History

lavc/pthread_frame: Update user context in ff_frame_thread_free

Resolution/format changes lead to re-initialization of hardware accelerations(vaapi/dxva2/..) with new hwaccel_priv_data in the worker-thread. But hwaccel_priv_data in user context won't be updated until the resolution changing frame is output. A termination with "-vframes" just after the reinit will lead to: 1. memory leak in worker-thread. 2. double free in user-thread. Update user context in ff_frame_thread_free with the last thread submit_packet() was called on. To reproduce: ffmpeg -hwaccel vaapi(dxva2) -v verbose -i fate-suite/h264/reinit-large_420_8-to-small_420_8.h264 -pix_fmt nv12 -f rawvideo -vsync passthrough -vframes 47 -y out.yuv

Linjie Fu committed 6 years ago

Commit 091341f1 parent ddbd77d1 file · +7 −0Browse files

Unified · Split

libavcodec/pthread_frame.c+7−0
@@ -658,6 +658,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) · 657 unmodified lines
658 658
659 park_frame_worker_threads(fctx, thread_count);659 park_frame_worker_threads(fctx, thread_count);
660 660
661 if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
662 fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
663 if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 0) {
664 av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
665 }
666 }
667
661 if (fctx->prev_thread && fctx->prev_thread != fctx->threads)668 if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
662 if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {669 if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {
663 av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");670 av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t