[Ffmpeg-cvslog] r7566 - trunk/libavcodec/imgconvert.c

lu_zero subversion
Wed Jan 17 12:02:07 CET 2007


Author: lu_zero
Date: Wed Jan 17 12:02:07 2007
New Revision: 7566

Modified:
   trunk/libavcodec/imgconvert.c

Log:
Avoid branches in the loop and solve a gcc warning

Modified: trunk/libavcodec/imgconvert.c
==============================================================================
--- trunk/libavcodec/imgconvert.c	(original)
+++ trunk/libavcodec/imgconvert.c	Wed Jan 17 12:02:07 2007
@@ -2256,7 +2256,7 @@
             int pix_fmt, int padtop, int padbottom, int padleft, int padright,
             int *color)
 {
-    uint8_t *optr, *iptr;
+    uint8_t *optr;
     int y_shift;
     int x_shift;
     int yheight;
@@ -2274,24 +2274,30 @@
                 dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
         }
 
-        if (padleft || padright || src) {
-            if (src) { /* first line */
-                iptr = src->data[i];
-                optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
-                        (padleft >> x_shift);
-                memcpy(optr, iptr, src->linesize[i]);
-                iptr += src->linesize[i];
+        if (padleft || padright) {
+            optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+                (dst->linesize[i] - (padright >> x_shift));
+            yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
+            for (y = 0; y < yheight; y++) {
+                memset(optr, color[i], (padleft + padright) >> x_shift);
+                optr += dst->linesize[i];
             }
+        }
+
+        if (src) { /* first line */
+            uint8_t *iptr = src->data[i];
+            optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+                    (padleft >> x_shift);
+            memcpy(optr, iptr, src->linesize[i]);
+            iptr += src->linesize[i];
             optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
                 (dst->linesize[i] - (padright >> x_shift));
             yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
             for (y = 0; y < yheight; y++) {
                 memset(optr, color[i], (padleft + padright) >> x_shift);
-                if (src) {
-                    memcpy(optr + ((padleft + padright) >> x_shift), iptr,
-                        src->linesize[i]);
-                    iptr += src->linesize[i];
-                }
+                memcpy(optr + ((padleft + padright) >> x_shift), iptr,
+                    src->linesize[i]);
+                iptr += src->linesize[i];
                 optr += dst->linesize[i];
             }
         }




More information about the ffmpeg-cvslog mailing list