ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / Platform / arm9_P6 / video_quantizer_p6.c
1 #include "video_quantizer_p6.h"
2 #include "video_utils_p6.h"
3 #include "video_config.h"
4
5 #ifdef HAS_DO_QUANTIZE_INTRA_MB
6 // when quantization is done by P6 hardware, do_quantize_intra_mb just count the number of coefficient and find the last one
7 int16_t* do_quantize_intra_mb(int16_t* ptr, int32_t invQuant, int32_t* last_ptr)
8 {
9         int32_t i, num_coeff;
10         int32_t last;
11         uint32_t* ptr32 = (uint32_t*)ptr;
12
13           for( i = 6; i > 0; i-- )
14           {
15                 last=0;
16                 ptr = (int16_t*)ptr32;
17                 if( *ptr == 0 )
18                 {
19               *ptr = 1;
20                 }
21
22                 num_coeff = MCU_BLOCK_SIZE/4;
23
24             while( num_coeff > 0 )
25             {
26                 // we load 2 coeff at a time
27                 uint32_t coeff2 = *ptr32++;
28                 num_coeff--;
29                         if (coeff2 > 0x0000FFFF)
30                                 last++;
31                         if ((coeff2<<16) > 0x0000FFFF)
32                                 last++;
33                         // next 2 coeffs (gcc will unroll the loop)
34                         coeff2 = *ptr32++;
35                         if (coeff2 > 0x0000FFFF)
36                                 last++;
37                         if ((coeff2<<16) > 0x0000FFFF)
38                                 last++;
39             }
40
41             *last_ptr++ = last;
42           }
43
44
45           return (int16_t*)ptr32;
46 }
47 #endif // HAS_DO_QUANTIZE_INTRA_MB