[FFmpeg-devel] [PATCH 09/36] avcodec/vp9_superframe_split_bsf: Don't restrict frame_size to INT_MAX/8

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat May 30 19:05:14 EEST 2020


By using a GetBitContext with a packet's data as buffer, one restricts
said packet to a size of about INT_MAX/8. This restriction is not
onerous, but unnecessary: The bitreader is only used to read the first
byte of data. So change it.

Furthermore, given that it has already been checked that the packet's
size is > 0, one can omit the check for whether init_get_bits() succeeds
and stop unreferencing the packet destined for output on failure as it
now never contains any data upon failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/vp9_superframe_split_bsf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c
index df5b964414..48c3723206 100644
--- a/libavcodec/vp9_superframe_split_bsf.c
+++ b/libavcodec/vp9_superframe_split_bsf.c
@@ -108,9 +108,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out)
         if (s->next_frame >= s->nb_frames)
             av_packet_unref(s->buffer_pkt);
 
-        ret = init_get_bits8(&gb, out->data, out->size);
-        if (ret < 0)
-            goto fail;
+        init_get_bits(&gb, out->data, 8);
 
         get_bits(&gb, 2); // frame_marker
         profile  = get_bits1(&gb);
@@ -131,8 +129,6 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out)
 
     return 0;
 fail:
-    if (ret < 0)
-        av_packet_unref(out);
     av_packet_unref(s->buffer_pkt);
     return ret;
 }
-- 
2.20.1



More information about the ffmpeg-devel mailing list