summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-16 21:09:54 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-21 01:33:09 +0100
commit20f972701806be20a77f808db332d9489343bb78 (patch)
tree8d8b588c0ca06fa652518a5685db8280b0bf532d /libavcodec/utils.c
parenta688f3c13ce55c2ba51dbbb344564649f1bb52fe (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/utils.c')
-rw-r--r--libavcodec/utils.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b18af6d0a8..1666f5dabb 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -71,13 +71,15 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE);
}
-int av_codec_is_encoder(const AVCodec *codec)
+int av_codec_is_encoder(const AVCodec *avcodec)
{
+ const FFCodec *const codec = ffcodec(avcodec);
return codec && (codec->encode_sub || codec->encode2 || codec->receive_packet);
}
-int av_codec_is_decoder(const AVCodec *codec)
+int av_codec_is_decoder(const AVCodec *avcodec)
{
+ const FFCodec *const codec = ffcodec(avcodec);
return codec && (codec->decode || codec->receive_frame);
}
@@ -435,7 +437,7 @@ void ff_color_frame(AVFrame *frame, const int c[4])
}
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){
- return !!(codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM);
+ return !!(ffcodec(codec)->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM);
}
const char *avcodec_get_name(enum AVCodecID id)
@@ -868,8 +870,9 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
return i;
}
-const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
+const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *avcodec, int index)
{
+ const FFCodec *const codec = ffcodec(avcodec);
int i;
if (!codec->hw_configs || index < 0)
return NULL;