[FFmpeg-devel] [PATCH] avformat/avformat.h: Add av_stream_remove_side_data.

Jacob Trimble modmaker at google.com
Mon Jul 2 19:56:34 EEST 2018


On Mon, Jun 25, 2018 at 4:04 PM Jacob Trimble <modmaker at google.com> wrote:
>
> Signed-off-by: Jacob Trimble <modmaker at google.com>
> ---
>  libavformat/avformat.h |  8 ++++++++
>  libavformat/utils.c    | 11 +++++++++++
>  2 files changed, 19 insertions(+)
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index fdaffa5bf4..434c88837e 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2167,6 +2167,14 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
>  int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
>                              uint8_t *data, size_t size);
>
> +/**
> + * Removes any existing side data of the given type.
> + *
> + * @param st stream
> + * @param type side information type
> + */
> +void av_stream_remove_side_data(AVStream *st, enum AVPacketSideDataType type);
> +
>  /**
>   * Allocate new information from stream.
>   *
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index c9cdd2b470..4f7c408d93 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -5491,6 +5491,17 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
>      return 0;
>  }
>
> +void av_stream_remove_side_data(AVStream *st, enum AVPacketSideDataType type)
> +{
> +  for (int i = 0; i < st->nb_side_data; i++) {
> +      if (st->side_data[i].type == type) {
> +          av_freep(&st->side_data[i].data);
> +          st->side_data[i] = st->side_data[st->nb_side_data - 1];
> +          st->nb_side_data--;
> +      }
> +  }
> +}
> +
>  uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
>                                   int size)
>  {
> --
> 2.18.0.rc2.346.g013aa6912e-goog
>

Ping.


More information about the ffmpeg-devel mailing list