[FFmpeg-cvslog] avcodec/codec_internal: Add dedicated is_decoder flag to FFCodec
Andreas Rheinhardt
git at videolan.org
Thu Mar 13 03:27:50 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Mar 10 16:40:39 2025 +0100| [47d7c6cd15716127b867125e6ae088043f5e7b31] | committer: Andreas Rheinhardt
avcodec/codec_internal: Add dedicated is_decoder flag to FFCodec
Allows to simplify av_codec_is_decoder() and av_codec_is_encoder().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47d7c6cd15716127b867125e6ae088043f5e7b31
---
libavcodec/codec_internal.h | 13 ++++++++++++-
libavcodec/utils.c | 8 ++------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h
index b2df8e729a..2b9c7354a0 100644
--- a/libavcodec/codec_internal.h
+++ b/libavcodec/codec_internal.h
@@ -133,7 +133,12 @@ typedef struct FFCodec {
/**
* Internal codec capabilities FF_CODEC_CAP_*.
*/
- unsigned caps_internal:27;
+ unsigned caps_internal:26;
+
+ /**
+ * Is this a decoder?
+ */
+ unsigned is_decoder:1;
/**
* This field determines the video color ranges supported by an encoder.
@@ -309,21 +314,27 @@ int ff_default_get_supported_config(const struct AVCodecContext *avctx,
#endif
#define FF_CODEC_DECODE_CB(func) \
+ .is_decoder = 1, \
.cb_type = FF_CODEC_CB_TYPE_DECODE, \
.cb.decode = (func)
#define FF_CODEC_DECODE_SUB_CB(func) \
+ .is_decoder = 1, \
.cb_type = FF_CODEC_CB_TYPE_DECODE_SUB, \
.cb.decode_sub = (func)
#define FF_CODEC_RECEIVE_FRAME_CB(func) \
+ .is_decoder = 1, \
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_FRAME, \
.cb.receive_frame = (func)
#define FF_CODEC_ENCODE_CB(func) \
+ .is_decoder = 0, \
.cb_type = FF_CODEC_CB_TYPE_ENCODE, \
.cb.encode = (func)
#define FF_CODEC_ENCODE_SUB_CB(func) \
+ .is_decoder = 0, \
.cb_type = FF_CODEC_CB_TYPE_ENCODE_SUB, \
.cb.encode_sub = (func)
#define FF_CODEC_RECEIVE_PACKET_CB(func) \
+ .is_decoder = 0, \
.cb_type = FF_CODEC_CB_TYPE_RECEIVE_PACKET, \
.cb.receive_packet = (func)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0aa5a6f55e..90867ed6b1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -79,17 +79,13 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
int av_codec_is_encoder(const AVCodec *avcodec)
{
const FFCodec *const codec = ffcodec(avcodec);
- return codec && (codec->cb_type == FF_CODEC_CB_TYPE_ENCODE ||
- codec->cb_type == FF_CODEC_CB_TYPE_ENCODE_SUB ||
- codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_PACKET);
+ return codec && !codec->is_decoder;
}
int av_codec_is_decoder(const AVCodec *avcodec)
{
const FFCodec *const codec = ffcodec(avcodec);
- return codec && (codec->cb_type == FF_CODEC_CB_TYPE_DECODE ||
- codec->cb_type == FF_CODEC_CB_TYPE_DECODE_SUB ||
- codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME);
+ return codec && codec->is_decoder;
}
int ff_set_dimensions(AVCodecContext *s, int width, int height)
More information about the ffmpeg-cvslog
mailing list