summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decavcodec.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index f8a06992f..19bd56c45 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1044,10 +1044,6 @@ static int decavcodecviWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_buffer_t ** buf_out )
{
hb_work_private_t *pv = w->private_data;
- if ( ! pv->context )
- {
- init_ffmpeg_context( w );
- }
hb_buffer_t *in = *buf_in;
*buf_in = NULL;
@@ -1055,7 +1051,7 @@ static int decavcodecviWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
if ( in->size == 0 )
{
/* flush any frames left in the decoder */
- while ( decodeFrame( pv, NULL, 0 ) )
+ while ( pv->context && decodeFrame( pv, NULL, 0 ) )
{
}
flushDelayQueue( pv );
@@ -1064,6 +1060,11 @@ static int decavcodecviWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
return HB_WORK_DONE;
}
+ if ( ! pv->context )
+ {
+ init_ffmpeg_context( w );
+ }
+
int64_t pts = in->start;
if( pts >= 0 )
{