[FFmpeg-cvslog] avcodec/flac_parser: ensure there are more headers for scoring

Paul B Mahol git at videolan.org
Thu Sep 8 17:59:12 EEST 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Sep  5 18:12:10 2022 +0200| [5ca781598e1a7c24aec7ebada16e8ad8c5725a41] | committer: Paul B Mahol

avcodec/flac_parser: ensure there are more headers for scoring

Previously invalid frame may be returned, happened when seeking.

Fixes #7684

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ca781598e1a7c24aec7ebada16e8ad8c5725a41
---

 libavcodec/flac_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index a1d9cd7f29..11cd5540cf 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -600,7 +600,7 @@ static int score_header(FLACParseContext *fpc, FLACHeaderMarker *header)
 static void score_sequences(FLACParseContext *fpc)
 {
     FLACHeaderMarker *curr;
-    int best_score = 0;//FLAC_HEADER_NOT_SCORED_YET;
+    int best_score = FLAC_HEADER_NOT_SCORED_YET;
     /* First pass to clear all old scores. */
     for (curr = fpc->headers; curr; curr = curr->next)
         curr->max_score = FLAC_HEADER_NOT_SCORED_YET;
@@ -682,7 +682,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
     }
 
     fpc->avctx = avctx;
-    if (fpc->best_header_valid)
+    if (fpc->best_header_valid && fpc->nb_headers_buffered >= FLAC_MIN_HEADERS)
         return get_best_header(fpc, poutbuf, poutbuf_size);
 
     /* If a best_header was found last call remove it with the buffer data. */



More information about the ffmpeg-cvslog mailing list