diff mbox series

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

Message ID 20200530160541.29517-9-andreas.rheinhardt@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/36] avcodec/vp9_superframe_bsf: Check for existence of data before reading it
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 30, 2020, 4:05 p.m. UTC
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@gmail.com>
---
 libavcodec/vp9_superframe_split_bsf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

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;
 }