diff mbox series

[FFmpeg-devel,06/15] flac: Increase change penalty and header lookahead

Message ID e93cbcf79ea1f1ff652d94838383b41f3a9896d8.camel@haerdin.se
State New
Headers show
Series Spotify patchset | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Tomas Härdin Oct. 29, 2024, 2:48 p.m. UTC
Needs sample

'Revert "flac: Increase change penalty and header lookahead"' reverts
this, so it seems it's no longer necessary. I therefore haven't
bothered mailing in that patch

Spotify comments
----------------
Decrease possibility for flac demuxer frame detect heuristics to find
false frame starts.

Possible other solutions:
    • Some other way to improve heuristics
    • Make it possible to disable flac demuxer frame heuristics and
instead demux on frame at a time with loss of parallelism.

/Tomas
diff mbox series

Patch

From 2967391f86834de9ca3b549f52804ce2c06ab797 Mon Sep 17 00:00:00 2001
From: Mattias Wadman <wader@spotify.com>
Date: Wed, 8 Dec 2021 14:16:56 +0100
Subject: [PATCH 06/15] flac: Increase change penalty and header lookahead

Set FLAC_HEADER_CHANGED_PENALTY to same as FLAC_HEADER_CRC_FAIL_PENALTY. Having it
higher than FLAC_HEADER_BASE_SCORE seem to be important.

Also increase FLAC_MIN_HEADERS and FLAC_MAX_SEQUENTIAL_HEADERS to increase chance
to find a valid frame if there lots of false ones.

Related to GOL-771 and 8f4ac56b-e9c3-4e8e-b199-f8b2f5f221d2

But seems to not help with GOL-740 where a false frame is found at the end.
---
 libavcodec/flac_parser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index d9c47801f8..a927c5d132 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -38,15 +38,15 @@ 
 #include "flac_parse.h"
 
 /** maximum number of adjacent headers that compare CRCs against each other   */
-#define FLAC_MAX_SEQUENTIAL_HEADERS 4
+#define FLAC_MAX_SEQUENTIAL_HEADERS 10
 /** minimum number of headers buffered and checked before returning frames    */
-#define FLAC_MIN_HEADERS 10
+#define FLAC_MIN_HEADERS 20
 /** estimate for average size of a FLAC frame                                 */
 #define FLAC_AVG_FRAME_SIZE 8192
 
 /** scoring settings for score_header */
 #define FLAC_HEADER_BASE_SCORE        10
-#define FLAC_HEADER_CHANGED_PENALTY   7
+#define FLAC_HEADER_CHANGED_PENALTY   50
 #define FLAC_HEADER_CRC_FAIL_PENALTY  50
 #define FLAC_HEADER_NOT_PENALIZED_YET 100000
 #define FLAC_HEADER_NOT_SCORED_YET    -100000
-- 
2.39.2