From: Nicolas Gaullier <nicolas.gaullier@cji.paris> To: ffmpeg-devel@ffmpeg.org Cc: Nicolas Gaullier <nicolas.gaullier@cji.paris> Subject: [FFmpeg-devel] [PATCH 1/1] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits Date: Fri, 10 Mar 2023 10:17:53 +0100 Message-ID: <20230310091753.10230-2-nicolas.gaullier@cji.paris> (raw) In-Reply-To: <20230310091753.10230-1-nicolas.gaullier@cji.paris> Mantissas are the last data in the channel subsegment and it appears it is sometimes missing a very few bits for the parsing to complete. This should not be confused with data corruption. For 5.1+2@25fps, the occurence of this issue is pretty steady and about once every 2 hours. The truncation is at about 950 out of the 1024 values (never seen below 923 so far). The current code raises a severe 'Read past end' error and all data is lost resulting in 20ms(@25fps) of silence for the affected channel. This patch introduces a tolerance: if 800 out of the 1024 mantissas have been parsed, a simple warning is raised and the data is preserved. Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris> --- libavcodec/dolby_e.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 921c33f3ba..a24edfcc93 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -845,6 +845,7 @@ static int parse_indices(DBEContext *s, DBEChannel *c) return 0; } +#define MIN_MANTISSAS 800 static int parse_mantissas(DBEContext *s, DBEChannel *c) { DBEGroup *g; @@ -885,6 +886,14 @@ static int parse_mantissas(DBEContext *s, DBEChannel *c) } } } else { + if (i == c->nb_groups - 1 + && count * size1 > get_bits_left(&s->gb) + && get_bits_left(&s->gb) >= 0 + && (int)(mnt - c->mantissas) >= MIN_MANTISSAS) { + av_log(s->avctx, AV_LOG_WARNING, "Truncated mantissas @%d, " + "highest frequencies not recoverable\n", (int)(mnt - c->mantissas)); + break; + } for (k = 0; k < count; k++) mnt[k] = get_sbits(&s->gb, size1) * scale; } -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-03-10 9:18 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-10 9:17 [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier 2023-03-10 9:17 ` Nicolas Gaullier [this message] 2023-03-13 13:05 ` [FFmpeg-devel] [PATCH 1/1] " Tomas Härdin 2023-03-13 15:07 ` Nicolas Gaullier 2024-03-11 14:01 [FFmpeg-devel] [PATCH 0/1] " Nicolas Gaullier 2024-03-11 14:01 ` [FFmpeg-devel] [PATCH 1/1] " Nicolas Gaullier 2024-03-26 16:16 ` Nicolas Gaullier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230310091753.10230-2-nicolas.gaullier@cji.paris \ --to=nicolas.gaullier@cji.paris \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git