]> git.sesse.net Git - ffmpeg/commitdiff
Check if chroma horizontal scaler is needed in sws_init_swScale().
authorRamiro Polla <ramiro.polla@gmail.com>
Mon, 21 Dec 2009 01:34:45 +0000 (01:34 +0000)
committerRamiro Polla <ramiro.polla@gmail.com>
Mon, 21 Dec 2009 01:34:45 +0000 (01:34 +0000)
Originally committed as revision 30096 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale

libswscale/swscale_internal.h
libswscale/swscale_template.c

index f60ffb0a111bcca2de5b20661d80dca88ed8d7ce..eb73fa6daef0fee0df021ce9040751e3c150e7cf 100644 (file)
@@ -279,6 +279,8 @@ typedef struct SwsContext {
     int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions.
     int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions.
 
+    int needs_hcscale; ///< Set if there are chroma planes to be converted.
+
 } SwsContext;
 //FIXME check init (where 0)
 
index 9208a07498435bae0591a567fe39f63b0745ae0c..3c6c8ebe8d14085a04e7e932999ef3a4b12f2a12 100644 (file)
@@ -2438,9 +2438,6 @@ inline static void RENAME(hcscale)(SwsContext *c, uint16_t *dst, long dstWidth,
     int     av_unused canMMX2BeUsed  = c->canMMX2BeUsed;
     void    av_unused *mmx2FilterCode= c->chrMmx2FilterCode;
 
-    if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
-        return;
-
     src1 += c->chrSrcOffset;
     src2 += c->chrSrcOffset;
 
@@ -2717,7 +2714,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
             assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);
             //FIXME replace parameters through context struct (some at least)
 
-            if (!(isGray(srcFormat) || isGray(dstFormat)))
+            if (c->needs_hcscale)
                 RENAME(hcscale)(c, chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
                                 flags, hChrFilter, hChrFilterPos, hChrFilterSize,
                                 c->srcFormat, formatConvBuffer,
@@ -3067,4 +3064,8 @@ static void RENAME(sws_init_swScale)(SwsContext *c)
             c->chrConvertRange = RENAME(chrRangeToJpeg);
         }
     }
+
+    if (!(isGray(srcFormat) || isGray(c->dstFormat) ||
+          srcFormat == PIX_FMT_MONOBLACK || srcFormat == PIX_FMT_MONOWHITE))
+        c->needs_hcscale = 1;
 }