Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits
@ 2022-09-13 21:31 Nicolas Gaullier
  2022-09-16  8:28 ` Nicolas Gaullier
  2022-10-14  8:03 ` Nicolas Gaullier
  0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Gaullier @ 2022-09-13 21:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nicolas Gaullier

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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index 06f4fdd44f..0ec7b5e318 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -844,6 +844,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;
@@ -884,6 +885,13 @@ 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.11.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits
  2022-09-13 21:31 [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits Nicolas Gaullier
@ 2022-09-16  8:28 ` Nicolas Gaullier
  2022-10-14  8:03 ` Nicolas Gaullier
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Gaullier @ 2022-09-16  8:28 UTC (permalink / raw)
  To: ffmpeg-devel

>Envoyé : mardi 13 septembre 2022 23:31
>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.

Here is a very short sample set with an audacity screen grab which shows the effect of the fix:
http://0x0.st/oOvv.zip

I don't know how to make this patch acceptable... and especially I understand that setting an arbitrary limit with a #define does not look to be the best practice in the world.
The fact is that the reference implementation (checked against dp600 and a certified broadcast encoder) does handle that (maybe with no limit at all, hard to tell).
Do you have any suggestion ?
If it can help, I can post a message to ffmpeg-user to gain more users support ?

Nicolas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits
  2022-09-13 21:31 [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits Nicolas Gaullier
  2022-09-16  8:28 ` Nicolas Gaullier
@ 2022-10-14  8:03 ` Nicolas Gaullier
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Gaullier @ 2022-10-14  8:03 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: BUCCIANTINI Francesco - ADECCO

>Envoyé : mardi 13 septembre 2022 23:31

>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.

I did not received any feedback yet (except trivial wrap-lines warning from patchwork).
I tried to contact foobaz86@gmail.com > 2 weeks ago, but with no answer, I fear there is nobody behind the screen.
And no activity in https://github.com/foo86 for 5 years.

Maybe MAINTAINERS should be updated ?

There are a lot of things to come as DolbyED2 support (rawly already decodable with current code) and broader avformats support,
so this is not only about this single interoperability point issue.

Thank you for your support
Nicolas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-14  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 21:31 [FFmpeg-devel] [PATCH] avcodec/dolby_e: Add error recovery when parse_mantissas run out of bits Nicolas Gaullier
2022-09-16  8:28 ` Nicolas Gaullier
2022-10-14  8:03 ` Nicolas Gaullier

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