]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/svq3: Don't copy watermarked frame data twice
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 20 Mar 2021 17:58:23 +0000 (18:58 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 23 Mar 2021 12:51:18 +0000 (13:51 +0100)
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@gmail.com>
libavcodec/svq3.c

index 32accb148432a3aed1d9fc0d142227acc6de9830..edc8aeacc60002d0b99e6d5fe09732f1548c78ff 100644 (file)
@@ -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;
 }