]> granicus.if.org Git - handbrake/commitdiff
Adds presets for iPod/H.264 and iPod/MPEG-4 + small UI fixes
authortiter <eric@lapsus.org>
Tue, 21 Mar 2006 17:15:21 +0000 (17:15 +0000)
committertiter <eric@lapsus.org>
Tue, 21 Mar 2006 17:15:21 +0000 (17:15 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@47 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb.c
libhb/hb.h
macosx/English.lproj/Express.nib/classes.nib
macosx/English.lproj/Express.nib/info.nib
macosx/English.lproj/Express.nib/keyedobjects.nib
macosx/ExpressController.h
macosx/ExpressController.m

index 0e78b1e2c38a2b58587f580ca81691fff46eb49c..7bc41be8e00fc540857d225e4a9110a553f158f8 100644 (file)
@@ -251,6 +251,70 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
     free( buf4 );
 }
 
+void hb_set_size( hb_job_t * job, int aspect, int pixels )
+{
+    hb_title_t * title = job->title;
+
+    int croppedWidth  = title->width - title->crop[2] - title->crop[3];
+    int croppedHeight = title->height - title->crop[0] - title->crop[1];
+    int croppedAspect = title->aspect * title->height * croppedWidth /
+                            croppedHeight / title->width;
+    int addCrop;
+
+    if( aspect <= 0 )
+    {
+        /* Keep the best possible aspect ratio */
+        aspect = croppedAspect;
+    }
+
+    /* Crop if necessary to obtain the desired ratio */
+    memcpy( job->crop, title->crop, 4 * sizeof( int ) );
+    if( aspect < croppedAspect )
+    {
+        /* Need to crop on the left and right */
+        addCrop = croppedWidth - aspect * croppedHeight * title->width /
+                    title->aspect / title->height;
+        if( addCrop & 3 )
+        {
+            addCrop = ( addCrop + 1 ) / 2;
+            job->crop[2] += addCrop;
+            job->crop[3] += addCrop;
+        }
+        else if( addCrop & 2 )
+        {
+            addCrop /= 2;
+            job->crop[2] += addCrop - 1;
+            job->crop[3] += addCrop + 1;
+        }
+        else
+        {
+            addCrop /= 2;
+            job->crop[2] += addCrop;
+            job->crop[3] += addCrop;
+        }
+    }
+    else if( aspect > croppedAspect )
+    {
+        /* Need to crop on the top and bottom */
+        /* TODO */
+    }
+
+    /* Compute a resolution from the number of pixels and aspect */
+    int i, w, h;
+    for( i = 0;; i++ )
+    {
+        w = 16 * i;
+        h = MULTIPLE_16( w * HB_ASPECT_BASE / aspect );
+        if( w * h > pixels )
+        {
+            break;
+        }
+    }
+    i--;
+    job->width  = 16 * i;
+    job->height = MULTIPLE_16( 16 * i * HB_ASPECT_BASE / aspect );
+}
+
 int hb_count( hb_handle_t * h )
 {
     return hb_list_count( h->jobs );
index 7a1ab7ea8990f93cf12ffea88c1655e64a316545..5feef6c94f7de7fd1b975f3bd1134074a4ab7c9f 100644 (file)
@@ -78,6 +78,7 @@ hb_list_t   * hb_get_titles( hb_handle_t * );
 
 void          hb_get_preview( hb_handle_t *, hb_title_t *, int,
                               uint8_t * );
+void          hb_set_size( hb_job_t *, int ratio, int pixels );
 
 /* Handling jobs */
 int           hb_count( hb_handle_t * );
index 28084023ad2f5393b42b5ac7dcf9a4a80cc1056b..5498cdf8c979bedf2e2764a0944e07d2498218e3 100644 (file)
             CLASS = ExpressController; 
             LANGUAGE = ObjC; 
             OUTLETS = {
+                fConvertAspectPopUp = NSPopUpButton; 
                 fConvertFolderPopUp = NSPopUpButton; 
+                fConvertFormatPopUp = NSPopUpButton; 
                 fConvertIndicator = NSProgressIndicator; 
+                fConvertInfoString = NSTextField; 
                 fConvertTableView = NSTableView; 
                 fConvertView = NSView; 
                 fEmptyView = NSView; 
index ae8fc644ed673d6b975d1755e76a96dd6b3276b8..b7418f0ef8575151a30b8338c5f9b173a1d418cc 100644 (file)
@@ -9,7 +9,7 @@
                <key>248</key>
                <string>487 424 408 321 0 0 1440 878 </string>
                <key>259</key>
-               <string>487 331 408 508 0 0 1440 878 </string>
+               <string>417 300 408 508 0 0 1280 832 </string>
                <key>29</key>
                <string>33 298 338 44 0 0 1280 832 </string>
                <key>303</key>
@@ -18,6 +18,6 @@
        <key>IBFramework Version</key>
        <string>443.0</string>
        <key>IBSystem Version</key>
-       <string>8G1454</string>
+       <string>8H14</string>
 </dict>
 </plist>
index c53053a44345b9dc132b583955beba821c39b915..34bee0b64af5a43f248e3616be36db90eeb1b5cf 100644 (file)
Binary files a/macosx/English.lproj/Express.nib/keyedobjects.nib and b/macosx/English.lproj/Express.nib/keyedobjects.nib differ
index f4ef02130b3cb2f018e0acd0a2c785c0c815fcb0..303651b5ce4521a19cf165fb288f3c0a4860debe 100644 (file)
@@ -27,6 +27,9 @@
     IBOutlet NSView              * fConvertView;
     IBOutlet NSTableView         * fConvertTableView;
     IBOutlet NSPopUpButton       * fConvertFolderPopUp;
+    IBOutlet NSPopUpButton       * fConvertFormatPopUp;
+    IBOutlet NSPopUpButton       * fConvertAspectPopUp;
+    IBOutlet NSTextField         * fConvertInfoString;
     IBOutlet NSProgressIndicator * fConvertIndicator;
     NSMutableArray               * fConvertCheckArray;
     NSString                     * fConvertFolderString;
index d32ad3242a3bcd4e45808047161e3261a1b44565..0336cd8099b957cbb8c3500f82f1c0f01bdb8a05 100644 (file)
@@ -23,6 +23,8 @@
  **********************************************************************/
 - (void) awakeFromNib
 {
+    NSEnumerator * enumerator;
+
     /* Show the "Open DVD" interface */
     fDriveDetector = [[DriveDetector alloc] initWithCallback: self
         selector: @selector( openUpdateDrives: )];
     [fWindow makeKeyAndOrderFront: nil];
 
     /* NSTableView initializations */
-    NSTableColumn * tableColumn = [fConvertTableView
-        tableColumnWithIdentifier: @"Check"];
-    NSButtonCell * buttonCell = [[[NSButtonCell alloc]
-        initTextCell: @""] autorelease];
+     NSButtonCell * buttonCell;
+     NSTableColumn * tableColumn;
+     enumerator = [[fConvertTableView tableColumns] objectEnumerator];
+     while( ( tableColumn = [enumerator nextObject] ) )
+     {
+         [tableColumn setEditable: NO];
+     }
+     tableColumn = [fConvertTableView tableColumnWithIdentifier: @"Check"];
+     buttonCell = [[[NSButtonCell alloc] initTextCell: @""] autorelease];
     [buttonCell setEditable: YES];
     [buttonCell setButtonType: NSSwitchButton];
     [tableColumn setDataCell: buttonCell];
         hb_title_t * title = hb_list_item( fList, i );
         hb_job_t   * job   = title->job;
 
-        job->width = 320;
-        for( ;; )
+        int pixels, aspect;
+        if( [fConvertFormatPopUp indexOfSelectedItem] )
         {
-            /* XXX */
-            hb_fix_aspect( job, HB_KEEP_WIDTH );
-            if( job->height == 240 )
-            {
-                break;
-            }
-            else if( job->height < 240 )
-            {
-                job->crop[2] += 2;
-                job->crop[3] += 2;
-            }
-            else
-            {
-                job->crop[0] += 2;
-                job->crop[1] += 2;
-            }
+            job->vcodec   = HB_VCODEC_FFMPEG;
+            job->vbitrate = 1200;
+            pixels        = 230400;
+        }
+        else
+        {
+            job->vcodec   = HB_VCODEC_X264;
+            job->h264_13  = 1;
+            job->vbitrate = 600;
+            pixels        = 76800;
+        }
+        if( [fConvertAspectPopUp indexOfSelectedItem] )
+        {
+            aspect = -1;
         }
+        else
+        {
+            aspect = 4 * HB_ASPECT_BASE / 3;
+        }
+
+        hb_set_size( job, aspect, pixels );
+
         job->vquality = -1.0;
-        job->vbitrate = 600;
-        job->vcodec   = HB_VCODEC_X264;
-        job->h264_13  = 1;
         job->file     = strdup( [[NSString stringWithFormat:
             @"%@/%p - Title %d.mp4", fConvertFolderString, self,
             title->index] UTF8String] );
         [fOpenFolderString release];
     fOpenFolderString = [[[sheet filenames] objectAtIndex: 0] retain];
     [fOpenFolderField setStringValue: [fOpenFolderString lastPathComponent]];
+    [self openGo: self];
 }
 
 - (void) openEnable: (BOOL) b
     {
 #define p s.param.working
         case HB_STATE_WORKING:
+        {
+            NSMutableString * string = [NSMutableString
+                stringWithFormat: @"Converting: %.1f %%, %.1f fps",
+                100.0 * p.progress, p.rate_avg];
+            if( p.hours > 0 )
+            {
+                [string appendFormat: @" (%d hours %d mins left)",
+                    p.hours, p.minutes];
+            }
+            else if( p.minutes > 0 )
+            {
+                [string appendFormat: @" (%d mins %d secs left)",
+                    p.minutes, p.seconds];
+            }
+            else if( p.seconds > -1 )
+            {
+                [string appendFormat: @" (%d seconds left)",
+                    p.seconds];
+            }
+            [fConvertInfoString setStringValue: string];
             [fConvertIndicator setIndeterminate: NO];
             [fConvertIndicator setDoubleValue: 100.0 * p.progress];
             break;
+        }
 #undef p
 
         case HB_STATE_WORKDONE:
             [timer invalidate];
+            [fConvertInfoString setStringValue: @"Done."];
             [fConvertIndicator setIndeterminate: NO];
             [fConvertIndicator setDoubleValue: 0.0];
             break;