diff mbox series

[FFmpeg-devel,18/36] avcodec/bytestream: Add unchecked bytestream2 peek functions

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

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
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/bytestream.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h
index 0516a6e3dc..d0033f14f3 100644
--- a/libavcodec/bytestream.h
+++ b/libavcodec/bytestream.h
@@ -77,11 +77,15 @@  static av_always_inline type bytestream2_get_ ## name(GetByteContext *g)       \
     }                                                                          \
     return bytestream2_get_ ## name ## u(g);                                   \
 }                                                                              \
+static av_always_inline type bytestream2_peek_ ## name ## u(GetByteContext *g) \
+{                                                                              \
+    return read(g->buffer);                                                    \
+}                                                                              \
 static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g)      \
 {                                                                              \
     if (g->buffer_end - g->buffer < bytes)                                     \
         return 0;                                                              \
-    return read(g->buffer);                                                    \
+    return bytestream2_peek_ ## name ## u(g);                                  \
 }
 
 DEF(uint64_t,     le64, 8, AV_RL64, AV_WL64)