* [FFmpeg-devel] [PATCH] avocdec/flac_parser: another fix
@ 2022-09-05 18:19 Paul B Mahol
2022-09-07 10:31 ` Mattias Wadman
0 siblings, 1 reply; 3+ messages in thread
From: Paul B Mahol @ 2022-09-05 18:19 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 16 bytes --]
Patch attached.
[-- Attachment #2: 0001-avcodec-flac_parser-add-missed-opportunity-to-check-.patch --]
[-- Type: text/x-patch, Size: 1759 bytes --]
From 01e931d2c7f50727d8893268cdc3ae0dbe75c250 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Mon, 5 Sep 2022 20:16:13 +0200
Subject: [PATCH] avcodec/flac_parser: add missed opportunity to check crc
Fixes #9621
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavcodec/flac_parser.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index 11cd5540cf..dd70721696 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -455,7 +455,7 @@ static int check_header_mismatch(FLACParseContext *fpc,
int log_level_offset)
{
FLACFrameInfo *header_fi = &header->fi, *child_fi = &child->fi;
- int deduction, deduction_expected = 0, i;
+ int check_crc, deduction, deduction_expected = 0, i;
deduction = check_header_fi_mismatch(fpc, header_fi, child_fi,
log_level_offset);
/* Check sample and frame numbers. */
@@ -491,8 +491,15 @@ static int check_header_mismatch(FLACParseContext *fpc,
"sample/frame number mismatch in adjacent frames\n");
}
+ if ((fpc->last_fi.frame_or_sample_num + 1 == header_fi->frame_or_sample_num) ||
+ (fpc->last_fi.frame_or_sample_num + fpc->last_fi.blocksize == header_fi->frame_or_sample_num)) {
+ check_crc = 0;
+ } else {
+ check_crc = !deduction && !deduction_expected;
+ }
+
/* If we have suspicious headers, check the CRC between them */
- if (deduction && !deduction_expected) {
+ if (check_crc || (deduction && !deduction_expected)) {
FLACHeaderMarker *curr;
int read_len;
uint8_t *buf;
--
2.37.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] avocdec/flac_parser: another fix
2022-09-05 18:19 [FFmpeg-devel] [PATCH] avocdec/flac_parser: another fix Paul B Mahol
@ 2022-09-07 10:31 ` Mattias Wadman
2022-09-07 10:51 ` Paul B Mahol
0 siblings, 1 reply; 3+ messages in thread
From: Mattias Wadman @ 2022-09-07 10:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Sep 5, 2022 at 8:16 PM Paul B Mahol <onemda@gmail.com> wrote:
> Patch attached.
>
Thanks and can confirm that the patch produces the same samples as the flac
reference decoder for the original file in
https://trac.ffmpeg.org/ticket/9621 that I could not share.
But I'm not sure I follow how the patch works. I read it as we skip
checking CRC if the current frame or sample number is the expected next one?
+ if ((fpc->last_fi.frame_or_sample_num + 1 ==
header_fi->frame_or_sample_num) ||
+ (fpc->last_fi.frame_or_sample_num + fpc->last_fi.blocksize ==
header_fi->frame_or_sample_num)) {
Would it make sense to look at the blocking strategy bit to know which one
to check?
_______________________________________________
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] avocdec/flac_parser: another fix
2022-09-07 10:31 ` Mattias Wadman
@ 2022-09-07 10:51 ` Paul B Mahol
0 siblings, 0 replies; 3+ messages in thread
From: Paul B Mahol @ 2022-09-07 10:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, Sep 7, 2022 at 12:31 PM Mattias Wadman <mattias.wadman@gmail.com>
wrote:
> On Mon, Sep 5, 2022 at 8:16 PM Paul B Mahol <onemda@gmail.com> wrote:
>
> > Patch attached.
> >
>
> Thanks and can confirm that the patch produces the same samples as the flac
> reference decoder for the original file in
> https://trac.ffmpeg.org/ticket/9621 that I could not share.
>
> But I'm not sure I follow how the patch works. I read it as we skip
> checking CRC if the current frame or sample number is the expected next
> one?
>
It always force CRC check if they do not match, previously code would do
that sometimes.
>
> + if ((fpc->last_fi.frame_or_sample_num + 1 ==
> header_fi->frame_or_sample_num) ||
> + (fpc->last_fi.frame_or_sample_num + fpc->last_fi.blocksize ==
> header_fi->frame_or_sample_num)) {
>
> Would it make sense to look at the blocking strategy bit to know which one
> to check?
>
Could be.
_______________________________________________
> 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".
>
_______________________________________________
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-09-07 10:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 18:19 [FFmpeg-devel] [PATCH] avocdec/flac_parser: another fix Paul B Mahol
2022-09-07 10:31 ` Mattias Wadman
2022-09-07 10:51 ` Paul B Mahol
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