diff options
author | handbrake <[email protected]> | 2006-01-14 13:05:49 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2006-01-14 13:05:49 +0000 |
commit | 5824c4979fbc54ae3d3015c07cbf6fa4aea7516d (patch) | |
tree | 49ba3bbe1f8d8166fa4f7f964055d4011d2deca0 /macosx | |
parent | f013e3544c0bdf17348d617a467af0e4fde0f545 (diff) |
HandBrake 0.5
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.h | 17 | ||||
-rw-r--r-- | macosx/Controller.mm | 657 | ||||
-rw-r--r-- | macosx/English.lproj/InfoPlist.strings | bin | 496 -> 488 bytes | |||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 4 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/info.nib | 20 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/objects.nib | bin | 17820 -> 18217 bytes | |||
-rw-r--r-- | macosx/HandBrake.pbproj/project.pbxproj | 146 | ||||
-rw-r--r-- | macosx/PictureGLView.h | 24 | ||||
-rw-r--r-- | macosx/PictureGLView.mm | 258 | ||||
-rw-r--r-- | macosx/TargetSizeField.h | 6 | ||||
-rw-r--r-- | macosx/TargetSizeField.mm | 12 | ||||
-rw-r--r-- | macosx/main.mm | 4 |
12 files changed, 725 insertions, 423 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 4759a1d5b..469994c68 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -1,12 +1,12 @@ -/* $Id: Controller.h,v 1.6 2003/10/13 23:09:56 titer Exp $ +/* $Id: Controller.h,v 1.4 2003/11/07 21:22:17 titer Exp $ This file is part of the HandBrake source code. - Homepage: <http://beos.titer.org/handbrake/>. + Homepage: <http://handbrake.m0k.org/>. It may be used under the terms of the GNU General Public License. */ #include <Cocoa/Cocoa.h> -#include "Common.h" +#include "HandBrake.h" #include "PictureGLView.h" #include "TargetSizeField.h" @@ -18,7 +18,6 @@ IBOutlet NSWindow * fWindow; /* Scan view */ - uint64_t fLastDVDDetection; IBOutlet NSView * fScanView; IBOutlet NSMatrix * fScanMatrix; IBOutlet NSPopUpButton * fDVDPopUp; @@ -63,7 +62,7 @@ /* "Done" alert panel */ IBOutlet NSPanel * fDonePanel; - /* Crop & resize panel */ + /* Crop & scale panel */ IBOutlet NSPanel * fPicturePanel; IBOutlet HBPictureGLView * fPictureGLView; IBOutlet NSTextField * fWidthField; @@ -78,9 +77,12 @@ IBOutlet NSTextField * fRightField; IBOutlet NSStepper * fRightStepper; IBOutlet NSTextField * fInfoField; + IBOutlet NSButton * fOpenGLCheck; + IBOutlet NSButton * fPreviousButton; + IBOutlet NSButton * fNextButton; int fPicture; - HBManager * fManager; + HBHandle * fHandle; HBList * fTitleList; } @@ -91,6 +93,7 @@ - (IBAction) Scan: (id) sender; - (IBAction) TitlePopUpChanged: (id) sender; +- (IBAction) VideoCodecPopUpChanged: (id) sender; - (IBAction) VideoMatrixChanged: (id) sender; - (IBAction) AudioPopUpChanged: (id) sender; - (IBAction) BrowseFile: (id) sender; @@ -111,6 +114,6 @@ - (IBAction) UpdatePicture: (id) sender; - (void) UpdateIntf: (NSTimer *) timer; -- (void) DetectDrives; +- (void) DetectDrives: (NSNotification *) notification; @end diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 402d721fa..a345bdec1 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -1,7 +1,7 @@ -/* $Id: Controller.mm,v 1.10 2003/10/13 23:09:56 titer Exp $ +/* $Id: Controller.mm,v 1.7 2003/11/07 21:22:17 titer Exp $ This file is part of the HandBrake source code. - Homepage: <http://beos.titer.org/handbrake/>. + Homepage: <http://handbrake.m0k.org/>. It may be used under the terms of the GNU General Public License. */ #include <paths.h> @@ -11,20 +11,25 @@ #include <IOKit/storage/IODVDMedia.h> #include "Controller.h" -#include "Manager.h" @implementation HBController - (void) applicationDidFinishLaunching: (NSNotification *) notification { /* Init libhb */ - fManager = new HBManager( true ); + fHandle = HBInit( 1, 0 ); + [fPictureGLView SetHandle: fHandle]; /* Update the GUI every 1/10 sec */ fDie = false; [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector( UpdateIntf: ) userInfo: nil repeats: YES]; + + /* Detect drives mounted after the app is started */ + [[[NSWorkspace sharedWorkspace] notificationCenter] + addObserver: self selector: @selector( DetectDrives: ) + name: NSWorkspaceDidMountNotification object: nil]; } - (NSApplicationTerminateReply) applicationShouldTerminate: @@ -32,7 +37,7 @@ { /* Clean up */ fDie = true; - delete fManager; + HBClose( &fHandle ); return NSTerminateNow; } @@ -42,6 +47,10 @@ [fDVDPopUp removeAllItems]; [fScanProgress setStyle: NSProgressIndicatorSpinningStyle]; [fScanProgress setDisplayedWhenStopped: NO]; + [fVideoCodecPopUp removeAllItems]; + [fVideoCodecPopUp addItemWithTitle: @"MPEG-4 (Ffmpeg)"]; + [fVideoCodecPopUp addItemWithTitle: @"MPEG-4 (XviD)"]; + [fVideoCodecPopUp selectItemWithTitle: @"MPEG-4 (Ffmpeg)"]; [fAudioBitratePopUp removeAllItems]; [fAudioBitratePopUp addItemWithTitle: @"32"]; [fAudioBitratePopUp addItemWithTitle: @"64"]; @@ -65,8 +74,7 @@ [fWindow center]; /* Detect DVD drives */ - fLastDVDDetection = GetDate(); - [self DetectDrives]; + [self DetectDrives: nil]; [self ScanMatrixChanged: self]; } @@ -139,76 +147,82 @@ - (IBAction) Scan: (id) sender { - /* Ask the manager to start scanning the specified volume */ + /* Ask libhb to start scanning the specified volume */ if( ![fScanMatrix selectedRow] ) { /* DVD drive */ - fManager->ScanVolumes( (char*) [[fDVDPopUp titleOfSelectedItem] - cString] ); + HBScanDevice( fHandle, + (char*) [[fDVDPopUp titleOfSelectedItem] cString], + 0 ); } else { /* DVD folder */ - fManager->ScanVolumes( (char*) [[fDVDFolderField stringValue] - cString] ); + HBScanDevice( fHandle, + (char*) [[fDVDFolderField stringValue] cString], + 0 ); } } - (IBAction) ShowPicturePanel: (id) sender { HBTitle * title = (HBTitle*) - fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + HBListItemAt( fTitleList, [fTitlePopUp indexOfSelectedItem] ); - [fPictureGLView SetManager: fManager]; [fPictureGLView SetTitle: title]; fPicture = 0; - [fPictureGLView ShowPicture: fPicture]; + [fPictureGLView ShowPicture: fPicture animate: HB_ANIMATE_NONE]; [fWidthStepper setValueWraps: NO]; [fWidthStepper setIncrement: 16]; [fWidthStepper setMinValue: 16]; - [fWidthStepper setMaxValue: title->fOutWidthMax]; - [fWidthStepper setIntValue: title->fOutWidth]; - [fWidthField setIntValue: title->fOutWidth]; - [fTopStepper setValueWraps: NO]; + [fWidthStepper setMaxValue: title->outWidthMax]; + [fWidthStepper setIntValue: title->outWidth]; + [fWidthField setIntValue: title->outWidth]; + [fDeinterlaceCheck setState: + title->deinterlace ? NSOnState : NSOffState]; + [fTopStepper setValueWraps: NO]; [fTopStepper setIncrement: 2]; [fTopStepper setMinValue: 0]; - [fTopStepper setMaxValue: title->fInHeight / 4]; - [fTopStepper setIntValue: title->fTopCrop]; - [fTopField setIntValue: title->fTopCrop]; + [fTopStepper setMaxValue: title->inHeight / 4]; + [fTopStepper setIntValue: title->topCrop]; + [fTopField setIntValue: title->topCrop]; [fBottomStepper setValueWraps: NO]; [fBottomStepper setIncrement: 2]; [fBottomStepper setMinValue: 0]; - [fBottomStepper setMaxValue: title->fInHeight / 4]; - [fBottomStepper setIntValue: title->fBottomCrop]; - [fBottomField setIntValue: title->fBottomCrop]; + [fBottomStepper setMaxValue: title->inHeight / 4]; + [fBottomStepper setIntValue: title->bottomCrop]; + [fBottomField setIntValue: title->bottomCrop]; [fLeftStepper setValueWraps: NO]; [fLeftStepper setIncrement: 2]; [fLeftStepper setMinValue: 0]; - [fLeftStepper setMaxValue: title->fInWidth / 4]; - [fLeftStepper setIntValue: title->fLeftCrop]; - [fLeftField setIntValue: title->fLeftCrop]; + [fLeftStepper setMaxValue: title->inWidth / 4]; + [fLeftStepper setIntValue: title->leftCrop]; + [fLeftField setIntValue: title->leftCrop]; [fRightStepper setValueWraps: NO]; [fRightStepper setIncrement: 2]; [fRightStepper setMinValue: 0]; - [fRightStepper setMaxValue: title->fInWidth / 4]; - [fRightStepper setIntValue: title->fRightCrop]; - [fRightField setIntValue: title->fRightCrop]; + [fRightStepper setMaxValue: title->inWidth / 4]; + [fRightStepper setIntValue: title->rightCrop]; + [fRightField setIntValue: title->rightCrop]; + + [fPreviousButton setEnabled: NO]; + [fNextButton setEnabled: YES]; char string[1024]; memset( string, 0, 1024 ); sprintf( string, "Final size: %dx%d", - title->fOutWidth, title->fOutHeight ); + title->outWidth, title->outHeight ); [fInfoField setStringValue: [NSString stringWithCString: string]]; /* Resize the panel */ NSSize newSize; /* XXX */ newSize.width = 762 /*fPicturePanelSize.width*/ + - title->fOutWidthMax - 720; + title->outWidthMax - 720; newSize.height = 740 /*fPicturePanelSize.height*/ + - title->fOutHeightMax - 576; + title->outHeightMax - 576; [fPicturePanel setContentSize: newSize]; [NSApp beginSheet: fPicturePanel modalForWindow: fWindow @@ -260,10 +274,10 @@ { fclose( file ); NSBeginCriticalAlertSheet( @"File already exists", - @"Nooo", @"Yes, go ahead!", nil, fWindow, self, + @"Nooo!", @"Yes, go ahead", nil, fWindow, self, @selector( OverwriteAlertDone:returnCode:contextInfo: ), nil, nil, - [NSString stringWithFormat: @"Do you want to overwrite %s ?", + [NSString stringWithFormat: @"Do you want to overwrite %s?", [[fFileField stringValue] cString]] ); return; } @@ -284,32 +298,36 @@ { /* Get the specified title & audio track(s) */ HBTitle * title = (HBTitle*) - fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + HBListItemAt( fTitleList, [fTitlePopUp indexOfSelectedItem] ); HBAudio * audio1 = (HBAudio*) - title->fAudioList->ItemAt( [fLanguagePopUp indexOfSelectedItem] ); + HBListItemAt( title->audioList, + [fLanguagePopUp indexOfSelectedItem] ); HBAudio * audio2 = (HBAudio*) - title->fAudioList->ItemAt( [fSecondaryLanguagePopUp - indexOfSelectedItem] ); + HBListItemAt( title->audioList, + [fSecondaryLanguagePopUp indexOfSelectedItem] ); /* Use user settings */ - title->fBitrate = [fCustomBitrateField intValue]; - title->fTwoPass = ( [fTwoPassCheck state] == NSOnState ); - audio1->fOutBitrate = [[fAudioBitratePopUp titleOfSelectedItem] + title->file = strdup( [[fFileField stringValue] cString] ); + title->bitrate = [fCustomBitrateField intValue]; + title->twoPass = ( [fTwoPassCheck state] == NSOnState ); + title->codec = ( [[fVideoCodecPopUp titleOfSelectedItem] compare: + @"MPEG-4 (Ffmpeg)"] == NSOrderedSame ) ? + HB_CODEC_FFMPEG : HB_CODEC_XVID; + audio1->outBitrate = [[fAudioBitratePopUp titleOfSelectedItem] intValue]; if( audio2 ) { - audio2->fOutBitrate = + audio2->outBitrate = [[fAudioBitratePopUp titleOfSelectedItem] intValue]; } /* Let libhb do the job */ - fManager->StartRip( title, audio1, audio2, - (char*) [[fFileField stringValue] cString] ); + HBStartRip( fHandle, title, audio1, audio2 ); } - (IBAction) Cancel: (id) sender { - fManager->StopRip(); + HBStopRip( fHandle ); } - (IBAction) Suspend: (id) sender @@ -320,50 +338,68 @@ return; } - fManager->SuspendRip(); + HBPauseRip( fHandle ); } - (IBAction) Resume: (id) sender { - fManager->ResumeRip(); + HBResumeRip( fHandle ); } - (IBAction) PreviousPicture: (id) sender { - if( fPicture > 0 ) + fPicture--; + if( [fOpenGLCheck state] == NSOnState ) { - fPicture--; - [fPictureGLView ShowPicture: fPicture]; + [fPictureGLView ShowPicture: fPicture + animate: HB_ANIMATE_LEFT]; } + else + { + [fPictureGLView ShowPicture: fPicture + animate: HB_ANIMATE_NONE]; + } + + [fPreviousButton setEnabled: ( fPicture > 0 )]; + [fNextButton setEnabled: YES]; } - (IBAction) NextPicture: (id) sender { - if( fPicture < 9 ) + fPicture++; + if( [fOpenGLCheck state] == NSOnState ) + { + [fPictureGLView ShowPicture: fPicture + animate: HB_ANIMATE_RIGHT]; + } + else { - fPicture++; - [fPictureGLView ShowPicture: fPicture]; + [fPictureGLView ShowPicture: fPicture + animate: HB_ANIMATE_NONE]; } + + [fPreviousButton setEnabled: YES]; + [fNextButton setEnabled: ( fPicture < 9 )]; } - (IBAction) UpdatePicture: (id) sender { HBTitle * title = (HBTitle*) - fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); - title->fOutWidth = [fWidthStepper intValue]; - title->fDeinterlace = ( [fDeinterlaceCheck state] == NSOnState ); - title->fTopCrop = [fTopStepper intValue]; - title->fBottomCrop = [fBottomStepper intValue]; - title->fLeftCrop = [fLeftStepper intValue]; - title->fRightCrop = [fRightStepper intValue]; - - [fPictureGLView ShowPicture: fPicture]; - - [fWidthStepper setIntValue: title->fOutWidth]; - [fTopStepper setIntValue: title->fTopCrop]; - [fBottomStepper setIntValue: title->fBottomCrop]; - [fLeftStepper setIntValue: title->fLeftCrop]; - [fRightStepper setIntValue: title->fRightCrop]; + HBListItemAt( fTitleList, [fTitlePopUp indexOfSelectedItem] ); + title->outWidth = [fWidthStepper intValue]; + title->deinterlace = ( [fDeinterlaceCheck state] == NSOnState ); + title->topCrop = [fTopStepper intValue]; + title->bottomCrop = [fBottomStepper intValue]; + title->leftCrop = [fLeftStepper intValue]; + title->rightCrop = [fRightStepper intValue]; + + [fPictureGLView ShowPicture: fPicture animate: HB_ANIMATE_NONE]; + + [fWidthStepper setIntValue: title->outWidth]; + [fTopStepper setIntValue: title->topCrop]; + [fBottomStepper setIntValue: title->bottomCrop]; + [fLeftStepper setIntValue: title->leftCrop]; + [fRightStepper setIntValue: title->rightCrop]; [fWidthField setIntValue: [fWidthStepper intValue]]; [fTopField setIntValue: [fTopStepper intValue]]; [fBottomField setIntValue: [fBottomStepper intValue]]; @@ -372,7 +408,7 @@ char string[1024]; memset( string, 0, 1024 ); sprintf( string, "Final size: %dx%d", - title->fOutWidth, title->fOutHeight ); + title->outWidth, title->outHeight ); [fInfoField setStringValue: [NSString stringWithCString: string]]; } @@ -384,25 +420,19 @@ return; } - /* Update DVD popup */ - if( [fWindow contentView] == fScanView && - GetDate() > fLastDVDDetection + 2000000 ) - { - [self DetectDrives]; - fLastDVDDetection = GetDate(); - } - - /* Ask libhb about what's happening now */ - if( fManager->NeedUpdate() ) + int modeChanged; + HBStatus status; + + modeChanged = HBGetStatus( fHandle, &status ); + + switch( status.mode ) { - HBStatus status = fManager->GetStatus(); + case HB_MODE_NEED_DEVICE: + break; - switch( status.fMode ) + case HB_MODE_SCANNING: { - case HB_MODE_NEED_VOLUME: - break; - - case HB_MODE_SCANNING: + if( modeChanged ) { [fScanMatrix setEnabled: NO]; [fDVDPopUp setEnabled: NO]; @@ -410,81 +440,88 @@ [fScanBrowseButton setEnabled: NO]; [fScanProgress startAnimation: self]; [fScanButton setEnabled: NO]; - - char string[1024]; memset( string, 0, 1024 ); - if( status.fScannedTitle ) - { - sprintf( string, "Scanning %s, title %d...", - status.fScannedVolume, - status.fScannedTitle ); - } - else - { - sprintf( string, "Opening %s...", - status.fScannedVolume ); - } - [fScanStatusField setStringValue: - [NSString stringWithCString: string]]; - - break; } - case HB_MODE_INVALID_VOLUME: + char string[1024]; memset( string, 0, 1024 ); + if( status.scannedTitle ) + { + sprintf( string, "Scanning title %d...", + status.scannedTitle ); + } + else { - [fScanMatrix setEnabled: YES]; - [self ScanMatrixChanged: self]; - [fScanProgress stopAnimation: self]; - [fScanButton setEnabled: YES]; + sprintf( string, "Opening device..." ); + } + [fScanStatusField setStringValue: + [NSString stringWithCString: string]]; + + break; + } - [fScanStatusField setStringValue: - @"Invalid volume, try again" ]; + case HB_MODE_INVALID_DEVICE: + { + if( !modeChanged ) break; - } + + [fScanMatrix setEnabled: YES]; + [self ScanMatrixChanged: self]; + [fScanProgress stopAnimation: self]; + [fScanButton setEnabled: YES]; + + [fScanStatusField setStringValue: + @"Invalid volume, try again" ]; + break; + } - case HB_MODE_READY_TO_RIP: - { - fTitleList = status.fTitleList; - - /* Show a temporary empty view while the window - resizing animation */ - [fWindow setContentView: fTempView ]; - - /* Actually resize it */ - NSRect newFrame; - newFrame = [NSWindow contentRectForFrameRect: [fWindow frame] - styleMask: [fWindow styleMask]]; - newFrame.origin.y += newFrame.size.height - - [fRipView frame].size.height; - newFrame.size.height = [fRipView frame].size.height; - newFrame.size.width = [fRipView frame].size.width; - newFrame = [NSWindow frameRectForContentRect: newFrame - styleMask: [fWindow styleMask]]; - [fWindow setFrame: newFrame display: YES animate: YES]; - - /* Show the new GUI */ - [fWindow setContentView: fRipView ]; - [fSuspendButton setEnabled: NO]; - - [fTitlePopUp removeAllItems]; - HBTitle * title; - for( uint32_t i = 0; i < fTitleList->CountItems(); i++ ) - { - title = (HBTitle*) fTitleList->ItemAt( i ); - char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "%d (%02lld:%02lld:%02lld)", - title->fIndex, title->fLength / 3600, - ( title->fLength % 3600 ) / 60, - title->fLength % 60 ); - [[fTitlePopUp menu] addItemWithTitle: - [NSString stringWithCString: string] - action: nil keyEquivalent: @""]; - } - [self TitlePopUpChanged: self]; - + case HB_MODE_READY_TO_RIP: + { + if( !modeChanged ) break; + + fTitleList = status.titleList; + + /* Show a temporary empty view while the window + resizing animation */ + [fWindow setContentView: fTempView ]; + + /* Actually resize it */ + NSRect newFrame; + newFrame = [NSWindow contentRectForFrameRect: [fWindow frame] + styleMask: [fWindow styleMask]]; + newFrame.origin.y += newFrame.size.height - + [fRipView frame].size.height; + newFrame.size.height = [fRipView frame].size.height; + newFrame.size.width = [fRipView frame].size.width; + newFrame = [NSWindow frameRectForContentRect: newFrame + styleMask: [fWindow styleMask]]; + [fWindow setFrame: newFrame display: YES animate: YES]; + + /* Show the new GUI */ + [fWindow setContentView: fRipView ]; + [fSuspendButton setEnabled: NO]; + + [fTitlePopUp removeAllItems]; + HBTitle * title; + for( int i = 0; i < HBListCountItems( fTitleList ); i++ ) + { + title = (HBTitle*) HBListItemAt( fTitleList, i ); + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "%d - %02dh%02dm%02ds", + title->index, title->length / 3600, + ( title->length % 3600 ) / 60, + title->length % 60 ); + [[fTitlePopUp menu] addItemWithTitle: + [NSString stringWithCString: string] + action: nil keyEquivalent: @""]; } + [self TitlePopUpChanged: self]; + + break; + } - case HB_MODE_ENCODING: + case HB_MODE_ENCODING: + { + if( modeChanged ) { [fTitlePopUp setEnabled: NO]; [fVideoCodecPopUp setEnabled: NO]; @@ -502,150 +539,161 @@ [fSuspendButton setEnabled: YES]; [fSuspendButton setTitle: @"Suspend"]; [fRipButton setTitle: @"Cancel"]; - - if( !status.fPosition ) - { - [fRipStatusField setStringValue: @"Starting..."]; - [fRipProgress setIndeterminate: YES]; - [fRipProgress startAnimation: self];; - } - else - { - char string[1024]; - memset( string, 0, 1024 ); - sprintf( string, "Encoding: %.2f %%", - 100 * status.fPosition ); - [fRipStatusField setStringValue: - [NSString stringWithCString: string]]; - memset( string, 0, 1024 ); - sprintf( string, - "Speed: %.2f fps (%02d:%02d:%02d remaining)", - status.fFrameRate, - status.fRemainingTime / 3600, - ( status.fRemainingTime % 3600 ) / 60, - status.fRemainingTime % 60 ); - [fRipInfoField setStringValue: - [NSString stringWithCString: string]]; - - [fRipProgress setIndeterminate: NO]; - [fRipProgress setDoubleValue: 100 * status.fPosition]; - } - - break; } - - case HB_MODE_SUSPENDED: + + if( !status.position ) { - char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "Encoding: %.2f %% (PAUSED)", - 100 * status.fPosition ) ; + [fRipStatusField setStringValue: @"Starting..."]; + [fRipProgress setIndeterminate: YES]; + [fRipProgress startAnimation: self];; + } + else + { + char string[1024]; + memset( string, 0, 1024 ); + sprintf( string, "Encoding: %.2f %% (pass %d of %d)", + 100 * status.position, status.pass, + status.passCount ); [fRipStatusField setStringValue: [NSString stringWithCString: string]]; - [fRipInfoField setStringValue: @""]; - - [fRipProgress setDoubleValue: 100 * status.fPosition]; + memset( string, 0, 1024 ); + sprintf( string, "Speed: %.2f fps (avg %.2f fps, " + "%02dh%02dm%02ds remaining)", + status.frameRate, status.avFrameRate, + status.remainingTime / 3600, + ( status.remainingTime / 60 ) % 60, + status.remainingTime % 60 ); + [fRipInfoField setStringValue: + [NSString stringWithCString: string]]; - [fSuspendButton setTitle: @"Resume"]; - break; + [fRipProgress setIndeterminate: NO]; + [fRipProgress setDoubleValue: 100 * status.position]; } + + break; + } - case HB_MODE_STOPPING: - [fRipStatusField setStringValue: @"Stopping..."]; - [fRipInfoField setStringValue: @""]; - [fRipProgress setIndeterminate: YES]; - [fRipProgress startAnimation: self];; + case HB_MODE_PAUSED: + { + if( !modeChanged ) break; + + char string[1024]; memset( string, 0, 1024 ); + sprintf( string, "Encoding: %.2f %% (PAUSED)", + 100 * status.position ) ; + [fRipStatusField setStringValue: + [NSString stringWithCString: string]]; + [fRipInfoField setStringValue: @""]; + + [fRipProgress setDoubleValue: 100 * status.position]; - case HB_MODE_DONE: - case HB_MODE_CANCELED: - case HB_MODE_ERROR: - [fRipProgress setIndeterminate: NO]; - - if( status.fMode == HB_MODE_DONE ) - { - [fRipProgress setDoubleValue: 100]; - [fRipStatusField setStringValue: @"Done." ]; - NSBeep(); - [NSApp requestUserAttention: NSInformationalRequest]; - [NSApp beginSheet: fDonePanel - modalForWindow: fWindow modalDelegate: nil - didEndSelector: nil contextInfo: nil]; - [NSApp runModalForWindow: fDonePanel]; - [NSApp endSheet: fDonePanel]; - [fDonePanel orderOut: self]; - } - else if( status.fMode == HB_MODE_CANCELED ) - { - [fRipProgress setDoubleValue: 0]; - [fRipStatusField setStringValue: @"Canceled." ]; - } - else - { - [fRipProgress setDoubleValue: 0]; - switch( status.fError ) - { - case HB_ERROR_A52_SYNC: - [fRipStatusField setStringValue: - @"An error occured (corrupted AC3 data)." ]; - break; - case HB_ERROR_AVI_WRITE: - [fRipStatusField setStringValue: - @"An error occured (could not write to file)." ]; - break; - case HB_ERROR_DVD_OPEN: - [fRipStatusField setStringValue: - @"An error occured (could not open device)." ]; - break; - case HB_ERROR_DVD_READ: - [fRipStatusField setStringValue: - @"An error occured (DVD read failed)." ]; - break; - case HB_ERROR_MP3_INIT: - [fRipStatusField setStringValue: - @"An error occured (could not init MP3 encoder)." ]; - break; - case HB_ERROR_MP3_ENCODE: - [fRipStatusField setStringValue: - @"An error occured (MP3 encoder failed)." ]; - break; - case HB_ERROR_MPEG4_INIT: - [fRipStatusField setStringValue: - @"An error occured (could not init MPEG4 encoder)." ]; - break; - } - } + [fSuspendButton setTitle: @"Resume"]; + break; + } - [fRipInfoField setStringValue: @""]; - - [fTitlePopUp setEnabled: YES]; - [fVideoCodecPopUp setEnabled: YES]; - [fVideoMatrix setEnabled: YES]; - [fTwoPassCheck setEnabled: YES]; - [fCropButton setEnabled: YES]; - [fLanguagePopUp setEnabled: YES]; - [fSecondaryLanguagePopUp setEnabled: YES]; - [fAudioCodecPopUp setEnabled: YES]; - [fAudioBitratePopUp setEnabled: YES]; - [fFileFormatPopUp setEnabled: YES]; - [fFileBrowseButton setEnabled: YES]; - [fSuspendButton setEnabled: NO]; - [fSuspendButton setTitle: @"Suspend"]; - [fRipButton setTitle: @"Rip"]; + case HB_MODE_STOPPING: + if( !modeChanged ) + break; - [self VideoMatrixChanged: self]; + [fRipStatusField setStringValue: @"Stopping..."]; + [fRipInfoField setStringValue: @""]; + [fRipProgress setIndeterminate: YES]; + [fRipProgress startAnimation: self];; + break; - /* Warn the finder to update itself */ - [[NSWorkspace sharedWorkspace] noteFileSystemChanged: - [fFileField stringValue]]; + case HB_MODE_DONE: + case HB_MODE_CANCELED: + case HB_MODE_ERROR: + if( !modeChanged ) break; - default: - break; - } + /* Warn the finder to update itself */ + [[NSWorkspace sharedWorkspace] noteFileSystemChanged: + [fFileField stringValue]]; + + [fRipProgress setIndeterminate: NO]; + [fRipInfoField setStringValue: @""]; + + if( status.mode == HB_MODE_DONE ) + { + [fRipProgress setDoubleValue: 100]; + [fRipStatusField setStringValue: @"Done." ]; + NSBeep(); + [NSApp requestUserAttention: NSInformationalRequest]; + [NSApp beginSheet: fDonePanel + modalForWindow: fWindow modalDelegate: nil + didEndSelector: nil contextInfo: nil]; + [NSApp runModalForWindow: fDonePanel]; + [NSApp endSheet: fDonePanel]; + [fDonePanel orderOut: self]; + } + else if( status.mode == HB_MODE_CANCELED ) + { + [fRipProgress setDoubleValue: 0]; + [fRipStatusField setStringValue: @"Canceled." ]; + } + else + { + [fRipProgress setDoubleValue: 0]; + switch( status.error ) + { + case HB_ERROR_A52_SYNC: + [fRipStatusField setStringValue: + @"An error occured (corrupted AC3 data)." ]; + break; + case HB_ERROR_AVI_WRITE: + [fRipStatusField setStringValue: + @"An error occured (could not write to file)." ]; + break; + case HB_ERROR_DVD_OPEN: + [fRipStatusField setStringValue: + @"An error occured (could not open device)." ]; + break; + case HB_ERROR_DVD_READ: + [fRipStatusField setStringValue: + @"An error occured (DVD read failed)." ]; + break; + case HB_ERROR_MP3_INIT: + [fRipStatusField setStringValue: + @"An error occured (could not init MP3 encoder)." ]; + break; + case HB_ERROR_MP3_ENCODE: + [fRipStatusField setStringValue: + @"An error occured (MP3 encoder failed)." ]; + break; + case HB_ERROR_MPEG4_INIT: + [fRipStatusField setStringValue: + @"An error occured (could not init MPEG4 encoder)." ]; + break; + } + } + + [fTitlePopUp setEnabled: YES]; + [fVideoCodecPopUp setEnabled: YES]; + [fVideoMatrix setEnabled: YES]; + [fTwoPassCheck setEnabled: YES]; + [fCropButton setEnabled: YES]; + [fLanguagePopUp setEnabled: YES]; + [fSecondaryLanguagePopUp setEnabled: YES]; + [fAudioCodecPopUp setEnabled: YES]; + [fAudioBitratePopUp setEnabled: YES]; + [fFileFormatPopUp setEnabled: YES]; + [fFileBrowseButton setEnabled: YES]; + [fSuspendButton setEnabled: NO]; + [fSuspendButton setTitle: @"Suspend"]; + [fRipButton setTitle: @"Rip"]; + + [self VideoMatrixChanged: self]; + [self VideoCodecPopUpChanged: self]; + + break; + + default: + break; } } -- (void) DetectDrives +- (void) DetectDrives: (NSNotification *) notification { /* Scan DVD drives (stolen from VLC) */ io_object_t next_media; @@ -666,7 +714,7 @@ return; } - CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectable ), + CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ), kCFBooleanTrue ); kern_result = @@ -690,7 +738,7 @@ { str_bsd_path = IORegistryEntryCreateCFProperty( next_media, - CFSTR( kIOBSDName ), + CFSTR( kIOBSDNameKey ), kCFAllocatorDefault, 0 ); if( str_bsd_path == NULL ) @@ -720,25 +768,6 @@ IOObjectRelease( media_iterator ); - /* Refresh only if a change occured */ - if( [drivesList count] == (unsigned) [fDVDPopUp numberOfItems] ) - { - bool isSame = true; - for( unsigned i = 0; i < [drivesList count]; i++ ) - { - if( ![[drivesList objectAtIndex: i] isEqualToString: - [fDVDPopUp itemTitleAtIndex: i]] ) - { - isSame = false; - break; - } - } - if( isSame ) - { - return; - } - } - [fDVDPopUp removeAllItems]; for( unsigned i = 0; i < [drivesList count]; i++ ) { @@ -770,29 +799,29 @@ - (IBAction) TitlePopUpChanged: (id) sender { HBTitle * title = (HBTitle*) - fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); + HBListItemAt( fTitleList, [fTitlePopUp indexOfSelectedItem] ); [fLanguagePopUp removeAllItems]; [fSecondaryLanguagePopUp removeAllItems]; HBAudio * audio; - for( uint32_t i = 0; i < title->fAudioList->CountItems(); i++ ) + for( int i = 0; i < HBListCountItems( title->audioList ); i++ ) { - audio = (HBAudio*) title->fAudioList->ItemAt( i ); + audio = (HBAudio*) HBListItemAt( title->audioList, i ); /* We cannot use NSPopUpButton's addItemWithTitle because it checks for duplicate entries */ [[fLanguagePopUp menu] addItemWithTitle: - [NSString stringWithCString: audio->fDescription] + [NSString stringWithCString: audio->language] action: nil keyEquivalent: @""]; [[fSecondaryLanguagePopUp menu] addItemWithTitle: - [NSString stringWithCString: audio->fDescription] + [NSString stringWithCString: audio->language] action: nil keyEquivalent: @""]; } [fSecondaryLanguagePopUp addItemWithTitle: @"None"]; [fSecondaryLanguagePopUp selectItemWithTitle: @"None"]; [fSecondaryLanguagePopUp setEnabled: - ( title->fAudioList->CountItems() > 1 )]; + ( HBListCountItems( title->audioList ) > 1 )]; [fTargetSizeField SetHBTitle: title]; if( [fVideoMatrix selectedRow] ) @@ -801,6 +830,20 @@ } } +- (IBAction) VideoCodecPopUpChanged: (id) sender +{ + if( [[fVideoCodecPopUp titleOfSelectedItem] + compare: @"MPEG-4 (Ffmpeg)"] == NSOrderedSame ) + { + [fTwoPassCheck setEnabled: YES]; + } + else + { + [fTwoPassCheck setState: NSOffState]; + [fTwoPassCheck setEnabled: NO]; + } +} + - (IBAction) AudioPopUpChanged: (id) sender { if( [fVideoMatrix selectedRow] ) diff --git a/macosx/English.lproj/InfoPlist.strings b/macosx/English.lproj/InfoPlist.strings Binary files differindex 7690c78ef..9a0f313a7 100644 --- a/macosx/English.lproj/InfoPlist.strings +++ b/macosx/English.lproj/InfoPlist.strings diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index 38429950c..c9539b9d2 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -18,6 +18,7 @@ Suspend = id; TitlePopUpChanged = id; UpdatePicture = id; + VideoCodecPopUpChanged = id; VideoMatrixChanged = id; }; CLASS = HBController; @@ -40,8 +41,11 @@ fLanguagePopUp = NSPopUpButton; fLeftField = NSTextField; fLeftStepper = NSStepper; + fNextButton = NSButton; + fOpenGLCheck = NSButton; fPictureGLView = HBPictureGLView; fPicturePanel = NSPanel; + fPreviousButton = NSButton; fRightField = NSTextField; fRightStepper = NSStepper; fRipButton = NSButton; diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib index af41a1429..96ab6e7ce 100644 --- a/macosx/English.lproj/MainMenu.nib/info.nib +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -3,31 +3,31 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>29 16 381 380 0 0 1440 878 </string> + <string>25 188 381 380 0 0 1440 878 </string> <key>IBEditorPositions</key> <dict> <key>29</key> <string>407 469 205 44 0 0 1440 878 </string> <key>556</key> - <string>510 480 420 244 0 0 1440 878 </string> + <string>510 481 420 244 0 0 1440 878 </string> <key>583</key> - <string>648 516 144 171 0 0 1440 878 </string> + <string>648 517 144 171 0 0 1440 878 </string> <key>589</key> <string>510 282 420 586 0 0 1440 878 </string> </dict> <key>IBFramework Version</key> - <string>291.0</string> + <string>349.0</string> <key>IBOpenObjects</key> <array> - <integer>583</integer> - <integer>21</integer> - <integer>589</integer> - <integer>365</integer> + <integer>556</integer> <integer>434</integer> <integer>29</integer> - <integer>556</integer> + <integer>589</integer> + <integer>21</integer> + <integer>583</integer> + <integer>365</integer> </array> <key>IBSystem Version</key> - <string>6R73</string> + <string>7B85</string> </dict> </plist> diff --git a/macosx/English.lproj/MainMenu.nib/objects.nib b/macosx/English.lproj/MainMenu.nib/objects.nib Binary files differindex 9fe323510..1e6996ef4 100644 --- a/macosx/English.lproj/MainMenu.nib/objects.nib +++ b/macosx/English.lproj/MainMenu.nib/objects.nib diff --git a/macosx/HandBrake.pbproj/project.pbxproj b/macosx/HandBrake.pbproj/project.pbxproj index 2cc6e1054..8c918d283 100644 --- a/macosx/HandBrake.pbproj/project.pbxproj +++ b/macosx/HandBrake.pbproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 38; + objectVersion = 39; objects = { 080E96DCFE201CFB7F000001 = { fileRef = 29B97318FDCFA39411CA2CEA; @@ -23,6 +23,7 @@ isa = PBXGroup; name = Classes; refType = 4; + sourceTree = "<group>"; }; 089C165CFE840E0CC02AAC07 = { children = ( @@ -31,13 +32,16 @@ isa = PBXVariantGroup; name = InfoPlist.strings; refType = 4; + sourceTree = "<group>"; }; 089C165DFE840E0CC02AAC07 = { + expectedFileType = text.plist.strings; fileEncoding = 10; isa = PBXFileReference; name = English; path = English.lproj/InfoPlist.strings; refType = 4; + sourceTree = "<group>"; }; 089C165EFE840E0CC02AAC07 = { fileRef = 089C165CFE840E0CC02AAC07; @@ -64,12 +68,16 @@ isa = PBXGroup; name = "Linked Frameworks"; refType = 4; + sourceTree = "<group>"; }; 1058C7A1FEA54F0111CA2CBB = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; isa = PBXFrameworkReference; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; refType = 0; + sourceTree = "<absolute>"; }; 1058C7A2FEA54F0111CA2CBB = { children = ( @@ -79,6 +87,7 @@ isa = PBXGroup; name = "Other Frameworks"; refType = 4; + sourceTree = "<group>"; }; 1058C7A3FEA54F0111CA2CBB = { fileRef = 1058C7A1FEA54F0111CA2CBB; @@ -97,9 +106,12 @@ //173 //174 17587328FF379C6511CA2CBB = { + expectedFileType = wrapper.application; + fallbackIsa = PBXFileReference; isa = PBXApplicationReference; path = HandBrake.app; refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; }; //170 //171 @@ -118,6 +130,7 @@ isa = PBXGroup; name = Products; refType = 4; + sourceTree = "<group>"; }; //190 //191 @@ -130,6 +143,10 @@ //293 //294 29B97313FDCFA39411CA2CEA = { + buildSettings = { + MACOSX_DEPLOYMENT_TARGET = 10.2; + SDKROOT = /Developer/SDKs/MacOSX10.2.7.sdk; + }; buildStyles = ( 4A9504CCFFE6A4B311CA0CBA, 4A9504CDFFE6A4B311CA0CBA, @@ -154,23 +171,26 @@ name = HandBrake; path = ""; refType = 4; + sourceTree = "<group>"; }; 29B97315FDCFA39411CA2CEA = { children = ( 29B97316FDCFA39411CA2CEA, - 4D358C040534AB8100D654EB, - 4D929FEB0527903D00A80101, + 4DFDC318054AC84C00151618, ); isa = PBXGroup; name = "Other Sources"; path = ""; refType = 4; + sourceTree = "<group>"; }; 29B97316FDCFA39411CA2CEA = { + expectedFileType = sourcecode.cpp.objcpp; fileEncoding = 30; isa = PBXFileReference; path = main.mm; refType = 4; + sourceTree = "<group>"; }; 29B97317FDCFA39411CA2CEA = { children = ( @@ -183,6 +203,7 @@ 4D69F5CC0527944A00A80101, 4D69F5CD0527944A00A80101, 4D69F5CE0527944A00A80101, + 4DDEF3B905474DCC002904DE, 4D118405053054CD00C39CA9, 089C165CFE840E0CC02AAC07, ); @@ -190,6 +211,7 @@ name = Resources; path = ""; refType = 4; + sourceTree = "<group>"; }; 29B97318FDCFA39411CA2CEA = { children = ( @@ -199,12 +221,15 @@ name = MainMenu.nib; path = ""; refType = 4; + sourceTree = "<group>"; }; 29B97319FDCFA39411CA2CEA = { + expectedFileType = wrapper.nib; isa = PBXFileReference; name = English; path = English.lproj/MainMenu.nib; refType = 4; + sourceTree = "<group>"; }; 29B97323FDCFA39411CA2CEA = { children = ( @@ -215,18 +240,25 @@ name = Frameworks; path = ""; refType = 4; + sourceTree = "<group>"; }; 29B97324FDCFA39411CA2CEA = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; isa = PBXFrameworkReference; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; refType = 0; + sourceTree = "<absolute>"; }; 29B97325FDCFA39411CA2CEA = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; isa = PBXFrameworkReference; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; refType = 0; + sourceTree = "<absolute>"; }; 29B97326FDCFA39411CA2CEA = { buildPhases = ( @@ -263,7 +295,7 @@ <key>CFBundleExecutable</key> <string>HandBrake</string> <key>CFBundleGetInfoString</key> - <string>HandBrake 0.4.1 - By Eric Petit <[email protected]></string> + <string>HandBrake 0.5 - By Eric Petit <[email protected]></string> <key>CFBundleIconFile</key> <string>HandBrake.icns</string> <key>CFBundleIdentifier</key> @@ -275,11 +307,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>0.4.1</string> + <string>0.5</string> <key>CFBundleSignature</key> <string>HB##</string> <key>CFBundleVersion</key> - <string>0.4.1</string> + <string>0.5</string> <key>NSMainNibFile</key> <string>MainMenu</string> <key>NSPrincipalClass</key> @@ -291,11 +323,10 @@ 29B97327FDCFA39411CA2CEA = { buildActionMask = 2147483647; files = ( - 4D929FEC0527903D00A80101, 4D6615EA05288C2300A80101, 4D857591052B78E300C39CA9, 4D358C020534A91300D654EB, - 4D358C050534AB8100D654EB, + 4DFDC319054AC84C00151618, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -343,6 +374,7 @@ 4D69F5D50527944A00A80101, 4DEB2025052B055F00C39CA9, 4DDE9725052B7B2B00C39CA9, + 4DDEF3BA05474DCC002904DE, ); isa = PBXFrameworksBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -362,7 +394,12 @@ ); buildSettings = { COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; OPTIMIZATION_CFLAGS = "-O0"; + ZERO_LINK = YES; }; isa = PBXBuildStyle; name = Development; @@ -372,6 +409,8 @@ ); buildSettings = { COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + ZERO_LINK = NO; }; isa = PBXBuildStyle; name = Deployment; @@ -387,9 +426,11 @@ //4D3 //4D4 4D118405053054CD00C39CA9 = { + expectedFileType = image.icns; isa = PBXFileReference; path = HandBrake.icns; refType = 4; + sourceTree = "<group>"; }; 4D118406053054CD00C39CA9 = { fileRef = 4D118405053054CD00C39CA9; @@ -398,16 +439,20 @@ }; }; 4D358C000534A91300D654EB = { + expectedFileType = sourcecode.c.h; fileEncoding = 30; isa = PBXFileReference; path = TargetSizeField.h; refType = 4; + sourceTree = "<group>"; }; 4D358C010534A91300D654EB = { + expectedFileType = sourcecode.cpp.objcpp; fileEncoding = 30; isa = PBXFileReference; path = TargetSizeField.mm; refType = 4; + sourceTree = "<group>"; }; 4D358C020534A91300D654EB = { fileRef = 4D358C000534A91300D654EB; @@ -421,19 +466,6 @@ settings = { }; }; - 4D358C040534AB8100D654EB = { - fileEncoding = 30; - isa = PBXFileReference; - name = Common.h; - path = /Users/titer/HandBrake/core/Common.h; - refType = 0; - }; - 4D358C050534AB8100D654EB = { - fileRef = 4D358C040534AB8100D654EB; - isa = PBXBuildFile; - settings = { - }; - }; 4D6615EA05288C2300A80101 = { fileRef = 4DF3C8CB052889CD00A80101; isa = PBXBuildFile; @@ -441,46 +473,60 @@ }; }; 4D69F5C80527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = liba52.a; path = /usr/local/lib/liba52.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5C90527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libavcodec.a; path = /usr/local/lib/libavcodec.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CA0527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libdvdcss.a; path = /usr/local/lib/libdvdcss.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CB0527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libdvdplay.a; path = /usr/local/lib/libdvdplay.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CC0527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libdvdread.a; path = /usr/local/lib/libdvdread.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CD0527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libmp3lame.a; path = /usr/local/lib/libmp3lame.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CE0527944A00A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libmpeg2.a; path = /usr/local/lib/libmpeg2.a; refType = 0; + sourceTree = "<absolute>"; }; 4D69F5CF0527944A00A80101 = { fileRef = 4D69F5C80527944A00A80101; @@ -525,16 +571,20 @@ }; }; 4D85758E052B78E300C39CA9 = { + expectedFileType = sourcecode.cpp.objcpp; fileEncoding = 30; isa = PBXFileReference; path = PictureGLView.mm; refType = 4; + sourceTree = "<group>"; }; 4D85758F052B78E300C39CA9 = { + expectedFileType = sourcecode.c.h; fileEncoding = 30; isa = PBXFileReference; path = PictureGLView.h; refType = 4; + sourceTree = "<group>"; }; 4D857590052B78E300C39CA9 = { fileRef = 4D85758E052B78E300C39CA9; @@ -548,24 +598,13 @@ settings = { }; }; - 4D929FEB0527903D00A80101 = { - fileEncoding = 30; - isa = PBXFileReference; - name = Manager.h; - path = ../core/Manager.h; - refType = 4; - }; - 4D929FEC0527903D00A80101 = { - fileRef = 4D929FEB0527903D00A80101; - isa = PBXBuildFile; - settings = { - }; - }; 4D929FED0527907200A80101 = { + expectedFileType = archive.ar; isa = PBXFileReference; name = libhb.a; path = ../core/libhb.a; refType = 4; + sourceTree = "<group>"; }; 4D929FEE0527907200A80101 = { fileRef = 4D929FED0527907200A80101; @@ -574,10 +613,13 @@ }; }; 4DDE9724052B7B2B00C39CA9 = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; isa = PBXFrameworkReference; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; refType = 0; + sourceTree = "<absolute>"; }; 4DDE9725052B7B2B00C39CA9 = { fileRef = 4DDE9724052B7B2B00C39CA9; @@ -585,11 +627,28 @@ settings = { }; }; + 4DDEF3B905474DCC002904DE = { + expectedFileType = archive.ar; + isa = PBXFileReference; + name = libxvidcore.a; + path = /usr/local/lib/libxvidcore.a; + refType = 0; + sourceTree = "<absolute>"; + }; + 4DDEF3BA05474DCC002904DE = { + fileRef = 4DDEF3B905474DCC002904DE; + isa = PBXBuildFile; + settings = { + }; + }; 4DEB2024052B055F00C39CA9 = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; isa = PBXFrameworkReference; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; refType = 0; + sourceTree = "<absolute>"; }; 4DEB2025052B055F00C39CA9 = { fileRef = 4DEB2024052B055F00C39CA9; @@ -598,16 +657,20 @@ }; }; 4DF3C8CB052889CD00A80101 = { + expectedFileType = sourcecode.c.h; fileEncoding = 30; isa = PBXFileReference; path = Controller.h; refType = 4; + sourceTree = "<group>"; }; 4DF3C8CC052889CD00A80101 = { + expectedFileType = sourcecode.cpp.objcpp; fileEncoding = 30; isa = PBXFileReference; path = Controller.mm; refType = 4; + sourceTree = "<group>"; }; 4DF3C8CE052889CD00A80101 = { fileRef = 4DF3C8CC052889CD00A80101; @@ -615,6 +678,21 @@ settings = { }; }; + 4DFDC318054AC84C00151618 = { + expectedFileType = sourcecode.c.h; + fileEncoding = 30; + isa = PBXFileReference; + name = HandBrake.h; + path = ../core/HandBrake.h; + refType = 4; + sourceTree = "<group>"; + }; + 4DFDC319054AC84C00151618 = { + fileRef = 4DFDC318054AC84C00151618; + isa = PBXBuildFile; + settings = { + }; + }; }; rootObject = 29B97313FDCFA39411CA2CEA; } diff --git a/macosx/PictureGLView.h b/macosx/PictureGLView.h index 06e5a16e1..c558c3c0f 100644 --- a/macosx/PictureGLView.h +++ b/macosx/PictureGLView.h @@ -1,20 +1,34 @@ -/* PictureGLView */ +/* $Id: PictureGLView.h,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.m0k.org/>. + It may be used under the terms of the GNU General Public License. */ #include <Cocoa/Cocoa.h> -#include "Manager.h" +#include "HandBrake.h" + +#define HB_ANIMATE_NONE 0 +#define HB_ANIMATE_LEFT 1 +#define HB_ANIMATE_RIGHT 2 @interface HBPictureGLView : NSOpenGLView { - HBManager * fManager; + HBHandle * fHandle; HBTitle * fTitle; uint8_t * fPicture; + uint8_t * fOldPicture; } -- (void) SetManager: (HBManager*) manager; +- (id) initWithFrame: (NSRect) frame; +- (void) reshape; +- (void) drawRect: (NSRect) rect; +- (void) drawAnimation: (int) how; + +- (void) SetHandle: (HBHandle*) handle; - (void) SetTitle: (HBTitle*) title; -- (void) ShowPicture: (int) picture; +- (void) ShowPicture: (int) index animate: (int) how; @end diff --git a/macosx/PictureGLView.mm b/macosx/PictureGLView.mm index 79103f6b6..8df19907b 100644 --- a/macosx/PictureGLView.mm +++ b/macosx/PictureGLView.mm @@ -1,68 +1,153 @@ +/* $Id: PictureGLView.mm,v 1.3 2003/11/03 22:01:13 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.m0k.org/>. + It may be used under the terms of the GNU General Public License. */ + #include <OpenGL/gl.h> +#include <math.h> #include "PictureGLView.h" +#define PROUT 2.5 + +/* XXX This file needs some serious cleaning XXX */ + +GLuint texture[2]; +float rotation; +float translation; +uint8_t * truc; + @implementation HBPictureGLView -- (void) SetManager: (HBManager*) manager +- (void) SetHandle: (HBHandle*) handle { - fManager = manager; + fHandle = handle; } - (void) SetTitle: (HBTitle*) title { fTitle = title; - + /* This is needed as the view's size may have changed */ [self clearGLContext]; [self openGLContext]; } -- (void) ShowPicture: (int) index +- (void) ShowPicture: (int) index animate: (int) how { + if( fOldPicture ) free( fOldPicture ); + fOldPicture = fPicture; + /* Get the picture */ - uint8_t * tmp = fManager->GetPreview( fTitle, index ); + uint8_t * tmp = HBGetPreview( fHandle, fTitle, index ); /* Make it be upside-down */ - if( fPicture ) free( fPicture ); - fPicture = (uint8_t*) malloc( 4 * ( fTitle->fOutWidthMax + 2 ) * - ( fTitle->fOutHeightMax + 2 ) ); - for( uint32_t i = 0; i < fTitle->fOutHeightMax + 2; i++ ) + fPicture = (uint8_t*) malloc( 4 * ( fTitle->outWidthMax + 2 ) * + ( fTitle->outHeightMax + 2 ) ); + uint8_t * in = tmp; + uint8_t * out = fPicture + + 4 * ( fTitle->outWidthMax + 2 ) * ( fTitle->outHeightMax + 1 ); + for( int i = 0; i < fTitle->outHeightMax + 2; i++ ) { - memcpy( fPicture + 4 * ( fTitle->fOutWidthMax + 2 ) * i, - tmp + 4 * ( fTitle->fOutWidthMax + 2 ) * - ( fTitle->fOutHeightMax + 1 - i ), - 4 * ( fTitle->fOutWidthMax + 2 ) ); + memcpy( out, in, 4 * ( fTitle->outWidthMax + 2 ) ); + in += 4 * ( fTitle->outWidthMax + 2 ); + out -= 4 * ( fTitle->outWidthMax + 2 ); } free( tmp ); - /* Grrr - should find a way to give ARGB to OpenGL */ - uint8_t r, g, b, a; - for( uint32_t i = 0; i < fTitle->fOutHeightMax + 2; i++ ) + /* ARGB -> RGBA */ + uint32_t * p = (uint32_t*) fPicture; + for( int i = 0; + i < ( fTitle->outHeightMax + 2 ) * ( fTitle->outWidthMax + 2 ); + i++ ) + { + *(p++) = ( ( (*p) & 0xff000000 ) >> 24 ) | + ( ( (*p) & 0x00ff0000 ) << 8 ) | + ( ( (*p) & 0x0000ff00 ) << 8 ) | + ( ( (*p) & 0x000000ff ) << 8 ); + } + + if( how == HB_ANIMATE_NONE ) + { + [self drawRect: [self bounds]]; + return; + } + + in = fOldPicture; + out = truc; + for( int i = 0; i < fTitle->outHeightMax + 2; i++ ) + { + memcpy( out, in, ( fTitle->outWidthMax + 2 ) * 4 ); + in += ( fTitle->outWidthMax + 2 ) * 4; + out += 1024 * 4; + } + glBindTexture( GL_TEXTURE_2D, texture[0] ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 1024, + 1024, 0, GL_RGBA, + GL_UNSIGNED_BYTE, truc ); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + + in = fPicture; + out = truc; + for( int i = 0; i < fTitle->outHeightMax + 2; i++ ) { - for( uint32_t j = 0; j < fTitle->fOutWidthMax + 2; j++ ) + memcpy( out, in, ( fTitle->outWidthMax + 2 ) * 4 ); + in += ( fTitle->outWidthMax + 2 ) * 4; + out += 1024 * 4; + } + glBindTexture( GL_TEXTURE_2D, texture[1] ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 1024, + 1024, 0, GL_RGBA, + GL_UNSIGNED_BYTE, truc ); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + + glEnable( GL_TEXTURE_2D ); + glShadeModel( GL_SMOOTH ); + glClearColor( 0.0f, 0.0f, 0.0f, 0.5f ); + glClearDepth( 1.0f ); + glEnable( GL_DEPTH_TEST ); + glDepthFunc( GL_LEQUAL ); + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); + +#define ANIMATION_TIME 500000 + + rotation = 0.0; + float w = ( how == HB_ANIMATE_LEFT ) ? 1.0 : -1.0; + uint64_t date; + int64_t wait; + for( ;; ) + { + date = HBGetDate(); + translation = - PROUT - cos( rotation * M_PI / 180 ) * + ( 1 + w * tan( rotation * M_PI / 180 ) ); + + [self drawAnimation: how]; + + rotation += w; + if( w * rotation >= 90.0 ) + { + break; + } + + wait = ANIMATION_TIME / 90 - ( HBGetDate() - date ); + if( wait > 0 ) { - a = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)]; - r = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+1]; - g = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+2]; - b = fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+3]; - - fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)] = r; - fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+1] = g; - fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+2] = b; - fPicture[4*(i*(fTitle->fOutWidthMax+2)+j)+3] = a; + HBSnooze( wait ); } } - [self setNeedsDisplay: YES]; + [self drawRect: [self bounds]]; } -/* Override NSView's initWithFrame: to specify our pixel format */ - (id) initWithFrame: (NSRect) frame { - fManager = NULL; - fTitle = NULL; - fPicture = NULL; + fHandle = NULL; + fTitle = NULL; + fPicture = NULL; + fOldPicture = NULL; GLuint attribs[] = { @@ -81,34 +166,109 @@ NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs]; - if( !fmt ) + self = [super initWithFrame:frame pixelFormat: [fmt autorelease]]; + + if( !self ) { - fprintf( stderr, "Sarass\n" ); + return NULL; } - return self = [super initWithFrame:frame pixelFormat: - [fmt autorelease]]; + [[self openGLContext] makeCurrentContext]; + [self reshape]; + + glGenTextures( 2, texture ); + truc = (uint8_t*) malloc( 1024*1024*4 ); + + return self; +} + +/* + * Resize ourself + */ +- (void) reshape +{ + NSRect bounds; + + [[self openGLContext] update]; + bounds = [self bounds]; + glViewport( 0, 0, (GLsizei) bounds.size.width, + (GLsizei) bounds.size.height ); +} + +- (void) drawAnimation: (int) how +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, PROUT, 20.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, translation ); + glRotatef( rotation, 0.0, 1.0, 0.0 ); + + glEnable( GL_POLYGON_SMOOTH ); + glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); + + glBindTexture( GL_TEXTURE_2D, texture[0] ); + + glBegin( GL_QUADS ); + glTexCoord2f( 0.0, 0.0 ); + glVertex3f( -1.0, -1.0, 1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, 0.0 ); + glVertex3f( 1.0, -1.0, 1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, + ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( 1.0, 1.0, 1.0 ); + glTexCoord2f( 0.0, ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( -1.0, 1.0, 1.0 ); + glEnd(); + + glBindTexture( GL_TEXTURE_2D, texture[1] ); + + glBegin( GL_QUADS ); + if( how == HB_ANIMATE_RIGHT ) + { + glTexCoord2f( 0.0, 0.0 ); + glVertex3f( 1.0, -1.0, 1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, 0.0 ); + glVertex3f( 1.0, -1.0, -1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, + ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( 1.0, 1.0, -1.0 ); + glTexCoord2f( 0.0, ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( 1.0, 1.0, 1.0 ); + } + else + { + glTexCoord2f( 0.0, 0.0 ); + glVertex3f( -1.0, -1.0, -1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, 0.0 ); + glVertex3f( -1.0, -1.0, 1.0 ); + glTexCoord2f( ( 2.0 + fTitle->outWidthMax ) / 1024, + ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( -1.0, 1.0, 1.0 ); + glTexCoord2f( 0.0, ( 2.0 + fTitle->outHeightMax ) / 1024 ); + glVertex3f( -1.0, 1.0, -1.0 ); + } + glEnd(); + + [[self openGLContext] flushBuffer]; } -/* Override the view's drawRect: to draw our GL content */ - (void) drawRect: (NSRect) rect { - glViewport( 0, 0, (GLsizei) rect.size.width, - (GLsizei) rect.size.height ); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - /* Black background */ - glClearColor( 0, 0, 0, 0 ); - glClear( GL_COLOR_BUFFER_BIT ); + if( !fPicture ) + { + return; + } - /* Show it */ - if( fPicture ) - { - glDrawPixels( fTitle->fOutWidthMax + 2, - fTitle->fOutHeightMax + 2, GL_RGBA, - GL_UNSIGNED_BYTE, fPicture ); - } + glDrawPixels( fTitle->outWidthMax + 2, + fTitle->outHeightMax + 2, GL_RGBA, + GL_UNSIGNED_BYTE, fPicture ); - [[self openGLContext] flushBuffer]; + [[self openGLContext] flushBuffer]; } @end diff --git a/macosx/TargetSizeField.h b/macosx/TargetSizeField.h index 12224cae7..6bc4a716f 100644 --- a/macosx/TargetSizeField.h +++ b/macosx/TargetSizeField.h @@ -1,12 +1,12 @@ -/* $Id: TargetSizeField.h,v 1.2 2003/10/09 23:33:36 titer Exp $ +/* $Id: TargetSizeField.h,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ This file is part of the HandBrake source code. - Homepage: <http://beos.titer.org/handbrake/>. + Homepage: <http://handbrake.m0k.org/>. It may be used under the terms of the GNU General Public License. */ #include <Cocoa/Cocoa.h> -#include "Common.h" +#include "HandBrake.h" @interface HBTargetSizeField : NSTextField diff --git a/macosx/TargetSizeField.mm b/macosx/TargetSizeField.mm index 0c43701fb..bde9f0ec2 100644 --- a/macosx/TargetSizeField.mm +++ b/macosx/TargetSizeField.mm @@ -1,7 +1,7 @@ -/* $Id: TargetSizeField.mm,v 1.4 2003/10/09 23:33:36 titer Exp $ +/* $Id: TargetSizeField.mm,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ This file is part of the HandBrake source code. - Homepage: <http://beos.titer.org/handbrake/>. + Homepage: <http://handbrake.m0k.org/>. It may be used under the terms of the GNU General Public License. */ #include "TargetSizeField.h" @@ -41,14 +41,14 @@ /* Video chunk headers (8 bytes / frame) and index (16 bytes / frame) */ - available -= 24 * fTitle->fLength * fTitle->fRate / fTitle->fScale; + available -= 24 * fTitle->length * fTitle->rate / fTitle->rateBase; /* Audio tracks */ available -= ( ( [[fSecondaryLanguagePopUp titleOfSelectedItem] compare: @"None"] == NSOrderedSame ) ? 1 : 2 ) * - ( fTitle->fLength * + ( fTitle->length * [[fAudioBitratePopUp titleOfSelectedItem] intValue] * - 128 + 24 * fTitle->fLength * 44100 / 1152 ); + 128 + 24 * fTitle->length * 44100 / 1152 ); if( available < 0 ) { @@ -57,7 +57,7 @@ else { [fBitrateField setIntValue: - available / ( 128 * fTitle->fLength )]; + available / ( 128 * fTitle->length )]; } } diff --git a/macosx/main.mm b/macosx/main.mm index 56aa102fa..bd649f8ba 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,7 +1,7 @@ -/* $Id: main.mm,v 1.5 2003/09/30 14:38:15 titer Exp $ +/* $Id: main.mm,v 1.1.1.1 2003/11/03 12:03:51 titer Exp $ This file is part of the HandBrake source code. - Homepage: <http://beos.titer.org/handbrake/>. + Homepage: <http://handbrake.m0k.org/>. It may be used under the terms of the GNU General Public License. */ #import <Cocoa/Cocoa.h> |