diff mbox series

[FFmpeg-devel,10/36] avcodec/vp9_superframe_split_bsf: Use unchecked bytestream reader

Message ID 20200530160541.29517-10-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
It has already been checked that there is enough data available.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/vp9_superframe_split_bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anton Khirnov June 1, 2020, 9:33 a.m. UTC | #1
Quoting Andreas Rheinhardt (2020-05-30 18:05:15)
> It has already been checked that there is enough data available.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---

I don't see how this improves things. The only advantage of unchecked
reads is performance, but I don't think that is relevant here.
Otherwise, it just adds a non-obvious dependency on the check being
there and being correct (not to mention cluttering history).

IMO unchecked reads should be used ONLY when there are important
performance reasons to use them, otherwise checked reads should be used
even if they are not strictly necessary.
diff mbox series

Patch

diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c
index 48c3723206..9f9e495bd5 100644
--- a/libavcodec/vp9_superframe_split_bsf.c
+++ b/libavcodec/vp9_superframe_split_bsf.c
@@ -72,7 +72,7 @@  static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out)
                 for (i = 0; i < nb_frames; i++) {
                     unsigned frame_size = 0;
                     for (j = 0; j < length_size; j++)
-                        frame_size |= bytestream2_get_byte(&bc) << (j * 8);
+                        frame_size |= bytestream2_get_byteu(&bc) << (j * 8);
 
                     total_size += frame_size;
                     if (!frame_size || total_size > in->size - idx_size) {