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(-)
@@ -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