changeset 30039:3b0026eb9c4d

Set horizontal scaler's src offsets in context in sws_init_swScale().
author ramiro
date Sun, 20 Dec 2009 16:21:25 +0000
parents d1c5b275d3f9
children 79adcc3e4e83
files libswscale/swscale_internal.h libswscale/swscale_template.c
diffstat 2 files changed, 24 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale_internal.h	Sun Dec 20 15:16:34 2009 +0000
+++ b/libswscale/swscale_internal.h	Sun Dec 20 16:21:25 2009 +0000
@@ -273,6 +273,10 @@
                    int xInc, const int16_t *filter, const int16_t *filterPos,
                    long filterSize);
 
+    int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions.
+    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.
+
 } SwsContext;
 //FIXME check init (where 0)
 
--- a/libswscale/swscale_template.c	Sun Dec 20 15:16:34 2009 +0000
+++ b/libswscale/swscale_template.c	Sun Dec 20 16:21:25 2009 +0000
@@ -2254,16 +2254,7 @@
     void    av_unused *mmx2FilterCode= c->lumMmx2FilterCode;
     void (*internal_func)(uint8_t *, const uint8_t *, long, uint32_t *) = isAlpha ? c->hascale_internal : c->hyscale_internal;
 
-    if (isAlpha) {
-        if (srcFormat == PIX_FMT_RGB32   || srcFormat == PIX_FMT_BGR32  )
-            src += 3;
-    } else {
-        if (srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
-            src += ALT32_CORR;
-    }
-
-    if (srcFormat == PIX_FMT_RGB48LE)
-        src++;
+    src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset;
 
     if (internal_func) {
         internal_func(formatConvBuffer, src, srcW, pal);
@@ -2433,15 +2424,8 @@
     if (isGray(srcFormat) || srcFormat==PIX_FMT_MONOBLACK || srcFormat==PIX_FMT_MONOWHITE)
         return;
 
-    if (srcFormat==PIX_FMT_RGB32_1 || srcFormat==PIX_FMT_BGR32_1) {
-        src1 += ALT32_CORR;
-        src2 += ALT32_CORR;
-    }
-
-    if (srcFormat==PIX_FMT_RGB48LE) {
-        src1++;
-        src2++;
-    }
+    src1 += c->chrSrcOffset;
+    src2 += c->chrSrcOffset;
 
     if (c->hcscale_internal) {
         c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
@@ -3049,4 +3033,21 @@
         case PIX_FMT_BGR32_1: c->hascale_internal = abgrToA; break;
         }
     }
+
+    switch (srcFormat) {
+    case PIX_FMT_RGB32  :
+    case PIX_FMT_BGR32  :
+        c->alpSrcOffset = 3;
+        break;
+    case PIX_FMT_RGB32_1:
+    case PIX_FMT_BGR32_1:
+        c->lumSrcOffset = ALT32_CORR;
+        c->chrSrcOffset = ALT32_CORR;
+        break;
+    case PIX_FMT_RGB48LE:
+        c->lumSrcOffset = 1;
+        c->chrSrcOffset = 1;
+        c->alpSrcOffset = 1;
+        break;
+    }
 }