[FFmpeg-cvslog] avcodec/snow: ensure current_picture is writable before modifying its data
James Almer
git at videolan.org
Wed Jun 10 00:22:48 EEST 2020
ffmpeg | branch: release/4.3 | James Almer <jamrial at gmail.com> | Fri May 29 13:59:12 2020 -0300| [52dc21a68df37f5aa36b334de4d10747780bff9d] | committer: James Almer
avcodec/snow: ensure current_picture is writable before modifying its data
current_picture was not writable here because a reference existed in
at least avctx->coded_frame, and potentially elsewhere if the caller
created new ones from it.
Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit 1ee3c984b91e0241068d1c093d222ecec2e6052c)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=52dc21a68df37f5aa36b334de4d10747780bff9d
---
libavcodec/snowenc.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index fb8983cd2f..b1cf1426ee 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1625,10 +1625,22 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->lambda = 0;
}//else keep previous frame's qlog until after motion estimation
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+ av_frame_unref(avctx->coded_frame);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (s->current_picture->data[0]) {
int w = s->avctx->width;
int h = s->avctx->height;
+#if FF_API_CODED_FRAME
+ ret = av_frame_make_writable(s->current_picture);
+ if (ret < 0)
+ return ret;
+#endif
+
s->mpvencdsp.draw_edges(s->current_picture->data[0],
s->current_picture->linesize[0], w , h ,
EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM);
@@ -1646,7 +1658,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ff_snow_frame_start(s);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
- av_frame_unref(avctx->coded_frame);
ret = av_frame_ref(avctx->coded_frame, s->current_picture);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
More information about the ffmpeg-cvslog
mailing list