diff options
author | dynaflash <[email protected]> | 2007-04-25 17:24:58 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-04-25 17:24:58 +0000 |
commit | cdcdac58032b929a7edea0459047a9cb56da767d (patch) | |
tree | c0aad497331fe94fb7f6b13b9600283f9350cf59 /test/test.c | |
parent | e1f55561971a286170d003d20eff51c9a5563f43 (diff) |
Fix Previous Bad commit for Cyanders Chapter Markers
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@548 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test/test.c')
-rw-r--r-- | test/test.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/test/test.c b/test/test.c index 903b330b6..967cd9c11 100644 --- a/test/test.c +++ b/test/test.c @@ -11,6 +11,7 @@ #include <unistd.h> #include "hb.h" +#include "parsecsv.h" /* Options */ static int debug = HB_DEBUG_NONE; @@ -44,6 +45,7 @@ static int pixelratio = 0; static int chapter_start = 0; static int chapter_end = 0; static int chapter_markers = 0; +static char * marker_file = NULL; static int crf = 0; static char *x264opts = NULL; static char *x264opts2 = NULL; @@ -314,6 +316,53 @@ static int HandleEvents( hb_handle_t * h ) if ( chapter_markers ) { job->chapter_markers = chapter_markers; + + if( marker_file != NULL ) + { + hb_csv_file_t * file = hb_open_csv_file( marker_file ); + hb_csv_cell_t * cell; + int row = 0; + int chapter = 0; + + fprintf( stderr, "Reading chapter markers from file %s\n", marker_file ); + + if( file == NULL ) + { + fprintf( stderr, "Cannot open chapter marker file, using defaults\n" ); + } + else + { + /* Parse the cells */ + while( NULL != ( cell = hb_read_next_cell( file ) ) ) + { + /* We have a chapter number */ + if( cell->cell_col == 0 ) + { + row = cell->cell_row; + chapter = atoi( cell->cell_text ); + } + + /* We have a chapter name */ + if( cell->cell_col == 1 && row == cell->cell_row ) + { + /* If we have a valid chapter, copy the string an terminate it */ + if( chapter >= job->chapter_start && chapter <= job->chapter_end ) + { + hb_chapter_t * chapter_s; + + chapter_s = hb_list_item( job->title->list_chapter, chapter - 1); + strncpy(chapter_s->title, cell->cell_text, 1023); + chapter_s->title[1023] = '\0'; + } + } + + + hb_dispose_cell( cell ); + } + + hb_close_csv_file( file ); + } + } } if( crop[0] >= 0 && crop[1] >= 0 && @@ -650,7 +699,7 @@ static int ParseOptions( int argc, char ** argv ) { "title", required_argument, NULL, 't' }, { "chapters", required_argument, NULL, 'c' }, - { "markers", no_argument, NULL, 'm' }, + { "markers", optional_argument, NULL, 'm' }, { "audio", required_argument, NULL, 'a' }, { "mixdown", required_argument, NULL, '6' }, { "subtitle", required_argument, NULL, 's' }, @@ -740,6 +789,10 @@ static int ParseOptions( int argc, char ** argv ) break; } case 'm': + if( optarg != NULL ) + { + marker_file = strdup( optarg ); + } chapter_markers = 1; break; case 'a': |