You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/dovi_rpudec: parse RPU forward, don't try to find end
Instead of scanning backwards for the end of RPU payload, parse it and report if we didn't land at the terminator byte. Current expectation was that we can have additional zero bytes after RPU payload, which were skipped to find playload end. That's not always the case. So loosen this requirement. This fixes files where there is additional non-zeroed padding after the end of the RPU in NALU. Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
committed by
Niklas Haas
parent
bf640b53db
commit
ef167512ab
@ -408,22 +408,6 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
|
|||||||
VALIDATE(rpu[0], 25, 25); /* NAL prefix */
|
VALIDATE(rpu[0], 25, 25); /* NAL prefix */
|
||||||
rpu++;
|
rpu++;
|
||||||
rpu_size--;
|
rpu_size--;
|
||||||
/* Strip trailing padding bytes */
|
|
||||||
while (rpu_size && rpu[rpu_size - 1] == 0)
|
|
||||||
rpu_size--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rpu_size || rpu[rpu_size - 1] != 0x80)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
|
|
||||||
if (err_recognition & AV_EF_CRCCHECK) {
|
|
||||||
uint32_t crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),
|
|
||||||
-1, rpu, rpu_size - 1)); /* exclude 0x80 */
|
|
||||||
if (crc) {
|
|
||||||
av_log(s->logctx, AV_LOG_ERROR, "RPU CRC mismatch: %X\n", crc);
|
|
||||||
if (err_recognition & AV_EF_EXPLODE)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = init_get_bits8(gb, rpu, rpu_size)) < 0)
|
if ((ret = init_get_bits8(gb, rpu, rpu_size)) < 0)
|
||||||
@ -738,5 +722,26 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size,
|
|||||||
av_refstruct_unref(&s->ext_blocks);
|
av_refstruct_unref(&s->ext_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
align_get_bits(gb);
|
||||||
|
skip_bits(gb, 32); /* CRC32 */
|
||||||
|
if (get_bits(gb, 8) != 0x80) {
|
||||||
|
avpriv_request_sample(s->logctx, "Unexpected RPU format");
|
||||||
|
ff_dovi_ctx_unref(s);
|
||||||
|
return AVERROR_PATCHWELCOME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err_recognition & AV_EF_CRCCHECK) {
|
||||||
|
rpu_size = get_bits_count(gb) / 8;
|
||||||
|
uint32_t crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),
|
||||||
|
-1, rpu, rpu_size - 1)); /* exclude 0x80 */
|
||||||
|
if (crc) {
|
||||||
|
av_log(s->logctx, AV_LOG_ERROR, "RPU CRC mismatch: %X\n", crc);
|
||||||
|
if (err_recognition & AV_EF_EXPLODE) {
|
||||||
|
ff_dovi_ctx_unref(s);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user