]> granicus.if.org Git - handbrake/commitdiff
QSV: update the condition to reclaim QSV resources when doing point 2 point encoding.
authorRodeo <tdskywalker@gmail.com>
Tue, 20 Aug 2013 20:58:32 +0000 (20:58 +0000)
committerRodeo <tdskywalker@gmail.com>
Tue, 20 Aug 2013 20:58:32 +0000 (20:58 +0000)
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

libhb/sync.c

index 975f05c8f01598fdf45fa2894964da4e29c029d2..e32358663e9ade7725fb35e663cb152110b01a44 100644 (file)
@@ -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 );