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/options.c | |
parent | a688f3c13ce55c2ba51dbbb344564649f1bb52fe (diff) | |
download | ffmpeg-20f972701806be20a77f808db332d9489343bb78.tar.gz |
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/options.c')
-rw-r--r-- | libavcodec/options.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c index 306625f25e..9cf5b0eb74 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -68,8 +68,10 @@ static const AVClass *codec_child_class_iterate(void **iter) static AVClassCategory get_category(void *ptr) { AVCodecContext* avctx = ptr; - if(avctx->codec && avctx->codec->decode) return AV_CLASS_CATEGORY_DECODER; - else return AV_CLASS_CATEGORY_ENCODER; + if (avctx->codec && ffcodec(avctx->codec)->decode) + return AV_CLASS_CATEGORY_DECODER; + else + return AV_CLASS_CATEGORY_ENCODER; } static const AVClass av_codec_context_class = { @@ -86,6 +88,7 @@ static const AVClass av_codec_context_class = { static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) { + const FFCodec *const codec2 = ffcodec(codec); int flags=0; memset(s, 0, sizeof(AVCodecContext)); @@ -122,8 +125,8 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) s->sample_fmt = AV_SAMPLE_FMT_NONE; s->reordered_opaque = AV_NOPTS_VALUE; - if(codec && codec->priv_data_size){ - s->priv_data = av_mallocz(codec->priv_data_size); + if(codec && codec2->priv_data_size){ + s->priv_data = av_mallocz(codec2->priv_data_size); if (!s->priv_data) return AVERROR(ENOMEM); if(codec->priv_class){ @@ -131,9 +134,9 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) av_opt_set_defaults(s->priv_data); } } - if (codec && codec->defaults) { + if (codec && codec2->defaults) { int ret; - const AVCodecDefault *d = codec->defaults; + const AVCodecDefault *d = codec2->defaults; while (d->key) { ret = av_opt_set(s, d->key, d->value, 0); av_assert0(ret >= 0); |