Make find_stream_info get side data from the codec context. --- fftools/ffmpeg.c | 16 +++------------- libavformat/avformat.h | 11 +++++++++++ libavformat/utils.c | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9af2bc2fb5..232c8f5fd8 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3537,19 +3537,9 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) if (ret < 0) return ret; - if (ost->enc_ctx->nb_coded_side_data) { - int i; - - for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { - const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; - uint8_t *dst_data; - - dst_data = av_stream_new_side_data(ost->st, sd_src->type, sd_src->size); - if (!dst_data) - return AVERROR(ENOMEM); - memcpy(dst_data, sd_src->data, sd_src->size); - } - } + ret = av_stream_add_coded_side_data(ost->st, ost->enc_ctx); + if (ret < 0) + return ret; /* * Add global input side data. For now this is naive, and copies it diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d4d9a3b06e..8e0d0df55e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2191,6 +2191,17 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, */ uint8_t *av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size); + +/** ++ * Add stream side_data from the coded_side_data of the supplied context. ++ * ++ * @param stream stream ++ * @param avctx the codec context that may contain coded_side_data ++ * @return >= 0 in case of success, a negative AVERROR code in case of ++ * failure ++ */ +int av_stream_add_coded_side_data(AVStream *stream, AVCodecContext *avctx); + /** * Get side information from stream. * diff --git a/libavformat/utils.c b/libavformat/utils.c index b472762dd1..f7c949f0a1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4137,6 +4137,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx); if (ret < 0) goto find_stream_info_err; + ret = av_stream_add_coded_side_data(st, st->internal->avctx); + if (ret < 0) + goto find_stream_info_err; #if FF_API_LOWRES // The decoder might reduce the video size by the lowres factor. if (st->internal->avctx->lowres && orig_w) { @@ -5556,6 +5559,21 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, return data; } +int av_stream_add_coded_side_data(AVStream *st, AVCodecContext *avctx) +{ + int i; + + for (i = 0; i < avctx->nb_coded_side_data; i++) { + const AVPacketSideData *sd_src = &avctx->coded_side_data[i]; + uint8_t *dst_data; + dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); + if (!dst_data) + return AVERROR(ENOMEM); + memcpy(dst_data, sd_src->data, sd_src->size); + } + return 0; +} + int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args) { int ret; -- 2.14.1.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".