[FFmpeg-devel] [PATCH] avcodec/cbs_av1: change the assert in trailing_bits to accept zero bits when reading
James Almer
jamrial at gmail.com
Sun Feb 10 22:12:00 EET 2019
If nb_bits is zero when reading an OBU, then it's not a bug in CBS but an
invalid bitstream, and we should abort gracefully instead.
Signed-off-by: James Almer <jamrial at gmail.com>
---
rav1e is currently encoding invalid Metadata OBUs without trailing bits, which
are triggering the assert when parsed by CBS. This change makes sure to instead
report the bitstream as invalid and gracefully return with an error code
instead of crashing.
libavcodec/cbs_av1_syntax_template.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 48f4fab514..02b4ed221c 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -45,7 +45,11 @@ static int FUNC(trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw, int nb
{
int err;
+#ifdef READ
+ av_assert0(nb_bits >= 0);
+#else
av_assert0(nb_bits > 0);
+#endif
fixed(1, trailing_one_bit, 1);
--nb_bits;
--
2.20.1
More information about the ffmpeg-devel
mailing list