summaryrefslogtreecommitdiffstats
path: root/libhb/muxavformat.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-05-17 11:51:25 -0600
committerJohn Stebbins <[email protected]>2016-05-17 11:51:25 -0600
commitde858d1600ac61258dc895b2fc8756b7c5d1d3a8 (patch)
treecdbd82e3d9ee83cfb9a31ebbb034852aa36fb2cb /libhb/muxavformat.c
parent9dcce9df07f4db1fa61f25ffeb106aa00bd64190 (diff)
libhb: send initial chapter through pipeline
Eliminate the need for everyone to assume that the first chapter starts at the first frame.
Diffstat (limited to 'libhb/muxavformat.c')
-rw-r--r--libhb/muxavformat.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c
index ef72130b6..0a69d83f8 100644
--- a/libhb/muxavformat.c
+++ b/libhb/muxavformat.c
@@ -197,7 +197,7 @@ static int avformatInit( hb_mux_object_t * m )
job->mux_data = track;
track->type = MUX_TYPE_VIDEO;
- track->prev_chapter_tc = 0;
+ track->prev_chapter_tc = AV_NOPTS_VALUE;
track->st = avformat_new_stream(m->oc, NULL);
if (track->st == NULL)
{
@@ -1156,33 +1156,37 @@ static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *bu
{
if (job->chapter_markers && buf->s.new_chap)
{
- hb_chapter_t *chapter;
-
- // reached chapter N, write marker for chapter N-1
- // we don't know the end time of chapter N-1 till we receive
- // chapter N. So we are always writing the previous chapter
- // mark.
- track->current_chapter = buf->s.new_chap - 1;
-
- // chapter numbers start at 1, but the list starts at 0
- chapter = hb_list_item(job->list_chapter,
- track->current_chapter - 1);
-
- // make sure we're not writing a chapter that has 0 length
- if (chapter != NULL && track->prev_chapter_tc < pkt.pts)
+ if (track->current_chapter > 0)
{
- char title[1024];
- if (chapter->title != NULL)
- {
- snprintf(title, 1023, "%s", chapter->title);
- }
- else
+ hb_chapter_t *chapter;
+
+ // reached chapter N, write marker for chapter N-1
+ // we don't know the end time of chapter N-1 till we receive
+ // chapter N. So we are always writing the previous chapter
+ // mark.
+ // chapter numbers start at 1, but the list starts at 0
+ chapter = hb_list_item(job->list_chapter,
+ track->current_chapter - 1);
+
+ // make sure we're not writing a chapter that has 0 length
+ if (chapter != NULL &&
+ track->prev_chapter_tc != AV_NOPTS_VALUE &&
+ track->prev_chapter_tc < pkt.pts)
{
- snprintf(title, 1023, "Chapter %d",
- track->current_chapter);
+ char title[1024];
+ if (chapter->title != NULL)
+ {
+ snprintf(title, 1023, "%s", chapter->title);
+ }
+ else
+ {
+ snprintf(title, 1023, "Chapter %d",
+ track->current_chapter);
+ }
+ add_chapter(m, track->prev_chapter_tc, pkt.pts, title);
}
- add_chapter(m, track->prev_chapter_tc, pkt.pts, title);
}
+ track->current_chapter = buf->s.new_chap;
track->prev_chapter_tc = pkt.pts;
}
} break;
@@ -1362,7 +1366,7 @@ static int avformatEnd(hb_mux_object_t *m)
hb_chapter_t *chapter;
// get the last chapter
- chapter = hb_list_item(job->list_chapter, track->current_chapter++);
+ chapter = hb_list_item(job->list_chapter, track->current_chapter - 1);
// only write the last chapter marker if it lasts at least 1.5 second
if (chapter != NULL && chapter->duration > 135000LL)