[FFmpeg-devel] [PATCH] nobody cares: use designated initializers

Paul B Mahol onemda at gmail.com
Fri Dec 30 13:02:05 CET 2011


---
 libavcodec/bintext.c          |   51 +++++++++++++++++++---------------------
 libavcodec/diracdec.c         |    1 -
 libavcodec/g729dec.c          |   14 +++++------
 libavcodec/j2kdec.c           |   15 +++++------
 libavcodec/j2kenc.c           |   14 +++++-----
 libavcodec/libaacplus.c       |   14 +++++-----
 libavcodec/libopenjpegenc.c   |    1 -
 libavcodec/libutvideo.cpp     |   22 ++++++-----------
 libavcodec/msvideo1enc.c      |   14 +++++-----
 libavcodec/proresenc.c        |    1 -
 libavcodec/sonic.c            |   45 +++++++++++++++++-------------------
 libavformat/cafenc.c          |   20 ++++++++--------
 libavformat/g723_1.c          |   10 +++-----
 libavformat/mkvtimestamp_v2.c |   15 +++++-------
 14 files changed, 107 insertions(+), 130 deletions(-)

diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index df37fee..0b46dd4 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -211,40 +211,37 @@ static av_cold int decode_end(AVCodecContext *avctx)
 }
 
 AVCodec ff_bintext_decoder = {
-    "bintext",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_BINTEXT,
-    sizeof(XbinContext),
-    decode_init,
-    NULL,
-    decode_end,
-    decode_frame,
-    CODEC_CAP_DR1,
+    .name           = "bintext",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_BINTEXT,
+    .priv_data_size = sizeof(XbinContext),
+    .init           = decode_init,
+    .close          = decode_end,
+    .decode         = decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("Binary text"),
 };
 
 AVCodec ff_xbin_decoder = {
-    "xbin",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_XBIN,
-    sizeof(XbinContext),
-    decode_init,
-    NULL,
-    decode_end,
-    decode_frame,
-    CODEC_CAP_DR1,
+    .name           = "xbin",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_XBIN,
+    .priv_data_size = sizeof(XbinContext),
+    .init           = decode_init,
+    .close          = decode_end,
+    .decode         = decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("eXtended BINary text"),
 };
 
 AVCodec ff_idf_decoder = {
-    "idf",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_IDF,
-    sizeof(XbinContext),
-    decode_init,
-    NULL,
-    decode_end,
-    decode_frame,
-    CODEC_CAP_DR1,
+    .name           = "idf",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_IDF,
+    .priv_data_size = sizeof(XbinContext),
+    .init           = decode_init,
+    .close          = decode_end,
+    .decode         = decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("iCEDraw text"),
 };
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 1ace7bd..1bc7334 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1898,7 +1898,6 @@ AVCodec ff_dirac_decoder = {
     .id             = CODEC_ID_DIRAC,
     .priv_data_size = sizeof(DiracContext),
     .init           = dirac_decode_init,
-    .encode         = NULL,
     .close          = dirac_decode_end,
     .decode         = dirac_decode_frame,
     .capabilities   = CODEC_CAP_DELAY,
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 4714f19..191794b 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -714,14 +714,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
 
 AVCodec ff_g729_decoder =
 {
-    "g729",
-    AVMEDIA_TYPE_AUDIO,
-    CODEC_ID_G729,
-    sizeof(G729Context),
-    decoder_init,
-    NULL,
-    NULL,
-    decode_frame,
+    .name           = "g729",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_G729,
+    .priv_data_size = sizeof(G729Context),
+    .init           = decoder_init,
+    .decode         = decode_frame,
     .capabilities = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("G.729"),
 };
diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index e35c97d..d605b13 100644
--- a/libavcodec/j2kdec.c
+++ b/libavcodec/j2kdec.c
@@ -1068,14 +1068,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
 }
 
 AVCodec ff_jpeg2000_decoder = {
-    "j2k",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_JPEG2000,
-    sizeof(J2kDecoderContext),
-    j2kdec_init,
-    NULL,
-    decode_end,
-    decode_frame,
+    .name           = "j2k",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_JPEG2000,
+    .priv_data_size = sizeof(J2kDecoderContext),
+    .init           = j2kdec_init,
+    .close          = decode_end,
+    .decode         = decode_frame,
     .capabilities = CODEC_CAP_EXPERIMENTAL,
     .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),
     .pix_fmts =
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 58789c9..37e31a9 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1036,13 +1036,13 @@ static int j2kenc_destroy(AVCodecContext *avctx)
 }
 
 AVCodec ff_jpeg2000_encoder = {
-    "j2k",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_JPEG2000,
-    sizeof(J2kEncoderContext),
-    j2kenc_init,
-    encode_frame,
-    j2kenc_destroy,
+    .name           = "j2k",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_JPEG2000,
+    .priv_data_size = sizeof(J2kEncoderContext),
+    .init           = j2kenc_init,
+    .encode         = encode_frame,
+    .close          = j2kenc_destroy,
     .capabilities= CODEC_CAP_EXPERIMENTAL,
     .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),
     .pix_fmts =
diff --git a/libavcodec/libaacplus.c b/libavcodec/libaacplus.c
index a5ededb..3ab4e03 100644
--- a/libavcodec/libaacplus.c
+++ b/libavcodec/libaacplus.c
@@ -122,13 +122,13 @@ static av_cold int aacPlus_encode_close(AVCodecContext *avctx)
 }
 
 AVCodec ff_libaacplus_encoder = {
-    "libaacplus",
-    AVMEDIA_TYPE_AUDIO,
-    CODEC_ID_AAC,
-    sizeof(aacPlusAudioContext),
-    aacPlus_encode_init,
-    aacPlus_encode_frame,
-    aacPlus_encode_close,
+    .name           = "libaacplus",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_AAC,
+    .priv_data_size = sizeof(aacPlusAudioContext),
+    .init           = aacPlus_encode_init,
+    .encode         = aacPlus_encode_frame,
+    .close          = aacPlus_encode_close,
     .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("libaacplus AAC+ (Advanced Audio Codec with SBR+PS)"),
 };
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 6b37fb0..c088acc 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -365,7 +365,6 @@ AVCodec ff_libopenjpeg_encoder = {
     .init           = libopenjpeg_encode_init,
     .encode         = libopenjpeg_encode_frame,
     .close          = libopenjpeg_encode_close,
-    .decode         = NULL,
     .capabilities   = 0,
     .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24,PIX_FMT_RGBA,PIX_FMT_GRAY8,
                                            PIX_FMT_YUV420P,PIX_FMT_YUV422P,PIX_FMT_YUVA420P,
diff --git a/libavcodec/libutvideo.cpp b/libavcodec/libutvideo.cpp
index 635720e..95ce587 100644
--- a/libavcodec/libutvideo.cpp
+++ b/libavcodec/libutvideo.cpp
@@ -188,18 +188,12 @@ static av_cold int utvideo_decode_close(AVCodecContext *avctx)
 }
 
 AVCodec ff_libutvideo_decoder = {
-    "libutvideo",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_UTVIDEO,
-    sizeof(UtVideoContext),
-    utvideo_decode_init,
-    NULL,
-    utvideo_decode_close,
-    utvideo_decode_frame,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL_IF_CONFIG_SMALL("Ut Video"),
+    .name           = "libutvideo",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_UTVIDEO,
+    .priv_data_size = sizeof(UtVideoContext),
+    .init           = utvideo_decode_init,
+    .close          = utvideo_decode_close,
+    .decode         = utvideo_decode_frame,
+    .long_name      = NULL_IF_CONFIG_SMALL("Ut Video"),
 };
diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c
index 09cc7a1..401ac2a 100644
--- a/libavcodec/msvideo1enc.c
+++ b/libavcodec/msvideo1enc.c
@@ -290,13 +290,13 @@ static av_cold int encode_end(AVCodecContext *avctx)
 }
 
 AVCodec ff_msvideo1_encoder = {
-    "msvideo1",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_MSVIDEO1,
-    sizeof(Msvideo1EncContext),
-    encode_init,
-    encode_frame,
-    encode_end,
+    .name           = "msvideo1",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_MSVIDEO1,
+    .priv_data_size = sizeof(Msvideo1EncContext),
+    .init           = encode_init,
+    .encode         = encode_frame,
+    .close          = encode_end,
     .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB555, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video-1"),
 };
diff --git a/libavcodec/proresenc.c b/libavcodec/proresenc.c
index 8cdcff3..09678a0 100644
--- a/libavcodec/proresenc.c
+++ b/libavcodec/proresenc.c
@@ -594,6 +594,5 @@ AVCodec ff_prores_encoder = {
     .encode         = prores_encode_frame,
     .pix_fmts       = (const enum PixelFormat[]){PIX_FMT_YUV422P10, PIX_FMT_NONE},
     .long_name      = NULL_IF_CONFIG_SMALL("Apple ProRes"),
-    .capabilities   = 0,
     .profiles       = profiles
 };
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index e7cdb3b..71641f9 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -936,42 +936,39 @@ static int sonic_decode_frame(AVCodecContext *avctx,
 }
 
 AVCodec ff_sonic_decoder = {
-    "sonic",
-    AVMEDIA_TYPE_AUDIO,
-    CODEC_ID_SONIC,
-    sizeof(SonicContext),
-    sonic_decode_init,
-    NULL,
-    sonic_decode_close,
-    sonic_decode_frame,
+    .name           = "sonic",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_SONIC,
+    .priv_data_size = sizeof(SonicContext),
+    .init           = sonic_decode_init,
+    .close          = sonic_decode_close,
+    .decode         = sonic_decode_frame,
     .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
 };
 #endif /* CONFIG_SONIC_DECODER */
 
 #if CONFIG_SONIC_ENCODER
 AVCodec ff_sonic_encoder = {
-    "sonic",
-    AVMEDIA_TYPE_AUDIO,
-    CODEC_ID_SONIC,
-    sizeof(SonicContext),
-    sonic_encode_init,
-    sonic_encode_frame,
-    sonic_encode_close,
-    NULL,
+    .name           = "sonic",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_SONIC,
+    .priv_data_size = sizeof(SonicContext),
+    .init           = sonic_encode_init,
+    .encode         = sonic_encode_frame,
+    .close          = sonic_encode_close,
     .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
 };
 #endif
 
 #if CONFIG_SONIC_LS_ENCODER
 AVCodec ff_sonic_ls_encoder = {
-    "sonicls",
-    AVMEDIA_TYPE_AUDIO,
-    CODEC_ID_SONIC_LS,
-    sizeof(SonicContext),
-    sonic_encode_init,
-    sonic_encode_frame,
-    sonic_encode_close,
-    NULL,
+    .name           = "sonicls",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_SONIC_LS,
+    .priv_data_size = sizeof(SonicContext),
+    .init           = sonic_encode_init,
+    .encode         = sonic_encode_frame,
+    .close          = sonic_encode_close,
     .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
 };
 #endif
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 0dd4b34..699c67d 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -248,15 +248,15 @@ static int caf_write_trailer(AVFormatContext *s)
 }
 
 AVOutputFormat ff_caf_muxer = {
-    "caf",
-    NULL_IF_CONFIG_SMALL("Apple Core Audio Format"),
-    "audio/x-caf",
-    "caf",
-    sizeof(CAFContext),
-    CODEC_ID_PCM_S16BE,
-    CODEC_ID_NONE,
-    caf_write_header,
-    caf_write_packet,
-    caf_write_trailer,
+    .name           = "caf",
+    .long_name      = NULL_IF_CONFIG_SMALL("Apple Core Audio Format"),
+    .mime_type      = "audio/x-caf",
+    .extensions     = "caf",
+    .priv_data_size = sizeof(CAFContext),
+    .audio_codec    = CODEC_ID_PCM_S16BE,
+    .video_codec    = CODEC_ID_NONE,
+    .write_header   = caf_write_header,
+    .write_packet   = caf_write_packet,
+    .write_trailer  = caf_write_trailer,
     .codec_tag= (const AVCodecTag* const []){ff_codec_caf_tags, 0},
 };
diff --git a/libavformat/g723_1.c b/libavformat/g723_1.c
index 86ef540..00cfe16 100644
--- a/libavformat/g723_1.c
+++ b/libavformat/g723_1.c
@@ -73,12 +73,10 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
 }
 
 AVInputFormat ff_g723_1_demuxer = {
-    "g723_1",
-    NULL_IF_CONFIG_SMALL("G.723.1 format"),
-    0,
-    NULL,
-    g723_1_init,
-    g723_1_read_packet,
+    .name        = "g723_1",
+    .long_name   = NULL_IF_CONFIG_SMALL("G.723.1 format"),
+    .read_header = g723_1_init,
+    .read_packet = g723_1_read_packet,
     .extensions = "tco,rco",
     .flags = AVFMT_GENERIC_INDEX
 };
diff --git a/libavformat/mkvtimestamp_v2.c b/libavformat/mkvtimestamp_v2.c
index f120460..469b75d 100644
--- a/libavformat/mkvtimestamp_v2.c
+++ b/libavformat/mkvtimestamp_v2.c
@@ -42,13 +42,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 
 AVOutputFormat ff_mkvtimestamp_v2_muxer = {
-    "mkvtimestamp_v2",
-    NULL_IF_CONFIG_SMALL("extract pts as timecode v2 format, as defined by mkvtoolnix"),
-    NULL,
-    "",
-    0,
-    CODEC_ID_NONE,
-    CODEC_ID_RAWVIDEO,
-    write_header,
-    write_packet,
+    .name         = "mkvtimestamp_v2",
+    .long_name    = NULL_IF_CONFIG_SMALL("extract pts as timecode v2 format, as defined by mkvtoolnix"),
+    .audio_codec  = CODEC_ID_NONE,
+    .video_codec  = CODEC_ID_RAWVIDEO,
+    .write_header = write_header,
+    .write_packet = write_packet,
 };
-- 
1.7.7



More information about the ffmpeg-devel mailing list