[FFmpeg-cvslog] avcodec/snow: only allocate space for edges when encoding

Michael Niedermayer git at videolan.org
Wed Jul 16 05:04:14 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jul 16 04:57:42 2014 +0200| [aa1d096d027be4fe901062f04a0b2adfb75af82f] | committer: Michael Niedermayer

avcodec/snow: only allocate space for edges when encoding

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/snow.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index e3518eb..7cce7a5 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -69,19 +69,26 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_
 int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
 {
     int ret, i;
+    int edges_needed = av_codec_is_encoder(s->avctx->codec);
 
-    frame->width  = s->avctx->width  + 2 * EDGE_WIDTH;
-    frame->height = s->avctx->height + 2 * EDGE_WIDTH;
+    frame->width  = s->avctx->width ;
+    frame->height = s->avctx->height;
+    if (edges_needed) {
+        frame->width  += 2 * EDGE_WIDTH;
+        frame->height += 2 * EDGE_WIDTH;
+    }
     if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
         return ret;
-    for (i = 0; frame->data[i]; i++) {
-        int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
-                        frame->linesize[i] +
-                        (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
-        frame->data[i] += offset;
+    if (edges_needed) {
+        for (i = 0; frame->data[i]; i++) {
+            int offset = (EDGE_WIDTH >> (i ? s->chroma_v_shift : 0)) *
+                            frame->linesize[i] +
+                            (EDGE_WIDTH >> (i ? s->chroma_h_shift : 0));
+            frame->data[i] += offset;
+        }
+        frame->width  = s->avctx->width;
+        frame->height = s->avctx->height;
     }
-    frame->width  = s->avctx->width;
-    frame->height = s->avctx->height;
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list