From: Rodeo Date: Tue, 20 Aug 2013 20:58:32 +0000 (+0000) Subject: QSV: update the condition to reclaim QSV resources when doing point 2 point encoding. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8fbd657f97f3d4b4fe8c3fcf76c4b39e7455b31;p=handbrake QSV: update the condition to reclaim QSV resources when doing point 2 point encoding. HB_VCODEC_QSV_H264 and the QSV context being non-NULL are both true even when --disable-qsv-decoding is used, so we need to check the presence of the QSV atom (NULL at this point if decoding is done via software). git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5727 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/sync.c b/libhb/sync.c index 975f05c8f..e32358663 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -344,27 +344,24 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, UpdateSearchState( w, next_start ); #ifdef USE_QSV - // as we drop prepared decode, we need to reclaim resources - if( job && job->vcodec == HB_VCODEC_QSV_H264 && job->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) { - hb_buffer_t *buf = next; - av_qsv_list* received_item = buf->qsv_details.qsv_atom; - av_qsv_context *qsv = job->qsv; - - if( received_item && qsv ) + av_qsv_stage *stage = av_qsv_get_last_stage(next->qsv_details.qsv_atom); + if (stage != NULL) { - av_qsv_stage *stage = av_qsv_get_last_stage(received_item); - if( stage ) + av_qsv_wait_on_sync(job->qsv, stage); + if (stage->out.sync->in_use > 0) { - av_qsv_wait_on_sync( 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); + 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( qsv->pipes, &received_item ); } + av_qsv_flush_stages(job->qsv->pipes, &next->qsv_details.qsv_atom); } #endif hb_buffer_close( &next );