[FFmpeg-devel] [PATCH]lavf:Constify AVOutputFormat pointer

James Almer jamrial at gmail.com
Sat Feb 9 16:42:25 EET 2019


On 2/9/2019 11:23 AM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch is supposed to constify all occurrences of
> AVOutputFormat in libavformat.
> 
> Please comment, Carl Eugen
> 
> 
> 0001-lavf-Constify-AVOutputFormat-pointer.patch
> 
> From ba32f41824df07b7a6cb45964ef912c5fc05b276 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> Date: Sat, 9 Feb 2019 15:21:17 +0100
> Subject: [PATCH] lavf: Constify AVOutputFormat pointer.
> 
> ---
>  libavformat/allformats.c         |    4 ++++
>  libavformat/avformat.h           |   15 ++++++++++-----
>  libavformat/fifo.c               |    4 ++--
>  libavformat/format.c             |    6 +++---
>  libavformat/hdsenc.c             |    2 +-
>  libavformat/hlsenc.c             |    4 ++--
>  libavformat/mux.c                |    4 ++--
>  libavformat/rtp.c                |    2 +-
>  libavformat/rtpenc_chain.c       |    2 +-
>  libavformat/rtpenc_mpegts.c      |    4 ++--
>  libavformat/segment.c            |    2 +-
>  libavformat/smoothstreamingenc.c |    2 +-
>  libavformat/version.h            |    3 +++
>  libavformat/webm_chunk.c         |    2 +-
>  14 files changed, 34 insertions(+), 22 deletions(-)
> 
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 0684498..64d0f02 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -595,7 +595,11 @@ AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
>      ff_thread_once(&av_format_next_init, av_format_init_next);
>  
>      if (f)
> +#if FF_API_AVIOFORMAT
> +        return (AVOutputFormat *) f->next;
> +#else
>          return f->next;
> +#endif
>      else {
>          void *opaque = NULL;
>          return (AVOutputFormat *)av_muxer_iterate(&opaque);
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index fdaffa5..52922c0 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -532,7 +532,12 @@ typedef struct AVOutputFormat {
>       * New public fields should be added right above.
>       *****************************************************************
>       */
> -    struct AVOutputFormat *next;
> +#if FF_API_AVIOFORMAT
> +#define av_const59 const
> +#else
> +#define av_const59
> +#endif

Shouldn't it be the other way around? FF_API_AVIOFORMAT evaluates to 1
when major is < 59.


More information about the ffmpeg-devel mailing list