[FFmpeg-cvslog] swscale: replace formatConvBuffer[VOF] by allocated array.

Ronald S. Bultje git at videolan.org
Sun May 29 01:02:07 CEST 2011


ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Thu May 26 09:15:38 2011 -0400| [485d73ef215323ead6cb58a83853d1f6b52ede54] | committer: Michael Niedermayer

swscale: replace formatConvBuffer[VOF] by allocated array.

This allows to convert between formats of arbitrary width,
regardless of the value of VOF/VOFW.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=485d73ef215323ead6cb58a83853d1f6b52ede54
---

 libswscale/swscale_internal.h |    2 +-
 libswscale/swscale_template.c |    5 +++--
 libswscale/utils.c            |    2 ++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 70eec62..9f656c9 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -118,7 +118,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 586614f..2957aa4 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -490,9 +490,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*2+78, 16);
+        c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal);
         src1= formatConvBuffer;
-        src2= formatConvBuffer+VOFW;
+        src2= buf2;
     }
 
     if (c->hScale16) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index eba7f82..b0548dc 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -798,6 +798,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
         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*2+78, 16) * 2, fail);
 
     if (!dstFilter) dstFilter= &dummyFilter;
     if (!srcFilter) srcFilter= &dummyFilter;
@@ -1522,6 +1523,7 @@ void sws_freeContext(SwsContext *c)
 #endif /* HAVE_MMX */
 
     av_freep(&c->yuvTable);
+    av_freep(&c->formatConvBuffer);
 
     av_free(c);
 }



More information about the ffmpeg-cvslog mailing list