diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/bd.c | 11 | ||||
-rw-r--r-- | libhb/decmetadata.c | 26 | ||||
-rw-r--r-- | libhb/dvd.c | 21 | ||||
-rw-r--r-- | libhb/dvdnav.c | 18 | ||||
-rw-r--r-- | libhb/stream.c | 28 |
5 files changed, 67 insertions, 37 deletions
diff --git a/libhb/bd.c b/libhb/bd.c index bb051115a..f980dac03 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -457,14 +457,15 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) chapter = calloc( sizeof( hb_chapter_t ), 1 ); chapter->index = ii + 1; + sprintf( chapter->title, "Chapter %d", chapter->index ); + chapter->duration = ti->chapters[ii].duration; chapter->block_start = ti->chapters[ii].offset; - int seconds; - seconds = ( chapter->duration + 45000 ) / 90000; - chapter->hours = seconds / 3600; - chapter->minutes = ( seconds % 3600 ) / 60; - chapter->seconds = seconds % 60; + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); hb_log( "bd: chap %d packet=%"PRIu64", %"PRId64" ms", chapter->index, diff --git a/libhb/decmetadata.c b/libhb/decmetadata.c index bd848a95a..01f1b0dec 100644 --- a/libhb/decmetadata.c +++ b/libhb/decmetadata.c @@ -80,13 +80,25 @@ static void decmp4metadata( hb_title_t *title ) chapter = calloc( sizeof( hb_chapter_t ), 1 ); chapter->index = i; chapter->duration = chapter_list[i-1].duration * 90; - chapter->hours = chapter->duration / 90000 / 3600; - chapter->minutes = ( ( chapter->duration / 90000 ) % 3600 ) / 60; - chapter->seconds = ( chapter->duration / 90000 ) % 60; - strcpy( chapter->title, chapter_list[i-1].title ); - hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRId64", (%02i:%02i:%02i)", chapter->index, chapter->title, - chapter->duration, chapter->hours, - chapter->minutes, chapter->seconds); + + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); + + if( chapter_list[i-1].title ) + { + strcpy( chapter->title, chapter_list[i-1].title ); + } + else + { + sprintf( chapter->title, "Chapter %d", chapter->index ); + } + + hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRId64", (%02i:%02i:%02i)", + chapter->index, chapter->title, chapter->duration, + chapter->hours, chapter->minutes, chapter->seconds); + hb_list_add( title->list_chapter, chapter ); i++; } diff --git a/libhb/dvd.c b/libhb/dvd.c index 5dbe85072..f4260d5fc 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -170,7 +170,6 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur ifo_handle_t * vts = NULL; int pgc_id, pgn, i; hb_chapter_t * chapter; - int c; uint64_t duration; float duration_correction; unsigned char unused[1024]; @@ -562,12 +561,14 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur /* Chapters */ hb_log( "scan: title %d has %d chapters", t, vts->vts_ptt_srpt->title[title->ttn-1].nr_of_ptts ); - for( i = 0, c = 1; + for( i = 0; i < vts->vts_ptt_srpt->title[title->ttn-1].nr_of_ptts; i++ ) { chapter = calloc( sizeof( hb_chapter_t ), 1 ); + /* remember the on-disc chapter number */ chapter->index = i + 1; + sprintf( chapter->title, "Chapter %d", chapter->index ); pgc_id = vts->vts_ptt_srpt->title[title->ttn-1].ptt[i].pgcn; pgn = vts->vts_ptt_srpt->title[title->ttn-1].ptt[i].pgn; @@ -605,8 +606,8 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur FindNextCell( d ); d->cell_cur = d->cell_next; } + hb_list_add( title->list_chapter, chapter ); - c++; } /* The durations we get for chapters aren't precise. Scale them so @@ -620,13 +621,13 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur duration_correction = (float) title->duration / (float) duration; for( i = 0; i < hb_list_count( title->list_chapter ); i++ ) { - int seconds; - chapter = hb_list_item( title->list_chapter, i ); - chapter->duration = duration_correction * chapter->duration; - seconds = ( chapter->duration + 45000 ) / 90000; - chapter->hours = seconds / 3600; - chapter->minutes = ( seconds % 3600 ) / 60; - chapter->seconds = seconds % 60; + chapter = hb_list_item( title->list_chapter, i ); + chapter->duration = duration_correction * chapter->duration; + + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); hb_log( "scan: chap %d c=%d->%d, b=%"PRIu64"->%"PRIu64" (%"PRIu64"), %"PRId64" ms", chapter->index, chapter->cell_start, chapter->cell_end, diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index 8b356e188..e40a02f05 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -721,9 +721,11 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura { chapter = calloc( sizeof( hb_chapter_t ), 1 ); - chapter->index = c + 1; chapter->pgcn = pgcn; chapter->pgn = i; + chapter->index = c + 1; + sprintf( chapter->title, "Chapter %d", chapter->index ); + hb_list_add( title->list_chapter, chapter ); c++; } @@ -780,13 +782,13 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura duration_correction = (float) title->duration / (float) duration; for( i = 0; i < hb_list_count( title->list_chapter ); i++ ) { - int seconds; - chapter = hb_list_item( title->list_chapter, i ); - chapter->duration = duration_correction * chapter->duration; - seconds = ( chapter->duration + 45000 ) / 90000; - chapter->hours = seconds / 3600; - chapter->minutes = ( seconds % 3600 ) / 60; - chapter->seconds = seconds % 60; + chapter = hb_list_item( title->list_chapter, i ); + chapter->duration = duration_correction * chapter->duration; + + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); hb_log( "scan: chap %d c=%d->%d, b=%"PRIu64"->%"PRIu64" (%"PRIu64"), %"PRId64" ms", chapter->index, chapter->cell_start, chapter->cell_end, diff --git a/libhb/stream.c b/libhb/stream.c index 7961eebfb..48b1e9742 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -5501,15 +5501,29 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) chapter->index = i+1; chapter->duration = ( m->end / ( (double) m->time_base.num * m->time_base.den ) ) * 90000 - duration_sum; duration_sum += chapter->duration; - chapter->hours = chapter->duration / 90000 / 3600; - chapter->minutes = ( ( chapter->duration / 90000 ) % 3600 ) / 60; - chapter->seconds = ( chapter->duration / 90000 ) % 60; + + int seconds = ( chapter->duration + 45000 ) / 90000; + chapter->hours = ( seconds / 3600 ); + chapter->minutes = ( seconds % 3600 ) / 60; + chapter->seconds = ( seconds % 60 ); + tag = av_dict_get( m->metadata, "title", NULL, 0 ); - strcpy( chapter->title, tag ? tag->value : "" ); + /* Ignore generic chapter names set by MakeMKV ("Chapter 00" etc.). + * Our default chapter names are better. */ + if( tag && tag->value && + ( strncmp( "Chapter ", tag->value, 8 ) || strlen( tag->value ) > 11 ) ) + { + strcpy( chapter->title, tag->value ); + } + else + { + sprintf( chapter->title, "Chapter %d", chapter->index ); + } + hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRIu64", (%02i:%02i:%02i)", - chapter->index, chapter->title, - chapter->duration, chapter->hours, - chapter->minutes, chapter->seconds ); + chapter->index, chapter->title, chapter->duration, + chapter->hours, chapter->minutes, chapter->seconds ); + hb_list_add( title->list_chapter, chapter ); } } |