diff options
author | eddyg <[email protected]> | 2007-10-09 02:23:44 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-10-09 02:23:44 +0000 |
commit | 1e3bd57546c713d238cad5b9d16faf61f50652e8 (patch) | |
tree | 0f24359c9301f661bbfc98dd045d52d2b2c7c1c6 /libhb | |
parent | b3178968037a18c721a66e2669ae6f040a12196a (diff) |
Fix to the chapter merging to ensure that when reading from the media we take into account chapters that we have merged. This prevents premature exiting from encoding.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1012 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/dvd.c | 12 | ||||
-rw-r--r-- | libhb/reader.c | 28 |
2 files changed, 30 insertions, 10 deletions
diff --git a/libhb/dvd.c b/libhb/dvd.c index 234e55bd2..6ecaab9e9 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -386,7 +386,8 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) pgc_t * pgc_next; chapter = calloc( sizeof( hb_chapter_t ), 1 ); - chapter->index = c; + /* remember the on-disc chapter number */ + chapter->index = i + 1; 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; @@ -439,14 +440,13 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t ) d->cell_cur = d->cell_next; } - if( chapter->block_count < 2048 && chapter->index > 1 ) + if( chapter->block_count < 2048 && c > 1 ) { - hb_log( "scan: chapter %d too short (%d blocks, " - "cells=%d->%d), merging", chapter->index, + hb_log( "scan: chapter %d(%d) too short (%d blocks, " + "cells=%d->%d), merging", c, chapter->index, chapter->block_count, chapter->cell_start, chapter->cell_end ); - chapter_old = hb_list_item( title->list_chapter, - chapter->index - 2 ); + chapter_old = hb_list_item( title->list_chapter, c - 2 ); chapter_old->cell_end = chapter->cell_end; chapter_old->block_end = chapter->block_end; chapter_old->block_count += chapter->block_count; diff --git a/libhb/reader.c b/libhb/reader.c index 4ced0a611..e53e3880c 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -58,6 +58,7 @@ static void ReaderFunc( void * _r ) hb_buffer_t * buf; hb_list_t * list; int chapter = -1; + int chapter_end = r->job->chapter_end; if( !( r->dvd = hb_dvd_init( r->title->dvd ) ) ) { @@ -69,7 +70,26 @@ static void ReaderFunc( void * _r ) if (r->dvd) { - if( !hb_dvd_start( r->dvd, r->title->index, r->job->chapter_start ) ) + /* + * XXX this code is a temporary hack that should go away if/when + * chapter merging goes away in libhb/dvd.c + * map the start and end chapter numbers to on-media chapter + * numbers since chapter merging could cause the handbrake numbers + * to diverge from the media numbers and, if our chapter_end is after + * a media chapter that got merged, we'll stop ripping too early. + */ + int start = r->job->chapter_start; + hb_chapter_t * chap = hb_list_item( r->title->list_chapter, chapter_end - 1 ); + + chapter_end = chap->index; + if (start > 1) + { + chap = hb_list_item( r->title->list_chapter, start - 1 ); + start = chap->index; + } + /* end chapter mapping XXX */ + + if( !hb_dvd_start( r->dvd, r->title->index, start ) ) { hb_dvd_close( &r->dvd ); return; @@ -99,10 +119,10 @@ static void ReaderFunc( void * _r ) hb_log( "reader: end of the title reached" ); break; } - if( chapter > r->job->chapter_end ) + if( chapter > chapter_end ) { - hb_log( "reader: end of chapter %d reached (%d)", - r->job->chapter_end, chapter ); + hb_log( "reader: end of chapter %d (media %d) reached at media chapter %d", + r->job->chapter_end, chapter_end, chapter ); break; } |