X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test%2Ftest.c;h=06aa02881b514d8b041e1d5800120a72d6c51768;hb=29f46e91b9e657b1aa5705fee8ffda9463a19544;hp=2c24d4c367386e2454d1b19604d8678dacb04e50;hpb=746a8e0074297794f4dd1eeae4d463cd939057ab;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/test/test.c b/test/test.c index 2c24d4c3..06aa0288 100644 --- a/test/test.c +++ b/test/test.c @@ -97,6 +97,9 @@ static int preview_count = 10; static int store_previews = 0; static int start_at_preview = 0; static int64_t stop_at_pts = 0; +static int stop_at_frame = 0; +static char * stop_at_string = NULL; +static char * stop_at_token = NULL; /* Exit cleanly on Ctrl-C */ static volatile int die = 0; @@ -151,6 +154,11 @@ int main( int argc, char ** argv ) return 1; } +#ifdef PTW32_STATIC_LIB + pthread_win32_process_attach_np(); + pthread_win32_thread_attach_np(); +#endif + /* Register our error handler */ hb_register_error_handler(&hb_cli_error_handler); @@ -158,8 +166,8 @@ int main( int argc, char ** argv ) h = hb_init( debug, update ); /* Show version */ - fprintf( stderr, "HandBrake %s (%d) - http://handbrake.fr/\n", - hb_get_version( h ), hb_get_build( h ) ); + fprintf( stderr, "%s - %s - %s\n", + HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); /* Check for update */ if( update ) @@ -207,7 +215,7 @@ int main( int argc, char ** argv ) /* Wait... */ while( !die ) { -#if !defined(SYS_BEOS) +#if !defined(SYS_BEOS) && !defined(__MINGW32__) fd_set fds; struct timeval tv; int ret; @@ -292,9 +300,15 @@ int main( int argc, char ** argv ) if( x264opts ) free (x264opts ); if( x264opts2 ) free (x264opts2 ); if (preset_name) free (preset_name); + if( stop_at_string ) free( stop_at_string ); fprintf( stderr, "HandBrake has exited.\n" ); +#ifdef PTW32_STATIC_LIB + pthread_win32_thread_detach_np(); + pthread_win32_process_detach_np(); +#endif + return 0; } @@ -468,7 +482,7 @@ static int HandleEvents( hb_handle_t * h ) PrintTitleInfo( title ); - if( chapter_start && chapter_end && !stop_at_pts && !start_at_preview ) + if( chapter_start && chapter_end && !stop_at_pts && !start_at_preview && !stop_at_frame ) { job->chapter_start = MAX( job->chapter_start, chapter_start ); @@ -1683,6 +1697,12 @@ static int HandleEvents( hb_handle_t * h ) subtitle_scan = 0; } + if( stop_at_frame ) + { + job->frame_to_stop = stop_at_frame; + subtitle_scan = 0; + } + if( subtitle_scan ) { char *x264opts_tmp; @@ -1868,8 +1888,9 @@ void SigHandler( int i_signal ) static void ShowHelp() { int i; + FILE* const out = stdout; - fprintf( stderr, + fprintf( out, "Syntax: HandBrakeCLI [options] -i -o \n" "\n" "### General Handbrake Options------------------------------------------------\n\n" @@ -1895,9 +1916,8 @@ static void ShowHelp() " and whether or not they're stored to disk (0 or 1).\n" " (default: 10:0)\n" " --start-at-preview <#> Start encoding at a given preview.\n" - " --stop-at-duration <#> Stop encoding after a given duration in seconds.\n" - " --stop-at-pts <#> Stop encoding at a given timestamp (90,000Hz clock).\n" - " (--stop-at-pts and --stop-at-duration are mutually exclusive options)\n" + " --stop-at Stop encoding at a given frame, duration (in seconds),\n" + " or pts (on a 90kHz clock)" "\n" "### Destination Options------------------------------------------------------\n\n" @@ -1930,11 +1950,11 @@ static void ShowHelp() " -r, --rate Set video framerate (" ); for( i = 0; i < hb_video_rates_count; i++ ) { - fprintf( stderr, hb_video_rates[i].string ); + fprintf( out, hb_video_rates[i].string ); if( i != hb_video_rates_count - 1 ) - fprintf( stderr, "/" ); + fprintf( out, "/" ); } - fprintf( stderr, ")\n" + fprintf( out, ")\n" " Be aware that not specifying a framerate lets\n" " HandBrake preserve a source's time stamps,\n" " potentially creating variable framerate video\n" @@ -1946,8 +1966,8 @@ static void ShowHelp() " input.\n" " (\"none\" for no audio, \"1,2,3\" for multiple\n" " tracks, default: first one)\n" - " -E, --aencoder Audio encoder(s) (faac/lame/vorbis/ac3) \n" - " ac3 meaning passthrough\n" + " -E, --aencoder Audio encoder(s) (faac/lame/vorbis/ac3/dts) \n" + " ac3 and dts meaning passthrough\n" " Separated by commas for more than one audio track.\n" " (default: guessed)\n" " -B, --ab Set audio bitrate(s) (default: 160)\n" @@ -1958,11 +1978,11 @@ static void ShowHelp() " -R, --arate Set audio samplerate(s) (" ); for( i = 0; i < hb_audio_rates_count; i++ ) { - fprintf( stderr, hb_audio_rates[i].string ); + fprintf( out, hb_audio_rates[i].string ); if( i != hb_audio_rates_count - 1 ) - fprintf( stderr, "/" ); + fprintf( out, "/" ); } - fprintf( stderr, " kHz)\n" + fprintf( out, " kHz)\n" " Separated by commas for more than one audio track.\n" " -D, --drc Apply extra dynamic range compression to the audio,\n" " making soft sounds louder. Range is 1.0 to 4.0\n" @@ -2101,8 +2121,7 @@ static int ParseOptions( int argc, char ** argv ) #define PREVIEWS 257 #define START_AT_PREVIEW 258 - #define STOP_AT_PTS 259 - #define STOP_AT_DURATION 260 + #define STOP_AT 259 for( ;; ) { @@ -2165,8 +2184,7 @@ static int ParseOptions( int argc, char ** argv ) { "color-matrix",required_argument, NULL, 'M' }, { "previews", required_argument, NULL, PREVIEWS }, { "start-at-preview", required_argument, NULL, START_AT_PREVIEW }, - { "stop-at-pts", required_argument, NULL, STOP_AT_PTS }, - { "stop-at-duration", required_argument, NULL, STOP_AT_DURATION }, + { "stop-at", required_argument, NULL, STOP_AT }, { 0, 0, 0, 0 } }; @@ -2217,20 +2235,19 @@ static int ParseOptions( int argc, char ** argv ) break; case 'i': input = strdup( optarg ); - #ifdef __APPLE_CC__ - char *devName = bsd_name_for_path( input ); - if( devName == NULL ) - { - break; - } - if( device_is_dvd( devName ) ) +#ifdef __APPLE_CC__ + char *devName = bsd_name_for_path( input ); // alloc + if( devName ) { - char *newInput = malloc( strlen("/dev/") + strlen( devName ) + 1); - sprintf( newInput, "/dev/%s", devName ); - free(input); - input = newInput; + if( device_is_dvd( devName )) + { + free( input ); + input = malloc( strlen( "/dev/" ) + strlen( devName ) + 1 ); + sprintf( input, "/dev/%s", devName ); + } + free( devName ); } - #endif +#endif break; case 'o': output = strdup( optarg ); @@ -2518,12 +2535,25 @@ static int ParseOptions( int argc, char ** argv ) case START_AT_PREVIEW: start_at_preview = atoi( optarg ); break; - case STOP_AT_PTS: - sscanf( optarg, "%"SCNd64, &stop_at_pts ); - break; - case STOP_AT_DURATION: - sscanf( optarg, "%"SCNd64, &stop_at_pts ); - stop_at_pts *= 90000LL; + case STOP_AT: + stop_at_string = strdup( optarg ); + stop_at_token = strtok( stop_at_string, ":"); + if( !strcmp( stop_at_token, "frame" ) ) + { + stop_at_token = strtok( NULL, ":"); + stop_at_frame = atoi(stop_at_token); + } + else if( !strcmp( stop_at_token, "pts" ) ) + { + stop_at_token = strtok( NULL, ":"); + sscanf( stop_at_token, "%"SCNd64, &stop_at_pts ); + } + else if( !strcmp( stop_at_token, "duration" ) ) + { + stop_at_token = strtok( NULL, ":"); + sscanf( stop_at_token, "%"SCNd64, &stop_at_pts ); + stop_at_pts *= 90000LL; + } break; case 'M': if( atoi( optarg ) == 601 ) @@ -2711,10 +2741,20 @@ static char* bsd_name_for_path(char *path) return NULL; } - // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the - // vMDeviceID field. It is actually a char * value. This is mentioned in the - // header CoreServices/CarbonCore/Files.h. - return volumeParms.vMDeviceID; + // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the vMDeviceID field. + // It is actually a char * value. This is mentioned in the header CoreServices/CarbonCore/Files.h. + if( volumeParms.vMVersion < 4 ) + { + return NULL; + } + + // vMDeviceID might be zero as is reported with experimental ZFS (zfs-119) support in Leopard. + if( !volumeParms.vMDeviceID ) + { + return NULL; + } + + return strdup( volumeParms.vMDeviceID ); } /****************************************************************************