sync: move chapter logging to sync.c
authorJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 17 May 2016 19:42:50 +0000 (13:42 -0600)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 17 May 2016 19:42:50 +0000 (13:42 -0600)
libhb/decavcodec.c
libhb/sync.c

index 83bbcf517d9f5f1d912f666ed4834db7f1f812a1..c35ec6343733766b4b8598f47f066d94fffc01ec 100644 (file)
@@ -909,26 +909,6 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv )
     return out;
 }
 
-static void log_chapter( hb_work_private_t *pv, int chap_num, int64_t pts )
-{
-    hb_chapter_t *c;
-
-    if ( !pv->job )
-        return;
-
-    c = hb_list_item( pv->job->list_chapter, chap_num - 1 );
-    if ( c && c->title )
-    {
-        hb_log( "%s: \"%s\" (%d) at frame %u time %"PRId64,
-                pv->context->codec->name, c->title, chap_num, pv->nframes, pts );
-    }
-    else
-    {
-        hb_log( "%s: Chapter %d at frame %u time %"PRId64,
-                pv->context->codec->name, chap_num, pv->nframes, pts );
-    }
-}
-
 static void flushDelayQueue( hb_work_private_t *pv )
 {
     hb_buffer_t *buf;
@@ -1250,7 +1230,6 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int64_t pt
             if ( pv->new_chap && buf->s.start >= pv->chap_time )
             {
                 buf->s.new_chap = pv->new_chap;
-                log_chapter( pv, pv->new_chap, buf->s.start );
                 pv->new_chap = 0;
                 pv->chap_time = 0;
             }
@@ -1289,7 +1268,6 @@ static int decodeFrame( hb_work_object_t *w, uint8_t *data, int size, int64_t pt
             if ( pv->new_chap && buf->s.start >= pv->chap_time )
             {
                 buf->s.new_chap = pv->new_chap;
-                log_chapter( pv, pv->new_chap, buf->s.start );
                 pv->new_chap = 0;
                 pv->chap_time = 0;
             }
index 8375edc61bef9f1c1324bd82fba128f3959edb65..2ee82e7a370aeb74766369a234fc139b8c4c79a7 100644 (file)
@@ -133,6 +133,8 @@ struct sync_common_s
     uint64_t   st_counts[4];
     uint64_t   st_dates[4];
     uint64_t   st_first;
+
+    int             chapter;
 };
 
 struct hb_work_private_s
@@ -774,6 +776,27 @@ static void streamFlush( sync_stream_t * stream )
     hb_buffer_list_append(&stream->out_queue, hb_buffer_eof_init());
 }
 
+static void log_chapter( sync_common_t *common, int chap_num,
+                         int nframes, int64_t pts )
+{
+    hb_chapter_t *c;
+
+    if ( !common->job )
+        return;
+
+    c = hb_list_item( common->job->list_chapter, chap_num - 1 );
+    if ( c && c->title )
+    {
+        hb_log("sync: \"%s\" (%d) at frame %d time %"PRId64,
+               c->title, chap_num, nframes, pts);
+    }
+    else
+    {
+        hb_log("sync: Chapter %d at frame %d time %"PRId64,
+               chap_num, nframes, pts );
+    }
+}
+
 #define TOP_FIRST PIC_FLAG_TOP_FIELD_FIRST
 #define PROGRESSIVE PIC_FLAG_PROGRESSIVE_FRAME
 #define REPEAT_FIRST PIC_FLAG_REPEAT_FIRST_FIELD
@@ -1109,6 +1132,13 @@ static void OutputBuffer( sync_common_t * common )
             {
                 out_stream->max_frame_duration = buf->s.duration;
             }
+            if (out_stream->type == SYNC_TYPE_VIDEO &&
+                buf->s.new_chap   > common->chapter)
+            {
+                common->chapter = buf->s.new_chap;
+                log_chapter(common, buf->s.new_chap, out_stream->frame_count,
+                            buf->s.start);
+            }
             hb_buffer_list_append(&out_stream->out_queue, buf);
         }
     } while (full);