utvideoenc: optimize and simplify mangle_rgb_planes
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 22 Aug 2012 00:47:32 +0000 (02:47 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 22 Aug 2012 14:49:53 +0000 (16:49 +0200)
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/utvideoenc.c

index f3ba739..95205ea 100644 (file)
@@ -196,16 +196,13 @@ static void mangle_rgb_planes(uint8_t *src, int step, int stride, int width,
                               int height)
 {
     int i, j;
-    uint8_t r, g, b;
+    unsigned g;
 
     for (j = 0; j < height; j++) {
         for (i = 0; i < width * step; i += step) {
-            r = src[i];
-            g = src[i + 1];
-            b = src[i + 2];
-
-            src[i]     = r - g + 0x80;
-            src[i + 2] = b - g + 0x80;
+            g           = src[i + 1] + 0x80;
+            src[i]     -= g;
+            src[i + 2] -= g;
         }
         src += stride;
     }