]> git.sesse.net Git - ffmpeg/commitdiff
swscale: replace formatConvBuffer[VOF] by allocated array.
authorRonald S. Bultje <rsbultje@gmail.com>
Thu, 26 May 2011 13:15:38 +0000 (09:15 -0400)
committerRonald S. Bultje <rsbultje@gmail.com>
Thu, 26 May 2011 13:31:02 +0000 (09:31 -0400)
This allows to convert between formats of arbitrary width,
regardless of the value of VOF/VOFW.

libswscale/swscale_internal.h
libswscale/swscale_template.c
libswscale/utils.c

index 5f2ff94691c36f7be6535e8465d09761d01458f2..1e52ea2a95863dfb45d9454f113c92a9783e0da9 100644 (file)
@@ -122,7 +122,7 @@ typedef struct SwsContext {
     int       chrBufIndex;        ///< Index in ring buffer of the last scaled horizontal chroma     line from source.
     //@}
 
-    uint8_t formatConvBuffer[VOF]; //FIXME dynamic allocation, but we have to change a lot of code for this to be useful
+    uint8_t *formatConvBuffer;
 
     /**
      * @name Horizontal and vertical filters.
index aeeb42815e050de641ce5ddeddb102314652ff72..8784359dc24e9ba4b94d1cb46f3e4e16efa8072f 100644 (file)
@@ -459,9 +459,10 @@ inline static void hcscale_c(SwsContext *c, uint16_t *dst, long dstWidth,
     src2 += c->chrSrcOffset;
 
     if (c->chrToYV12) {
-        c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
+        uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16);
+        c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal);
         src1= formatConvBuffer;
-        src2= formatConvBuffer+VOFW;
+        src2= buf2;
     }
 
     if (!c->hcscale_fast) {
index 96b3207cdd13efdc19a2c82dda6c60ef928edf9a..20f07d672eb2e5430d663cc378ef8411c3399465 100644 (file)
@@ -790,10 +790,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
                srcW, srcH, dstW, dstH);
         return AVERROR(EINVAL);
     }
-    if(srcW > VOFW || dstW > VOFW) {
-        av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
-        return AVERROR(EINVAL);
-    }
+    FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2, fail);
 
     if (!dstFilter) dstFilter= &dummyFilter;
     if (!srcFilter) srcFilter= &dummyFilter;
@@ -1507,6 +1504,7 @@ void sws_freeContext(SwsContext *c)
 #endif /* HAVE_MMX */
 
     av_freep(&c->yuvTable);
+    av_free(c->formatConvBuffer);
 
     av_free(c);
 }