OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o
diff -Naur ../../libav-v9.3/libavcodec/qsv.c ./libavcodec/qsv.c
--- ../../libav-v9.3/libavcodec/qsv.c 1970-01-01 01:00:00.000000000 +0100
-+++ ./libavcodec/qsv.c 2013-05-15 17:13:43.317341393 +0200
-@@ -0,0 +1,621 @@
++++ ./libavcodec/qsv.c 2013-05-19 14:46:43.248504511 +0200
+@@ -0,0 +1,645 @@
+/* ********************************************************************* *\
+
+Copyright (C) 2013 Intel Corporation. All rights reserved.
+{
+ if ((*stage)->out.sync) {
+ *(*stage)->out.sync->p_sync = 0;
++ if( (*stage)->out.sync->in_use > 0 )
+ ff_qsv_atomic_dec(&(*stage)->out.sync->in_use);
+ (*stage)->out.sync = 0;
+ }
+ MFXClose(mfx_session);
+ return sts;
+}
++
++void av_qsv_wait_on_sync(av_qsv_context *qsv, av_qsv_stage *stage)
++{
++ int iter = 0;
++ mfxStatus sts = MFX_ERR_NONE;
++ if( stage )
++ if(*stage->out.sync->p_sync){
++ while(1){
++ iter++;
++ sts = MFXVideoCORE_SyncOperation(qsv->mfx_session,*stage->out.sync->p_sync, AV_QSV_SYNC_TIME_DEFAULT);
++ if(MFX_WRN_IN_EXECUTION == sts){
++
++ if(iter>20)
++ AV_QSV_DEBUG_ASSERT(1, "Sync failed");
++
++ av_qsv_sleep(10);
++ continue;
++ }
++ AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
++ break;
++ }
++ }
++}
+\ No newline at end of file
diff -Naur ../../libav-v9.3/libavcodec/qsv.h ./libavcodec/qsv.h
--- ../../libav-v9.3/libavcodec/qsv.h 1970-01-01 01:00:00.000000000 +0100
-+++ ./libavcodec/qsv.h 2013-05-15 17:13:43.321341889 +0200
-@@ -0,0 +1,493 @@
++++ ./libavcodec/qsv.h 2013-05-19 14:46:43.249504634 +0200
+@@ -0,0 +1,494 @@
+/* ********************************************************************* *\
+
+Copyright (C) 2013 Intel Corporation. All rights reserved.
+int av_qsv_get_free_encode_task(av_qsv_list *);
+
+int av_is_qsv_available(mfxIMPL, mfxVersion *);
++void av_qsv_wait_on_sync(av_qsv_context *, av_qsv_stage *);
+
+void av_qsv_add_context_usage(av_qsv_context *, int);
+
+#endif //AVCODEC_QSV_H
diff -Naur ../../libav-v9.3/libavcodec/qsv_h264.c ./libavcodec/qsv_h264.c
--- ../../libav-v9.3/libavcodec/qsv_h264.c 1970-01-01 01:00:00.000000000 +0100
-+++ ./libavcodec/qsv_h264.c 2013-05-15 17:13:43.320341765 +0200
++++ ./libavcodec/qsv_h264.c 2013-05-19 14:46:43.248504511 +0200
@@ -0,0 +1,959 @@
+/* ********************************************************************* *\
+
+};
diff -Naur ../../libav-v9.3/libavcodec/qsv_h264.h ./libavcodec/qsv_h264.h
--- ../../libav-v9.3/libavcodec/qsv_h264.h 1970-01-01 01:00:00.000000000 +0100
-+++ ./libavcodec/qsv_h264.h 2013-05-15 17:13:43.335343623 +0200
++++ ./libavcodec/qsv_h264.h 2013-05-19 14:46:43.261506110 +0200
@@ -0,0 +1,64 @@
+/* ********************************************************************* *\
+
// only here we need to wait on operation been completed, therefore SyncOperation is used,
// after this step - we continue to work with bitstream, muxing ...
- if(*stage->out.sync->p_sync){
- int iter = 0;
- while(1){
- iter++;
- sts = MFXVideoCORE_SyncOperation(qsv->mfx_session,*stage->out.sync->p_sync, AV_QSV_SYNC_TIME_DEFAULT); // Synchronize. Wait until frame processing is ready, also care about MFX_WRN_IN_EXECUTION
- if(MFX_WRN_IN_EXECUTION == sts){
-
- //normally, should be here
- if(iter>20)
- DEBUG_ASSERT(1, "Sync failed within encode.");
-
- av_qsv_sleep(10);
- continue;
- }
- AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
- break;
- }
+ av_qsv_wait_on_sync( qsv,stage );
if(task->bs->DataLength>0){
av_qsv_flush_stages( qsv->pipes, &this_pipe );
pv->frames_out++;
}
}
- }
}while(is_end);
av_qsv_stage* stage = av_qsv_get_last_stage( out->qsv_details.qsv_atom );
mfxFrameSurface1 *work_surface = stage->out.p_surface;
- if(stage->out.sync && *stage->out.sync->p_sync){
- int iter = 0;
- while(1){
- iter++;
- sts = MFXVideoCORE_SyncOperation(qsv->mfx_session,*stage->out.sync->p_sync, AV_QSV_SYNC_TIME_DEFAULT);
- if(MFX_WRN_IN_EXECUTION == sts){
-
- //normally, should be here
- if(iter>20)
- DEBUG_ASSERT(1, "Sync failed within encode.");
-
- av_qsv_sleep(10);
- continue;
- }
- AV_QSV_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
- break;
- }
- }
+ av_qsv_wait_on_sync( qsv,stage );
+
av_qsv_space *qsv_vpp = pv->vpp_space;
int64_t duration = ((double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtD/(double)qsv_vpp->m_mfxVideoParam.vpp.Out.FrameRateExtN ) * 90000.;
out->s.start = work_surface->Data.TimeStamp;
hb_unlock( pv->common->mutex );
UpdateSearchState( w, next_start );
+
+ // as we drop prepared decode, we need to reclaim resources
+ if( job && job->vcodec == HB_VCODEC_QSV_H264 && job->qsv )
+ {
+ 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(received_item);
+ if( stage )
+ {
+ 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);
+ }
+ av_qsv_flush_stages( qsv->pipes, &received_item );
+ }
+ }
hb_buffer_close( &next );
return HB_WORK_OK;