[FFmpeg-devel] [PATCH v2 3/7] avformat: Add av_stream_add_coded_side_data()

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Dec 19 20:34:00 EET 2019


Nicolas Gaullier:
> This will allow avformat_find_stream_info() get side data from the codec context.
> ---
>  doc/APIchanges         |  3 +++
>  libavformat/avformat.h | 11 +++++++++++
>  libavformat/utils.c    | 15 +++++++++++++++
>  libavformat/version.h  |  2 +-
>  4 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 401c65a753..62b5effda7 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
>  
>  API changes, most recent first:
>  
> +2019-12-19 - xxxxxxxxxx - lavf 58.36.101 - avformat.h
> +  Add av_stream_add_coded_side_data().
> +
>  2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
>    Add av_expr_count_vars().
>  
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index d4d9a3b06e..4dee1a272a 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..fe92ad4a1d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -5556,6 +5556,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;
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 213b66b45f..15495bfd31 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -32,7 +32,7 @@
>  // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
>  // Also please add any ticket numbers that you believe might be affected here
>  #define LIBAVFORMAT_VERSION_MAJOR  58
> -#define LIBAVFORMAT_VERSION_MINOR  35
> +#define LIBAVFORMAT_VERSION_MINOR  36
>  #define LIBAVFORMAT_VERSION_MICRO 101
>  
You forgot to reset micro.

- Andreas


More information about the ffmpeg-devel mailing list