summaryrefslogtreecommitdiff
path: root/libavcodec/snow.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-03-23 16:17:20 +0100
committerAnton Khirnov <anton@khirnov.net>2022-05-11 10:37:17 +0200
commitc954cf1e1b766a0d1992d5be0a8be0055a8e1a6a (patch)
tree244b9eb3d088011dc6ae1878eb2319a6050826b9 /libavcodec/snow.c
parenta4ce3706595edd9b537861f0e5447e31babf2100 (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/snow.c')
-rw-r--r--libavcodec/snow.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 97b0448dbf..293a0eb7d9 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -23,6 +23,7 @@
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "avcodec.h"
+#include "encode.h"
#include "me_cmp.h"
#include "snow_dwt.h"
#include "internal.h"
@@ -76,8 +77,11 @@ int ff_snow_get_buffer(SnowContext *s, AVFrame *frame)
if (edges_needed) {
frame->width += 2 * EDGE_WIDTH;
frame->height += 2 * EDGE_WIDTH;
- }
- if ((ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
+
+ ret = ff_encode_alloc_frame(s->avctx, frame);
+ } else
+ ret = ff_get_buffer(s->avctx, frame, AV_GET_BUFFER_FLAG_REF);
+ if (ret < 0)
return ret;
if (edges_needed) {
for (i = 0; frame->data[i]; i++) {