OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / test / test.c
index 9c85e31..85d506f 100644 (file)
@@ -22,9 +22,17 @@ static char * format      = NULL;
 static int    titleindex  = 1;
 static int    longest_title = 0;
 static int    subtitle_scan = 0;
+static int    subtitle_force = 0;
 static char * native_language = NULL;
 static int    twoPass     = 0;
-static int    deinterlace = 0;
+static int    deinterlace           = 0;
+static char * deinterlace_opt       = 0;
+static int    deblock               = 0;
+static char * deblock_opt           = 0;
+static int    denoise               = 0;
+static char * denoise_opt           = 0;
+static int    detelecine            = 0;
+static char * detelecine_opt        = 0;
 static int    grayscale   = 0;
 static int    vcodec      = HB_VCODEC_FFMPEG;
 static int    h264_13     = 0;
@@ -55,7 +63,7 @@ static char     *x264opts2    = NULL;
 static int       maxHeight             = 0;
 static int       maxWidth              = 0;
 static int    turbo_opts_enabled = 0;
-static char * turbo_opts = "ref=1:subme=1:me=dia:analyse=none:weightb=0:trellis=0:no-fast-pskip=0:8x8dct=0";
+static char * turbo_opts = "ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0";
 static int    largeFileSize = 0;
 
 /* Exit cleanly on Ctrl-C */
@@ -427,6 +435,29 @@ static int HandleEvents( hb_handle_t * h )
             job->grayscale   = grayscale;
             job->pixel_ratio = pixelratio;
 
+            /* Add selected filters */
+            job->filters = hb_list_init();
+            if( detelecine )
+            {
+                hb_filter_detelecine.settings = detelecine_opt;
+                hb_list_add( job->filters, &hb_filter_detelecine );
+            }
+            if( deinterlace )
+            {
+                hb_filter_deinterlace.settings = deinterlace_opt;
+                hb_list_add( job->filters, &hb_filter_deinterlace );
+            }
+            if( deblock )
+            {
+                hb_filter_deblock.settings = deblock_opt;
+                hb_list_add( job->filters, &hb_filter_deblock );
+            }
+            if( denoise )
+            {
+                hb_filter_denoise.settings = denoise_opt;
+                hb_list_add( job->filters, &hb_filter_denoise );
+            }
+            
             if( width && height )
             {
                 job->width  = width;
@@ -567,7 +598,40 @@ static int HandleEvents( hb_handle_t * h )
                 job->maxWidth = maxWidth;
             if (maxHeight)
                 job->maxHeight = maxHeight;
-                               
+       
+            if( subtitle_force )
+            {
+                job->subtitle_force = subtitle_force;
+            }
+
+            if( subtitle_scan )
+            {
+                char *x264opts_tmp;
+
+                /*
+                 * When subtitle scan is enabled do a fast pre-scan job
+                 * which will determine which subtitles to enable, if any.
+                 */
+                job->pass = -1;
+                
+                x264opts_tmp = job->x264opts;
+
+                job->x264opts = NULL;
+
+                job->subtitle_scan = subtitle_scan;  
+                fprintf( stderr, "Subtitle Scan Enabled - enabling "
+                         "subtitles if found for foreign language segments\n");
+                job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+                *(job->select_subtitle) = NULL;
+                
+                /*
+                 * Add the pre-scan job
+                 */
+                hb_add( h, job );
+
+                job->x264opts = x264opts_tmp;
+            }
+
             if( twoPass )
             {
                 /*
@@ -575,15 +639,13 @@ static int HandleEvents( hb_handle_t * h )
                  * for the first pass and then off again for the
                  * second. 
                  */
+                hb_subtitle_t **subtitle_tmp = job->select_subtitle;
+
+                job->select_subtitle = NULL;
+
                 job->pass = 1;
-                job->subtitle_scan = subtitle_scan;
-                if( subtitle_scan ) 
-                {
-                    fprintf( stderr, "Subtitle Scan Enabled - enabling "
-                             "subtitles if found for foreign language segments\n");
-                    job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
-                    *(job->select_subtitle) = NULL;
-                } 
+
+                job->subtitle_scan = 0;
 
                 /*
                  * If turbo options have been selected then append them
@@ -616,6 +678,9 @@ static int HandleEvents( hb_handle_t * h )
                     job->x264opts = x264opts;
                 }     
                 hb_add( h, job );
+
+                job->select_subtitle = subtitle_tmp;
+
                 job->pass = 2;
                 /*
                  * On the second pass we turn off subtitle scan so that we
@@ -634,14 +699,9 @@ static int HandleEvents( hb_handle_t * h )
                 /*
                  * Turn on subtitle scan if requested, note that this option
                  * precludes encoding of any actual subtitles.
-                 */
-                job->subtitle_scan = subtitle_scan;
-                if ( subtitle_scan ) 
-                {
-                    fprintf( stderr, "Subtitle Scan Enabled, will scan all "
-                             "subtitles matching the audio language for any\n"
-                             "that meet our auto-selection criteria.\n");
-                }
+                 */ 
+
+                job->subtitle_scan = 0;
                 job->pass = 0;
                 hb_add( h, job );
             }
@@ -755,9 +815,13 @@ static void ShowHelp()
        "    -X, --maxWidth <#>      Set maximum width\n"
        "    -s, --subtitle <number> Select subtitle (default: none)\n"
     "    -U, --subtitle-scan     Scan for subtitles on the first pass, and choose\n"
-    "                            the one that's only used 20 percent of the time\n"
+    "                            the one that's only used 10 percent of the time\n"
     "                            or less. This should locate subtitles for short\n"
     "                            foreign language segments. Only works with 2-pass.\n"
+    "    -F, --subtitle-forced   Only display subtitles from the selected stream if\n"
+    "                            the subtitle has the forced flag set. May be used in\n"
+    "                            conjunction with --subtitle-scan to auto-select\n"
+    "                            a stream if it contains forced subtitles.\n"
     "    -N, --native-language   Select subtitles with this language if it does not\n"
     "          <string>          match the Audio language. Provide the language's\n"
     "                            iso639-2 code (fre, eng, spa, dut, et cetera)\n"
@@ -781,7 +845,14 @@ static void ShowHelp()
     fprintf( stderr, ")\n"
        "\n"
        "    -2, --two-pass          Use two-pass mode\n"
-    "    -d, --deinterlace       Deinterlace video\n"
+     "    -d, --deinterlace       Deinterlace video with yadif/mcdeint filter\n"
+     "          <YM:FD:MM:QP>     (default 0:-1:-1:1)\n"            
+     "    -7, --deblock           Deblock video with pp7 filter\n"
+     "          <QP:M>            (default 0:2)\n"
+     "    -8, --denoise           Denoise video with hqdn3d filter\n"
+     "          <SL:SC:TL:TC>     (default 4:3:6:4.5)\n"
+     "    -9, --detelecine        Detelecine video with pullup filter\n"
+     "          <L:R:T:B:SB:MP>   (default 1:1:4:4:0:0)\n"
     "    -g, --grayscale         Grayscale encoding\n"
     "    -p, --pixelratio        Store pixel aspect ratio in video stream\n"
        
@@ -847,12 +918,16 @@ static int ParseOptions( int argc, char ** argv )
             { "mixdown",     required_argument, NULL,    '6' },
             { "subtitle",    required_argument, NULL,    's' },
             { "subtitle-scan", no_argument,     NULL,    'U' },
+            { "subtitle-forced", no_argument,   NULL,    'F' },
             { "native-language", required_argument, NULL,'N' },
 
             { "encoder",     required_argument, NULL,    'e' },
             { "aencoder",    required_argument, NULL,    'E' },
             { "two-pass",    no_argument,       NULL,    '2' },
-            { "deinterlace", no_argument,       NULL,    'd' },
+            { "deinterlace", optional_argument, NULL,    'd' },
+            { "deblock",     optional_argument, NULL,    '7' },
+            { "denoise",     optional_argument, NULL,    '8' },
+            { "detelecine",  optional_argument, NULL,    '9' },
             { "grayscale",   no_argument,       NULL,    'g' },
             { "pixelratio",  no_argument,       NULL,    'p' },
             { "width",       required_argument, NULL,    'w' },
@@ -879,7 +954,7 @@ static int ParseOptions( int argc, char ** argv )
         int c;
 
         c = getopt_long( argc, argv,
-                         "hvuC:f:4i:o:t:Lc:ma:6:s:UN:e:E:2dgpw:l:n:b:q:S:B:r:R:Qx:TY:X:",
+                         "hvuC:f:4i:o:t:Lc:ma:6:s:UFN:e:E:2d789gpw:l:n:b:q:S:B:r:R:Qx:TY:X:",
                          long_options, &option_index );
         if( c < 0 )
         {
@@ -978,6 +1053,9 @@ static int ParseOptions( int argc, char ** argv )
             case 'U':
                 subtitle_scan = 1;
                 break;
+            case 'F':
+                subtitle_force = 1;
+                break;
             case 'N':
                 native_language = strdup( optarg );
                 break;
@@ -985,8 +1063,33 @@ static int ParseOptions( int argc, char ** argv )
                 twoPass = 1;
                 break;
             case 'd':
+                if( optarg != NULL )
+                {
+                    deinterlace_opt = strdup( optarg );
+                }
                 deinterlace = 1;
                 break;
+            case '7':
+                if( optarg != NULL )
+                {
+                    deblock_opt = strdup( optarg );
+                }
+                deblock = 1;
+                break;
+            case '8':
+                if( optarg != NULL )
+                {
+                    denoise_opt = strdup( optarg );
+                }
+                denoise = 1;
+                break;                
+            case '9':
+                if( optarg != NULL )
+                {
+                    detelecine_opt = strdup( optarg );
+                }
+                detelecine = 1;
+                break;                
             case 'g':
                 grayscale = 1;
                 break;