From d41905d539046445e1b81499ff7bd04d170c91d4 Mon Sep 17 00:00:00 2001 From: Rodeo Date: Thu, 22 Aug 2013 20:33:35 +0000 Subject: Big merge, QSV to trunk: part 1 (tracked files). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5737 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/sync.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'libhb/sync.c') diff --git a/libhb/sync.c b/libhb/sync.c index c04e517d4..8134688b3 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -527,6 +527,27 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_unlock( pv->common->mutex ); UpdateSearchState( w, next_start ); +#ifdef USE_QSV + // reclaim QSV resources before dropping the buffer + // when decoding without QSV, the QSV atom will be NULL + if (job != NULL && job->qsv != NULL && next->qsv_details.qsv_atom != NULL) + { + av_qsv_stage *stage = av_qsv_get_last_stage(next->qsv_details.qsv_atom); + if (stage != NULL) + { + av_qsv_wait_on_sync(job->qsv, stage); + if (stage->out.sync->in_use > 0) + { + ff_qsv_atomic_dec(&stage->out.sync->in_use); + } + if (stage->out.p_surface->Data.Locked > 0) + { + ff_qsv_atomic_dec(&stage->out.p_surface->Data.Locked); + } + } + av_qsv_flush_stages(job->qsv->pipes, &next->qsv_details.qsv_atom); + } +#endif hb_buffer_close( &next ); return HB_WORK_OK; @@ -720,6 +741,29 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, // don't drop a chapter mark when we drop the buffer sync->chap_mark = next->s.new_chap; } + +#ifdef USE_QSV + // reclaim QSV resources before dropping the buffer + // when decoding without QSV, the QSV atom will be NULL + if (job != NULL && job->qsv != NULL && next->qsv_details.qsv_atom != NULL) + { + av_qsv_stage *stage = av_qsv_get_last_stage(next->qsv_details.qsv_atom); + if (stage != NULL) + { + av_qsv_wait_on_sync(job->qsv, stage); + if (stage->out.sync->in_use > 0) + { + ff_qsv_atomic_dec(&stage->out.sync->in_use); + } + if (stage->out.p_surface->Data.Locked > 0) + { + ff_qsv_atomic_dec(&stage->out.p_surface->Data.Locked); + } + } + av_qsv_flush_stages(job->qsv->pipes, &next->qsv_details.qsv_atom); + } +#endif + hb_buffer_close( &next ); return HB_WORK_OK; } -- cgit v1.2.3