aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/videotoolbox.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2017-02-21 10:48:37 -0800
committerwm4 <nfxjfg@googlemail.com>2017-03-07 11:58:38 +0100
commitb6eaa3928e198554a3934dd5ad6eac4d16f27df2 (patch)
treeac5d26ca5881babd93877dda02eb461b8219194d /libavcodec/videotoolbox.c
parent734d760e2fb2621040edef3536b5935e7bc45351 (diff)
downloadffmpeg-b6eaa3928e198554a3934dd5ad6eac4d16f27df2.tar.gz
avcodec/h264, videotoolbox: fix crash after VT decoder fails
The way videotoolbox hooks in as a hwaccel is pretty hacky. The VT decode API is not invoked until end_frame(), so alloc_frame() returns a dummy frame with a 1-byte buffer. When end_frame() is eventually called, the dummy buffer is replaced with the actual decoded data from VTDecompressionSessionDecodeFrame(). When the VT decoder fails, the frame returned to the h264 decoder from alloc_frame() remains invalid and should not be used. Before 9747219958060d8c4f697df62e7f172c2a77e6c7, it was accidentally being returned all the way up to the API user. After that commit, the dummy frame was unref'd so the user received an error. However, since that commit, VT hwaccel failures started causing random segfaults in the h264 decoder. This happened more often on iOS where the VT implementation is more likely to throw errors on bitstream anomolies. A recent report of this issue can be see in http://ffmpeg.org/pipermail/libav-user/2016-November/009831.html The issue here is that the dummy frame is still referenced internally by the h264 decoder, as part of the reflist and cur_pic_ptr. Deallocating the frame causes assertions like this one to trip later on during decoding: Assertion h->cur_pic_ptr->f->buf[0] failed at src/libavcodec/h264_slice.c:1340 With this commit, we leave the dummy 1-byte frame intact, but avoid returning it to the user. This reverts commit 9747219958060d8c4f697df62e7f172c2a77e6c7. Signed-off-by: wm4 <nfxjfg@googlemail.com>
Diffstat (limited to 'libavcodec/videotoolbox.c')
-rw-r--r--libavcodec/videotoolbox.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 9199b02055..67adad53ed 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -352,8 +352,6 @@ static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
AVVideotoolboxContext *videotoolbox = avctx->hwaccel_context;
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
- av_buffer_unref(&frame->buf[0]);
-
if (!videotoolbox->session || !vtctx->bitstream)
return AVERROR_INVALIDDATA;