From e12dabcd04fc59677660fce8fc9437931d141e93 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 3 Mar 2024 14:59:46 +0100 Subject: [PATCH] nihav_itu: ignore high-profile extradata tail when it is not correct --- nihav-itu/src/codecs/h264/decoder_mt.rs | 5 ++++- nihav-itu/src/codecs/h264/decoder_st.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nihav-itu/src/codecs/h264/decoder_mt.rs b/nihav-itu/src/codecs/h264/decoder_mt.rs index f66ce2f..cdddfec 100644 --- a/nihav-itu/src/codecs/h264/decoder_mt.rs +++ b/nihav-itu/src/codecs/h264/decoder_mt.rs @@ -769,7 +769,10 @@ impl NADecoderMT for H264MTDecoder { match profile { 100 | 110 | 122 | 144 => { let b = br.read_byte()?; - validate!((b & 0xFC) == 0xFC); + // some encoders put something different here + if (b & 0xFC) != 0xFC { + return Ok(()); + } // b & 3 -> chroma format let b = br.read_byte()?; validate!((b & 0xF8) == 0xF8); diff --git a/nihav-itu/src/codecs/h264/decoder_st.rs b/nihav-itu/src/codecs/h264/decoder_st.rs index 94b3977..fad0dd9 100644 --- a/nihav-itu/src/codecs/h264/decoder_st.rs +++ b/nihav-itu/src/codecs/h264/decoder_st.rs @@ -756,7 +756,10 @@ impl NADecoder for H264Decoder { match profile { 100 | 110 | 122 | 144 => { let b = br.read_byte()?; - validate!((b & 0xFC) == 0xFC); + // some encoders put something different here + if (b & 0xFC) != 0xFC { + return Ok(()); + } // b & 3 -> chroma format let b = br.read_byte()?; validate!((b & 0xF8) == 0xF8); -- 2.39.5