ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / P264 / p264_merge.c
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VLIB/P264/p264_merge.c b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VLIB/P264/p264_merge.c
new file mode 100644 (file)
index 0000000..9ca7f58
--- /dev/null
@@ -0,0 +1,42 @@
+#include <VLIB/P264/p264_merge.h>
+
+// merge scaled residual data from iTransform and prediction data already located in the output picture
+void p264_merge_4x4 (int16_t* residual,uint8_t* picture, uint32_t x, uint32_t y, uint32_t linesize)
+{
+  uint32_t i;
+  int16_t pixel;
+  picture += y*linesize+x;
+  for (i=0;i<4;i++)
+  {
+    pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
+    if (pixel > 0xFF)
+      *picture++ = 0xFF;
+    else if (pixel < 0)
+      *picture++ = 0;
+    else
+      *picture++ = pixel;
+    pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
+    if (pixel > 0xFF)
+      *picture++ = 0xFF;
+    else if (pixel < 0)
+      *picture++ = 0;
+    else
+      *picture++ = pixel;
+    pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
+    if (pixel > 0xFF)
+      *picture++ = 0xFF;
+    else if (pixel < 0)
+      *picture++ = 0;
+    else
+      *picture++ = pixel;
+    pixel = (int16_t)(((int16_t)*picture) + (((*residual++)+32)>>6));
+    if (pixel > 0xFF)
+      *picture = 0xFF;
+    else if (pixel < 0)
+      *picture = 0;
+    else
+      *picture = pixel;
+    // jump to next line
+    picture += linesize-3;
+  }
+}