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/mpegpicture.c | |
parent | a4ce3706595edd9b537861f0e5447e31babf2100 (diff) |
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/mpegpicture.c')
-rw-r--r-- | libavcodec/mpegpicture.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index 681ccc2b82..aaa1df0bd8 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -26,6 +26,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "encode.h" #include "motion_est.h" #include "mpegpicture.h" #include "mpegutils.h" @@ -123,14 +124,15 @@ static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, int r, ret; pic->tf.f = pic->f; - if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && - avctx->codec_id != AV_CODEC_ID_VC1IMAGE && - avctx->codec_id != AV_CODEC_ID_MSS2) { - if (edges_needed) { - pic->f->width = avctx->width + 2 * EDGE_WIDTH; - pic->f->height = avctx->height + 2 * EDGE_WIDTH; - } + if (edges_needed) { + pic->f->width = avctx->width + 2 * EDGE_WIDTH; + pic->f->height = avctx->height + 2 * EDGE_WIDTH; + + r = ff_encode_alloc_frame(avctx, pic->f); + } else if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && + avctx->codec_id != AV_CODEC_ID_VC1IMAGE && + avctx->codec_id != AV_CODEC_ID_MSS2) { r = ff_thread_get_ext_buffer(avctx, &pic->tf, pic->reference ? AV_GET_BUFFER_FLAG_REF : 0); } else { |