diff options
author | eddyg <eddyg.hb@myreflection.org> | 2007-10-09 02:23:44 +0000 |
---|---|---|
committer | eddyg <eddyg.hb@myreflection.org> | 2007-10-09 02:23:44 +0000 |
commit | 1e3bd57546c713d238cad5b9d16faf61f50652e8 (patch) | |
tree | 0f24359c9301f661bbfc98dd045d52d2b2c7c1c6 /libhb/reader.c | |
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/reader.c')
-rw-r--r-- | libhb/reader.c | 28 |
1 files changed, 24 insertions, 4 deletions
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; } |