]> granicus.if.org Git - handbrake/commitdiff
avfilter: fix flushing final frame
authorJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 31 May 2018 17:27:35 +0000 (10:27 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 31 May 2018 18:02:37 +0000 (11:02 -0700)
Fixes https://github.com/HandBrake/HandBrake/issues/1357

(cherry picked from commit f70380a7b1c99f919712cb69b28bfc48eeb0b83d)

libhb/avfilter.c

index b8262142680900707738bd4162bf1cf405d1a23f..91b5713017ef8bcb4b7d2304279f8290283733c4 100644 (file)
@@ -406,8 +406,15 @@ static hb_buffer_t* filterFrame( hb_filter_private_t * pv, hb_buffer_t * in )
     int                result;
     hb_buffer_list_t   list;
 
-    fill_frame(pv, pv->frame, in);
-    result = av_buffersrc_add_frame(pv->input, pv->frame);
+    if (in != NULL)
+    {
+        fill_frame(pv, pv->frame, in);
+        result = av_buffersrc_add_frame(pv->input, pv->frame);
+    }
+    else
+    {
+        result = av_buffersrc_add_frame(pv->input, NULL);
+    }
     if (result < 0)
     {
         return NULL;
@@ -444,11 +451,13 @@ static int avfilter_work( hb_filter_object_t * filter,
 
     if (in->s.flags & HB_BUF_FLAG_EOF)
     {
+        hb_buffer_t * out  = filterFrame(pv, NULL);
         hb_buffer_t * last = hb_buffer_list_tail(&pv->list);
         if (last != NULL && last->s.start != AV_NOPTS_VALUE)
         {
             last->s.stop = last->s.start + last->s.duration;
         }
+        hb_buffer_list_prepend(&pv->list, out);
         hb_buffer_list_append(&pv->list, in);
         *buf_out = hb_buffer_list_clear(&pv->list);
         *buf_in = NULL;