PR #23319 opened by Kacper Michajłow (kasper93) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23319 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23319.patch
On some files when we land already at a byte boundary, there is full padding byte added by the encoder. Skip this byte and also validate it's zero as the alignment padding should be. It is likely just an encoder quirk that adds padding always, and if it is aligned, it does full additional byte. From 0bb33156808a4b79c8b6d3bc214f6877b618c4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]> Date: Wed, 3 Jun 2026 17:42:24 +0200 Subject: [PATCH] avcodec/dovi_rpudec: skip full padding byte if it is already aligned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some files when we land already at a byte boundary, there is full padding byte added by the encoder. Skip this byte and also validate it's zero as the alignment padding should be. It is likely just an encoder quirk that adds padding always, and if it is aligned, it does full additional byte. Signed-off-by: Kacper Michajłow <[email protected]> --- libavcodec/dovi_rpudec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c index d210ba52cf..5a5e921dc6 100644 --- a/libavcodec/dovi_rpudec.c +++ b/libavcodec/dovi_rpudec.c @@ -719,6 +719,17 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, av_refstruct_unref(&s->ext_blocks); } + /* On some files when we land already at a byte boundary, there is full + * padding byte added by the encoder. */ + if (get_bits_count(gb) % 8 == 0) { + unsigned pad = get_bits(gb, 8); + if (pad && (err_recognition & (AV_EF_COMPLIANT | AV_EF_CAREFUL))) { + av_log(s->logctx, AV_LOG_ERROR, "Nonzero Dolby Vision RPU " + "alignment padding: 0x%02x\n", pad); + ff_dovi_ctx_unref(s); + return AVERROR_INVALIDDATA; + } + } align_get_bits(gb); skip_bits(gb, 32); /* CRC32 */ if (get_bits(gb, 8) != 0x80) { -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
