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 );