This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit c37079067e160a165f7f3b3ce93ce6c480b0d700 Author: Kacper Michajłow <[email protected]> AuthorDate: Wed Oct 14 10:16:49 2026 +0200 Commit: Kacper Michajłow <[email protected]> CommitDate: Fri Oct 16 21:17:22 2026 +0000 avformat: skip the program lookup in av_new_program() for monotonic ids Track whether the program ids are strictly increasing, like avpriv_new_chapter() does, and skip the scan of the existing programs when the new id is above the last one. Fixes: Timeout (7s -> 240ms) Fixes: clusterfuzz-testcase-ffmpeg_dem_HLS_fuzzer-5202060644253696 Signed-off-by: Kacper Michajłow <[email protected]> --- libavformat/avformat.c | 13 ++++++++++--- libavformat/internal.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 17c0534de2..e8ebb89097 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -296,14 +296,21 @@ const char *avformat_stream_group_name(enum AVStreamGroupParamsType type) AVProgram *av_new_program(AVFormatContext *ac, int id) { + FFFormatContext *const si = ffformatcontext(ac); AVProgram *program = NULL; int ret; av_log(ac, AV_LOG_TRACE, "new_program: id=0x%04x\n", id); - for (unsigned i = 0; i < ac->nb_programs; i++) - if (ac->programs[i]->id == id) - program = ac->programs[i]; + if (!ac->nb_programs) { + si->program_ids_monotonic = 1; + } else if (!si->program_ids_monotonic || ac->programs[ac->nb_programs - 1]->id >= id) { + for (unsigned i = 0; i < ac->nb_programs; i++) + if (ac->programs[i]->id == id) + program = ac->programs[i]; + if (!program) + si->program_ids_monotonic = 0; + } if (!program) { program = av_mallocz(sizeof(*program)); diff --git a/libavformat/internal.h b/libavformat/internal.h index b77292a532..53dc7b939b 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -119,6 +119,11 @@ typedef struct FFFormatContext { int missing_streams; + /** + * Set if program ids are strictly monotonic. + */ + int program_ids_monotonic; + /** * Shared libcurl event loop, created on demand on the first use. Freed on * context free. This allows to share libcurl state across URLContexts, -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
