aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHao Guan <hguandl@gmail.com>2024-06-21 14:08:20 +0800
committerZhao Zhili <zhilizhao@tencent.com>2024-07-07 18:46:02 +0800
commitcd2f8a22e94700c68b1de7968df11e8bebfd315b (patch)
treefeb51115838984c9ff5e1119dd197b40f78a01a8
parent24b3bad811f147ebb089048f64fea97a1e627243 (diff)
downloadffmpeg-cd2f8a22e94700c68b1de7968df11e8bebfd315b.tar.gz
avcodec/videotoolboxenc: fix vtctx reset condition
In vtenc_populate_extradata, the cleanup function vtenc_reset should not be used when no error occurs, otherwise some color information is lost (#11036). This patch checks the status code and conducts the correct cleanup. Signed-off-by: Hao Guan <hguandl@gmail.com> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--libavcodec/videotoolboxenc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 42065cbcb3..bc505abee4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2767,7 +2767,14 @@ static int vtenc_populate_extradata(AVCodecContext *avctx,
pe_cleanup:
CVPixelBufferRelease(pix_buf);
- vtenc_reset(vtctx);
+
+ if (status) {
+ vtenc_reset(vtctx);
+ } else if (vtctx->session) {
+ CFRelease(vtctx->session);
+ vtctx->session = NULL;
+ }
+
vtctx->frame_ct_out = 0;
av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 0));