[FFmpeg-devel] [PATCH] Use named initators for pcm codec struct

Måns Rullgård mans
Thu Jul 15 17:59:23 CEST 2010


Peter Ross <pross at xvid.org> writes:

> $subject

The correct term is designated initialisers.

> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 4e86154..ba0f53a 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
> @@ -444,16 +444,14 @@ static int pcm_decode_frame(AVCodecContext *avctx,
>  }
>  
>  #if CONFIG_ENCODERS
> -#define PCM_ENCODER(id,sample_fmt_,name,long_name_) \
> -AVCodec name ## _encoder = {                    \
> -    #name,                                      \
> -    AVMEDIA_TYPE_AUDIO,                         \
> -    id,                                         \
> -    0,                                          \
> -    pcm_encode_init,                            \
> -    pcm_encode_frame,                           \
> -    pcm_encode_close,                           \
> -    NULL,                                       \
> +#define PCM_ENCODER(id_,sample_fmt_,name_,long_name_) \
> +AVCodec name_ ## _encoder = {                   \
> +    .name        = #name_,                      \
> +    .type        = AVMEDIA_TYPE_AUDIO,          \
> +    .id          = id_,                         \
> +    .init        = pcm_encode_init,             \
> +    .encode      = pcm_encode_frame,            \
> +    .close       = pcm_encode_close,            \
>      .sample_fmts = (const enum SampleFormat[]){sample_fmt_,SAMPLE_FMT_NONE}, \
>      .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
>  };

I'm not too fond of trailing underscores.  Unfortunately I have no
better suggestion, though you could at least leave it off the params
that don't clash with anything.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list