X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test%2Ftest.c;h=fb26df9d7bd1db57d422c17d616222d5012ef98a;hb=9155051f96ff6f923fe2137e0730a300e8ce1404;hp=aa09a34c7ffdb5b2542a36df077ba18d076a91bc;hpb=d1410d443fc439f41ac0cf61d4dda624e897eb01;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/test/test.c b/test/test.c index aa09a34c..fb26df9d 100644 --- a/test/test.c +++ b/test/test.c @@ -37,7 +37,8 @@ static char * input = NULL; static char * output = NULL; static char * format = NULL; static int titleindex = 1; -static int longest_title = 0; +static int titlescan = 0; +static int main_feature = 0; static char * native_language = NULL; static int native_dub = 0; static int twoPass = 0; @@ -213,6 +214,7 @@ int main( int argc, char ** argv ) "date.\n" ); } hb_close( &h ); + hb_global_close(); return 0; } @@ -232,9 +234,9 @@ int main( int argc, char ** argv ) /* Feed libhb with a DVD to scan */ fprintf( stderr, "Opening %s...\n", input ); - if (longest_title) { + if (main_feature) { /* - * We need to scan for all the titles in order to find the longest + * We need to scan for all the titles in order to find the main feature */ titleindex = 0; } @@ -324,6 +326,7 @@ int main( int argc, char ** argv ) /* Clean up */ hb_close( &h ); + hb_global_close(); if( input ) free( input ); if( output ) free( output ); if( format ) free( format ); @@ -375,6 +378,10 @@ static void PrintTitleInfo( hb_title_t * title ) int i; fprintf( stderr, "+ title %d:\n", title->index ); + if ( title->index == title->job->feature ) + { + fprintf( stderr, " + Main Feature\n" ); + } if ( title->type == HB_STREAM_TYPE ) { fprintf( stderr, " + stream: %s\n", title->path ); @@ -480,7 +487,7 @@ static int HandleEvents( hb_handle_t * h ) case HB_STATE_SCANNING: /* Show what title is currently being scanned */ fprintf( stderr, "Scanning title %d", p.title_cur ); - if( !titleindex ) + if( !titleindex || titlescan ) fprintf( stderr, " of %d", p.title_count ); fprintf( stderr, "...\n" ); break; @@ -511,15 +518,15 @@ static int HandleEvents( hb_handle_t * h ) die = 1; break; } - if( longest_title ) + if( main_feature ) { int i; - int longest_title_idx=0; - int longest_title_pos=-1; - int longest_title_time=0; + int main_feature_idx=0; + int main_feature_pos=-1; + int main_feature_time=0; int title_time; - fprintf( stderr, "Searching for longest title...\n" ); + fprintf( stderr, "Searching for main feature title...\n" ); for( i = 0; i < hb_list_count( list ); i++ ) { @@ -527,29 +534,36 @@ static int HandleEvents( hb_handle_t * h ) title_time = (title->hours*60*60 ) + (title->minutes *60) + (title->seconds); fprintf( stderr, " + Title (%d) index %d has length %dsec\n", i, title->index, title_time ); - if( longest_title_time < title_time ) + if( main_feature_time < title_time ) { - longest_title_time = title_time; - longest_title_pos = i; - longest_title_idx = title->index; + main_feature_time = title_time; + main_feature_pos = i; + main_feature_idx = title->index; + } + if( title->job->feature == title->index ) + { + main_feature_time = title_time; + main_feature_pos = i; + main_feature_idx = title->index; + break; } } - if( longest_title_pos == -1 ) + if( main_feature_pos == -1 ) { - fprintf( stderr, "No longest title found.\n" ); + fprintf( stderr, "No main feature title found.\n" ); die = 1; break; } - titleindex = longest_title_idx; - fprintf( stderr, "Found longest title, setting title to %d\n", - longest_title_idx); + titleindex = main_feature_idx; + fprintf( stderr, "Found main feature title, setting title to %d\n", + main_feature_idx); - title = hb_list_item( list, longest_title_pos); + title = hb_list_item( list, main_feature_pos); } else { title = hb_list_item( list, 0 ); } - if( !titleindex ) + if( !titleindex || titlescan ) { /* Scan-only mode, print infos and exit */ int i; @@ -623,7 +637,10 @@ static int HandleEvents( hb_handle_t * h ) { x264opts = strdup("cabac=0:ref=2:me=umh:bframes=0:8x8dct=0:trellis=0:subme=6"); } - anamorphic_mode = 2; + if( !anamorphic_mode ) + { + anamorphic_mode = 2; + } job->chapter_markers = 1; } @@ -744,9 +761,12 @@ static int HandleEvents( hb_handle_t * h ) maxWidth = 960; if( !x264opts ) { - x264opts = strdup("cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0"); + x264opts = strdup("cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500"); + } + if( !anamorphic_mode ) + { + anamorphic_mode = 2; } - anamorphic_mode = 2; job->chapter_markers = 1; } @@ -786,7 +806,10 @@ static int HandleEvents( hb_handle_t * h ) { x264opts = strdup("ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0"); } - anamorphic_mode = 1; + if( !anamorphic_mode ) + { + anamorphic_mode = 1; + } job->chapter_markers = 1; } @@ -828,7 +851,10 @@ static int HandleEvents( hb_handle_t * h ) } detelecine = 1; decomb = 1; - anamorphic_mode = 2; + if( !anamorphic_mode ) + { + anamorphic_mode = 2; + } job->chapter_markers = 1; } @@ -902,7 +928,10 @@ static int HandleEvents( hb_handle_t * h ) { x264opts = strdup("ref=1:subme=5:me=umh:no-fast-pskip=1:cabac=0:weightb=0:8x8dct=0:trellis=0"); } - anamorphic_mode = 1; + if( !anamorphic_mode ) + { + anamorphic_mode = 1; + } job->chapter_markers = 1; } @@ -1134,7 +1163,7 @@ static int HandleEvents( hb_handle_t * h ) if (modulus) { - job->anamorphic.modulus = modulus; + job->modulus = modulus; } if( itu_par ) @@ -1159,7 +1188,7 @@ static int HandleEvents( hb_handle_t * h ) if (modulus) { - job->anamorphic.modulus = modulus; + job->modulus = modulus; } if( itu_par ) @@ -1778,18 +1807,10 @@ static int HandleEvents( hb_handle_t * h ) force = test_sub_list(subforce, token, pos); - if ( !burn && mux == HB_MUX_MKV && - subtitle->format == PICTURESUB) + if ( !burn && subtitle->format == PICTURESUB) { sub_config.dest = PASSTHRUSUB; } - else if (!burn && mux == HB_MUX_MP4 && - subtitle->format == PICTURESUB) - { - // Skip any non-burned vobsubs when output is mp4 - fprintf( stderr, "Warning: Skipping subtitle track %d, can't pass-through VOBSUBs in an MP4 container,\nadd '--subtitle-burn %d' to the command line\n", track+1, track+1 ); - continue; - } else if ( burn && subtitle->format == PICTURESUB ) { // Only allow one subtitle to be burned into video @@ -2197,9 +2218,10 @@ static void ShowHelp() "### Source Options-----------------------------------------------------------\n\n" " -i, --input Set input device\n" - " -t, --title Select a title to encode (0 to scan only,\n" + " -t, --title Select a title to encode (0 to scan all titles only,\n" " default: 1)\n" - " -L, --longest Select the longest title\n" + " --scan Scan selected title only.\n" + " --main-feature Detect and select the main feature title.\n" " -c, --chapters Select chapters (e.g. \"1-3\" for chapters\n" " 1 to 3, or \"3\" for chapter 3 only,\n" " default: all chapters)\n" @@ -2232,7 +2254,7 @@ static void ShowHelp() " -x, --x264opts Specify advanced x264 options in the\n" " same style as mencoder:\n" " option1=value1:option2=value2\n" - " -q, --quality Set video quality (0.0..1.0)\n" + " -q, --quality Set video quality\n" " -S, --size Set target size\n" " -b, --vb Set video bitrate (default: 1000)\n" " -2, --two-pass Use two-pass mode\n" @@ -2327,8 +2349,8 @@ static void ShowHelp() " --itu-par Use wider, ITU pixel aspect values for loose and\n" " custom anamorphic, useful with underscanned sources\n" " --modulus Set the number you want the scaled pixel dimensions\n" - " to divide cleanly by, for loose and custom\n" - " anamorphic modes (default: 16)\n" + " to divide cleanly by. Does not affect strict\n" + " anamorphic mode, which is always mod 2 (default: 16)\n" " -M --color-matrix Set the color space signaled by the output\n" " <601 or 709> (Bt.601 is mostly for SD content, Bt.709 for HD,\n" " default: set by resolution)\n" @@ -2432,7 +2454,7 @@ static void ShowPresets() printf("\n + iPhone & iPod Touch: -e x264 -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R 48 -D 0.0 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0\n"); - printf("\n + AppleTV: -e x264 -q 20.0 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 -4 -X 960 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0\n"); + printf("\n + AppleTV: -e x264 -q 20.0 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 -4 -X 960 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500\n"); printf("\n>\n"); @@ -2530,6 +2552,8 @@ static int ParseOptions( int argc, char ** argv ) #define SRT_LANG 273 #define SRT_DEFAULT 274 #define ROTATE_FILTER 275 + #define SCAN_ONLY 276 + #define MAIN_FEATURE 277 for( ;; ) { @@ -2549,7 +2573,8 @@ static int ParseOptions( int argc, char ** argv ) { "ipod-atom", no_argument, NULL, 'I' }, { "title", required_argument, NULL, 't' }, - { "longest", no_argument, NULL, 'L' }, + { "scan", no_argument, NULL, SCAN_ONLY }, + { "main-feature",no_argument, NULL, MAIN_FEATURE }, { "chapters", required_argument, NULL, 'c' }, { "angle", required_argument, NULL, ANGLE }, { "markers", optional_argument, NULL, 'm' }, @@ -2616,9 +2641,12 @@ static int ParseOptions( int argc, char ** argv ) int option_index = 0; int c; + int cur_optind; - c = getopt_long( argc, argv, - "hv::uC:f:4i:Io:t:Lc:m::M:a:A:6:s:UF::N:e:E:2dD:7895gOw:l:n:b:q:S:B:r:R:x:TY:X:Z:z", + cur_optind = optind; + c = getopt_long( argc, argv, + "hv::uC:f:4i:Io:t:c:m::M:a:A:6:s:UF::N:e:E:" + "2dD:7895gOw:l:n:b:q:S:B:r:R:x:TY:X:Z:z", long_options, &option_index ); if( c < 0 ) { @@ -2696,8 +2724,11 @@ static int ParseOptions( int argc, char ** argv ) case 't': titleindex = atoi( optarg ); break; - case 'L': - longest_title = 1; + case SCAN_ONLY: + titlescan = 1; + break; + case MAIN_FEATURE: + main_feature = 1; break; case 'c': { @@ -3071,7 +3102,7 @@ static int ParseOptions( int argc, char ** argv ) color_matrix = 2; break; default: - fprintf( stderr, "unknown option (%s)\n", argv[optind] ); + fprintf( stderr, "unknown option (%s)\n", argv[cur_optind] ); return -1; } } @@ -3094,7 +3125,7 @@ static int CheckOptions( int argc, char ** argv ) } /* Parse format */ - if( titleindex > 0 ) + if( titleindex > 0 && !titlescan ) { if( output == NULL || *output == '\0' ) {