ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / P264 / p264_merge.c
1 #include <VLIB/P264/p264_merge.h>
2
3 // merge scaled residual data from iTransform and prediction data already located in the output picture
4 void p264_merge_4x4 (int16_t* residual,uint8_t* picture, uint32_t x, uint32_t y, uint32_t linesize)
5 {
6   uint32_t i;
7   int16_t pixel;
8   picture += y*linesize+x;
9   for (i=0;i<4;i++)
10   {
11     pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
12     if (pixel > 0xFF)
13       *picture++ = 0xFF;
14     else if (pixel < 0)
15       *picture++ = 0;
16     else
17       *picture++ = pixel;
18     pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
19     if (pixel > 0xFF)
20       *picture++ = 0xFF;
21     else if (pixel < 0)
22       *picture++ = 0;
23     else
24       *picture++ = pixel;
25     pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
26     if (pixel > 0xFF)
27       *picture++ = 0xFF;
28     else if (pixel < 0)
29       *picture++ = 0;
30     else
31       *picture++ = pixel;
32     pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
33     if (pixel > 0xFF)
34       *picture = 0xFF;
35     else if (pixel < 0)
36       *picture = 0;
37     else
38       *picture = pixel;
39     // jump to next line
40     picture += linesize-3;
41   }
42 }