summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c44
1 files changed, 44 insertions, 0 deletions
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;
}