OSDN Git Service

Don't try to show muxing progress since it always stays at 0 anyway.
[handbrake-jp/handbrake-jp-git.git] / test / test.c
index 7739834..940bd82 100644 (file)
@@ -66,7 +66,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: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:weightb=0";
 static int    largeFileSize = 0;
 static int    preset        = 0;
 static char * preset_name   = 0;
@@ -87,6 +87,9 @@ static int  ParseOptions( int argc, char ** argv );
 static int  CheckOptions( int argc, char ** argv );
 static int  HandleEvents( hb_handle_t * h );
 
+/* Only print the "Muxing..." message once */
+static int show_mux_warning = 1;
+
 /****************************************************************************
  * hb_error_handler
  * 
@@ -402,7 +405,7 @@ static int HandleEvents( hb_handle_t * h )
 
             if (preset)
             {
-                hb_log("+ Using preset: %s", preset_name);
+                fprintf( stderr, "+ Using preset: %s", preset_name);
                 
                 if (!strcmp(preset_name, "Animation"))
                 {
@@ -412,9 +415,9 @@ static int HandleEvents( hb_handle_t * h )
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
-                    x264opts = strdup("ref=5:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2");
+                    x264opts = strdup("ref=5:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2");
                     deinterlace = 1;
-                    deinterlace_opt = "2:-1:1";
+                    deinterlace_opt = "0";
                     job->chapter_markers = 1;
                     pixelratio = 1;
                     twoPass = 1;
@@ -424,11 +427,14 @@ static int HandleEvents( hb_handle_t * h )
                 if (!strcmp(preset_name, "AppleTV"))
                 {
                     mux = HB_MUX_MP4;
+                    job->largeFileSize = 1;
                     vcodec = HB_VCODEC_X264;
                     job->vbitrate = 2500;
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
+                    audio_mixdown = HB_AMIXDOWN_DOLBYPLII_AC3;
+                    arate = 48000;
                     x264opts = strdup("bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0");
                     job->chapter_markers = 1;
                     pixelratio = 1;
@@ -440,7 +446,7 @@ static int HandleEvents( hb_handle_t * h )
                     vcodec = HB_VCODEC_X264;
                     job->vbitrate = 1800;
                     acodec = HB_ACODEC_AC3;
-                    x264opts = strdup("ref=16:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:me-range=64:analyse=all:8x8dct:trellis=2:no-fast-pskip:no-dct-decimate:filter=-2,-1");
+                    x264opts = strdup("ref=16:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=esa:subme=7:me-range=64:analyse=all:8x8dct:trellis=1:no-fast-pskip:no-dct-decimate:filter=-2,-1");
                     job->chapter_markers = 1;
                     pixelratio = 1;
                     twoPass = 1;
@@ -513,7 +519,7 @@ static int HandleEvents( hb_handle_t * h )
                     vcodec = HB_VCODEC_X264;
                     job->vbitrate = 1800;
                     acodec = HB_ACODEC_AC3;
-                    x264opts = strdup("ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip");
+                    x264opts = strdup("ref=3:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip");
                     job->chapter_markers = 1;
                     pixelratio = 1;
                     twoPass = 1;
@@ -523,42 +529,42 @@ static int HandleEvents( hb_handle_t * h )
                 if (!strcmp(preset_name, "iPhone / iPod Touch"))
                 {
                     mux = HB_MUX_MP4;
+                    job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->h264_level = 30;
                     job->vbitrate = 960;
                     job->abitrate = 128;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
                     job->width = 480;
-                    x264opts = strdup("cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1");
+                    x264opts = strdup("level=30:cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1");
                     job->chapter_markers = 1;
                 }
 
                 if (!strcmp(preset_name, "iPod High-Rez"))
                 {
                     mux = HB_MUX_MP4;
+                    job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->h264_level = 30;
                     job->vbitrate = 1500;
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
                     job->width = 640;
-                    x264opts = strdup("bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1");
+                    x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1");
                     job->chapter_markers = 1;
                 }
 
                 if (!strcmp(preset_name, "iPod Low-Rez"))
                 {
                     mux = HB_MUX_MP4;
+                    job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->h264_level = 30;
                     job->vbitrate = 700;
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
                     job->width = 320;
-                    x264opts = strdup("bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1");
+                    x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1");
                     job->chapter_markers = 1;
                 }
 
@@ -624,9 +630,9 @@ static int HandleEvents( hb_handle_t * h )
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
-                    x264opts = strdup("ref=3:mixed-refs:bframes=16:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip");
+                    x264opts = strdup("ref=3:mixed-refs:bframes=6:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip");
                     deinterlace = 1;
-                    deinterlace_opt = "2:-1:1";
+                    deinterlace_opt = "0";
                     denoise = 1;
                     denoise_opt = "2:1:2:3";
                     job->chapter_markers = 1;
@@ -642,7 +648,7 @@ static int HandleEvents( hb_handle_t * h )
                     job->abitrate = 160;
                     job->arate = 48000;
                     acodec = HB_ACODEC_FAAC;
-                    x264opts = strdup("level=40:ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip:filter=-2,-1");
+                    x264opts = strdup("level=40:ref=2:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:no-fast-pskip:filter=-2,-1");
                     pixelratio = 1;
                 }
             }
@@ -832,6 +838,26 @@ static int HandleEvents( hb_handle_t * h )
                            job->audios[0] = 0;
                            job->audio_mixdowns[0] = audio_mixdown;
                        }
+                       
+                       if( audio_mixdown == HB_AMIXDOWN_DOLBYPLII_AC3)
+                       {
+               int i;
+               for( i = 3 ; i > 0; i--)
+               {                   
+                   job->audios[i*2+1] = job->audios[i];
+                   job->audios[i*2] = job->audios[i];
+                   if(job->audios[i] != -1  )
+                   {
+                       job->audio_mixdowns[i*2+1] = HB_AMIXDOWN_AC3;
+                       job->audio_mixdowns[i*2] = HB_AMIXDOWN_DOLBYPLII;
+                   }
+               }
+               
+               job->audios[1] = job->audios[0];
+               job->audio_mixdowns[1] = HB_AMIXDOWN_AC3;
+               job->audio_mixdowns[0] = HB_AMIXDOWN_DOLBYPLII;
+            }
+                       
             if( abitrate )
             {
                 job->abitrate = abitrate;
@@ -1035,8 +1061,12 @@ static int HandleEvents( hb_handle_t * h )
 #define p s.param.muxing
         case HB_STATE_MUXING:
         {
-            fprintf( stdout, "\rMuxing: %.2f %%", 100.0 * p.progress );
-            fflush(stdout);
+            if (show_mux_warning)
+            {
+                fprintf( stdout, "\rMuxing: this may take awhile..." );
+                fflush(stdout);
+                show_mux_warning = 0;
+            }
             break;
         }
 #undef p
@@ -1166,7 +1196,7 @@ static void ShowHelp()
      "    -d, --deinterlace       Deinterlace video with yadif/mcdeint filter\n"
      "          <YM:FD:MM:QP>     (default 0:-1:-1:1)\n"
      "           or\n"
-     "          <fast/slow/slower/slowest>\n"            
+     "          <fast/slow/slower>\n"            
      "    -7, --deblock           Deblock video with pp7 filter\n"
      "          <QP:M>            (default 0:2)\n"
      "    -8, --denoise           Denoise video with hqdn3d filter\n"
@@ -1186,12 +1216,15 @@ static void ShowHelp()
        
        
        "### Audio Options-----------------------------------------------------------\n\n"
-       "    -E, --aencoder <string> Set audio encoder (faac/lame/vorbis/ac3, ac3\n"
-    "                            meaning passthrough, default: guessed)\n"
+       "    -E, --aencoder <string> Audio encoder (faac/lame/vorbis/ac3/aac+ac3) \n"
+       "                            ac3 meaning passthrough, aac+ac3 meaning an\n"
+       "                            aac dpl2 mixdown paired with ac3 pass-thru\n"
+       "                            (default: guessed)\n"
        "    -B, --ab <kb/s>         Set audio bitrate (default: 128)\n"
        "    -a, --audio <string>    Select audio channel(s), separated by commas\n"
        "                            (\"none\" for no audio, \"1,2,3\" for multiple\n"
-       "                             tracks, default: first one, max: eight)\n"
+       "                             tracks, default: first one,\n"
+       "                             max 8 normally, max 4 with aac+ac3)\n"
     "    -6, --mixdown <string>  Format for surround sound downmixing\n"
     "                            (mono/stereo/dpl1/dpl2/6ch, default: dpl2)\n"
     "    -R, --arate             Set audio samplerate (" );
@@ -1227,11 +1260,11 @@ static void ShowHelp()
  ****************************************************************************/
 static void ShowPresets()
 {
-    printf("\n+ Animation:  -e x264 -b 1000 -B 160 -R 48 -E faac -f mkv --deinterlace=\"slower\" -m -p -2 -T -x ref=5:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2\n");
+    printf("\n+ Animation:  -e x264 -b 1000 -B 160 -R 48 -E faac -f mkv --deinterlace=\"slower\" -m -p -2 -T -x ref=5:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2\n");
 
-    printf("\n+ AppleTV:  -e x264 -b 2500 -B 160 -R 48 -E faac -f mp4 -m -p -x bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0\n");
+    printf("\n+ AppleTV:  -e x264 -b 2500 -B 160 -R 48 -E aac+ac3 -f mp4 -4 -m -p -x bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0\n");
 
-    printf("\n+ Bedlam:  -e x264 -b 1800 -E ac3 -f mkv -m -p -2 -T -x ref=16:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:me-range=64:analyse=all:8x8dct:trellis=2:no-fast-pskip:no-dct-decimate:filter=-2,-1\n");
+    printf("\n+ Bedlam:  -e x264 -b 1800 -E ac3 -f mkv -m -p -2 -T -x ref=16:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=esa:subme=7:me-range=64:analyse=all:8x8dct:trellis=1:no-fast-pskip:no-dct-decimate:filter=-2,-1\n");
 
     printf("\n+ Blind:  -b 512 -B 128 -R 48 -E faac -f mp4 -w 512 -m\n");
 
@@ -1239,17 +1272,17 @@ static void ShowPresets()
 
     printf("\n+ Classic:  -b 1000 -B 160 -R 48 -E faac -f mp4\n");
 
-    printf("\n+ Constant Quality Rate:  -e x264 -q 0.64709997177124023 -Q  -E ac3 -f mkv -m -p -x ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh\n");
+    printf("\n+ Constant Quality Rate:  -e x264 -q 0.64709997177124023 -E ac3 -f mkv -m -p -x ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh\n");
 
     printf("\n+ Deux Six Quatre:  -e x264 -b 1600 -E ac3 -f mkv -m -p -2 -T -x ref=5:mixed-refs:bframes=3:bime:weightb:b-rdo:b-pyramid:me=umh:subme=7:trellis=1:analyse=all:8x8dct:no-fast-pskip\n");
 
-    printf("\n+ Film:  -e x264 -b 1800 -E ac3 -f mkv -m -p -2 -T -x ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip\n");
+    printf("\n+ Film:  -e x264 -b 1800 -E ac3 -f mkv -m -p -2 -T -x ref=3:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip\n");
 
-    printf("\n+ iPhone / iPod Touch:  -e x264b30 -b 960 -B 128 -R 48 -E faac -f mp4 -w 480 -m -x cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1\n");
+    printf("\n+ iPhone / iPod Touch:  -e x264 -b 960 -B 128 -R 48 -E faac -f mp4 -I -w 480 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1\n");
 
-    printf("\n+ iPod High-Rez:  -e x264b30 -b 1500 -B 160 -R 48 -E faac -f mp4 -w 640 -m -x bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1\n");
+    printf("\n+ iPod High-Rez:  -e x264 -b 1500 -B 160 -R 48 -E faac -f mp4 -I -w 640 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1\n");
 
-    printf("\n+ iPod Low-Rez:  -e x264b30 -b 700 -B 160 -R 48 -E faac -f mp4 -w 320 -m -x bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1\n");
+    printf("\n+ iPod Low-Rez:  -e x264 -b 700 -B 160 -R 48 -E faac -f mp4 -I -w 320 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1\n");
 
     printf("\n+ Normal:  -e x264 -b 1500 -B 160 -R 48 -E faac -f mp4 -m -p -2 -T -x ref=2:bframes=2:subme=5:me=umh\n");
 
@@ -1259,9 +1292,9 @@ static void ShowPresets()
 
     printf("\n+ QuickTime:  -e x264 -b 2000 -B 160 -R 48 -E faac -f mp4 -m -p -2 -T -x ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:me=umh:subme=5:analyse=all:trellis=1:no-fast-pskip\n");
 
-    printf("\n+ Television:  -e x264 -b 1300 -B 160 -R 48 -E faac -f mkv --deinterlace=\"slower\" --denoise=\"weak\" -m -2 -T -x ref=3:mixed-refs:bframes=16:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip\n");
+    printf("\n+ Television:  -e x264 -b 1300 -B 160 -R 48 -E faac -f mkv --deinterlace=\"slower\" --denoise=\"weak\" -m -2 -T -x ref=3:mixed-refs:bframes=6:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip\n");
 
-    printf("\n+ Xbox 360:  -e x264 -b 2000 -B 160 -R 48 -E faac -f mp4 -p -x level=40:ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip:filter=-2,-1\n");
+    printf("\n+ Xbox 360:  -e x264 -b 2000 -B 160 -R 48 -E faac -f mp4 -p -x level=40:ref=2:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:no-fast-pskip:filter=-2,-1\n");
 }
 
 /****************************************************************************
@@ -1468,15 +1501,11 @@ static int ParseOptions( int argc, char ** argv )
                     }
                     else if (!( strcmp( optarg, "slow" ) ))
                     {
-                        deinterlace_opt = "0";
+                        deinterlace_opt = "2";
                     }
                     else if (!( strcmp( optarg, "slower" ) ))
                     {
-                        deinterlace_opt = "2:-1:1";
-                    }
-                    else if (!( strcmp( optarg, "slowest" ) ))
-                    {
-                        deinterlace_opt = "1:-1:1";
+                        deinterlace_opt = "0";
                     }
                     else
                     {
@@ -1580,6 +1609,12 @@ static int ParseOptions( int argc, char ** argv )
                 {
                     acodec = HB_ACODEC_VORBIS;
                 }
+                else if( !strcasecmp( optarg, "aac+ac3") )
+                {
+                    acodec = HB_ACODEC_FAAC;
+                    audio_mixdown = HB_AMIXDOWN_DOLBYPLII_AC3;
+                    arate = 48000;
+                }
                 break;
             case 'w':
                 width = atoi( optarg );