ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / Platform / arm9 / video_utils.c
1 #include <VLIB/video_controller.h>
2 #include <VLIB/video_picture.h>
3
4 #include <VLIB/Platform/video_config.h>
5 #include <VLIB/Platform/video_utils.h>
6
7 #include <stdio.h>
8
9 static uint32_t num_references = 0;
10
11 #if (VIDEO_DCT_USE_INTRAM == 1)
12 // Put DMA buffer into INTRAM, this should avoid bus contention with CAMIF
13 static int16_t dct_buffer[2*DCT_BUFFER_SIZE] __attribute__((aligned(CACHE_DLINESIZE), section(".data.fast")));
14 #endif
15
16 C_RESULT video_utils_init( video_controller_t* controller )
17 {
18   if( num_references == 0 )
19   {
20 #if (VIDEO_DCT_USE_INTRAM == 1)
21     // Put in non cached INTRAM
22     controller->blockline_cache = (int16_t*) (((CYG_ADDRESS) &dct_buffer[0]) + CYGMEM_REGION_intram_SHADOW - CYGMEM_REGION_intram);
23 #endif
24   }
25
26   num_references ++;
27
28   return C_OK;
29 }
30
31 C_RESULT video_utils_close( video_controller_t* controller )
32 {
33   if( num_references > 0 )
34   {
35     num_references --;
36
37     if( num_references == 0 )
38     {
39 #if (VIDEO_DCT_USE_INTRAM == 1)
40       // Put in non cached INTRAM
41       controller->blockline_cache = NULL;
42 #endif
43     }
44   }
45
46   return C_OK;
47 }
48
49 uint32_t ramcode_format_shifter_op_imm(uint32_t imm)
50 {
51   uint32_t shifter, imm8;
52
53   shifter = 32/2;
54   imm8    = imm;
55
56   while( (imm8 & 0xFF) != imm8 )
57   {
58     imm8 >>= 2;
59     shifter --;
60   }
61
62   if( (imm8 << (32-shifter*2)) != imm )
63     return 0xFFFFFFFF;
64
65   if( shifter == 16 )
66     shifter = 0;
67
68   return (shifter << 8 | imm8);
69 }
70
71 C_RESULT video_utils_set_format( uint32_t width, uint32_t height )
72 {
73   return C_OK;
74 }