[FFmpeg-cvslog] avcodec/svq3: Don't copy watermarked frame data twice

Andreas Rheinhardt git at videolan.org
Tue Mar 23 15:04:13 EET 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Mar 20 18:58:23 2021 +0100| [bcf707639e2eb308407cf5536153a27bdff91990] | committer: Andreas Rheinhardt

avcodec/svq3: Don't copy watermarked frame data twice

The SVQ3 decoder modifies the input bitstream at two places.
One of them is only reached when the file is watermarked.
Therefore commit 2264c1108135380c49fdf0aef97520bf77a6ed37
made a copy of all the frame data in this case.

But there is a second possibility for modifying the frame and
therefore Libav commit 1098f5c0495c61a98d4ff6b8e24c17974d4bace5
made the decoder always copy the data. This of course makes
the additional copy for watermarked frames redundant, but it hasn't
been removed. This commit does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/svq3.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 32accb1484..edc8aeacc6 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -97,8 +97,6 @@ typedef struct SVQ3Context {
     int thirdpel_flag;
     int has_watermark;
     uint32_t watermark_key;
-    uint8_t *buf;
-    int buf_size;
     int adaptive_quant;
     int next_p_frame_damaged;
     int h_edge_pos;
@@ -1383,7 +1381,6 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
     SVQ3Context *s     = avctx->priv_data;
     int buf_size       = avpkt->size;
     int left;
-    uint8_t *buf;
     int ret, m, i;
 
     /* special case for last picture */
@@ -1400,17 +1397,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
 
     s->mb_x = s->mb_y = s->mb_xy = 0;
 
-    if (s->watermark_key) {
-        av_fast_padded_malloc(&s->buf, &s->buf_size, buf_size);
-        if (!s->buf)
-            return AVERROR(ENOMEM);
-        memcpy(s->buf, avpkt->data, buf_size);
-        buf = s->buf;
-    } else {
-        buf = avpkt->data;
-    }
-
-    ret = init_get_bits(&s->gb, buf, 8 * buf_size);
+    ret = init_get_bits8(&s->gb, avpkt->data, avpkt->size);
     if (ret < 0)
         return ret;
 
@@ -1611,10 +1598,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx)
     av_freep(&s->edge_emu_buffer);
     av_freep(&s->mb2br_xy);
 
-
-    av_freep(&s->buf);
-    s->buf_size = 0;
-
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list