[FFmpeg-cvslog] lavc/videotoolboxenc: flush/free frames on close

Rick Kern git at videolan.org
Mon Oct 17 16:00:37 EEST 2016


ffmpeg | branch: master | Rick Kern <kernrj at gmail.com> | Mon Oct 10 09:13:39 2016 -0400| [aa413b810a7f94d8317635160a1de1b573b138ee] | committer: Rick Kern

lavc/videotoolboxenc: flush/free frames on close

Prevents encode callback from running after codec is closed.
Fixes a crash when an error is returned.

Signed-off-by: Rick Kern <kernrj at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa413b810a7f94d8317635160a1de1b573b138ee
---

 libavcodec/videotoolboxenc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index d910049..73e673f 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -145,6 +145,11 @@ static void set_async_error(VTEncContext *vtctx, int err)
     pthread_mutex_unlock(&vtctx->lock);
 }
 
+static void clear_frame_queue(VTEncContext *vtctx)
+{
+    set_async_error(vtctx, 0);
+}
+
 static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf, ExtraSEI **sei)
 {
     BufNode *info;
@@ -1966,6 +1971,9 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
 
     if(!vtctx->session) return 0;
 
+    VTCompressionSessionCompleteFrames(vtctx->session,
+                                       kCMTimeIndefinite);
+    clear_frame_queue(vtctx);
     pthread_cond_destroy(&vtctx->cv_sample_sent);
     pthread_mutex_destroy(&vtctx->lock);
     CFRelease(vtctx->session);



More information about the ffmpeg-cvslog mailing list