[FFmpeg-devel] [PATCH 1/3] imgutils: Use designated initializers for AVClass

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Nov 21 15:16:04 CET 2015


On Sat, Nov 21, 2015 at 12:34 AM, Timothy Gu <timothygu99 at gmail.com> wrote:
> More readable and less breakable.
> ---
>  libavutil/imgutils.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 8956ae3..a189a50 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -236,11 +236,21 @@ typedef struct ImgUtils {
>      void *log_ctx;
>  } ImgUtils;
>
> -static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
> +static const AVClass imgutils_class = {
> +    .class_name = "IMGUTILS",
> +    .item_name  = av_default_item_name,
> +    .version    = LIBAVUTIL_VERSION_INT,
> +    .log_level_offset_offset   = offsetof(ImgUtils, log_offset),
> +    .parent_log_context_offset = offsetof(ImgUtils, log_ctx)
> +};
>
>  int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
>  {
> -    ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
> +    ImgUtils imgutils = {
> +        .class      = &imgutils_class,
> +        .log_offset = log_offset,
> +        .log_ctx    = log_ctx
> +    };
>
>      if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
>          return 0;
> --
> 2.1.4

minor nit: please use a comma for the last field as well, it seems
like that is preferred (and I prefer it as well), at least what
avcodec/aacenc, avcodec/alac do.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list