This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 7623379a770c3149da2565bf351f38e193c84b8c Author: Gyan Doshi <[email protected]> AuthorDate: Fri Feb 17 21:08:15 2023 +0530 Commit: Gyan Doshi <[email protected]> CommitDate: Tue May 5 12:51:54 2026 +0530 avformat: add av_program_add_stream_index2() av_program_add_stream_index() added in 526efa10534 may fail to carry out its purpose but the lack of a return value stops callers from catching any error. Fixed in new function. --- doc/APIchanges | 3 +++ libavformat/avformat.c | 21 +++++++++++++++------ libavformat/avformat.h | 13 +++++++++++++ libavformat/version.h | 4 ++-- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f1cbbb41b8..4b7f21aca6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28 API changes, most recent first: +2026-05-05 - xxxxxxxxxxx - lavf 62.14.100 - avformat.h + Add av_program_add_stream_index2(). + 2026-04-14 - 7faa6ee2aa - lavc 62.30.100 - packet.h Add AV_PKT_DATA_DYNAMIC_HDR_SMPTE_2094_APP5 side data type. diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 8a98f2e53e..f4bb4dbac0 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -299,14 +299,14 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) return program; } -void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) +int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned idx) { AVProgram *program = NULL; void *tmp; if (idx >= ac->nb_streams) { - av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx); - return; + av_log(ac, AV_LOG_ERROR, "stream index %d is greater than stream count %d\n", idx, ac->nb_streams); + return AVERROR(EINVAL); } for (unsigned i = 0; i < ac->nb_programs; i++) { @@ -315,15 +315,24 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) program = ac->programs[i]; for (unsigned j = 0; j < program->nb_stream_indexes; j++) if (program->stream_index[j] == idx) - return; + return 0; tmp = av_realloc_array(program->stream_index, program->nb_stream_indexes+1, sizeof(unsigned int)); if (!tmp) - return; + return AVERROR(ENOMEM); program->stream_index = tmp; program->stream_index[program->nb_stream_indexes++] = idx; - return; + return 0; } + + av_log(ac, AV_LOG_ERROR, "no program with id %d found\n", progid); + return AVERROR(EINVAL); +} + +void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx) +{ + av_program_add_stream_index2(ac, progid, idx); + return; } AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index ee0ddddf8d..33289e3b89 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2230,6 +2230,19 @@ AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx); +/** + * Add the supplied index of a stream to the AVProgram with matching id. + * + * @param ac the format context which contains the target AVProgram + * @param progid the ID of the AVProgram whose stream index is to be updated + * @param idx the index of the stream to be added + * + * @return >=0 upon successful addition or if index was already present, + * AVERROR if no matching program is found or stream index is invalid or + * the stream index array reallocation failed. + */ +int av_program_add_stream_index2(AVFormatContext *ac, int progid, unsigned int idx); + /** * Find the "best" stream in the file. * The best stream is determined according to various heuristics as the most diff --git a/libavformat/version.h b/libavformat/version.h index ff831498b3..14bf700274 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 13 -#define LIBAVFORMAT_VERSION_MICRO 102 +#define LIBAVFORMAT_VERSION_MINOR 14 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
