This allows to convert between formats of arbitrary width,
regardless of the value of VOF/VOFW.
---
 libswscale/swscale_internal.h |    2 +-
 libswscale/swscale_template.c |    4 ++--
 libswscale/utils.c            |    6 ++----
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 5f2ff94..1e52ea2 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -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.
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index 49d594a..70bd2fb 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -461,9 +461,9 @@ 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);
+        c->chrToYV12(formatConvBuffer, formatConvBuffer+srcW, src1, src2, 
srcW, pal);
         src1= formatConvBuffer;
-        src2= formatConvBuffer+VOFW;
+        src2= formatConvBuffer+srcW;
     }
 
     if (!c->hcscale_fast) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 29fc975..a531346 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -791,10 +791,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, srcW * 2, fail);
 
     if (!dstFilter) dstFilter= &dummyFilter;
     if (!srcFilter) srcFilter= &dummyFilter;
@@ -1508,6 +1505,7 @@ void sws_freeContext(SwsContext *c)
 #endif /* HAVE_MMX */
 
     av_freep(&c->yuvTable);
+    av_free(c->formatConvBuffer);
 
     av_free(c);
 }
-- 
1.7.4.4

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to