[FFmpeg-devel] [PATCH 19/36] avcodec/hevc_mp4toannexb_bsf: Use unchecked bytestream2 API

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


We already check manually and error out on invalid data, so we don't
have to rely on the implicit checks provided by the safe version of the
bytestream2 API.

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

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
index ba1deb2848..634bfe9c46 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -147,14 +147,14 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
             goto fail;
         }
         for (i = 0; i < s->length_size; i++)
-            nalu_size = (nalu_size << 8) | bytestream2_get_byte(&gb);
+            nalu_size = (nalu_size << 8) | bytestream2_get_byteu(&gb);
 
         if (nalu_size < 2 || nalu_size > bytestream2_get_bytes_left(&gb)) {
             ret = AVERROR_INVALIDDATA;
             goto fail;
         }
 
-        nalu_type = (bytestream2_peek_byte(&gb) >> 1) & 0x3f;
+        nalu_type = (bytestream2_peek_byteu(&gb) >> 1) & 0x3f;
 
         /* prepend extradata to IRAP frames */
         is_irap       = nalu_type >= 16 && nalu_type <= 23;
@@ -176,7 +176,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
         if (extra_size)
             memcpy(out->data + prev_size, ctx->par_out->extradata, extra_size);
         AV_WB32(out->data + prev_size + extra_size, 1);
-        bytestream2_get_buffer(&gb, out->data + prev_size + 4 + extra_size, nalu_size);
+        bytestream2_get_bufferu(&gb, out->data + prev_size + 4 + extra_size, nalu_size);
     }
 
     ret = av_packet_copy_props(out, in);
-- 
2.20.1



More information about the ffmpeg-devel mailing list