summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/hb.c64
-rw-r--r--libhb/hb.h1
-rw-r--r--macosx/English.lproj/Express.nib/classes.nib3
-rw-r--r--macosx/English.lproj/Express.nib/info.nib4
-rw-r--r--macosx/English.lproj/Express.nib/keyedobjects.nibbin34369 -> 34653 bytes
-rw-r--r--macosx/ExpressController.h3
-rw-r--r--macosx/ExpressController.m82
7 files changed, 130 insertions, 27 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 0e78b1e2c..7bc41be8e 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -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 );
diff --git a/libhb/hb.h b/libhb/hb.h
index 7a1ab7ea8..5feef6c94 100644
--- a/libhb/hb.h
+++ b/libhb/hb.h
@@ -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 * );
diff --git a/macosx/English.lproj/Express.nib/classes.nib b/macosx/English.lproj/Express.nib/classes.nib
index 28084023a..5498cdf8c 100644
--- a/macosx/English.lproj/Express.nib/classes.nib
+++ b/macosx/English.lproj/Express.nib/classes.nib
@@ -38,8 +38,11 @@
CLASS = ExpressController;
LANGUAGE = ObjC;
OUTLETS = {
+ fConvertAspectPopUp = NSPopUpButton;
fConvertFolderPopUp = NSPopUpButton;
+ fConvertFormatPopUp = NSPopUpButton;
fConvertIndicator = NSProgressIndicator;
+ fConvertInfoString = NSTextField;
fConvertTableView = NSTableView;
fConvertView = NSView;
fEmptyView = NSView;
diff --git a/macosx/English.lproj/Express.nib/info.nib b/macosx/English.lproj/Express.nib/info.nib
index ae8fc644e..b7418f0ef 100644
--- a/macosx/English.lproj/Express.nib/info.nib
+++ b/macosx/English.lproj/Express.nib/info.nib
@@ -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>
diff --git a/macosx/English.lproj/Express.nib/keyedobjects.nib b/macosx/English.lproj/Express.nib/keyedobjects.nib
index c53053a44..34bee0b64 100644
--- a/macosx/English.lproj/Express.nib/keyedobjects.nib
+++ b/macosx/English.lproj/Express.nib/keyedobjects.nib
Binary files differ
diff --git a/macosx/ExpressController.h b/macosx/ExpressController.h
index f4ef02130..303651b5c 100644
--- a/macosx/ExpressController.h
+++ b/macosx/ExpressController.h
@@ -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;
diff --git a/macosx/ExpressController.m b/macosx/ExpressController.m
index d32ad3242..0336cd809 100644
--- a/macosx/ExpressController.m
+++ b/macosx/ExpressController.m
@@ -23,6 +23,8 @@
**********************************************************************/
- (void) awakeFromNib
{
+ NSEnumerator * enumerator;
+
/* Show the "Open DVD" interface */
fDriveDetector = [[DriveDetector alloc] initWithCallback: self
selector: @selector( openUpdateDrives: )];
@@ -33,10 +35,15 @@
[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];
@@ -188,30 +195,32 @@
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] );
@@ -258,6 +267,7 @@
[fOpenFolderString release];
fOpenFolderString = [[[sheet filenames] objectAtIndex: 0] retain];
[fOpenFolderField setStringValue: [fOpenFolderString lastPathComponent]];
+ [self openGo: self];
}
- (void) openEnable: (BOOL) b
@@ -373,13 +383,35 @@
{
#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;