diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-03-23 16:17:20 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-05-11 10:37:17 +0200 |
commit | c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a (patch) | |
tree | 244b9eb3d088011dc6ae1878eb2319a6050826b9 /libavcodec/decode.c | |
parent | a4ce3706595edd9b537861f0e5447e31babf2100 (diff) | |
download | ffmpeg-c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a.tar.gz |
lavc/encode: add an encoder-specific get_buffer() variant
Several encoders (roqvideo, svq1, snow, and the mpegvideo family)
currently call ff_get_buffer(). However this function is written
assuming it is called by a decoder. Though nothing has been obviously
broken by this until now, that may change in the future.
To avoid potential future issues, introduce a simple encode-specific
wrapper around avcodec_default_get_buffer2() and enforce its use in
encoders.
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 69e68ab09d..909235feb4 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1405,6 +1405,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int override_dimensions = 1; int ret; + av_assert0(av_codec_is_decoder(avctx->codec)); + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN || (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { |