diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-04-21 19:13:07 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-04-25 12:35:40 +0200 |
commit | 0279eb9c93159c5280d679fe722c7dd91636b82d (patch) | |
tree | 6da16eb5134584ce67faad9a07f5e8541aee2807 | |
parent | 0d9b0015ba716d015b5c29712d289e87e632760c (diff) | |
download | ffmpeg-0279eb9c93159c5280d679fe722c7dd91636b82d.tar.gz |
avcodec/imm5: Reference H.264/HEVC decoders directly
This is simpler and allows to fuzz them -- up until now,
the linker did not see the dependency and fuzzing them
returned AVERROR_BUG during init.
It took just a few seconds here to run into an assert
due to a return value of AVERROR(EAGAIN) in the decode
callback...
Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/imm5.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/libavcodec/imm5.c b/libavcodec/imm5.c index 2535e7726c..4b9f3f6b75 100644 --- a/libavcodec/imm5.c +++ b/libavcodec/imm5.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes_internal.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" @@ -51,32 +52,27 @@ static const struct IMM5_unit { static av_cold int imm5_init(AVCodecContext *avctx) { IMM5Context *ctx = avctx->priv_data; - const AVCodec *codec; int ret; - codec = avcodec_find_decoder(AV_CODEC_ID_H264); - if (!codec) - return AVERROR_BUG; - ctx->h264_avctx = avcodec_alloc_context3(codec); + EXTERN const FFCodec ff_h264_decoder; + ctx->h264_avctx = avcodec_alloc_context3(&ff_h264_decoder.p); if (!ctx->h264_avctx) return AVERROR(ENOMEM); ctx->h264_avctx->thread_count = 1; ctx->h264_avctx->flags = avctx->flags; ctx->h264_avctx->flags2 = avctx->flags2; - ret = avcodec_open2(ctx->h264_avctx, codec, NULL); + ret = avcodec_open2(ctx->h264_avctx, NULL, NULL); if (ret < 0) return ret; - codec = avcodec_find_decoder(AV_CODEC_ID_HEVC); - if (!codec) - return AVERROR_BUG; - ctx->hevc_avctx = avcodec_alloc_context3(codec); + EXTERN const FFCodec ff_hevc_decoder; + ctx->hevc_avctx = avcodec_alloc_context3(&ff_hevc_decoder.p); if (!ctx->hevc_avctx) return AVERROR(ENOMEM); ctx->hevc_avctx->thread_count = 1; ctx->hevc_avctx->flags = avctx->flags; ctx->hevc_avctx->flags2 = avctx->flags2; - ret = avcodec_open2(ctx->hevc_avctx, codec, NULL); + ret = avcodec_open2(ctx->hevc_avctx, NULL, NULL); if (ret < 0) return ret; |