diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-03-16 21:09:54 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-03-21 01:33:09 +0100 |
commit | 20f972701806be20a77f808db332d9489343bb78 (patch) | |
tree | 8d8b588c0ca06fa652518a5685db8280b0bf532d /libavcodec/libcodec2.c | |
parent | a688f3c13ce55c2ba51dbbb344564649f1bb52fe (diff) |
avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
Up until now, codec.h contains both public and private parts
of AVCodec. This exposes the internals of AVCodec to users
and leads them into the temptation of actually using them
and forces us to forward-declare structures and types that
users can't use at all.
This commit changes this by adding a new structure FFCodec to
codec_internal.h that extends AVCodec, i.e. contains the public
AVCodec as first member; the private fields of AVCodec are moved
to this structure, leaving codec.h clean.
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/libcodec2.c')
-rw-r--r-- | libavcodec/libcodec2.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index a2efb813c6..f59cb31bf2 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -23,6 +23,7 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "libavutil/opt.h" +#include "codec_internal.h" #include "encode.h" #include "internal.h" #include "codec2utils.h" @@ -176,39 +177,39 @@ static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, return 0; } -const AVCodec ff_libcodec2_decoder = { - .name = "libcodec2", - .long_name = NULL_IF_CONFIG_SMALL("codec2 decoder using libcodec2"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_CODEC2, +const FFCodec ff_libcodec2_decoder = { + .p.name = "libcodec2", + .p.long_name = NULL_IF_CONFIG_SMALL("codec2 decoder using libcodec2"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_CODEC2, + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF, + .p.supported_samplerates = (const int[]){ 8000, 0 }, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, .priv_data_size = sizeof(LibCodec2Context), .init = libcodec2_init_decoder, .close = libcodec2_close, .decode = libcodec2_decode, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF, - .supported_samplerates = (const int[]){ 8000, 0 }, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, #if FF_API_OLD_CHANNEL_LAYOUT - .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, + .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, #endif - .ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, }; -const AVCodec ff_libcodec2_encoder = { - .name = "libcodec2", - .long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_CODEC2, - .capabilities = AV_CODEC_CAP_DR1, +const FFCodec ff_libcodec2_encoder = { + .p.name = "libcodec2", + .p.long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_CODEC2, + .p.capabilities = AV_CODEC_CAP_DR1, + .p.supported_samplerates = (const int[]){ 8000, 0 }, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, + .p.priv_class = &libcodec2_enc_class, .priv_data_size = sizeof(LibCodec2Context), .init = libcodec2_init_encoder, .close = libcodec2_close, .encode2 = libcodec2_encode, - .supported_samplerates = (const int[]){ 8000, 0 }, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, #if FF_API_OLD_CHANNEL_LAYOUT - .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, + .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, #endif - .ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, - .priv_class = &libcodec2_enc_class, }; |