OSDN Git Service

import 0.9.4 original original-0.9.4
authorhylom <hylom@silver.local>
Thu, 3 Dec 2009 12:18:17 +0000 (21:18 +0900)
committerhylom <hylom@silver.local>
Thu, 3 Dec 2009 12:18:17 +0000 (21:18 +0900)
383 files changed:
AUTHORS
NEWS
configure
contrib/a52dec/A00-dpl2.patch [new file with mode: 0644]
contrib/a52dec/module.defs [new file with mode: 0644]
contrib/a52dec/module.rules [new file with mode: 0644]
contrib/bzip2/module.defs [new file with mode: 0644]
contrib/bzip2/module.rules [new file with mode: 0644]
contrib/faac/P00-cygwin.patch [new file with mode: 0644]
contrib/faac/module.defs [new file with mode: 0644]
contrib/faac/module.rules [new file with mode: 0644]
contrib/faad2/P00-mingw-types.patch [new file with mode: 0644]
contrib/faad2/P00-solaris.patch [new file with mode: 0644]
contrib/faad2/module.defs [new file with mode: 0644]
contrib/faad2/module.rules [new file with mode: 0644]
contrib/ffmpeg/A00-latm.patch [new file with mode: 0644]
contrib/ffmpeg/A01-mpegleak.patch [new file with mode: 0644]
contrib/ffmpeg/A02-audioconvert.patch [new file with mode: 0644]
contrib/ffmpeg/A03-png-sequences.patch [new file with mode: 0644]
contrib/ffmpeg/A04-disable-depend.patch [new file with mode: 0644]
contrib/ffmpeg/P00-cygwin.patch [new file with mode: 0644]
contrib/ffmpeg/P01-solaris.patch [new file with mode: 0644]
contrib/ffmpeg/module.defs [new file with mode: 0644]
contrib/ffmpeg/module.rules [new file with mode: 0644]
contrib/lame/P00-darwin-xmmintrin.patch [new file with mode: 0644]
contrib/lame/module.defs [new file with mode: 0644]
contrib/lame/module.rules [new file with mode: 0644]
contrib/libdca/A00-general.patch [new file with mode: 0644]
contrib/libdca/module.defs [new file with mode: 0644]
contrib/libdca/module.rules [new file with mode: 0644]
contrib/libdvdnav/A00-log-stderr.patch [new file with mode: 0644]
contrib/libdvdnav/A01-program-info.patch [new file with mode: 0644]
contrib/libdvdnav/A02-mult-pgc.patch [new file with mode: 0644]
contrib/libdvdnav/A03-quiet.patch [new file with mode: 0644]
contrib/libdvdnav/A04-m4-uid0.patch [new file with mode: 0644]
contrib/libdvdnav/A05-forward-seek.patch [new file with mode: 0644]
contrib/libdvdnav/A07-missing-menu.patch [new file with mode: 0644]
contrib/libdvdnav/P00-mingw-no-examples.patch [new file with mode: 0644]
contrib/libdvdnav/module.defs [new file with mode: 0644]
contrib/libdvdnav/module.rules [new file with mode: 0644]
contrib/libdvdread/A00-volume-name.patch [new file with mode: 0644]
contrib/libdvdread/A02-msc_ver-defs.patch [new file with mode: 0644]
contrib/libdvdread/A03-m4-uid0.patch [new file with mode: 0644]
contrib/libdvdread/A04-dup-lut-pgc.patch [new file with mode: 0644]
contrib/libdvdread/P00-darwin-css-vlc-dylib.patch [new file with mode: 0644]
contrib/libdvdread/P05-mingw-large-file.patch [new file with mode: 0644]
contrib/libdvdread/P06-darwin.patch [new file with mode: 0644]
contrib/libdvdread/module.defs [new file with mode: 0644]
contrib/libdvdread/module.rules [new file with mode: 0644]
contrib/libiconv/module.defs [new file with mode: 0644]
contrib/libiconv/module.rules [new file with mode: 0644]
contrib/libmkv/P00-mingw-large-file.patch [new file with mode: 0644]
contrib/libmkv/module.defs [new file with mode: 0644]
contrib/libmkv/module.rules [new file with mode: 0644]
contrib/libogg/module.defs [new file with mode: 0644]
contrib/libogg/module.rules [new file with mode: 0644]
contrib/libsamplerate/module.defs [new file with mode: 0644]
contrib/libsamplerate/module.rules [new file with mode: 0644]
contrib/libtheora/module.defs [new file with mode: 0644]
contrib/libtheora/module.rules [new file with mode: 0644]
contrib/libvorbis/A00-disable-examples.patch [new file with mode: 0644]
contrib/libvorbis/module.defs [new file with mode: 0644]
contrib/libvorbis/module.rules [new file with mode: 0644]
contrib/mp4v2/module.defs [new file with mode: 0644]
contrib/mp4v2/module.rules [new file with mode: 0644]
contrib/mpeg2dec/A00-tags.patch [new file with mode: 0644]
contrib/mpeg2dec/module.defs [new file with mode: 0644]
contrib/mpeg2dec/module.rules [new file with mode: 0644]
contrib/pthreadw32/module.defs [new file with mode: 0644]
contrib/pthreadw32/module.rules [new file with mode: 0644]
contrib/x264/P01-solaris.patch [new file with mode: 0644]
contrib/x264/module.defs [new file with mode: 0644]
contrib/x264/module.rules [new file with mode: 0644]
contrib/zlib/module.defs [new file with mode: 0644]
contrib/zlib/module.rules [new file with mode: 0644]
doc/BUILD-Cygwin [new file with mode: 0644]
doc/BUILD-Linux [new file with mode: 0644]
doc/BUILD-Mac [new file with mode: 0644]
doc/module.defs [new file with mode: 0644]
doc/module.rules [new file with mode: 0644]
doc/texi/Building.cygwin.texi [new file with mode: 0644]
doc/texi/Building.linux.texi [new file with mode: 0644]
doc/texi/Building.osx.texi [new file with mode: 0644]
doc/texi/base/article.texi [new file with mode: 0644]
doc/texi/base/glossary.texi [new file with mode: 0644]
doc/texi/base/handbrake.texi.m4 [new file with mode: 0644]
doc/texi/building/appendix.repo.texi [new file with mode: 0644]
doc/texi/building/chapter.introduction.texi [new file with mode: 0644]
doc/texi/building/chapter.quickstart.texi [new file with mode: 0644]
doc/texi/building/chapter.troubleshooting.texi [new file with mode: 0644]
doc/texi/building/chapter.via.terminal.texi [new file with mode: 0644]
doc/texi/building/chapter.via.xcode.texi [new file with mode: 0644]
doc/texi/building/command.texi [new file with mode: 0644]
doc/texi/building/method.checkout.texi [new file with mode: 0644]
doc/texi/building/prerequisites.bundled.texi [new file with mode: 0644]
doc/texi/building/prerequisites.common.texi [new file with mode: 0644]
gtk/Makefile.am
gtk/configure.ac
gtk/ghb.spec
gtk/module.defs [new file with mode: 0644]
gtk/module.rules [new file with mode: 0644]
gtk/src/Makefile.am
gtk/src/appcast.c
gtk/src/audiohandler.c
gtk/src/audiohandler.h
gtk/src/callbacks.c
gtk/src/callbacks.h
gtk/src/composite_example.c [new file with mode: 0644]
gtk/src/create_resources.c
gtk/src/create_resources.py [new file with mode: 0644]
gtk/src/ghb-dvd.c
gtk/src/ghb.ui
gtk/src/ghbcellrenderertext.c
gtk/src/ghbcompositor.c [new file with mode: 0644]
gtk/src/ghbcompositor.h [new file with mode: 0644]
gtk/src/hb-backend.c
gtk/src/hb-backend.h
gtk/src/hb-picture.32.png [new file with mode: 0644]
gtk/src/hb-status-empty.32.png [new file with mode: 0644]
gtk/src/hb-status.32.png [new file with mode: 0644]
gtk/src/icons.c
gtk/src/internal_defaults.xml
gtk/src/main.c
gtk/src/makedeps.py [new file with mode: 0644]
gtk/src/plist.c
gtk/src/preset_xlat.c
gtk/src/presets.c
gtk/src/presets.h
gtk/src/preview.c [new file with mode: 0644]
gtk/src/preview.h [new file with mode: 0644]
gtk/src/queuehandler.c
gtk/src/queuehandler.h
gtk/src/quotestring.py [new file with mode: 0644]
gtk/src/resources.list
gtk/src/settings.c
gtk/src/settings.h
gtk/src/standard_presets.xml
gtk/src/subtitlehandler.c [new file with mode: 0644]
gtk/src/subtitlehandler.h [new file with mode: 0644]
gtk/src/values.c
gtk/src/values.h
gtk/src/widgetdeps.c [new file with mode: 0644]
gtk/src/x264handler.c
gtk/src/x264handler.h
libhb/common.c
libhb/common.h
libhb/deblock.c
libhb/deca52.c
libhb/decavcodec.c
libhb/deccc608sub.c [new file with mode: 0644]
libhb/deccc608sub.h [new file with mode: 0644]
libhb/decdca.c
libhb/decmetadata.c [new file with mode: 0644]
libhb/decmpeg2.c
libhb/decomb.c
libhb/decsrtsub.c [new file with mode: 0644]
libhb/decvobsub.c [new file with mode: 0644]
libhb/deinterlace.c
libhb/demuxmpeg.c
libhb/denoise.c
libhb/detelecine.c
libhb/dvd.c
libhb/dvd.h [new file with mode: 0644]
libhb/dvdnav.c [new file with mode: 0644]
libhb/eedi2.c [new file with mode: 0644]
libhb/eedi2.h [new file with mode: 0644]
libhb/encavcodec.c
libhb/enclame.c
libhb/enctheora.c
libhb/encvobsub.c [new file with mode: 0644]
libhb/encvorbis.c
libhb/encx264.c
libhb/fifo.c
libhb/hb.c
libhb/hb.h
libhb/hbffmpeg.h [new file with mode: 0644]
libhb/internal.h
libhb/module.defs [new file with mode: 0644]
libhb/module.rules [new file with mode: 0644]
libhb/muxavi.c
libhb/muxcommon.c
libhb/muxmkv.c
libhb/muxmp4.c
libhb/muxogm.c
libhb/platform/macosx/encca_aac.c [new file with mode: 0644]
libhb/ports.c
libhb/ports.h
libhb/project.h.m4 [new file with mode: 0644]
libhb/reader.c
libhb/render.c
libhb/scan.c
libhb/stream.c [changed mode: 0755->0644]
libhb/sync.c
libhb/update.c
libhb/work.c
macosx/ChapterTitles.h
macosx/ChapterTitles.m
macosx/Controller.h
macosx/Controller.m [new file with mode: 0644]
macosx/English.lproj/AdvancedView.xib
macosx/English.lproj/MainMenu.xib
macosx/English.lproj/OutputPanel.xib
macosx/English.lproj/PicturePreview.xib [new file with mode: 0644]
macosx/English.lproj/PictureSettings.xib
macosx/English.lproj/Preferences.xib
macosx/Growl.framework/Versions/A/Growl
macosx/Growl.framework/Versions/A/Headers/GrowlApplicationBridge-Carbon.h
macosx/Growl.framework/Versions/A/Headers/GrowlApplicationBridge.h
macosx/Growl.framework/Versions/A/Headers/GrowlDefines.h
macosx/Growl.framework/Versions/A/Resources/Info.plist
macosx/HBAdvancedController.h
macosx/HBAdvancedController.m
macosx/HBDVDDetector.m
macosx/HBImageAndTextCell.m
macosx/HBOutputPanelController.m
macosx/HBPreferencesController.m
macosx/HBPresets.h
macosx/HBPresets.m
macosx/HBPreviewController.h [new file with mode: 0644]
macosx/HBPreviewController.m [new file with mode: 0644]
macosx/HBQueueController.mm
macosx/HBSubtitles.h [new file with mode: 0644]
macosx/HBSubtitles.m [new file with mode: 0644]
macosx/HandBrake-64.icns [new file with mode: 0644]
macosx/HandBrake.xcodeproj/project.pbxproj
macosx/Info.h.m4 [new file with mode: 0644]
macosx/Info.plist [new file with mode: 0644]
macosx/PictureController.h
macosx/PictureController.m [new file with mode: 0644]
macosx/Sparkle.disable.security.patch [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Headers/SUAppcast.h
macosx/Sparkle.framework/Versions/A/Headers/SUAppcastItem.h
macosx/Sparkle.framework/Versions/A/Headers/SUUpdater.h
macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol copy.h [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol.h [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Headers/Sparkle.h
macosx/Sparkle.framework/Versions/A/Resources/Info.plist
macosx/Sparkle.framework/Versions/A/Resources/License.txt [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Resources/SUModelTranslation.plist [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Resources/SUStatus.nib/classes.nib
macosx/Sparkle.framework/Versions/A/Resources/SUStatus.nib/info.nib
macosx/Sparkle.framework/Versions/A/Resources/SUStatus.nib/keyedobjects.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/classes.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/info.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/classes.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/info.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/keyedobjects.nib
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/classes.nib [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/info.nib [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib [new file with mode: 0644]
macosx/Sparkle.framework/Versions/A/Resources/en.lproj/Sparkle.strings
macosx/Sparkle.framework/Versions/A/Resources/fr_CA.lproj [new symlink]
macosx/Sparkle.framework/Versions/A/Resources/relaunch [new file with mode: 0755]
macosx/Sparkle.framework/Versions/A/Sparkle
macosx/icons/Brushed_Window.png [new file with mode: 0644]
macosx/module.defs [new file with mode: 0644]
macosx/module.rules [new file with mode: 0644]
macosx/module.xcode [new file with mode: 0644]
make/config.guess [new file with mode: 0755]
make/configure.py [new file with mode: 0644]
make/include/base.defs [new file with mode: 0644]
make/include/base.rules [new file with mode: 0644]
make/include/contrib.defs [new file with mode: 0644]
make/include/function.defs [new file with mode: 0644]
make/include/gcc.defs [new file with mode: 0644]
make/include/main.defs [new file with mode: 0644]
make/include/main.rules [new file with mode: 0644]
make/include/report.defs [new file with mode: 0644]
make/include/select.defs [new file with mode: 0644]
make/include/target.defs [new file with mode: 0644]
make/include/tool.defs [new file with mode: 0644]
make/test/build.matrix.darwin [new file with mode: 0755]
make/variant/cygwin.defs [new file with mode: 0644]
make/variant/darwin.defs [new file with mode: 0644]
make/variant/darwin.rules [new file with mode: 0644]
make/variant/darwin.x86_64.defs [new file with mode: 0644]
make/variant/freebsd.defs [new file with mode: 0644]
make/variant/linux.defs [new file with mode: 0644]
make/variant/mingw.defs [new file with mode: 0644]
make/variant/solaris.defs [new file with mode: 0644]
make/xcodemake [new file with mode: 0755]
pkg/appcast.xml.m4 [new file with mode: 0644]
pkg/darwin/module.defs [new file with mode: 0644]
pkg/darwin/module.rules [new file with mode: 0644]
pkg/linux/debian/README.Debian [new file with mode: 0644]
pkg/linux/debian/changelog [new file with mode: 0644]
pkg/linux/debian/compat [new file with mode: 0644]
pkg/linux/debian/control [new file with mode: 0644]
pkg/linux/debian/copyright [new file with mode: 0644]
pkg/linux/debian/docs [new file with mode: 0644]
pkg/linux/debian/handbrake-cli.dirs [new file with mode: 0644]
pkg/linux/debian/handbrake-cli.install [new file with mode: 0644]
pkg/linux/debian/handbrake-gtk.dirs [new file with mode: 0644]
pkg/linux/debian/handbrake-gtk.docs [new file with mode: 0644]
pkg/linux/debian/handbrake-gtk.install [new file with mode: 0644]
pkg/linux/debian/rules [new file with mode: 0755]
pkg/linux/module.defs [new file with mode: 0644]
pkg/linux/module.rules [new file with mode: 0644]
pkg/module.defs [new file with mode: 0644]
pkg/module.rules [new file with mode: 0644]
scripts/manicure.rb
test/module.defs [new file with mode: 0644]
test/module.rules [new file with mode: 0644]
test/parsecsv.c
test/test.c
win/C#/Changelog.html [new file with mode: 0644]
win/C#/Controls/AudioPanel.Designer.cs [new file with mode: 0644]
win/C#/Controls/AudioPanel.cs [new file with mode: 0644]
win/C#/Controls/AudioPanel.resx [new file with mode: 0644]
win/C#/Controls/Filters.Designer.cs [new file with mode: 0644]
win/C#/Controls/Filters.cs [new file with mode: 0644]
win/C#/Controls/Filters.resx [new file with mode: 0644]
win/C#/Controls/PictureSettings.Designer.cs [new file with mode: 0644]
win/C#/Controls/PictureSettings.cs [new file with mode: 0644]
win/C#/Controls/PictureSettings.resx [new file with mode: 0644]
win/C#/Controls/Subtitles.Designer.cs [new file with mode: 0644]
win/C#/Controls/Subtitles.cs [new file with mode: 0644]
win/C#/Controls/Subtitles.resx [new file with mode: 0644]
win/C#/Controls/x264Panel.Designer.cs [new file with mode: 0644]
win/C#/Controls/x264Panel.cs [new file with mode: 0644]
win/C#/Controls/x264Panel.resx [new file with mode: 0644]
win/C#/EncodeQueue/EncodeAndQueueHandler.cs [new file with mode: 0644]
win/C#/EncodeQueue/Job.cs [new file with mode: 0644]
win/C#/Functions/AppcastReader.cs
win/C#/Functions/GrowlCommunicator.cs [new file with mode: 0644]
win/C#/Functions/Main.cs
win/C#/Functions/PresetLoader.cs [new file with mode: 0644]
win/C#/Functions/QueryGenerator.cs [new file with mode: 0644]
win/C#/Functions/QueryParser.cs
win/C#/Functions/UpdateCheckInformation.cs [new file with mode: 0644]
win/C#/Functions/Win32.cs [new file with mode: 0644]
win/C#/HandBrakeCS.csproj
win/C#/Installer/Installer.nsi
win/C#/Parsing/AudioTrack.cs
win/C#/Parsing/Chapter.cs
win/C#/Parsing/DVD.cs
win/C#/Parsing/Parser.cs
win/C#/Parsing/Subtitle.cs
win/C#/Parsing/Title.cs
win/C#/Presets/Import.cs [new file with mode: 0644]
win/C#/Presets/PresetsHandler.cs
win/C#/Presets/preset.cs
win/C#/Program.cs
win/C#/Properties/AssemblyInfo.cs
win/C#/Properties/Resources.Designer.cs
win/C#/Properties/Resources.resx
win/C#/Properties/Settings.Designer.cs
win/C#/Properties/Settings.settings
win/C#/Resources/AddToQueue_small.png [new file with mode: 0644]
win/C#/Resources/Play_small.png [new file with mode: 0644]
win/C#/Resources/SplashScreen.jpg
win/C#/Resources/picture.png [new file with mode: 0644]
win/C#/Resources/window.png [new file with mode: 0644]
win/C#/app.config
win/C#/frmAbout.Designer.cs
win/C#/frmAbout.cs
win/C#/frmActivityWindow.Designer.cs
win/C#/frmActivityWindow.cs
win/C#/frmActivityWindow.resx
win/C#/frmAddPreset.Designer.cs
win/C#/frmAddPreset.cs
win/C#/frmAddPreset.resx
win/C#/frmDownload.Designer.cs
win/C#/frmDownload.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs
win/C#/frmMain.resx
win/C#/frmOptions.Designer.cs
win/C#/frmOptions.cs
win/C#/frmOptions.resx
win/C#/frmPreview.Designer.cs [new file with mode: 0644]
win/C#/frmPreview.cs [new file with mode: 0644]
win/C#/frmPreview.resx [new file with mode: 0644]
win/C#/frmQueue.Designer.cs
win/C#/frmQueue.cs
win/C#/frmQueue.resx
win/C#/frmSplashScreen.Designer.cs
win/C#/frmSplashScreen.cs
win/C#/frmUpdater.Designer.cs
win/C#/frmUpdater.cs
win/C#/libraries/Growl.Connector.dll [new file with mode: 0644]
win/C#/libraries/Growl.CoreLibrary.dll [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index 3352092..5568f1d 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -20,12 +20,20 @@ Laurent Aimar <fenrir@via.ecp.fr>
  + Gtk2 interface
  + wxWidgets interface
 
+Van Jacobson <vanj.hb@gmail.com> (van)
+ + Universal input architecture
+ + MPEG Standard Target Decoder timing model
+ + Auto-typing MPEG stream files
+ + Minor bug fixing in MPEG stream support
+ + Minor dvd reader fixes
+ + Chapter mark bug fixes
+
 John Allen (?) <johnallenemail@gmail.com> (johnallen)
  + Core enhancements
  + Threading enhancements
  + Simplified Mac OS X GUI
 
-Joe Crain <joe@dynaflashtech.net> (dynaflash)
+Joe Crain <dynaflashtech@gmail.com> (dynaflash)
  + Mac OS X GUI enhancements/rewrite
 
 Damiano Galassi <damiog@gmail.com> (ritsuka)
@@ -80,10 +88,15 @@ Jonathon Rubin <jb.rubin@gmail.com> (jbrjake)
  + Massive core enhancements
  + Significant improvements to H.264 support
 
-Scott <sr55ww@googlemail.com> (sr55)
+Scott <unknown> (s55)
  + Windows GUI
- + Windows CLI port
-
+John Stebbins <jstebbins.hb@gmail.com> (j45)
+ + GTK GUI
+ + TrueHD demuxing
+ + libavcodec video encoding quality enhancements
+ + Numerous bug fixes
 Chris Thoman <cthoman@gmail.com> (huevos_rancheros)
  + Ported video filters from libmpcodec
 
@@ -91,8 +104,5 @@ Mark Krenek <markkrenek@mac.com> (travistex)
  + Mac OS X GUI enhancements
  + Mac OS X GUI Queueing system
 
-Van Jacobson <vanj.hb@gmail.com> (van)
- + Auto-typing MPEG stream files
- + Minor bug fixing in MPEG stream support
- + Minor dvd reader fixes
- + Chapter mark bug fixes
+Kona 'mike' Blend <Kona8lend@gmail.com> (KonaBlend)
+ + Build System and related guides
diff --git a/NEWS b/NEWS
index e3c750d..ed7b57d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,134 @@
 NEWS file for HandBrake <http://handbrake.fr/>
 
+Changes between 0.9.3 and 0.9.4:
+
+Core:
+
+* New build system, allowing 64-bit binaries (around 10% faster)
+* Soft subtitles and Closed Captions:
+  - DVD Closed Captions
+  - ATSC Closed Captions
+  - SRT subtitle import
+  - Text soft subtitles in MP4 and MKV output
+  - Bitmap soft subtitles in MKV output
+* Better support for DVD inputs:
+  - Uses libdvdnav
+  - DVD angles support
+  - Workaround for libdvdread malloc bomb on invalid PGC entry
+  - DVD drive region detection support in Linux
+  - Handles DVD programs with more than 16 streams
+  - No longer tries to detect and discard duplicate titles when scanning
+  - Libdvdnav patched to perform read error recovery
+  - Libdvdread patched to allow raw device access in Windows
+  - Handles poorly mastered DVDs that had the menus ripped out of them
+* Better support for non-DVD inputs:
+  - Preserves MP4 metadata
+  - TrueHD
+  - DTS-HD demuxing
+  - 8 bit audio
+  - Better handling of transport streams where audio starts first
+  - Better handling of transport streams that have been spliced together, leading to duplicate timestamps
+  - Better VC-1 frame detection
+  - Fixes bug that was causing one sec. of audio to be dropped on many ffmpeg files
+  - Looks harder for aspect ratio info from DV sources
+  - No longer truncates the last (dummy) chapter
+  - Allows specifying field parity for detelecine and decomb
+* Better AV sync
+* Support for sources with no audio
+* DTS passthrough for MKV
+* x264 bumped from r1169 to r1347, which means speed optimizations, new default settings (see r2742 commit comment), the magic of macroblock tree rate control (mbtree), a new CRF curve (meaning you will get different, generally lower bitrates at the same RF, with similar quality metrics), and weighted P-Frames (disabled by default for Baseline encodes and the AppleTV preset). 
+* Better sample interleaving
+* Better, optional deinterlacer for decomb (EEDI2)
+* New mode structure for the decomb filter
+* Variable verbose logging levels
+* Fixed timing for first two frames coming out of filters
+* Libtheora bumped to 1.1.0
+* Improvements to our theora implementation (2 pass encoding + soft target rate control)
+* Caters to Theora's insistence on content having mod16 framing dimensions specified
+* Flushes LAME encoder's final packets
+* Fixed interjob framerate calculation
+* Fixed pthreads regression in cygwin
+* Tweaks for packaging tools
+* Solaris 10 build support
+
+All interfaces:
+
+* Live video preview
+* New subtitle tab
+* New filters and picture settings inspector
+* Custom anamorphic mode
+* Updated Sparkle
+* Custom number of preview images
+* Quality slider now works off actual rate factor/quantizer values instead of percentages
+* Partially updated advanced x264 tab
+* New built-in presets
+* Use libdvdnav by default on DVD sources
+* Removed Constant QP encoding option for x264 (use CRF)
+* Various bug fixes and UI tweaks
+* x264 turbo 1st pass mode now uses subme=2 not subme=1
+
+Mac:
+
+* Core Audio AAC encoding
+* H.264 video source decoding crash fixed
+* Queue displays varying row heights based on encode settings
+* Fixed EyeTV package scanning
+* 64bit / 32 bit VLC detection 
+* Preset import/export
+
+Windows:
+
+* New audio tab
+* AAC audio source decoding bug fixed
+* Tray minimization is now optional
+* Queue can now be started from main window
+* Growl for Windows notification support
+* General UI improvements
+* Preset import
+* Preferred language control for audio dubs and subtitles
+* Fixed file extensions resetting to m4v when enabling chapter markers in mkv
+* Faster updating of GUI elements from CLI data
+* Cleanup / Improved some of the programs options. (Growl, use m4v, drive detection)
+* Numerous fixes in the Picture Settings Panel and CLI Query Handling code.
+* Bug Fixes and Usability improvements.
+
+Linux:
+
+* General UI improvements
+* Inhibits sleep mode while encoding
+* Single title scan
+* Chapter duration display
+* Notifications when encodes complete
+* Tray minimization
+* Full screen preview
+* Preset import/export
+* Preferred language control for audio dubs and subtitles
+* Preferences rearrangement
+* Preference to auto-apply .m4v extension
+* New system tray icon behavior
+* Preference for what to do when encode completes
+* Preference for how often to delete activity logs
+* Preference to disable automatic scanning
+* New Gnome session manager support
+* Improved "auto" audio selection
+* Use .m4v as the default extension for the MPEG-4 container
+* Use .m4v when soft subs are enabled
+* Alternate angle encoding fix
+* Only strips drive letters for Windows builds
+* Show correct audio format info when it's been sanitized for incompatibilities
+* Preserve chapter list modifications made to queued jobs
+* Fixed error when navigating chapter titles with the keyboard
+* Bug Fixes.
+
+CLI:
+
+* Options to handle new subtitle, anamorphic, and preview features
+* --srt-file, --srt-codeset, --srt-offset, --srt-lang, --srt-default
+* --native-dub option lets users request dubbing instead of subs when the audio isn't in their native language
+* Allow encoding sources with no audio without explicitly stating -a none
+* Update checker on MinGW built exe should now work correctly.
+* Matches GUIs' default verbosity level of 1
+
 Changes between 0.9.2 and 0.9.3:
 
 0.9.3 Snapshot 5 -> 0.9.3 Final
index 224b2b2..09c80b7 100755 (executable)
--- a/configure
+++ b/configure
 #! /bin/sh
+#
 
-CC="gcc"
-CXX="g++"
-CCFLAGS="$CCFLAGS -Wall -g"
-OPTIM="$OPTIM -O3 -funroll-loops"
-LINKLIBS="-lz -lbz2"
-MAKE=make
-
-# System-specific flags
-SYSTEM=`uname -s`
-case $SYSTEM in
-  BeOS)
-    CCFLAGS="$CCFLAGS -Wno-multichar"
-    DEFINES="$DEFINES SYS_BEOS"
-    LINKLIBS="$LINKLIBS -lbe -ltracker"
-
-    RELEASE=`uname -r`
-    case $RELEASE in
-      6.0|5.0.4) # Zeta or R5 / BONE beta 7
-        SYSTEM="$SYSTEM / BONE"
-        LINKLIBS="$LINKLIBS -lbind -lsocket"
-        ;;
-      5.0*)      # R5 / net_server
-        SYSTEM="$SYSTEM / net_server"
-        DEFINES="$DEFINES BEOS_NETSERVER"
-        LINKLIBS="$LINKLIBS -lnet"
-        ;;
-      *)
-        echo "Unsupported BeOS version"
-        exit 1 ;;
-    esac
-    ;;
-
-  Darwin)
-    DEFINES="$DEFINES SYS_DARWIN USE_PTHREAD"
-    LINKLIBS="$LINKLIBS -lpthread"
-    ;;
-
-  FreeBSD)
-    DEFINES="$DEFINES SYS_FREEBSD USE_PTHREAD"
-    LINKLIBS="$LINKLIBS -pthread"
-    ;;
-
-  NetBSD)
-    DEFINES="$DEFINES SYS_NETBSD USE_PTHREAD"
-    LINKLIBS="$LINKLIBS -lpthread"
-    ;;
-
-  Linux)
-    DEFINES="$DEFINES SYS_LINUX USE_PTHREAD _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64"
-    LINKLIBS="$LINKLIBS -lpthread -ldl"
-    ;;
-
-  CYGWIN*)
-    DEFINES="$DEFINES SYS_CYGWIN USE_PTHREAD"
-    LINKLIBS="$LINKLIBS -lpthread"
-    ;;
-  SunOS)
-    DEFINES="$DEFINES SYS_SunOS USE_PTHREAD _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64"
-    LINKLIBS="$LINKLIBS -lpthread -lsocket -lnsl"
-    ;;
-
-  *)
-    echo "Unsupported operating system"
-    exit 1 ;;
-esac
-echo
-echo "System: $SYSTEM"
-
-# Check for endianness (we need to define WORDS_BIGENDIAN for libdvdread)
-cat > testconf.c << EOF
-int main()
+inpath()
 {
-    int i = 1;
-    return *( (char *) &i );
+    IFS=:
+    for d in $PATH
+    do
+        if [ -x $d/$1 ]; then
+            return 0
+        fi
+    done
+    return 1
 }
-EOF
-if ( $CC -o testconf testconf.c && ./testconf ) > /dev/null 2>&1
-then
-  echo "Endian: big"
-  DEFINES="$DEFINES WORDS_BIGENDIAN"
-else
-  echo "Endian: little"
-fi
-rm -f testconf.c testconf
-
-#
-# Use Gnu make when available over the built in make
-#
-if ( make --version | grep GNU ) > /dev/null 2>&1
-then
-MAKE=make
-elif ( gmake --version | grep GNU ) > /dev/null 2>&1
-then
-MAKE=gmake
-else
-MAKE=make
-fi
-
-# Unless the user wants a release build, configure for SVN snapshots
-if test "$1" = "--release" || test "$2" = "--release"; then
-    SNAPSHOT=0
-else
-    SNAPSHOT=1
-fi
-
-# We fought the law and the law won
-if test "$1" = "--libdvdcss" || test "$2" = "--libdvdcss"; then
-    CSS=1
-else
-    CSS=0
-fi
-
-# Generating the HB_BUILD and HB_VERSION for snapshots requires
-# the build date, working path, and current SVN revision. 
-BUILD_DATE=`date +%Y%m%d`
-FULL_PATH=`pwd`
-SVN_REV=`svnversion`
 
-# Generate config.jam
-rm -f config.jam
-cat << EOF > config.jam
-CC       = $CC ;
-C++      = $CXX ;
-LINK     = $CXX ;
-CCFLAGS  = $CCFLAGS ;
-C++FLAGS = $CCFLAGS ;
-OPTIM    = $OPTIM ;
-DEFINES  = $DEFINES ;
-LINKLIBS = $LINKLIBS ;
-MAKE     = $MAKE ;
-SNAPSHOT = $SNAPSHOT ;
-BUILD_DATE = $BUILD_DATE ;
-FULL_PATH = $FULL_PATH ;
-SVN_REV = $SVN_REV ;
-CSS      = $CSS ;
-EOF
+for p in python2.7 python2.6 python2.5 python2.4 python2 python
+do
+    if ( inpath $p ); then
+        exec $p `dirname $0`/make/configure.py "$@"
+        exit 0
+    fi
+done
 
-echo
-echo "Don't run configure by hand, make runs it automatically."
-echo
-echo "No, really. That's it. Just type 'make' and hit return."
-echo
-echo "You're supposed to be building with make, not jam."
-echo "If you were going to use jam--which you shouldn't--you'd run:"
-echo " './jam' on a Mac, or"
-echo " 'jam' on Linux or Windows"
-echo
-echo "To make jam, boil fruit with sugar and an acid until pectins are released."
-echo
+echo "ERROR: no suitable version of python found."
+exit 1
diff --git a/contrib/a52dec/A00-dpl2.patch b/contrib/a52dec/A00-dpl2.patch
new file mode 100644 (file)
index 0000000..cf1c8a6
--- /dev/null
@@ -0,0 +1,114 @@
+diff -Naur a52dec_original/include/a52.h a52dec_patched/include/a52.h
+--- a52dec_original/include/a52.h      2002-01-28 05:37:54.000000000 +0000
++++ a52dec_patched/include/a52.h       2007-04-04 19:12:57.000000000 +0100
+@@ -48,6 +48,10 @@
+ #define A52_LFE 16
+ #define A52_ADJUST_LEVEL 32
++// this next constant can be ORed with A52_DOLBY to tell liba52 to use 5.0 DPLII matrix encoding,
++// rather than just 4.0 Dolby Surround matrix encoding
++#define A52_USE_DPLII 64
++
+ a52_state_t * a52_init (uint32_t mm_accel);
+ sample_t * a52_samples (a52_state_t * state);
+ int a52_syncinfo (uint8_t * buf, int * flags,
+diff -Naur a52dec_original/liba52/a52_internal.h a52dec_patched/liba52/a52_internal.h
+--- a52dec_original/liba52/a52_internal.h      2002-07-28 02:52:06.000000000 +0100
++++ a52dec_patched/liba52/a52_internal.h       2007-04-04 19:11:43.000000000 +0100
+@@ -93,6 +93,10 @@
+ #define LEVEL_45DB 0.5946035575013605
+ #define LEVEL_6DB 0.5
++// these next two constants are used for DPL matrix encoding in downmix.c
++#define LEVEL_SQRT_1_2 0.5
++#define LEVEL_SQRT_3_4 0.8660254037844386
++
+ #define EXP_REUSE (0)
+ #define EXP_D15   (1)
+ #define EXP_D25   (2)
+diff -Naur a52dec_original/liba52/downmix.c a52dec_patched/liba52/downmix.c
+--- a52dec_original/liba52/downmix.c   2002-01-28 05:37:54.000000000 +0000
++++ a52dec_patched/liba52/downmix.c    2007-04-06 13:47:49.000000000 +0100
+@@ -34,6 +34,7 @@
+ int a52_downmix_init (int input, int flags, sample_t * level,
+                     sample_t clev, sample_t slev)
+ {
++
+     static uint8_t table[11][8] = {
+       {A52_CHANNEL,   A52_DOLBY,      A52_STEREO,     A52_STEREO,
+        A52_STEREO,    A52_STEREO,     A52_STEREO,     A52_STEREO},
+@@ -148,6 +149,9 @@
+           break;
+       }
++      // add the DPLII flag back into the output if it was passed in
++      output = output | (flags & A52_USE_DPLII);
++
+     return output;
+ }
+@@ -418,17 +422,46 @@
+     }
+ }
+-static void mix32toS (sample_t * samples, sample_t bias)
++static void mix32toS (sample_t * samples, sample_t bias, int use_dpl2)
+ {
+-    int i;
+-    sample_t common, surround;
+-    for (i = 0; i < 256; i++) {
+-      common = samples[i + 256] + bias;
+-      surround = samples[i + 768] + samples[i + 1024];
+-      samples[i] += common - surround;
+-      samples[i + 256] = samples[i + 512] + common + surround;
+-    }
++      if (use_dpl2 == 1) {
++
++              int i;
++              sample_t cc, Lt, Rt, Ls, Rs, Lss, Rss;
++      
++              for (i = 0; i < 256; i++) {
++      
++                      cc = samples[i + 256] * LEVEL_3DB;
++              
++                      Lt = samples[i] + cc;
++                      Rt = samples[i + 512] + cc;
++              
++                      Ls = samples[i + 768];
++                      Rs = samples[i + 1024];
++                      
++                      Lss = (LEVEL_SQRT_3_4 * Ls) - (LEVEL_SQRT_1_2 * Rs);
++                      Rss = -(LEVEL_SQRT_1_2 * Ls) + (LEVEL_SQRT_3_4 * Rs);
++              
++                      samples[i] = bias + Lt + Lss;
++                      samples[i + 256] = bias + Rt + Rss;
++      
++              }
++
++      } else {
++
++              int i;
++              sample_t common, surround;
++      
++              for (i = 0; i < 256; i++) {
++              common = samples[i + 256] + bias;
++              surround = samples[i + 768] + samples[i + 1024];
++              samples[i] += common - surround;
++              samples[i + 256] = samples[i + 512] + common + surround;
++              }
++
++      }
++
+ }
+ static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
+@@ -533,7 +566,7 @@
+       break;
+     case CONVERT (A52_3F2R, A52_DOLBY):
+-      mix32toS (samples, bias);
++      mix32toS (samples, bias, ((output & A52_USE_DPLII) == A52_USE_DPLII));
+       break;
+     case CONVERT (A52_3F1R, A52_3F):
diff --git a/contrib/a52dec/module.defs b/contrib/a52dec/module.defs
new file mode 100644 (file)
index 0000000..470ddfa
--- /dev/null
@@ -0,0 +1,6 @@
+$(eval $(call import.MODULE.defs,A52DEC,a52dec))
+$(eval $(call import.CONTRIB.defs,A52DEC))
+
+A52DEC.FETCH.url = http://download.m0k.org/handbrake/contrib/a52dec-0.7.4.tar.gz
+A52DEC.EXTRACT.tarbase = a52dec
+A52DEC.INSTALL.strip = liba52.a
diff --git a/contrib/a52dec/module.rules b/contrib/a52dec/module.rules
new file mode 100644 (file)
index 0000000..cecab72
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,A52DEC))
+$(eval $(call import.CONTRIB.rules,A52DEC))
diff --git a/contrib/bzip2/module.defs b/contrib/bzip2/module.defs
new file mode 100644 (file)
index 0000000..8cb6d7e
--- /dev/null
@@ -0,0 +1,26 @@
+$(eval $(call import.MODULE.defs,BZIP2,bzip2))
+$(eval $(call import.CONTRIB.defs,BZIP2))
+
+BZIP2.FETCH.url = http://download.m0k.org/handbrake/contrib/bzip2-1.0.5.tar.gz
+BZIP2.EXTRACT.tarbase = bzip2
+BZIP2.CONFIGURE = $(TOUCH.exe) $@
+
+BZIP2.BUILD.extra = \
+    CC=$(BZIP2.GCC.gcc) \
+    CFLAGS="$(call fn.ARGS,BZIP2.GCC,*archs *sysroot *minver)" \
+    RANLIB="$(RANLIB.exe)"
+    PREFIX=$(call fn.ABSOLUTE,$(CONTRIB.build/))
+
+BZIP2.BUILD.ntargets = libbz2.a
+
+define BZIP2.INSTALL
+    $(CP.exe) $(BZIP2.EXTRACT.dir/)libbz2.a $(CONTRIB.build/)lib/
+    $(CP.exe) $(BZIP2.EXTRACT.dir/)bzlib.h $(CONTRIB.build/)include/
+    $(TOUCH.exe) $@
+endef
+
+define BZIP2.UNINSTALL
+    $(RM.exe) -f $(CONTRIB.build/)lib/libbz2.a
+    $(RM.exe) -f $(CONTRIB.build/)include/bzlib.h
+    $(RM.exe) -f $(BZIP2.INSTALL.target)
+endef
diff --git a/contrib/bzip2/module.rules b/contrib/bzip2/module.rules
new file mode 100644 (file)
index 0000000..456bb12
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,BZIP2))
+$(eval $(call import.CONTRIB.rules,BZIP2))
diff --git a/contrib/faac/P00-cygwin.patch b/contrib/faac/P00-cygwin.patch
new file mode 100644 (file)
index 0000000..a5da42d
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur faac-1.28.orig/include/faac.h faac-1.28/include/faac.h
+--- faac-1.28.orig/include/faac.h      2009-01-25 13:50:32.000000000 -0500
++++ faac-1.28/include/faac.h   2009-03-20 03:31:46.000000000 -0400
+@@ -50,7 +50,7 @@
+ typedef void *faacEncHandle;
+ #ifndef HAVE_INT32_T
+-typedef signed int int32_t;
++//typedef signed int int32_t;
+ #endif
+ /*
diff --git a/contrib/faac/module.defs b/contrib/faac/module.defs
new file mode 100644 (file)
index 0000000..cb8afdb
--- /dev/null
@@ -0,0 +1,9 @@
+$(eval $(call import.MODULE.defs,FAAC,faac))
+$(eval $(call import.CONTRIB.defs,FAAC))
+
+FAAC.FETCH.url = http://download.m0k.org/handbrake/contrib/faac-1.28.tar.gz
+FAAC.EXTRACT.tarbase = faac-1.28
+
+# If faac not already bootstrapped then add the following
+#FAAC.CONFIGURE.bootstrap = ./bootstrap;
+FAAC.CONFIGURE.extra     = --without-mp4v2
diff --git a/contrib/faac/module.rules b/contrib/faac/module.rules
new file mode 100644 (file)
index 0000000..5c31130
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,FAAC))
+$(eval $(call import.CONTRIB.rules,FAAC))
diff --git a/contrib/faad2/P00-mingw-types.patch b/contrib/faad2/P00-mingw-types.patch
new file mode 100644 (file)
index 0000000..3e5bba5
--- /dev/null
@@ -0,0 +1,25 @@
+diff -Naur faad2.orig/common/mp4ff/mp4ff_int_types.h faad2/common/mp4ff/mp4ff_int_types.h
+--- faad2.orig/common/mp4ff/mp4ff_int_types.h  2005-02-01 08:15:55.000000000 -0500
++++ faad2/common/mp4ff/mp4ff_int_types.h       2008-10-07 16:43:06.000000000 -0400
+@@ -1,7 +1,7 @@
+ #ifndef _MP4FF_INT_TYPES_H_
+ #define _MP4FF_INT_TYPES_H_
+-#if defined (_WIN32)
++#if defined(_WIN32) && !defined(__MINGW32__)
+ typedef char int8_t;
+ typedef unsigned char uint8_t;
+diff -Naur faad2.orig/frontend/main.c faad2/frontend/main.c
+--- faad2.orig/frontend/main.c 2007-11-01 08:33:29.000000000 -0400
++++ faad2/frontend/main.c      2008-10-07 16:55:49.000000000 -0400
+@@ -31,7 +31,9 @@
+ #ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
++#ifndef __MINGW32__
+ #define off_t __int64
++#endif
+ #else
+ #include <time.h>
+ #endif
diff --git a/contrib/faad2/P00-solaris.patch b/contrib/faad2/P00-solaris.patch
new file mode 100644 (file)
index 0000000..9239332
--- /dev/null
@@ -0,0 +1,23 @@
+diff -Naur faad2-2.7.orig/libfaad/Makefile.am faad2-2.7/libfaad/Makefile.am
+--- faad2-2.7.orig/libfaad/Makefile.am 2009-02-04 19:51:03.000000000 -0500
++++ faad2-2.7/libfaad/Makefile.am      2009-03-20 03:20:46.326379809 -0400
+@@ -1,6 +1,6 @@
+ lib_LTLIBRARIES = libfaad.la
+-AM_CFLAGS     = -iquote $(top_srcdir)/include
++AM_CFLAGS     = -I$(top_srcdir)/include
+ include_HEADERS = $(top_srcdir)/include/faad.h \
+                 $(top_srcdir)/include/neaacdec.h
+diff -Naur faad2-2.7.orig/libfaad/Makefile.in faad2-2.7/libfaad/Makefile.in
+--- faad2-2.7.orig/libfaad/Makefile.in 2009-02-10 03:36:11.000000000 -0500
++++ faad2-2.7/libfaad/Makefile.in      2009-03-20 03:20:57.702298514 -0400
+@@ -195,7 +195,7 @@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+ lib_LTLIBRARIES = libfaad.la
+-AM_CFLAGS = -iquote $(top_srcdir)/include
++AM_CFLAGS = -I$(top_srcdir)/include
+ include_HEADERS = $(top_srcdir)/include/faad.h \
+                 $(top_srcdir)/include/neaacdec.h
diff --git a/contrib/faad2/module.defs b/contrib/faad2/module.defs
new file mode 100644 (file)
index 0000000..65825eb
--- /dev/null
@@ -0,0 +1,8 @@
+$(eval $(call import.MODULE.defs,FAAD2,faad2))
+$(eval $(call import.CONTRIB.defs,FAAD2))
+
+FAAD2.FETCH.url = http://download.m0k.org/handbrake/contrib/faad2-2.7.tar.gz
+FAAD2.EXTRACT.tarbase = faad2-2.7
+
+# If faad not already bootstrapped then add the following
+#FAAD2.CONFIGURE.bootstrap = ./bootstrap;
diff --git a/contrib/faad2/module.rules b/contrib/faad2/module.rules
new file mode 100644 (file)
index 0000000..2b9bdd0
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,FAAD2))
+$(eval $(call import.CONTRIB.rules,FAAD2))
diff --git a/contrib/ffmpeg/A00-latm.patch b/contrib/ffmpeg/A00-latm.patch
new file mode 100644 (file)
index 0000000..b17c114
--- /dev/null
@@ -0,0 +1,875 @@
+diff -Naur ffmpeg-r19067.orig/libavcodec/Makefile ffmpeg-r19067/libavcodec/Makefile
+--- ffmpeg-r19067.orig/libavcodec/Makefile     2009-05-25 18:19:35.000000000 -0400
++++ ffmpeg-r19067/libavcodec/Makefile  2009-06-01 12:39:48.000000000 -0400
+@@ -382,7 +382,7 @@
+ OBJS-$(CONFIG_LIBDIRAC_DECODER)        += libdiracdec.o
+ OBJS-$(CONFIG_LIBDIRAC_ENCODER)        += libdiracenc.o libdirac_libschro.o
+ OBJS-$(CONFIG_LIBFAAC)                 += libfaac.o
+-OBJS-$(CONFIG_LIBFAAD)                 += libfaad.o
++OBJS-$(CONFIG_LIBFAAD)                 += libfaad.o latmaac.o
+ OBJS-$(CONFIG_LIBGSM)                  += libgsm.o
+ OBJS-$(CONFIG_LIBMP3LAME)              += libmp3lame.o
+ OBJS-$(CONFIG_LIBOPENJPEG)             += libopenjpeg.o
+@@ -395,7 +395,7 @@
+ OBJS-$(CONFIG_LIBXVID)                 += libxvidff.o libxvid_rc.o
+ # parsers
+-OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o mpeg4audio.o
++OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o mpeg4audio.o latm_parser.o
+ OBJS-$(CONFIG_AC3_PARSER)              += ac3_parser.o ac3tab.o aac_ac3_parser.o
+ OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
+ OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
+diff -Naur ffmpeg-r19067.orig/libavcodec/allcodecs.c ffmpeg-r19067/libavcodec/allcodecs.c
+--- ffmpeg-r19067.orig/libavcodec/allcodecs.c  2009-05-12 15:56:48.000000000 -0400
++++ ffmpeg-r19067/libavcodec/allcodecs.c       2009-06-01 12:39:48.000000000 -0400
+@@ -306,6 +306,7 @@
+     REGISTER_ENCDEC  (LIBDIRAC, libdirac);
+     REGISTER_ENCODER (LIBFAAC, libfaac);
+     REGISTER_DECODER (LIBFAAD, libfaad);
++    REGISTER_DECODER (LIBFAAD, libfaad2);
+     REGISTER_ENCDEC  (LIBGSM, libgsm);
+     REGISTER_ENCDEC  (LIBGSM_MS, libgsm_ms);
+     REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
+@@ -319,6 +320,7 @@
+     /* parsers */
+     REGISTER_PARSER  (AAC, aac);
++    REGISTER_PARSER  (AAC, aac_latm);
+     REGISTER_PARSER  (AC3, ac3);
+     REGISTER_PARSER  (CAVSVIDEO, cavsvideo);
+     REGISTER_PARSER  (DCA, dca);
+diff -Naur ffmpeg-r19067.orig/libavcodec/avcodec.h ffmpeg-r19067/libavcodec/avcodec.h
+--- ffmpeg-r19067.orig/libavcodec/avcodec.h    2009-05-31 02:51:18.000000000 -0400
++++ ffmpeg-r19067/libavcodec/avcodec.h 2009-06-01 12:39:48.000000000 -0400
+@@ -271,6 +271,7 @@
+     CODEC_ID_MP2= 0x15000,
+     CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
+     CODEC_ID_AAC,
++    CODEC_ID_AAC_LATM,
+     CODEC_ID_AC3,
+     CODEC_ID_DTS,
+     CODEC_ID_VORBIS,
+diff -Naur ffmpeg-r19067.orig/libavcodec/latm_parser.c ffmpeg-r19067/libavcodec/latm_parser.c
+--- ffmpeg-r19067.orig/libavcodec/latm_parser.c        1969-12-31 19:00:00.000000000 -0500
++++ ffmpeg-r19067/libavcodec/latm_parser.c     2009-06-01 12:39:48.000000000 -0400
+@@ -0,0 +1,128 @@
++/*
++ * LATM parser
++ * Copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/**
++ * @file latm_parser.c
++ * LATM parser
++ */
++
++#include "parser.h"
++
++#define LATM_HEADER     0x56e000      // 0x2b7 (11 bits)
++#define LATM_MASK       0xFFE000      // top 11 bits
++#define LATM_SIZE_MASK  0x001FFF      // bottom 13 bits
++
++typedef struct LATMParseContext{
++    ParseContext pc;
++    int count;
++} LATMParseContext;
++
++/**
++ * finds the end of the current frame in the bitstream.
++ * @return the position of the first byte of the next frame, or -1
++ */
++static int latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf,
++                               int buf_size) {
++    LATMParseContext *s = s1->priv_data;
++    ParseContext *pc = &s->pc;
++    int pic_found, i;
++    uint32_t state;
++
++    pic_found = pc->frame_start_found;
++    state = pc->state;
++
++    i = 0;
++    if(!pic_found){
++        for(i=0; i<buf_size; i++){
++            state = (state<<8) | buf[i];
++            if((state & LATM_MASK) == LATM_HEADER){
++                i++;
++                s->count = - i;
++                pic_found=1;
++                break;
++            }
++        }
++    }
++
++    if(pic_found){
++        /* EOF considered as end of frame */
++        if (buf_size == 0)
++            return 0;
++        if((state & LATM_SIZE_MASK) - s->count <= buf_size) {
++            pc->frame_start_found = 0;
++            pc->state = -1;
++            return (state & LATM_SIZE_MASK) - s->count;
++      }
++    }
++
++    s->count += buf_size;
++    pc->frame_start_found = pic_found;
++    pc->state = state;
++    return END_NOT_FOUND;
++}
++
++static int latm_parse(AVCodecParserContext *s1,
++                           AVCodecContext *avctx,
++                           const uint8_t **poutbuf, int *poutbuf_size,
++                           const uint8_t *buf, int buf_size)
++{
++    LATMParseContext *s = s1->priv_data;
++    ParseContext *pc = &s->pc;
++    int next;
++
++    if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){
++        next = buf_size;
++    }else{
++        next = latm_find_frame_end(s1, buf, buf_size);
++
++        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
++            *poutbuf = NULL;
++            *poutbuf_size = 0;
++            return buf_size;
++        }
++    }
++    *poutbuf = buf;
++    *poutbuf_size = buf_size;
++    return next;
++}
++
++static int latm_split(AVCodecContext *avctx,
++                           const uint8_t *buf, int buf_size)
++{
++    int i;
++    uint32_t state= -1;
++
++    for(i=0; i<buf_size; i++){
++        state= (state<<8) | buf[i];
++        if((state & LATM_MASK) == LATM_HEADER)
++            return i-2;
++    }
++    return 0;
++}
++
++AVCodecParser aac_latm_parser = {
++    { CODEC_ID_AAC_LATM },
++    sizeof(LATMParseContext),
++    NULL,
++    latm_parse,
++    ff_parse_close,
++    latm_split,
++};
+diff -Naur ffmpeg-r19067.orig/libavcodec/latmaac.c ffmpeg-r19067/libavcodec/latmaac.c
+--- ffmpeg-r19067.orig/libavcodec/latmaac.c    1969-12-31 19:00:00.000000000 -0500
++++ ffmpeg-r19067/libavcodec/latmaac.c 2009-06-01 12:39:48.000000000 -0400
+@@ -0,0 +1,624 @@
++/*
++ * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/**
++ * @file latmaac.c
++ * LATM wrapped AAC decoder
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <math.h>
++#include <sys/types.h>
++
++#include "parser.h"
++#include "get_bits.h"
++#include "put_bits.h"
++#include "mpeg4audio.h"
++#include "neaacdec.h"
++
++#define min(a,b) ((a)<(b) ? (a) : (b))
++
++
++/*
++    Note: This decoder filter is intended to decode LATM streams transferred
++    in MPEG transport streams which are only supposed to contain one program.
++    To do a more complex LATM demuxing a separate LATM demuxer should be used.
++*/
++
++#define AAC_NONE 0            // mode not detected (or indicated in mediatype)
++#define AAC_LATM 1            // LATM packets (ISO/IEC 14496-3  1.7.3 Multiplex layer)
++
++#define SYNC_LATM 0x2b7            // 11 bits
++
++#define MAX_SIZE 8*1024
++
++typedef struct AACConfig
++{
++    uint8_t    extra[64];            // should be way enough
++    int        extrasize;
++
++    int        audioObjectType;
++    int        samplingFrequencyIndex;
++    int        samplingFrequency;
++    int        channelConfiguration;
++    int        channels;
++} AACConfig;
++
++typedef struct AACParser
++{
++    AACConfig          config;
++    uint8_t            frameLengthType;
++    uint16_t           muxSlotLengthBytes;
++
++    uint8_t            audio_mux_version;
++    uint8_t            audio_mux_version_A;
++    int                taraFullness;
++    uint8_t            config_crc;
++    int64_t            other_data_bits;
++
++    int                mode;
++    int                offset;        // byte offset in "buf" buffer
++    uint8_t            buf[MAX_SIZE]; // allocated buffer
++    int                count;         // number of bytes written in buffer
++} AACParser;
++
++typedef struct AACDecoder 
++{
++    AACParser          *parser;
++    faacDecHandle      aac_decoder;
++    int                open;
++    uint32_t           in_samplerate;
++    uint8_t            in_channels;
++} AACDecoder;
++
++typedef struct {
++    AACDecoder*        decoder;
++} FAACContext;
++
++static inline int64_t latm_get_value(GetBitContext *b)
++{
++    uint8_t bytesForValue = get_bits(b, 2);
++    int64_t value = 0;
++    int i;
++    for (i=0; i<=bytesForValue; i++) {
++        value <<= 8;
++        value |= get_bits(b, 8);
++    }
++    return value;
++}
++
++static void readGASpecificConfig(struct AACConfig *cfg, GetBitContext *b, PutBitContext *o)
++{
++    int framelen_flag = get_bits(b, 1);
++    put_bits(o, 1, framelen_flag);
++    int dependsOnCoder = get_bits(b, 1);
++    put_bits(o, 1, dependsOnCoder);
++    int ext_flag;
++    int delay;
++    int layerNr;
++
++    if (dependsOnCoder) {
++        delay = get_bits(b, 14);
++        put_bits(o, 14, delay);
++    }
++    ext_flag = get_bits(b, 1);
++    put_bits(o, 1, ext_flag);
++    if (!cfg->channelConfiguration) {
++        // program config element
++        // TODO:
++    }
++
++    if (cfg->audioObjectType == 6 || cfg->audioObjectType == 20) {
++        layerNr = get_bits(b, 3);
++        put_bits(o, 3, layerNr);
++    }
++    if (ext_flag) {
++        if (cfg->audioObjectType == 22) {
++            skip_bits(b, 5);                    // numOfSubFrame
++            skip_bits(b, 11);                    // layer_length
++
++            put_bits(o, 16, 0);
++        }
++        if (cfg->audioObjectType == 17 ||
++            cfg->audioObjectType == 19 ||
++            cfg->audioObjectType == 20 ||
++            cfg->audioObjectType == 23) {
++
++            skip_bits(b, 3);                    // stuff
++            put_bits(o, 3, 0);
++        }
++
++        skip_bits(b, 1);                        // extflag3
++        put_bits(o, 1, 0);
++    }
++}
++
++static int readAudioSpecificConfig(struct AACConfig *cfg, GetBitContext *b)
++{
++    PutBitContext o;
++    init_put_bits(&o, cfg->extra, sizeof(cfg->extra));
++
++    // returns the number of bits read
++    int ret = 0;
++    int sbr_present = -1;
++
++    // object
++    cfg->audioObjectType = get_bits(b, 5);
++        put_bits(&o, 5, cfg->audioObjectType);
++    if (cfg->audioObjectType == 31) {
++        uint8_t n = get_bits(b, 6);
++        put_bits(&o, 6, n);
++        cfg->audioObjectType = 32 + n;
++    }
++
++    cfg->samplingFrequencyIndex = get_bits(b, 4);
++    cfg->samplingFrequency = ff_mpeg4audio_sample_rates[cfg->samplingFrequencyIndex];
++    put_bits(&o, 4, cfg->samplingFrequencyIndex);
++    if (cfg->samplingFrequencyIndex == 0x0f) {
++        uint32_t f = get_bits_long(b, 24);
++        put_bits(&o, 24, f);
++        cfg->samplingFrequency = f;
++    }
++    cfg->channelConfiguration = get_bits(b, 4);
++    put_bits(&o, 4, cfg->channelConfiguration);
++    cfg->channels = ff_mpeg4audio_channels[cfg->channelConfiguration];
++
++    if (cfg->audioObjectType == 5) {
++        sbr_present = 1;
++
++        // TODO: parsing !!!!!!!!!!!!!!!!
++    }
++
++    switch (cfg->audioObjectType) {
++    case 1:
++    case 2:
++    case 3:
++    case 4:
++    case 6:
++    case 7:
++    case 17:
++    case 19:
++    case 20:
++    case 21:
++    case 22:
++    case 23:
++        readGASpecificConfig(cfg, b, &o);
++        break;
++    }
++
++    if (sbr_present == -1) {
++        if (cfg->samplingFrequency <= 24000) {
++            cfg->samplingFrequency *= 2;
++        }            
++    }
++
++    // count the extradata
++    ret = put_bits_count(&o);
++    align_put_bits(&o);
++    flush_put_bits(&o);
++    cfg->extrasize = (ret + 7) >> 3;
++    return ret;
++}
++
++static void readStreamMuxConfig(struct AACParser *parser, GetBitContext *b)
++{
++    parser->audio_mux_version_A = 0;
++    parser->audio_mux_version = get_bits(b, 1);
++    if (parser->audio_mux_version == 1) {                // audioMuxVersion
++        parser->audio_mux_version_A = get_bits(b, 1);
++    }
++
++    if (parser->audio_mux_version_A == 0) {
++        if (parser->audio_mux_version == 1) {
++            parser->taraFullness = latm_get_value(b);
++        }
++        get_bits(b, 1);                    // allStreamSameTimeFraming = 1
++        get_bits(b, 6);                    // numSubFrames = 0
++        get_bits(b, 4);                    // numPrograms = 0
++
++        // for each program
++        get_bits(b, 3);                    // numLayer = 0
++
++        // for each layer
++        if (parser->audio_mux_version == 0) {
++            // audio specific config.
++            readAudioSpecificConfig(&parser->config, b);
++        } else {
++            int ascLen = latm_get_value(b);
++            ascLen -= readAudioSpecificConfig(&parser->config, b);
++
++            // fill bits
++            while (ascLen > 16) {
++                skip_bits(b, 16);
++                ascLen -= 16;
++            }
++            skip_bits(b, ascLen);                    
++        }
++
++        // these are not needed... perhaps
++        int frame_length_type = get_bits(b, 3);
++        parser->frameLengthType = frame_length_type;
++        if (frame_length_type == 0) {
++            get_bits(b, 8);
++        } else if (frame_length_type == 1) {
++            get_bits(b, 9);
++        } else if (frame_length_type == 3 ||
++            frame_length_type == 4 ||
++            frame_length_type == 5) {
++            int celp_table_index = get_bits(b, 6);
++        } else if (frame_length_type == 6 ||
++            frame_length_type == 7) {
++            int hvxc_table_index = get_bits(b, 1);
++        }
++
++        // other data
++        parser->other_data_bits = 0;
++        if (get_bits(b, 1)) {
++            // other data present
++            if (parser->audio_mux_version == 1) {
++                parser->other_data_bits = latm_get_value(b);
++            } else {
++                // other data not present
++                parser->other_data_bits = 0;
++                int esc, tmp;
++                do {
++                    parser->other_data_bits <<= 8;
++                    esc = get_bits(b, 1);
++                    tmp = get_bits(b, 8);
++                    parser->other_data_bits |= tmp;
++                } while (esc);
++            }
++        }
++
++        // CRC
++        if (get_bits(b, 1)) {
++            parser->config_crc = get_bits(b, 8);
++        }
++    } else {
++        // tbd
++    }
++}
++
++static void readPayloadLengthInfo(struct AACParser *parser, GetBitContext *b)
++{
++    uint8_t tmp;
++    if (parser->frameLengthType == 0) {
++        parser->muxSlotLengthBytes = 0;
++        do {
++            tmp = get_bits(b, 8);
++            parser->muxSlotLengthBytes += tmp;
++        } while (tmp == 255);
++    } else {
++        if (parser->frameLengthType == 5 ||
++            parser->frameLengthType == 7 ||
++            parser->frameLengthType == 3) {
++            get_bits(b, 2);
++        }
++    }
++}
++
++static void readAudioMuxElement(struct AACParser *parser, GetBitContext *b, uint8_t *payload, int *payloadsize)
++{
++    uint8_t    use_same_mux = get_bits(b, 1);
++    if (!use_same_mux) {
++        readStreamMuxConfig(parser, b);
++    }
++
++    if (parser->audio_mux_version_A == 0) {
++        int j;
++
++        readPayloadLengthInfo(parser, b);
++
++        // copy data
++        for (j=0; j<parser->muxSlotLengthBytes; j++) {
++            *payload++ = get_bits(b, 8);
++        }
++        *payloadsize = parser->muxSlotLengthBytes;
++
++        // ignore otherdata
++    } else {
++        // TBD
++    }
++}
++
++static int readAudioSyncStream(struct AACParser *parser, GetBitContext *b, int size, uint8_t *payload, int *payloadsize)
++{
++    // ISO/IEC 14496-3 Table 1.28 - Syntax of AudioMuxElement()
++    if (get_bits(b, 11) != 0x2b7) return -1;        // not LATM
++    int muxlength = get_bits(b, 13);
++
++    if (3+muxlength > size) return 0;            // not enough data
++
++    readAudioMuxElement(parser, b, payload, payloadsize);
++
++    // we don't parse anything else here...
++    return (3+muxlength);
++}
++
++
++static void flush_buf(struct AACParser *parser, int offset) {
++    int bytes_to_flush = min(parser->count, offset);
++    int left = (parser->count - bytes_to_flush);
++
++    if (bytes_to_flush > 0) {
++        if (left > 0) {
++            memcpy(parser->buf, parser->buf+bytes_to_flush, left);
++            parser->count = left;
++        } else {
++            parser->count = 0;
++        }
++    }
++}
++
++static struct AACParser *latm_create_parser()
++{
++    struct AACParser *parser = (struct AACParser *)av_malloc(sizeof(struct AACParser));
++    memset(parser, 0, sizeof(struct AACParser));
++    return parser;
++}
++
++static void latm_destroy_parser(struct AACParser *parser)
++{
++    av_free(parser);
++}
++
++static void latm_flush(struct AACParser *parser)
++{
++    parser->offset = 0;
++    parser->count = 0;
++}
++
++static void latm_write_data(struct AACParser *parser, uint8_t *data, int len)
++{
++    // buffer overflow check... just ignore the data before
++    if (parser->count + len > MAX_SIZE) {
++        flush_buf(parser, parser->offset);
++        parser->offset = 0;
++        if (parser->count + len > MAX_SIZE) {
++            int to_flush = (parser->count+len) - MAX_SIZE;
++            flush_buf(parser, to_flush);
++        }
++    }
++
++    // append data
++    memcpy(parser->buf+parser->count, data, len);
++    parser->count += len;
++}
++
++static int latm_parse_packet(struct AACParser *parser, uint8_t *data, int maxsize)
++{
++    /*
++        Return value is either number of bytes parsed or
++        -1 when failed.
++        0 = need more data.
++    */
++
++    uint8_t    *start = parser->buf + parser->offset;
++    int        bytes  = parser->count - parser->offset;
++    GetBitContext    b;
++    init_get_bits(&b, start, bytes);
++
++    if (parser->mode == AAC_LATM) {
++        int outsize = 0;
++        int    ret = readAudioSyncStream(parser, &b, bytes, data, &outsize);
++
++        if (ret < 0) return -1;
++        if (ret == 0) return 0;
++
++        // update the offset
++        parser->offset += ret;
++        return outsize;
++    }
++
++    // check for syncwords
++    while (bytes > 2) {
++        if (show_bits(&b, 11) == SYNC_LATM) {
++            // we must parse config first...
++            int outsize = 0;
++
++            // check if there is a complete packet available...
++            int ret = readAudioSyncStream(parser, &b, bytes, data, &outsize);
++            if (ret < 0) return -1;
++            if (ret == 0) return 0;
++            parser->offset += ret;
++
++            parser->mode = AAC_LATM;
++            return outsize;
++        }
++        skip_bits(&b, 8);
++        parser->offset++;
++        bytes--;
++    }
++    return 0;
++}
++
++static void aac_filter_close(AACDecoder *decoder)
++{
++    if (decoder->aac_decoder) {
++        NeAACDecClose(decoder->aac_decoder);
++        decoder->aac_decoder = NULL;
++    }
++    decoder->open = 0;
++}
++
++static int aac_decoder_open(AACDecoder *decoder)
++{
++    if (decoder->aac_decoder) return 0;
++
++    decoder->aac_decoder = NeAACDecOpen();
++    if (!decoder->aac_decoder) return -1;
++
++    // are we going to initialize from decoder specific info ?
++    if (decoder->parser->config.extrasize > 0) {
++        char ret = NeAACDecInit2(decoder->aac_decoder, (unsigned char*)decoder->parser->config.extra, decoder->parser->config.extrasize, &decoder->in_samplerate, &decoder->in_channels);
++        if (ret < 0) {
++            aac_filter_close(decoder);        // gone wrong ?
++            return -1;
++        }
++        decoder->open = 1;
++    } else {
++        // we'll open the decoder later...
++        decoder->open = 0;
++    }
++    return 0;
++}
++
++AACDecoder *aac_filter_create()
++{
++    AACDecoder *decoder = (AACDecoder *)av_malloc(sizeof(AACDecoder));
++    decoder->parser = latm_create_parser();
++    decoder->aac_decoder = NULL;
++    decoder->open = 0;
++    return (void *)decoder;
++}
++
++void aac_filter_destroy(AACDecoder *decoder)
++{
++    aac_filter_close(decoder);
++    latm_destroy_parser(decoder->parser);
++    av_free(decoder);
++}
++
++int aac_filter_receive(AACDecoder *decoder, void *out, int *out_size, uint8_t *data, int size)
++{
++    uint8_t    tempbuf[32*1024];
++    int        ret;
++    int        consumed = size;
++    int        decoded;
++    int        max_size = *out_size;
++    
++    *out_size = 0;
++
++    //-------------------------------------------------------------------------
++    // Multiplex Parsing
++    //-------------------------------------------------------------------------
++
++    latm_write_data(decoder->parser, data, size);
++
++    do {
++        ret = latm_parse_packet(decoder->parser, tempbuf, sizeof(tempbuf));
++                if (ret < 0) {
++                        latm_flush(decoder->parser);
++                        return consumed;
++                }
++        if (ret == 0) return consumed;
++
++        data = tempbuf;
++        size = ret;
++
++        //-------------------------------------------------------------------------
++        // Initialize decoder (if necessary)
++        //-------------------------------------------------------------------------
++        if (!decoder->open) {
++            aac_filter_close(decoder);
++            if (decoder->parser->mode == AAC_LATM) {
++                ret = aac_decoder_open(decoder);
++                if (ret < 0) return consumed;
++            }
++
++            if(!decoder->open) return consumed;
++        }
++
++        //-------------------------------------------------------------------------
++        // Decode samples
++        //-------------------------------------------------------------------------
++        NeAACDecFrameInfo    info;
++        void *buf = NeAACDecDecode(decoder->aac_decoder, &info, data, size);
++
++        if (buf) {
++            decoder->in_samplerate = info.samplerate;
++            decoder->in_channels = info.channels;
++
++            //---------------------------------------------------------------------
++            // Deliver decoded samples
++            //---------------------------------------------------------------------
++
++            // kram dekoduje 16-bit. my vypustame 16-bit. takze by to malo byt okej
++            decoded = info.samples * sizeof(short);
++
++            // napraskame tam sample
++            *out_size += decoded;
++            if(*out_size > max_size) {
++                av_log(NULL, AV_LOG_ERROR, "overflow!\n");
++            } else {
++                memcpy(out, buf, decoded);
++                out = (unsigned char *)out + decoded;
++            }
++        } else {
++            // need more data
++            break;
++        }
++
++    } while (1);    // decode all packets
++    return consumed;
++}
++
++void aac_filter_getinfo(AACDecoder *decoder, int *sample_rate, int *channels)
++{
++    if(!decoder->open) return;
++    *sample_rate = decoder->in_samplerate;
++    *channels = decoder->in_channels;
++}
++
++static int faac_decode_init(AVCodecContext *avctx)
++{
++    FAACContext *s = avctx->priv_data;
++    avctx->frame_size = 360;
++    avctx->sample_rate = 48000;
++    avctx->channels = 2;
++    avctx->bit_rate = 8192 * 8 * avctx->sample_rate / avctx->frame_size;
++    s->decoder = aac_filter_create();
++    return 0;
++}
++
++static int faac_decode_frame(AVCodecContext *avctx,
++                             void *data, int *data_size,
++                             AVPacket *avpkt)
++{
++    FAACContext *s = avctx->priv_data;
++    int ret;
++
++    if (s->decoder == NULL) faac_decode_init(avctx);
++    ret = aac_filter_receive(s->decoder, data, data_size, avpkt->data, avpkt->size);
++    aac_filter_getinfo(s->decoder, &(avctx->sample_rate), &(avctx->channels));
++    return ret;
++}
++
++static int faac_decode_end(AVCodecContext *avctx)
++{
++    FAACContext *s = avctx->priv_data;
++    if(s->decoder != NULL) {
++        aac_filter_destroy(s->decoder);
++    }
++    return 0;
++}
++
++AVCodec libfaad2_decoder = {
++    .name = "AAC_LATM",
++    .type = CODEC_TYPE_AUDIO,
++    .id = CODEC_ID_AAC_LATM,
++    .priv_data_size = sizeof (FAACContext),
++    .init = faac_decode_init,
++    .close = faac_decode_end,
++    .decode = faac_decode_frame,
++    .long_name = "AAC over LATM",
++};
+diff -Naur ffmpeg-r19067.orig/libavformat/mpeg.c ffmpeg-r19067/libavformat/mpeg.c
+--- ffmpeg-r19067.orig/libavformat/mpeg.c      2009-04-17 14:08:39.000000000 -0400
++++ ffmpeg-r19067/libavformat/mpeg.c   2009-06-01 12:39:48.000000000 -0400
+@@ -279,7 +279,7 @@
+     /* find matching stream */
+     if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
+           (startcode >= 0x1e0 && startcode <= 0x1ef) ||
+-          (startcode == 0x1bd) || (startcode == 0x1fd)))
++          (startcode == 0x1bd) || (startcode == 0x1fa) || (startcode == 0x1fd)))
+         goto redo;
+     if (ppos) {
+         *ppos = url_ftell(s->pb) - 4;
+@@ -446,6 +446,9 @@
+         } else if(es_type == STREAM_TYPE_AUDIO_AAC){
+             codec_id = CODEC_ID_AAC;
+             type = CODEC_TYPE_AUDIO;
++        } else if(es_type == STREAM_TYPE_AUDIO_AAC_LATM){
++            codec_id = CODEC_ID_AAC_LATM;
++            type = CODEC_TYPE_AUDIO;
+         } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){
+             codec_id = CODEC_ID_MPEG4;
+             type = CODEC_TYPE_VIDEO;
+diff -Naur ffmpeg-r19067.orig/libavformat/mpeg.h ffmpeg-r19067/libavformat/mpeg.h
+--- ffmpeg-r19067.orig/libavformat/mpeg.h      2009-01-19 10:46:40.000000000 -0500
++++ ffmpeg-r19067/libavformat/mpeg.h   2009-06-01 12:39:48.000000000 -0400
+@@ -53,6 +53,7 @@
+ #define STREAM_TYPE_PRIVATE_DATA    0x06
+ #define STREAM_TYPE_AUDIO_AAC       0x0f
+ #define STREAM_TYPE_VIDEO_MPEG4     0x10
++#define STREAM_TYPE_AUDIO_AAC_LATM  0x11
+ #define STREAM_TYPE_VIDEO_H264      0x1b
+ #define STREAM_TYPE_AUDIO_AC3       0x81
+diff -Naur ffmpeg-r19067.orig/libavformat/mpegts.c ffmpeg-r19067/libavformat/mpegts.c
+--- ffmpeg-r19067.orig/libavformat/mpegts.c    2009-05-31 04:47:40.000000000 -0400
++++ ffmpeg-r19067/libavformat/mpegts.c 2009-06-01 12:39:48.000000000 -0400
+@@ -495,6 +495,7 @@
+     { 0x04, CODEC_TYPE_AUDIO,        CODEC_ID_MP3 },
+     { 0x0f, CODEC_TYPE_AUDIO,        CODEC_ID_AAC },
+     { 0x10, CODEC_TYPE_VIDEO,      CODEC_ID_MPEG4 },
++    { 0x11, CODEC_TYPE_AUDIO,   CODEC_ID_AAC_LATM },
+     { 0x1b, CODEC_TYPE_VIDEO,       CODEC_ID_H264 },
+     { 0xd1, CODEC_TYPE_VIDEO,      CODEC_ID_DIRAC },
+     { 0xea, CODEC_TYPE_VIDEO,        CODEC_ID_VC1 },
+@@ -933,7 +934,7 @@
+                     if (pes->st->discard == AVDISCARD_ALL ||
+                         !((code >= 0x1c0 && code <= 0x1df) ||
+                           (code >= 0x1e0 && code <= 0x1ef) ||
+-                          (code == 0x1bd) || (code == 0x1fd)))
++                          (code == 0x1bd) || (code == 0x1fa) || (code == 0x1fd)))
+                         goto skip;
+                     pes->state = MPEGTS_PESHEADER_FILL;
+                     pes->total_size = AV_RB16(pes->header + 4);
+diff -Naur ffmpeg-r19067.orig/libavformat/mpegts.h ffmpeg-r19067/libavformat/mpegts.h
+--- ffmpeg-r19067.orig/libavformat/mpegts.h    2009-05-30 23:02:12.000000000 -0400
++++ ffmpeg-r19067/libavformat/mpegts.h 2009-06-01 12:39:48.000000000 -0400
+@@ -47,6 +47,7 @@
+ #define STREAM_TYPE_PRIVATE_DATA    0x06
+ #define STREAM_TYPE_AUDIO_AAC       0x0f
+ #define STREAM_TYPE_VIDEO_MPEG4     0x10
++#define STREAM_TYPE_AUDIO_AAC_LATM  0x11
+ #define STREAM_TYPE_VIDEO_H264      0x1b
+ #define STREAM_TYPE_VIDEO_VC1       0xea
+ #define STREAM_TYPE_VIDEO_DIRAC     0xd1
diff --git a/contrib/ffmpeg/A01-mpegleak.patch b/contrib/ffmpeg/A01-mpegleak.patch
new file mode 100644 (file)
index 0000000..d02365d
--- /dev/null
@@ -0,0 +1,56 @@
+diff -Naur ffmpeg-r19067.orig/libavcodec/h264.c ffmpeg-r19067/libavcodec/h264.c
+--- ffmpeg-r19067.orig/libavcodec/h264.c       2009-05-29 20:24:20.000000000 -0400
++++ ffmpeg-r19067/libavcodec/h264.c    2009-06-01 12:45:16.000000000 -0400
+@@ -3406,7 +3406,7 @@
+          * stream. Need to discard one frame. Prevents overrun of the
+          * short_ref and long_ref buffers.
+          */
+-        av_log(h->s.avctx, AV_LOG_ERROR,
++        av_log(h->s.avctx, AV_LOG_DEBUG,
+                "number of reference frames exceeds max (probably "
+                "corrupt input), discarding one\n");
+@@ -7770,7 +7770,7 @@
+     if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
+         if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
+-        av_log(avctx, AV_LOG_ERROR, "no frame!\n");
++        av_log(avctx, AV_LOG_DEBUG, "no frame!\n");
+         return -1;
+     }
+diff -Naur ffmpeg-r19067.orig/libavcodec/mpegvideo.c ffmpeg-r19067/libavcodec/mpegvideo.c
+--- ffmpeg-r19067.orig/libavcodec/mpegvideo.c  2009-05-27 15:55:35.000000000 -0400
++++ ffmpeg-r19067/libavcodec/mpegvideo.c       2009-06-01 12:45:16.000000000 -0400
+@@ -831,19 +831,18 @@
+     }
+     av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n");
+-    /* We could return -1, but the codec would crash trying to draw into a
+-     * non-existing frame anyway. This is safer than waiting for a random crash.
+-     * Also the return of this is never useful, an encoder must only allocate
+-     * as much as allowed in the specification. This has no relationship to how
+-     * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
+-     * enough for such valid streams).
+-     * Plus, a decoder has to check stream validity and remove frames if too
+-     * many reference frames are around. Waiting for "OOM" is not correct at
+-     * all. Similarly, missing reference frames have to be replaced by
+-     * interpolated/MC frames, anything else is a bug in the codec ...
+-     */
+-    abort();
+-    return -1;
++    /* XXX there seems to be a leak caused by h264 in mpeg transport
++     * streams: Over-the-air streams have a lot of errors. A picture
++     * may be marked as referenced but the actual references get lost
++     * so it never gets released. We take care of that here by releasing
++     * the oldest we have & reusing its slot. */
++    int oldest=0;
++    for(i=0; i<MAX_PICTURE_COUNT; i++){
++        if (s->picture[i].coded_picture_number < s->picture[oldest].coded_picture_number)
++            oldest = i;
++    }
++    s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[oldest]);
++    return oldest;
+ }
+ static void update_noise_reduction(MpegEncContext *s){
diff --git a/contrib/ffmpeg/A02-audioconvert.patch b/contrib/ffmpeg/A02-audioconvert.patch
new file mode 100644 (file)
index 0000000..bec0cac
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur ffmpeg.orig/libavcodec/Makefile ffmpeg/libavcodec/Makefile
+--- ffmpeg.orig/libavcodec/Makefile    2008-12-01 01:40:36.000000000 -0500
++++ ffmpeg/libavcodec/Makefile 2009-02-23 07:03:23.000000000 -0500
+@@ -3,7 +3,7 @@
+ NAME = avcodec
+ FFLIBS = avutil
+-HEADERS = avcodec.h opt.h vdpau.h xvmc.h
++HEADERS = avcodec.h opt.h vdpau.h xvmc.h audioconvert.h
+ OBJS = allcodecs.o                                                      \
+        audioconvert.o                                                   \
diff --git a/contrib/ffmpeg/A03-png-sequences.patch b/contrib/ffmpeg/A03-png-sequences.patch
new file mode 100644 (file)
index 0000000..c996fa1
--- /dev/null
@@ -0,0 +1,30 @@
+diff -Naur ffmpeg-r19067.orig/libavcodec/pngdec.c ffmpeg-r19067/libavcodec/pngdec.c
+--- ffmpeg-r19067.orig/libavcodec/pngdec.c     2009-05-24 08:44:54.000000000 -0400
++++ ffmpeg-r19067/libavcodec/pngdec.c  2009-06-03 18:53:52.000000000 -0400
+@@ -593,6 +593,18 @@
+         }
+     }
+  exit_loop:
++/* ffmpeg-r18421 introduced support for CorePNG p-frames which
++ * breaks raw png sequences created by QuickTime Pro.
++ * since only the first png appears to be marked as PKT_FLAG_KEY
++ * it means either QuickTime Pro is encoding incorrectly, or
++ * this code block needs to find other criteria.
++ *
++ * As of ffmpeg-r19079 this patch should no longer be required.
++ * It offers a similar solution; forces code block to be skipped.
++ *
++ * --kb
++ */
++#if 0
+      /* handle p-frames only if a predecessor frame is available */
+      if(s->last_picture->data[0] != NULL) {
+          if(!(avpkt->flags & PKT_FLAG_KEY)) {
+@@ -609,6 +621,7 @@
+             }
+         }
+     }
++#endif
+     *picture= *s->current_picture;
+     *data_size = sizeof(AVFrame);
diff --git a/contrib/ffmpeg/A04-disable-depend.patch b/contrib/ffmpeg/A04-disable-depend.patch
new file mode 100644 (file)
index 0000000..e6099da
--- /dev/null
@@ -0,0 +1,33 @@
+diff -Naur ffmpeg-r19067.orig/common.mak ffmpeg-r19067/common.mak
+--- ffmpeg-r19067.orig/common.mak      2009-05-29 07:56:54.000000000 -0400
++++ ffmpeg-r19067/common.mak   2009-06-23 20:36:58.000000000 -0400
+@@ -29,17 +29,6 @@
+ %.ho: %.h
+       $(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
+-%.d: %.c
+-      $(DEPEND_CMD) > $@
+-
+-%.d: %.S
+-      $(DEPEND_CMD) > $@
+-
+-%.d: %.cpp
+-      $(DEPEND_CMD) > $@
+-
+-%.o: %.d
+-
+ %$(EXESUF): %.c
+ SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
+@@ -76,11 +65,6 @@
+ ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
+ checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
+-DEPS := $(OBJS:.o=.d)
+-depend dep: $(DEPS)
+-
+ CLEANSUFFIXES     = *.o *~ *.ho *.map
+ DISTCLEANSUFFIXES = *.d *.pc
+ LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
+-
+--include $(DEPS)
diff --git a/contrib/ffmpeg/P00-cygwin.patch b/contrib/ffmpeg/P00-cygwin.patch
new file mode 100644 (file)
index 0000000..b6ca99f
--- /dev/null
@@ -0,0 +1,15 @@
+diff -Naur ffmpeg/libavcodec/mpegaudiodec.c ffmpeg-patched/libavcodec/mpegaudiodec.c
+--- ffmpeg/libavcodec/mpegaudiodec.c   2006-09-23 14:22:06.000000000 -0400
++++ ffmpeg-patched/libavcodec/mpegaudiodec.c   2007-01-01 18:31:51.156250000 -0500
+@@ -401,9 +401,9 @@
+         for(i=0; i<512*16; i++){
+             int exponent= (i>>4);
+             double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
+-            expval_table[exponent][i&15]= llrint(f);
++            expval_table[exponent][i&15]= lrint(f);
+             if((i&15)==1)
+-                exp_table[exponent]= llrint(f);
++                exp_table[exponent]= lrint(f);
+         }
+         for(i=0;i<7;i++) {
diff --git a/contrib/ffmpeg/P01-solaris.patch b/contrib/ffmpeg/P01-solaris.patch
new file mode 100644 (file)
index 0000000..f5cd7d7
--- /dev/null
@@ -0,0 +1,25 @@
+--- ffmpeg/configure   Sat Jun  7 03:19:09 2008
++++ ffmpeg.solaris/configure   Thu Jun 19 12:10:48 2008
+@@ -50,6 +50,9 @@
+     exit 1
+ fi
++# Solaris must use the xpg4 version of grep
++PATH=/usr/xpg4/bin:$PATH
++
+ show_help(){
+   echo "Usage: configure [options]"
+   echo "Options: [defaults in brackets after descriptions]"
+@@ -1585,8 +1588,11 @@
+ check_cc <<EOF || die "endian test failed"
+ unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
+ EOF
+-od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
++#od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
++/usr/bin/tr -cd "BIGE" < $TMPO | grep -q 'B *I *G *E' && enable bigendian
++echo "BIGE=$bigendian"
++
+ # ---
+ # check availability of some header files
diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs
new file mode 100644 (file)
index 0000000..4b8b092
--- /dev/null
@@ -0,0 +1,52 @@
+$(eval $(call import.MODULE.defs,FFMPEG,ffmpeg,BZIP2 FAAD2 ZLIB))
+$(eval $(call import.CONTRIB.defs,FFMPEG))
+
+FFMPEG.FETCH.url = http://download.m0k.org/handbrake/contrib/ffmpeg-r19067.tar.bz2
+
+FFMPEG.CONFIGURE.deps =
+FFMPEG.CONFIGURE.env  =
+FFMPEG.CONFIGURE.host =
+
+FFMPEG.CONFIGURE.extra = \
+    --disable-bsfs \
+    --disable-encoders \
+    --disable-ffmpeg \
+    --disable-ffserver \
+    --disable-muxers \
+    --disable-network \
+    --enable-bzlib \
+    --enable-encoder=ac3 \
+    --enable-encoder=mpeg4 \
+    --enable-encoder=snow \
+    --enable-gpl \
+    --enable-libfaad \
+    --enable-muxer=ipod \
+    --enable-zlib \
+    --cc="$(FFMPEG.GCC.gcc)" \
+    --extra-cflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -I$(call fn.ABSOLUTE,$(CONTRIB.build/)include)" \
+    --extra-ldflags="$(call fn.ARGS,FFMPEG.GCC,*archs *sysroot *minver ?extra) -L$(call fn.ABSOLUTE,$(CONTRIB.build/)lib)"
+
+## check against tuple: B-SYSTEM where B is { 0 | 1 } for cross-compiling flag
+ifeq (0-cygwin,$(BUILD.cross)-$(BUILD.system))
+    FFMPEG.CONFIGURE.extra += --enable-pthreads --enable-memalign-hack
+    FFMPEG.GCC.args.extra = -fno-common
+else ifeq (darwin,$(BUILD.system))
+    ## section for darwin-archs
+    FFMPEG.CONFIGURE.extra += --enable-pthreads --enable-cross-compile --arch=$(BUILD.machine)
+else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+    FFMPEG.CONFIGURE.extra += \
+        --enable-w32threads \
+        --enable-memalign-hack \
+        --target-os=mingw32 \
+        --enable-cross-compile --cross-prefix=$(BUILD.cross.prefix)
+    FFMPEG.GCC.args.extra += -fno-common
+else
+    FFMPEG.CONFIGURE.extra += --enable-pthreads
+endif
+
+#
+# MPC8 Doesn't compile on SPARC
+#
+ifeq (solaris,$(BUILD.system))
+    FFMPEG.CONFIGURE.extra += --disable-demuxer=mpc8
+endif
diff --git a/contrib/ffmpeg/module.rules b/contrib/ffmpeg/module.rules
new file mode 100644 (file)
index 0000000..7f475b3
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,FFMPEG))
+$(eval $(call import.CONTRIB.rules,FFMPEG))
diff --git a/contrib/lame/P00-darwin-xmmintrin.patch b/contrib/lame/P00-darwin-xmmintrin.patch
new file mode 100644 (file)
index 0000000..de19e55
--- /dev/null
@@ -0,0 +1,28 @@
+diff -Naur lame.orig/configure lame/configure
+--- lame.orig/configure        2008-06-29 17:40:05.000000000 -0400
++++ lame/configure     2008-10-14 05:01:29.000000000 -0400
+@@ -21031,7 +21031,14 @@
+-
++case $host_cpu in
++powerpc*)
++    check_xmmintrin=
++    ;;
++*)
++    check_xmmintrin="xmmintrin.h"
++    ;;
++esac
+ for ac_header in \
+                errno.h \
+@@ -21042,7 +21049,7 @@
+                sys/soundcard.h \
+                sys/time.h \
+                unistd.h \
+-               xmmintrin.h \
++               $check_xmmintrin \
+                linux/soundcard.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
diff --git a/contrib/lame/module.defs b/contrib/lame/module.defs
new file mode 100644 (file)
index 0000000..dd89cd6
--- /dev/null
@@ -0,0 +1,5 @@
+$(eval $(call import.MODULE.defs,LAME,lame))
+$(eval $(call import.CONTRIB.defs,LAME))
+
+LAME.FETCH.url = http://download.m0k.org/handbrake/contrib/lame-3.98.tar.gz
+LAME.EXTRACT.tarbase = lame
diff --git a/contrib/lame/module.rules b/contrib/lame/module.rules
new file mode 100644 (file)
index 0000000..058bc7b
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LAME))
+$(eval $(call import.CONTRIB.rules,LAME))
diff --git a/contrib/libdca/A00-general.patch b/contrib/libdca/A00-general.patch
new file mode 100644 (file)
index 0000000..cab8db2
--- /dev/null
@@ -0,0 +1,834 @@
+diff -Naur libdca/include/audio_out.h libdca_patched/include/audio_out.h
+--- libdca/include/audio_out.h 2007-05-02 10:05:03.000000000 +0100
++++ libdca_patched/include/audio_out.h 2007-05-02 10:09:42.000000000 +0100
+@@ -26,8 +26,8 @@
+ struct ao_instance_s {
+     int (* setup) (ao_instance_t * instance, int sample_rate, int * flags,
+-                 level_t * level, sample_t * bias);
+-    int (* play) (ao_instance_t * instance, int flags, sample_t * samples);
++                 dca_level_t * level, dca_sample_t * bias);
++    int (* play) (ao_instance_t * instance, int flags, dca_sample_t * samples);
+     void (* close) (ao_instance_t * instance);
+ };
+diff -Naur libdca/include/dca.h libdca_patched/include/dca.h
+--- libdca/include/dca.h       2007-05-02 10:05:03.000000000 +0100
++++ libdca_patched/include/dca.h       2007-05-02 10:09:36.000000000 +0100
+@@ -32,14 +32,14 @@
+ uint32_t mm_accel (void);
+ #if defined(LIBDCA_FIXED)
+-typedef int32_t sample_t;
+-typedef int32_t level_t;
++typedef int32_t dca_sample_t;
++typedef int32_t dca_level_t;
+ #elif defined(LIBDCA_DOUBLE)
+-typedef double sample_t;
+-typedef double level_t;
++typedef double dca_sample_t;
++typedef double dca_level_t;
+ #else
+-typedef float sample_t;
+-typedef float level_t;
++typedef float dca_sample_t;
++typedef float dca_level_t;
+ #endif
+ typedef struct dca_state_s dca_state_t;
+@@ -65,21 +65,24 @@
+ #define DCA_LFE 0x80
+ #define DCA_ADJUST_LEVEL 0x100
++#define DCA_OUT_DPLI  0x200
++#define DCA_OUT_DPLII 0x400
++
+ dca_state_t * dca_init (uint32_t mm_accel);
+ int dca_syncinfo (dca_state_t *state, uint8_t * buf, int * flags,
+                   int * sample_rate, int * bit_rate, int *frame_length);
+ int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
+-               level_t * level, sample_t bias);
++               dca_level_t * level, dca_sample_t bias);
+ void dca_dynrng (dca_state_t * state,
+-                 level_t (* call) (level_t, void *), void * data);
++                 dca_level_t (* call) (dca_level_t, void *), void * data);
+ int dca_blocks_num (dca_state_t * state);
+ int dca_block (dca_state_t * state);
+-sample_t * dca_samples (dca_state_t * state);
++dca_sample_t * dca_samples (dca_state_t * state);
+ void dca_free (dca_state_t * state);
+diff -Naur libdca/libao/audio_out_aif.c libdca_patched/libao/audio_out_aif.c
+--- libdca/libao/audio_out_aif.c       2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_aif.c       2007-05-02 10:09:41.000000000 +0100
+@@ -49,7 +49,7 @@
+ };
+ static int aif_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                    level_t * level, sample_t * bias)
++                    dca_level_t * level, dca_sample_t * bias)
+ {
+     aif_instance_t * instance = (aif_instance_t *) _instance;
+@@ -78,7 +78,7 @@
+     buf[1] = value;
+ }
+-static int aif_play (ao_instance_t * _instance, int flags, sample_t * _samples)
++static int aif_play (ao_instance_t * _instance, int flags, dca_sample_t * _samples)
+ {
+     aif_instance_t * instance = (aif_instance_t *) _instance;
+     int16_t int16_samples[256*2];
+diff -Naur libdca/libao/audio_out_al.c libdca_patched/libao/audio_out_al.c
+--- libdca/libao/audio_out_al.c        2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_al.c        2007-05-02 10:09:41.000000000 +0100
+@@ -44,7 +44,7 @@
+ } al_instance_t;
+ static int al_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                   level_t * level, sample_t * bias)
++                   dca_level_t * level, dca_sample_t * bias)
+ {
+     al_instance_t * instance = (al_instance_t *) _instance;
+@@ -59,7 +59,7 @@
+     return 0;
+ }
+-static int al_play (ao_instance_t * _instance, int flags, sample_t * _samples)
++static int al_play (ao_instance_t * _instance, int flags, dca_sample_t * _samples)
+ {
+     al_instance_t * instance = (al_instance_t *) _instance;
+     int16_t int16_samples[256*6];
+diff -Naur libdca/libao/audio_out_float.c libdca_patched/libao/audio_out_float.c
+--- libdca/libao/audio_out_float.c     2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_float.c     2007-05-02 10:09:40.000000000 +0100
+@@ -32,7 +32,7 @@
+ #include "audio_out_internal.h"
+ static int float_setup (ao_instance_t * instance, int sample_rate, int * flags,
+-                      level_t * level, sample_t * bias)
++                      dca_level_t * level, dca_sample_t * bias)
+ {
+     (void)instance;
+     (void)sample_rate;
+@@ -44,7 +44,7 @@
+ }
+ static int float_play (ao_instance_t * instance, int flags,
+-                     sample_t * _samples)
++                     dca_sample_t * _samples)
+ {
+ #if defined(LIBDCA_FIXED)
+     float samples[256 * 2];
+diff -Naur libdca/libao/audio_out_internal.h libdca_patched/libao/audio_out_internal.h
+--- libdca/libao/audio_out_internal.h  2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_internal.h  2007-05-02 10:09:40.000000000 +0100
+@@ -25,7 +25,7 @@
+ #ifdef LIBDCA_DOUBLE
+ typedef float convert_t;
+ #else
+-typedef sample_t convert_t;
++typedef dca_sample_t convert_t;
+ #endif
+ #ifdef LIBDCA_FIXED
+diff -Naur libdca/libao/audio_out_null.c libdca_patched/libao/audio_out_null.c
+--- libdca/libao/audio_out_null.c      2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_null.c      2007-05-02 10:09:39.000000000 +0100
+@@ -36,7 +36,7 @@
+ } null_instance_t;
+ static int null_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                     level_t * level, sample_t * bias)
++                     dca_level_t * level, dca_sample_t * bias)
+ {
+     null_instance_t * instance = (null_instance_t *) _instance;
+@@ -48,7 +48,7 @@
+     return 0;
+ }
+-static int null_play (ao_instance_t * instance, int flags, sample_t * samples)
++static int null_play (ao_instance_t * instance, int flags, dca_sample_t * samples)
+ {
+     (void)instance; (void)flags; (void)samples;
+     return 0;
+diff -Naur libdca/libao/audio_out_oss.c libdca_patched/libao/audio_out_oss.c
+--- libdca/libao/audio_out_oss.c       2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_oss.c       2007-05-02 10:09:38.000000000 +0100
+@@ -68,7 +68,7 @@
+ } oss_instance_t;
+ static int oss_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                    level_t * level, sample_t * bias)
++                    dca_level_t * level, dca_sample_t * bias)
+ {
+     oss_instance_t * instance = (oss_instance_t *) _instance;
+@@ -83,7 +83,7 @@
+     return 0;
+ }
+-static int oss_play (ao_instance_t * _instance, int flags, sample_t * _samples)
++static int oss_play (ao_instance_t * _instance, int flags, dca_sample_t * _samples)
+ {
+     oss_instance_t * instance = (oss_instance_t *) _instance;
+     int16_t int16_samples[256*6];
+diff -Naur libdca/libao/audio_out_peak.c libdca_patched/libao/audio_out_peak.c
+--- libdca/libao/audio_out_peak.c      2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_peak.c      2007-05-02 10:09:38.000000000 +0100
+@@ -16,7 +16,7 @@
+ } peak_instance_t;
+ static int peak_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                     level_t * level, sample_t * bias)
++                     dca_level_t * level, dca_sample_t * bias)
+ {
+     peak_instance_t * instance = (peak_instance_t *) _instance;
+@@ -29,7 +29,7 @@
+     return 0;
+ }
+-static int peak_play (ao_instance_t * _instance, int flags, sample_t * samples)
++static int peak_play (ao_instance_t * _instance, int flags, dca_sample_t * samples)
+ {
+     peak_instance_t * instance = (peak_instance_t *) _instance;
+     int i;
+diff -Naur libdca/libao/audio_out_solaris.c libdca_patched/libao/audio_out_solaris.c
+--- libdca/libao/audio_out_solaris.c   2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_solaris.c   2007-05-02 10:09:37.000000000 +0100
+@@ -47,7 +47,7 @@
+ } solaris_instance_t;
+ static int solaris_setup (ao_instance_t * _instance, int sample_rate,
+-                        int * flags, level_t * level, sample_t * bias)
++                        int * flags, dca_level_t * level, dca_sample_t * bias)
+ {
+     solaris_instance_t * instance = (solaris_instance_t *) _instance;
+@@ -63,7 +63,7 @@
+ }
+ static int solaris_play (ao_instance_t * _instance, int flags,
+-                       sample_t * _samples)
++                       dca_sample_t * _samples)
+ {
+     solaris_instance_t * instance = (solaris_instance_t *) _instance;
+     int16_t int16_samples[256*2];
+diff -Naur libdca/libao/audio_out_wav.c libdca_patched/libao/audio_out_wav.c
+--- libdca/libao/audio_out_wav.c       2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_wav.c       2007-05-02 10:09:37.000000000 +0100
+@@ -87,7 +87,7 @@
+ };
+ static int wav_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                      level_t * level, sample_t * bias)
++                      dca_level_t * level, dca_sample_t * bias)
+ {
+     wav_instance_t * instance = (wav_instance_t *) _instance;
+@@ -157,7 +157,7 @@
+ #include <stdio.h>
+-static int wav_play (ao_instance_t * _instance, int flags, sample_t * _samples)
++static int wav_play (ao_instance_t * _instance, int flags, dca_sample_t * _samples)
+ {
+     wav_instance_t * instance = (wav_instance_t *) _instance;
+     union
+diff -Naur libdca/libao/audio_out_win.c libdca_patched/libao/audio_out_win.c
+--- libdca/libao/audio_out_win.c       2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/libao/audio_out_win.c       2007-05-02 10:09:36.000000000 +0100
+@@ -55,7 +55,7 @@
+ } win_instance_t;
+ static int win_setup (ao_instance_t * _instance, int sample_rate, int * flags,
+-                    level_t * level, sample_t * bias)
++                    dca_level_t * level, dca_sample_t * bias)
+ {
+     win_instance_t * instance = (win_instance_t *) _instance;
+@@ -70,7 +70,7 @@
+     return 0;
+ }
+-static int win_play (ao_instance_t * _instance, int flags, sample_t * _samples)
++static int win_play (ao_instance_t * _instance, int flags, dca_sample_t * _samples)
+ {
+     win_instance_t * instance = (win_instance_t *) _instance;
+     int current_buffer;
+diff -Naur libdca/libdca/dca_internal.h libdca_patched/libdca/dca_internal.h
+--- libdca/libdca/dca_internal.h       2007-05-02 10:05:05.000000000 +0100
++++ libdca_patched/libdca/dca_internal.h       2007-05-02 10:09:35.000000000 +0100
+@@ -116,20 +116,20 @@
+     double subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][64];
+     /* Audio output */
+-    level_t clev;            /* centre channel mix level */
+-    level_t slev;            /* surround channels mix level */
++    dca_level_t clev;            /* centre channel mix level */
++    dca_level_t slev;            /* surround channels mix level */
+     int output;              /* type of output */
+-    level_t level;           /* output level */
+-    sample_t bias;           /* output bias */
++    dca_level_t level;           /* output level */
++    dca_sample_t bias;           /* output bias */
+-    sample_t * samples;      /* pointer to the internal audio samples buffer */
++    dca_sample_t * samples;      /* pointer to the internal audio samples buffer */
+     int downmixed;
+     int dynrnge;             /* apply dynamic range */
+-    level_t dynrng;          /* dynamic range */
++    dca_level_t dynrng;          /* dynamic range */
+     void * dynrngdata;       /* dynamic range callback funtion and data */
+-    level_t (* dynrngcall) (level_t range, void * dynrngdata);
++    dca_level_t (* dynrngcall) (dca_level_t range, void * dynrngdata);
+     /* Bitstream handling */
+     uint32_t * buffer_start;
+@@ -155,19 +155,23 @@
+ #define LEVEL_45DB 0.5946035575013605
+ #define LEVEL_6DB 0.5
+-int dca_downmix_init (int input, int flags, level_t * level,
+-                      level_t clev, level_t slev);
+-int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+-                       level_t clev, level_t slev);
+-void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+-                  level_t clev, level_t slev);
+-void dca_upmix (sample_t * samples, int acmod, int output);
++// these next two constants are used for DPL matrix encoding in downmix.c
++#define LEVEL_SQRT_1_2 0.5
++#define LEVEL_SQRT_3_4 0.8660254037844386
++
++int dca_downmix_init (int input, int flags, dca_level_t * level,
++                      dca_level_t clev, dca_level_t slev);
++int dca_downmix_coeff (dca_level_t * coeff, int acmod, int output, dca_level_t level,
++                       dca_level_t clev, dca_level_t slev);
++void dca_downmix (dca_sample_t * samples, int acmod, int output, dca_sample_t bias,
++                  dca_level_t clev, dca_level_t slev);
++void dca_upmix (dca_sample_t * samples, int acmod, int output);
+ #define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
+ #ifndef LIBDCA_FIXED
+-typedef sample_t quantizer_t;
++typedef dca_sample_t quantizer_t;
+ #define SAMPLE(x) (x)
+ #define LEVEL(x) (x)
+ #define MUL(a,b) ((a) * (b))
+@@ -179,8 +183,8 @@
+ #else /* LIBDCA_FIXED */
+ typedef int16_t quantizer_t;
+-#define SAMPLE(x) (sample_t)((x) * (1 << 30))
+-#define LEVEL(x) (level_t)((x) * (1 << 26))
++#define SAMPLE(x) (dca_sample_t)((x) * (1 << 30))
++#define LEVEL(x) (dca_level_t)((x) * (1 << 26))
+ #if 0
+ #define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
+diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c
+--- libdca/libdca/downmix.c    2007-05-02 10:05:05.000000000 +0100
++++ libdca_patched/libdca/downmix.c    2007-05-06 19:45:54.000000000 +0100
+@@ -33,8 +33,8 @@
+ #define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod))
+-int dca_downmix_init (int input, int flags, level_t * level,
+-                    level_t clev, level_t slev)
++int dca_downmix_init (int input, int flags, dca_level_t * level,
++                    dca_level_t clev, dca_level_t slev)
+ {
+     static uint8_t table[11][10] = {
+         /* DCA_MONO */
+@@ -96,7 +96,7 @@
+       output = DCA_DOLBY;
+     if (flags & DCA_ADJUST_LEVEL) {
+-      level_t adjust;
++      dca_level_t adjust;
+       switch (CONVERT (input & 7, output)) {
+@@ -181,13 +181,16 @@
+       *level = MUL_L (*level, adjust);
+     }
++      // add the DPLI/DPLII flag back into the output if one was passed in
++      output = output | (flags & DCA_OUT_DPLI) | (flags & DCA_OUT_DPLII);
++
+     return output;
+ }
+-int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+-                     level_t clev, level_t slev)
++int dca_downmix_coeff (dca_level_t * coeff, int acmod, int output, dca_level_t level,
++                     dca_level_t clev, dca_level_t slev)
+ {
+-    level_t level_3db;
++    dca_level_t level_3db;
+     level_3db = MUL_C (level, LEVEL_3DB);
+@@ -344,7 +347,7 @@
+     return -1;        /* NOTREACHED */
+ }
+-static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
++static void mix2to1 (dca_sample_t * dest, dca_sample_t * src, dca_sample_t bias)
+ {
+     int i;
+@@ -352,7 +355,7 @@
+       dest[i] += BIAS (src[i]);
+ }
+-static void mix3to1 (sample_t * samples, sample_t bias)
++static void mix3to1 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+@@ -360,7 +363,7 @@
+       samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
+ }
+-static void mix4to1 (sample_t * samples, sample_t bias)
++static void mix4to1 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+@@ -369,7 +372,7 @@
+                           samples[i + 768]);
+ }
+-static void mix5to1 (sample_t * samples, sample_t bias)
++static void mix5to1 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+@@ -378,10 +381,10 @@
+                           samples[i + 768] + samples[i + 1024]);
+ }
+-static void mix3to2 (sample_t * samples, sample_t bias)
++static void mix3to2 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+-    sample_t common;
++    dca_sample_t common;
+     for (i = 0; i < 256; i++) {
+       common = BIAS (samples[i]);
+@@ -390,10 +393,10 @@
+     }
+ }
+-static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
++static void mix21to2 (dca_sample_t * left, dca_sample_t * right, dca_sample_t bias)
+ {
+     int i;
+-    sample_t common;
++    dca_sample_t common;
+     for (i = 0; i < 256; i++) {
+       common = BIAS (right[i + 256]);
+@@ -402,10 +405,10 @@
+     }
+ }
+-static void mix21toS (sample_t * samples, sample_t bias)
++static void mix21toS (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+-    sample_t surround;
++    dca_sample_t surround;
+     for (i = 0; i < 256; i++) {
+       surround = samples[i + 512];
+@@ -414,10 +417,10 @@
+     }
+ }
+-static void mix31to2 (sample_t * samples, sample_t bias)
++static void mix31to2 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+-    sample_t common;
++    dca_sample_t common;
+     for (i = 0; i < 256; i++) {
+       common = BIAS (samples[i] + samples[i + 768]);
+@@ -426,23 +429,32 @@
+     }
+ }
+-static void mix31toS (sample_t * samples, sample_t bias)
++static void mix31toS (dca_sample_t * samples, dca_sample_t bias)
+ {
+-    int i;
+-    sample_t common, surround;
+-    for (i = 0; i < 256; i++) {
+-      common = BIAS (samples[i]);
+-      surround = samples[i + 768];
+-      samples[i] = samples[i + 256] + common - surround;
+-      samples[i + 256] = samples[i + 512] + common + surround;
+-    }
++      int i;
++      dca_sample_t cc, surround, Lt, Rt;
++
++      for (i = 0; i < 256; i++) {
++
++              cc = samples[i] * LEVEL_3DB;
++
++              surround = samples[i + 768];
++
++              Lt = samples[i + 256] + cc;
++              Rt = samples[i + 512] + cc;
++
++              samples[i] = Lt - surround;
++              samples[i + 256] = Rt + surround;
++
++      }
++
+ }
+-static void mix22toS (sample_t * samples, sample_t bias)
++static void mix22toS (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+-    sample_t surround;
++    dca_sample_t surround;
+     for (i = 0; i < 256; i++) {
+       surround = samples[i + 512] + samples[i + 768];
+@@ -451,10 +463,10 @@
+     }
+ }
+-static void mix32to2 (sample_t * samples, sample_t bias)
++static void mix32to2 (dca_sample_t * samples, dca_sample_t bias)
+ {
+     int i;
+-    sample_t common;
++    dca_sample_t common;
+     for (i = 0; i < 256; i++) {
+       common = BIAS (samples[i]);
+@@ -463,20 +475,55 @@
+     }
+ }
+-static void mix32toS (sample_t * samples, sample_t bias)
++static void mix32toS (dca_sample_t * samples, dca_sample_t bias, int use_dpl2)
+ {
+-    int i;
+-    sample_t common, surround;
+-    for (i = 0; i < 256; i++) {
+-      common = BIAS (samples[i]);
+-      surround = samples[i + 768] + samples[i + 1024];
+-      samples[i] = samples[i + 256] + common - surround;
+-      samples[i + 256] = samples[i + 512] + common + surround;
+-    }
+-}
++      if (use_dpl2 == 1) {
+-static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
++              int i;
++              dca_sample_t cc, Lt, Rt, Ls, Rs, Lss, Rss;
++      
++              for (i = 0; i < 256; i++) {
++      
++                      cc = samples[i] * LEVEL_3DB;
++              
++                      Lt = samples[i + 256] + cc;
++                      Rt = samples[i + 512] + cc;
++              
++                      Ls = samples[i + 768];
++                      Rs = samples[i + 1024];
++                      
++                      Lss = (LEVEL_SQRT_3_4 * Ls) - (LEVEL_SQRT_1_2 * Rs);
++                      Rss = -(LEVEL_SQRT_1_2 * Ls) + (LEVEL_SQRT_3_4 * Rs);
++              
++                      samples[i] = Lt + Lss;
++                      samples[i + 256] = Rt + Rss;
++      
++              }
++
++      } else {
++
++              int i;
++              dca_sample_t cc, surround, Lt, Rt;
++      
++              for (i = 0; i < 256; i++) {
++
++                      cc = samples[i] * LEVEL_3DB;
++
++                      surround = samples[i + 768] + samples[i + 1024];
++
++                      Lt = samples[i + 256] + cc;
++                      Rt = samples[i + 512] + cc;
++
++                      samples[i] = Lt - surround;
++                      samples[i + 256] = Rt + surround;
++
++              }
++
++      }
++
++}
++static void move2to1 (dca_sample_t * src, dca_sample_t * dest, dca_sample_t bias)
+ {
+     int i;
+@@ -484,7 +531,7 @@
+       dest[i] = BIAS (src[i] + src[i + 256]);
+ }
+-static void zero (sample_t * samples)
++static void zero (dca_sample_t * samples)
+ {
+     int i;
+@@ -492,8 +539,8 @@
+       samples[i] = 0;
+ }
+-void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+-                level_t clev, level_t slev)
++void dca_downmix (dca_sample_t * samples, int acmod, int output, dca_sample_t bias,
++                dca_level_t clev, dca_level_t slev)
+ {
+     (void)clev;
+@@ -529,7 +576,7 @@
+       break;
+     case CONVERT (DCA_MONO, DCA_DOLBY):
+-      memcpy (samples + 256, samples, 256 * sizeof (sample_t));
++      memcpy (samples + 256, samples, 256 * sizeof (dca_sample_t));
+       break;
+     case CONVERT (DCA_3F, DCA_STEREO):
+@@ -576,7 +623,7 @@
+       break;
+     case CONVERT (DCA_3F2R, DCA_DOLBY):
+-      mix32toS (samples, bias);
++      mix32toS (samples, bias, 0);
+       break;
+     case CONVERT (DCA_3F1R, DCA_3F):
+@@ -594,7 +641,7 @@
+     case CONVERT (DCA_3F1R, DCA_2F1R):
+       mix3to2 (samples, bias);
+-      memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
++      memcpy (samples + 512, samples + 768, 256 * sizeof (dca_sample_t));
+       break;
+     case CONVERT (DCA_2F2R, DCA_2F1R):
+@@ -608,30 +655,52 @@
+     case CONVERT (DCA_3F2R, DCA_3F1R):
+       mix2to1 (samples + 768, samples + 1024, bias);
++      /* deal with the special-case 5.0 to 4.0 DPL mix */
++    if (output & DCA_OUT_DPLI)
++    {
++              mix31toS (samples, bias);
++      }
+       break;
+     case CONVERT (DCA_2F1R, DCA_2F2R):
+-      memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
++      memcpy (samples + 768, samples + 512, 256 * sizeof (dca_sample_t));
+       break;
+     case CONVERT (DCA_3F1R, DCA_2F2R):
+       mix3to2 (samples, bias);
+-      memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
++      memcpy (samples + 512, samples + 768, 256 * sizeof (dca_sample_t));
+       break;
+     case CONVERT (DCA_3F2R, DCA_2F2R):
+       mix3to2 (samples, bias);
+-      memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
+-      memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
++      memcpy (samples + 512, samples + 768, 256 * sizeof (dca_sample_t));
++      memcpy (samples + 768, samples + 1024, 256 * sizeof (dca_sample_t));
+       break;
+     case CONVERT (DCA_3F1R, DCA_3F2R):
+-      memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
++      memcpy (samples + 1024, samples + 768, 256 * sizeof (dca_sample_t));
++      break;
++
++      /* deal with the special-case DPL mixes */
++
++    case CONVERT (DCA_3F1R, DCA_3F1R):
++    if (output & DCA_OUT_DPLI)
++    {
++              mix31toS (samples, bias);
++      }
+       break;
++
++    case CONVERT (DCA_3F2R, DCA_3F2R):
++    if (output & DCA_OUT_DPLII)
++    {
++              mix32toS (samples, bias, 1);
++      }
++      break;
++
+     }
+ }
+-void dca_upmix (sample_t * samples, int acmod, int output)
++void dca_upmix (dca_sample_t * samples, int acmod, int output)
+ {
+     switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
+@@ -657,7 +726,7 @@
+     case CONVERT (DCA_3F, DCA_STEREO):
+     case CONVERT (DCA_3F, DCA_DOLBY):
+     mix_3to2:
+-      memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
++      memcpy (samples + 512, samples + 256, 256 * sizeof (dca_sample_t));
+       zero (samples + 256);
+       break;
+@@ -684,11 +753,11 @@
+       zero (samples + 1024);
+     case CONVERT (DCA_3F1R, DCA_2F1R):
+     mix_31to21:
+-      memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
++      memcpy (samples + 768, samples + 512, 256 * sizeof (dca_sample_t));
+       goto mix_3to2;
+     case CONVERT (DCA_3F2R, DCA_2F2R):
+-      memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
++      memcpy (samples + 1024, samples + 768, 256 * sizeof (dca_sample_t));
+       goto mix_31to21;
+     }
+ }
+diff -Naur libdca/libdca/parse.c libdca_patched/libdca/parse.c
+--- libdca/libdca/parse.c      2007-05-02 10:05:05.000000000 +0100
++++ libdca_patched/libdca/parse.c      2007-05-02 10:09:33.000000000 +0100
+@@ -59,12 +59,12 @@
+ static int decode_blockcode (int code, int levels, int *values);
+ static void qmf_32_subbands (dca_state_t * state, int chans,
+-                             double samples_in[32][8], sample_t *samples_out,
+-                             double rScale, sample_t bias);
++                             double samples_in[32][8], dca_sample_t *samples_out,
++                             double rScale, dca_sample_t bias);
+ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
+-                                   double *samples_in, sample_t *samples_out,
+-                                   double rScale, sample_t bias );
++                                   double *samples_in, dca_sample_t *samples_out,
++                                   double rScale, dca_sample_t bias );
+ static void pre_calc_cosmod( dca_state_t * state );
+@@ -80,7 +80,7 @@
+     memset (state, 0, sizeof(dca_state_t));
+-    state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t));
++    state->samples = (dca_sample_t *) memalign (16, 256 * 12 * sizeof (dca_sample_t));
+     if (state->samples == NULL) {
+         free (state);
+         return NULL;
+@@ -97,7 +97,7 @@
+     return state;
+ }
+-sample_t * dca_samples (dca_state_t * state)
++dca_sample_t * dca_samples (dca_state_t * state)
+ {
+     return state->samples;
+ }
+@@ -207,7 +207,7 @@
+ }
+ int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
+-               level_t * level, sample_t bias)
++               dca_level_t * level, dca_sample_t bias)
+ {
+     int i, j;
+     static float adj_table[] = { 1.0, 1.1250, 1.2500, 1.4375 };
+@@ -996,7 +996,7 @@
+     {
+         dca_upmix (state->samples, state->amode, state->output);
+     } else
+-    if (state->prim_channels > dca_channels[state->output & DCA_CHANNEL_MASK])
++    if (state->prim_channels >= dca_channels[state->output & DCA_CHANNEL_MASK])
+     {
+         dca_downmix (state->samples, state->amode, state->output, state->bias,
+                      state->clev, state->slev);
+@@ -1142,8 +1142,8 @@
+ }
+ static void qmf_32_subbands (dca_state_t * state, int chans,
+-                             double samples_in[32][8], sample_t *samples_out,
+-                             double scale, sample_t bias)
++                             double samples_in[32][8], dca_sample_t *samples_out,
++                             double scale, dca_sample_t bias)
+ {
+     double *prCoeff;
+     int i, j, k;
+@@ -1224,8 +1224,8 @@
+ }
+ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
+-                                   double *samples_in, sample_t *samples_out,
+-                                   double scale, sample_t bias)
++                                   double *samples_in, dca_sample_t *samples_out,
++                                   double scale, dca_sample_t bias)
+ {
+     /* samples_in: An array holding decimated samples.
+      *   Samples in current subframe starts from samples_in[0],
+@@ -1275,7 +1275,7 @@
+ }
+ void dca_dynrng (dca_state_t * state,
+-                 level_t (* call) (level_t, void *), void * data)
++                 dca_level_t (* call) (dca_level_t, void *), void * data)
+ {
+     state->dynrange = 0;
+     if (call) {
+diff -Naur libdca/src/dcadec.c libdca_patched/src/dcadec.c
+--- libdca/src/dcadec.c        2007-05-02 10:05:04.000000000 +0100
++++ libdca_patched/src/dcadec.c        2007-05-02 10:09:35.000000000 +0100
+@@ -280,15 +280,15 @@
+               }
+               bufpos = buf + length;
+           } else {
+-              level_t level;
+-              sample_t bias;
++              dca_level_t level;
++              dca_sample_t bias;
+               int i;
+               if (output->setup (output, sample_rate, &flags, &level, &bias))
+                   goto error;
+               if (!disable_adjust)
+                   flags |= DCA_ADJUST_LEVEL;
+-              level = (level_t) (level * gain);
++              level = (dca_level_t) (level * gain);
+               if (dca_frame (state, buf, &flags, &level, bias))
+                   goto error;
+               if (disable_dynrng)
diff --git a/contrib/libdca/module.defs b/contrib/libdca/module.defs
new file mode 100644 (file)
index 0000000..b69d1fb
--- /dev/null
@@ -0,0 +1,5 @@
+$(eval $(call import.MODULE.defs,LIBDCA,libdca))
+$(eval $(call import.CONTRIB.defs,LIBDCA))
+
+LIBDCA.FETCH.url = http://download.m0k.org/handbrake/contrib/libdca-r81-strapped.tar.gz
+LIBDCA.EXTRACT.tarbase = libdca
diff --git a/contrib/libdca/module.rules b/contrib/libdca/module.rules
new file mode 100644 (file)
index 0000000..0f33e21
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBDCA))
+$(eval $(call import.CONTRIB.rules,LIBDCA))
diff --git a/contrib/libdvdnav/A00-log-stderr.patch b/contrib/libdvdnav/A00-log-stderr.patch
new file mode 100644 (file)
index 0000000..36435dc
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur libdvdnav.orig/src/dvdnav_internal.h libdvdnav/src/dvdnav_internal.h
+--- libdvdnav.orig/src/dvdnav_internal.h       2008-10-03 13:11:43.000000000 -0700
++++ libdvdnav/src/dvdnav_internal.h    2009-04-24 14:23:04.000000000 -0700
+@@ -60,7 +60,7 @@
+ #endif /* WIN32 */
+ /* where should libdvdnav write its messages (stdout/stderr) */
+-#define MSG_OUT stdout
++#define MSG_OUT stderr
+ /* Maximum length of an error string */
+ #define MAX_ERR_LEN 255
diff --git a/contrib/libdvdnav/A01-program-info.patch b/contrib/libdvdnav/A01-program-info.patch
new file mode 100644 (file)
index 0000000..531741b
--- /dev/null
@@ -0,0 +1,214 @@
+diff -Naur libdvdnav.orig/src/dvdnav/dvdnav.h libdvdnav/src/dvdnav/dvdnav.h
+--- libdvdnav.orig/src/dvdnav/dvdnav.h 2009-03-13 18:28:22.000000000 -0700
++++ libdvdnav/src/dvdnav/dvdnav.h      2009-04-30 10:56:29.000000000 -0700
+@@ -279,6 +279,11 @@
+ dvdnav_status_t dvdnav_part_play(dvdnav_t *self, int32_t title, int32_t part);
+ /*
++ * Plays the specified title, starting from the specified program
++ */
++dvdnav_status_t dvdnav_program_play(dvdnav_t *this, int32_t title, int32_t pgcn, int32_t pgn);
++
++/*
+  * Stores in *times an array (that the application *must* free) of
+  * dvdtimes corresponding to the chapter times for the chosen title.
+  * *duration will have the duration of the title
+@@ -320,6 +325,13 @@
+                                         int32_t *part);
+ /*
++ * Return the title number, pgcn and pgn currently being played.
++ * A title of 0 indicates, we are in a menu.
++ */
++dvdnav_status_t dvdnav_current_title_program(dvdnav_t *self, int32_t *title,
++                                        int32_t *pgcn, int32_t *pgn);
++
++/*
+  * Return the current position (in blocks) within the current
+  * title and the length (in blocks) of said title.
+  *
+diff -Naur libdvdnav.orig/src/navigation.c libdvdnav/src/navigation.c
+--- libdvdnav.orig/src/navigation.c    2009-01-08 14:57:11.000000000 -0800
++++ libdvdnav/src/navigation.c 2009-04-30 10:55:47.000000000 -0700
+@@ -122,10 +122,90 @@
+   return DVDNAV_STATUS_ERR;
+ }
++dvdnav_status_t dvdnav_current_title_program(dvdnav_t *this, int32_t *title, int32_t *pgcn, int32_t *pgn) {
++  int32_t retval;
++  int32_t part;
++
++  pthread_mutex_lock(&this->vm_lock);
++  if (!this->vm->vtsi || !this->vm->vmgi) {
++    printerr("Bad VM state.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++  if (!this->started) {
++    printerr("Virtual DVD machine not started.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++  if (!this->vm->state.pgc) {
++    printerr("No current PGC.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++  if ( (this->vm->state.domain == VTSM_DOMAIN)
++      || (this->vm->state.domain == VMGM_DOMAIN) ) {
++    /* Get current Menu ID: into *part. */
++    if(! vm_get_current_menu(this->vm, &part)) {
++      pthread_mutex_unlock(&this->vm_lock);
++      return DVDNAV_STATUS_ERR;
++    }
++    if (part > -1) {
++      *title = 0;
++      *pgcn = this->vm->state.pgcN;
++      *pgn = this->vm->state.pgN;
++      pthread_mutex_unlock(&this->vm_lock);
++      return DVDNAV_STATUS_OK;
++    }
++  }
++  if (this->vm->state.domain == VTS_DOMAIN) {
++    retval = vm_get_current_title_part(this->vm, title, &part);
++    *pgcn = this->vm->state.pgcN;
++    *pgn = this->vm->state.pgN;
++    pthread_mutex_unlock(&this->vm_lock);
++    return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
++  }
++  printerr("Not in a title or menu.");
++  pthread_mutex_unlock(&this->vm_lock);
++  return DVDNAV_STATUS_ERR;
++}
++
+ dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) {
+   return dvdnav_part_play(this, title, 1);
+ }
++dvdnav_status_t dvdnav_program_play(dvdnav_t *this, int32_t title, int32_t pgcn, int32_t pgn) {
++  int32_t retval;
++
++  pthread_mutex_lock(&this->vm_lock);
++  if (!this->vm->vmgi) {
++    printerr("Bad VM state.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++  if (!this->started) {
++    /* don't report an error but be nice */
++    vm_start(this->vm);
++    this->started = 1;
++  }
++  if (!this->vm->state.pgc) {
++    printerr("No current PGC.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++  if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
++    printerr("Title out of range.");
++    pthread_mutex_unlock(&this->vm_lock);
++    return DVDNAV_STATUS_ERR;
++  }
++
++  retval = vm_jump_title_program(this->vm, title, pgcn, pgn);
++  if (retval)
++    this->vm->hop_channel++;
++  pthread_mutex_unlock(&this->vm_lock);
++
++  return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
++}
++
+ dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) {
+   int32_t retval;
+diff -Naur libdvdnav.orig/src/vm/vm.c libdvdnav/src/vm/vm.c
+--- libdvdnav.orig/src/vm/vm.c 2009-03-13 18:28:22.000000000 -0700
++++ libdvdnav/src/vm/vm.c      2009-04-30 11:07:35.000000000 -0700
+@@ -83,6 +83,8 @@
+ static int  set_PTT(vm_t *vm, int tt, int ptt);
+ static int  set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn);
+ static int  set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part);
++static int  set_PROG(vm_t *vm, int tt, int pgcn, int pgn);
++static int  set_VTS_PROG(vm_t *vm, int vtsN, int vts_ttn, int pgcn, int pgn);
+ static int  set_FP_PGC(vm_t *vm);
+ static int  set_MENU(vm_t *vm, int menu);
+ static int  set_PGCN(vm_t *vm, int pgcN);
+@@ -516,6 +518,24 @@
+   return 1;
+ }
++int vm_jump_title_program(vm_t *vm, int title, int pgcn, int pgn) {
++  link_t link;
++
++  if(!set_PROG(vm, title, pgcn, pgn))
++    return 0;
++  /* Some DVDs do not want us to jump directly into a title and have
++   * PGC pre commands taking us back to some menu. Since we do not like that,
++   * we do not execute PGC pre commands that would do a jump. */
++  /* process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); */
++  link = play_PGC_PG(vm, (vm->state).pgN);
++  if (link.command != PlayThis)
++    /* jump occured -> ignore it and play the PG anyway */
++    process_command(vm, play_PG(vm));
++  else
++    process_command(vm, link);
++  return 1;
++}
++
+ int vm_jump_title_part(vm_t *vm, int title, int part) {
+   link_t link;
+@@ -1644,6 +1664,42 @@
+   return res;
+ }
++static int set_PROG(vm_t *vm, int tt, int pgcn, int pgn) {
++  assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts);
++  return set_VTS_PROG(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr,
++                   vm->vmgi->tt_srpt->title[tt - 1].vts_ttn, pgcn, pgn);
++}
++
++static int set_VTS_PROG(vm_t *vm, int vtsN, int vts_ttn, int pgcn, int pgn) {
++  int pgcN, pgN, res, title, part;
++
++  (vm->state).domain = VTS_DOMAIN;
++
++  if (vtsN != (vm->state).vtsN)
++    if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN))  /* Also sets (vm->state).vtsN */
++      return 0;
++
++  if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts)) {
++    return 0;
++  }
++
++  pgcN = pgcn;
++  pgN = pgn;
++
++  (vm->state).TT_PGCN_REG = pgcN;
++  (vm->state).TTN_REG     = get_TT(vm, vtsN, vts_ttn);
++  assert( (vm->state.TTN_REG) != 0 );
++  (vm->state).VTS_TTN_REG = vts_ttn;
++  (vm->state).vtsN        = vtsN;  /* Not sure about this one. We can get to it easily from TTN_REG */
++  /* Any other registers? */
++
++  res = set_PGCN(vm, pgcN);   /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */
++  (vm->state).pgN = pgN;
++  vm_get_current_title_part(vm, &title, &part);
++  (vm->state).PTTN_REG    = part;
++  return res;
++}
++
+ static int set_FP_PGC(vm_t *vm) {
+   (vm->state).domain = FP_DOMAIN;
+   if (!vm->vmgi->first_play_pgc) {
+diff -Naur libdvdnav.orig/src/vm/vm.h libdvdnav/src/vm/vm.h
+--- libdvdnav.orig/src/vm/vm.h 2009-03-13 18:28:22.000000000 -0700
++++ libdvdnav/src/vm/vm.h      2009-04-30 10:57:02.000000000 -0700
+@@ -139,6 +139,7 @@
+ int vm_jump_pg(vm_t *vm, int pg);
+ int vm_jump_cell_block(vm_t *vm, int cell, int block);
+ int vm_jump_title_part(vm_t *vm, int title, int part);
++int vm_jump_title_program(vm_t *vm, int title, int pgcn, int pgn);
+ int vm_jump_top_pg(vm_t *vm);
+ int vm_jump_next_pg(vm_t *vm);
+ int vm_jump_prev_pg(vm_t *vm);
diff --git a/contrib/libdvdnav/A02-mult-pgc.patch b/contrib/libdvdnav/A02-mult-pgc.patch
new file mode 100644 (file)
index 0000000..5ccaa68
--- /dev/null
@@ -0,0 +1,22 @@
+# the bit tested here does not indicate 'random or shuffle' - it only says
+# that the title uses multiple PGCs. Since libdvdnav mostly deals correctly
+# with mult PGC titles (modulo some weirdness when seeking) we need the
+# state to get set correctly.
+--- libdvdnav/src/vm/vm.c.orig 2009-05-13 20:44:12.000000000 -0700
++++ libdvdnav/src/vm/vm.c      2009-05-13 20:46:02.000000000 -0700
+@@ -1758,14 +1758,10 @@
+     if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts)
+       return 0; /* ?? */
+     pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty;
+-    if(pb_ty->multi_or_random_pgc_title == /* One_Sequential_PGC_Title */ 0) {
++
+       int dummy, part;
+       vm_get_current_title_part(vm, &dummy, &part);
+       (vm->state).PTTN_REG = part;
+-    } else {
+-      /* FIXME: Handle RANDOM or SHUFFLE titles. */
+-      fprintf(MSG_OUT, "libdvdnav: RANDOM or SHUFFLE titles are NOT handled yet.\n");
+-    }
+   }
+   return 1;
+ }
diff --git a/contrib/libdvdnav/A03-quiet.patch b/contrib/libdvdnav/A03-quiet.patch
new file mode 100644 (file)
index 0000000..87a7e77
--- /dev/null
@@ -0,0 +1,21 @@
+diff -Naur libdvdnav.orig/src/vm/vm.c libdvdnav/src/vm/vm.c
+--- libdvdnav.orig/src/vm/vm.c 2009-03-13 18:28:22.000000000 -0700
++++ libdvdnav/src/vm/vm.c      2009-06-02 13:50:06.000000000 -0700
+@@ -354,8 +354,6 @@
+       fprintf(MSG_OUT, "libdvdnav: vm: failed to open/read the DVD\n");
+       return 0;
+     }
+-    dvd_read_name(vm->dvd_name, vm->dvd_serial, dvdroot);
+-    vm->map  = remap_loadmap(vm->dvd_name);
+     vm->vmgi = ifoOpenVMGI(vm->dvd);
+     if(!vm->vmgi) {
+       fprintf(MSG_OUT, "libdvdnav: vm: failed to read VIDEO_TS.IFO\n");
+@@ -386,6 +384,8 @@
+       /* return 0; Not really used for now.. */
+     }
+     /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */
++    dvd_read_name(vm->dvd_name, vm->dvd_serial, dvdroot);
++    vm->map  = remap_loadmap(vm->dvd_name);
+   }
+   if (vm->vmgi) {
+     int i, mask;
diff --git a/contrib/libdvdnav/A04-m4-uid0.patch b/contrib/libdvdnav/A04-m4-uid0.patch
new file mode 100644 (file)
index 0000000..4963827
--- /dev/null
@@ -0,0 +1,28 @@
+diff -Naur libdvdnav.orig/configure.ac libdvdnav/configure.ac
+--- libdvdnav.orig/configure.ac        2009-01-08 14:57:11.000000000 -0800
++++ libdvdnav/configure.ac     2009-08-24 10:20:16.560743586 -0700
+@@ -206,24 +206,6 @@
+ AC_SUBST(DEBUG_CFLAGS)
+-dnl ---------------------------------------------
+-dnl Get where .m4 should be installed.
+-dnl ---------------------------------------------
+-case "`id`" in
+-  uid=0\(* )
+-    AC_MSG_CHECKING(for aclocal directory)
+-    if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+-      ACLOCAL_DIR="`eval $ACLOCAL --print-ac-dir`"
+-      AC_MSG_RESULT($ACLOCAL_DIR)
+-    else
+-      ACLOCAL_DIR="/usr/local/share/aclocal"
+-      AC_MSG_RESULT(none - will be installed in $ACLOCAL_DIR)
+-    fi
+-    escapedprefix="`echo $prefix | sed -e 's/\\//\\\\\//g'`"
+-    ACLOCAL_DIR="`echo $ACLOCAL_DIR|sed -e 's/^'$escapedprefix/'\${prefix}'/`"
+-    AC_SUBST(ACLOCAL_DIR)
+-    ;;
+-esac
+ AM_CONDITIONAL(INSTALL_M4, test x"$ACLOCAL_DIR" != "x")
+ dnl ---------------------------------------------
diff --git a/contrib/libdvdnav/A05-forward-seek.patch b/contrib/libdvdnav/A05-forward-seek.patch
new file mode 100644 (file)
index 0000000..1c45b8e
--- /dev/null
@@ -0,0 +1,100 @@
+diff -Naur libdvdnav.orig/src/searching.c libdvdnav/src/searching.c
+--- libdvdnav.orig/src/searching.c     2009-01-08 14:57:11.000000000 -0800
++++ libdvdnav/src/searching.c  2009-09-12 15:36:14.403299590 -0700
+@@ -47,7 +47,7 @@
+ /* Return placed in vobu. */
+ /* Returns error status */
+ /* FIXME: Maybe need to handle seeking outside current cell. */
+-static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint32_t *vobu) {
++static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, int next, uint32_t *vobu) {
+   vobu_admap_t *admap = NULL;
+ #ifdef LOG_DEBUG
+@@ -89,7 +89,7 @@
+       vobu_start = next_vobu;
+       address++;
+     }
+-    *vobu = vobu_start;
++    *vobu = next ? next_vobu : vobu_start;
+     return DVDNAV_STATUS_OK;
+   }
+   fprintf(MSG_OUT, "libdvdnav: admap not located\n");
+@@ -160,7 +160,7 @@
+     fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
+           cell_nr, first_cell_nr, last_cell_nr);
+ #endif
+-    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
++    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
+       uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
+       if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
+@@ -184,9 +184,13 @@
+ dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
+                                    uint64_t offset, int32_t origin) {
+   uint32_t target = 0;
++  uint32_t current_pos;
++  uint32_t cur_sector;
++  uint32_t cur_cell_nr;
+   uint32_t length = 0;
+   uint32_t first_cell_nr, last_cell_nr, cell_nr;
+   int32_t found;
++  int forward = 0;
+   cell_playback_t *cell;
+   dvd_state_t *state;
+   dvdnav_status_t result;
+@@ -213,6 +217,10 @@
+   fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN);
+ #endif
++  current_pos = target;
++  cur_sector = this->vobu.vobu_start + this->vobu.blockN;
++  cur_cell_nr = state->cellN;
++
+   switch(origin) {
+    case SEEK_SET:
+     if(offset >= length) {
+@@ -244,6 +252,7 @@
+     pthread_mutex_unlock(&this->vm_lock);
+     return DVDNAV_STATUS_ERR;
+   }
++  forward = target > current_pos;
+   this->cur_cell_time = 0;
+   if (this->pgc_based) {
+@@ -270,6 +279,27 @@
+     } else {
+       /* convert the target sector from Cell-relative to absolute physical sector */
+       target += cell->first_sector;
++      if (forward && (cell_nr == cur_cell_nr)) {
++        uint32_t vobu;
++        /* if we are seeking forward from the current position, make sure
++         * we move to a new position that is after our current position.
++         * simply truncating to the vobu will go backwards */
++        if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) != DVDNAV_STATUS_OK)
++          break;
++        if (vobu <= cur_sector) {
++          if (dvdnav_scan_admap(this, state->domain, target, 1, &vobu) != DVDNAV_STATUS_OK)
++            break;
++          if (vobu > cell->last_sector) {
++            if (cell_nr == last_cell_nr)
++              break;
++            cell_nr++;
++            cell =  &(state->pgc->cell_playback[cell_nr-1]);
++            target = cell->first_sector;
++          } else {
++            target = vobu;
++          }
++        }
++      }
+       found = 1;
+       break;
+     }
+@@ -281,7 +311,7 @@
+     fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
+           cell_nr, first_cell_nr, last_cell_nr);
+ #endif
+-    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
++    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
+       int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
+       if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
diff --git a/contrib/libdvdnav/A07-missing-menu.patch b/contrib/libdvdnav/A07-missing-menu.patch
new file mode 100644 (file)
index 0000000..078f474
--- /dev/null
@@ -0,0 +1,110 @@
+diff -Naur libdvdnav.orig/src/vm/vm.c libdvdnav/src/vm/vm.c
+--- libdvdnav.orig/src/vm/vm.c 2009-10-29 09:10:44.836643320 -0700
++++ libdvdnav/src/vm/vm.c      2009-11-16 11:10:07.527247268 -0800
+@@ -585,6 +585,9 @@
+     switch(menuid) {
+     case DVD_MENU_Title:
+     case DVD_MENU_Escape:
++      if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) {
++        goto fail;
++      }
+       (vm->state).domain = VMGM_DOMAIN;
+       break;
+     case DVD_MENU_Root:
+@@ -592,6 +595,9 @@
+     case DVD_MENU_Audio:
+     case DVD_MENU_Angle:
+     case DVD_MENU_Part:
++      if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) {
++        goto fail;
++      }
+       (vm->state).domain = VTSM_DOMAIN;
+       break;
+     }
+@@ -606,6 +612,7 @@
+     break;
+   }
++fail:
+   return 0;
+ }
+@@ -1488,6 +1495,10 @@
+       /* Allowed from anywhere except the VTS Title domain */
+       /* Stop SPRM9 Timer and any GPRM counters */
+       assert((vm->state).domain != VTS_DOMAIN); /* ?? */
++      if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) {
++        link_values.command = Exit;
++        break;
++      }
+       (vm->state).domain = VMGM_DOMAIN;
+       if(!set_MENU(vm, link_values.data1))
+       assert(0);
+@@ -1504,14 +1515,22 @@
+       if (link_values.data1 != (vm->state).vtsN) {
+         /* the normal case */
+         assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
+-        (vm->state).domain = VTSM_DOMAIN;
+         if (!ifoOpenNewVTSI(vm, vm->dvd, link_values.data1))  /* Also sets (vm->state).vtsN */
+           assert(0);
++          if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) {
++            link_values.command = Exit;
++            break;
++          }
++        (vm->state).domain = VTSM_DOMAIN;
+       } else {
+         /* This happens on some discs like "Captain Scarlet & the Mysterons" or
+          * the German RC2 of "Anatomie" in VTSM. */
+         assert((vm->state).domain == VTSM_DOMAIN ||
+           (vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
++          if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) {
++            link_values.command = Exit;
++            break;
++          }
+         (vm->state).domain = VTSM_DOMAIN;
+       }
+       } else {
+@@ -1533,6 +1552,10 @@
+       /* set_PGCN:data1 */
+       /* Stop SPRM9 Timer and any GPRM counters */
+       assert((vm->state).domain != VTS_DOMAIN); /* ?? */
++      if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) {
++        link_values.command = Exit;
++        break;
++      }
+       (vm->state).domain = VMGM_DOMAIN;
+       if(!set_PGCN(vm, link_values.data1))
+       assert(0);
+@@ -1552,6 +1575,10 @@
+       /* set_RSMinfo:data2 */
+       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
+       /* Must be called before domain is changed */
++      if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) {
++        link_values.command = Exit;
++        break;
++      }
+       set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
+       (vm->state).domain = VMGM_DOMAIN;
+       if(!set_MENU(vm, link_values.data1))
+@@ -1563,6 +1590,10 @@
+       /* set_RSMinfo:data2 */
+       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
+       /* Must be called before domain is changed */
++      if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) {
++        link_values.command = Exit;
++        break;
++      }
+       set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
+       (vm->state).domain = VTSM_DOMAIN;
+       if(!set_MENU(vm, link_values.data1))
+@@ -1574,6 +1605,10 @@
+       /* set_RSMinfo:data2 */
+       assert((vm->state).domain == VTS_DOMAIN); /* ?? */
+       /* Must be called before domain is changed */
++      if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) {
++        link_values.command = Exit;
++        break;
++      }
+       set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
+       (vm->state).domain = VMGM_DOMAIN;
+       if(!set_PGCN(vm, link_values.data1))
diff --git a/contrib/libdvdnav/P00-mingw-no-examples.patch b/contrib/libdvdnav/P00-mingw-no-examples.patch
new file mode 100644 (file)
index 0000000..0e06186
--- /dev/null
@@ -0,0 +1,21 @@
+diff -Naur libdvdnav.orig/Makefile.am libdvdnav/Makefile.am
+--- libdvdnav.orig/Makefile.am 2008-10-03 16:11:46.000000000 -0400
++++ libdvdnav/Makefile.am      2009-04-24 02:53:15.000000000 -0400
+@@ -1,7 +1,7 @@
+ include $(top_srcdir)/misc/Makefile.common
+-SUBDIRS = src examples doc misc m4
++SUBDIRS = src doc misc m4
+ EXTRA_DIST = autogen.sh \
+            AUTHORS \
+diff -Naur libdvdnav.orig/configure.ac libdvdnav/configure.ac
+--- libdvdnav.orig/configure.ac        2009-01-08 17:57:11.000000000 -0500
++++ libdvdnav/configure.ac     2009-04-24 02:52:34.000000000 -0400
+@@ -252,5 +252,4 @@
+ misc/relchk.sh
+ m4/Makefile
+ doc/Makefile
+-examples/Makefile
+ ])
diff --git a/contrib/libdvdnav/module.defs b/contrib/libdvdnav/module.defs
new file mode 100644 (file)
index 0000000..4134146
--- /dev/null
@@ -0,0 +1,9 @@
+$(eval $(call import.MODULE.defs,LIBDVDNAV,libdvdnav,LIBDVDREAD))
+$(eval $(call import.CONTRIB.defs,LIBDVDNAV))
+
+LIBDVDNAV.FETCH.url = http://download.m0k.org/handbrake/contrib/libdvdnav-svn1168.tar.gz
+LIBDVDNAV.EXTRACT.tarbase = libdvdnav
+
+LIBDVDNAV.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache; autoreconf -fiv;
+
+LIBDVDNAV.CONFIGURE.extra += --with-dvdread-config=$(call fn.ABSOLUTE,$(CONTRIB.build/)bin/dvdread-config)
diff --git a/contrib/libdvdnav/module.rules b/contrib/libdvdnav/module.rules
new file mode 100644 (file)
index 0000000..8d23cca
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBDVDNAV))
+$(eval $(call import.CONTRIB.rules,LIBDVDNAV))
diff --git a/contrib/libdvdread/A00-volume-name.patch b/contrib/libdvdread/A00-volume-name.patch
new file mode 100644 (file)
index 0000000..af7018e
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur libdvdread.orig/src/dvd_udf.c libdvdread/src/dvd_udf.c
+--- libdvdread.orig/src/dvd_udf.c      2009-01-08 14:57:10.000000000 -0800
++++ libdvdread/src/dvd_udf.c   2009-04-23 13:36:08.000000000 -0700
+@@ -928,7 +928,7 @@
+   if(GetUDFCache(device, PVDCache, 0, pvd))
+     return 1;
+-  if(!UDFGetDescriptor( device, 1, pvd_buf, sizeof(pvd_buf)))
++  if(!UDFGetDescriptor( device, 1, pvd_buf, DVD_VIDEO_LB_LEN))
+     return 0;
+   memcpy(pvd->VolumeIdentifier, &pvd_buf[24], 32);
diff --git a/contrib/libdvdread/A02-msc_ver-defs.patch b/contrib/libdvdread/A02-msc_ver-defs.patch
new file mode 100644 (file)
index 0000000..9d58639
--- /dev/null
@@ -0,0 +1,85 @@
+diff -Naur libdvdread.orig/src/dvd_reader.c libdvdread/src/dvd_reader.c
+--- libdvdread.orig/src/dvd_reader.c   2009-03-13 18:28:21.000000000 -0700
++++ libdvdread/src/dvd_reader.c        2009-09-15 10:15:25.201548319 -0700
+@@ -36,6 +36,7 @@
+ /* misc win32 helpers */
+ #ifdef WIN32
++#include <windows.h>
+ #ifndef HAVE_GETTIMEOFDAY
+ /* replacement gettimeofday implementation */
+ #include <sys/timeb.h>
+@@ -335,7 +336,7 @@
+   char *dev_name = NULL;
+   char *path;
+-#ifdef _MSC_VER
++#ifdef _WIN32
+       int len;
+ #endif
+@@ -349,7 +350,7 @@
+   /* Try to open libdvdcss or fall back to standard functions */
+   have_css = dvdinput_setup();
+-#ifdef _MSC_VER
++#ifdef _WIN32
+   /* Strip off the trailing \ if it is not a drive */
+   len = strlen(path);
+   if ((len > 1) &&
+@@ -447,6 +448,14 @@
+       }
+     }
++#ifdef _WIN32
++    if( strlen( path_copy ) > TITLES_MAX ) {
++      if( !strcasecmp( &(path_copy[ strlen( path_copy ) - TITLES_MAX ]),
++                       "\\video_ts" ) ) {
++        path_copy[ strlen( path_copy ) - (TITLES_MAX-1) ] = '\0';
++      }
++    }
++#else
+     if( strlen( path_copy ) > TITLES_MAX ) {
+       if( !strcasecmp( &(path_copy[ strlen( path_copy ) - TITLES_MAX ]),
+                        "/video_ts" ) ) {
+@@ -458,6 +467,7 @@
+       path_copy[0] = '/';
+       path_copy[1] = '\0';
+     }
++#endif
+ #if defined(SYS_BSD)
+     if( ( fe = getfsfile( path_copy ) ) ) {
+@@ -508,11 +518,14 @@
+       }
+       fclose( mntfile );
+     }
+-#elif defined(_MSC_VER) || defined(__OS2__)
+-    auth_drive = DVDOpenImageFile( path, have_css );
++#elif defined(_WIN32) || defined(__OS2__)
++    if( GetDriveType( path_copy ) == DRIVE_CDROM ) {
++      path_copy[2] = '\0';
++      auth_drive = DVDOpenImageFile( path_copy, have_css );
++    }
+ #endif
+-#if !defined(_MSC_VER) && !defined(__OS2__)
++#if !defined(_WIN32) && !defined(__OS2__)
+     if( !dev_name ) {
+       fprintf( stderr, "libdvdread: Couldn't find device name.\n" );
+     } else if( !auth_drive ) {
+diff -Naur libdvdread.orig/src/dvdread_internal.h libdvdread/src/dvdread_internal.h
+--- libdvdread.orig/src/dvdread_internal.h     2008-10-03 13:11:30.000000000 -0700
++++ libdvdread/src/dvdread_internal.h  2009-09-15 09:44:01.788301485 -0700
+@@ -19,9 +19,9 @@
+ #ifndef LIBDVDREAD_DVDREAD_INTERNAL_H
+ #define LIBDVDREAD_DVDREAD_INTERNAL_H
+-#ifdef _MSC_VER
++#ifdef _WIN32
+ #include <unistd.h>
+-#endif /* _MSC_VER */
++#endif /* _WIN32 */
+ #define CHECK_VALUE(arg)                                                \
+   if(!(arg)) {                                                          \
diff --git a/contrib/libdvdread/A03-m4-uid0.patch b/contrib/libdvdread/A03-m4-uid0.patch
new file mode 100644 (file)
index 0000000..eab2617
--- /dev/null
@@ -0,0 +1,28 @@
+diff -Naur libdvdread.orig/configure.ac libdvdread/configure.ac
+--- libdvdread.orig/configure.ac       2009-01-08 14:57:10.000000000 -0800
++++ libdvdread/configure.ac    2009-08-24 10:17:47.036747814 -0700
+@@ -167,24 +167,6 @@
+ AC_SUBST(DEBUG_CFLAGS)
+-dnl ---------------------------------------------
+-dnl Get where .m4 should be installed.
+-dnl ---------------------------------------------
+-case "`id`" in
+-  uid=0\(* )
+-    AC_MSG_CHECKING(for aclocal directory)
+-    if (aclocal --version) < /dev/null > /dev/null 2>&1; then
+-      ACLOCAL_DIR="`eval $ACLOCAL --print-ac-dir`"
+-      AC_MSG_RESULT($ACLOCAL_DIR)
+-    else
+-      ACLOCAL_DIR="/usr/local/share/aclocal"
+-      AC_MSG_RESULT(none - will be installed in $ACLOCAL_DIR)
+-    fi
+-    escapedprefix="`echo $prefix | sed -e 's/\\//\\\\\//g'`"
+-    ACLOCAL_DIR="`echo $ACLOCAL_DIR|sed -e 's/^'$escapedprefix/'\${prefix}'/`"
+-    AC_SUBST(ACLOCAL_DIR)
+-    ;;
+-esac
+ AM_CONDITIONAL(INSTALL_M4, test x"$ACLOCAL_DIR" != "x")
+ dnl ---------------------------------------------
diff --git a/contrib/libdvdread/A04-dup-lut-pgc.patch b/contrib/libdvdread/A04-dup-lut-pgc.patch
new file mode 100644 (file)
index 0000000..cf34419
--- /dev/null
@@ -0,0 +1,324 @@
+--- libdvdread.orig/src/ifo_read.c     2009-10-29 09:11:32.066743831 -0700
++++ libdvdread/src/ifo_read.c  2009-11-13 10:27:49.293174360 -0800
+@@ -87,9 +87,9 @@
+ static int ifoRead_PGCIT_internal(ifo_handle_t *ifofile, pgcit_t *pgcit,
+                                   unsigned int offset);
+-static void ifoFree_PGC(pgc_t *pgc);
++static void ifoFree_PGC(pgc_t **pgc);
+ static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl);
+-static void ifoFree_PGCIT_internal(pgcit_t *pgcit);
++static void ifoFree_PGCIT_internal(pgcit_t **pgcit);
+ static inline int DVDFileSeekForce_( dvd_file_t *dvd_file, uint32_t offset, int force_size ) {
+   return (DVDFileSeekForce(dvd_file, (int)offset, force_size) == (int)offset);
+@@ -870,7 +870,6 @@
+     if(!ifoRead_PGC_COMMAND_TBL(ifofile, pgc->command_tbl,
+                                 offset + pgc->command_tbl_offset)) {
+-      free(pgc->command_tbl);
+       return 0;
+     }
+   } else {
+@@ -880,13 +879,10 @@
+   if(pgc->program_map_offset != 0 && pgc->nr_of_programs>0) {
+     pgc->program_map = malloc(pgc->nr_of_programs * sizeof(pgc_program_map_t));
+     if(!pgc->program_map) {
+-      ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
+       return 0;
+     }
+     if(!ifoRead_PGC_PROGRAM_MAP(ifofile, pgc->program_map,pgc->nr_of_programs,
+                                 offset + pgc->program_map_offset)) {
+-      ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
+-      free(pgc->program_map);
+       return 0;
+     }
+   } else {
+@@ -896,18 +892,11 @@
+   if(pgc->cell_playback_offset != 0 && pgc->nr_of_cells>0) {
+     pgc->cell_playback = malloc(pgc->nr_of_cells * sizeof(cell_playback_t));
+     if(!pgc->cell_playback) {
+-      ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
+-      if(pgc->program_map)
+-        free(pgc->program_map);
+       return 0;
+     }
+     if(!ifoRead_CELL_PLAYBACK_TBL(ifofile, pgc->cell_playback,
+                                   pgc->nr_of_cells,
+                                   offset + pgc->cell_playback_offset)) {
+-      ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
+-      if(pgc->program_map)
+-        free(pgc->program_map);
+-      free(pgc->cell_playback);
+       return 0;
+     }
+   } else {
+@@ -917,13 +906,11 @@
+   if(pgc->cell_position_offset != 0 && pgc->nr_of_cells>0) {
+     pgc->cell_position = malloc(pgc->nr_of_cells * sizeof(cell_position_t));
+     if(!pgc->cell_position) {
+-      ifoFree_PGC(pgc);
+       return 0;
+     }
+     if(!ifoRead_CELL_POSITION_TBL(ifofile, pgc->cell_position,
+                                   pgc->nr_of_cells,
+                                   offset + pgc->cell_position_offset)) {
+-      ifoFree_PGC(pgc);
+       return 0;
+     }
+   } else {
+@@ -946,29 +933,33 @@
+   if(ifofile->vmgi_mat->first_play_pgc == 0)
+     return 1;
+-  ifofile->first_play_pgc = (pgc_t *)malloc(sizeof(pgc_t));
++  ifofile->first_play_pgc = (pgc_t *)calloc(1, sizeof(pgc_t));
+   if(!ifofile->first_play_pgc)
+     return 0;
++  ifofile->first_play_pgc->ref_count = 1;
+   if(!ifoRead_PGC(ifofile, ifofile->first_play_pgc,
+                   ifofile->vmgi_mat->first_play_pgc)) {
+-    free(ifofile->first_play_pgc);
+-    ifofile->first_play_pgc = 0;
++    ifoFree_PGC(&ifofile->first_play_pgc);
+     return 0;
+   }
+   return 1;
+ }
+-static void ifoFree_PGC(pgc_t *pgc) {
+-  if(pgc) {
+-    ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
+-    if(pgc->program_map)
+-      free(pgc->program_map);
+-    if(pgc->cell_playback)
+-      free(pgc->cell_playback);
+-    if(pgc->cell_position)
+-      free(pgc->cell_position);
++static void ifoFree_PGC(pgc_t **pgc) {
++  if(pgc && *pgc && (--(*pgc)->ref_count) <= 0) {
++    ifoFree_PGC_COMMAND_TBL((*pgc)->command_tbl);
++    if((*pgc)->program_map)
++      free((*pgc)->program_map);
++    if((*pgc)->cell_playback)
++      free((*pgc)->cell_playback);
++    if((*pgc)->cell_position)
++      free((*pgc)->cell_position);
++    free(*pgc);
++  }
++  if (pgc) {
++    *pgc = NULL;
+   }
+ }
+@@ -977,9 +968,7 @@
+     return;
+   if(ifofile->first_play_pgc) {
+-    ifoFree_PGC(ifofile->first_play_pgc);
+-    free(ifofile->first_play_pgc);
+-    ifofile->first_play_pgc = 0;
++    ifoFree_PGC(&ifofile->first_play_pgc);
+   }
+ }
+@@ -1202,6 +1191,13 @@
+       CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgcn < 1000); /* ?? */
+       CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgn != 0);
+       CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgn < 100); /* ?? */
++      if (vts_ptt_srpt->title[i].ptt[j].pgcn == 0 ||
++          vts_ptt_srpt->title[i].ptt[j].pgcn >= 1000 ||
++          vts_ptt_srpt->title[i].ptt[j].pgn == 0 ||
++          vts_ptt_srpt->title[i].ptt[j].pgn >= 100) {
++        return 0;
++      }
++
+     }
+   }
+@@ -1372,7 +1368,6 @@
+   if(ifofile->vtsi_mat->vts_tmapt == 0) { /* optional(?) */
+     ifofile->vts_tmapt = NULL;
+-    fprintf(stderr,"Please send bug report - no VTS_TMAPT ?? \n");
+     return 1;
+   }
+@@ -1756,10 +1751,11 @@
+   if(ifofile->vtsi_mat->vts_pgcit == 0) /* mandatory */
+     return 0;
+-  ifofile->vts_pgcit = (pgcit_t *)malloc(sizeof(pgcit_t));
++  ifofile->vts_pgcit = (pgcit_t *)calloc(1, sizeof(pgcit_t));
+   if(!ifofile->vts_pgcit)
+     return 0;
++  ifofile->vts_pgcit->ref_count = 1;
+   if(!ifoRead_PGCIT_internal(ifofile, ifofile->vts_pgcit,
+                              ifofile->vtsi_mat->vts_pgcit * DVD_BLOCK_LEN)) {
+     free(ifofile->vts_pgcit);
+@@ -1770,6 +1766,17 @@
+   return 1;
+ }
++static int find_dup_pgc(pgci_srp_t *pgci_srp, uint32_t start_byte, int count) {
++  int i;
++
++  for(i = 0; i < count; i++) {
++    if(pgci_srp[i].pgc_start_byte == start_byte) {
++      return i;
++    }
++  }
++  return -1;
++}
++
+ static int ifoRead_PGCIT_internal(ifo_handle_t *ifofile, pgcit_t *pgcit,
+                                   unsigned int offset) {
+   int i, info_length;
+@@ -1818,21 +1825,26 @@
+     CHECK_VALUE(pgcit->pgci_srp[i].pgc_start_byte + PGC_SIZE <= pgcit->last_byte+1);
+   for(i = 0; i < pgcit->nr_of_pgci_srp; i++) {
+-    pgcit->pgci_srp[i].pgc = malloc(sizeof(pgc_t));
++    int dup;
++    if((dup = find_dup_pgc(pgcit->pgci_srp, pgcit->pgci_srp[i].pgc_start_byte, i)) >= 0) {
++      pgcit->pgci_srp[i].pgc = pgcit->pgci_srp[dup].pgc;
++      pgcit->pgci_srp[i].pgc->ref_count++;
++      continue;
++    }
++    pgcit->pgci_srp[i].pgc = calloc(1, sizeof(pgc_t));
+     if(!pgcit->pgci_srp[i].pgc) {
+       int j;
+       for(j = 0; j < i; j++) {
+-        ifoFree_PGC(pgcit->pgci_srp[j].pgc);
+-        free(pgcit->pgci_srp[j].pgc);
++        ifoFree_PGC(&pgcit->pgci_srp[j].pgc);
+       }
+       goto fail;
+     }
++    pgcit->pgci_srp[i].pgc->ref_count = 1;
+     if(!ifoRead_PGC(ifofile, pgcit->pgci_srp[i].pgc,
+                     offset + pgcit->pgci_srp[i].pgc_start_byte)) {
+       int j;
+-      for(j = 0; j < i; j++) {
+-        ifoFree_PGC(pgcit->pgci_srp[j].pgc);
+-        free(pgcit->pgci_srp[j].pgc);
++      for(j = 0; j <= i; j++) {
++        ifoFree_PGC(&pgcit->pgci_srp[j].pgc);
+       }
+       goto fail;
+     }
+@@ -1845,12 +1857,16 @@
+   return 0;
+ }
+-static void ifoFree_PGCIT_internal(pgcit_t *pgcit) {
+-  if(pgcit) {
++static void ifoFree_PGCIT_internal(pgcit_t **pgcit) {
++  if(pgcit && *pgcit && (--(*pgcit)->ref_count <= 0)) {
+     int i;
+-    for(i = 0; i < pgcit->nr_of_pgci_srp; i++)
+-      ifoFree_PGC(pgcit->pgci_srp[i].pgc);
+-    free(pgcit->pgci_srp);
++    for(i = 0; i < (*pgcit)->nr_of_pgci_srp; i++)
++      ifoFree_PGC(&(*pgcit)->pgci_srp[i].pgc);
++    free((*pgcit)->pgci_srp);
++    free(*pgcit);
++  }
++  if (pgcit) {
++    *pgcit = NULL;
+   }
+ }
+@@ -1859,12 +1875,20 @@
+     return;
+   if(ifofile->vts_pgcit) {
+-    ifoFree_PGCIT_internal(ifofile->vts_pgcit);
+-    free(ifofile->vts_pgcit);
+-    ifofile->vts_pgcit = 0;
++    ifoFree_PGCIT_internal(&ifofile->vts_pgcit);
+   }
+ }
++static int find_dup_lut(pgci_lu_t *lu, uint32_t start_byte, int count) {
++  int i;
++
++  for(i = 0; i < count; i++) {
++    if(lu[i].lang_start_byte == start_byte) {
++      return i;
++    }
++  }
++  return -1;
++}
+ int ifoRead_PGCI_UT(ifo_handle_t *ifofile) {
+   pgci_ut_t *pgci_ut;
+@@ -1958,27 +1982,31 @@
+   }
+   for(i = 0; i < pgci_ut->nr_of_lus; i++) {
++    int dup;
++    if((dup = find_dup_lut(pgci_ut->lu, pgci_ut->lu[i].lang_start_byte, i)) >= 0) {
++      pgci_ut->lu[i].pgcit = pgci_ut->lu[dup].pgcit;
++      pgci_ut->lu[i].pgcit->ref_count++;
++      continue;
++    }
+     pgci_ut->lu[i].pgcit = malloc(sizeof(pgcit_t));
+     if(!pgci_ut->lu[i].pgcit) {
+       unsigned int j;
+       for(j = 0; j < i; j++) {
+-        ifoFree_PGCIT_internal(pgci_ut->lu[j].pgcit);
+-        free(pgci_ut->lu[j].pgcit);
++        ifoFree_PGCIT_internal(&pgci_ut->lu[j].pgcit);
+       }
+       free(pgci_ut->lu);
+       free(pgci_ut);
+       ifofile->pgci_ut = 0;
+       return 0;
+     }
++    pgci_ut->lu[i].pgcit->ref_count = 1;
+     if(!ifoRead_PGCIT_internal(ifofile, pgci_ut->lu[i].pgcit,
+                                sector * DVD_BLOCK_LEN
+                                + pgci_ut->lu[i].lang_start_byte)) {
+       unsigned int j;
+-      for(j = 0; j < i; j++) {
+-        ifoFree_PGCIT_internal(pgci_ut->lu[j].pgcit);
+-        free(pgci_ut->lu[j].pgcit);
++      for(j = 0; j <= i; j++) {
++        ifoFree_PGCIT_internal(&pgci_ut->lu[j].pgcit);
+       }
+-      free(pgci_ut->lu[i].pgcit);
+       free(pgci_ut->lu);
+       free(pgci_ut);
+       ifofile->pgci_ut = 0;
+@@ -2000,8 +2028,7 @@
+   if(ifofile->pgci_ut) {
+     for(i = 0; i < ifofile->pgci_ut->nr_of_lus; i++) {
+-      ifoFree_PGCIT_internal(ifofile->pgci_ut->lu[i].pgcit);
+-      free(ifofile->pgci_ut->lu[i].pgcit);
++      ifoFree_PGCIT_internal(&ifofile->pgci_ut->lu[i].pgcit);
+     }
+     free(ifofile->pgci_ut->lu);
+     free(ifofile->pgci_ut);
+--- libdvdread.orig/src/dvdread/ifo_types.h    2009-10-29 09:11:32.161557143 -0700
++++ libdvdread/src/dvdread/ifo_types.h 2009-11-13 09:13:10.255237710 -0800
+@@ -301,6 +301,7 @@
+   pgc_program_map_t  *program_map;
+   cell_playback_t *cell_playback;
+   cell_position_t *cell_position;
++  int      ref_count;
+ } ATTRIBUTE_PACKED pgc_t;
+ #define PGC_SIZE 236U
+@@ -326,6 +327,7 @@
+   uint16_t zero_1;
+   uint32_t last_byte;
+   pgci_srp_t *pgci_srp;
++  int      ref_count;
+ } ATTRIBUTE_PACKED pgcit_t;
+ #define PGCIT_SIZE 8U
diff --git a/contrib/libdvdread/P00-darwin-css-vlc-dylib.patch b/contrib/libdvdread/P00-darwin-css-vlc-dylib.patch
new file mode 100644 (file)
index 0000000..d6c5f6d
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur libdvdread.orig/src/dvd_input.c libdvdread/src/dvd_input.c
+--- libdvdread.orig/src/dvd_input.c    2009-01-08 14:57:10.000000000 -0800
++++ libdvdread/src/dvd_input.c 2009-04-24 09:02:34.000000000 -0700
+@@ -285,7 +285,7 @@
+   /* dlopening libdvdcss */
+ #ifdef __APPLE__
+-  #define CSS_LIB "libdvdcss.2.dylib"
++  #define CSS_LIB "/Applications/VLC.app/Contents/MacOS/lib/libdvdcss.2.dylib"
+ #elif defined(WIN32)
+   #define CSS_LIB "libdvdcss.dll"
+ #elif defined(__OS2__)
diff --git a/contrib/libdvdread/P05-mingw-large-file.patch b/contrib/libdvdread/P05-mingw-large-file.patch
new file mode 100644 (file)
index 0000000..480d1e9
--- /dev/null
@@ -0,0 +1,28 @@
+diff -Naur libdvdread.orig/src/dvd_input.h libdvdread/src/dvd_input.h
+--- libdvdread.orig/src/dvd_input.h    2008-10-03 13:11:30.000000000 -0700
++++ libdvdread/src/dvd_input.h 2009-04-23 13:47:04.000000000 -0700
+@@ -29,6 +29,24 @@
+ #define DVDINPUT_READ_DECRYPT    (1 << 0)
++#if defined( __MINGW32__ )
++#   undef  lseek
++#   define lseek  _lseeki64
++#   undef  fseeko
++#   define fseeko fseeko64
++#   undef  ftello
++#   define ftello ftello64
++#   define flockfile(...)
++#   define funlockfile(...)
++#   define getc_unlocked getc
++#   undef  off_t
++#   define off_t off64_t
++#   undef  stat
++#   define stat  _stati64
++#   define fstat _fstati64
++#   define wstat _wstati64
++#endif
++
+ typedef struct dvd_input_s *dvd_input_t;
+ /**
diff --git a/contrib/libdvdread/P06-darwin.patch b/contrib/libdvdread/P06-darwin.patch
new file mode 100644 (file)
index 0000000..b6efc2e
--- /dev/null
@@ -0,0 +1,25 @@
+diff -Naur libdvdread.orig/configure.ac libdvdread/configure.ac
+--- libdvdread.orig/configure.ac       2009-01-08 17:57:10.000000000 -0500
++++ libdvdread/configure.ac    2009-04-24 01:50:56.000000000 -0400
+@@ -145,6 +145,9 @@
+   *cygwin*)
+     LDFLAGS="-no-undefined $LDFLAGS"
+     ;;
++  *darwin*)
++    CFLAGS="${CFLAGS} -D__DARWIN__"
++    ;;
+   *os2*)
+     LDFLAGS="-no-undefined -Zbin-files $LDFLAGS"
+     ;;
+diff -Naur libdvdread.orig/src/dvd_reader.c libdvdread/src/dvd_reader.c
+--- libdvdread.orig/src/dvd_reader.c   2009-03-13 21:28:21.000000000 -0400
++++ libdvdread/src/dvd_reader.c        2009-04-24 01:35:43.000000000 -0400
+@@ -314,7 +314,7 @@
+   char *new_path;
+   /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */
+-  if( !strncmp( path, "/dev/",  5 ) || strncmp( path, "/dev/r", 6 ) )
++  if( strncmp( path, "/dev/",  5 ) || !strncmp( path, "/dev/r", 6 ) )
+     return (char *) strdup( path );
+   /* Replace "/dev/" with "/dev/r" */
diff --git a/contrib/libdvdread/module.defs b/contrib/libdvdread/module.defs
new file mode 100644 (file)
index 0000000..3db333b
--- /dev/null
@@ -0,0 +1,7 @@
+$(eval $(call import.MODULE.defs,LIBDVDREAD,libdvdread))
+$(eval $(call import.CONTRIB.defs,LIBDVDREAD))
+
+LIBDVDREAD.FETCH.url = http://download.m0k.org/handbrake/contrib/libdvdread-svn1168.tar.gz
+LIBDVDREAD.EXTRACT.tarbase = libdvdread
+
+LIBDVDREAD.CONFIGURE.bootstrap = rm -fr aclocal.m4 autom4te.cache; autoreconf -fiv;
diff --git a/contrib/libdvdread/module.rules b/contrib/libdvdread/module.rules
new file mode 100644 (file)
index 0000000..6a9b42b
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBDVDREAD))
+$(eval $(call import.CONTRIB.rules,LIBDVDREAD))
diff --git a/contrib/libiconv/module.defs b/contrib/libiconv/module.defs
new file mode 100644 (file)
index 0000000..4d6748f
--- /dev/null
@@ -0,0 +1,4 @@
+$(eval $(call import.MODULE.defs,LIBICONV,libiconv))
+$(eval $(call import.CONTRIB.defs,LIBICONV))
+
+LIBICONV.FETCH.url = http://download.m0k.org/handbrake/contrib/libiconv-1.13.tar.bz2
diff --git a/contrib/libiconv/module.rules b/contrib/libiconv/module.rules
new file mode 100644 (file)
index 0000000..397d053
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBICONV))
+$(eval $(call import.CONTRIB.rules,LIBICONV))
diff --git a/contrib/libmkv/P00-mingw-large-file.patch b/contrib/libmkv/P00-mingw-large-file.patch
new file mode 100644 (file)
index 0000000..6a83eac
--- /dev/null
@@ -0,0 +1,24 @@
+--- libmkv.orig/src/matroska.c 2009-01-12 23:14:26.000000000 -0800
++++ libmkv/src/matroska.c      2009-03-25 15:22:30.000000000 -0700
+@@ -27,6 +27,11 @@
+ #include <sys/time.h>
++#if defined( __MINGW32__ )
++#undef fseeko
++#define fseeko fseeko64
++#endif
++
+ #define RESERVED_SEEKHEAD 0x100
+ /* 256 bytes should be enough room for our Seek entries. */
+ #define RESERVED_CHAPTERS 0x800
+@@ -34,7 +39,7 @@
+ int mk_seekFile(mk_Writer *w, uint64_t pos)
+ {
+-      if (fseek(w->fp, pos, SEEK_SET))
++      if (fseeko(w->fp, pos, SEEK_SET))
+               return -1;
+       w->f_pos = pos;
+
diff --git a/contrib/libmkv/module.defs b/contrib/libmkv/module.defs
new file mode 100644 (file)
index 0000000..3805d25
--- /dev/null
@@ -0,0 +1,4 @@
+$(eval $(call import.MODULE.defs,LIBMKV,libmkv))
+$(eval $(call import.CONTRIB.defs,LIBMKV))
+
+LIBMKV.FETCH.url = http://download.m0k.org/handbrake/contrib/libmkv-0.6.4.tar.bz2
diff --git a/contrib/libmkv/module.rules b/contrib/libmkv/module.rules
new file mode 100644 (file)
index 0000000..7f443fe
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBMKV))
+$(eval $(call import.CONTRIB.rules,LIBMKV))
diff --git a/contrib/libogg/module.defs b/contrib/libogg/module.defs
new file mode 100644 (file)
index 0000000..0edc410
--- /dev/null
@@ -0,0 +1,7 @@
+$(eval $(call import.MODULE.defs,LIBOGG,libogg))
+$(eval $(call import.CONTRIB.defs,LIBOGG))
+
+LIBOGG.FETCH.url = http://download.m0k.org/handbrake/contrib/libogg-1.1.3.tar.gz
+LIBOGG.EXTRACT.tarbase = libogg
+
+LIBOGG.CONFIGURE.extra = --disable-sdl
diff --git a/contrib/libogg/module.rules b/contrib/libogg/module.rules
new file mode 100644 (file)
index 0000000..956fe07
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBOGG))
+$(eval $(call import.CONTRIB.rules,LIBOGG))
diff --git a/contrib/libsamplerate/module.defs b/contrib/libsamplerate/module.defs
new file mode 100644 (file)
index 0000000..c0717df
--- /dev/null
@@ -0,0 +1,5 @@
+$(eval $(call import.MODULE.defs,LIBSAMPLERATE,libsamplerate))
+$(eval $(call import.CONTRIB.defs,LIBSAMPLERATE))
+
+LIBSAMPLERATE.FETCH.url = http://download.m0k.org/handbrake/contrib/libsamplerate-0.1.4.tar.gz
+LIBSAMPLERATE.EXTRACT.tarbase = libsamplerate
diff --git a/contrib/libsamplerate/module.rules b/contrib/libsamplerate/module.rules
new file mode 100644 (file)
index 0000000..ef63385
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBSAMPLERATE))
+$(eval $(call import.CONTRIB.rules,LIBSAMPLERATE))
diff --git a/contrib/libtheora/module.defs b/contrib/libtheora/module.defs
new file mode 100644 (file)
index 0000000..e3af528
--- /dev/null
@@ -0,0 +1,13 @@
+$(eval $(call import.MODULE.defs,LIBTHEORA,libtheora,LIBOGG LIBVORBIS))
+$(eval $(call import.CONTRIB.defs,LIBTHEORA))
+
+LIBTHEORA.FETCH.url = http://download.m0k.org/handbrake/contrib/libtheora-1.1.0.tar.bz2
+
+LIBTHEORA.CONFIGURE.extra = \
+    --disable-examples \
+    --disable-oggtest \
+    --disable-sdltest \
+    --disable-vorbistest \
+    --with-ogg=$(call fn.ABSOLUTE,$(CONTRIB.build/)) \
+    --with-vorbis=$(call fn.ABSOLUTE,$(CONTRIB.build/)) \
+    HAVE_PKG_CONFIG=no
diff --git a/contrib/libtheora/module.rules b/contrib/libtheora/module.rules
new file mode 100644 (file)
index 0000000..c30224b
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBTHEORA))
+$(eval $(call import.CONTRIB.rules,LIBTHEORA))
diff --git a/contrib/libvorbis/A00-disable-examples.patch b/contrib/libvorbis/A00-disable-examples.patch
new file mode 100644 (file)
index 0000000..7c163a8
--- /dev/null
@@ -0,0 +1,12 @@
+diff -Naur libvorbis.orig/Makefile.in libvorbis/Makefile.in
+--- libvorbis.orig/Makefile.in 2007-09-14 02:02:10.000000000 -0400
++++ libvorbis/Makefile.in      2009-03-04 21:20:22.000000000 -0500
+@@ -223,7 +223,7 @@
+ target_os = @target_os@
+ target_vendor = @target_vendor@
+ AUTOMAKE_OPTIONS = foreign dist-zip
+-SUBDIRS = lib include doc examples vq
++SUBDIRS = lib include doc vq
+ m4datadir = $(datadir)/aclocal
+ m4data_DATA = vorbis.m4
+ pkgconfigdir = $(libdir)/pkgconfig
diff --git a/contrib/libvorbis/module.defs b/contrib/libvorbis/module.defs
new file mode 100644 (file)
index 0000000..df7339c
--- /dev/null
@@ -0,0 +1,7 @@
+$(eval $(call import.MODULE.defs,LIBVORBIS,libvorbis,LIBOGG))
+$(eval $(call import.CONTRIB.defs,LIBVORBIS))
+
+LIBVORBIS.FETCH.url = http://download.m0k.org/handbrake/contrib/libvorbis-aotuv_b5.tar.gz
+LIBVORBIS.EXTRACT.tarbase = libvorbis
+
+LIBVORBIS.CONFIGURE.extra = --with-ogg=$(call fn.ABSOLUTE,$(CONTRIB.build/)) HAVE_PKG_CONFIG="no"
diff --git a/contrib/libvorbis/module.rules b/contrib/libvorbis/module.rules
new file mode 100644 (file)
index 0000000..418dfe0
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,LIBVORBIS))
+$(eval $(call import.CONTRIB.rules,LIBVORBIS))
diff --git a/contrib/mp4v2/module.defs b/contrib/mp4v2/module.defs
new file mode 100644 (file)
index 0000000..c27f347
--- /dev/null
@@ -0,0 +1,17 @@
+$(eval $(call import.MODULE.defs,MP4V2,mp4v2))
+$(eval $(call import.CONTRIB.defs,MP4V2))
+
+MP4V2.FETCH.url = http://download.m0k.org/handbrake/contrib/mp4v2-trunk-r355.tar.bz2
+
+## propagate more flags
+MP4V2.CONFIGURE.env.CFLAGS = CFLAGS="$(call fn.ARGS,MP4V2.GCC,*archs *sysroot *minver *D .g .O)"
+MP4V2.CONFIGURE.env.CXXFLAGS = CXXFLAGS="$(call fn.ARGS,MP4V2.GCC,*archs *sysroot *minver *D .g .O)"
+
+## save some build-time by disabling utils
+MP4V2.CONFIGURE.extra += --disable-util
+
+## make sure gch is disabled; we get build errors on linux with gcc-4.3.x and -g3
+## relatively safe to enable for darwin as it is unlikely to have that bugged version
+ifneq (darwin,$(BUILD.system))
+    MP4V2.CONFIGURE.extra += --disable-gch
+endif
diff --git a/contrib/mp4v2/module.rules b/contrib/mp4v2/module.rules
new file mode 100644 (file)
index 0000000..95686c4
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,MP4V2))
+$(eval $(call import.CONTRIB.rules,MP4V2))
diff --git a/contrib/mpeg2dec/A00-tags.patch b/contrib/mpeg2dec/A00-tags.patch
new file mode 100644 (file)
index 0000000..0b5d7d7
--- /dev/null
@@ -0,0 +1,27 @@
+diff -ru mpeg2dec.orig/libmpeg2/decode.c mpeg2dec/libmpeg2/decode.c
+--- mpeg2dec.orig/libmpeg2/decode.c    2008-07-09 12:16:05.000000000 -0700
++++ mpeg2dec/libmpeg2/decode.c 2009-07-03 16:29:48.000000000 -0700
+@@ -212,7 +212,7 @@
+ mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec)
+ {
+-    static int (* process_header[]) (mpeg2dec_t * mpeg2dec) = {
++    static int (* process_header[]) (mpeg2dec_t *) = {
+       mpeg2_header_picture, mpeg2_header_extension, mpeg2_header_user_data,
+       mpeg2_header_sequence, NULL, NULL, NULL, NULL, mpeg2_header_gop
+     };
+@@ -368,6 +368,14 @@
+ void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2)
+ {
++    if (mpeg2dec->num_tags == 0 && mpeg2dec->state == STATE_PICTURE && mpeg2dec->picture) {
++        // since tags got processed when we entered this state we
++        // have to set them directly or they'll end up on the next frame.
++        mpeg2dec->picture->tag = tag;
++        mpeg2dec->picture->tag2 = tag2;
++        mpeg2dec->picture->flags |= PIC_FLAG_TAGS;
++        return;
++    }
+     mpeg2dec->tag_previous = mpeg2dec->tag_current;
+     mpeg2dec->tag2_previous = mpeg2dec->tag2_current;
+     mpeg2dec->tag_current = tag;
diff --git a/contrib/mpeg2dec/module.defs b/contrib/mpeg2dec/module.defs
new file mode 100644 (file)
index 0000000..5d608cc
--- /dev/null
@@ -0,0 +1,7 @@
+$(eval $(call import.MODULE.defs,MPEG2DEC,mpeg2dec))
+$(eval $(call import.CONTRIB.defs,MPEG2DEC))
+
+MPEG2DEC.FETCH.url = http://download.m0k.org/handbrake/contrib/mpeg2dec-0.5.1.tar.gz
+MPEG2DEC.EXTRACT.tarbase = mpeg2dec
+
+MPEG2DEC.CONFIGURE.extra = --disable-sdl --without-x
diff --git a/contrib/mpeg2dec/module.rules b/contrib/mpeg2dec/module.rules
new file mode 100644 (file)
index 0000000..78ce10a
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,MPEG2DEC))
+$(eval $(call import.CONTRIB.rules,MPEG2DEC))
diff --git a/contrib/pthreadw32/module.defs b/contrib/pthreadw32/module.defs
new file mode 100644 (file)
index 0000000..0768da6
--- /dev/null
@@ -0,0 +1,25 @@
+$(eval $(call import.MODULE.defs,PTHREADW32,pthreadw32))
+$(eval $(call import.CONTRIB.defs,PTHREADW32))
+
+PTHREADW32.FETCH.url = http://download.m0k.org/handbrake/contrib/pthreads-w32-2-8-0-release.tar.gz
+
+PTHREADW32.CONFIGURE = $(TOUCH.exe) $@
+
+PTHREADW32.BUILD.extra = CROSS=$(BUILD.cross.prefix) clean GC-static
+PTHREADW32.BUILD.ntargets = clean GC-static
+
+define PTHREADW32.INSTALL
+    $(CP.exe) $(PTHREADW32.EXTRACT.dir/)libpthreadGC2.a $(CONTRIB.build/)lib/
+    $(CP.exe) $(PTHREADW32.EXTRACT.dir/)pthread.h $(CONTRIB.build/)include/
+    $(CP.exe) $(PTHREADW32.EXTRACT.dir/)sched.h $(CONTRIB.build/)include/
+    $(CP.exe) $(PTHREADW32.EXTRACT.dir/)semaphore.h $(CONTRIB.build/)include/
+    $(TOUCH.exe) $@
+endef
+
+define PTHREADW32.UNINSTALL
+    $(RM.exe) -f $(CONTRIB.build/)lib/libpthreadGC2.a
+    $(RM.exe) -f $(CONTRIB.build/)include/pthread.h
+    $(RM.exe) -f $(CONTRIB.build/)include/sched.h
+    $(RM.exe) -f $(CONTRIB.build/)include/semaphore.h
+    $(RM.exe) -f $(PTHREADW32.INSTALL.target)
+endef
diff --git a/contrib/pthreadw32/module.rules b/contrib/pthreadw32/module.rules
new file mode 100644 (file)
index 0000000..7844883
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,PTHREADW32))
+$(eval $(call import.CONTRIB.rules,PTHREADW32))
diff --git a/contrib/x264/P01-solaris.patch b/contrib/x264/P01-solaris.patch
new file mode 100644 (file)
index 0000000..3c0e1da
--- /dev/null
@@ -0,0 +1,31 @@
+diff -ru x264/Makefile x264.solaris/Makefile
+--- x264/Makefile      Mon Jun  9 01:36:08 2008
++++ x264.solaris/Makefile      Thu Jun 19 11:54:53 2008
+@@ -150,8 +150,10 @@
+       $(MAKE) -C gtk distclean
+ install: x264$(EXE) $(SONAME)
+-      install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
+-      install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
++      install -d $(DESTDIR)$(bindir) 
++      install -d $(DESTDIR)$(includedir)
++      install -d $(DESTDIR)$(libdir) 
++      install -d $(DESTDIR)$(libdir)/pkgconfig
+       install -m 644 x264.h $(DESTDIR)$(includedir)
+       install -m 644 libx264.a $(DESTDIR)$(libdir)
+       install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
+diff -ru x264/configure x264.solaris/configure
+--- x264/configure     Tue Aug 12 03:26:58 2008
++++ x264.modified/configure    Tue Aug 19 16:09:32 2008
+@@ -329,8 +327,10 @@
+ echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
+ $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
+-grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
++/usr/bin/tr -cd "BIGE" < conftest.o | /usr/xpg4/bin/grep -q BIGE && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
++echo $CFLAGS
++
+ # autodetect options that weren't forced nor disabled
+ libpthread=""
diff --git a/contrib/x264/module.defs b/contrib/x264/module.defs
new file mode 100644 (file)
index 0000000..fc7c56c
--- /dev/null
@@ -0,0 +1,19 @@
+$(eval $(call import.MODULE.defs,X264,x264,PTHREADW32))
+$(eval $(call import.CONTRIB.defs,X264))
+
+X264.FETCH.url = http://download.handbrake.fr/handbrake/contrib/x264-r1347-5ddd61b.tar.gz
+X264.EXTRACT.tarbase = x264
+
+X264.CONFIGURE.deps   =
+X264.CONFIGURE.shared =
+X264.CONFIGURE.static =
+
+X264.CONFIGURE.extra = --disable-mp4-output
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+    X264.CONFIGURE.extra += --enable-pthread --cross-prefix=$(BUILD.spec)-
+    X264.CONFIGURE.env.CFLAGS = CFLAGS="-I$(call fn.ABSOLUTE,$(CONTRIB.build/)include) $(call fn.ARGS,X264.GCC,*archs *sysroot *minver ?extra)"
+    X264.CONFIGURE.env.LDFLAGS = LDFLAGS="-L$(call fn.ABSOLUTE,$(CONTRIB.build/)lib) $(call fn.ARGS,X264.GCC,*archs *sysroot *minver)"
+else
+    X264.CONFIGURE.extra += --enable-pthread
+endif
diff --git a/contrib/x264/module.rules b/contrib/x264/module.rules
new file mode 100644 (file)
index 0000000..182ede8
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,X264))
+$(eval $(call import.CONTRIB.rules,X264))
diff --git a/contrib/zlib/module.defs b/contrib/zlib/module.defs
new file mode 100644 (file)
index 0000000..55daf6d
--- /dev/null
@@ -0,0 +1,12 @@
+$(eval $(call import.MODULE.defs,ZLIB,zlib))
+$(eval $(call import.CONTRIB.defs,ZLIB))
+
+ZLIB.FETCH.url = http://download.m0k.org/handbrake/contrib/zlib-1.2.3.tar.gz
+ZLIB.EXTRACT.tarbase = zlib
+ZLIB.CONFIGURE.args = !sete @dir !env !exe @prefix !extra
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+    ZLIB.CONFIGURE.env.AR     = AR="$(AR.exe) rc"
+    ZLIB.CONFIGURE.env.RANLIB = RANLIB="$(RANLIB.exe)"
+    ZLIB.CONFIGURE.env.args  += !AR !RANLIB
+endif
diff --git a/contrib/zlib/module.rules b/contrib/zlib/module.rules
new file mode 100644 (file)
index 0000000..5767ee6
--- /dev/null
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,ZLIB))
+$(eval $(call import.CONTRIB.rules,ZLIB))
diff --git a/doc/BUILD-Cygwin b/doc/BUILD-Cygwin
new file mode 100644 (file)
index 0000000..7f03ca8
--- /dev/null
@@ -0,0 +1,471 @@
+Guide to Building HandBrake svn2591 (2009062101) on Cygwin
+**********************************************************
+
+Table of Contents
+*****************
+
+1 Introduction
+2 Prerequisites
+3 QuickStart
+4 Overview
+5 Building via Terminal
+  5.1 Checkout Sources
+  5.2 Configure
+  5.3 Build
+  5.4 Make Targets
+    5.4.1 Global
+    5.4.2 General Modules
+    5.4.3 Contrib Modules
+    5.4.4 Contrib Touch and Untouch
+    5.4.5 Contrib Aggregates
+  5.5 Customizing Make
+6 Troubleshooting
+Appendix A Project Repository Details
+
+
+1 Introduction
+**************
+
+This guide documents the recommended process to build HandBrake on
+Cygwin hosts from the official source-code repository. Building from
+any other source is not supported.
+
+2 Prerequisites
+***************
+
+The following are the recommended specifications for building on
+Cygwin; but is not necessarily the only configuration that is possible:
+
+   * Intel 32-bit or 64-bit hardware (only 32-bit product binaries are
+     supported)
+
+   * Cygwin, gcc 4.2.4
+
+   * yasm 0.7.2.2153 (for i386 or x86_64 architectures)
+
+     Note: It is recommended to use the platform distribution's bundled
+     compiler for maximum C++ compatibility. If you build with a custom
+     compiler it will likely introduce non-standard runtime
+     requirements. There are of course many valid reasons to build with
+     unbundled compilers, but be aware it is generally unsupported and
+     left as an exercise to the reader.
+
+     Note: As of this writing, Cygwin has available to it several
+     versions of gcc; only one of which may be found and used in the
+     path as `gcc' and `g++'. Configure will thus find what is probably
+     the older version of gcc in a typical Cygwin environment. If you
+     desire to build with the newer gcc, it is found in the path as
+     `gcc-4' and `g++-4' respectively and you must indicate to
+     configure the desired versions. The following syntax should do the
+     trick:
+
+     ../configure --gcc=gcc-4
+
+The following general tools are used on various platforms and it is
+recommended you use these versions or similar:
+
+   * subversion - 1.6.2
+
+   * python - Python 2.4.6
+
+   * curl - curl 7.19.4 (or wget)
+
+   * m4 - GNU M4 1.4.6
+
+   * make - GNU Make 3.81
+
+   * patch - Patch 2.5.8
+
+   * tar - GNU tar 1.15.1
+
+   * wget - GNU Wget 1.11.4 (or curl)
+
+3 QuickStart
+************
+
+This chapter is for building from a terminal/shell environment in as
+few commands as possible. Upon completion of the following commands you
+should have a fresh build of HandBrake. Further instructions are
+available beginning with *Note overview:: which describes procedures
+suitable for repeating builds. This chapter should be skipped by those
+seeking more than a minimalist build.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+     ./configure --launch
+
+The special option `--launch' selects launch mode and performs the
+following steps:
+
+   * assert scratch directory `build/' does not exist
+
+   * create scratch directory `build/'
+
+   * change to directory `build/'
+
+   * launch `make'
+
+   * capture build output to `build/log/build.txt'
+
+   * echo build output
+
+   * print elapsed time
+
+   * indicate if build ultimately succeeded or failed
+
+4 Overview
+**********
+
+Cygwin builds are performed from a terminal. There is no support for
+building from any IDEs.
+
+5 Building via Terminal
+***********************
+
+5.1 Checkout Sources
+====================
+
+Checkout HandBrake from the official source-code repository.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+
+Sources are checked out from the `trunk' branch. This document was
+generated from that very branch, and for example purposes, we will use
+exactly the same branch.
+
+If you have write-access to the repository, then you may add the
+appropriate login/password information as needed. It is recommended to
+use Subversion 1.5.0 or higher. Lower versions should also work.
+
+5.2 Configure
+=============
+
+Configure the build system.
+
+     ./configure
+
+Configure will automatically create a scratch build directory `build'
+unless you use GNU-style build procedures and first `cd' to a directory
+other than top-level source. Additionally you may use `--build' to
+specify the directory. The name of the directory is arbitrary but it is
+recommended to use something which indicates transient files which are
+not checked into the repository.
+
+The `configure' utility accepts many options. It is recommended that
+you specify `--help' for the complete list of options. The following
+options are also documented here:
+
+`--help'
+     List available options.
+
+`--src=DIR'
+     Specify top-level source directory for HandBrake sources.
+
+`--build=DIR'
+     Specify destination directory for final product install. The
+     default is to use either `build' if in the top-level source
+     directory, otherwise `.'
+
+`--prefix=DIR'
+     Specify destination directory for final product install.  This
+     defaults to a reasonable platform-specific value.
+
+`--launch'
+     All-in-one option which launches the build and logs output
+     automatically.  Useful for novices and quick-start procedures.
+
+`--disable-xcode'
+     Disable shunting the build through `xcodebuild'. If this option is
+     applied, `HandBrakeCLI' will be produced in a similar fashion as
+     it is on other platforms; sans Xcode and the Cocoa application
+     will not be produced. Mac OS X only.
+
+`--disable-gtk'
+     Disable building the GTK GUI on applicable platforms such as
+     Linux.
+
+`--debug=MODE'
+     Select debug mode. Must be one of `none', `min', `std', `max'.
+     This generally maps to gcc options `-g0', `-g1', `-g2', `-g3'.
+
+`--optimize=MODE'
+     Select optimize mode. Must be one of `none', `speed', `size'.
+     This generally maps to gcc options `-g0', `-O0', `-O3', `-Os'.
+
+`--arch=MODE'
+     Select build architecture. The available architectures vary by
+     platform. Most platforms support exactly one architecture except
+     Mac OS X which has support for various universal binary
+     architectures. The available choices are hard-coded per platform
+     and no sanity checks for the required tools are performed.
+
+
+Clean-room procedures dictate that when certain factors change, old
+builds should be scrapped and new builds configured. This is the main
+reason for requiring a scratch directory; to promote consistent,
+reliable and clean software builds. The following is a short list of
+some of the reasons why someone may choose to scrap an existing build:
+
+   * configure with different options
+
+   * subversion working dir is updated and you want configure to
+     re-evaluate working dir metadata.
+
+   * build corruption is suspected
+
+There are generally two methods for scrapping a build. The `build'
+directory can be recursively removed which has the effect of loosing
+your existing configuration but does guarantee no residuals are left
+behind. The other method is to ask the build system to perform an `make
+xclean'. This is known to work well but will leave empty directories
+behind. However, the configuration is left intact.
+
+5.3 Build
+=========
+
+Build main product. All necessary dependencies are also built if
+required.
+
+     make
+
+Parallel builds may optionally be enabled. Be aware that while a
+parallel build may save time on systems with additional cores, the
+output is often mixed, overlapped and sometimes even corrupted with
+binary characters. Thus if you experience a build issue, you should
+clean and redo the build in default serial mode to produce a readable
+log. The following command allows for up to 4 concurrent jobs via make:
+
+     make -j4
+
+5.4 Make Targets
+================
+
+The build system supports passing many kinds of targets some of which
+become very useful in normal development cycles. The targets by
+convention are lower-case words passed to `make'. Global targets are
+one-word targets. Scoped targets are usually two-words separated by a
+period.
+
+5.4.1 Global
+------------
+
+`make'
+     Alias for `make build'.
+
+`make build'
+     Build main product. All necessary dependencies are also built if
+     required.
+
+`make clean'
+     Clean all build output excluding contrib modules. Configuration is
+     retained.
+
+`make install'
+     Perform final product(s) install.  This will install build
+     products to a standard directory or one specified via `configure
+     --prefix' option.
+
+`make uninstall'
+     Perform final product(s) uninstall.  This will uninstall any
+     products which may have been previously installed.
+
+`make xclean'
+     Clean all build output including contrib modules. Configuration is
+     retained.
+
+`make doc'
+     Build auto-generated project documentation. Various articles are
+     produced and may be found in `build/doc/articles'.
+
+`make report.help'
+     Print list of available makefile vars report targets.  These
+     reports detail var definitions and expanded values used by the
+     build system.  For experts only.
+
+`make report.all'
+     Convenience target which aggregates all reports.  For experts only.
+
+5.4.2 General Modules
+---------------------
+
+General modules such as `libhb', `test' and `gtk' have the following
+scoped targets:
+
+`make MODULE.build'
+     Build MODULE.
+
+`make MODULE.clean'
+     Clean build output for MODULE.
+
+5.4.3 Contrib Modules
+---------------------
+
+Contrib modules such as `a52dec', `bzip2', `faac', `faad2', `ffmpeg',
+`lame', `libdca', `libdvdread', `libmkv', `libogg', `libsamplerate',
+`libtheora', `libvorbis', `mp4v2', `mpeg2dec', `x264' and `zlib' have
+the following scoped targets:
+
+`make MODULE.fetch'
+     Download source tarball from the Internet and save to
+     `TOP/downloads' directory. No check-summing is performed.
+
+`make MODULE.extract'
+     Extract source tarball into `build' tree.
+
+`make MODULE.patch'
+     Apply appropriate patches (if any) to module sources.
+
+`make MODULE.configure'
+     Configure module sources.  This usually invokes autotool configure.
+
+`make MODULE.build'
+     Build module.  This usually invokes autotool build.
+
+`make MODULE.install'
+     Install module products such as headers and libraries into `build'
+     tree.  This usually invokes autotool install.
+
+`make MODULE.uninstall'
+     Uninstall module products; generally the reverse of install.  This
+     usually invokes autotool uninstall.
+
+`make MODULE.clean'
+     Clean module; generally the reverse of build.  This usually
+     invokes autotool clean.
+
+`make MODULE.xclean'
+     Extra clean module; first invokes uninstall then recursively
+     removes the module build directory.
+
+5.4.4 Contrib Touch and Untouch
+-------------------------------
+
+Also available are some very granular targets which help force builds
+from specific cycle points. The following targets are available to
+touch and untouch the respective module target; this will force the
+build system to treat the target as satisfied after a touch or
+unsatisfied after an untouch:
+
+   * make MODULE.extract.touch
+
+   * make MODULE.extract.untouch
+
+   * make MODULE.patch.touch
+
+   * make MODULE.patch.untouch
+
+   * make MODULE.configure.touch
+
+   * make MODULE.configure.untouch
+
+   * make MODULE.build.touch
+
+   * make MODULE.build.untouch
+
+   * make MODULE.install.touch
+
+   * make MODULE.install.untouch
+
+5.4.5 Contrib Aggregates
+------------------------
+
+For convenience, the following targets aggregate the all contrib
+modules' respective targets together:
+
+   * make contrib.fetch
+
+   * make contrib.extract
+
+   * make contrib.patch
+
+   * make contrib.configure
+
+   * make contrib.build
+
+   * make contrib.install
+
+   * make contrib.uninstall
+
+   * make contrib.clean
+
+   * make contrib.xclean
+
+5.5 Customizing Make
+====================
+
+If the need arises to override settings in the build system
+(essentially gnu-make variables) the recommended method is to create
+optional include files which are automatically included if present and
+follow this naming convention; Do not check these files into the
+repository:
+
+`_SRC_/custom.defs'
+     Custom makevar definitions outside `build'. Suitable for settings
+     which apply across all builds for a particular checkout; or which
+     survives manual removal of `build'.
+
+`_SRC_/custom.rules'
+     Custom make rules outside `build'. Suitable for rules which apply
+     across all builds for a particular checkout; or which survives
+     manual removal of `build'.
+
+`_BUILD_/GNUmakefile.custom.defs'
+     Custom makevar definitions specific to a `build' directory.
+
+`_BUILD_/GNUmakefile.custom.rules'
+     Custom makevar rules specific to a `build' directory.
+
+
+The purpose is to allow a place to store local build settings for
+testing, tweaking, and experimenting with build configuration without
+losing your settings if `configure' is invoked; ie: `configure' would
+overwrite `GNUmakefile' and any customizations contained therein would
+be lost. Here is a short example of what the contents of
+`_SRC_/custom.defs' might contain:
+
+     ## bump to gcc-4.2 in current path
+     GCC.gcc = /usr/bin/gcc-4.2
+
+     ## replace optimize for 'speed' with more aggressive settings
+     GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2
+
+See also `make report.help' which displays a set of reports used to
+dump makefile vars.
+
+6 Troubleshooting
+*****************
+
+When troubleshooting build issues, the following files relative to the
+`build/' directory may be especially useful:
+
+`GNUmakefile'
+     Top-level makefile which contains build settings generated via
+     configure.
+
+`log/config.info.txt'
+     Record of output from configure.
+
+`log/config.verbose.txt'
+     Record of verbose output from configure.
+
+`log/build.txt'
+     Record of output from `configure --launch'. Similar output may be
+     recorded using `make' depending on which shell is in use, eg:
+     `make >& log/build.txt' or `make > log/build.txt 2>&1'.
+
+`log/xcodemake.env.txt'
+     Environment (variables) dump as seen when Xcode forks `make'.
+     Mac OS X only.
+
+Appendix A Project Repository Details
+*************************************
+
+     url:    svn://svn.handbrake.fr/HandBrake/trunk
+     root:   svn://svn.handbrake.fr/HandBrake
+     branch: trunk
+     uuid:   b64f7644-9d1e-0410-96f1-a4d463321fa5
+     rev:    2591
+     date:   2009-06-21 13:15:04 -0400
+     type:   developer
+
diff --git a/doc/BUILD-Linux b/doc/BUILD-Linux
new file mode 100644 (file)
index 0000000..2e2f1f9
--- /dev/null
@@ -0,0 +1,548 @@
+Guide to Building HandBrake svn2688 (2009071301) on Linux
+*********************************************************
+
+Table of Contents
+*****************
+
+1 Introduction
+2 Prerequisites
+3 QuickStart
+4 Overview
+5 Building via Terminal
+  5.1 Checkout Sources
+  5.2 Configure
+  5.3 Build
+  5.4 Make Targets
+    5.4.1 Global
+    5.4.2 General Modules
+    5.4.3 Contrib Modules
+    5.4.4 Contrib Touch and Untouch
+    5.4.5 Contrib Aggregates
+  5.5 Customizing Make
+6 Troubleshooting
+Appendix A Project Repository Details
+
+
+1 Introduction
+**************
+
+This guide documents the recommended process to build HandBrake on
+Linux hosts from the official source-code repository. Building from any
+other source is not supported.
+
+2 Prerequisites
+***************
+
+The following are the recommended specifications for building on
+Linux; but is not necessarily the only configuration that is possible:
+
+   * Intel 32-bit or 64-bit kernel
+
+   * Ubuntu 8.0.4, gcc 4.3.0, yasm 0.7.1.2093
+
+   * Ubuntu 8.10, gcc 4.3.2, yasm 0.7.1.2093
+
+   * Fedora 9, gcc 4.3.0, yasm 0.7.1.2093
+
+   * Fedora 10, gcc 4.3.2, yasm 0.7.1.2093
+
+   * gcc 4.0.0 or higher is reported to work
+
+     Note: It is recommended to use the platform distribution's bundled
+     compiler for maximum C++ compatibility. If you build with a custom
+     compiler it will likely introduce non-standard runtime
+     requirements. There are of course many valid reasons to build with
+     unbundled compilers, but be aware it is generally unsupported and
+     left as an exercise to the reader.
+
+The following general tools are used on various platforms and it is
+recommended you use these versions or similar:
+
+   * subversion - 1.6.2
+
+   * python - Python 2.4.6
+
+   * curl - curl 7.19.4 (or wget)
+
+   * m4 - GNU M4 1.4.6
+
+   * make - GNU Make 3.81
+
+   * patch - Patch 2.5.8
+
+   * tar - GNU tar 1.15.1
+
+   * wget - GNU Wget 1.11.4 (or curl)
+
+The GTK UI introduces some significant extra build requirements. If you
+intend to disable building the GUI with `configure --disable-gtk' you
+will not need many of these packages installed:
+
+Ubuntu 8.10 packages:
+   * subversion (cli/gui)
+
+   * yasm (cli/gui)
+
+   * build-essential (cli/gui)
+
+   * autoconf (cli/gui)
+
+   * libtool (cli/gui)
+
+   * zlib1g-dev (cli/gui)
+
+   * libbz2-dev (cli/gui)
+
+   * intltool (gui)
+
+   * libglib2.0-dev (gui)
+
+   * libdbus-glib-1-dev (gui)
+
+   * libgtk2.0-dev (gui)
+
+   * libhal-dev (gui)
+
+   * libhal-storage-dev (gui)
+
+   * libwebkit-dev (gui)
+
+   * libnotify-dev (gui)
+
+   * libgstreamer0.10-dev (gui)
+
+   * libgstreamer-plugins-base0.10-dev (gui)
+
+To install these packages:
+     sudo apt-get install subversion yasm build-essential \
+     autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev \
+     libdbus-glib-1-dev libgtk2.0-dev libhal-dev libhal-storage-dev \
+     libwebkit-dev libnotify-dev libgstreamer0.10-dev \
+     libgstreamer-plugins-base0.10-dev
+
+Fedora 10 package groups:
+   * Development Tools
+
+   * Development Libraries
+
+   * X Software Development (gui)
+
+   * GNOME Software Development (gui)
+
+To install these package groups:
+     sudo yum groupinstall "Development Tools" "Development Libraries" \
+     "X Software Development" "GNOME Software Development"
+
+Additional Fedora 10 packages:
+   * yasm (cli/gui)
+
+   * zlib-devel (cli/gui)
+
+   * bzip2-devel (cli/gui)
+
+   * dbus-glib-devel (gui)
+
+   * hal-devel (gui)
+
+   * webkitgtk-devel (gui)
+
+   * libnotify-devel (gui)
+
+   * gstreamer-devel (gui)
+
+   * gstreamer-plugins-base-devel (gui)
+
+To install these packages:
+     sudo yum install yasm zlib-devel bzip2-devel \
+     dbus-glib-devel hal-devel webkitgtk-devel libnotify-devel\
+     gstreamer-devel gstreamer-plugins-base-devel
+
+3 QuickStart
+************
+
+This chapter is for building from a terminal/shell environment in as
+few commands as possible. Upon completion of the following commands you
+should have a fresh build of HandBrake. Further instructions are
+available beginning with *note overview:: which describes procedures
+suitable for repeating builds. This chapter should be skipped by those
+seeking more than a minimalist build.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+     ./configure --launch
+
+The special option `--launch' selects launch mode and performs the
+following steps:
+
+   * assert scratch directory `build/' does not exist
+
+   * create scratch directory `build/'
+
+   * change to directory `build/'
+
+   * launch `make'
+
+   * capture build output to `build/log/build.txt'
+
+   * echo build output
+
+   * print elapsed time
+
+   * indicate if build ultimately succeeded or failed
+
+4 Overview
+**********
+
+Linux builds are performed from a terminal. There is no support for
+building from any IDEs.
+
+5 Building via Terminal
+***********************
+
+5.1 Checkout Sources
+====================
+
+Checkout HandBrake from the official source-code repository.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+
+Sources are checked out from the `trunk' branch. This document was
+generated from that very branch, and for example purposes, we will use
+exactly the same branch.
+
+If you have write-access to the repository, then you may add the
+appropriate login/password information as needed. It is recommended to
+use Subversion 1.5.0 or higher. Lower versions should also work.
+
+5.2 Configure
+=============
+
+Configure the build system.
+
+     ./configure
+
+Configure will automatically create a scratch build directory `build'
+unless you use GNU-style build procedures and first `cd' to a directory
+other than top-level source. Additionally you may use `--build' to
+specify the directory. The name of the directory is arbitrary but it is
+recommended to use something which indicates transient files which are
+not checked into the repository.
+
+The `configure' utility accepts many options. It is recommended that
+you specify `--help' for the complete list of options. The following
+options are also documented here:
+
+`--help'
+     List available options.
+
+`--src=DIR'
+     Specify top-level source directory for HandBrake sources.
+
+`--build=DIR'
+     Specify destination directory for final product install. The
+     default is to use either `build' if in the top-level source
+     directory, otherwise `.'
+
+`--prefix=DIR'
+     Specify destination directory for final product install.  This
+     defaults to a reasonable platform-specific value.
+
+`--launch'
+     All-in-one option which launches the build and logs output
+     automatically.  Useful for novices and quick-start procedures.
+
+`--disable-xcode'
+     Disable shunting the build through `xcodebuild'. If this option is
+     applied, `HandBrakeCLI' will be produced in a similar fashion as
+     it is on other platforms; sans Xcode and the Cocoa application
+     will not be produced. Mac OS X only.
+
+`--disable-gtk'
+     Disable building the GTK GUI on applicable platforms such as
+     Linux.
+
+`--debug=MODE'
+     Select debug mode. Must be one of `none', `min', `std', `max'.
+     This generally maps to gcc options `-g0', `-g1', `-g2', `-g3'.
+
+`--optimize=MODE'
+     Select optimize mode. Must be one of `none', `speed', `size'.
+     This generally maps to gcc options `-g0', `-O0', `-O3', `-Os'.
+
+`--arch=MODE'
+     Select build architecture. The available architectures vary by
+     platform. Most platforms support exactly one architecture except
+     Mac OS X which has support for various universal binary
+     architectures. The available choices are hard-coded per platform
+     and no sanity checks for the required tools are performed.
+
+
+Clean-room procedures dictate that when certain factors change, old
+builds should be scrapped and new builds configured. This is the main
+reason for requiring a scratch directory; to promote consistent,
+reliable and clean software builds. The following is a short list of
+some of the reasons why someone may choose to scrap an existing build:
+
+   * configure with different options
+
+   * subversion working dir is updated and you want configure to
+     re-evaluate working dir metadata.
+
+   * build corruption is suspected
+
+There are generally two methods for scrapping a build. The `build'
+directory can be recursively removed which has the effect of loosing
+your existing configuration but does guarantee no residuals are left
+behind. The other method is to ask the build system to perform an `make
+xclean'. This is known to work well but will leave empty directories
+behind. However, the configuration is left intact.
+
+5.3 Build
+=========
+
+Build main product. All necessary dependencies are also built if
+required.
+
+     make
+
+Parallel builds may optionally be enabled. Be aware that while a
+parallel build may save time on systems with additional cores, the
+output is often mixed, overlapped and sometimes even corrupted with
+binary characters. Thus if you experience a build issue, you should
+clean and redo the build in default serial mode to produce a readable
+log. The following command allows for up to 4 concurrent jobs via make:
+
+     make -j4
+
+5.4 Make Targets
+================
+
+The build system supports passing many kinds of targets some of which
+become very useful in normal development cycles. The targets by
+convention are lower-case words passed to `make'. Global targets are
+one-word targets. Scoped targets are usually two-words separated by a
+period.
+
+5.4.1 Global
+------------
+
+`make'
+     Alias for `make build'.
+
+`make build'
+     Build main product. All necessary dependencies are also built if
+     required.
+
+`make clean'
+     Clean all build output excluding contrib modules. Configuration is
+     retained.
+
+`make install'
+     Perform final product(s) install.  This will install build
+     products to a standard directory or one specified via `configure
+     --prefix' option.
+
+`make uninstall'
+     Perform final product(s) uninstall.  This will uninstall any
+     products which may have been previously installed.
+
+`make xclean'
+     Clean all build output including contrib modules. Configuration is
+     retained.
+
+`make doc'
+     Build auto-generated project documentation. Various articles are
+     produced and may be found in `build/doc/articles'.
+
+`make report.help'
+     Print list of available makefile vars report targets.  These
+     reports detail var definitions and expanded values used by the
+     build system.  For experts only.
+
+`make report.all'
+     Convenience target which aggregates all reports.  For experts only.
+
+5.4.2 General Modules
+---------------------
+
+General modules such as `libhb', `test' and `gtk' have the following
+scoped targets:
+
+`make MODULE.build'
+     Build MODULE.
+
+`make MODULE.clean'
+     Clean build output for MODULE.
+
+5.4.3 Contrib Modules
+---------------------
+
+Contrib modules such as `a52dec', `bzip2', `faac', `faad2', `ffmpeg',
+`lame', `libdca', `libdvdread', `libmkv', `libogg', `libsamplerate',
+`libtheora', `libvorbis', `mp4v2', `mpeg2dec', `x264' and `zlib' have
+the following scoped targets:
+
+`make MODULE.fetch'
+     Download source tarball from the Internet and save to
+     `TOP/downloads' directory. No check-summing is performed.
+
+`make MODULE.extract'
+     Extract source tarball into `build' tree.
+
+`make MODULE.patch'
+     Apply appropriate patches (if any) to module sources.
+
+`make MODULE.configure'
+     Configure module sources.  This usually invokes autotool configure.
+
+`make MODULE.build'
+     Build module.  This usually invokes autotool build.
+
+`make MODULE.install'
+     Install module products such as headers and libraries into `build'
+     tree.  This usually invokes autotool install.
+
+`make MODULE.uninstall'
+     Uninstall module products; generally the reverse of install.  This
+     usually invokes autotool uninstall.
+
+`make MODULE.clean'
+     Clean module; generally the reverse of build.  This usually
+     invokes autotool clean.
+
+`make MODULE.xclean'
+     Extra clean module; first invokes uninstall then recursively
+     removes the module build directory.
+
+5.4.4 Contrib Touch and Untouch
+-------------------------------
+
+Also available are some very granular targets which help force builds
+from specific cycle points. The following targets are available to
+touch and untouch the respective module target; this will force the
+build system to treat the target as satisfied after a touch or
+unsatisfied after an untouch:
+
+   * make MODULE.extract.touch
+
+   * make MODULE.extract.untouch
+
+   * make MODULE.patch.touch
+
+   * make MODULE.patch.untouch
+
+   * make MODULE.configure.touch
+
+   * make MODULE.configure.untouch
+
+   * make MODULE.build.touch
+
+   * make MODULE.build.untouch
+
+   * make MODULE.install.touch
+
+   * make MODULE.install.untouch
+
+5.4.5 Contrib Aggregates
+------------------------
+
+For convenience, the following targets aggregate the all contrib
+modules' respective targets together:
+
+   * make contrib.fetch
+
+   * make contrib.extract
+
+   * make contrib.patch
+
+   * make contrib.configure
+
+   * make contrib.build
+
+   * make contrib.install
+
+   * make contrib.uninstall
+
+   * make contrib.clean
+
+   * make contrib.xclean
+
+5.5 Customizing Make
+====================
+
+If the need arises to override settings in the build system
+(essentially gnu-make variables) the recommended method is to create
+optional include files which are automatically included if present and
+follow this naming convention; Do not check these files into the
+repository:
+
+`_SRC_/custom.defs'
+     Custom makevar definitions outside `build'. Suitable for settings
+     which apply across all builds for a particular checkout; or which
+     survives manual removal of `build'.
+
+`_SRC_/custom.rules'
+     Custom make rules outside `build'. Suitable for rules which apply
+     across all builds for a particular checkout; or which survives
+     manual removal of `build'.
+
+`_BUILD_/GNUmakefile.custom.defs'
+     Custom makevar definitions specific to a `build' directory.
+
+`_BUILD_/GNUmakefile.custom.rules'
+     Custom makevar rules specific to a `build' directory.
+
+
+The purpose is to allow a place to store local build settings for
+testing, tweaking, and experimenting with build configuration without
+losing your settings if `configure' is invoked; ie: `configure' would
+overwrite `GNUmakefile' and any customizations contained therein would
+be lost. Here is a short example of what the contents of
+`_SRC_/custom.defs' might contain:
+
+     ## bump to gcc-4.2 in current path
+     GCC.gcc = /usr/bin/gcc-4.2
+
+     ## replace optimize for 'speed' with more aggressive settings
+     GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2
+
+See also `make report.help' which displays a set of reports used to
+dump makefile vars.
+
+6 Troubleshooting
+*****************
+
+When troubleshooting build issues, the following files relative to the
+`build/' directory may be especially useful:
+
+`GNUmakefile'
+     Top-level makefile which contains build settings generated via
+     configure.
+
+`log/config.info.txt'
+     Record of output from configure.
+
+`log/config.verbose.txt'
+     Record of verbose output from configure.
+
+`log/build.txt'
+     Record of output from `configure --launch'. Similar output may be
+     recorded using `make' depending on which shell is in use, eg:
+     `make >& log/build.txt' or `make > log/build.txt 2>&1'.
+
+`log/xcodemake.env.txt'
+     Environment (variables) dump as seen when Xcode forks `make'.
+     Mac OS X only.
+
+Appendix A Project Repository Details
+*************************************
+
+     url:    svn://svn.handbrake.fr/HandBrake/trunk
+     root:   svn://svn.handbrake.fr/HandBrake
+     branch: trunk
+     uuid:   b64f7644-9d1e-0410-96f1-a4d463321fa5
+     rev:    2688
+     date:   2009-07-12 22:47:33 -0700
+     type:   developer
+
diff --git a/doc/BUILD-Mac b/doc/BUILD-Mac
new file mode 100644 (file)
index 0000000..55a785e
--- /dev/null
@@ -0,0 +1,659 @@
+Build Guide for HandBrake svn2591 on Mac OS X
+*********************************************
+
+Table of Contents
+*****************
+
+1 Introduction
+2 Prerequisites
+3 QuickStart
+4 Overview
+5 Building via Terminal
+  5.1 Checkout Sources
+  5.2 Configure
+  5.3 Build
+  5.4 Make Targets
+    5.4.1 Global
+    5.4.2 General Modules
+    5.4.3 Contrib Modules
+    5.4.4 Contrib Touch and Untouch
+    5.4.5 Contrib Aggregates
+  5.5 Customizing Make
+  5.6 Universal Binaries
+6 Building via Xcode.app
+  6.1 Checkout Sources
+  6.2 Build
+  6.3 External Targets
+  6.4 User-Defined Settings
+7 Troubleshooting
+Appendix A Project Repository Details
+
+
+1 Introduction
+**************
+
+This guide documents the recommended process to build HandBrake on
+Mac OS X hosts from the official source-code repository. Building from
+any other source is not supported.
+
+2 Prerequisites
+***************
+
+Building on Mac OS X is well supported. It is the reference platform
+for HandBrake. The following are the recommended specifications for
+this platform; but is not necessarily the only configuration that is
+possible:
+
+   * Mac Intel hardware
+
+   * Mac OS X 10.5.7
+
+   * Xcode-3.1.2
+
+   * gcc 4.0.1 (Apple Inc. build 5490)
+
+   * yasm 0.8.0.2194 (for i386 and x86_64 architectures)
+
+     Note: It is recommended to use the platform distribution's bundled
+     compiler for maximum C++ compatibility. If you build with a custom
+     compiler it will likely introduce non-standard runtime
+     requirements. There are of course many valid reasons to build with
+     unbundled compilers, but be aware it is generally unsupported and
+     left as an exercise to the reader.
+
+The following general tools are used on various platforms and it is
+recommended you use these versions or similar:
+
+   * subversion - 1.6.2
+
+   * python - Python 2.4.6
+
+   * curl - curl 7.19.4 (or wget)
+
+   * m4 - GNU M4 1.4.6
+
+   * make - GNU Make 3.81
+
+   * patch - Patch 2.5.8
+
+   * tar - GNU tar 1.15.1
+
+   * wget - GNU Wget 1.11.4 (or curl)
+
+3 QuickStart
+************
+
+This chapter is for building from a terminal/shell environment in as
+few commands as possible. Upon completion of the following commands you
+should have a fresh build of HandBrake. Further instructions are
+available beginning with *Note overview:: which describes procedures
+suitable for repeating builds. This chapter should be skipped by those
+seeking more than a minimalist build.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+     ./configure --launch
+
+The special option `--launch' selects launch mode and performs the
+following steps:
+
+   * assert scratch directory `build/' does not exist
+
+   * create scratch directory `build/'
+
+   * change to directory `build/'
+
+   * launch `make'
+
+   * capture build output to `build/log/build.txt'
+
+   * echo build output
+
+   * print elapsed time
+
+   * indicate if build ultimately succeeded or failed
+
+4 Overview
+**********
+
+The two general methods to build on Mac OS X are from terminal or
+Xcode.app. The preferred method for automated and repeatable builds is
+to use the terminal. Otherwise the choice is generally up to the
+individual. To be extra clear, building from the terminal by default
+actually invokes `xcodebuild' to build the very same targets contained
+in the Xcode project. Think of it as building with Xcode but without
+the GUI.
+
+5 Building via Terminal
+***********************
+
+5.1 Checkout Sources
+====================
+
+Checkout HandBrake from the official source-code repository.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+
+Sources are checked out from the `trunk' branch. This document was
+generated from that very branch, and for example purposes, we will use
+exactly the same branch.
+
+If you have write-access to the repository, then you may add the
+appropriate login/password information as needed. It is recommended to
+use Subversion 1.5.0 or higher. Lower versions should also work.
+
+5.2 Configure
+=============
+
+Configure the build system.
+
+     ./configure
+
+Configure will automatically create a scratch build directory `build'
+unless you use GNU-style build procedures and first `cd' to a directory
+other than top-level source. Additionally you may use `--build' to
+specify the directory. The name of the directory is arbitrary but it is
+recommended to use something which indicates transient files which are
+not checked into the repository.
+
+The `configure' utility accepts many options. It is recommended that
+you specify `--help' for the complete list of options. The following
+options are also documented here:
+
+`--help'
+     List available options.
+
+`--src=DIR'
+     Specify top-level source directory for HandBrake sources.
+
+`--build=DIR'
+     Specify destination directory for final product install. The
+     default is to use either `build' if in the top-level source
+     directory, otherwise `.'
+
+`--prefix=DIR'
+     Specify destination directory for final product install.  This
+     defaults to a reasonable platform-specific value.
+
+`--launch'
+     All-in-one option which launches the build and logs output
+     automatically.  Useful for novices and quick-start procedures.
+
+`--disable-xcode'
+     Disable shunting the build through `xcodebuild'. If this option is
+     applied, `HandBrakeCLI' will be produced in a similar fashion as
+     it is on other platforms; sans Xcode and the Cocoa application
+     will not be produced. Mac OS X only.
+
+`--disable-gtk'
+     Disable building the GTK GUI on applicable platforms such as
+     Linux.
+
+`--debug=MODE'
+     Select debug mode. Must be one of `none', `min', `std', `max'.
+     This generally maps to gcc options `-g0', `-g1', `-g2', `-g3'.
+
+`--optimize=MODE'
+     Select optimize mode. Must be one of `none', `speed', `size'.
+     This generally maps to gcc options `-g0', `-O0', `-O3', `-Os'.
+
+`--arch=MODE'
+     Select build architecture. The available architectures vary by
+     platform. Most platforms support exactly one architecture except
+     Mac OS X which has support for various universal binary
+     architectures. The available choices are hard-coded per platform
+     and no sanity checks for the required tools are performed.
+
+
+Clean-room procedures dictate that when certain factors change, old
+builds should be scrapped and new builds configured. This is the main
+reason for requiring a scratch directory; to promote consistent,
+reliable and clean software builds. The following is a short list of
+some of the reasons why someone may choose to scrap an existing build:
+
+   * configure with different options
+
+   * subversion working dir is updated and you want configure to
+     re-evaluate working dir metadata.
+
+   * build corruption is suspected
+
+There are generally two methods for scrapping a build. The `build'
+directory can be recursively removed which has the effect of loosing
+your existing configuration but does guarantee no residuals are left
+behind. The other method is to ask the build system to perform an `make
+xclean'. This is known to work well but will leave empty directories
+behind. However, the configuration is left intact.
+
+5.3 Build
+=========
+
+Build main product. All necessary dependencies are also built if
+required.
+
+     make
+
+Parallel builds may optionally be enabled. Be aware that while a
+parallel build may save time on systems with additional cores, the
+output is often mixed, overlapped and sometimes even corrupted with
+binary characters. Thus if you experience a build issue, you should
+clean and redo the build in default serial mode to produce a readable
+log. The following command allows for up to 4 concurrent jobs via make:
+
+     make -j4
+
+5.4 Make Targets
+================
+
+The build system supports passing many kinds of targets some of which
+become very useful in normal development cycles. The targets by
+convention are lower-case words passed to `make'. Global targets are
+one-word targets. Scoped targets are usually two-words separated by a
+period.
+
+5.4.1 Global
+------------
+
+`make'
+     Alias for `make build'.
+
+`make build'
+     Build main product. All necessary dependencies are also built if
+     required.
+
+`make clean'
+     Clean all build output excluding contrib modules. Configuration is
+     retained.
+
+`make install'
+     Perform final product(s) install.  This will install build
+     products to a standard directory or one specified via `configure
+     --prefix' option.
+
+`make uninstall'
+     Perform final product(s) uninstall.  This will uninstall any
+     products which may have been previously installed.
+
+`make xclean'
+     Clean all build output including contrib modules. Configuration is
+     retained.
+
+`make doc'
+     Build auto-generated project documentation. Various articles are
+     produced and may be found in `build/doc/articles'.
+
+`make report.help'
+     Print list of available makefile vars report targets.  These
+     reports detail var definitions and expanded values used by the
+     build system.  For experts only.
+
+`make report.all'
+     Convenience target which aggregates all reports.  For experts only.
+
+5.4.2 General Modules
+---------------------
+
+General modules such as `libhb', `test' and `gtk' have the following
+scoped targets:
+
+`make MODULE.build'
+     Build MODULE.
+
+`make MODULE.clean'
+     Clean build output for MODULE.
+
+5.4.3 Contrib Modules
+---------------------
+
+Contrib modules such as `a52dec', `bzip2', `faac', `faad2', `ffmpeg',
+`lame', `libdca', `libdvdread', `libmkv', `libogg', `libsamplerate',
+`libtheora', `libvorbis', `mp4v2', `mpeg2dec', `x264' and `zlib' have
+the following scoped targets:
+
+`make MODULE.fetch'
+     Download source tarball from the Internet and save to
+     `TOP/downloads' directory. No check-summing is performed.
+
+`make MODULE.extract'
+     Extract source tarball into `build' tree.
+
+`make MODULE.patch'
+     Apply appropriate patches (if any) to module sources.
+
+`make MODULE.configure'
+     Configure module sources.  This usually invokes autotool configure.
+
+`make MODULE.build'
+     Build module.  This usually invokes autotool build.
+
+`make MODULE.install'
+     Install module products such as headers and libraries into `build'
+     tree.  This usually invokes autotool install.
+
+`make MODULE.uninstall'
+     Uninstall module products; generally the reverse of install.  This
+     usually invokes autotool uninstall.
+
+`make MODULE.clean'
+     Clean module; generally the reverse of build.  This usually
+     invokes autotool clean.
+
+`make MODULE.xclean'
+     Extra clean module; first invokes uninstall then recursively
+     removes the module build directory.
+
+5.4.4 Contrib Touch and Untouch
+-------------------------------
+
+Also available are some very granular targets which help force builds
+from specific cycle points. The following targets are available to
+touch and untouch the respective module target; this will force the
+build system to treat the target as satisfied after a touch or
+unsatisfied after an untouch:
+
+   * make MODULE.extract.touch
+
+   * make MODULE.extract.untouch
+
+   * make MODULE.patch.touch
+
+   * make MODULE.patch.untouch
+
+   * make MODULE.configure.touch
+
+   * make MODULE.configure.untouch
+
+   * make MODULE.build.touch
+
+   * make MODULE.build.untouch
+
+   * make MODULE.install.touch
+
+   * make MODULE.install.untouch
+
+5.4.5 Contrib Aggregates
+------------------------
+
+For convenience, the following targets aggregate the all contrib
+modules' respective targets together:
+
+   * make contrib.fetch
+
+   * make contrib.extract
+
+   * make contrib.patch
+
+   * make contrib.configure
+
+   * make contrib.build
+
+   * make contrib.install
+
+   * make contrib.uninstall
+
+   * make contrib.clean
+
+   * make contrib.xclean
+
+5.5 Customizing Make
+====================
+
+If the need arises to override settings in the build system
+(essentially gnu-make variables) the recommended method is to create
+optional include files which are automatically included if present and
+follow this naming convention; Do not check these files into the
+repository:
+
+`_SRC_/custom.defs'
+     Custom makevar definitions outside `build'. Suitable for settings
+     which apply across all builds for a particular checkout; or which
+     survives manual removal of `build'.
+
+`_SRC_/custom.rules'
+     Custom make rules outside `build'. Suitable for rules which apply
+     across all builds for a particular checkout; or which survives
+     manual removal of `build'.
+
+`_BUILD_/GNUmakefile.custom.defs'
+     Custom makevar definitions specific to a `build' directory.
+
+`_BUILD_/GNUmakefile.custom.rules'
+     Custom makevar rules specific to a `build' directory.
+
+
+The purpose is to allow a place to store local build settings for
+testing, tweaking, and experimenting with build configuration without
+losing your settings if `configure' is invoked; ie: `configure' would
+overwrite `GNUmakefile' and any customizations contained therein would
+be lost. Here is a short example of what the contents of
+`_SRC_/custom.defs' might contain:
+
+     ## bump to gcc-4.2 in current path
+     GCC.gcc = /usr/bin/gcc-4.2
+
+     ## replace optimize for 'speed' with more aggressive settings
+     GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2
+
+See also `make report.help' which displays a set of reports used to
+dump makefile vars.
+
+5.6 Universal Binaries
+======================
+
+This section outlines convenience procedures for creating Universal
+Binaries for all the architectures.
+
+     Note: The dummy (container) build configuration uses
+     `--disable-xcode'; but the nested architecture builds will all
+     make full use of Xcode.
+
+Create a dummy (container) build configuration and use it to launch a
+nested-build for each architecture serially; optionally you may
+substitute `make ub.build.serial' for `make ub.build.parallel' if your
+machine has the horsepower:
+
+     ./configure --disable-xcode
+     cd build/
+     make ub.build.serial
+     make ub.combine
+
+To specify a subset of architectures to be built first create/edit
+`_SRC_/custom.defs' with the following override to build UB for `i386'
+and `x86_64' before invoking `make':
+
+     ## prefer i386 (order is important)
+     UB.archs = i386 x86_64
+
+6 Building via Xcode.app
+************************
+
+6.1 Checkout Sources
+====================
+
+Checkout HandBrake from the official source-code repository.
+
+     svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk
+     cd hb-trunk
+
+Sources are checked out from the `trunk' branch. This document was
+generated from that very branch, and for example purposes, we will use
+exactly the same branch.
+
+If you have write-access to the repository, then you may add the
+appropriate login/password information as needed. It is recommended to
+use Subversion 1.5.0 or higher. Lower versions should also work.
+
+6.2 Build
+=========
+
+Open Xcode.app from a terminal by using the `open' command which passes
+your shell environment and its `PATH' setting to Xcode. Do not attempt
+to launch Xcode.app from Finder or by using Finder to open
+`HandBrake.xcodeproj' - doing so will defeat any custom path settings
+which contain required tools.
+
+     open `macosx/HandBrake.xcodeproj'
+
+Once the HandBrake Xcode project is open, perform the following steps
+to build the default configuration:
+
+   * select active configuration standard
+
+   * select active target HandBrake
+
+   * click Build or Build and Go
+
+The first build (on an empty `build' directory) will take a bit of
+time. You may use the Build Results window to observe progress. The
+most time-consuming part of the build is when the external build system
+(essentially the terminal method) is triggered by Xcode and a
+substantial amount of log transcript ensues. Much of that transcript
+are warnings and errors that are part of the normal build process for
+3rd-party contributed modules so in general you need not do anything.
+However, if Xcode itself reports the build failed, then you must take
+corrective action.
+
+Unfortunately, due to limitations of Xcode we do not have hooks in
+place to offer finer-grained control over per-module make actions for
+the (external) build system. Thus, you will have to use terminal to
+accomplish those tasks. Just `cd' into the build directory which is
+associated with your active configuration and perform any necessary
+`make' commands. Be careful not to issue commands from the terminal
+simultaneously with Xcode tasks as that will confuse both Xcode and
+make and likely corrupt your build directory.
+
+When you click clean in Xcode it will not perform an external build
+clean. Basically HandBrakeCLI and HandBrake.app are the only products
+which have full Xcode iterative development flexibility.
+
+Each configuration uses a different `build' directory. This makes it
+possible to build each configuration and switch between them without
+losing their respective build state. The description of each
+configuration and the name convention for build directories are as
+follows:
+
+`standard'
+     This configuration will build host native architecture. Build
+     directory is `build.standard' .  The standard variant produces
+     optimized code without debug information.
+
+`standard.i386'
+     This configuration will build i386 architecture. Build directory
+     is `build.standard.i386' .
+
+`standard.x86_64'
+     This configuration will build x86_64 architecture. Build directory
+     is `build.standard.x86_64' .
+
+`standard.ppc'
+     This configuration will build ppc architecture. Build directory is
+     `build.standard.ppc' .
+
+`standard.ppc64'
+     This configuration will build ppc64 architecture. Build directory
+     is `build.standard.ppc64' .
+
+`debug'
+     This configuration will build host native architecture. Build
+     directory is `build.debug' .  The debug variant produces
+     unoptimized code with debug information.
+
+`debug.i386'
+     This configuration will build i386 architecture. Build directory
+     is `build.debug.i386' .  The debug variant produces unoptimized
+     code with debug information.
+
+`debug.x86_64'
+     This configuration will build x86_64 architecture. Build directory
+     is `build.debug.x86_64' .  The debug variant produces unoptimized
+     code with debug information.
+
+`debug.ppc'
+     This configuration will build ppc architecture. Build directory is
+     `build.debug.ppc' .  The debug variant produces unoptimized code
+     with debug information.
+
+`debug.ppc64'
+     This configuration will build ppc64 architecture. Build directory
+     is `build.debug.ppc64' .  The debug variant produces unoptimized
+     code with debug information.
+
+6.3 External Targets
+====================
+
+The following external targets appear in the Xcode project and perform
+build and clean actions.
+
+`external'
+     Target maps to `make build' and `make clean' for everything Xcode
+     products depend upon from the external build system.
+
+`libhb'
+     Target maps to `make libhb.build' and `make libhb.clean'.
+
+`contrib'
+     Target maps to `make contrib.build' and `make contrib.xclean'.
+
+
+6.4 User-Defined Settings
+=========================
+
+The following user defined settings are used in Xcode project for the
+external build system:
+
+`EXTERNAL_BUILD'
+     Specifies the build (scratch) directory for each configuration.
+
+`EXTERNAL_JOBS'
+     Specifies the concurrency factor for the external build system
+     when builds are launched from within Xcode.  Modify for faster
+     external builds if your system has the horsepower and resources.
+     Specifying a value greater than the number of CPU cores (or
+     virtual cores) in your system is unlikely to produce gains and
+     will needlessly consume extra resources.
+
+`EXTERNAL_METHOD'
+     Do not modify; Used for internal/external build coordination and
+     must always be `xcode'.
+
+`EXTERNAL_SRC'
+     Specifies the top-level source directory for HandBrake.
+
+
+7 Troubleshooting
+*****************
+
+When troubleshooting build issues, the following files relative to the
+`build/' directory may be especially useful:
+
+`GNUmakefile'
+     Top-level makefile which contains build settings generated via
+     configure.
+
+`log/config.info.txt'
+     Record of output from configure.
+
+`log/config.verbose.txt'
+     Record of verbose output from configure.
+
+`log/build.txt'
+     Record of output from `configure --launch'. Similar output may be
+     recorded using `make' depending on which shell is in use, eg:
+     `make >& log/build.txt' or `make > log/build.txt 2>&1'.
+
+`log/xcodemake.env.txt'
+     Environment (variables) dump as seen when Xcode forks `make'.
+     Mac OS X only.
+
+Appendix A Project Repository Details
+*************************************
+
+     url:    svn://svn.handbrake.fr/HandBrake/trunk
+     root:   svn://svn.handbrake.fr/HandBrake
+     branch: trunk
+     uuid:   b64f7644-9d1e-0410-96f1-a4d463321fa5
+     rev:    2591
+     date:   2009-06-21 13:15:04 -0400
+     type:   developer
+
diff --git a/doc/module.defs b/doc/module.defs
new file mode 100644 (file)
index 0000000..de427a3
--- /dev/null
@@ -0,0 +1,41 @@
+$(eval $(call import.MODULE.defs,DOC,doc))
+
+DOC.in/  = $(SRC/)doc/
+DOC.out/ = $(BUILD/)doc/
+
+DOC.out.api/      = $(DOC.out/)api/
+DOC.out.articles/ = $(DOC.out/)articles/
+
+###############################################################################
+
+DOC.m4.srcs = \
+    texi/base/handbrake.texi.m4
+
+DOC.m4.in   = $(foreach n,$(DOC.m4.srcs),$(DOC.in/)$n)
+DOC.m4.out  = $(patsubst $(DOC.in/)%.m4,$(DOC.out/)%,$(DOC.m4.in))
+
+DOC.texi.includes = $(wildcard $(DOC.in/)texi/*/*.texi)
+DOC.texi.articles = $(wildcard $(DOC.in/)texi/*.texi)
+
+DOC.texi2html.out = $(patsubst $(DOC.in/)texi/%.texi,$(DOC.out.articles/)html/%.html,$(DOC.texi.articles))
+DOC.texi2txt.out  = $(patsubst $(DOC.in/)texi/%.texi,$(DOC.out.articles/)txt/%.txt,$(DOC.texi.articles))
+DOC.texi2xml.out  = $(patsubst $(DOC.in/)texi/%.texi,$(DOC.out.articles/)xml/%.xml,$(DOC.texi.articles))
+
+BUILD.out += $(DOC.m4.out)
+BUILD.out += $(DOC.texi2html.out)
+BUILD.out += $(DOC.texi2txt.out)
+BUILD.out += $(DOC.texi2xml.out)
+
+###############################################################################
+
+DOC.M4.exe   = $(M4.exe)
+DOC.M4.flags = -I$(BUILD/)project
+DOC.M4.deps  = $(BUILD/)project/handbrake.m4
+DOC.M4       = $(DOC.M4.exe) $(DOC.M4.flags) $(2) > $(1)
+
+MAKEINFO.exe        = makeinfo
+MAKEINFO.flags      = -I$(DOC.out/)texi -I$(DOC.in/)texi
+MAKEINFO.flags.html = --html --no-headers --no-split
+MAKEINFO.flags.txt  = --plaintext --no-headers
+MAKEINFO.flags.xml  = --xml --output-indent=4
+MAKEINFO            = $(MAKEINFO.exe) $(MAKEINFO.flags) $(MAKEINFO.flags.$(1)) $(2) -o $(3)
diff --git a/doc/module.rules b/doc/module.rules
new file mode 100644 (file)
index 0000000..fc1d0b5
--- /dev/null
@@ -0,0 +1,35 @@
+$(eval $(call import.MODULE.rules,DOC))
+
+doc: doc.txt
+
+doc.post: doc.txt
+       $(CP.exe) $(DOC.out.articles/)txt/Building.osx.txt $(DOC.in/)BUILD-Mac
+       $(CP.exe) $(DOC.out.articles/)txt/Building.linux.txt $(DOC.in/)BUILD-Linux
+       $(CP.exe) $(DOC.out.articles/)txt/Building.cygwin.txt $(DOC.in/)BUILD-Cygwin
+
+doc.txt: $(DOC.texi2txt.out)
+doc.xml: $(DOC.texi2xml.out)
+
+doc.clean:
+       $(RM.exe) -fr $(DOC.out/)
+
+$(DOC.texi2txt.out): | $(DOC.m4.out)
+$(DOC.texi2txt.out): | $(dir $(DOC.texi2txt.out))
+$(DOC.texi2txt.out): $(DOC.texi.includes)
+$(DOC.texi2txt.out): $(DOC.out.articles/)txt/%.txt: $(DOC.in/)texi/%.texi
+       $(call MAKEINFO,txt,$<,$@)
+       @echo $^
+
+$(DOC.texi2xml.out): | $(DOC.m4.out)
+$(DOC.texi2xml.out): | $(dir $(DOC.texi2xml.out))
+$(DOC.texi2xml.out): $(DOC.texi.includes)
+$(DOC.texi2xml.out): $(DOC.out.articles/)xml/%.xml: $(DOC.in/)texi/%.texi
+       $(call MAKEINFO,xml,$<,$@)
+       @echo $^
+
+$(DOC.m4.out): | $(dir $(DOC.m4.out))
+$(DOC.m4.out): $(DOC.M4.deps)
+$(DOC.m4.out): $(DOC.out/)%: $(DOC.in/)%.m4
+       $(call DOC.M4,$@,$<)
+
+clean: doc.clean
diff --git a/doc/texi/Building.cygwin.texi b/doc/texi/Building.cygwin.texi
new file mode 100644 (file)
index 0000000..583755b
--- /dev/null
@@ -0,0 +1,48 @@
+@input texinfo @c -*- Texinfo -*-
+@c %**start of header
+@setfilename Building.cygwin.info
+@include base/article.texi
+@include building/command.texi
+@paragraphindent none
+
+@set BG.platform cygwin
+@c %**end of header
+
+@majorheading Guide to Building @value{HB.title} on @value{OS.@value{BG.platform}}
+@contents
+@include building/chapter.introduction.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{prerequisites}
+@chapter Prerequisites
+The following are the recommended specifications for building on @value{OS.cygwin}; but is not necessarily the only configuration that is possible:
+
+@itemize @bullet
+@item Intel 32-bit or 64-bit hardware (only 32-bit product binaries are supported)
+@item @value{OS.cygwin}, gcc 4.2.4
+@item yasm 0.7.2.2153 (for i386 or x86_64 architectures)
+@end itemize
+
+@include building/prerequisites.bundled.texi
+
+@quotation Note
+As of this writing, @value{OS.cygwin} has available to it several versions of gcc; only one of which may be found and used in the path as @code{gcc} and @code{g++}. Configure will thus find what is probably the older version of gcc in a typical @value{OS.cygwin} environment. If you desire to build with the newer gcc, it is found in the path as @command{gcc-4} and @command{g++-4} respectively and you must indicate to configure the desired versions. The following syntax should do the trick:
+@end quotation
+
+@example
+../configure --gcc=gcc-4
+@end example
+
+@include building/prerequisites.common.texi
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.quickstart.texi
+
+@anchor{overview}
+@chapter Overview
+@value{OS.cygwin} builds are performed from a @b{terminal}. There is no support for building from any IDEs.
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.via.terminal.texi
+@include building/chapter.troubleshooting.texi
+@include building/appendix.repo.texi
diff --git a/doc/texi/Building.linux.texi b/doc/texi/Building.linux.texi
new file mode 100644 (file)
index 0000000..cd11e1a
--- /dev/null
@@ -0,0 +1,110 @@
+@input texinfo @c -*- Texinfo -*-
+@c %**start of header
+@setfilename Building.linux.info
+@include base/article.texi
+@include building/command.texi
+@paragraphindent none
+
+@set BG.platform linux
+@c %**end of header
+
+@majorheading Guide to Building @value{HB.title} on @value{OS.@value{BG.platform}}
+@contents
+@include building/chapter.introduction.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{prerequisites}
+@chapter Prerequisites
+The following are the recommended specifications for building on @value{OS.linux}; but is not necessarily the only configuration that is possible:
+
+@itemize @bullet
+@item Intel 32-bit or 64-bit kernel
+@item Ubuntu 8.0.4, gcc 4.3.0, yasm 0.7.1.2093
+@item Ubuntu 8.10, gcc 4.3.2, yasm 0.7.1.2093
+@item Fedora 9, gcc 4.3.0, yasm 0.7.1.2093
+@item Fedora 10, gcc 4.3.2, yasm 0.7.1.2093
+@item gcc 4.0.0 or higher is reported to work
+@end itemize
+
+@include building/prerequisites.bundled.texi
+
+@include building/prerequisites.common.texi
+
+The @b{GTK UI} introduces some significant extra build requirements. If you intend to disable building the GUI with @command{configure --disable-gtk} you will not need many of these packages installed:
+
+Ubuntu 8.10 packages:
+@itemize @bullet
+@item subversion (cli/gui)
+@item yasm (cli/gui)
+@item build-essential (cli/gui)
+@item autoconf (cli/gui)
+@item libtool (cli/gui)
+@item zlib1g-dev (cli/gui)
+@item libbz2-dev (cli/gui)
+@item intltool (gui)
+@item libglib2.0-dev (gui)
+@item libdbus-glib-1-dev (gui)
+@item libgtk2.0-dev (gui)
+@item libhal-dev (gui)
+@item libhal-storage-dev (gui)
+@item libwebkit-dev (gui)
+@item libnotify-dev (gui)
+@item libgstreamer0.10-dev (gui)
+@item libgstreamer-plugins-base0.10-dev (gui)
+@end itemize
+
+To install these packages:
+@example
+sudo apt-get install subversion yasm build-essential \
+autoconf libtool zlib1g-dev libbz2-dev intltool libglib2.0-dev \
+libdbus-glib-1-dev libgtk2.0-dev libhal-dev libhal-storage-dev \
+libwebkit-dev libnotify-dev libgstreamer0.10-dev \
+libgstreamer-plugins-base0.10-dev
+@end example
+
+Fedora 10 package groups:
+@itemize @bullet
+@item Development Tools
+@item Development Libraries
+@item X Software Development (gui)
+@item GNOME Software Development (gui)
+@end itemize
+
+To install these package groups:
+@example
+sudo yum groupinstall "Development Tools" "Development Libraries" \
+"X Software Development" "GNOME Software Development"
+@end example
+
+Additional Fedora 10 packages:
+@itemize @bullet
+@item yasm (cli/gui)
+@item zlib-devel (cli/gui)
+@item bzip2-devel (cli/gui)
+@item dbus-glib-devel (gui)
+@item hal-devel (gui)
+@item webkitgtk-devel (gui)
+@item libnotify-devel (gui)
+@item gstreamer-devel (gui)
+@item gstreamer-plugins-base-devel (gui)
+@end itemize
+
+To install these packages:
+@example
+sudo yum install yasm zlib-devel bzip2-devel \
+dbus-glib-devel hal-devel webkitgtk-devel libnotify-devel\
+gstreamer-devel gstreamer-plugins-base-devel
+@end example
+
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.quickstart.texi
+
+@anchor{overview}
+@chapter Overview
+@value{OS.linux} builds are performed from a @b{terminal}. There is no support for building from any IDEs.
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.via.terminal.texi
+@include building/chapter.troubleshooting.texi
+@include building/appendix.repo.texi
diff --git a/doc/texi/Building.osx.texi b/doc/texi/Building.osx.texi
new file mode 100644 (file)
index 0000000..ee3f826
--- /dev/null
@@ -0,0 +1,71 @@
+@input texinfo @c -*- Texinfo -*-
+@c %**start of header
+@setfilename Building.osx.info
+@include base/article.texi
+@include building/command.texi
+@paragraphindent none
+
+@set BG.platform osx
+@c %**end of header
+
+@majorheading Build Guide for @value{HB.name} @value{HB.version} on @value{OS.@value{BG.platform}}
+
+@contents
+@include building/chapter.introduction.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{prerequisites}
+@chapter Prerequisites
+Building on @value{OS.osx} is well supported. It is the reference platform for @value{HB.name}. The following are the recommended specifications for this platform; but is not necessarily the only configuration that is possible:
+
+@itemize @bullet
+@item Mac Intel hardware
+@item @value{OS.osx} 10.5.7
+@item Xcode-3.1.2
+@item gcc 4.0.1 (Apple Inc. build 5490)
+@item yasm 0.8.0.2194 (for i386 and x86_64 architectures)
+@end itemize
+
+@include building/prerequisites.bundled.texi
+@include building/prerequisites.common.texi
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.quickstart.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{overview}
+@chapter Overview
+The two general methods to build on @value{OS.osx} are from @b{terminal} or @b{Xcode.app}. The preferred method for automated and repeatable builds is to use the terminal. Otherwise the choice is generally up to the individual. To be extra clear, building from the terminal by default actually invokes @command{xcodebuild} to build the very same targets contained in the Xcode project. Think of it as building with Xcode but without the GUI.
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.via.terminal.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.ub}
+@section Universal Binaries
+This section outlines convenience procedures for creating Universal Binaries for all the architectures.
+
+@quotation Note
+The dummy (container) build configuration uses @command{--disable-xcode}; but the nested architecture builds will all make full use of Xcode.
+@end quotation
+
+Create a dummy (container) build configuration and use it to launch a nested-build for each architecture @i{serially}; optionally you may substitute @command{make ub.build.serial} for @command{make ub.build.parallel} if your machine has the horsepower:
+
+@example
+./configure --disable-xcode
+cd build/
+make ub.build.serial
+make ub.combine
+@end example
+
+To specify a subset of architectures to be built first create/edit @file{_SRC_/custom.defs} with the following override to build UB for @samp{i386} and @samp{x86_64} before invoking @command{make}:
+
+@example
+## prefer i386 (order is important)
+UB.archs = i386 x86_64
+@end example
+
+@c %**-------------------------------------------------------------------------
+@include building/chapter.via.xcode.texi
+@include building/chapter.troubleshooting.texi
+@include building/appendix.repo.texi
diff --git a/doc/texi/base/article.texi b/doc/texi/base/article.texi
new file mode 100644 (file)
index 0000000..7ff6c74
--- /dev/null
@@ -0,0 +1,6 @@
+@ifhtml
+@exampleindent 0
+@end ifhtml
+
+@include base/handbrake.texi
+@include base/glossary.texi
diff --git a/doc/texi/base/glossary.texi b/doc/texi/base/glossary.texi
new file mode 100644 (file)
index 0000000..1a998f4
--- /dev/null
@@ -0,0 +1,7 @@
+@set OS.cygwin   Cygwin
+@set OS.freebsd  FreeBSD
+@set OS.linux    Linux
+@set OS.osx      Mac OS X
+@set OS.solaris  Solaris
+@set OS.unix     unix
+@set OS.windows  Windows
diff --git a/doc/texi/base/handbrake.texi.m4 b/doc/texi/base/handbrake.texi.m4
new file mode 100644 (file)
index 0000000..0466df7
--- /dev/null
@@ -0,0 +1,29 @@
+changequote(<<,>>)dnl
+include(<<handbrake.m4>>)dnl
+dnl
+dnl
+dnl
+@set HB.title           __HB_title
+@set HB.name            __HB_name
+@set HB.name.lower      __HB_name_lower
+@set HB.name.upper      __HB_name_upper
+@set HB.acro.lower      __HB_acro_lower
+@set HB.acro.upper      __HB_acro_upper
+@set HB.url.website     __HB_url_website
+@set HB.url.community   __HB_url_community
+@set HB.url.irc         __HB_url_irc
+@set HB.url.appcast     __HB_url_appcast
+@set HB.version.major   __HB_version_major
+@set HB.version.minor   __HB_version_minor
+@set HB.version.point   __HB_version_point
+@set HB.version         __HB_version
+@set HB.version.hex     __HB_version_hex
+@set HB.build           __HB_build
+@set HB.repo.url        __HB_repo_url
+@set HB.repo.root       __HB_repo_root
+@set HB.repo.branch     __HB_repo_branch
+@set HB.repo.uuid       __HB_repo_uuid
+@set HB.repo.rev        __HB_repo_rev
+@set HB.repo.date       __HB_repo_date
+@set HB.repo.official   __HB_repo_official
+@set HB.repo.type       __HB_repo_type
diff --git a/doc/texi/building/appendix.repo.texi b/doc/texi/building/appendix.repo.texi
new file mode 100644 (file)
index 0000000..8d4ee0c
--- /dev/null
@@ -0,0 +1,10 @@
+@appendix Project Repository Details
+@example
+url:    @value{HB.repo.url}
+root:   @value{HB.repo.root}
+branch: @value{HB.repo.branch}
+uuid:   @value{HB.repo.uuid}
+rev:    @value{HB.repo.rev}
+date:   @value{HB.repo.date}
+type:   @value{HB.repo.type}
+@end example
diff --git a/doc/texi/building/chapter.introduction.texi b/doc/texi/building/chapter.introduction.texi
new file mode 100644 (file)
index 0000000..9c60533
--- /dev/null
@@ -0,0 +1,3 @@
+@anchor{introduction}
+@chapter Introduction
+This guide documents the recommended process to build @value{HB.name} on @value{OS.@value{BG.platform}} hosts from the official source-code repository. @b{Building from any other source is not supported}.
diff --git a/doc/texi/building/chapter.quickstart.texi b/doc/texi/building/chapter.quickstart.texi
new file mode 100644 (file)
index 0000000..6aee76b
--- /dev/null
@@ -0,0 +1,21 @@
+@anchor{quickstart}
+@chapter QuickStart
+This chapter is for building from a terminal/shell environment in as few commands as possible. Upon completion of the following commands you should have a fresh build of @value{HB.name}. Further instructions are available beginning with @ref{overview} which describes procedures suitable for repeating builds. This chapter should be skipped by those seeking more than a minimalist build.
+
+@example
+@COMMAND.checkout{}
+./configure --launch
+@end example
+
+The special option @command{--launch} selects launch mode and performs the following steps:
+
+@itemize
+@item assert scratch directory @file{build/} does not exist
+@item create scratch directory @file{build/}
+@item change to directory @file{build/}
+@item launch @command{make}
+@item capture build output to @file{build/log/build.txt}
+@item echo build output
+@item print elapsed time
+@item indicate if build ultimately succeeded or failed
+@end itemize
diff --git a/doc/texi/building/chapter.troubleshooting.texi b/doc/texi/building/chapter.troubleshooting.texi
new file mode 100644 (file)
index 0000000..4d42e76
--- /dev/null
@@ -0,0 +1,20 @@
+@anchor{troubleshooting}
+@chapter Troubleshooting
+When troubleshooting build issues, the following files relative to the @file{build/} directory may be especially useful:
+
+@table @file
+@item GNUmakefile
+Top-level makefile which contains build settings generated via @b{configure}.
+
+@item log/config.info.txt
+Record of output from @b{configure}.
+
+@item log/config.verbose.txt
+Record of verbose output from @b{configure}.
+
+@item log/build.txt
+Record of output from @command{configure --launch}. Similar output may be recorded using @command{make} depending on which shell is in use, eg: @command{make >& log/build.txt} or @command{make > log/build.txt 2>&1}.
+
+@item log/xcodemake.env.txt
+Environment (variables) dump as seen when Xcode forks @command{make}. @value{OS.osx} only.
+@end table
diff --git a/doc/texi/building/chapter.via.terminal.texi b/doc/texi/building/chapter.via.terminal.texi
new file mode 100644 (file)
index 0000000..69f1424
--- /dev/null
@@ -0,0 +1,242 @@
+@anchor{terminal}
+@chapter Building via Terminal
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.checkout}
+@section Checkout Sources
+@include building/method.checkout.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.configure}
+@section Configure
+Configure the build system.
+
+@example
+./configure
+@end example
+
+Configure will automatically create a scratch build directory @file{build} unless you use GNU-style build procedures and first @command{cd} to a directory other than top-level source. Additionally you may use @command{--build} to specify the directory. The name of the directory is arbitrary but it is recommended to use something which indicates transient files which are @b{not} checked into the repository.
+
+The @command{configure} utility accepts many options. It is recommended that you specify @command{--help} for the complete list of options. The following options are also documented here:
+
+@table @samp
+@item --help
+List available options.
+
+@item --src=DIR
+Specify top-level source directory for @value{HB.name} sources.
+
+@item --build=DIR
+Specify destination directory for final product install. The default is to use either @file{build} if in the top-level source directory, otherwise @file{.} 
+
+@item --prefix=DIR
+Specify destination directory for final product install.
+This defaults to a reasonable platform-specific value.
+
+@item --launch
+All-in-one option which launches the build and logs output automatically.
+Useful for novices and quick-start procedures.
+
+@item --disable-xcode
+Disable shunting the build through @command{xcodebuild}. If this option is applied, @command{HandBrakeCLI} will be produced in a similar fashion as it is on other platforms; sans Xcode and the Cocoa application will not be produced. @value{OS.osx} only.
+
+@item --disable-gtk
+Disable building the GTK GUI on applicable platforms such as @value{OS.linux}.
+
+@item --debug=MODE
+Select debug mode. Must be one of @samp{none}, @samp{min}, @samp{std}, @samp{max}.
+This generally maps to gcc options @samp{-g0}, @samp{-g1}, @samp{-g2}, @samp{-g3}.
+
+@item --optimize=MODE
+Select optimize mode. Must be one of @samp{none}, @samp{speed}, @samp{size}.
+This generally maps to gcc options @samp{-g0}, @samp{-O0}, @samp{-O3}, @samp{-Os}.
+
+@item --arch=MODE
+Select build architecture. The available architectures vary by platform. Most platforms support exactly one architecture except @value{OS.osx} which has support for various universal binary architectures. The available choices are hard-coded per platform and no sanity checks for the required tools are performed.
+
+@end table
+
+Clean-room procedures dictate that when certain factors change, old builds should be scrapped and new builds configured. This is the main reason for requiring a scratch directory; to promote consistent, reliable and clean software builds. The following is a short list of some of the reasons why someone may choose to scrap an existing build:
+
+@itemize
+@item configure with different options
+@item subversion working dir is updated and you want configure to re-evaluate working dir metadata.
+@item build corruption is suspected
+@end itemize
+
+There are generally two methods for scrapping a build. The @file{build} directory can be recursively removed which has the effect of loosing your existing configuration but does guarantee no residuals are left behind. The other method is to ask the build system to perform an @command{make xclean}. This is known to work well but will leave empty directories behind. However, the configuration is left intact.
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.build}
+@section Build
+Build main product. All necessary dependencies are also built if required.
+
+@example
+make
+@end example
+
+Parallel builds may optionally be enabled. Be aware that while a parallel build may save time on systems with additional cores, the output is often mixed, overlapped and sometimes even corrupted with binary characters. Thus if you experience a build issue, you should clean and redo the build in default serial mode to produce a readable log. The following command allows for up to 4 concurrent jobs via make:
+
+@example
+make -j4
+@end example
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.targets}
+@section Make Targets
+
+The build system supports passing many kinds of targets some of which become very useful in normal development cycles. The targets by convention are lower-case words passed to @command{make}. Global targets are one-word targets. Scoped targets are usually two-words separated by a period.
+
+@anchor{terminal.targets.global}
+@subsection Global
+
+@table @samp
+@item make
+Alias for @samp{make build}.
+
+@item make build
+Build main product. All necessary dependencies are also built if required.
+
+@item make clean
+Clean all build output excluding contrib modules. Configuration is retained.
+
+@item make install
+Perform final product(s) install.
+This will install build products to a standard directory or one specified via @command{configure --prefix} option.
+
+@item make uninstall
+Perform final product(s) uninstall.
+This will uninstall any products which may have been previously installed.
+
+@item make xclean
+Clean all build output including contrib modules. Configuration is retained.
+
+@item make doc
+Build auto-generated project documentation. Various articles are produced and may be found in @file{build/doc/articles}.
+
+@item make report.help
+Print list of available makefile vars report targets.
+These reports detail var definitions and expanded values used by the build system.
+@b{For experts only}.
+
+@item make report.all
+Convenience target which aggregates all reports.
+@b{For experts only}.
+@end table
+
+@anchor{terminal.targets.general}
+@subsection General Modules
+
+General modules such as @samp{libhb}, @samp{test} and @samp{gtk} have the following scoped targets:
+
+@table @samp
+@item make @i{MODULE}.build
+Build @i{MODULE}.
+
+@item make @i{MODULE}.clean
+Clean build output for @i{MODULE}.
+@end table
+
+@anchor{terminal.targets.contrib}
+@subsection Contrib Modules
+
+Contrib modules such as @samp{a52dec}, @samp{bzip2}, @samp{faac}, @samp{faad2}, @samp{ffmpeg}, @samp{lame}, @samp{libdca}, @samp{libdvdread}, @samp{libmkv}, @samp{libogg}, @samp{libsamplerate}, @samp{libtheora}, @samp{libvorbis}, @samp{mp4v2}, @samp{mpeg2dec}, @samp{x264} and @samp{zlib} have the following scoped targets:
+
+@table @samp
+@item make @i{MODULE}.fetch
+Download source tarball from the Internet and save to @file{TOP/downloads} directory. No check-summing is performed.
+
+@item make @i{MODULE}.extract
+Extract source tarball into @file{build} tree.
+
+@item make @i{MODULE}.patch
+Apply appropriate patches (if any) to module sources.
+
+@item make @i{MODULE}.configure
+Configure module sources.
+This usually invokes autotool configure.
+
+@item make @i{MODULE}.build
+Build module.
+This usually invokes autotool build.
+
+@item make @i{MODULE}.install
+Install module products such as headers and libraries into @file{build} tree.
+This usually invokes autotool install.
+
+@item make @i{MODULE}.uninstall
+Uninstall module products; generally the reverse of install.
+This usually invokes autotool uninstall.
+
+@item make @i{MODULE}.clean
+Clean module; generally the reverse of build.
+This usually invokes autotool clean.
+
+@item make @i{MODULE}.xclean
+Extra clean module; first invokes uninstall then recursively removes the module build directory.
+@end table
+
+@anchor{terminal.targets.contrib.touch}
+@subsection Contrib Touch and Untouch
+Also available are some very granular targets which help force builds from specific cycle points. The following targets are available to touch and untouch the respective module target; this will force the build system to treat the target as satisfied after a touch or unsatisfied after an untouch:
+
+@itemize
+@item make @i{MODULE}.extract.touch
+@item make @i{MODULE}.extract.untouch
+@item make @i{MODULE}.patch.touch
+@item make @i{MODULE}.patch.untouch
+@item make @i{MODULE}.configure.touch
+@item make @i{MODULE}.configure.untouch
+@item make @i{MODULE}.build.touch
+@item make @i{MODULE}.build.untouch
+@item make @i{MODULE}.install.touch
+@item make @i{MODULE}.install.untouch
+@end itemize
+
+@anchor{terminal.targets.contrib.aggregate}
+@subsection Contrib Aggregates
+For convenience, the following targets aggregate the all contrib modules' respective targets together:
+
+@itemize
+@item make contrib.fetch
+@item make contrib.extract
+@item make contrib.patch
+@item make contrib.configure
+@item make contrib.build
+@item make contrib.install
+@item make contrib.uninstall
+@item make contrib.clean
+@item make contrib.xclean
+@end itemize
+
+@c %**-------------------------------------------------------------------------
+@anchor{terminal.customizing}
+@section Customizing Make
+If the need arises to override settings in the build system (essentially gnu-make variables) the recommended method is to create optional include files which are automatically included if present and follow this naming convention; @b{Do not check these files into the repository}:
+
+@table @file
+@item _SRC_/custom.defs
+Custom makevar definitions @i{outside} @file{build}. Suitable for settings which apply across all builds for a particular checkout; or which survives manual removal of @file{build}.
+
+@item _SRC_/custom.rules
+Custom make rules @i{outside} @file{build}. Suitable for rules which apply across all builds for a particular checkout; or which survives manual removal of @file{build}.
+
+@item _BUILD_/GNUmakefile.custom.defs
+Custom makevar definitions specific to a @file{build} directory.
+
+@item _BUILD_/GNUmakefile.custom.rules
+Custom makevar rules specific to a @file{build} directory.
+
+@end table
+
+The purpose is to allow a place to store local build settings for testing, tweaking, and experimenting with build configuration without losing your settings if @command{configure} is invoked; ie: @command{configure} would overwrite @file{GNUmakefile} and any customizations contained therein would be lost. Here is a short example of what the contents of @file{_SRC_/custom.defs} might contain:
+
+@example
+## bump to gcc-4.2 in current path
+GCC.gcc = /usr/bin/gcc-4.2
+
+## replace optimize for 'speed' with more aggressive settings
+GCC.args.O.speed = -O3 -fomit-frame-pointer -msse4.2
+@end example
+
+See also @command{make report.help} which displays a set of reports used to dump makefile vars.
diff --git a/doc/texi/building/chapter.via.xcode.texi b/doc/texi/building/chapter.via.xcode.texi
new file mode 100644 (file)
index 0000000..2b79a7b
--- /dev/null
@@ -0,0 +1,108 @@
+@anchor{xcode}
+@chapter Building via Xcode.app
+
+@c %**-------------------------------------------------------------------------
+@anchor{xcode.checkout}
+@section Checkout Sources
+@include building/method.checkout.texi
+
+@c %**-------------------------------------------------------------------------
+@anchor{xcode.build}
+@section Build
+Open Xcode.app from a terminal by using the @command{open} command which passes your shell environment and its @samp{PATH} setting to Xcode. Do not attempt to launch Xcode.app from Finder or by using Finder to open @file{HandBrake.xcodeproj} -- doing so will defeat any custom path settings which contain required tools.
+
+@example
+open @file{macosx/HandBrake.xcodeproj}
+@end example
+
+Once the HandBrake Xcode project is open, perform the following steps to build the default configuration:
+
+@itemize
+@item select active configuration @b{standard}
+@item select active target @b{HandBrake}
+@item click @b{Build} or @b{Build and Go}
+@end itemize
+
+The first build (on an empty @file{build} directory) will take a bit of time. You may use the Build Results window to observe progress. The most time-consuming part of the build is when the external build system (essentially the @b{terminal} method) is triggered by Xcode and a substantial amount of log transcript ensues. Much of that transcript are warnings and errors that are part of the normal build process for 3rd-party contributed modules so in general you need not do anything. However, if Xcode itself reports the build failed, then you must take corrective action.
+
+Unfortunately, due to limitations of Xcode we do not have hooks in place to offer finer-grained control over per-module make actions for the (external) build system. Thus, you will have to use @b{terminal} to accomplish those tasks. Just @command{cd} into the build directory which is associated with your active configuration and perform any necessary @command{make} commands. @b{Be careful not to issue commands from the terminal simultaneously with Xcode tasks} as that will confuse both Xcode and make and likely corrupt your build directory.
+
+When you click @b{clean} in Xcode it will not perform an external build clean. Basically @b{HandBrakeCLI} and @b{HandBrake.app} are the only products which have full Xcode iterative development flexibility.
+
+Each configuration uses a different @file{build} directory. This makes it possible to build each configuration and switch between them without losing their respective build state. The description of each configuration and the name convention for build directories are as follows:
+
+@table @samp
+@item standard
+This configuration will build @b{host native} architecture. Build directory is @file{build.standard} .
+The standard variant produces optimized code without debug information.
+
+@item standard.i386
+This configuration will build @b{i386} architecture. Build directory is @file{build.standard.i386} .
+
+@item standard.x86_64
+This configuration will build @b{x86_64} architecture. Build directory is @file{build.standard.x86_64} .
+
+@item standard.ppc
+This configuration will build @b{ppc} architecture. Build directory is @file{build.standard.ppc} .
+
+@item standard.ppc64
+This configuration will build @b{ppc64} architecture. Build directory is @file{build.standard.ppc64} .
+
+@item debug
+This configuration will build @b{host native architecture}. Build directory is @file{build.debug} .
+The debug variant produces unoptimized code with debug information.
+
+@item debug.i386
+This configuration will build @b{i386} architecture. Build directory is @file{build.debug.i386} .
+The debug variant produces unoptimized code with debug information.
+
+@item debug.x86_64
+This configuration will build @b{x86_64} architecture. Build directory is @file{build.debug.x86_64} .
+The debug variant produces unoptimized code with debug information.
+
+@item debug.ppc
+This configuration will build @b{ppc} architecture. Build directory is @file{build.debug.ppc} .
+The debug variant produces unoptimized code with debug information.
+
+@item debug.ppc64
+This configuration will build @b{ppc64} architecture. Build directory is @file{build.debug.ppc64} .
+The debug variant produces unoptimized code with debug information.
+@end table
+
+@c %**-------------------------------------------------------------------------
+@anchor{xcode.extenal}
+@section External Targets
+The following external targets appear in the Xcode project and perform @b{build} and @b{clean} actions.
+
+@table @samp
+@item external
+Target maps to @command{make build} and @command{make clean} for everything Xcode products depend upon from the external build system.
+
+@item libhb
+Target maps to @command{make libhb.build} and @command{make libhb.clean}.
+
+@item contrib
+Target maps to @command{make contrib.build} and @command{make contrib.xclean}.
+
+@end table
+
+@c %**-------------------------------------------------------------------------
+@anchor{xcode.userdefined}
+@section User-Defined Settings
+The following user defined settings are used in Xcode project for the external build system:
+
+@table @samp
+@item EXTERNAL_BUILD
+Specifies the build (scratch) directory for each configuration.
+
+@item EXTERNAL_JOBS
+Specifies the concurrency factor for the external build system when builds are launched from within Xcode.
+Modify for faster external builds if your system has the horsepower and resources. Specifying a value greater than the number of CPU cores (or virtual cores) in your system is unlikely to produce gains and will needlessly consume extra resources.
+
+@item EXTERNAL_METHOD
+Do not modify; Used for internal/external build coordination and must always be @samp{xcode}.
+
+@item EXTERNAL_SRC
+Specifies the top-level source directory for @value{HB.name}.
+
+@end table
diff --git a/doc/texi/building/command.texi b/doc/texi/building/command.texi
new file mode 100644 (file)
index 0000000..3acddc3
--- /dev/null
@@ -0,0 +1,4 @@
+@macro COMMAND.checkout{}
+svn checkout @value{HB.repo.url} @value{HB.acro.lower}-@value{HB.repo.branch}
+cd @value{HB.acro.lower}-@value{HB.repo.branch}
+@end macro
diff --git a/doc/texi/building/method.checkout.texi b/doc/texi/building/method.checkout.texi
new file mode 100644 (file)
index 0000000..ca2352c
--- /dev/null
@@ -0,0 +1,9 @@
+Checkout @value{HB.name} from the official source-code repository.
+
+@example
+@COMMAND.checkout{}
+@end example
+
+Sources are checked out from the @samp{@value{HB.repo.branch}} branch. This document was generated from that very branch, and for example purposes, we will use exactly the same branch.
+
+If you have write-access to the repository, then you may add the appropriate login/password information as needed. It is recommended to use Subversion 1.5.0 or higher. Lower versions should also work.
diff --git a/doc/texi/building/prerequisites.bundled.texi b/doc/texi/building/prerequisites.bundled.texi
new file mode 100644 (file)
index 0000000..f5af0fc
--- /dev/null
@@ -0,0 +1,3 @@
+@quotation Note
+It is recommended to use the platform distribution's bundled compiler for maximum C++ compatibility. If you build with a custom compiler it will likely introduce non-standard runtime requirements. There are of course many valid reasons to build with unbundled compilers, but be aware it is generally unsupported and left as an exercise to the reader.
+@end quotation
diff --git a/doc/texi/building/prerequisites.common.texi b/doc/texi/building/prerequisites.common.texi
new file mode 100644 (file)
index 0000000..a975f9d
--- /dev/null
@@ -0,0 +1,12 @@
+The following general tools are used on various platforms and it is recommended you use these versions or similar:
+
+@itemize @bullet
+@item subversion - 1.6.2
+@item python - Python 2.4.6
+@item curl - curl 7.19.4 (or wget)
+@item m4 - GNU M4 1.4.6
+@item make - GNU Make 3.81
+@item patch - Patch 2.5.8
+@item tar - GNU tar 1.15.1
+@item wget - GNU Wget 1.11.4 (or curl)
+@end itemize
index 5fbda7c..19050d9 100644 (file)
@@ -4,13 +4,6 @@
 SUBDIRS = src po
 
 ghbdocdir = ${prefix}/share/doc/ghb
-ghbdoc_DATA = \
-       README\
-       COPYING\
-       AUTHORS\
-       ChangeLog\
-       INSTALL\
-       NEWS
 
 EXTRA_DIST = $(ghbdoc_DATA)
 
index 6b051eb..0a1b251 100644 (file)
@@ -3,7 +3,7 @@ dnl Created by Anjuta application wizard.
 
 AC_INIT(ghb, 0.1)
 
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
+AM_INIT_AUTOMAKE([1.7.9 foreign dist-bzip2 dist-zip])
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
@@ -17,7 +17,7 @@ AC_HEADER_STDC
 AC_ARG_WITH(hb,
        AC_HELP_STRING(
            [--with-hb=prefix],
-           [try this for the bh-library prefix install directory]
+           [try this for the hb-library prefix install directory]
          ),
          hb_PATHSET=1,
          hb_PATHSET=0
@@ -45,6 +45,10 @@ else
        AC_SUBST(HB_DIR, '$(top_srcdir)/'"..")
 fi
 
+AC_ARG_ENABLE(gst,
+       AS_HELP_STRING([--enable-gst], [enable gstreamer on Win32]),
+       w32_gst=yes, w32_gst=no)
+
 # overwrite global variable (used for Makefile generation)
 AC_SUBST(GLOBALCXXFLAGS, $CXXFLAGS )
 AC_SUBST(GLOBALLDFLAGS, $LDFLAGS )
@@ -60,23 +64,48 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
 AM_GLIB_GNU_GETTEXT
 IT_PROG_INTLTOOL([0.35.0])
 
-
-
 AM_PROG_LIBTOOL
 
+case $host in
+  *-*-mingw*)
+    if test "x$w32_gst" = "xyes" ; then
+               GHB_PACKAGES="gtk+-2.0 >= 2.10 gthread-2.0 gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-pbutils-0.10 gio-2.0"
+       else
+        GHB_PACKAGES="gtk+-2.0 >= 2.10 gthread-2.0 gio-2.0"
+       fi
+       mingw_flag=yes
+    ;;
+  *)
+       GHB_PACKAGES="gtk+-2.0 >= 2.10 gthread-2.0 gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-pbutils-0.10 gio-2.0 hal hal-storage libnotify"
+       mingw_flag=no
+    ;;
+esac
+
+if test "x$w32_gst" = "xyes" -o  "x$mingw_flag" != "xyes" ; then
+       CXXFLAGS="$CXXFLAGS -D_ENABLE_GST"
+       CFLAGS="$CFLAGS -D_ENABLE_GST"
+fi
+
+PKG_CHECK_MODULES(OldWebKitGtk, WebKitGtk, old_webkit=yes, old_webkit=no)
+if test "x$old_webkit" = "xyes" ; then
+       if test "x$mingw_flag" = "xno" ; then
+               GHB_PACKAGES="$GHB_PACKAGES WebKitGtk"
+               CXXFLAGS="$CXXFLAGS -D_OLD_WEBKIT"
+               CFLAGS="$CFLAGS -D_OLD_WEBKIT"
+       fi
+else
+       if test "x$mingw_flag" = "xno" ; then
+               GHB_PACKAGES="$GHB_PACKAGES webkit-1.0"
+       fi
+fi
 
+AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
 
-PKG_CHECK_MODULES(GHBTOOLS, [glib-2.0 gobject-2.0 gdk-pixbuf-2.0])
-AC_SUBST(GHBTOOLS_CFLAGS)
-AC_SUBST(GHBTOOLS_LIBS)
+PKG_CHECK_MODULES(GHB, [$GHB_PACKAGES])
 
-PKG_CHECK_MODULES(GHB, [gtk+-2.0 >= 2.8 gio-2.0 hal hal-storage libgtkhtml-3.14])
 AC_SUBST(GHB_CFLAGS)
 AC_SUBST(GHB_LIBS)
 
-
-
-
 AC_OUTPUT([
 Makefile
 src/Makefile
index 83cdab4..5b83853 100644 (file)
@@ -1,61 +1,86 @@
-Name:          handbrake
-Version:       0.9.2
-Release:       1%{?dist}
-Summary:       A program to rip and encode DVDs and other sources to MPEG-4
+%define name HandBrake
+%define release 1
+
+Name:          %{name}
+Version:       %{version}
+Release:       %{release}%{?dist}
+Summary:       A program to transcode DVDs and other sources to MPEG-4
 
 Group:         Applications/Multimedia
 License:       GPL
 URL:           http://handbrake.fr/
-Source0:       HandBrake.tgz
+Vendor:                The HandBrake Project
+Source0:       %{name}-%{version}.tar.bz2
+Prefix:                %{_prefix}
 BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-Requires:      glib2 >= 2.16, gtk2 >= 2.12, hal-libs
+Requires:      glib2 >= 2.16, gtk2 >= 2.12, hal-libs, webkitgtk, gstreamer
+Requires:      gstreamer-plugins-base
 
 %description
 HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded 
-DVD to MPEG-4 converter, available for MacOS X, Linux and Windows.
+transcoder, available for MacOS X, Linux and Windows.
+
+%package gui
+Summary:       A program to transcode DVDs and other sources to MPEG-4
+Group:         Applications/Multimedia
+
+%package cli
+Summary:       A program to transcode DVDs and other sources to MPEG-4
+Group:         Applications/Multimedia
+
+%description gui
+HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded 
+transcoder, available for MacOS X, Linux and Windows.
+
+%description cli
+HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded 
+transcoder, available for MacOS X, Linux and Windows.
 
 %prep
-%setup -q
+%setup -n %{name}-%{version} -D -T
+#%setup -q
+#cd %{_builddir}/%{name}-%{version}
 
 
 %build
-%configure
-jam
+#./configure --prefix=%{_prefix}
+#make -C build
 
 
 %install
-rm -rf $RPM_BUILD_ROOT
-DESTDIR=$RPM_BUILD_ROOT jam install 
+#rm -rf $RPM_BUILD_ROOT
+# I don't want to rebuild the world, so just install what I've prebuilt
+make -C $RPM_BUILD_ROOT/../.. DESTDIR=$RPM_BUILD_ROOT install
 
 ## blow away stuff we don't want
-/bin/rm $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/icon-theme.cache
+/bin/rm -f $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/icon-theme.cache
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post
+%post gui
 touch --no-create %{_datadir}/icons/hicolor
 if [ -x /usr/bin/gtk-update-icon-cache ]; then
   gtk-update-icon-cache -q %{_datadir}/icons/hicolor
 fi
 
-%postun
-/sbin/ldconfig
+%postun gui
 touch --no-create %{_datadir}/icons/hicolor
 if [ -x /usr/bin/gtk-update-icon-cache ]; then
   gtk-update-icon-cache -q %{_datadir}/icons/hicolor
 fi
 
-%files
+%files gui
 %defattr(-,root,root,-)
-%doc %{_datadir}/doc
-%{_datadir}/ghb
+%doc NEWS AUTHORS CREDITS THANKS COPYING
 %{_datadir}/icons
-%{_datadir}/locale
 %{_datadir}/applications
-%{_bindir}
+%{_bindir}/ghb
 
+%files cli
+%defattr(-,root,root,-)
+%doc NEWS AUTHORS CREDITS THANKS COPYING
+%{_bindir}/HandBrakeCLI
 
 %changelog
 * Sat May 31 2008 John Stebbins <jstebbins@jetheaddev.com> 
diff --git a/gtk/module.defs b/gtk/module.defs
new file mode 100644 (file)
index 0000000..8c1648d
--- /dev/null
@@ -0,0 +1,69 @@
+$(eval $(call import.MODULE.defs,GTK,gtk,LIBHB))
+$(eval $(call import.GCC,GTK))
+
+GTK.src/   = $(SRC/)gtk/
+GTK.build/ = $(BUILD/)gtk/
+
+GTK.CONFIGURE.stamp = $(GTK.build/).stamp.configure
+
+###############################################################################
+
+GTK.out += $(GTK.CONFIGURE.stamp)
+
+BUILD.out += $(GTK.out)
+
+###############################################################################
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+    GTK.GCC.D += PTW32_STATIC_LIB
+endif
+
+
+###############################################################################
+###############################################################################
+$(eval $(call import.MODULE.defs,HGTK,hgtk))
+$(eval $(call import.GCC,HGTK))
+
+HGTK.GCC.gcc = gcc
+HGTK.GCC.args.extra = $(shell pkg-config --cflags glib-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --cflags gdk-pixbuf-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --libs glib-2.0)
+HGTK.GCC.args.extra += $(shell pkg-config --libs gdk-pixbuf-2.0)
+
+HGTK.src/ = $(SRC/)gtk/src/
+HGTK.build/ = $(BUILD/)gtk/src/
+
+HGTKCOMMON.c = \
+       $(HGTK.src/)plist.c \
+       $(HGTK.src/)values.c
+
+HGTKCOMMON.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(HGTKCOMMON.c))
+
+CREATE_RES.c = \
+       $(HGTK.src/)create_resources.c \
+       $(HGTK.src/)icon_tools.c
+
+CREATE_RES.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(CREATE_RES.c))
+CREATE_RES.exe = $(HGTK.build/)create_resources
+
+WIDGETDEPS.c = \
+       $(HGTK.src/)widgetdeps.c
+
+WIDGETDEPS.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(WIDGETDEPS.c))
+WIDGETDEPS.exe = $(HGTK.build/)widgetdeps
+
+QUOTESTRING.c = \
+       $(HGTK.src/)quotestring.c
+
+QUOTESTRING.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%-native.o,$(QUOTESTRING.c))
+QUOTESTRING.exe = $(HGTK.build/)quotestring
+
+HGTK.out += $(HGTKCOMMON.c.o)
+HGTK.out += $(CREATE_RES.exe)
+HGTK.out += $(CREATE_RES.c.o)
+HGTK.out += $(WIDGETDEPS.exe)
+HGTK.out += $(WIDGETDEPS.c.o)
+HGTK.out += $(QUOTESTRING.exe)
+HGTK.out += $(QUOTESTRING.c.o)
+
+BUILD.out += $(HGTK.out)
diff --git a/gtk/module.rules b/gtk/module.rules
new file mode 100644 (file)
index 0000000..657a203
--- /dev/null
@@ -0,0 +1,86 @@
+$(eval $(call import.MODULE.rules,GTK))
+
+build: hgtk.build gtk.build
+install: gtk.install
+uninstall: gtk.uninstall
+clean: hgtk.clean gtk.clean
+xclean: hgtk.clean gtk.xclean
+
+gtk.configure: $(GTK.CONFIGURE.stamp)
+
+$(GTK.CONFIGURE.stamp): | $(dir $(GTK.CONFIGURE.stamp))
+$(GTK.CONFIGURE.stamp): $(GTK.src/)Makefile.am
+$(GTK.CONFIGURE.stamp): $(GTK.src/)configure.ac $(GTK.src/)src/Makefile.am
+       set -e; cd $(GTK.src/); NOCONFIGURE=1 ./autogen.sh
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+       set -e; cd $(GTK.build/); $(call fn.ABSOLUTE,$(GTK.src/))configure \
+               --host=$(BUILD.spec) \
+               PKG_CONFIG_PATH=$(BUILD/)contrib/lib/pkgconfig \
+           CFLAGS="$(call fn.ARGS,GTK.GCC,.g .O *D ?extra)" \
+           LDFLAGS="$(call fn.ARGS,GTK.GCC,?strip .g .O) " \
+           --prefix=$(PREFIX) \
+           --with-hb=$(call fn.ABSOLUTE,$(BUILD/))
+else
+       set -e; cd $(GTK.build/); $(call fn.ABSOLUTE,$(GTK.src/))configure \
+               PKG_CONFIG_PATH=$(BUILD/)contrib/lib/pkgconfig \
+           CFLAGS="$(call fn.ARGS,GTK.GCC,.g .O ?extra)" \
+           LDFLAGS="$(call fn.ARGS,GTK.GCC,?strip .g .O)" \
+           --prefix=$(PREFIX) \
+           --with-hb=$(call fn.ABSOLUTE,$(BUILD/))
+endif
+       $(TOUCH.exe) $@
+
+gtk.build: | $(GTK.build/)
+gtk.build: $(GTK.CONFIGURE.stamp) $(LIBHB.a)
+       +$(MAKE) -C $(GTK.build/)
+
+gtk.install:
+       $(MAKE) -C $(GTK.build/) prefix=$(PREFIX) install-strip
+
+gtk.uninstall:
+       $(MAKE) -C $(GTK.build/) uninstall
+
+gtk.clean:
+       $(MAKE) -C $(GTK.build/) clean
+
+gtk.xclean:
+       $(MAKE) -C $(GTK.build/) distclean
+       $(RM.exe) -f $(GTK.out)
+       $(RM.exe) -fr $(GTK.build/)
+
+###############################################################################
+###############################################################################
+$(eval $(call import.MODULE.rules,HGTK))
+
+hgtk.build: $(CREATE_RES.exe) $(WIDGETDEPS.exe) $(QUOTESTRING.exe)
+
+$(CREATE_RES.exe): | $(dir $(CREATE_RES.exe))
+$(CREATE_RES.exe): $(CREATE_RES.c.o) $(HGTKCOMMON.c.o)
+       $(call HGTK.GCC.EXE,$@,$^)
+
+$(HGTKCOMMON.c.o): | $(dir $(HGTKCOMMON.c.o))
+$(HGTKCOMMON.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+
+$(CREATE_RES.c.o): | $(dir $(CREATE_RES.c.o))
+$(CREATE_RES.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+
+$(WIDGETDEPS.exe): | $(dir $(WIDGETDEPS.exe))
+$(WIDGETDEPS.exe): $(WIDGETDEPS.c.o) $(HGTKCOMMON.c.o)
+       $(call HGTK.GCC.EXE,$@,$^)
+
+$(WIDGETDEPS.c.o): | $(dir $(WIDGETDEPS.c.o))
+$(WIDGETDEPS.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+
+$(QUOTESTRING.c.o): | $(dir $(QUOTESTRING.c.o))
+$(QUOTESTRING.c.o): $(BUILD/)%-native.o: $(SRC/)%.c
+       $(call HGTK.GCC.C_O,$@,$<)
+
+$(QUOTESTRING.exe): | $(dir $(QUOTESTRING.exe))
+$(QUOTESTRING.exe): $(QUOTESTRING.c.o)
+       $(call HGTK.GCC.EXE,$@,$^)
+
+hgtk.clean:
+       $(RM.exe) -f $(HGTK.out)
index 4cae9d3..52be4d1 100644 (file)
@@ -1,34 +1,18 @@
 ## Process this file with automake to produce Makefile.in
 
-## Created by Anjuta
-
-#HB_LIBS=$(HB_DIR)/libhb/libhb.a -la52 -lmkv -lavformat -lavcodec -lavutil -ldca -ldvdread -lfaac -lmp3lame -lmpeg2 -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lxvidcore -lmp4v2 -lswscale -ltheora -lfaad -lz -lbz2 -lpthread
-
-HB_LIBS=\
-       $(HB_DIR)/libhb/libhb.a \
-       $(HB_DIR)/contrib/lib/liba52.a \
-       $(HB_DIR)/contrib/lib/libmkv.a \
-       $(HB_DIR)/contrib/lib/libavformat.a \
-       $(HB_DIR)/contrib/lib/libavcodec.a \
-       $(HB_DIR)/contrib/lib/libavutil.a \
-       $(HB_DIR)/contrib/lib/libdca.a \
-       $(HB_DIR)/contrib/lib/libdvdread.a \
-       $(HB_DIR)/contrib/lib/libfaac.a \
-       $(HB_DIR)/contrib/lib/libmp3lame.a \
-       $(HB_DIR)/contrib/lib/libmpeg2.a \
-       $(HB_DIR)/contrib/lib/libvorbis.a \
-       $(HB_DIR)/contrib/lib/libvorbisenc.a \
-       $(HB_DIR)/contrib/lib/libogg.a \
-       $(HB_DIR)/contrib/lib/libsamplerate.a \
-       $(HB_DIR)/contrib/lib/libx264.a \
-       $(HB_DIR)/contrib/lib/libxvidcore.a \
-       $(HB_DIR)/contrib/lib/libmp4v2.a \
-       $(HB_DIR)/contrib/lib/libswscale.a \
-       $(HB_DIR)/contrib/lib/libtheora.a \
-       $(HB_DIR)/contrib/lib/libfaad.a \
-       -lz \
-       -lbz2 \
-       -lpthread
+if MINGW
+HB_LIBS= \
+       -lhb -la52 -lmkv -lavformat -lavcodec -lavutil -ldca -ldvdnav -ldvdread \
+       -lfaac -lmp3lame -lmpeg2 -lvorbis -lvorbisenc -logg -lsamplerate \
+       -lx264 -lmp4v2 -lswscale -ltheora -lfaad -lz \
+       -lbz2 -liberty -lpthreadGC2
+else
+HB_LIBS= \
+       -lhb -la52 -lmkv -lavformat -lavcodec -lavutil -ldca -ldvdnav -ldvdread \
+       -lfaac -lmp3lame -lmpeg2 -lvorbis -lvorbisenc -logg -lsamplerate \
+       -lx264 -lmp4v2 -lswscale -ltheora -lfaad -lz \
+       -lbz2 -lpthread
+endif
 
 icons =        \
        hb-icon.128.png 
@@ -39,6 +23,8 @@ icons_dep =   \
        hb-canceled.16.png \
        hb-complete.16.png \
        hb-drawer.32.png \
+       hb-status.32.png \
+       hb-status-empty.32.png \
        hb-icon.128.png \
        hb-icon.64.png \
        hb-pause.32.png \
@@ -68,17 +54,9 @@ AM_CPPFLAGS = \
        -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
        $(GHB_CFLAGS)
 
-AM_CFLAGS =\
-        -Wall\
-        -g
+AM_CFLAGS = -Wall -g
 
 bin_PROGRAMS = ghb 
-noinst_PROGRAMS = makewidgetdeps quotestring create_resources preset_xlat
-
-BUILT_SOURCES = HandBrakeCLI
-
-HandBrakeCLI: $(HB_DIR)/HandBrakeCLI
-       /bin/cp $< $@
 
 # Dummy file, not built.  Forces g++ linking
 nodist_EXTRA_ghb_SOURCES = dummy.cpp
@@ -90,6 +68,8 @@ ghb_SOURCES = \
        queuehandler.h \
        audiohandler.c \
        audiohandler.h \
+       subtitlehandler.c \
+       subtitlehandler.h \
        x264handler.c \
        x264handler.h \
        main.c \
@@ -99,6 +79,7 @@ ghb_SOURCES = \
        resources.h \
        presets.c \
        presets.h \
+       preview.c \
        icons.c \
        icons.h \
        icon_tools.c \
@@ -115,71 +96,44 @@ ghb_SOURCES = \
        renderer_button.c \
        ghbcellrenderertext.c \
        ghbcellrenderertext.h \
+    ghbcompositor.c \
+    ghbcompositor.h \
        ghb-dvd.c \
        ghb-dvd.h \
        marshalers.c \
        marshalers.h
 
+if MINGW
 ghb_LDFLAGS = \
-       -Wl,--export-dynamic
+       -mwindows -Wl,--export-dynamic -Wl,--exclude-libs,ALL
+else
+ghb_LDFLAGS = \
+       -Wl,--export-dynamic -Wl,--exclude-libs,ALL
+endif
 
-ghb_LDADD = $(GHB_LIBS) $(HB_LIBS)
+ghb_LDADD = $(HB_LIBS) $(GHB_LIBS)
 
 ghb_DEPENDENCIES = $(HB_DIR)/libhb/libhb.a
 
-makewidgetdeps_SOURCES = \
-       plist.c \
-       plist.h \
-       values.c \
-       values.h \
-       makedeps.c 
-
-makewidgetdeps_LDADD = $(GHBTOOLS_LIBS)
-
-create_resources_SOURCES = \
-       create_resources.c \
-       plist.c \
-       plist.h \
-       values.c \
-       values.h \
-       icon_tools.c \
-       icon_tools.h
-
-create_resources_LDADD = $(GHBTOOLS_LIBS)
-
-preset_xlat_SOURCES = \
-       preset_xlat.c \
-       plist.c \
-       plist.h \
-       values.c \
-       values.h
-
-preset_xlat_LDADD = $(GHBTOOLS_LIBS)
-
-quotestring_SOURCES = quotestring.c
-
-dumbell: preset_xlat
-
-resources.c: resource_data.h
+resources.o: resource_data.h
 
 resource_data.h: quotestring resources.plist
        ./quotestring resources.plist resource_data.h
 
-widget_deps: makewidgetdeps
-       ./makewidgetdeps
-
-resources.plist: create_resources resources.list $(icons_dep) internal_defaults.xml standard_presets.xml ghb.ui widget_deps widget_reverse_deps
-       ./create_resources resources.list resources.plist
+widget_reverse.deps: widgetdeps
+widget.deps: widgetdeps
+       ./widgetdeps
 
-ghbcellrenderertext.c: marshalers.h
+resources.plist: create_resources resources.list $(icons_dep) internal_defaults.xml standard_presets.xml ghb.ui widget.deps widget_reverse.deps
+       ./create_resources -I$(srcdir) $(srcdir)/resources.list resources.plist
 
-marshalers.h: marshalers.list
-       glib-genmarshal --prefix=ghb_marshal marshalers.list --header > marshalers.h
+ghbcellrenderertext.$(OBJEXT): marshalers.h
 
-marshalers.c: marshalers.list
-       glib-genmarshal --prefix=ghb_marshal marshalers.list --body > marshalers.c
+$(srcdir)/marshalers.h: marshalers.list
+       glib-genmarshal --prefix=ghb_marshal $(srcdir)/marshalers.list --header > $(srcdir)/marshalers.h
 
-EXTRA_DIST = HandBrakeCLI
+$(srcdir)/marshalers.c: marshalers.list
+       glib-genmarshal --prefix=ghb_marshal $(srcdir)/marshalers.list --body > $(srcdir)/marshalers.c
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(DESTDIR)/$(datadir)/icons/hicolor
 
@@ -195,7 +149,7 @@ uninstall-local:
                fi; \
                rm -f $(DESTDIR)/$(datadir)/icons/hicolor/$$SIZE/apps/$$FILE; \
        done
-       @-if test -n "$(DESTDIR)/$(datadir)"; then \
+       @-if test -z "$(DESTDIR)"; then \
                echo "Updating Gtk icon cache."; \
                $(gtk_update_icon_cache); \
        else \
@@ -204,9 +158,6 @@ uninstall-local:
        fi
        rm -f $(DESTDIR)/$(datadir)/applications/$(hb_menu)
 
-install-exec-local:
-       $(INSTALL_PROGRAM) $(srcdir)/HandBrakeCLI $(DESTDIR)/$(bindir)/HandBrakeCLI
-
 install-data-local:
        for icon in $(icons); do \
                SIZE=`echo $$icon | cut -d. -f2`; \
@@ -220,7 +171,7 @@ install-data-local:
                mkdir -p $(DESTDIR)/$(datadir)/icons/hicolor/$$SIZE/apps/; \
                $(INSTALL_DATA) $(srcdir)/$$icon $(DESTDIR)/$(datadir)/icons/hicolor/$$SIZE/apps/$$FILE; \
        done
-       @-if test -n "$(DESTDIR)/$(datadir)"; then \
+       @-if test -z "$(DESTDIR)"; then \
                echo "Updating Gtk icon cache."; \
                $(gtk_update_icon_cache); \
        else \
index 114b653..6e6f564 100644 (file)
@@ -35,7 +35,7 @@ typedef struct
 
 static tag_map_t tag_map[] =
 {
-       {"description", A_DESCRIPTION},
+       {"sparkle:releaseNotesLink", A_DESCRIPTION},
        {"enclosure", A_ENCLOSURE},
        {"item", A_ITEM},
 };
index eaf7f93..fbe5e90 100644 (file)
@@ -17,6 +17,7 @@
 #include "hb-backend.h"
 #include "values.h"
 #include "callbacks.h"
+#include "preview.h"
 #include "audiohandler.h"
 
 void
@@ -46,12 +47,15 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
 
        if (ghb_audio_is_passthru (acodec))
        {
-               ghb_set_default_bitrate_opts (ud->builder, -1);
+               ghb_set_default_bitrate_opts (ud->builder, 0, -1);
                if (ghb_get_audio_info (&ainfo, titleindex, audioindex))
                {
                        gint br = ainfo.bitrate / 1000;
                        // Set the values for bitrate and samplerate to the input rates
-                       ghb_set_passthru_bitrate_opts (ud->builder, br);
+                       if (br >= 8)
+                               ghb_set_passthru_bitrate_opts (ud->builder, br);
+                       else
+                               br = 160;
                        ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br));
                        ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
                        ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
@@ -62,47 +66,81 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
                        ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
                        ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
                }
+               ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0));
        }
-       else if (acodec == HB_ACODEC_FAAC && mix != HB_AMIXDOWN_6CH)
+       else if (acodec == HB_ACODEC_FAAC)
        {
-               gint br;
+               gint br, last = 160, first = 0;
+
+               if (mix == HB_AMIXDOWN_6CH)
+               {
+                       first = 192;
+                       last = 448;
+               }
 
                widget = GHB_WIDGET(ud->builder, "AudioBitrate");
                gval = ghb_widget_value(widget);
                br = ghb_lookup_combo_int("AudioBitrate", gval);
                ghb_value_free(gval);
-               if (br > 160)
-                       ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(160));
-               ghb_set_default_bitrate_opts (ud->builder, 160);
+               if (br > last)
+                       ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(last));
+               if (br < first)
+                       ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(first));
+               ghb_set_default_bitrate_opts (ud->builder, first, last);
        }
        else
        {
-               ghb_set_default_bitrate_opts (ud->builder, -1);
+               ghb_set_default_bitrate_opts (ud->builder, 0, -1);
        }
 }
 
 void
+free_audio_index_list(gpointer data)
+{
+       g_free(data);
+}
+
+gchar*
+ghb_get_user_audio_lang(signal_user_data_t *ud, gint titleindex, gint track)
+{
+       GValue *audio_list, *asettings;
+       gchar *lang = NULL;
+
+       audio_list = ghb_settings_get_value(ud->settings, "audio_list");
+       if (ghb_array_len(audio_list) <= track)
+               return NULL;
+       asettings = ghb_array_get_nth(audio_list, track);
+       track = ghb_settings_get_int(asettings, "AudioTrack");
+       lang = ghb_get_source_audio_lang(titleindex, track);
+       return lang;
+}
+
+void
 ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
 {
        gint acodec_code, mix_code, track;
-       gchar *source_lang;
+       gchar *source_lang = NULL;
        GtkWidget *button;
        ghb_audio_info_t ainfo;
-       gint index;
-       GHashTable *track_indicies;
-       gint *iptr;
+       GHashTable *track_indices;
 
-       GValue *pref_audio;
-       GValue *audio, *acodec, *bitrate, *rate, *mix, *drc;
+       const GValue *pref_audio;
+       const GValue *audio, *acodec, *bitrate, *rate, *mix, *drc;
        gint count, ii, list_count;
        
        g_debug("set_pref_audio");
-       track_indicies = g_hash_table_new(g_int_hash, g_int_equal);
+       track_indices = g_hash_table_new_full(g_int_hash, g_int_equal, 
+                                                                                       NULL, free_audio_index_list);
        // Clear the audio list
        ghb_clear_audio_list(ud);
        // Find "best" audio based on audio preferences
        button = GHB_WIDGET (ud->builder, "audio_add");
-       source_lang = ghb_settings_get_string(ud->settings, "SourceAudioLang");
+       if (!ghb_settings_get_boolean(ud->settings, "AudioDUB"))
+       {
+               source_lang = ghb_get_source_audio_lang(titleindex, 0);
+       }
+       if (source_lang == NULL)
+               source_lang = ghb_settings_get_string(ud->settings, "PreferredLanguage");
 
        pref_audio = ghb_settings_get_value(ud->settings, "AudioList");
 
@@ -118,15 +156,10 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
                drc = ghb_settings_get_value(audio, "AudioTrackDRCSlider");
                acodec_code = ghb_lookup_combo_int("AudioEncoder", acodec);
                // If there are multiple audios using the same codec, then
-               // select sequential tracks for each.  This hash keeps track 
-               // of the last used track for each codec.
-               iptr = g_hash_table_lookup(track_indicies, &acodec_code);
-               if (iptr == NULL)
-                       index = 0;
-               else
-                       index = *(gint*)iptr;
-
-               track = ghb_find_audio_track(titleindex, source_lang, index);
+               // select sequential tracks for each.  The hash keeps track 
+               // of the tracks used for each codec.
+               track = ghb_find_audio_track(titleindex, source_lang, 
+                                                                       acodec_code, track_indices);
                // Check to see if:
                // 1. pref codec is ac3
                // 2. source codec is not ac3
@@ -134,7 +167,8 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
                if (ghb_get_audio_info (&ainfo, titleindex, track) && 
                        ghb_audio_is_passthru (acodec_code))
                {
-                       if (!ghb_audio_is_passthru(ainfo.codec))
+                       // HB_ACODEC_* are bit fields.  Treat acodec_code as mask
+                       if (!(ainfo.codec & acodec_code))
                        {
                                acodec_code = ghb_get_default_acodec();
                                // If there's more audio to process, or we've already
@@ -145,6 +179,10 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
                                        acodec_code = 0;
                                }
                        }
+                       else
+                       {
+                               acodec_code &= ainfo.codec;
+                       }
                }
                if (titleindex >= 0 && track < 0)
                        acodec_code = 0;
@@ -165,13 +203,12 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
                                        titleindex, track, acodec_code, mix_code);
                                ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix_code));
                        }
+                       ghb_adjust_audio_rate_combos(ud);
                        ghb_ui_update(ud, "AudioTrackDRCSlider", drc);
-                       index++;
-                       g_hash_table_insert(track_indicies, &acodec_code, &index);
                }
        }
        g_free(source_lang);
-       g_hash_table_destroy(track_indicies);
+       g_hash_table_destroy(track_indices);
 }
 
 static GValue*
@@ -207,8 +244,8 @@ get_selected_asettings(signal_user_data_t *ud)
        return asettings;
 }
 
-static void
-audio_list_refresh_selected(signal_user_data_t *ud)
+void
+ghb_audio_list_refresh_selected(signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
        GtkTreePath *treepath;
@@ -220,14 +257,15 @@ audio_list_refresh_selected(signal_user_data_t *ud)
        GValue *asettings = NULL;
        const GValue *audio_list;
        
-       g_debug("audio_list_refresh_selected ()");
+       g_debug("ghb_audio_list_refresh_selected ()");
        treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
        selection = gtk_tree_view_get_selection (treeview);
        if (gtk_tree_selection_get_selected(selection, &store, &iter))
        {
                const gchar *track, *codec, *br, *sr, *mix;
-               gchar *drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
-               gdouble s_drc;
+               gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+               gint itrack, icodec;
+               gdouble drc;
                // Get the row number
                treepath = gtk_tree_model_get_path (store, &iter);
                indices = gtk_tree_path_get_indices (treepath);
@@ -241,18 +279,26 @@ audio_list_refresh_selected(signal_user_data_t *ud)
                asettings = ghb_array_get_nth(audio_list, row);
 
                track = ghb_settings_combo_option(asettings, "AudioTrack");
+               itrack = ghb_settings_combo_int(asettings, "AudioTrack");
                codec = ghb_settings_combo_option(asettings, "AudioEncoder");
+               icodec = ghb_settings_combo_int(asettings, "AudioEncoder");
                br = ghb_settings_combo_option(asettings, "AudioBitrate");
                sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
                mix = ghb_settings_combo_option(asettings, "AudioMixdown");
-               drc = ghb_settings_get_string(asettings, "AudioTrackDRCSlider");
 
                s_track = ghb_settings_get_string(asettings, "AudioTrack");
                s_codec = ghb_settings_get_string(asettings, "AudioEncoder");
                s_br = ghb_settings_get_string(asettings, "AudioBitrate");
                s_sr = ghb_settings_get_string(asettings, "AudioSamplerate");
                s_mix = ghb_settings_get_string(asettings, "AudioMixdown");
-               s_drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
+               drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
+               if (drc < 1.0)
+                       s_drc = g_strdup("Off");
+               else
+                       s_drc = g_strdup_printf("%.1f", drc);
+
+               if (icodec == HB_ACODEC_MASK)
+                       codec = ghb_select_audio_codec_str(ud, itrack);
 
                gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
                        // These are displayed in list
@@ -261,16 +307,16 @@ audio_list_refresh_selected(signal_user_data_t *ud)
                        2, br,
                        3, sr,
                        4, mix,
+                       5, s_drc,
                        // These are used to set combo values when a list item is selected
-                       5, drc,
                        6, s_track,
                        7, s_codec,
                        8, s_br,
                        9, s_sr,
                        10, s_mix,
-                       11, s_drc,
+                       11, drc,
                        -1);
-               g_free(drc);
+               g_free(s_drc);
                g_free(s_track);
                g_free(s_codec);
                g_free(s_br);
@@ -279,7 +325,7 @@ audio_list_refresh_selected(signal_user_data_t *ud)
        }
 }
 
-void
+G_MODULE_EXPORT void
 audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        static gint prev_acodec = 0;
@@ -306,42 +352,29 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                mix_code = ghb_lookup_combo_int("AudioMixdown", ghb_string_value("dpl2"));
                mix_code = ghb_get_best_mix( titleindex, track, acodec_code, mix_code);
                ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix_code));
-               ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(1.0));
        }
        ghb_adjust_audio_rate_combos(ud);
        ghb_grey_combo_options (ud->builder);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        prev_acodec = acodec_code;
        asettings = get_selected_asettings(ud);
        if (asettings != NULL)
        {
                ghb_widget_to_setting(asettings, widget);
-               audio_list_refresh_selected(ud);
-       }
-
-       const GValue *audio_list;
-       audio_list = ghb_settings_get_value(ud->settings, "audio_list");
-       if (ghb_ac3_in_audio_list (audio_list))
-       {
-               gchar *container;
-
-               container = ghb_settings_get_string(ud->settings, "FileFormat");
-               if (strcmp(container, "mp4") == 0)
-               {
-                       ghb_ui_update(ud, "FileFormat", ghb_string_value("m4v"));
-               }
-               g_free(container);
+               ghb_audio_list_refresh_selected(ud);
        }
+       ghb_update_destination_extension(ud);
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
 audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        GValue *asettings;
 
        g_debug("audio_track_changed_cb ()");
        ghb_adjust_audio_rate_combos(ud);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_grey_combo_options(ud->builder);
        asettings = get_selected_asettings(ud);
        if (asettings != NULL)
@@ -349,54 +382,84 @@ audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                const gchar *track;
 
                ghb_widget_to_setting(asettings, widget);
-               audio_list_refresh_selected(ud);
+               ghb_audio_list_refresh_selected(ud);
                track = ghb_settings_combo_option(asettings, "AudioTrack");
                ghb_settings_set_string(asettings, "AudioTrackDescription", track);
        }
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
 audio_mix_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        GValue *asettings;
 
-       g_debug("audio_widget_changed_cb ()");
+       g_debug("audio_mix_changed_cb ()");
        ghb_adjust_audio_rate_combos(ud);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        asettings = get_selected_asettings(ud);
        if (asettings != NULL)
        {
                ghb_widget_to_setting(asettings, widget);
-               audio_list_refresh_selected(ud);
+               ghb_audio_list_refresh_selected(ud);
        }
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
 audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        GValue *asettings;
 
        g_debug("audio_widget_changed_cb ()");
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        asettings = get_selected_asettings(ud);
        if (asettings != NULL)
        {
                ghb_widget_to_setting(asettings, widget);
-               audio_list_refresh_selected(ud);
+               ghb_audio_list_refresh_selected(ud);
        }
+       ghb_live_reset(ud);
+}
+
+G_MODULE_EXPORT void
+drc_widget_changed_cb(GtkWidget *widget, gdouble val, signal_user_data_t *ud)
+{
+       GValue *asettings;
+       GtkLabel *label;
+       gchar *drc;
+
+       g_debug("drc_widget_changed_cb ()");
+
+       label = GTK_LABEL(GHB_WIDGET(ud->builder, "drc_label"));
+       if (val < 1.0)
+               drc = g_strdup_printf("Off");
+       else
+               drc = g_strdup_printf("%.1f", val);
+       gtk_label_set_text(label, drc);
+       g_free(drc);
+       ghb_check_dependency(ud, widget, NULL);
+       asettings = get_selected_asettings(ud);
+       if (asettings != NULL)
+       {
+               ghb_widget_to_setting(asettings, widget);
+               ghb_audio_list_refresh_selected(ud);
+       }
+       ghb_live_reset(ud);
 }
 
 // subtitles differ from other settings in that
 // the selection is updated automaitcally when the title
 // changes.  I don't want the preset selection changed as
 // would happen for regular settings.
-void
+G_MODULE_EXPORT void
 subtitle_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        const gchar *name = gtk_widget_get_name(widget);
        g_debug("subtitle_changed_cb () %s", name);
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_live_reset(ud);
 }
 
 void
@@ -428,8 +491,9 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
        GtkListStore *store;
        GtkTreeSelection *selection;
        const gchar *track, *codec, *br, *sr, *mix;
-       gchar *drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
-       gdouble s_drc;
+       gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+       gint icodec, itrack;
+       gdouble drc;
        
        g_debug("add_to_audio_list ()");
        treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
@@ -437,18 +501,28 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
        store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
 
        track = ghb_settings_combo_option(settings, "AudioTrack");
+       itrack = ghb_settings_combo_int(settings, "AudioTrack");
        codec = ghb_settings_combo_option(settings, "AudioEncoder");
+       icodec = ghb_settings_combo_int(settings, "AudioEncoder");
        br = ghb_settings_combo_option(settings, "AudioBitrate");
        sr = ghb_settings_combo_option(settings, "AudioSamplerate");
        mix = ghb_settings_combo_option(settings, "AudioMixdown");
-       drc = ghb_settings_get_string(settings, "AudioTrackDRCSlider");
 
        s_track = ghb_settings_get_string(settings, "AudioTrack");
        s_codec = ghb_settings_get_string(settings, "AudioEncoder");
        s_br = ghb_settings_get_string(settings, "AudioBitrate");
        s_sr = ghb_settings_get_string(settings, "AudioSamplerate");
        s_mix = ghb_settings_get_string(settings, "AudioMixdown");
-       s_drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider");
+       drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider");
+       if (drc < 1.0)
+               s_drc = g_strdup("Off");
+       else
+               s_drc = g_strdup_printf("%.1f", drc);
+
+       if (icodec == HB_ACODEC_MASK)
+       {
+               codec = ghb_select_audio_codec_str(ud, itrack);
+       }
 
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 
@@ -458,17 +532,17 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
                2, br,
                3, sr,
                4, mix,
+               5, s_drc,
                // These are used to set combo box values when a list item is selected
-               5, drc,
                6, s_track,
                7, s_codec,
                8, s_br,
                9, s_sr,
                10, s_mix,
-               11, s_drc,
+               11, drc,
                -1);
        gtk_tree_selection_select_iter(selection, &iter);
-       g_free(drc);
+       g_free(s_drc);
        g_free(s_track);
        g_free(s_codec);
        g_free(s_br);
@@ -476,7 +550,7 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings)
        g_free(s_mix);
 }
 
-void
+G_MODULE_EXPORT void
 audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
 {
        GtkTreeModel *store;
@@ -505,19 +579,15 @@ audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t
                ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(drc));
                widget = GHB_WIDGET (ud->builder, "audio_remove");
                gtk_widget_set_sensitive(widget, TRUE);
-               //widget = GHB_WIDGET (ud->builder, "audio_update");
-               //gtk_widget_set_sensitive(widget, TRUE);
        }
        else
        {
                widget = GHB_WIDGET (ud->builder, "audio_remove");
                gtk_widget_set_sensitive(widget, FALSE);
-               //widget = GHB_WIDGET (ud->builder, "audio_update");
-               //gtk_widget_set_sensitive(widget, FALSE);
        }
 }
 
-void
+G_MODULE_EXPORT void
 audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        // Add the current audio settings to the list.
@@ -554,13 +624,14 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        ghb_array_append(audio_list, asettings);
        add_to_audio_list(ud, asettings);
        count = ghb_array_len(audio_list);
-       if (count >= 8)
+       if (count >= 99)
        {
                gtk_widget_set_sensitive(xwidget, FALSE);
        }
+       ghb_update_destination_extension(ud);
 }
 
-void
+G_MODULE_EXPORT void
 audio_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
index 727a98b..a3b3234 100644 (file)
@@ -31,5 +31,8 @@ void ghb_adjust_audio_rate_combos(signal_user_data_t *ud);
 void ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud);
 void ghb_clear_audio_list(signal_user_data_t *ud);
 void ghb_set_audio(signal_user_data_t *ud, GValue *settings);
+gchar* ghb_get_user_audio_lang(
+       signal_user_data_t *ud, gint titleindex, gint track);
+void ghb_audio_list_refresh_selected(signal_user_data_t *ud);
 
 #endif // _AUDIOHANDLER_H_
index e13b97d..532ac69 100644 (file)
 #endif
 
 #include <string.h>
-#include <poll.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <time.h>
+
+#if !defined(_WIN32)
+#include <poll.h>
+#include <libhal-storage.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
 #include <netinet/in.h>
 #include <netdb.h>
-#include <libhal-storage.h>
+#if defined(_OLD_WEBKIT)
+#include <webkit.h>
+#else
+#include <webkit/webkit.h>
+#endif
+#include <libnotify/notify.h>
+#include <gdk/gdkx.h>
+#else
+#define WINVER 0x0500
+#include <winsock2.h>
+#include <dbt.h>
+#endif
+
 #include <gtk/gtk.h>
-#include <gtkhtml/gtkhtml.h>
 #include <gdk/gdkkeysyms.h>
 #include <glib/gstdio.h>
 #include <gio/gio.h>
 #include "callbacks.h"
 #include "queuehandler.h"
 #include "audiohandler.h"
+#include "subtitlehandler.h"
 #include "resources.h"
 #include "settings.h"
 #include "presets.h"
+#include "preview.h"
 #include "values.h"
 #include "plist.h"
 #include "appcast.h"
 #include "ghb-dvd.h"
 #include "ghbcellrenderertext.h"
 
+static void reset_chapter_list(signal_user_data_t *ud, GValue *settings);
 static void update_chapter_list(signal_user_data_t *ud);
 static GList* dvd_device_list();
 static void prune_logs(signal_user_data_t *ud);
+void ghb_notify_done(signal_user_data_t *ud);
+gpointer ghb_check_update(signal_user_data_t *ud);
+static gboolean ghb_can_shutdown_gsm();
+static void ghb_shutdown_gsm();
+static gboolean ghb_can_suspend_gpm();
+static void ghb_suspend_gpm();
+static gboolean appcast_busy = FALSE;
 
 // This is a dependency map used for greying widgets
 // that are dependent on the state of another widget.
@@ -64,7 +92,7 @@ ghb_init_dep_map()
 }
 
 static gboolean
-dep_check(signal_user_data_t *ud, const gchar *name)
+dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide)
 {
        GtkWidget *widget;
        GObject *dep_object;
@@ -76,15 +104,18 @@ dep_check(signal_user_data_t *ud, const gchar *name)
        
        g_debug("dep_check () %s", name);
 
+       if (rev_map == NULL) return TRUE;
        array = ghb_dict_lookup(rev_map, name);
        count = ghb_array_len(array);
+       *out_hide = FALSE;
        for (ii = 0; ii < count; ii++)
        {
                data = ghb_array_get_nth(array, ii);
                widget_name = ghb_value_string(ghb_array_get_nth(data, 0));
                widget = GHB_WIDGET(ud->builder, widget_name);
                dep_object = gtk_builder_get_object(ud->builder, name);
-               g_free(widget_name);
+               if (widget != NULL && !GTK_WIDGET_SENSITIVE(widget))
+                       continue;
                if (dep_object == NULL)
                {
                        g_message("Failed to find widget");
@@ -95,9 +126,10 @@ dep_check(signal_user_data_t *ud, const gchar *name)
                        gint jj = 0;
                        gchar **values;
                        gboolean sensitive = FALSE;
-                       gboolean die;
+                       gboolean die, hide;
 
                        die = ghb_value_boolean(ghb_array_get_nth(data, 2));
+                       hide = ghb_value_boolean(ghb_array_get_nth(data, 3));
                        value = ghb_value_string(ghb_array_get_nth(data, 1));
                        values = g_strsplit(value, "|", 10);
                        g_free(value);
@@ -105,7 +137,7 @@ dep_check(signal_user_data_t *ud, const gchar *name)
                        if (widget)
                                value = ghb_widget_string(widget);
                        else
-                               value = ghb_settings_get_string(ud->settings, name);
+                               value = ghb_settings_get_string(ud->settings, widget_name);
                        while (values && values[jj])
                        {
                                if (values[jj][0] == '>')
@@ -136,16 +168,24 @@ dep_check(signal_user_data_t *ud, const gchar *name)
                                jj++;
                        }
                        sensitive = die ^ sensitive;
-                       if (!sensitive) result = FALSE;
+                       if (!sensitive)
+                       {
+                               result = FALSE;
+                               *out_hide |= hide;
+                       }
                        g_strfreev (values);
                        g_free(value);
                }
+               g_free(widget_name);
        }
        return result;
 }
 
 void
-ghb_check_dependency(signal_user_data_t *ud, GtkWidget *widget)
+ghb_check_dependency(
+       signal_user_data_t *ud, 
+       GtkWidget *widget, 
+       const char *alt_name)
 {
        GObject *dep_object;
        const gchar *name;
@@ -154,18 +194,25 @@ ghb_check_dependency(signal_user_data_t *ud, GtkWidget *widget)
        gchar *dep_name;
        GType type;
 
-       type = GTK_WIDGET_TYPE(widget);
-       if (type == GTK_TYPE_COMBO_BOX || type == GTK_TYPE_COMBO_BOX_ENTRY)
-               if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return;
+       if (widget != NULL)
+       {
+               type = GTK_WIDGET_TYPE(widget);
+               if (type == GTK_TYPE_COMBO_BOX || type == GTK_TYPE_COMBO_BOX_ENTRY)
+                       if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) < 0) return;
+               name = gtk_widget_get_name(widget);
+       }
+       else
+               name = alt_name;
 
-       name = gtk_widget_get_name(widget);
        g_debug("ghb_check_dependency () %s", name);
 
+       if (dep_map == NULL) return;
        array = ghb_dict_lookup(dep_map, name);
        count = ghb_array_len(array);
        for (ii = 0; ii < count; ii++)
        {
                gboolean sensitive;
+               gboolean hide;
 
                data = ghb_array_get_nth(array, ii);
                dep_name = ghb_value_string(data);
@@ -176,12 +223,25 @@ ghb_check_dependency(signal_user_data_t *ud, GtkWidget *widget)
                        g_free(dep_name);
                        continue;
                }
-               sensitive = dep_check(ud, dep_name);
+               sensitive = dep_check(ud, dep_name, &hide);
                g_free(dep_name);
                if (GTK_IS_ACTION(dep_object))
+               {
                        gtk_action_set_sensitive(GTK_ACTION(dep_object), sensitive);
+                       gtk_action_set_visible(GTK_ACTION(dep_object), sensitive || !hide);
+               }
                else
+               {
                        gtk_widget_set_sensitive(GTK_WIDGET(dep_object), sensitive);
+                       if (!sensitive && hide)
+                       {
+                               gtk_widget_hide(GTK_WIDGET(dep_object));
+                       }
+                       else
+                       {
+                               gtk_widget_show_now(GTK_WIDGET(dep_object));
+                       }
+               }
        }
 }
 
@@ -194,6 +254,7 @@ ghb_check_all_depencencies(signal_user_data_t *ud)
        GObject *dep_object;
 
        g_debug("ghb_check_all_depencencies ()");
+       if (rev_map == NULL) return;
        ghb_dict_iter_init(&iter, rev_map);
        // middle (void*) cast prevents gcc warning "defreferencing type-punned
        // pointer will break strict-aliasing rules"
@@ -201,62 +262,43 @@ ghb_check_all_depencencies(signal_user_data_t *ud)
                        &iter, (gpointer*)(void*)&dep_name, (gpointer*)(void*)&value))
        {
                gboolean sensitive;
+               gboolean hide;
+
                dep_object = gtk_builder_get_object (ud->builder, dep_name);
                if (dep_object == NULL)
                {
                        g_message("Failed to find dependent widget %s", dep_name);
                        continue;
                }
-               sensitive = dep_check(ud, dep_name);
+               sensitive = dep_check(ud, dep_name, &hide);
                if (GTK_IS_ACTION(dep_object))
-                       gtk_action_set_sensitive(GTK_ACTION(dep_object), sensitive);
-               else
-                       gtk_widget_set_sensitive(GTK_WIDGET(dep_object), sensitive);
-       }
-}
-
-static gchar*
-expand_tilde(const gchar *path)
-{
-       const gchar *user_home;
-       gchar *home;
-       const gchar *suffix;
-       gchar *expanded_path = NULL;
-       
-       g_debug("expand_tilde ()");
-       if (path[0] == '~')
-       {
-               user_home = g_get_home_dir();
-               home = NULL; // squash warning about home uninitialized
-               if (path[1] == 0)
-               {
-                       home = g_strdup(user_home);
-                       suffix = "";
-               }
-               else if (path[1] == '/')
                {
-                       home = g_strdup(user_home);
-                       suffix = &path[2];
+                       gtk_action_set_sensitive(GTK_ACTION(dep_object), sensitive);
+                       gtk_action_set_visible(GTK_ACTION(dep_object), sensitive || !hide);
                }
                else
                {
-                       home = g_path_get_dirname(user_home);
-                       suffix = &path[1];
+                       gtk_widget_set_sensitive(GTK_WIDGET(dep_object), sensitive);
+                       if (!sensitive && hide)
+                       {
+                               gtk_widget_hide(GTK_WIDGET(dep_object));
+                       }
+                       else
+                       {
+                               gtk_widget_show_now(GTK_WIDGET(dep_object));
+                       }
                }
-               expanded_path = g_strdup_printf("%s/%s", home, suffix);
-               g_free(home);
        }
-       return expanded_path;
 }
 
-void
+G_MODULE_EXPORT void
 on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud)
 {
        gint state = ghb_get_queue_state();
        g_debug("on_quit1_activate ()");
        if (state & GHB_STATE_WORKING)
-       {
-               if (ghb_cancel_encode("Closing HandBrake will terminate encoding.\n"))
+       {
+               if (ghb_cancel_encode2(ud, "Closing HandBrake will terminate encoding.\n"))
                {
                        ghb_hb_cleanup(FALSE);
                        prune_logs(ud);
@@ -270,53 +312,11 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud)
        gtk_main_quit();
 }
 
-static void
-set_destination(signal_user_data_t *ud)
-{
-       g_debug("set_destination");
-       if (ghb_settings_get_boolean(ud->settings, "use_source_name"))
-       {
-               gchar *vol_name, *filename, *extension;
-               gchar *dir, *new_name;
-               
-               filename = ghb_settings_get_string(ud->settings, "destination");
-               extension = ghb_settings_get_string(ud->settings, "FileFormat");
-               dir = g_path_get_dirname (filename);
-               vol_name = ghb_settings_get_string(ud->settings, "volume_label");
-               if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination"))
-               {
-                       gint start, end;
-
-                       start = ghb_settings_get_int(ud->settings, "start_chapter");
-                       end = ghb_settings_get_int(ud->settings, "end_chapter");
-                       if (start == end)
-                       {
-                               new_name = g_strdup_printf("%s/%s-%d.%s", 
-                                       dir, vol_name, start, extension);
-                       }
-                       else
-                       {
-                               new_name = g_strdup_printf("%s/%s-%d-%d.%s", 
-                                       dir, vol_name, start, end, extension);
-                       }
-               }
-               else
-               {
-                       new_name = g_strdup_printf("%s/%s.%s", dir, vol_name, extension);
-               }
-               ghb_ui_update(ud, "destination", ghb_string_value(new_name));
-               g_free(filename);
-               g_free(extension);
-               g_free(vol_name);
-               g_free(dir);
-               g_free(new_name);
-       }
-}
-
 gboolean
-uppers_and_unders(const gchar *str)
+uppers_and_unders(gchar *str)
 {
        if (str == NULL) return FALSE;
+       str = g_strchomp(g_strchug(str));
        while (*str)
        {
                if (*str == ' ')
@@ -369,51 +369,351 @@ camel_convert(gchar *str)
        }
 }
 
+#if defined(_WIN32)
+static gchar*
+get_dvd_device_name(gchar *device)
+{
+       return g_strdup(device);
+}
+#else
+static gchar*
+get_dvd_device_name(GDrive *gd)
+{
+       return g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+}
+#endif
+
+static GHashTable *volname_hash = NULL;
+static GMutex     *volname_mutex = NULL;
+
+static void
+free_volname_key(gpointer data)
+{
+       if (data != NULL)
+               g_free(data);
+}
+
+static void
+free_volname_value(gpointer data)
+{
+       if (data != NULL)
+               g_free(data);
+}
+
+#if defined(_WIN32)
+static gchar*
+get_direct_dvd_volume_name(const gchar *drive)
+{
+       gchar *result = NULL;
+       gchar vname[51], fsname[51];
+
+       if (GetVolumeInformation(drive, vname, 50, NULL, NULL, NULL, fsname, 50))
+       {
+               result = g_strdup_printf("%s", vname);
+       }
+       return result;
+}
+#else
+static gchar*
+get_direct_dvd_volume_name(const gchar *drive)
+{
+       gchar *result;
+
+       result = ghb_dvd_volname (drive);
+       return result;
+}
+#endif
+
+static gchar*
+get_dvd_volume_name(gpointer gd)
+{
+       gchar *label = NULL;
+       gchar *result;
+       gchar *drive;
+
+       drive = get_dvd_device_name(gd);
+       g_mutex_lock(volname_mutex);
+       label = g_strdup(g_hash_table_lookup(volname_hash, drive));
+       g_mutex_unlock(volname_mutex);
+       if (label != NULL)
+       {
+               if (uppers_and_unders(label))
+               {
+                       camel_convert(label);
+               }
+#if defined(_WIN32)
+               result = g_strdup_printf("%s (%s)", label, drive);
+#else
+               result = g_strdup_printf("%s - %s", drive, label);
+#endif
+               g_free(label);
+       }
+       else
+       {
+               result = g_strdup_printf("%s", drive);
+       }
+       g_free(drive);
+       return result;
+}
+
+void
+ghb_volname_cache_init(void)
+{
+       volname_mutex = g_mutex_new();
+       volname_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                                                               free_volname_key, free_volname_value);
+}
+
+static void
+free_drive(gpointer drive)
+{
+#if defined(_WIN32)
+               g_free(drive);
+#else
+               g_object_unref(drive);
+#endif
+}
+
+gpointer
+ghb_cache_volnames(signal_user_data_t *ud)
+{
+       GList *link, *drives;
+
+       g_debug("ghb_cache_volnames()");
+       link = drives = dvd_device_list();
+       if (drives == NULL)
+               return NULL;
+
+       g_mutex_lock(volname_mutex);
+       g_hash_table_remove_all(volname_hash);
+       while (link != NULL)
+       {
+               gchar *name, *drive;
+
+#if !defined(_WIN32)
+               if (!g_drive_has_media (link->data))
+               {
+                       g_object_unref(link->data);
+                       link = link->next;
+                       continue;
+               }
+#endif
+               drive = get_dvd_device_name(link->data);
+               name = get_direct_dvd_volume_name(drive);
+
+               if (drive != NULL && name != NULL)
+               {
+                       g_hash_table_insert(volname_hash, drive, name);
+               }
+               else
+               {
+                       if (drive != NULL)
+                               g_free(drive);
+                       if (name != NULL)
+                               g_free(name);
+               }
+       
+               free_drive(link->data);
+               link = link->next;
+       }
+       g_mutex_unlock(volname_mutex);
+
+       g_list_free(drives);
+
+       g_idle_add((GSourceFunc)ghb_file_menu_add_dvd, ud);
+
+       return NULL;
+}
+
+static const gchar*
+get_extension(signal_user_data_t *ud)
+{
+       int container;
+       const gchar *extension = "error";
+       GValue *audio_list;
+       GValue *subtitle_list;
+
+       container = ghb_settings_combo_int(ud->settings, "FileFormat");
+       if (container == HB_MUX_MP4)
+       {
+               extension = "mp4";
+               audio_list = ghb_settings_get_value(ud->settings, "audio_list");
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               if (ghb_ac3_in_audio_list(audio_list) ||
+                       ghb_soft_in_subtitle_list(subtitle_list) ||
+                       ghb_settings_get_boolean(ud->settings, "ChapterMarkers") ||
+                       ghb_settings_get_boolean(ud->settings, "UseM4v"))
+               {
+                       extension = "m4v";
+               }
+       }
+       else if (container == HB_MUX_MKV)
+       {
+               extension = "mkv";
+       }
+       return extension;
+}
+
+static void
+set_destination(signal_user_data_t *ud)
+{
+       g_debug("set_destination");
+       if (ghb_settings_get_boolean(ud->settings, "use_source_name"))
+       {
+               GString *str = g_string_new("");
+               gchar *vol_name, *filename;
+               const gchar *extension;
+               gchar *new_name;
+               gint title;
+               
+               filename = ghb_settings_get_string(ud->settings, "dest_file");
+               extension = get_extension(ud);
+               vol_name = ghb_settings_get_string(ud->settings, "volume_label");
+               g_string_append_printf(str, "%s", vol_name);
+               title = ghb_settings_combo_int(ud->settings, "title");
+               if (title >= 0)
+               {
+                       if (ghb_settings_get_boolean(
+                                       ud->settings, "title_no_in_destination"))
+                       {
+
+                               title = ghb_settings_combo_int(ud->settings, "title");
+                               g_string_append_printf(str, " - %d", title+1);
+                       }
+                       if (ghb_settings_get_boolean(
+                                       ud->settings, "chapters_in_destination"))
+                       {
+                               gint start, end;
+
+                               if (!ghb_settings_get_boolean(
+                                               ud->settings, "title_no_in_destination"))
+                               {
+                                       g_string_append_printf(str, " -");
+                               }
+                               start = ghb_settings_get_int(ud->settings, "start_chapter");
+                               end = ghb_settings_get_int(ud->settings, "end_chapter");
+                               if (start == end)
+                                       g_string_append_printf(str, " Ch %d", start);
+                               else
+                                       g_string_append_printf(str, " Ch %d-%d", start, end);
+                       }
+               }
+               g_string_append_printf(str, ".%s", extension);
+               new_name = g_string_free(str, FALSE);
+               ghb_ui_update(ud, "dest_file", ghb_string_value(new_name));
+               g_free(filename);
+               g_free(vol_name);
+               g_free(new_name);
+       }
+}
+
 static gchar*
 get_file_label(const gchar *filename)
 {
-       static gchar *containers[] = 
-               {".vob", ".mpg", ".m2ts", ".mkv", ".mp4", ".m4v", ".avi", ".ogm", NULL};
-       gchar *base;
-       gint ii;
+       gchar *base, *pos, *end;
 
        base = g_path_get_basename(filename);
-       for (ii = 0; containers[ii] != NULL; ii++)
+       pos = strrchr(base, '.');
+       if (pos != NULL)
        {
-               if (g_str_has_suffix(base, containers[ii]))
-               {
-                       gchar *pos;
-                       pos = strrchr(base, '.');
+               // If the last '.' is within 4 chars of end of name, assume
+               // there is an extension we want to strip.
+               end = &base[strlen(base) - 1];
+               if (end - pos <= 4)
                        *pos = 0;
-                       break;
-               }
        }
        return base;
 }
 
+static gchar*
+resolve_drive_name(gchar *filename)
+{
+#if defined(_WIN32)
+       if (filename[1] == ':')
+       {
+               gchar drive[4];
+               gchar *name;
+               gint dtype;
+
+               g_strlcpy(drive, filename, 4);
+               dtype = GetDriveType(drive);
+               if (dtype == DRIVE_CDROM)
+               {
+                       gchar vname[51], fsname[51];
+                       GetVolumeInformation(drive, vname, 50, NULL, 
+                                                               NULL, NULL, fsname, 50);
+                       name = g_strdup(vname);
+                       return name;
+               }
+       }
+       return NULL;
+#else
+       return NULL;
+#endif
+}
+
 static gboolean
-update_source_label(signal_user_data_t *ud, const gchar *source)
+update_source_label(signal_user_data_t *ud, const gchar *source, gboolean update_dest)
 {
        gchar *label = NULL;
        gint len;
        gchar **path;
+       gchar *start;
        gchar *filename = g_strdup(source);
        
+       g_debug("update_source_label()");
        len = strlen(filename);
-       if (filename[len-1] == '/') filename[len-1] = 0;
        if (g_file_test(filename, G_FILE_TEST_IS_DIR))
        {
-               path = g_strsplit(filename, "/", -1);
-               len = g_strv_length (path);
-               if ((len > 1) && (strcmp("VIDEO_TS", path[len-1]) == 0))
+               // Skip dos drive letters
+#if defined(_WIN32)
+               start = strchr(filename, ':');
+#else
+               start = filename;
+#endif
+               label = resolve_drive_name(filename);
+               if (label != NULL)
                {
-                       label = g_strdup(path[len-2]);
+                       if (uppers_and_unders(label))
+                       {
+                               camel_convert(label);
+                       }
                }
                else
                {
-                       label = g_strdup(path[len-1]);
+                       if (filename[len-1] == G_DIR_SEPARATOR) filename[len-1] = 0;
+                       if (start != NULL)
+                               start++;
+                       else
+                               start = filename;
+                       
+                       path = g_strsplit(start, G_DIR_SEPARATOR_S, -1);
+                       len = g_strv_length (path);
+                       if ((len > 1) && (strcmp("VIDEO_TS", path[len-1]) == 0))
+                       {
+                               label = g_strdup(path[len-2]);
+                               if (uppers_and_unders(label))
+                               {
+                                       camel_convert(label);
+                               }
+                       }
+                       else if (len > 0)
+                       {
+                               if (path[len-1][0] != 0)
+                               {
+                                       label = g_strdup(path[len-1]);
+                                       if (uppers_and_unders(label))
+                                       {
+                                               camel_convert(label);
+                                       }
+                               }
+                               else
+                                       label = g_strdup("new_video");
+                       }
+                       else
+                               label = g_strdup("new_video");
+                       g_strfreev (path);
                }
-               g_strfreev (path);
        }
        else
        {
@@ -439,7 +739,8 @@ update_source_label(signal_user_data_t *ud, const gchar *source)
                gtk_label_set_text (GTK_LABEL(widget), label);
                ghb_settings_set_string(ud->settings, "volume_label", label);
                g_free(label);
-               set_destination(ud);
+               if (update_dest)
+                       set_destination(ud);
        }
        else
        {
@@ -451,18 +752,18 @@ update_source_label(signal_user_data_t *ud, const gchar *source)
        return TRUE;
 }
 
-static GtkWidget *dvd_device_combo = NULL;
-
-void
-chooser_file_selected_cb(GtkFileChooser *dialog, GtkComboBox *combo)
+G_MODULE_EXPORT void
+chooser_file_selected_cb(GtkFileChooser *dialog, signal_user_data_t *ud)
 {
-       const gchar *name = gtk_file_chooser_get_filename (dialog);
+       gchar *name = gtk_file_chooser_get_filename (dialog);
        GtkTreeModel *store;
        GtkTreeIter iter;
        const gchar *device;
        gboolean foundit = FALSE;
+       GtkComboBox *combo;
        
        if (name == NULL) return;
+       combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, "source_device"));
        store = gtk_combo_box_get_model(combo);
        if (gtk_tree_model_get_iter_first(store, &iter))
        {
@@ -480,31 +781,47 @@ chooser_file_selected_cb(GtkFileChooser *dialog, GtkComboBox *combo)
                gtk_combo_box_set_active_iter (combo, &iter);
        else
                gtk_combo_box_set_active (combo, 0);
+
+       g_free(name);
 }
 
-void
-dvd_device_changed_cb(GtkComboBox *combo, GtkWidget *dialog)
+G_MODULE_EXPORT void
+dvd_device_changed_cb(GtkComboBox *combo, signal_user_data_t *ud)
 {
-       gint ii = gtk_combo_box_get_active (combo);
-       if (ii != 0)
+       GtkWidget *dialog;
+       gint ii;
+
+       ii = gtk_combo_box_get_active (combo);
+       if (ii > 0)
        {
-               const gchar *device = gtk_combo_box_get_active_text (combo);
-               const gchar *name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
+               const gchar *device;
+               gchar *name;
+
+               dialog = GHB_WIDGET(ud->builder, "source_dialog");
+               device = gtk_combo_box_get_active_text (combo);
+               name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
                if (name == NULL || strcmp(name, device) != 0)
                        gtk_file_chooser_select_filename (GTK_FILE_CHOOSER(dialog), device);
+               if (name != NULL)
+                       g_free(name);
        }
 }
 
-void
-source_type_changed_cb(GtkToggleButton *toggle, GtkFileChooser *chooser)
+G_MODULE_EXPORT void
+source_type_changed_cb(GtkToggleButton *toggle, signal_user_data_t *ud)
 {
        gchar *folder;
+       GtkFileChooser *chooser;
+       GtkWidget *dvd_device_combo;
        
        g_debug("source_type_changed_cb ()");
+       chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog"));
+       dvd_device_combo = GHB_WIDGET(ud->builder, "source_device");
        folder = gtk_file_chooser_get_current_folder (chooser);
        if (gtk_toggle_button_get_active (toggle))
        {
-               gtk_file_chooser_set_action (chooser, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+               gtk_file_chooser_set_action (chooser, 
+                                                                       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
                gtk_widget_set_sensitive (dvd_device_combo, FALSE);
                gtk_combo_box_set_active (GTK_COMBO_BOX(dvd_device_combo), 0);
        }
@@ -520,76 +837,95 @@ source_type_changed_cb(GtkToggleButton *toggle, GtkFileChooser *chooser)
        }
 }
 
-static GtkWidget*
-source_dialog_extra_widgets(GtkWidget *dialog, gboolean checkbutton_active)
+static void
+source_dialog_extra_widgets(
+       signal_user_data_t *ud,
+       GtkWidget *dialog, 
+       gboolean checkbutton_active)
 {
-       GtkBox *vbox;
-       GtkWidget *checkbutton;
-       
-       vbox = GTK_BOX(gtk_vbox_new (FALSE, 2));
-       checkbutton = gtk_check_button_new_with_label ("Open VIDEO_TS folder");
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton), checkbutton_active);
-       gtk_box_pack_start (vbox, checkbutton, FALSE, FALSE, 1);
-       gtk_widget_show(checkbutton);
-
-       GtkWidget *combo;
-       GtkBox *hbox;
+       GtkToggleButton *checkbutton;
+       GtkComboBox *combo;
        GList *drives, *link;
-       GtkWidget *label, *blank;
+       
+       checkbutton = GTK_TOGGLE_BUTTON(
+               GHB_WIDGET(ud->builder, "source_folder_flag"));
+       gtk_toggle_button_set_active(checkbutton, checkbutton_active);
+       combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, "source_device"));
+       gtk_list_store_clear(GTK_LIST_STORE(
+                                               gtk_combo_box_get_model(combo)));
 
-       hbox = GTK_BOX(gtk_hbox_new (FALSE, 2));
-       combo = gtk_combo_box_new_text();
-       label = gtk_label_new("Detected DVD devices:");
-       blank = gtk_label_new("");
        link = drives = dvd_device_list();
-       gtk_combo_box_append_text (GTK_COMBO_BOX(combo), "Not Selected");
+       gtk_combo_box_append_text (combo, "Not Selected");
        while (link != NULL)
        {
-               gchar *name = (gchar*)link->data;
-               gtk_combo_box_append_text (GTK_COMBO_BOX(combo), name);
+               gchar *name = get_dvd_device_name(link->data);
+               gtk_combo_box_append_text(combo, name);
                g_free(name);
+               free_drive(link->data);
                link = link->next;
        }
        g_list_free(drives);
-       gtk_combo_box_set_active (GTK_COMBO_BOX(combo), 0);
-       gtk_box_pack_start (vbox, GTK_WIDGET(hbox), FALSE, FALSE, 1);
-       gtk_widget_show(GTK_WIDGET(hbox));
-       gtk_box_pack_start (hbox, label, FALSE, FALSE, 1);
-       gtk_widget_show(label);
-       gtk_box_pack_start (hbox, combo, FALSE, FALSE, 2);
-       gtk_widget_show(combo);
-       gtk_box_pack_start (hbox, blank, TRUE, TRUE, 1);
-       gtk_widget_show(blank);
-       // Ugly hackish global alert
-       dvd_device_combo = combo;
-       g_signal_connect(combo, "changed", (GCallback)dvd_device_changed_cb, dialog);
-       g_signal_connect(dialog, "selection-changed", (GCallback)chooser_file_selected_cb, combo);
-
-       g_signal_connect(checkbutton, "toggled", (GCallback)source_type_changed_cb, dialog);
-       return GTK_WIDGET(vbox);
 }
 
 extern GValue *ghb_queue_edit_settings;
 static gchar *last_scan_file = NULL;
 
-void
-ghb_do_scan(signal_user_data_t *ud, const gchar *filename, gboolean force)
+static void 
+show_scan_progress(signal_user_data_t *ud)
 {
-       if (!force && last_scan_file != NULL &&
-               strcmp(last_scan_file, filename) == 0)
-       {
-               if (ghb_queue_edit_settings)
-               {
-                       gint jstatus;
+       GtkProgressBar *progress;
+       GtkLabel *label;
 
-                       jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
-                       ghb_settings_to_ui(ud, ghb_queue_edit_settings);
-                       ghb_set_audio(ud, ghb_queue_edit_settings);
-                       if (jstatus == GHB_QUEUE_PENDING)
-                       {
-                               ghb_value_free(ghb_queue_edit_settings);
-                       }
+       progress = GTK_PROGRESS_BAR(GHB_WIDGET(ud->builder, "scan_prog"));
+       gtk_progress_bar_set_fraction (progress, 0);
+       gtk_widget_show(GTK_WIDGET(progress));
+
+       label = GTK_LABEL(GHB_WIDGET(ud->builder, "source_title"));
+       gtk_label_set_text( label, "Scanning ..." );
+}
+
+static void
+start_scan(
+       signal_user_data_t *ud, 
+       const gchar *path, 
+       gint titlenum, 
+       gint preview_count)
+{
+       GtkWidget *widget;
+       GtkAction *action;
+       ghb_status_t status;
+
+       ghb_get_status(&status);
+       if (status.scan.state != GHB_STATE_IDLE)
+               return;
+
+       widget = GHB_WIDGET(ud->builder, "sourcetoolbutton");
+       gtk_widget_set_sensitive(widget, FALSE);
+       action = GHB_ACTION(ud->builder, "source_action");
+       gtk_action_set_sensitive(action, FALSE);
+       action = GHB_ACTION(ud->builder, "source_single_action");
+       gtk_action_set_sensitive(action, FALSE);
+       ghb_backend_scan(path, titlenum, preview_count);
+}
+
+void
+ghb_do_scan(
+       signal_user_data_t *ud, 
+       const gchar *filename, 
+       gint titlenum, 
+       gboolean force)
+{
+       g_debug("ghb_do_scan()");
+       if (!force && last_scan_file != NULL &&
+               strcmp(last_scan_file, filename) == 0)
+       {
+               if (ghb_queue_edit_settings)
+               {
+                       ghb_settings_to_ui(ud, ghb_queue_edit_settings);
+                       ghb_set_audio(ud, ghb_queue_edit_settings);
+                       ghb_reset_subtitles(ud, ghb_queue_edit_settings);
+                       reset_chapter_list(ud, ghb_queue_edit_settings);
+                       ghb_value_free(ghb_queue_edit_settings);
                        ghb_queue_edit_settings = NULL;
                }
                return;
@@ -601,17 +937,17 @@ ghb_do_scan(signal_user_data_t *ud, const gchar *filename, gboolean force)
        {
                last_scan_file = g_strdup(filename);
                ghb_settings_set_string(ud->settings, "source", filename);
-               if (update_source_label(ud, filename))
+               if (update_source_label(ud, filename, TRUE))
                {
-                       GtkProgressBar *progress;
-                       progress = GTK_PROGRESS_BAR(GHB_WIDGET(ud->builder, "progressbar"));
                        gchar *path;
+                       gint preview_count;
+
+                       show_scan_progress(ud);
                        path = ghb_settings_get_string( ud->settings, "source");
-                       gtk_progress_bar_set_fraction (progress, 0);
-                       gtk_progress_bar_set_text (progress, "Scanning ...");
-                       ghb_hb_cleanup(TRUE);
                        prune_logs(ud);
-                       ghb_backend_scan (path, 0);
+
+                       preview_count = ghb_settings_get_int(ud->settings, "preview_count");
+                       start_scan(ud, path, titlenum, preview_count);
                        g_free(path);
                }
                else
@@ -621,11 +957,24 @@ ghb_do_scan(signal_user_data_t *ud, const gchar *filename, gboolean force)
        }
 }
 
-void
-source_button_clicked_cb(GtkButton *button, signal_user_data_t *ud)
+static gboolean 
+update_source_name(gpointer data)
+{
+       signal_user_data_t *ud = (signal_user_data_t*)data;
+       GtkWidget *dialog;
+       gchar *sourcename;
+
+       sourcename = ghb_settings_get_string(ud->settings, "source");
+       dialog = GHB_WIDGET(ud->builder, "source_dialog");
+       gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), sourcename);
+       g_free(sourcename);
+       return FALSE;
+}
+
+static void
+do_source_dialog(GtkButton *button, gboolean single, signal_user_data_t *ud)
 {
        GtkWidget *dialog;
-       GtkWidget *widget;
        gchar *sourcename;
        gint    response;
        GtkFileChooserAction action;
@@ -643,28 +992,40 @@ source_button_clicked_cb(GtkButton *button, signal_user_data_t *ud)
        {
                action = GTK_FILE_CHOOSER_ACTION_OPEN;
        }
-       dialog = gtk_file_chooser_dialog_new ("Select Source",
-                                                               NULL,
-                                                               action,
-                                                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-                                                               NULL);
-       widget = source_dialog_extra_widgets(dialog, checkbutton_active);
-       gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), widget);
-       gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), sourcename);
+       GtkWidget *widget;
+       widget = GHB_WIDGET(ud->builder, "single_title_box");
+       if (single)
+               gtk_widget_show(widget);
+       else
+               gtk_widget_hide(widget);
+       dialog = GHB_WIDGET(ud->builder, "source_dialog");
+       source_dialog_extra_widgets(ud, dialog, checkbutton_active);
+       gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog), action);
+       // Updating the filename in the file chooser dialog doesn't seem
+       // to work unless the dialog is running for some reason.
+       // So handle it in an "idle" event.
+       //gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), sourcename);
+       g_idle_add((GSourceFunc)update_source_name, ud);
        response = gtk_dialog_run(GTK_DIALOG (dialog));
        gtk_widget_hide(dialog);
        if (response == GTK_RESPONSE_ACCEPT)
        {
-               char *filename;
+               gchar *filename;
 
                filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
                if (filename != NULL)
                {
-                       ghb_do_scan(ud, filename, TRUE);
+                       gint titlenum;
+
+                       if (single)
+                               titlenum = ghb_settings_get_int(ud->settings, "single_title");
+                       else
+                               titlenum = 0;
+                       ghb_do_scan(ud, filename, titlenum, TRUE);
                        if (strcmp(sourcename, filename) != 0)
                        {
-                               ghb_settings_set_string (ud->settings, "default_source", filename);
+                               ghb_settings_set_string (ud->settings, 
+                                                                               "default_source", filename);
                                ghb_pref_save (ud->settings, "default_source");
                                ghb_dvd_set_current (filename, ud);
                        }
@@ -672,10 +1033,21 @@ source_button_clicked_cb(GtkButton *button, signal_user_data_t *ud)
                }
        }
        g_free(sourcename);
-       gtk_widget_destroy(dialog);
 }
 
-void
+G_MODULE_EXPORT void
+source_button_clicked_cb(GtkButton *button, signal_user_data_t *ud)
+{
+       do_source_dialog(button, FALSE, ud);
+}
+
+G_MODULE_EXPORT void
+single_title_source_cb(GtkButton *button, signal_user_data_t *ud)
+{
+       do_source_dialog(button, TRUE, ud);
+}
+
+G_MODULE_EXPORT void
 dvd_source_activate_cb(GtkAction *action, signal_user_data_t *ud)
 {
        const gchar *filename;
@@ -683,7 +1055,7 @@ dvd_source_activate_cb(GtkAction *action, signal_user_data_t *ud)
 
        sourcename = ghb_settings_get_string(ud->settings, "source");
        filename = gtk_action_get_name(action);
-       ghb_do_scan(ud, filename, TRUE);
+       ghb_do_scan(ud, filename, 0, TRUE);
        if (strcmp(sourcename, filename) != 0)
        {
                ghb_settings_set_string (ud->settings, "default_source", filename);
@@ -693,18 +1065,25 @@ dvd_source_activate_cb(GtkAction *action, signal_user_data_t *ud)
        g_free(sourcename);
 }
 
-static void
-update_destination_extension(signal_user_data_t *ud)
+void
+ghb_update_destination_extension(signal_user_data_t *ud)
 {
-       static gchar *containers[] = {".mkv", ".mp4", ".m4v", ".avi", ".ogm", NULL};
+       static gchar *containers[] = {".mkv", ".mp4", ".m4v", NULL};
        gchar *filename;
-       gchar *extension;
+       const gchar *extension;
        gint ii;
        GtkEntry *entry;
+       static gboolean busy = FALSE;
 
-       g_debug("update_destination_extension ()");
-       extension = ghb_settings_get_string(ud->settings, "FileFormat");
-       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "destination"));
+       g_debug("ghb_update_destination_extension ()");
+       // Since this function modifies the thing that triggers it's
+       // invocation, check to see if busy to prevent accidental infinite
+       // recursion.
+       if (busy)
+               return;
+       busy = TRUE;
+       extension = get_extension(ud);
+       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "dest_file"));
        filename = g_strdup(gtk_entry_get_text(entry));
        for (ii = 0; containers[ii] != NULL; ii++)
        {
@@ -726,13 +1105,13 @@ update_destination_extension(signal_user_data_t *ud)
                                break;
                        }
                        new_name = g_strjoin(".", filename, extension, NULL); 
-                       ghb_ui_update(ud, "destination", ghb_string_value(new_name));
+                       ghb_ui_update(ud, "dest_file", ghb_string_value(new_name));
                        g_free(new_name);
                        break;
                }
        }
-       g_free(extension);
        g_free(filename);
+       busy = FALSE;
 }
 
 static void
@@ -751,19 +1130,20 @@ destination_select_title(GtkEntry *entry)
        }
        for (start = end; start >= 0; start--)
        {
-               if (dest[start] == '/')
+               if (dest[start] == G_DIR_SEPARATOR)
                {
                        start++;
                        break;
                }
        }
+       if (start < 0) start = 0;
        if (start < end)
        {
                gtk_editable_select_region(GTK_EDITABLE(entry), start, end);
        }
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 destination_grab_cb(
        GtkEntry *entry, 
        signal_user_data_t *ud)
@@ -774,25 +1154,44 @@ destination_grab_cb(
 
 static gboolean update_default_destination = FALSE;
 
-void
-destination_entry_changed_cb(GtkEntry *entry, signal_user_data_t *ud)
+G_MODULE_EXPORT void
+dest_dir_set_cb(GtkFileChooserButton *dest_chooser, signal_user_data_t *ud)
 {
-       gchar *dest;
+       gchar *dest_file, *dest_dir, *dest;
        
-       g_debug("destination_entry_changed_cb ()");
-       if ((dest = expand_tilde(gtk_entry_get_text(entry))) != NULL)
-       {
-               gtk_entry_set_text(entry, dest);
-               g_free(dest);
-       }
-       update_destination_extension(ud);
+       g_debug("dest_dir_set_cb ()");
+       ghb_widget_to_setting(ud->settings, (GtkWidget*)dest_chooser);
+       dest_file = ghb_settings_get_string(ud->settings, "dest_file");
+       dest_dir = ghb_settings_get_string(ud->settings, "dest_dir");
+       dest = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dest_dir, dest_file);
+       ghb_settings_set_string(ud->settings, "destination", dest);
+       g_free(dest_file);
+       g_free(dest_dir);
+       g_free(dest);
+       update_default_destination = TRUE;
+}
+
+G_MODULE_EXPORT void
+dest_file_changed_cb(GtkEntry *entry, signal_user_data_t *ud)
+{
+       gchar *dest_file, *dest_dir, *dest;
+       
+       g_debug("dest_file_changed_cb ()");
+       ghb_update_destination_extension(ud);
        ghb_widget_to_setting(ud->settings, (GtkWidget*)entry);
        // This signal goes off with ever keystroke, so I'm putting this
        // update on the timer.
+       dest_file = ghb_settings_get_string(ud->settings, "dest_file");
+       dest_dir = ghb_settings_get_string(ud->settings, "dest_dir");
+       dest = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dest_dir, dest_file);
+       ghb_settings_set_string(ud->settings, "destination", dest);
+       g_free(dest_file);
+       g_free(dest_dir);
+       g_free(dest);
        update_default_destination = TRUE;
 }
 
-void
+G_MODULE_EXPORT void
 destination_browse_clicked_cb(GtkButton *button, signal_user_data_t *ud)
 {
        GtkWidget *dialog;
@@ -815,24 +1214,24 @@ destination_browse_clicked_cb(GtkButton *button, signal_user_data_t *ud)
        g_free(basename);
        if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
        {
-               char *filename;
+               char *filename, *dirname;
+               GtkFileChooser *dest_chooser;
                
                filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-               entry = (GtkEntry*)GHB_WIDGET(ud->builder, "destination");
-               if (entry == NULL)
-               {
-                       g_debug("Failed to find widget: %s", "destination");
-               }
-               else
-               {
-                       gtk_entry_set_text(entry, filename);
-               }
+               basename = g_path_get_basename(filename);
+               dirname = g_path_get_dirname(filename);
+               entry = (GtkEntry*)GHB_WIDGET(ud->builder, "dest_file");
+               gtk_entry_set_text(entry, basename);
+               dest_chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "dest_dir"));
+               gtk_file_chooser_set_filename(dest_chooser, dirname);
+               g_free (dirname);
+               g_free (basename);
                g_free (filename);
        }
        gtk_widget_destroy(dialog);
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 window_destroy_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *ud)
 {
        g_debug("window_destroy_event_cb ()");
@@ -842,14 +1241,14 @@ window_destroy_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *
        return FALSE;
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *ud)
 {
        gint state = ghb_get_queue_state();
        g_debug("window_delete_event_cb ()");
        if (state & GHB_STATE_WORKING)
        {
-               if (ghb_cancel_encode("Closing HandBrake will terminate encoding.\n"))
+               if (ghb_cancel_encode2(ud, "Closing HandBrake will terminate encoding.\n"))
                {
                        ghb_hb_cleanup(FALSE);
                        prune_logs(ud);
@@ -870,29 +1269,18 @@ update_acodec_combo(signal_user_data_t *ud)
        ghb_grey_combo_options (ud->builder);
 }
 
-void
+G_MODULE_EXPORT void
 container_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
-       const GValue *audio_list;
        g_debug("container_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       update_destination_extension(ud);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        update_acodec_combo(ud);
+       ghb_update_destination_extension(ud);
        ghb_clear_presets_selection(ud);
-
-       audio_list = ghb_settings_get_value(ud->settings, "audio_list");
-       if (ghb_ac3_in_audio_list (audio_list))
-       {
-               gchar *container;
-
-               container = ghb_settings_get_string(ud->settings, "FileFormat");
-               if (strcmp(container, "mp4") == 0)
-               {
-                       ghb_ui_update(ud, "FileFormat", ghb_string_value("m4v"));
-               }
-               g_free(container);
-       }
+       ghb_live_reset(ud);
+       ghb_subtitle_prune(ud);
+       ghb_audio_list_refresh_selected(ud);
 }
 
 static gchar*
@@ -927,6 +1315,7 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        GtkWidget *widget;
        gchar *text;
 
+       ud->dont_clear_presets = TRUE;
        widget = GHB_WIDGET (ud->builder, "title_duration");
        if (tinfo->duration != 0)
        {
@@ -958,10 +1347,11 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        ghb_ui_update(ud, "scale_width", 
                ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
        // If anamorphic or keep_aspect, the hight will be automatically calculated
-       gboolean keep_aspect, anamorphic;
+       gboolean keep_aspect;
+       gint pic_par;
        keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
-       anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic");
-       if (!(keep_aspect || anamorphic))
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
+       if (!(keep_aspect || pic_par) || pic_par == 3)
        {
                ghb_ui_update(ud, "scale_height", 
                        ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));
@@ -970,12 +1360,12 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        // Set the limits of cropping.  hb_set_anamorphic_size crashes if
        // you pass it a cropped width or height == 0.
        gint bound;
-       bound = tinfo->height / 2 - 2;
+       bound = tinfo->height / 2 - 8;
        widget = GHB_WIDGET (ud->builder, "PictureTopCrop");
        gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
        widget = GHB_WIDGET (ud->builder, "PictureBottomCrop");
        gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
-       bound = tinfo->width / 2 - 2;
+       bound = tinfo->width / 2 - 8;
        widget = GHB_WIDGET (ud->builder, "PictureLeftCrop");
        gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
        widget = GHB_WIDGET (ud->builder, "PictureRightCrop");
@@ -987,7 +1377,7 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
                ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(tinfo->crop[2]));
                ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(tinfo->crop[3]));
        }
-       ghb_set_scale (ud, GHB_SCALE_KEEP_NONE);
+       ghb_set_scale (ud, GHB_PIC_KEEP_PAR);
        gint width, height, crop[4];
        crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop");
        crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop");
@@ -1007,58 +1397,16 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        widget = GHB_WIDGET (ud->builder, "start_chapter");
        gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
        gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters);
+
+       widget = GHB_WIDGET (ud->builder, "angle");
+       gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
+       gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->angle_count);
+       ud->dont_clear_presets = FALSE;
 }
 
-static gint preview_button_width;
-static gint preview_button_height;
 static gboolean update_preview = FALSE;
 
-static void
-set_preview_image(signal_user_data_t *ud)
-{
-       GtkWidget *widget;
-       gint preview_width, preview_height, target_height, width, height;
-
-       g_debug("set_preview_button_image ()");
-       gint titleindex;
-
-       titleindex = ghb_settings_combo_int(ud->settings, "title");
-       if (titleindex < 0) return;
-       widget = GHB_WIDGET (ud->builder, "preview_frame");
-       gint frame = ghb_widget_int(widget) - 1;
-       GdkPixbuf *preview = ghb_get_preview_image (titleindex, frame, ud->settings, TRUE);
-       if (preview == NULL) return;
-       widget = GHB_WIDGET (ud->builder, "preview_image");
-       gtk_image_set_from_pixbuf(GTK_IMAGE(widget), preview);
-
-       preview_width = gdk_pixbuf_get_width(preview);
-       preview_height = gdk_pixbuf_get_height(preview);
-       gchar *text = g_strdup_printf("%d x %d", preview_width, preview_height);
-       widget = GHB_WIDGET (ud->builder, "preview_dims");
-       gtk_label_set_text(GTK_LABEL(widget), text);
-       g_free(text);
-       
-       g_debug("preview %d x %d", preview_width, preview_height);
-       target_height = MIN(preview_button_height - 12, 128);
-       height = target_height;
-       width = preview_width * height / preview_height;
-
-       if ((height >= 16) && (width >= 16))
-       {
-               GdkPixbuf *scaled_preview;
-               scaled_preview = gdk_pixbuf_scale_simple (preview, width, height, GDK_INTERP_NEAREST);
-               if (scaled_preview != NULL)
-               {
-                       g_object_unref (preview);
-                       
-                       widget = GHB_WIDGET (ud->builder, "preview_button_image");
-                       gtk_image_set_from_pixbuf(GTK_IMAGE(widget), scaled_preview);
-                       g_object_unref (scaled_preview);
-               }
-       }
-}
-
-void
+G_MODULE_EXPORT void
 title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        ghb_title_info_t tinfo;
@@ -1066,13 +1414,12 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        
        g_debug("title_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
 
        titleindex = ghb_settings_combo_int(ud->settings, "title");
-       ghb_update_ui_combo_box (ud->builder, "AudioTrack", titleindex, FALSE);
-       ghb_update_ui_combo_box (ud->builder, "Subtitles", titleindex, FALSE);
+       ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
+       ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
 
-       ghb_update_from_preset(ud, "Subtitles");
        if (ghb_get_title_info (&tinfo, titleindex))
        {
                show_title_info(ud, &tinfo);
@@ -1080,6 +1427,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        update_chapter_list (ud);
        ghb_adjust_audio_rate_combos(ud);
        ghb_set_pref_audio(titleindex, ud);
+       ghb_set_pref_subtitle(titleindex, ud);
        if (ghb_settings_get_boolean(ud->settings, "vquality_type_target"))
        {
                gint bitrate = ghb_calculate_target_bitrate (ud->settings, titleindex);
@@ -1087,115 +1435,106 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        }
 
        // Unfortunately, there is no way to query how many frames were
-       // actually generated during the scan.  It attempts to make 10.
+       // actually generated during the scan.
        // If I knew how many were generated, I would adjust the spin
        // control range here.
-       ghb_ui_update(ud, "preview_frame", ghb_int64_value(1));
-
-       set_preview_image (ud);
+       // I do know how many were asked for.
+       gint preview_count;
+       preview_count = ghb_settings_get_int(ud->settings, "preview_count");
+       widget = GHB_WIDGET(ud->builder, "preview_frame");
+       gtk_range_set_range (GTK_RANGE(widget), 1, preview_count);
+       ghb_ui_update(ud, "preview_frame", ghb_int64_value(2));
+
+       ghb_set_preview_image (ud);
+       if (ghb_settings_get_boolean(ud->settings, "title_no_in_destination"))
+       {
+               set_destination(ud);
+       }
+       ghb_preview_set_visible(ud);
 }
 
-void
+G_MODULE_EXPORT void
 setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
 }
 
-static void
-validate_filter_widget(signal_user_data_t *ud, const gchar *name)
+G_MODULE_EXPORT void
+chapter_markers_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
-       GtkTreeModel *store;
-       GtkTreeIter iter;
-       const gchar *str;
-       gboolean foundit = FALSE;
-       GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, name));
-       if (gtk_combo_box_get_active(combo) < 0)
-       { // Validate user input
-               gchar *val = ghb_settings_get_string(ud->settings, name);
-               store = gtk_combo_box_get_model(combo);
-               // Check to see if user manually entered one of the combo options
-               if (gtk_tree_model_get_iter_first(store, &iter))
-               {
-                       do
-                       {
-                               gtk_tree_model_get(store, &iter, 0, &str, -1);
-                               if (strcasecmp(val, str) == 0)
-                               {
-                                       gtk_combo_box_set_active_iter(combo, &iter);
-                                       foundit = TRUE;
-                                       break;
-                               }
-                       } while (gtk_tree_model_iter_next(store, &iter));
-               }
-               if (!foundit)
-               { // validate format of filter string
-                       if (!ghb_validate_filter_string(val, -1))
-                               gtk_combo_box_set_active(combo, 0);
-               }
-               g_free(val);
-       }
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
+       ghb_update_destination_extension(ud);
 }
 
-gboolean
-deint_tweak_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, 
-       signal_user_data_t *ud)
+G_MODULE_EXPORT void
+vquality_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
-       g_debug("deint_tweak_focus_out_cb ()");
-       validate_filter_widget(ud, "tweak_PictureDeinterlace");
-       return FALSE;
-}
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
 
-gboolean
-denoise_tweak_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, 
-       signal_user_data_t *ud)
-{
-       g_debug("denoise_tweak_focus_out_cb ()");
-       validate_filter_widget(ud, "tweak_PictureDenoise");
-       return FALSE;
+       gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
+       gdouble step;
+       if (vcodec == HB_VCODEC_X264)
+       {
+               step = ghb_settings_combo_double(ud->settings, 
+                                                                                       "VideoQualityGranularity");
+       }
+       else
+       {
+               step = 1;
+       }
+       gdouble val = gtk_range_get_value(GTK_RANGE(widget));
+       val = ((int)((val + step / 2) / step)) * step;
+       gtk_range_set_value(GTK_RANGE(widget), val);
 }
 
-void
+G_MODULE_EXPORT void
 http_opt_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
        // AC3 is not allowed when Web optimized
        ghb_grey_combo_options (ud->builder);
 }
 
-void
+G_MODULE_EXPORT void
 vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        gdouble vqmin, vqmax, step, page;
+       gboolean inverted;
        gint digits;
-       gint vcodec;
 
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
-       ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits);
+       ghb_live_reset(ud);
+       ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted);
        GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider");
        gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax);
        gtk_range_set_increments (GTK_RANGE(qp), step, page);
        gtk_scale_set_digits(GTK_SCALE(qp), digits);
-       vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
-       if (vcodec != HB_VCODEC_X264 && vcodec != HB_VCODEC_FFMPEG)
-       {
-               ghb_ui_update(ud, "directqp", ghb_boolean_value(FALSE));
-       }
+       gtk_range_set_inverted (GTK_RANGE(qp), inverted);
 }
 
-void
+G_MODULE_EXPORT void
 target_size_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        const gchar *name = gtk_widget_get_name(widget);
-       g_debug("setting_widget_changed_cb () %s", name);
+       g_debug("target_size_changed_cb () %s", name);
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
        if (ghb_settings_get_boolean(ud->settings, "vquality_type_target"))
        {
                gint titleindex;
@@ -1205,7 +1544,7 @@ target_size_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        }
 }
 
-void
+G_MODULE_EXPORT void
 start_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        gint start, end;
@@ -1217,14 +1556,25 @@ start_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        end = ghb_settings_get_int(ud->settings, "end_chapter");
        if (start > end)
                ghb_ui_update(ud, "end_chapter", ghb_int_value(start));
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination"))
        {
                set_destination(ud);
        }
+       widget = GHB_WIDGET (ud->builder, "chapters_tab");
+       // End may have been changed above, get it again
+       end = ghb_settings_get_int(ud->settings, "end_chapter");
+       if (start == end)
+       {
+               gtk_widget_hide(widget);
+       }
+       else
+       {
+               gtk_widget_show(widget);
+       }
 }
 
-void
+G_MODULE_EXPORT void
 end_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        gint start, end;
@@ -1236,20 +1586,33 @@ end_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        end = ghb_settings_get_int(ud->settings, "end_chapter");
        if (start > end)
                ghb_ui_update(ud, "start_chapter", ghb_int_value(end));
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        if (ghb_settings_get_boolean(ud->settings, "chapters_in_destination"))
        {
                set_destination(ud);
        }
+       widget = GHB_WIDGET (ud->builder, "chapters_tab");
+       // Start may have been changed above, get it again
+       start = ghb_settings_get_int(ud->settings, "start_chapter");
+       if (start == end)
+       {
+               gtk_widget_hide(widget);
+       }
+       else
+       {
+               gtk_widget_show(widget);
+       }
 }
 
-void
+G_MODULE_EXPORT void
 scale_width_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("scale_width_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
-       ghb_set_scale (ud, GHB_SCALE_KEEP_WIDTH);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_WIDTH);
        update_preview = TRUE;
        gchar *text;
        gint width = ghb_settings_get_int(ud->settings, "scale_width");
@@ -1258,15 +1621,18 @@ scale_width_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        text = g_strdup_printf ("%d x %d", width, height);
        gtk_label_set_text (GTK_LABEL(widget), text);
        g_free(text);
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
 scale_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("scale_height_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
-       ghb_set_scale (ud, GHB_SCALE_KEEP_HEIGHT);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_HEIGHT);
        update_preview = TRUE;
        gchar *text;
        gint width = ghb_settings_get_int(ud->settings, "scale_width");
@@ -1275,9 +1641,10 @@ scale_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        text = g_strdup_printf ("%d x %d", width, height);
        gtk_label_set_text (GTK_LABEL(widget), text);
        g_free(text);
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
 crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        gint titleindex, crop[4];
@@ -1285,8 +1652,10 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        
        g_debug("crop_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
-       ghb_set_scale (ud, GHB_SCALE_KEEP_NONE);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, 0);
 
        crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop");
        crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop");
@@ -1303,6 +1672,8 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                widget = GHB_WIDGET (ud->builder, "crop_dimensions");
                text = g_strdup_printf ("%d x %d", width, height);
                gtk_label_set_text (GTK_LABEL(widget), text);
+               widget = GHB_WIDGET (ud->builder, "crop_dimensions2");
+               gtk_label_set_text (GTK_LABEL(widget), text);
                g_free(text);
        }
        gchar *text;
@@ -1311,16 +1682,61 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        gtk_label_set_text (GTK_LABEL(widget), text);
        g_free(text);
        update_preview = TRUE;
+       ghb_live_reset(ud);
 }
 
-void
+G_MODULE_EXPORT void
+display_width_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("display_width_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_DISPLAY_WIDTH);
+
+       update_preview = TRUE;
+}
+
+G_MODULE_EXPORT void
+display_height_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("display_height_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_DISPLAY_HEIGHT);
+
+       update_preview = TRUE;
+}
+
+G_MODULE_EXPORT void
+par_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("par_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, GHB_PIC_KEEP_PAR);
+
+       update_preview = TRUE;
+}
+
+G_MODULE_EXPORT void
 scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("scale_changed_cb ()");
        ghb_widget_to_setting(ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
-       ghb_set_scale (ud, GHB_SCALE_KEEP_NONE);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, 0);
        update_preview = TRUE;
        
        gchar *text;
@@ -1331,12 +1747,41 @@ scale_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        text = ghb_settings_get_boolean(ud->settings, "autoscale") ? "On" : "Off";
        widget = GHB_WIDGET (ud->builder, "scale_auto");
        gtk_label_set_text (GTK_LABEL(widget), text);
-       text = ghb_settings_get_boolean(ud->settings, "anamorphic") ? "On" : "Off";
+       switch (ghb_settings_combo_int(ud->settings, "PicturePAR"))
+       {
+               case 0:
+                       text = "Off";
+                       break;
+               case 1:
+                       text = "Strict";
+                       break;
+               case 2:
+                       text = "Loose";
+                       break;
+               case 3:
+                       text = "Custom";
+                       break;
+               default:
+                       text = "Unknown";
+                       break;
+       }
        widget = GHB_WIDGET (ud->builder, "scale_anamorphic");
        gtk_label_set_text (GTK_LABEL(widget), text);
 }
 
-void
+G_MODULE_EXPORT void
+show_crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("show_crop_changed_cb ()");
+       ghb_widget_to_setting(ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_live_reset(ud);
+       if (GTK_WIDGET_SENSITIVE(widget))
+               ghb_set_scale (ud, 0);
+       update_preview = TRUE;
+}
+
+G_MODULE_EXPORT void
 generic_entry_changed_cb(GtkEntry *entry, signal_user_data_t *ud)
 {
        // Normally (due to user input) I only want to process the entry
@@ -1353,7 +1798,7 @@ generic_entry_changed_cb(GtkEntry *entry, signal_user_data_t *ud)
        }
 }
 
-void
+G_MODULE_EXPORT void
 prefs_dialog_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkWidget *dialog;
@@ -1365,6 +1810,95 @@ prefs_dialog_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        gtk_widget_hide(dialog);
 }
 
+typedef struct
+{
+       GtkMessageDialog *dlg;
+       const gchar *msg;
+       const gchar *action;
+       gint timeout;
+} countdown_t;
+
+static gboolean
+shutdown_cb(countdown_t *cd)
+{
+       gchar *str;
+
+       cd->timeout--;
+       if (cd->timeout == 0)
+       {
+               ghb_shutdown_gsm();
+               gtk_main_quit();
+               return FALSE;
+       }
+       str = g_strdup_printf("%s\n\n%s in %d seconds ...", 
+                                                       cd->msg, cd->action, cd->timeout);
+       gtk_message_dialog_set_markup(cd->dlg, str);
+       g_free(str);
+       return TRUE;
+}
+
+static gboolean
+suspend_cb(countdown_t *cd)
+{
+       gchar *str;
+
+       cd->timeout--;
+       if (cd->timeout == 0)
+       {
+               gtk_widget_destroy (GTK_WIDGET(cd->dlg));
+               ghb_suspend_gpm();
+               return FALSE;
+       }
+       str = g_strdup_printf("%s\n\n%s in %d seconds ...", 
+                                                       cd->msg, cd->action, cd->timeout);
+       gtk_message_dialog_set_markup(cd->dlg, str);
+       g_free(str);
+       return TRUE;
+}
+
+void
+ghb_countdown_dialog(
+       GtkMessageType type, 
+       const gchar *message, 
+       const gchar *action, 
+       const gchar *cancel, 
+       GSourceFunc action_func,
+       gint timeout)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+       guint timeout_id;
+       countdown_t cd;
+                       
+       cd.msg = message;
+       cd.action = action;
+       cd.timeout = timeout;
+
+       // Toss up a warning dialog
+       dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+                                                       type, GTK_BUTTONS_NONE,
+                                                       "%s\n\n%s in %d seconds ...", 
+                                                       message, action, timeout);
+       gtk_dialog_add_buttons( GTK_DIALOG(dialog), 
+                                                  cancel, GTK_RESPONSE_CANCEL,
+                                                  NULL);
+
+       cd.dlg = GTK_MESSAGE_DIALOG(dialog);
+       timeout_id = g_timeout_add(1000, action_func, &cd);
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+       if (response == GTK_RESPONSE_CANCEL)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+}
+
 gboolean
 ghb_message_dialog(GtkMessageType type, const gchar *message, const gchar *no, const gchar *yes)
 {
@@ -1387,26 +1921,91 @@ ghb_message_dialog(GtkMessageType type, const gchar *message, const gchar *no, c
        return TRUE;
 }
 
-gboolean
-ghb_cancel_encode(const gchar *extra_msg)
+void
+ghb_error_dialog(GtkMessageType type, const gchar *message, const gchar *cancel)
 {
        GtkWidget *dialog;
        GtkResponseType response;
-       
-       if (extra_msg == NULL) extra_msg = "";
+                       
        // Toss up a warning dialog
        dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
-                               "%sYour movie will be lost if you don't continue encoding.",
-                               extra_msg);
+                                                       type, GTK_BUTTONS_NONE,
+                                                       "%s", message);
        gtk_dialog_add_buttons( GTK_DIALOG(dialog), 
-                                                  "Continue Encoding", GTK_RESPONSE_NO,
-                                                  "Stop Encoding", GTK_RESPONSE_YES, NULL);
+                                                  cancel, GTK_RESPONSE_CANCEL, NULL);
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy (dialog);
-       if (response == GTK_RESPONSE_NO) return FALSE;
-       ghb_stop_queue();
-       return TRUE;
+}
+
+void
+ghb_cancel_encode(signal_user_data_t *ud, const gchar *extra_msg)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+       
+       if (extra_msg == NULL) extra_msg = "";
+       // Toss up a warning dialog
+       dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+                               GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
+                               "%sYour movie will be lost if you don't continue encoding.",
+                               extra_msg);
+       gtk_dialog_add_buttons( GTK_DIALOG(dialog), 
+                                                  "Cancel Current and Stop", 1,
+                                                  "Cancel Current, Start Next", 2,
+                                                  "Finish Current, then Stop", 3,
+                                                  "Continue Encoding", 4,
+                                                  NULL);
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+       switch (response)
+       {
+               case 1:
+                       ghb_stop_queue();
+                       ud->cancel_encode = GHB_CANCEL_ALL;
+                       break;
+               case 2:
+                       ghb_stop_queue();
+                       ud->cancel_encode = GHB_CANCEL_CURRENT;
+                       break;
+               case 3:
+                       ud->cancel_encode = GHB_CANCEL_FINISH;
+                       break;
+               case 4:
+               default:
+                       ud->cancel_encode = GHB_CANCEL_NONE;
+                       break;
+       }
+}
+
+gboolean
+ghb_cancel_encode2(signal_user_data_t *ud, const gchar *extra_msg)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+       
+       if (extra_msg == NULL) extra_msg = "";
+       // Toss up a warning dialog
+       dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+                               GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
+                               "%sYour movie will be lost if you don't continue encoding.",
+                               extra_msg);
+       gtk_dialog_add_buttons( GTK_DIALOG(dialog), 
+                                                  "Cancel Current and Stop", 1,
+                                                  "Continue Encoding", 4,
+                                                  NULL);
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+       switch (response)
+       {
+               case 1:
+                       ghb_stop_queue();
+                       ud->cancel_encode = GHB_CANCEL_ALL;
+                       return TRUE;
+               case 4:
+               default:
+                       break;
+       }
+       return FALSE;
 }
 
 static void
@@ -1414,7 +2013,7 @@ submit_job(GValue *settings)
 {
        static gint unique_id = 1;
        gchar *type, *modified, *preset;
-       GValue *path;
+       const GValue *path;
        gboolean preset_modified;
 
        g_debug("submit_job");
@@ -1438,13 +2037,19 @@ static void
 prune_logs(signal_user_data_t *ud)
 {
        gchar *dest_dir;
+       gint days;
 
        // Only prune logs stored in the default config dir location
+       days = ghb_settings_combo_int(ud->settings, "LogLongevity");
+       if (days > 365)
+               return;
+
        dest_dir = ghb_get_user_config_dir("EncodeLogs");
        if (g_file_test(dest_dir, G_FILE_TEST_IS_DIR))
        {
                const gchar *file;
-               int week = 7*24*60*60;
+               gint duration = days * 24 * 60 * 60;
+               
                GDir *gdir = g_dir_open(dest_dir, 0, NULL);
                time_t now;
 
@@ -1457,7 +2062,7 @@ prune_logs(signal_user_data_t *ud)
 
                        path = g_strdup_printf("%s/%s", dest_dir, file);
                        g_stat(path, &stbuf);
-                       if (now - stbuf.st_mtime > week)
+                       if (now - stbuf.st_mtime > duration)
                        {
                                g_unlink(path);
                        }
@@ -1467,6 +2072,7 @@ prune_logs(signal_user_data_t *ud)
                g_dir_close(gdir);
        }
        g_free(dest_dir);
+       ghb_preview_cleanup(ud);
 }
 
 static void
@@ -1496,10 +2102,11 @@ queue_scan(signal_user_data_t *ud, GValue *js)
        {
                *pos = 0;
        }
-       log_path = g_strdup_printf("%s/%d-%02d-%02d %02d-%02d-%02d %s.log",
+       log_path = g_strdup_printf("%s/%s %d-%02d-%02d %02d-%02d-%02d.log",
                dest_dir,
+               basename,
                now->tm_year + 1900, now->tm_mon + 1, now->tm_mday,
-               now->tm_hour, now->tm_min, now->tm_sec, basename);
+               now->tm_hour, now->tm_min, now->tm_sec);
        g_free(basename);
        g_free(dest_dir);
        if (ud->job_activity_log)
@@ -1510,7 +2117,7 @@ queue_scan(signal_user_data_t *ud, GValue *js)
                gchar *ver_str;
 
                ver_str = g_strdup_printf("Handbrake Version: %s (%d)\n", 
-                                                                       HB_VERSION, HB_BUILD);
+                                                                       hb_get_version(NULL), hb_get_build(NULL));
                g_io_channel_write_chars (ud->job_activity_log, ver_str, 
                                                                        -1, NULL, NULL);
                g_free(ver_str);
@@ -1523,6 +2130,42 @@ queue_scan(signal_user_data_t *ud, GValue *js)
        g_free(path);
 }
 
+static gint
+queue_pending_count(GValue *queue)
+{
+       gint nn, ii, count;
+       GValue *js;
+       gint status;
+
+       nn = 0;
+       count = ghb_array_len(queue);
+       for (ii = 0; ii < count; ii++)
+       {
+
+               js = ghb_array_get_nth(queue, ii);
+               status = ghb_settings_get_int(js, "job_status");
+               if (status == GHB_QUEUE_PENDING)
+               {
+                       nn++;
+               }
+       }
+       return nn;
+}
+
+void
+ghb_update_pending(signal_user_data_t *ud)
+{
+       GtkLabel *label;
+       gint pending;
+       gchar *str;
+
+       label = GTK_LABEL(GHB_WIDGET(ud->builder, "pending_status"));
+       pending = queue_pending_count(ud->queue);
+       str = g_strdup_printf("%d encode(s) pending", pending);
+       gtk_label_set_text(label, str);
+       g_free(str);
+}
+
 GValue* 
 ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
 {
@@ -1530,8 +2173,12 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
        gint count, ii, jj;
        GValue *js;
        gint status;
+       GtkWidget *prog;
 
        g_debug("start_next_job");
+       prog = GHB_WIDGET(ud->builder, "progressbar");
+       gtk_widget_show(prog);
+
        count = ghb_array_len(ud->queue);
        if (find_first)
        {       // Start the first pending item in the queue
@@ -1544,11 +2191,15 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                        if (status == GHB_QUEUE_PENDING)
                        {
                                current = ii;
+                               ghb_inhibit_gsm(ud);
                                queue_scan(ud, js);
+                               ghb_update_pending(ud);
                                return js;
                        }
                }
                // Nothing pending
+               ghb_uninhibit_gsm();
+               ghb_notify_done(ud);
                return NULL;
        }
        // Find the next pending item after the current running item
@@ -1565,7 +2216,9 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                                if (status == GHB_QUEUE_PENDING)
                                {
                                        current = jj;
+                                       ghb_inhibit_gsm(ud);
                                        queue_scan(ud, js);
+                                       ghb_update_pending(ud);
                                        return js;
                                }
                        }
@@ -1580,11 +2233,17 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first)
                if (status == GHB_QUEUE_PENDING)
                {
                        current = ii;
+                       ghb_inhibit_gsm(ud);
                        queue_scan(ud, js);
+                       ghb_update_pending(ud);
                        return js;
                }
        }
        // Nothing found
+       ghb_uninhibit_gsm();
+       ghb_notify_done(ud);
+       ghb_update_pending(ud);
+       gtk_widget_hide(prog);
        return NULL;
 }
 
@@ -1597,6 +2256,9 @@ find_queue_job(GValue *queue, gint unique_id, GValue **job)
        
        *job = NULL;
        g_debug("find_queue_job");
+       if (unique_id == 0)  // Invalid Id
+               return -1;
+
        count = ghb_array_len(queue);
        for (ii = 0; ii < count; ii++)
        {
@@ -1612,32 +2274,45 @@ find_queue_job(GValue *queue, gint unique_id, GValue **job)
 }
 
 gchar*
-working_status_string(signal_user_data_t *ud, ghb_status_t *status)
+working_status_string(signal_user_data_t *ud, ghb_instance_status_t *status)
 {
        gchar *task_str, *job_str, *status_str;
        gint qcount;
        gint index;
        GValue *js;
+       gboolean subtitle_scan = FALSE;
 
-       if (status->job_count > 1)
-       {
-               task_str = g_strdup_printf("pass %d of %d, ", 
-                       status->job_cur, status->job_count);
-       }
-       else
+       qcount = ghb_array_len(ud->queue);
+       index = find_queue_job(ud->queue, status->unique_id, &js);
+       if (js != NULL)
        {
-               task_str = g_strdup("");
+               subtitle_scan = ghb_settings_get_boolean(js, "subtitle_scan");
        }
-       qcount = ghb_array_len(ud->queue);
        if (qcount > 1)
        {
-               index = find_queue_job(ud->queue, status->unique_id, &js);
                job_str = g_strdup_printf("job %d of %d, ", index+1, qcount);
        }
        else
        {
                job_str = g_strdup("");
        }
+       if (status->job_count > 1)
+       {
+               if (status->job_cur == 1 && subtitle_scan)
+               {
+                       task_str = g_strdup_printf("pass %d (subtitle scan) of %d, ", 
+                               status->job_cur, status->job_count);
+               }
+               else
+               {
+                       task_str = g_strdup_printf("pass %d of %d, ", 
+                               status->job_cur, status->job_count);
+               }
+       }
+       else
+       {
+               task_str = g_strdup("");
+       }
        if(status->seconds > -1)
        {
                status_str= g_strdup_printf(
@@ -1666,116 +2341,182 @@ ghb_backend_events(signal_user_data_t *ud)
        ghb_status_t status;
        gchar *status_str;
        GtkProgressBar *progress;
+       GtkLabel       *work_status;
        gint titleindex;
        GValue *js;
        gint index;
        GtkTreeView *treeview;
        GtkTreeStore *store;
        GtkTreeIter iter;
-       static gint working = 0;
-       static gboolean work_started = FALSE;
+       static gint prev_scan_state = 0;
+       static gint prev_queue_state = 0;
        
        ghb_track_status();
        ghb_get_status(&status);
+       if (prev_scan_state != status.scan.state ||
+               prev_queue_state != status.queue.state)
+       {
+               ghb_queue_buttons_grey(ud);
+               prev_scan_state = status.scan.state;
+               prev_queue_state = status.queue.state;
+       }
        progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
+       work_status = GTK_LABEL(GHB_WIDGET (ud->builder, "work_status"));
+       if (status.scan.state == GHB_STATE_IDLE && 
+               status.queue.state == GHB_STATE_IDLE)
+       {
+               static gboolean prev_dvdnav;
+               gboolean dvdnav = ghb_settings_get_boolean(ud->settings, "use_dvdnav");
+               if (dvdnav != prev_dvdnav)
+               {
+                       hb_dvd_set_dvdnav(dvdnav);
+                       prev_dvdnav = dvdnav;
+               }
+       }
        // First handle the status of title scans
        // Then handle the status of the queue
-       if (status.state & GHB_STATE_SCANNING)
+       if (status.scan.state & GHB_STATE_SCANNING)
        {
-               if (status.title_cur == 0)
+               GtkProgressBar *scan_prog;
+               GtkLabel *label;
+
+               scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog"));
+               label = GTK_LABEL(GHB_WIDGET (ud->builder, "source_title"));
+
+               if (status.scan.title_cur == 0)
                {
                        status_str = g_strdup ("Scanning...");
                }
                else
                {
                        status_str = g_strdup_printf ("Scanning title %d of %d...", 
-                                                                 status.title_cur, status.title_count );
+                                                         status.scan.title_cur, status.scan.title_count );
                }
-               gtk_progress_bar_set_text (progress, status_str);
+               gtk_label_set_text (label, status_str);
                g_free(status_str);
-               if (status.title_count > 0)
+               if (status.scan.title_count > 0)
                {
-                       gtk_progress_bar_set_fraction (progress
-                               (gdouble)status.title_cur / status.title_count);
+                       gtk_progress_bar_set_fraction (scan_prog
+                               (gdouble)status.scan.title_cur / status.scan.title_count);
                }
        }
-       else if (status.state & GHB_STATE_SCANDONE)
+       else if (status.scan.state & GHB_STATE_SCANDONE)
        {
-               status_str = g_strdup_printf ("Scan done"); 
-               gtk_progress_bar_set_text (progress, status_str);
-               g_free(status_str);
-               gtk_progress_bar_set_fraction (progress, 1.0);
+               gchar *source;
+               GtkProgressBar *scan_prog;
+               GtkLabel *label;
+
+               GtkWidget *widget;
+               GtkAction *action;
+
+               widget = GHB_WIDGET(ud->builder, "sourcetoolbutton");
+               gtk_widget_set_sensitive(widget, TRUE);
+               action = GHB_ACTION(ud->builder, "source_action");
+               gtk_action_set_sensitive(action, TRUE);
+               action = GHB_ACTION(ud->builder, "source_single_action");
+               gtk_action_set_sensitive(action, TRUE);
+
+               source = ghb_settings_get_string(ud->settings, "source");
+               update_source_label(ud, source, FALSE);
+
+               scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog"));
+               gtk_progress_bar_set_fraction (scan_prog, 1.0);
+               gtk_widget_hide(GTK_WIDGET(scan_prog));
 
                ghb_title_info_t tinfo;
                        
-               ghb_update_ui_combo_box(ud->builder, "title", 0, FALSE);
+               ghb_update_ui_combo_box(ud, "title", 0, FALSE);
                titleindex = ghb_longest_title();
                ghb_ui_update(ud, "title", ghb_int64_value(titleindex));
 
+               label = GTK_LABEL(GHB_WIDGET (ud->builder, "source_title"));
                // Are there really any titles.
                if (!ghb_get_title_info(&tinfo, titleindex))
                {
-                       GtkProgressBar *progress;
-                       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
-                       gtk_progress_bar_set_fraction (progress, 0);
-                       gtk_progress_bar_set_text (progress, "No Source");
+                       gtk_label_set_text(label, "None");
                }
-               ghb_clear_state(GHB_STATE_SCANDONE);
-               ghb_queue_buttons_grey(ud, work_started);
+               ghb_clear_scan_state(GHB_STATE_SCANDONE);
                if (ghb_queue_edit_settings)
                {
-                       gint jstatus;
-
-                       jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
                        ghb_settings_to_ui(ud, ghb_queue_edit_settings);
                        ghb_set_audio(ud, ghb_queue_edit_settings);
-                       if (jstatus == GHB_QUEUE_PENDING)
-                       {
-                               ghb_value_free(ghb_queue_edit_settings);
-                       }
+                       ghb_reset_subtitles(ud, ghb_queue_edit_settings);
+                       reset_chapter_list(ud, ghb_queue_edit_settings);
+                       ghb_value_free(ghb_queue_edit_settings);
                        ghb_queue_edit_settings = NULL;
                }
        }
-       else if (status.queue_state & GHB_STATE_SCANNING)
+
+       if (status.queue.state & GHB_STATE_SCANNING)
        {
-               status_str = g_strdup_printf ("Scanning ...");
-               gtk_progress_bar_set_text (progress, status_str);
-               g_free(status_str);
+               // This needs to be in scanning and working since scanning
+               // happens fast enough that it can be missed
+               gtk_label_set_text (work_status, "Scanning ...");
                gtk_progress_bar_set_fraction (progress, 0);
        }
-       else if (status.queue_state & GHB_STATE_SCANDONE)
+       else if (status.queue.state & GHB_STATE_SCANDONE)
        {
                ghb_clear_queue_state(GHB_STATE_SCANDONE);
+               usleep(2000000);
                submit_job(ud->current_job);
+               ghb_update_pending(ud);
        }
-       else if (status.queue_state & GHB_STATE_PAUSED)
+       else if (status.queue.state & GHB_STATE_PAUSED)
        {
-               status_str = g_strdup_printf ("Paused"); 
-               gtk_progress_bar_set_text (progress, status_str);
-               g_free(status_str);
+               gtk_label_set_text (work_status, "Paused");
        }
-       else if (status.queue_state & GHB_STATE_WORKING)
+       else if (status.queue.state & GHB_STATE_WORKING)
        {
-               status_str = working_status_string(ud, &status);
-               gtk_progress_bar_set_text (progress, status_str);
-               gtk_progress_bar_set_fraction (progress, status.progress);
+               static gint working = 0;
+
+               // This needs to be in scanning and working since scanning
+               // happens fast enough that it can be missed
+               index = find_queue_job(ud->queue, status.queue.unique_id, &js);
+               if (status.queue.unique_id != 0 && index >= 0)
+               {
+                       gchar working_icon[] = "hb-working0";
+                       working_icon[10] = '0' + working;
+                       working = (working+1) % 6;
+                       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
+                       store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
+                       gchar *path = g_strdup_printf ("%d", index);
+                       if (gtk_tree_model_get_iter_from_string(
+                                       GTK_TREE_MODEL(store), &iter, path))
+                       {
+                               gtk_tree_store_set(store, &iter, 0, working_icon, -1);
+                       }
+                       g_free(path);
+               }
+               GtkLabel *label;
+               gchar *status_str;
+
+               status_str = working_status_string(ud, &status.queue);
+               label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status"));
+               gtk_label_set_text (label, status_str);
+#if !GTK_CHECK_VERSION(2, 16, 0)
+               GtkStatusIcon *si;
+
+               si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+               gtk_status_icon_set_tooltip(si, status_str);
+#endif
+               gtk_label_set_text (work_status, status_str);
+               gtk_progress_bar_set_fraction (progress, status.queue.progress);
                g_free(status_str);
        }
-       else if (status.queue_state & GHB_STATE_WORKDONE)
+       else if (status.queue.state & GHB_STATE_WORKDONE)
        {
                gint qstatus;
 
-               work_started = FALSE;
-               ghb_queue_buttons_grey(ud, FALSE);
-               index = find_queue_job(ud->queue, status.unique_id, &js);
+               index = find_queue_job(ud->queue, status.queue.unique_id, &js);
                treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
                store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
-               if (ud->cancel_encode)
-                       status.error = GHB_ERROR_CANCELED;
-               switch( status.error )
+               if (ud->cancel_encode == GHB_CANCEL_ALL || 
+                       ud->cancel_encode == GHB_CANCEL_CURRENT)
+                       status.queue.error = GHB_ERROR_CANCELED;
+               switch( status.queue.error )
                {
                        case GHB_ERROR_NONE:
-                               gtk_progress_bar_set_text( progress, "Rip done!" );
+                               gtk_label_set_text (work_status, "Rip Done!");
                                qstatus = GHB_QUEUE_DONE;
                                if (js != NULL)
                                {
@@ -1789,7 +2530,7 @@ ghb_backend_events(signal_user_data_t *ud)
                                }
                                break;
                        case GHB_ERROR_CANCELED:
-                               gtk_progress_bar_set_text( progress, "Rip canceled." );
+                               gtk_label_set_text (work_status, "Rip Canceled.");
                                qstatus = GHB_QUEUE_CANCELED;
                                if (js != NULL)
                                {
@@ -1803,7 +2544,7 @@ ghb_backend_events(signal_user_data_t *ud)
                                }
                                break;
                        default:
-                               gtk_progress_bar_set_text( progress, "Rip failed.");
+                               gtk_label_set_text (work_status, "Rip Failed.");
                                qstatus = GHB_QUEUE_CANCELED;
                                if (js != NULL)
                                {
@@ -1818,71 +2559,97 @@ ghb_backend_events(signal_user_data_t *ud)
                }
                gtk_progress_bar_set_fraction (progress, 1.0);
                ghb_clear_queue_state(GHB_STATE_WORKDONE);
-               if (!ud->cancel_encode)
+               if (ud->job_activity_log)
+                       g_io_channel_unref(ud->job_activity_log);
+               ud->job_activity_log = NULL;
+               if (ud->cancel_encode != GHB_CANCEL_ALL &&
+                       ud->cancel_encode != GHB_CANCEL_FINISH)
+               {
                        ud->current_job = ghb_start_next_job(ud, FALSE);
+               }
                else
+               {
+                       ghb_uninhibit_gsm();
                        ud->current_job = NULL;
+                       gtk_widget_hide(GTK_WIDGET(progress));
+               }
                if (js)
                        ghb_settings_set_int(js, "job_status", qstatus);
                ghb_save_queue(ud->queue);
-               ud->cancel_encode = FALSE;
-               g_io_channel_unref(ud->job_activity_log);
-               ud->job_activity_log = NULL;
+               ud->cancel_encode = GHB_CANCEL_NONE;
+#if !GTK_CHECK_VERSION(2, 16, 0)
+               GtkStatusIcon *si;
+
+               si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+               gtk_status_icon_set_tooltip(si, "HandBrake");
+#endif
        }
-       else if (status.queue_state & GHB_STATE_MUXING)
+       else if (status.queue.state & GHB_STATE_MUXING)
        {
-               gtk_progress_bar_set_text(progress, "Muxing: this may take awhile...");
+               gtk_label_set_text (work_status, "Muxing: This may take a while...");
        }
-       if (status.queue_state & GHB_STATE_SCANNING)
+
+       if (status.scan.state & GHB_STATE_WORKING)
        {
-               // This needs to be in scanning and working since scanning
-               // happens fast enough that it can be missed
-               if (!work_started)
-               {
-                       work_started = TRUE;
-                       ghb_queue_buttons_grey(ud, TRUE);
-               }
+               GtkProgressBar *live_progress;
+               live_progress = GTK_PROGRESS_BAR(
+                       GHB_WIDGET(ud->builder, "live_encode_progress"));
+               status_str = working_status_string(ud, &status.scan);
+               gtk_progress_bar_set_text (live_progress, status_str);
+               gtk_progress_bar_set_fraction (live_progress, status.scan.progress);
+               g_free(status_str);
        }
-       if (status.queue_state & GHB_STATE_WORKING)
+       if (status.scan.state & GHB_STATE_WORKDONE)
        {
-               // This needs to be in scanning and working since scanning
-               // happens fast enough that it can be missed
-               if (!work_started)
-               {
-                       work_started = TRUE;
-                       ghb_queue_buttons_grey(ud, TRUE);
-               }
-               index = find_queue_job(ud->queue, status.unique_id, &js);
-               if (status.unique_id != 0 && index >= 0)
+               switch( status.scan.error )
                {
-                       gchar working_icon[] = "hb-working0";
-                       working_icon[10] = '0' + working;
-                       working = (working+1) % 6;
-                       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
-                       store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
-                       gchar *path = g_strdup_printf ("%d", index);
-                       if (gtk_tree_model_get_iter_from_string(
-                                       GTK_TREE_MODEL(store), &iter, path))
+                       case GHB_ERROR_NONE:
                        {
-                               gtk_tree_store_set(store, &iter, 0, working_icon, -1);
-                       }
-                       g_free(path);
+                               ghb_live_encode_done(ud, TRUE);
+                       } break;
+                       default:
+                       {
+                               ghb_live_encode_done(ud, FALSE);
+                       } break;
                }
-               GtkLabel *label;
-               gchar *status_str;
-
-               status_str = working_status_string(ud, &status);
-               label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status"));
-               gtk_label_set_text (label, status_str);
-               g_free(status_str);
+               ghb_clear_scan_state(GHB_STATE_WORKDONE);
        }
 }
 
-gboolean
+#if GTK_CHECK_VERSION(2, 16, 0)
+G_MODULE_EXPORT gboolean
+status_icon_query_tooltip_cb(
+       GtkStatusIcon *si,
+       gint           x,
+       gint           y,
+       gboolean       kbd_mode,
+       GtkTooltip    *tt,
+       signal_user_data_t *ud)
+{
+       ghb_status_t status;
+       gchar *status_str;
+
+       ghb_get_status(&status);
+       if (status.queue.state & GHB_STATE_WORKING)
+               status_str = working_status_string(ud, &status.queue);
+       else if (status.queue.state & GHB_STATE_WORKDONE)
+               status_str = g_strdup("Encode Complete");
+       else
+               status_str = g_strdup("HandBrake");
+
+       gtk_tooltip_set_text(tt, status_str);
+       gtk_tooltip_set_icon_from_icon_name(tt, "hb-icon", GTK_ICON_SIZE_BUTTON);
+       g_free(status_str);
+       return TRUE;
+}
+#endif
+
+G_MODULE_EXPORT gboolean
 ghb_timer_cb(gpointer data)
 {
        signal_user_data_t *ud = (signal_user_data_t*)data;
 
+       ghb_live_preview_progress(ud);
        ghb_backend_events(ud);
        if (update_default_destination)
        {
@@ -1902,17 +2669,49 @@ ghb_timer_cb(gpointer data)
        }
        if (update_preview)
        {
-               set_preview_image (ud);
+               g_debug("Updating preview\n");
+               ghb_set_preview_image (ud);
                update_preview = FALSE;
        }
+
+       if (!appcast_busy)
+       {
+               gchar *updates;
+               updates = ghb_settings_get_string(ud->settings, "check_updates");
+               gint64 duration = 0;
+               if (strcmp(updates, "daily") == 0)
+                       duration = 60 * 60 * 24;
+               else if (strcmp(updates, "weekly") == 0)
+                       duration = 60 * 60 * 24 * 7;
+               else if (strcmp(updates, "monthly") == 0)
+                       duration = 60 * 60 * 24 * 7;
+
+               g_free(updates);
+               if (duration != 0)
+               {
+                       gint64 last;
+                       time_t tt;
+
+                       last = ghb_settings_get_int64(ud->settings, "last_update_check");
+                       time(&tt);
+                       if (last + duration < tt)
+                       {
+                               ghb_settings_set_int64(ud->settings, 
+                                                                               "last_update_check", tt);
+                               ghb_pref_save(ud->settings, "last_update_check");
+                               g_thread_create((GThreadFunc)ghb_check_update, ud, 
+                                                               FALSE, NULL);
+                       }
+               }
+       }
        return TRUE;
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
 {
        gchar *text = NULL;
-       gsize length;
+       gsize length, outlength;
        GtkTextView *textview;
        GtkTextBuffer *buffer;
        GtkTextIter iter;
@@ -1923,18 +2722,23 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
        signal_user_data_t *ud = (signal_user_data_t*)data;
 
        status = g_io_channel_read_line (source, &text, &length, NULL, &gerror);
-       if (text != NULL)
+       // Trim nils from end of text, they cause g_io_channel_write_chars to
+       // fail with an assertion that aborts
+       while (length > 0 && text[length-1] == 0)
+               length--;
+       if (text != NULL && length > 0)
        {
                GdkWindow *window;
                gint width, height;
                gint x, y;
                gboolean bottom = FALSE;
+               gchar *utf8_text;
 
                textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view"));
                buffer = gtk_text_view_get_buffer (textview);
                // I would like to auto-scroll the window when the scrollbar
                // is at the bottom, 
-               // must determining whether the insert point is at
+               // must determine whether the insert point is at
                // the bottom of the window 
                window = gtk_text_view_get_window(textview, GTK_TEXT_WINDOW_TEXT);
                if (window != NULL)
@@ -1954,20 +2758,45 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
                        bottom = TRUE;
                }
                gtk_text_buffer_get_end_iter(buffer, &iter);
-               gtk_text_buffer_insert(buffer, &iter, text, -1);
-               if (bottom)
+               utf8_text = g_convert_with_fallback(text, -1, "UTF-8", "ISO-8859-1",
+                                                                                       "?", NULL, &length, NULL);
+               if (utf8_text != NULL)
                {
-                       //gtk_text_view_scroll_to_iter(textview, &iter, 0, FALSE, 0, 0);
-                       mark = gtk_text_buffer_get_insert (buffer);
-                       gtk_text_view_scroll_mark_onscreen(textview, mark);
+                       gtk_text_buffer_insert(buffer, &iter, utf8_text, -1);
+                       if (bottom)
+                       {
+                               gtk_text_buffer_get_end_iter(buffer, &iter);
+                               mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
+                               gtk_text_view_scroll_mark_onscreen(textview, mark);
+                               gtk_text_buffer_delete_mark(buffer, mark);
+                       }
+#if defined(_WIN32)
+                       gsize one = 1;
+                       utf8_text[length-1] = '\r';
+#endif
+                       g_io_channel_write_chars (ud->activity_log, utf8_text, 
+                                                                       length, &outlength, NULL);
+#if defined(_WIN32)
+                       g_io_channel_write_chars (ud->activity_log, "\n", 
+                                                                       one, &one, NULL);
+#endif
+                       g_io_channel_flush(ud->activity_log, NULL);
+                       if (ud->job_activity_log)
+                       {
+                               g_io_channel_write_chars (ud->job_activity_log, utf8_text, 
+                                                                               length, &outlength, NULL);
+#if defined(_WIN32)
+                               g_io_channel_write_chars (ud->activity_log, "\n", 
+                                                                               one, &outlength, NULL);
+#endif
+                               g_io_channel_flush(ud->job_activity_log, NULL);
+                       }
+                       g_free(utf8_text);
                }
-               g_io_channel_write_chars (ud->activity_log, text, 
-                                                               length, &length, NULL);
-               if (ud->job_activity_log)
-                       g_io_channel_write_chars (ud->job_activity_log, text, 
-                                                                       length, &length, NULL);
-               g_free(text);
        }
+       if (text != NULL)
+               g_free(text);
+
        if (status != G_IO_STATUS_NORMAL)
        {
                // This should never happen, but if it does I would get into an
@@ -1985,11 +2814,43 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
        return TRUE;
 }
 
-void
+static void
+set_visible(GtkWidget *widget, gboolean visible)
+{
+       if (visible)
+       {
+               gtk_widget_show_now(widget);
+       }
+       else
+       {
+               gtk_widget_hide(widget);
+       }
+}
+
+G_MODULE_EXPORT void
 show_activity_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkWidget *widget = GHB_WIDGET (ud->builder, "activity_window");
-       gtk_widget_show (widget);
+       set_visible(widget, gtk_toggle_tool_button_get_active(
+                                               GTK_TOGGLE_TOOL_BUTTON(xwidget)));
+}
+
+G_MODULE_EXPORT void
+show_activity_menu_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *widget = GHB_WIDGET (ud->builder, "activity_window");
+       set_visible(widget, TRUE);
+       widget = GHB_WIDGET (ud->builder, "show_activity");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), TRUE);
+}
+
+G_MODULE_EXPORT gboolean
+activity_window_delete_cb(GtkWidget *xwidget, GdkEvent *event, signal_user_data_t *ud)
+{
+       set_visible(xwidget, FALSE);
+       GtkWidget *widget = GHB_WIDGET (ud->builder, "show_activity");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), FALSE);
+       return TRUE;
 }
 
 void
@@ -2002,21 +2863,13 @@ ghb_log(gchar *log, ...)
 
        _now = time(NULL);
        now = localtime( &_now );
-       snprintf(fmt, 362, "[%02d:%02d:%02d] lingui: %s\n", 
+       snprintf(fmt, 362, "[%02d:%02d:%02d] gtkgui: %s\n", 
                        now->tm_hour, now->tm_min, now->tm_sec, log);
        va_start(args, log);
        vfprintf(stderr, fmt, args);
        va_end(args);
 }
 
-void
-about_activate_cb(GtkWidget *xwidget, signal_user_data_t *ud)
-{
-       GtkWidget *widget = GHB_WIDGET (ud->builder, "hb_about");
-       gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), ghb_version());
-       gtk_widget_show (widget);
-}
-
 static void
 browse_url(const gchar *url)
 {
@@ -2048,33 +2901,76 @@ browse_url(const gchar *url)
 }
 
 void
+about_web_hook(GtkAboutDialog *about, const gchar *link, gpointer data)
+{
+       browse_url(link);
+}
+
+G_MODULE_EXPORT void
+about_activate_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *widget = GHB_WIDGET (ud->builder, "hb_about");
+       gchar *ver;
+
+       ver = g_strdup_printf("%s (%s)", HB_PROJECT_VERSION, HB_PROJECT_BUILD_ARCH);
+       gtk_about_dialog_set_url_hook(about_web_hook, NULL, NULL);
+       gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), ver);
+       g_free(ver);
+       gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), 
+                                                               HB_PROJECT_URL_WEBSITE);
+       gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(widget), 
+                                                                               HB_PROJECT_URL_WEBSITE);
+       gtk_widget_show (widget);
+}
+
+G_MODULE_EXPORT void
 guide_activate_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        browse_url("http://trac.handbrake.fr/wiki/HandBrakeGuide");
 }
 
-void
+G_MODULE_EXPORT void
 hb_about_response_cb(GtkWidget *widget, gint response, signal_user_data_t *ud)
 {
        gtk_widget_hide (widget);
 }
 
-void
+G_MODULE_EXPORT void
 show_queue_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_window");
-       gtk_widget_show (widget);
+       set_visible(widget, gtk_toggle_tool_button_get_active(
+                                               GTK_TOGGLE_TOOL_BUTTON(xwidget)));
 }
 
-void
-show_presets_toggled_cb(GtkToggleButton *button, signal_user_data_t *ud)
+G_MODULE_EXPORT void
+show_queue_menu_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_window");
+       set_visible(widget, TRUE);
+       widget = GHB_WIDGET (ud->builder, "show_queue");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), TRUE);
+}
+
+G_MODULE_EXPORT gboolean
+queue_window_delete_cb(GtkWidget *xwidget, GdkEvent *event, signal_user_data_t *ud)
+{
+       set_visible(xwidget, FALSE);
+       GtkWidget *widget = GHB_WIDGET (ud->builder, "show_queue");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), FALSE);
+       return TRUE;
+}
+
+G_MODULE_EXPORT void
+show_presets_toggled_cb(GtkWidget *action, signal_user_data_t *ud)
 {
        GtkWidget *widget;
        GtkWindow *hb_window;
        
        g_debug("show_presets_clicked_cb ()");
        widget = GHB_WIDGET (ud->builder, "presets_frame");
-       if (gtk_toggle_button_get_active(button))
+       ghb_widget_to_setting(ud->settings, action);
+       if (ghb_settings_get_boolean(ud->settings, "show_presets"))
        {
                gtk_widget_show_now(widget);
        }
@@ -2084,11 +2980,87 @@ show_presets_toggled_cb(GtkToggleButton *button, signal_user_data_t *ud)
                hb_window = GTK_WINDOW(GHB_WIDGET (ud->builder, "hb_window"));
                gtk_window_resize(hb_window, 16, 16);
        }
-       ghb_widget_to_setting(ud->settings, GTK_WIDGET(button));
        ghb_pref_save(ud->settings, "show_presets");
 }
 
 static void
+reset_chapter_list(signal_user_data_t *ud, GValue *settings)
+{
+       GtkTreeView *treeview;
+       GtkTreeIter iter;
+       GtkListStore *store;
+       gboolean done;
+       GValue *chapters;
+       gint titleindex, ii;
+       gint count;
+       
+       g_debug("reset_chapter_list ()");
+       chapters = ghb_value_dup(ghb_settings_get_value(settings, "chapter_list"));
+       count = ghb_array_len(chapters);
+       ghb_settings_set_value(ud->settings, "chapter_list", chapters);
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "chapters_list"));
+       store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+       ii = 0;
+       if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
+       {
+               do
+               {
+
+                       if (ii < count)
+                       {
+                               gchar *chapter, *duration;
+                               gint hh, mm, ss;
+
+                               // Update row with settings data
+                               g_debug("Updating row");
+                               chapter = ghb_value_string(ghb_array_get_nth(chapters, ii));
+                               ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss);
+                               duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss);
+                               gtk_list_store_set(store, &iter, 
+                                       0, ii+1,
+                                       1, duration,
+                                       2, chapter,
+                                       3, TRUE,
+                                       -1);
+                               g_free(chapter);
+                               g_free(duration);
+                               ii++;
+                               done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
+                       }
+                       else
+                       {
+                               // No more settings data, remove row
+                               g_debug("Removing row");
+                               done = !gtk_list_store_remove(store, &iter);
+                       }
+               } while (!done);
+       }
+       while (ii < count)
+       {
+               gchar *chapter, *duration;
+               gint hh, mm, ss;
+
+               // Additional settings, add row
+               g_debug("Adding row");
+               chapter = ghb_value_string(ghb_array_get_nth(chapters, ii));
+               ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss);
+               duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss);
+               gtk_list_store_append(store, &iter);
+               gtk_list_store_set(store, &iter, 
+                       0, ii+1,
+                       1, duration,
+                       2, chapter,
+                       3, TRUE,
+                       -1);
+               g_free(chapter);
+               g_free(duration);
+               ii++;
+       }
+}
+
+static void
 update_chapter_list(signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
@@ -2116,17 +3088,22 @@ update_chapter_list(signal_user_data_t *ud)
 
                        if (ii < count)
                        {
-                               gchar *chapter;
+                               gchar *chapter, *duration;
+                               gint hh, mm, ss;
 
                                // Update row with settings data
                                g_debug("Updating row");
                                chapter = ghb_value_string(ghb_array_get_nth(chapters, ii));
+                               ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss);
+                               duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss);
                                gtk_list_store_set(store, &iter, 
                                        0, ii+1,
-                                       1, chapter,
-                                       2, TRUE,
+                                       1, duration,
+                                       2, chapter,
+                                       3, TRUE,
                                        -1);
                                g_free(chapter);
+                               g_free(duration);
                                ii++;
                                done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
                        }
@@ -2140,25 +3117,30 @@ update_chapter_list(signal_user_data_t *ud)
        }
        while (ii < count)
        {
-               gchar *chapter;
+               gchar *chapter, *duration;
+               gint hh, mm, ss;
 
                // Additional settings, add row
                g_debug("Adding row");
                chapter = ghb_value_string(ghb_array_get_nth(chapters, ii));
+               ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss);
+               duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss);
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
                        0, ii+1,
-                       1, chapter,
-                       2, TRUE,
+                       1, duration,
+                       2, chapter,
+                       3, TRUE,
                        -1);
                g_free(chapter);
+               g_free(duration);
                ii++;
        }
 }
 
 static gint chapter_edit_key = 0;
 
-gboolean
+G_MODULE_EXPORT gboolean
 chapter_keypress_cb(
        GhbCellRendererText *cell,
        GdkEventKey *event,
@@ -2168,7 +3150,7 @@ chapter_keypress_cb(
        return FALSE;
 }
 
-void
+G_MODULE_EXPORT void
 chapter_edited_cb(
        GhbCellRendererText *cell, 
        gchar *path, 
@@ -2193,12 +3175,12 @@ chapter_edited_cb(
        row = pi[0];
        gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath);
        gtk_list_store_set(store, &iter, 
-               1, text,
-               2, TRUE,
+               2, text,
+               3, TRUE,
                -1);
        gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &index, -1);
 
-       GValue *chapters;
+       const GValue *chapters;
        GValue *chapter;
 
        chapters = ghb_settings_get_value(ud->settings, "chapter_list");
@@ -2234,63 +3216,20 @@ chapter_edited_cb(
                // I got industrious and made my own CellTextRendererText that
                // passes on the key-press-event. So now I have much better
                // control of this.
-               column = gtk_tree_view_get_column(treeview, 1);
+               column = gtk_tree_view_get_column(treeview, 2);
                gtk_tree_view_set_cursor(treeview, treepath, column, TRUE);
        }
        else if (chapter_edit_key == GDK_Up && row > 0)
        {
                GtkTreeViewColumn *column;
                gtk_tree_path_prev(treepath);
-               column = gtk_tree_view_get_column(treeview, 1);
+               column = gtk_tree_view_get_column(treeview, 2);
                gtk_tree_view_set_cursor(treeview, treepath, column, TRUE);
        }
        gtk_tree_path_free (treepath);
 }
 
 void
-chapter_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
-{
-       g_debug("chapter_list_selection_changed_cb ()");
-       //chapter_selection_changed = TRUE;
-}
-
-void
-preview_button_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
-{
-       gint titleindex;
-
-       titleindex = ghb_settings_combo_int(ud->settings, "title");
-       if (titleindex < 0) return;
-       g_debug("titleindex %d", titleindex);
-
-       GtkWidget *widget = GHB_WIDGET (ud->builder, "preview_window");
-       gtk_widget_show (widget);
-}
-
-void
-preview_frame_value_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
-{
-       set_preview_image(ud);
-}
-
-void
-preview_button_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, signal_user_data_t *ud)
-{
-       g_debug("-------------------------------allocate %d x %d", allocation->width, allocation->height);
-       if (preview_button_width == allocation->width &&
-               preview_button_height == allocation->height)
-       {
-               // Nothing to do. Bug out.
-               g_debug("nothing to do");
-               return;
-       }
-       g_debug("-------------------------------prev allocate %d x %d", preview_button_width, preview_button_height);
-       preview_button_width = allocation->width;
-       preview_button_height = allocation->height;
-       set_preview_image(ud);
-}
-
-void
 debug_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer data)
 {
        signal_user_data_t *ud = (signal_user_data_t*)data;
@@ -2301,17 +3240,10 @@ debug_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, g
        }
 }
 
-static void
-set_visible(GtkWidget *widget, gboolean visible)
+void
+warn_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer data)
 {
-       if (visible)
-       {
-               gtk_widget_show_now(widget);
-       }
-       else
-       {
-               gtk_widget_hide(widget);
-       }
+       printf("%s: %s\n", domain, msg);
 }
 
 void
@@ -2338,14 +3270,12 @@ ghb_hbfd(signal_user_data_t *ud, gboolean hbfd)
        set_visible(widget, !hbfd);
        widget = GHB_WIDGET(ud->builder, "presets_remove");
        set_visible(widget, !hbfd);
-       widget = GHB_WIDGET(ud->builder, "presets_default");
-       set_visible(widget, !hbfd);
        widget = GHB_WIDGET (ud->builder, "hb_window");
        gtk_window_resize(GTK_WINDOW(widget), 16, 16);
 
 }
 
-void
+G_MODULE_EXPORT void
 hbfd_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("hbfd_toggled_cb");
@@ -2355,245 +3285,938 @@ hbfd_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
        ghb_pref_save(ud->settings, "hbfd");
 }
 
-void
+G_MODULE_EXPORT void
 pref_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("pref_changed_cb");
        ghb_widget_to_setting (ud->settings, widget);
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        const gchar *name = gtk_widget_get_name(widget);
        ghb_pref_save(ud->settings, name);
 }
 
-void
+G_MODULE_EXPORT void
+use_m4v_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("use_m4v_changed_cb");
+       ghb_widget_to_setting (ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+       ghb_update_destination_extension(ud);
+}
+
+G_MODULE_EXPORT void
+show_status_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("show_status_cb");
+       ghb_widget_to_setting (ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+
+       GtkStatusIcon *si;
+
+       si = GTK_STATUS_ICON(GHB_OBJECT (ud->builder, "hb_status"));
+       gtk_status_icon_set_visible(si,
+                       ghb_settings_get_boolean(ud->settings, "show_status"));
+}
+
+G_MODULE_EXPORT void
+vqual_granularity_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("vqual_granularity_changed_cb");
+       ghb_widget_to_setting (ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+
+       gdouble vqmin, vqmax, step, page;
+       gboolean inverted;
+       gint digits;
+
+       ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted);
+       GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider");
+       gtk_range_set_increments (GTK_RANGE(qp), step, page);
+}
+
+G_MODULE_EXPORT void
 tweaks_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("tweaks_changed_cb");
        ghb_widget_to_setting (ud->settings, widget);
        const gchar *name = gtk_widget_get_name(widget);
        ghb_pref_save(ud->settings, name);
+}
+
+G_MODULE_EXPORT void
+hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("hbfd_feature_changed_cb");
+       ghb_widget_to_setting (ud->settings, widget);
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+
+       gboolean hbfd = ghb_settings_get_boolean(ud->settings, "hbfd_feature");
+       GtkAction *action;
+       if (hbfd)
+       {
+               const GValue *val;
+               val = ghb_settings_get_value(ud->settings, "hbfd");
+               ghb_ui_update(ud, "hbfd", val);
+       }
+       action = GHB_ACTION (ud->builder, "hbfd");
+       gtk_action_set_visible(action, hbfd);
+}
+
+gboolean
+ghb_file_menu_add_dvd(signal_user_data_t *ud)
+{
+       GList *link, *drives;
+       static GtkActionGroup *agroup = NULL;
+       static gint merge_id;
+
+       g_debug("ghb_file_menu_add_dvd()");
+       link = drives = dvd_device_list();
+       if (drives != NULL)
+       {
+               GtkUIManager *ui = GTK_UI_MANAGER(
+                       gtk_builder_get_object(ud->builder, "uimanager1"));
+
+               if (agroup == NULL)
+               {
+                       agroup = gtk_action_group_new("dvdgroup");
+                       gtk_ui_manager_insert_action_group(ui, agroup, 0);
+               }
+               else
+                       gtk_ui_manager_remove_ui(ui, merge_id);
+
+               merge_id = gtk_ui_manager_new_merge_id(ui);
+               // Add separator
+               gtk_ui_manager_add_ui(ui, merge_id, 
+                       "ui/menubar1/menuitem1/quit1", "dvdsep", NULL,
+                       GTK_UI_MANAGER_SEPARATOR, TRUE);
+
+               while (link != NULL)
+               {
+                       GtkAction *action;
+                       gchar *drive = get_dvd_device_name(link->data);
+                       gchar *name = get_dvd_volume_name(link->data);
+               
+                       action = gtk_action_group_get_action(agroup, drive);
+                       if (action != NULL)
+                       {
+                               gtk_action_group_remove_action(agroup, action);
+                               g_object_unref(G_OBJECT(action));
+                       }
+                       // Create action for this drive
+                       action = gtk_action_new(drive, name,
+                               "Scan this DVD source", "gtk-cdrom");
+                       // Add action to action group
+                       gtk_action_group_add_action_with_accel(agroup, action, NULL);
+                       // Add to ui manager
+                       gtk_ui_manager_add_ui(ui, merge_id, 
+                               "ui/menubar1/menuitem1/dvdsep", drive, drive,
+                               GTK_UI_MANAGER_AUTO, TRUE);
+                       // Connect signal to action (menu item)
+                       g_signal_connect(action, "activate", 
+                               (GCallback)dvd_source_activate_cb, ud);
+                       g_free(name);
+                       g_free(drive);
+                       free_drive(link->data);
+                       link = link->next;
+               }
+               g_list_free(drives);
+       }
+       return FALSE;
+}
+
+gboolean ghb_is_cd(GDrive *gd);
+
+static GList*
+dvd_device_list()
+{
+       GList *dvd_devices = NULL;
+
+#if defined(_WIN32)
+       gint ii, drives;
+       gchar drive[5];
+
+       strcpy(drive, "A:" G_DIR_SEPARATOR_S);
+       drives = GetLogicalDrives();
+       for (ii = 0; ii < 26; ii++)
+       {
+               if (drives & 0x01)
+               {
+                       guint dtype;
+
+                       drive[0] = 'A' + ii;
+                       dtype = GetDriveType(drive);
+                       if (dtype == DRIVE_CDROM)
+                       {
+                               dvd_devices = g_list_append(dvd_devices, 
+                                               (gpointer)g_strdup(drive));
+                       }
+               }
+               drives >>= 1;
+       }
+#else
+       GVolumeMonitor *gvm;
+       GList *drives, *link;
+       
+       gvm = g_volume_monitor_get ();
+       drives = g_volume_monitor_get_connected_drives (gvm);
+       link = drives;
+       while (link != NULL)
+       {
+               GDrive *gd;
+               
+               gd = (GDrive*)link->data;
+               if (ghb_is_cd(gd))
+               {
+                       dvd_devices = g_list_append(dvd_devices, gd);
+               }
+               else
+                       g_object_unref (gd);
+               link = link->next;
+       }
+       g_list_free(drives);
+#endif
+
+       return dvd_devices;
+}
+
+#if !defined(_WIN32)
+static LibHalContext *hal_ctx = NULL;
+#endif
+
+gboolean
+ghb_is_cd(GDrive *gd)
+{
+#if !defined(_WIN32)
+       gchar *device;
+       LibHalDrive *halDrive;
+       LibHalDriveType dtype;
+
+       if (hal_ctx == NULL)
+               return FALSE;
+
+       device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+       if (device == NULL)
+               return FALSE;
+       halDrive = libhal_drive_from_device_file (hal_ctx, device);
+       g_free(device);
+       if (halDrive == NULL)
+               return FALSE;
+       dtype = libhal_drive_get_type(halDrive);
+       libhal_drive_free(halDrive);
+       return (dtype == LIBHAL_DRIVE_TYPE_CDROM);
+#else
+       return FALSE;
+#endif
+}
+
+#if defined(_WIN32)
+static void
+handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud)
+{
+       guint dtype;
+       static gint ins_count = 0;
+       static gint rem_count = 0;
+
+       // The media change event in windows bounces around a bit
+       // so I debounce it here
+       // DVD insertion detected.  Scan it.
+       dtype = GetDriveType(device);
+       if (dtype != DRIVE_CDROM)
+               return;
+       if (insert)
+       {
+               rem_count = 0;
+               ins_count++;
+               if (ins_count == 2)
+               {
+                       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
+                       if (ghb_settings_get_boolean(ud->settings, "AutoScan") &&
+                               ud->current_dvd_device != NULL &&
+                               strcmp(device, ud->current_dvd_device) == 0)
+                       {
+                               show_scan_progress(ud);
+                               update_source_label(ud, device, TRUE);
+                               gint preview_count;
+                               preview_count = ghb_settings_get_int(ud->settings, "preview_count");
+                               ghb_settings_set_string(ud->settings, "source", device);
+                               start_scan(ud, device, 0, preview_count);
+                       }
+               }
+       }
+       else
+       {
+               ins_count = 0;
+               rem_count++;
+               if (rem_count == 2)
+               {
+                       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
+                       if (ud->current_dvd_device != NULL &&
+                               strcmp(device, ud->current_dvd_device) == 0)
+                       {
+                               ghb_hb_cleanup(TRUE);
+                               prune_logs(ud);
+                               ghb_settings_set_string(ud->settings, "source", "/dev/null");
+                               start_scan(ud, "/dev/null", 0, 1);
+                       }
+               }
+       }
+}
+
+static gchar
+FindDriveFromMask(ULONG unitmask)
+{
+       gchar cc;
+       for (cc = 0; cc < 26; cc++)
+       {
+               if (unitmask & 0x01)
+                       return 'A' + cc;
+               unitmask >>= 1;
+       }
+       return 0;
+}
+
+void
+wm_drive_changed(MSG *msg, signal_user_data_t *ud)
+{
+       PDEV_BROADCAST_HDR bch = (PDEV_BROADCAST_HDR)msg->lParam;
+       gchar drive[4];
+
+       g_strlcpy(drive, "A:" G_DIR_SEPARATOR_S, 4);
+       switch (msg->wParam)
+       {
+               case DBT_DEVICEARRIVAL:
+               {
+                       if (bch->dbch_devicetype == DBT_DEVTYP_VOLUME)
+                       {
+                               PDEV_BROADCAST_VOLUME bcv = (PDEV_BROADCAST_VOLUME)bch;
+
+                               if (bcv->dbcv_flags & DBTF_MEDIA)
+                               {
+                                       drive[0] = FindDriveFromMask(bcv->dbcv_unitmask);
+                                       handle_media_change(drive, TRUE, ud);
+                               }
+                       }
+               } break;
+
+               case DBT_DEVICEREMOVECOMPLETE:
+               {
+                       if (bch->dbch_devicetype == DBT_DEVTYP_VOLUME)
+                       {
+                               PDEV_BROADCAST_VOLUME bcv = (PDEV_BROADCAST_VOLUME)bch;
+
+                               if (bcv->dbcv_flags & DBTF_MEDIA)
+                               {
+                                       drive[0] = FindDriveFromMask(bcv->dbcv_unitmask);
+                                       handle_media_change(drive, FALSE, ud);
+                               }
+                       }
+               } break;
+               default: ;
+       }
+}
+
+#else
+
+G_MODULE_EXPORT void
+drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud)
+{
+       gchar *device;
+       gint state;
+
+       g_debug("drive_changed_cb()");
+       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
+
+       state = ghb_get_scan_state();
+       device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+       if (ud->current_dvd_device == NULL ||
+               strcmp(device, ud->current_dvd_device) != 0 ||
+               state != GHB_STATE_IDLE )
+       {
+               return;
+       }
+       if (g_drive_has_media(gd))
+       {
+               if (ghb_settings_get_boolean(ud->settings, "AutoScan"))
+               {
+                       show_scan_progress(ud);
+                       update_source_label(ud, device, TRUE);
+                       gint preview_count;
+                       preview_count = ghb_settings_get_int(ud->settings, "preview_count");
+                       ghb_settings_set_string(ud->settings, "source", device);
+                       start_scan(ud, device, 0, preview_count);
+               }
+       }
+       else
+       {
+               ghb_hb_cleanup(TRUE);
+               prune_logs(ud);
+               ghb_settings_set_string(ud->settings, "source", "/dev/null");
+               start_scan(ud, "/dev/null", 0, 1);
+       }
+}
+#endif
+
+#if !defined(_WIN32)
+static void
+dbus_init (void)
+{
+       dbus_g_thread_init();
+}
+
+#define GPM_DBUS_PM_SERVICE                    "org.freedesktop.PowerManagement"
+#define GPM_DBUS_PM_PATH                       "/org/freedesktop/PowerManagement"
+#define GPM_DBUS_PM_INTERFACE          "org.freedesktop.PowerManagement"
+#define GPM_DBUS_INHIBIT_PATH          "/org/freedesktop/PowerManagement/Inhibit"
+#define GPM_DBUS_INHIBIT_INTERFACE     "org.freedesktop.PowerManagement.Inhibit" 
+static gboolean gpm_inhibited = FALSE;
+static guint gpm_cookie = -1;
+#endif
+
+static gboolean
+ghb_can_suspend_gpm()
+{
+       gboolean can_suspend = FALSE;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
+
+       g_debug("ghb_can_suspend_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return FALSE;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_PM_PATH, GPM_DBUS_PM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return FALSE;
+       }
+       res = dbus_g_proxy_call(proxy, "CanSuspend", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_BOOLEAN, &can_suspend,
+                                                       G_TYPE_INVALID);
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_warning("CanSuspend failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("CanSuspend failed");
+               // Try to shutdown anyway
+               can_suspend = TRUE;
+       }
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+#endif
+       return can_suspend;
+}
+
+static void
+ghb_suspend_gpm()
+{
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
+
+       g_debug("ghb_suspend_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_PM_PATH, GPM_DBUS_PM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "Suspend", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_INVALID);
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_warning("Suspend failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("Suspend failed");
+       }
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+#endif
+}
+
+static gboolean
+ghb_can_shutdown_gpm()
+{
+       gboolean can_shutdown = FALSE;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
+
+       g_debug("ghb_can_shutdown_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return FALSE;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_PM_PATH, GPM_DBUS_PM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return FALSE;
+       }
+       res = dbus_g_proxy_call(proxy, "CanShutdown", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_BOOLEAN, &can_shutdown,
+                                                       G_TYPE_INVALID);
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_warning("CanShutdown failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("CanShutdown failed");
+               // Try to shutdown anyway
+               can_shutdown = TRUE;
+       }
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+#endif
+       return can_shutdown;
+}
 
-       gboolean tweaks = ghb_settings_get_boolean(ud->settings, "allow_tweaks");
-       widget = GHB_WIDGET(ud->builder, "PictureDeinterlace");
-       tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-       widget = GHB_WIDGET(ud->builder, "tweak_PictureDeinterlace");
-       !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
+static void
+ghb_shutdown_gpm()
+{
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
 
-       widget = GHB_WIDGET(ud->builder, "PictureDenoise");
-       tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-       widget = GHB_WIDGET(ud->builder, "tweak_PictureDenoise");
-       !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-       if (tweaks)
+       g_debug("ghb_shutdown_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
        {
-               const GValue *value;
-               value = ghb_settings_get_value(ud->settings, "PictureDeinterlace");
-               ghb_ui_update(ud, "tweak_PictureDeinterlace", value);
-               value = ghb_settings_get_value(ud->settings, "PictureDenoise");
-               ghb_ui_update(ud, "tweak_PictureDenoise", value);
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
        }
-       else
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_PM_PATH, GPM_DBUS_PM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "Shutdown", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_INVALID);
+       if (!res)
        {
-               const GValue *value;
-               value = ghb_settings_get_value(ud->settings, "tweak_PictureDeinterlace");
-               ghb_ui_update(ud, "PictureDeinterlace", value);
-               value = ghb_settings_get_value(ud->settings, "tweak_PictureDenoise");
-               ghb_ui_update(ud, "PictureDenoise", value);
+               if (error != NULL)
+               {
+                       g_warning("Shutdown failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("Shutdown failed");
        }
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+#endif
 }
 
 void
-hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+ghb_inhibit_gpm()
 {
-       g_debug("hbfd_feature_changed_cb");
-       ghb_widget_to_setting (ud->settings, widget);
-       const gchar *name = gtk_widget_get_name(widget);
-       ghb_pref_save(ud->settings, name);
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
 
-       gboolean hbfd = ghb_settings_get_boolean(ud->settings, "hbfd_feature");
-       GtkAction *action;
-       if (hbfd)
+       if (gpm_inhibited)
        {
-               const GValue *val;
-               val = ghb_settings_get_value(ud->settings, "hbfd");
-               ghb_ui_update(ud, "hbfd", val);
+               // Already inhibited
+               return;
        }
-       action = GHB_ACTION (ud->builder, "hbfd");
-       gtk_action_set_visible(action, hbfd);
+       g_debug("ghb_inhibit_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_INHIBIT_PATH, GPM_DBUS_INHIBIT_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "Inhibit", &error,
+                                                       G_TYPE_STRING, "ghb",
+                                                       G_TYPE_STRING, "Encoding",
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_UINT, &gpm_cookie,
+                                                       G_TYPE_INVALID);
+       gpm_inhibited = TRUE;
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_warning("Inhibit failed: %s", error->message);
+                       g_error_free(error);
+                       gpm_cookie = -1;
+               }
+               else
+                       g_warning("Inhibit failed");
+               gpm_cookie = -1;
+               gpm_inhibited = FALSE;
+       }
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+#endif
 }
 
 void
-ghb_file_menu_add_dvd(signal_user_data_t *ud)
+ghb_uninhibit_gpm()
 {
-       GList *link, *drives;
-
-       GtkActionGroup *agroup = GTK_ACTION_GROUP(
-               gtk_builder_get_object(ud->builder, "actiongroup1"));
-       GtkUIManager *ui = GTK_UI_MANAGER(
-               gtk_builder_get_object(ud->builder, "uimanager1"));
-       guint merge_id = gtk_ui_manager_new_merge_id(ui);
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
+       g_debug("ghb_uninhibit_gpm() gpm_cookie %u", gpm_cookie);
 
-       link = drives = dvd_device_list();
-       while (link != NULL)
+       if (!gpm_inhibited)
        {
-               gchar *name = (gchar*)link->data;
-               // Create action for this drive
-               GtkAction *action = gtk_action_new(name, name,
-                       "Scan this DVD source", "gtk-cdrom");
-               // Add action to action group
-               gtk_action_group_add_action_with_accel(agroup, action, "");
-               // Add to ui manager
-               gtk_ui_manager_add_ui(ui, merge_id, 
-                       "ui/menubar1/menuitem1/quit1", name, name,
-                       GTK_UI_MANAGER_AUTO, TRUE);
-               // Connect signal to action (menu item)
-               g_signal_connect(action, "activate", 
-                       (GCallback)dvd_source_activate_cb, ud);
-               g_free(name);
-               link = link->next;
+               // Not inhibited
+               return;
        }
-       g_list_free(drives);
-
-       // Add separator
-       gtk_ui_manager_add_ui(ui, merge_id, 
-               "ui/menubar1/menuitem1/quit1", "", NULL,
-               GTK_UI_MANAGER_AUTO, TRUE);
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_PM_SERVICE,
+                                                       GPM_DBUS_INHIBIT_PATH, GPM_DBUS_INHIBIT_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_PM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "UnInhibit", &error,
+                                                       G_TYPE_UINT, gpm_cookie,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_INVALID);
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_warning("UnInhibit failed: %s", error->message);
+                       g_error_free(error);
+               }
+               else
+                       g_warning("UnInhibit failed");
+       }
+       gpm_inhibited = FALSE;
+       dbus_g_connection_unref(conn);
+       g_object_unref(G_OBJECT(proxy));
+#endif
 }
 
-gboolean ghb_is_cd(GDrive *gd);
+#if !defined(_WIN32)
 
-static GList*
-dvd_device_list()
+// For inhibit and shutdown
+#define GPM_DBUS_SM_SERVICE                    "org.gnome.SessionManager"
+#define GPM_DBUS_SM_PATH                       "/org/gnome/SessionManager"
+#define GPM_DBUS_SM_INTERFACE          "org.gnome.SessionManager"
+
+#endif
+
+static gboolean
+ghb_can_shutdown_gsm()
 {
-       GVolumeMonitor *gvm;
-       GList *drives, *link;
-       GList *dvd_devices = NULL;
+       gboolean can_shutdown = FALSE;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
        
-       gvm = g_volume_monitor_get ();
-       drives = g_volume_monitor_get_connected_drives (gvm);
-       link = drives;
-       while (link != NULL)
+
+       g_debug("ghb_can_shutdown_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
        {
-               GDrive *gd;
-               
-               gd = (GDrive*)link->data;
-               if (ghb_is_cd(gd))
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return FALSE;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_SM_SERVICE,
+                                                       GPM_DBUS_SM_PATH, GPM_DBUS_SM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return FALSE;
+       }
+       res = dbus_g_proxy_call(proxy, "CanShutdown", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_BOOLEAN, &can_shutdown,
+                                                       G_TYPE_INVALID);
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+       if (!res)
+       {
+               if (error != NULL)
                {
-                       gchar *device;
-                       device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
-                       dvd_devices = g_list_append(dvd_devices, (gpointer)device);
+                       g_error_free(error);
                }
-               g_object_unref (gd);
-               link = link->next;
+               // Try to shutdown anyway
+               can_shutdown = TRUE;
+               // Try the gpm version
+               return ghb_can_shutdown_gpm();
        }
-       g_list_free(drives);
-       return dvd_devices;
+#endif
+       return can_shutdown;
 }
 
-
-static DBusConnection *dbus_connection = NULL;
-static LibHalContext *hal_ctx;
-
-gboolean
-ghb_is_cd(GDrive *gd)
+static void
+ghb_shutdown_gsm()
 {
-       gchar *device;
-       LibHalDrive *halDrive;
-       LibHalDriveType dtype;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
 
-       device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
-       halDrive = libhal_drive_from_device_file (hal_ctx, device);
-       dtype = libhal_drive_get_type(halDrive);
-       libhal_drive_free(halDrive);
-       g_free(device);
-       return (dtype == LIBHAL_DRIVE_TYPE_CDROM);
+       g_debug("ghb_shutdown_gpm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_SM_SERVICE,
+                                                       GPM_DBUS_SM_PATH, GPM_DBUS_SM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "Shutdown", &error,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_INVALID);
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_error_free(error);
+               }
+               // Try the gpm version
+               ghb_shutdown_gpm();
+       }
+#endif
 }
 
 void
-drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud)
+ghb_inhibit_gsm(signal_user_data_t *ud)
 {
-       gchar *device;
-       gint state = ghb_get_state();
-       static gboolean first_time = TRUE;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       guint xid;
+       GtkWidget *widget;
+       
 
-       if (ud->current_dvd_device == NULL) return;
-       // A drive change event happens when the program initially starts
-       // and I don't want to automatically scan at that time.
-       if (first_time)
+       if (gpm_inhibited)
        {
-               first_time = FALSE;
+               // Already inhibited
                return;
        }
-       if (state != GHB_STATE_IDLE) return;
-       device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
-       
-       // DVD insertion detected.  Scan it.
-       if (strcmp(device, ud->current_dvd_device) == 0)
+       g_debug("ghb_inhibit_gsm()");
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
        {
-               if (g_drive_has_media (gd))
-               {
-                       GtkProgressBar *progress;
-                       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
-                       gtk_progress_bar_set_text (progress, "Scanning ...");
-                       gtk_progress_bar_set_fraction (progress, 0);
-                       update_source_label(ud, device);
-                       ghb_hb_cleanup(TRUE);
-                       prune_logs(ud);
-                       ghb_backend_scan(device, 0);
-               }
-               else
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_SM_SERVICE,
+                                                       GPM_DBUS_SM_PATH, GPM_DBUS_SM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       widget = GHB_WIDGET(ud->builder, "hb_window");
+       xid = GDK_DRAWABLE_XID(widget->window);
+       res = dbus_g_proxy_call(proxy, "Inhibit", &error,
+                                                       G_TYPE_STRING, "ghb",
+                                                       G_TYPE_UINT, xid,
+                                                       G_TYPE_STRING, "Encoding",
+                                                       G_TYPE_UINT, 1 | 4,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_UINT, &gpm_cookie,
+                                                       G_TYPE_INVALID);
+       gpm_inhibited = TRUE;
+       g_object_unref(G_OBJECT(proxy));
+       dbus_g_connection_unref(conn);
+       if (!res)
+       {
+               if (error != NULL)
                {
-                       ghb_hb_cleanup(TRUE);
-                       prune_logs(ud);
-                       ghb_backend_scan("/dev/null", 0);
+                       g_error_free(error);
+                       gpm_cookie = -1;
                }
+               gpm_cookie = -1;
+               gpm_inhibited = FALSE;
+               // Try the gpm version
+               ghb_inhibit_gpm();
        }
-       g_free(device);
+#endif
 }
 
-
-static gboolean
-dbus_init (void)
+void
+ghb_uninhibit_gsm()
 {
-       DBusError error;
-
-       if (dbus_connection != NULL)
-               return TRUE;
+#if !defined(_WIN32)
+       DBusGConnection *conn;
+       DBusGProxy      *proxy;
+       GError *error = NULL;
+       gboolean res;
+       
+       g_debug("ghb_uninhibit_gsm() gpm_cookie %u", gpm_cookie);
 
-       dbus_error_init (&error);
-       if (!(dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error))) {
-               g_debug ("could not get system bus: %s", error.message);
-               dbus_error_free (&error);
-               return FALSE;
+       if (!gpm_inhibited)
+       {
+               // Not inhibited
+               return;
        }
-
-       //dbus_connection_setup_with_g_main (dbus_connection, NULL);
-       //dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
-       //dbus_connection_add_filter (dbus_connection, gvm_dbus_filter_function, NULL, NULL);
-
-       return TRUE;
+       conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+       if (error != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+       proxy = dbus_g_proxy_new_for_name(conn, GPM_DBUS_SM_SERVICE,
+                                                       GPM_DBUS_SM_PATH, GPM_DBUS_SM_INTERFACE);
+       if (proxy == NULL)
+       {
+               g_warning("Could not get DBUS proxy: %s", GPM_DBUS_SM_SERVICE);
+               dbus_g_connection_unref(conn);
+               return;
+       }
+       res = dbus_g_proxy_call(proxy, "Uninhibit", &error,
+                                                       G_TYPE_UINT, gpm_cookie,
+                                                       G_TYPE_INVALID,
+                                                       G_TYPE_INVALID);
+       dbus_g_connection_unref(conn);
+       g_object_unref(G_OBJECT(proxy));
+       if (!res)
+       {
+               if (error != NULL)
+               {
+                       g_error_free(error);
+               }
+               ghb_uninhibit_gpm();
+       }
+       gpm_inhibited = FALSE;
+#endif
 }
 
 void
 ghb_hal_init()
 {
+#if !defined(_WIN32)
+       DBusGConnection *gconn;
+       DBusConnection *conn;
+       GError *gerror = NULL;
        DBusError error;
        char **devices;
        int nr;
 
-       if (!dbus_init ())
-               return;
+       dbus_init ();
 
        if (!(hal_ctx = libhal_ctx_new ())) {
                g_warning ("failed to create a HAL context!");
                return;
        }
 
-       libhal_ctx_set_dbus_connection (hal_ctx, dbus_connection);
+       gconn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &gerror);
+       if (gerror != NULL)
+       {
+               g_warning("DBUS cannot connect: %s", gerror->message);
+               g_error_free(gerror);
+               return;
+       }
+       conn = dbus_g_connection_get_connection(gconn);
+       libhal_ctx_set_dbus_connection (hal_ctx, conn);
        dbus_error_init (&error);
        if (!libhal_ctx_init (hal_ctx, &error)) {
                g_warning ("libhal_ctx_init failed: %s", error.message ? error.message : "unknown");
                dbus_error_free (&error);
                libhal_ctx_free (hal_ctx);
+               dbus_g_connection_unref(gconn);
+               hal_ctx = NULL;
                return;
        }
 
@@ -2609,15 +4232,17 @@ ghb_hal_init()
 
                libhal_ctx_shutdown (hal_ctx, NULL);
                libhal_ctx_free (hal_ctx);
+               hal_ctx = NULL;
+               dbus_g_connection_unref(gconn);
                return;
        }
 
        libhal_free_string_array (devices);
-
-       //gvm_hal_claim_branch ("/org/freedesktop/Hal/devices/local");
+       dbus_g_connection_unref(gconn);
+#endif
 }
 
-gboolean 
+G_MODULE_EXPORT gboolean 
 tweak_setting_cb(
        GtkWidget *widget, 
        GdkEventButton *event, 
@@ -2679,7 +4304,7 @@ tweak_setting_cb(
        return ret;
 }
 
-gboolean 
+G_MODULE_EXPORT gboolean 
 easter_egg_cb(
        GtkWidget *widget, 
        GdkEventButton *event, 
@@ -2705,7 +4330,7 @@ easter_egg_cb(
        return FALSE;
 }
 
-gchar*
+G_MODULE_EXPORT gchar*
 format_deblock_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
 {
        if (val < 5.0)
@@ -2718,48 +4343,67 @@ format_deblock_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
        }
 }
 
-gchar*
-format_vquality_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
+G_MODULE_EXPORT gchar*
+format_drc_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
 {
-       if (ghb_settings_get_boolean(ud->settings, "directqp"))
+       if (val <= 0.0)
        {
-               gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
-               // Only x264 and ffmpeg currently support direct qp/crf entry
-               if (vcodec != HB_VCODEC_X264 && vcodec != HB_VCODEC_FFMPEG)
-               {
-                       val *= 100;
-                       return g_strdup_printf("%.1f", val);
-               }
-               return g_strdup_printf("%d", (gint)val);
+               return g_strdup_printf("Off");
        }
        else
        {
-               val *= 100;
                return g_strdup_printf("%.1f", val);
        }
 }
 
-static void
-html_link_cb(GtkHTML *html, const gchar *url, signal_user_data_t *ud)
+G_MODULE_EXPORT gchar*
+format_vquality_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud)
 {
-       browse_url(url);
-}
+       gdouble percent;
+
+       gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
+       switch (vcodec)
+       {
+               case HB_VCODEC_X264:
+               {
+                       percent = 100. * (51 - val) / 51.;
+                       return g_strdup_printf("RF: %.4g (%.0f%%)", val, percent);
+               } break;
+
+               case HB_VCODEC_FFMPEG:
+               {
+                       percent = 100. * (30 - (val - 1)) / 30.;
+                       return g_strdup_printf("QP: %d (%.0f%%)", (int)val, percent);
+               } break;
+
+               case HB_VCODEC_THEORA:
+               {
+                       percent = 100. * val / 63.;
+                       return g_strdup_printf("QP: %d (%.0f%%)", (int)val, percent);
+               } break;
 
-static gboolean check_stable_update(signal_user_data_t *ud);
-static gboolean stable_update_lock = FALSE;
+               default:
+               {
+                       percent = 0;
+               } break;
+       }
+       return g_strdup_printf("QP: %.1f / %.1f%%", val, percent);
+}
 
 static void
 process_appcast(signal_user_data_t *ud)
 {
        gchar *description = NULL, *build = NULL, *version = NULL, *msg;
-       GtkWidget *html, *window, *dialog, *label;
+#if !defined(_WIN32)
+       GtkWidget *window;
+       static GtkWidget *html = NULL;
+#endif
+       GtkWidget *dialog, *label;
        gint    response, ibuild = 0, skip;
 
        if (ud->appcast == NULL || ud->appcast_len < 15 || 
                strncmp(&(ud->appcast[9]), "200 OK", 6))
        {
-               if (!stable_update_lock && HB_BUILD % 100)
-                       g_idle_add((GSourceFunc)check_stable_update, ud);
                goto done;
        }
        ghb_appcast_parse(ud->appcast, &description, &build, &version);
@@ -2767,27 +4411,30 @@ process_appcast(signal_user_data_t *ud)
                ibuild = g_strtod(build, NULL);
        skip = ghb_settings_get_int(ud->settings, "update_skip_version");
        if (description == NULL || build == NULL || version == NULL 
-               || ibuild <= HB_BUILD || skip == ibuild)
+               || ibuild <= hb_get_build(NULL) || skip == ibuild)
        {
-               if (!stable_update_lock && HB_BUILD % 100)
-                       g_idle_add((GSourceFunc)check_stable_update, ud);
                goto done;
        }
        msg = g_strdup_printf("HandBrake %s/%s is now available (you have %s/%d).",
-                       version, build, HB_VERSION, HB_BUILD);
+                       version, build, hb_get_version(NULL), hb_get_build(NULL));
        label = GHB_WIDGET(ud->builder, "update_message");
        gtk_label_set_text(GTK_LABEL(label), msg);
-       html = gtk_html_new_from_string(description, -1);
-       g_signal_connect(html, "link_clicked", G_CALLBACK(html_link_cb), ud);
-       window = GHB_WIDGET(ud->builder, "update_scroll");
-       gtk_container_add(GTK_CONTAINER(window), html);
-       // Show it
+
+#if !defined(_WIN32)
+       if (html == NULL)
+       {
+               html = webkit_web_view_new();
+               window = GHB_WIDGET(ud->builder, "update_scroll");
+               gtk_container_add(GTK_CONTAINER(window), html);
+               // Show it
+               gtk_widget_set_size_request(html, 420, 240);
+               gtk_widget_show(html);
+       }
+       webkit_web_view_open(WEBKIT_WEB_VIEW(html), description);
+#endif
        dialog = GHB_WIDGET(ud->builder, "update_dialog");
-       gtk_widget_set_size_request(html, 420, 240);
-       gtk_widget_show(html);
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
-       gtk_widget_destroy(html);
        if (response == GTK_RESPONSE_OK)
        {
                // Skip
@@ -2803,6 +4450,7 @@ done:
        g_free(ud->appcast);
        ud->appcast_len = 0;
        ud->appcast = NULL;
+       appcast_busy = FALSE;
 }
 
 void
@@ -2817,7 +4465,7 @@ ghb_net_close(GIOChannel *ioc)
        g_io_channel_unref(ioc);
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 ghb_net_recv_cb(GIOChannel *ioc, GIOCondition cond, gpointer data)
 {
        gchar buf[2048];
@@ -2860,6 +4508,7 @@ ghb_net_open(signal_user_data_t *ud, gchar *address, gint port)
        if( !( host = gethostbyname( address ) ) )
        {
                g_warning( "gethostbyname failed (%s)", address );
+               appcast_busy = FALSE;
                return NULL;
        }
 
@@ -2872,12 +4521,14 @@ ghb_net_open(signal_user_data_t *ud, gchar *address, gint port)
        if( fd < 0 )
        {
                g_debug( "socket failed" );
+               appcast_busy = FALSE;
                return NULL;
        }
 
        if(connect(fd, (struct sockaddr*)&sock, sizeof(struct sockaddr_in )) < 0 )
        {
                g_debug( "connect failed" );
+               appcast_busy = FALSE;
                return NULL;
        }
        ioc = g_io_channel_unix_new(fd);
@@ -2888,55 +4539,127 @@ ghb_net_open(signal_user_data_t *ud, gchar *address, gint port)
        return ioc;
 }
 
-gboolean
+gpointer
 ghb_check_update(signal_user_data_t *ud)
 {
        gchar *query;
        gsize len;
        GIOChannel *ioc;
        GError *gerror = NULL;
+       GRegex *regex;
+       GMatchInfo *mi;
+       gchar *host, *appcast;
 
        g_debug("ghb_check_update");
-       if (HB_BUILD % 100)
-       {
-       query = 
-               "GET /appcast_unstable.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-       }
-       else
+       appcast_busy = TRUE;
+       regex = g_regex_new("^http://(.+)/(.+)$", 0, 0, NULL);
+       if (!g_regex_match(regex, HB_PROJECT_URL_APPCAST, 0, &mi))
        {
-               stable_update_lock = TRUE;
-       query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
+               return NULL;
        }
-       ioc = ghb_net_open(ud, "handbrake.fr", 80);
+
+       host = g_match_info_fetch(mi, 1);
+       appcast = g_match_info_fetch(mi, 2);
+
+       if (host == NULL || appcast == NULL)
+               return NULL;
+
+       query = g_strdup_printf( "GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
+                                                       appcast, host);
+
+       ioc = ghb_net_open(ud, host, 80);
        if (ioc == NULL)
-               return FALSE;
+               return NULL;
 
        g_io_channel_write_chars(ioc, query, strlen(query), &len, &gerror);
        g_io_channel_flush(ioc, &gerror);
-       // This function is initiated by g_idle_add.  Must return false
-       // so that it is not called again
+       g_free(query);
+       g_free(host);
+       g_free(appcast);
+       g_match_info_free(mi);
+       g_regex_unref(regex);
+       return NULL;
+}
+
+G_MODULE_EXPORT gboolean
+hb_visibility_event_cb(
+       GtkWidget *widget, 
+       GdkEventVisibility *vs, 
+       signal_user_data_t *ud)
+{
+       ud->hb_visibility = vs->state;
        return FALSE;
 }
 
-static gboolean
-check_stable_update(signal_user_data_t *ud)
+G_MODULE_EXPORT void
+status_activate_cb(GtkStatusIcon *si, signal_user_data_t *ud)
 {
-       gchar *query;
-       gsize len;
-       GIOChannel *ioc;
-       GError *gerror = NULL;
+       GtkWindow *window;
+       GdkWindowState state;
 
-       g_debug("check_stable_update");
-       stable_update_lock = TRUE;
-       query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-       ioc = ghb_net_open(ud, "handbrake.fr", 80);
-       if (ioc == NULL)
-               return FALSE;
+       window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window"));
+       state = gdk_window_get_state(GTK_WIDGET(window)->window);
+       if ((state & GDK_WINDOW_STATE_ICONIFIED) ||
+               (ud->hb_visibility != GDK_VISIBILITY_UNOBSCURED))
+       {
+               gtk_window_present(window);
+               gtk_window_set_skip_taskbar_hint(window, FALSE);
+       }
+       else
+       {
+               gtk_window_set_skip_taskbar_hint(window, TRUE);
+               gtk_window_iconify(window);
+       }
+}
 
-       g_io_channel_write_chars(ioc, query, strlen(query), &len, &gerror);
-       g_io_channel_flush(ioc, &gerror);
-       // This function is initiated by g_idle_add.  Must return false
-       // so that it is not called again
-       return FALSE;
+#if !defined(_WIN32)
+G_MODULE_EXPORT void
+notify_closed_cb(NotifyNotification *notification, signal_user_data_t *ud)
+{
+       g_object_unref(G_OBJECT(notification));
 }
+#endif
 
+void
+ghb_notify_done(signal_user_data_t *ud)
+{
+       GtkStatusIcon *si;
+
+       if (ghb_settings_combo_int(ud->settings, "WhenComplete") == 0)
+               return;
+
+       si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+
+#if !defined(_WIN32)
+       NotifyNotification *notification;
+       notification = notify_notification_new(
+               "Encode Complete",
+               "Put down that cocktail, Your HandBrake queue is done!",
+               "hb-icon",
+               NULL);
+       notify_notification_attach_to_status_icon(notification, si);
+       g_signal_connect(notification, "closed", (GCallback)notify_closed_cb, ud);
+       notify_notification_show(notification, NULL);
+#endif
+
+       if (ghb_settings_combo_int(ud->settings, "WhenComplete") == 3)
+       {
+               if (ghb_can_shutdown_gsm())
+               {
+                       ghb_countdown_dialog(GTK_MESSAGE_WARNING, 
+                               "Your encode is complete.",
+                               "Shutting down the computer", 
+                               "Cancel", (GSourceFunc)shutdown_cb, 60);
+               }
+       }
+       if (ghb_settings_combo_int(ud->settings, "WhenComplete") == 2)
+       {
+               if (ghb_can_suspend_gpm())
+               {
+                       ghb_countdown_dialog(GTK_MESSAGE_WARNING, 
+                               "Your encode is complete.",
+                               "Putting computer to sleep", 
+                               "Cancel", (GSourceFunc)suspend_cb, 60);
+               }
+       }
+}
index 7afaf9d..a124ab5 100644 (file)
 #if !defined(_CALLBACKS_H_)
 #define _CALLBACKS_H_
 
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
 #include <gtk/gtk.h>
 #include "settings.h"
 
 void ghb_check_all_depencencies(signal_user_data_t *ud);
 gboolean ghb_timer_cb(gpointer data);
 gboolean ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data);
+void warn_log_handler(
+       const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer ud);
 void debug_log_handler(
        const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer ud);
 void ghb_hbfd(signal_user_data_t *ud, gboolean hbfd);
-void ghb_file_menu_add_dvd(signal_user_data_t *ud);
-void ghb_hal_init();
+gboolean ghb_file_menu_add_dvd(signal_user_data_t *ud);
+void ghb_hal_init(void);
 gboolean ghb_message_dialog(
        GtkMessageType type, const gchar *message, 
        const gchar *no, const gchar *yes);
-void ghb_init_dep_map();
-gboolean ghb_reload_queue(signal_user_data_t *ud);
-gboolean ghb_cancel_encode(const gchar *extra_msg);
+void ghb_error_dialog(
+       GtkMessageType type, const gchar *message, const gchar *cancel);
+void ghb_init_dep_map(void);
+void ghb_cancel_encode(signal_user_data_t *ud, const gchar *extra_msg);
+gboolean ghb_cancel_encode2(signal_user_data_t *ud, const gchar *extra_msg);
 GValue* ghb_start_next_job(signal_user_data_t *ud, gboolean find_first);
-void ghb_check_dependency(signal_user_data_t *ud, GtkWidget *widget);
-void ghb_do_scan(signal_user_data_t *ud, const gchar *filename, gboolean force);
+void ghb_check_dependency(
+       signal_user_data_t *ud, GtkWidget *widget, const gchar *alt_name);
+void ghb_do_scan( signal_user_data_t *ud, const gchar *filename, 
+       gint titlenum, gboolean force);
 void ghb_log(gchar *log, ...);
-gboolean ghb_check_update(signal_user_data_t *ud);
+gpointer ghb_check_update(signal_user_data_t *ud);
+void ghb_uninhibit_gsm(void);
+void ghb_inhibit_gsm(signal_user_data_t *ud);
+#if defined(_WIN32)
+void wm_drive_changed(MSG *msg, signal_user_data_t *ud);
+#endif
+gpointer ghb_cache_volnames(signal_user_data_t *ud);
+void ghb_volname_cache_init(void);
+void ghb_update_destination_extension(signal_user_data_t *ud);
+void ghb_update_pending(signal_user_data_t *ud);
 
 #endif // _CALLBACKS_H_
 
diff --git a/gtk/src/composite_example.c b/gtk/src/composite_example.c
new file mode 100644 (file)
index 0000000..7918b30
--- /dev/null
@@ -0,0 +1,78 @@
+#include <gtk/gtk.h>
+#include "ghbcompositor.h"
+
+// GhbCompositor example
+int
+main(gint argc, gchar *argv[])
+{
+    GtkWidget *window;
+    GtkWidget *blender;
+    GtkWidget *eb_bottom;
+    GtkWidget *eb_top1;
+    GtkWidget *eb_top2;
+    GtkWidget *eb_top3;
+    GtkWidget *bottom;
+    GtkWidget *top1;
+    GtkWidget *top2;
+    GtkWidget *top3;
+    GtkWidget *table;
+    GtkWidget *image;
+
+    gtk_init(&argc, &argv);
+
+    // Make the top level window
+    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+    // Only widgets that have a GdkDrawing area can be composited
+    // These would be GtkEventBox or GtkDrawingArea
+    // Create the widgets that will be composited
+    eb_bottom = gtk_event_box_new();
+    eb_top1 = gtk_event_box_new();
+    eb_top2 = gtk_event_box_new();
+    eb_top3 = gtk_event_box_new();
+
+    // Create the compositor
+    blender = ghb_compositor_new();
+
+    // Create an button to put on the bottom layer
+    bottom = gtk_button_new_with_label("Bottom");
+    image = gtk_image_new_from_stock("gtk-help", 6);
+    gtk_button_set_image(GTK_BUTTON(bottom), image);
+
+    // The button must be placed inside an event box since
+    // buttons do not have their own window.
+    gtk_container_add(GTK_CONTAINER(eb_bottom), bottom);
+
+    // Create the buttons that will be visible on the top layer
+    top1 = gtk_button_new_with_label("Top 1");
+    top2 = gtk_button_new_with_label("Top 2");
+    top3 = gtk_button_new_with_label("Top 3");
+
+    // The buttons must be placed inside an event box since
+    // buttons do not have their own window.
+    gtk_container_add(GTK_CONTAINER(eb_top1), top1);
+    gtk_container_add(GTK_CONTAINER(eb_top2), top2);
+    gtk_container_add(GTK_CONTAINER(eb_top3), top3);
+
+    // Create the table that will be the top layer
+    // Using a layout widget gives flexibility in the layout of the layer
+    table = gtk_table_new(3, 3, TRUE);
+    gtk_table_attach(GTK_TABLE(table), eb_top1, 0, 1, 0, 1, 0, 0, 0, 0);
+    gtk_table_attach(GTK_TABLE(table), eb_top2, 1, 2, 1, 2, 0, 0, 0, 0);
+    gtk_table_attach(GTK_TABLE(table), eb_top3, 2, 3, 2, 3, 0, 0, 0, 0);
+
+    // Add the blender to the main window.
+    gtk_container_add(GTK_CONTAINER(window), blender);
+
+    // Set the blenders zlist, with opacity values
+    // Bottom layer is opaque, top layer 60%
+    ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), eb_bottom, 1, 1);
+    ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), table, 2, 0.6);
+
+    // Start the show
+    gtk_widget_show_all(window);
+
+    gtk_main();
+    return 0;
+}
+
index 4fea4d7..b91def6 100644 (file)
@@ -1,4 +1,6 @@
+#include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <string.h>
 #include <glib.h>
 #include <glib/gstdio.h>
@@ -42,6 +44,34 @@ typedef struct
        gboolean closed_top;
 } parse_data_t;
 
+GList *inc_list = NULL;
+
+static gchar*
+find_file(GList *list, const gchar *name)
+{
+       gchar *str;
+       GList *link = list;
+
+       while (link != NULL)
+       {
+               gchar *inc;
+
+               inc = (gchar*)link->data;
+               str = g_strdup_printf("%s/%s", inc, name);
+               if (g_file_test(str, G_FILE_TEST_IS_REGULAR))
+               {
+                       return str;
+               }
+               g_free(str);
+               link = g_list_next(link);
+       }
+       if (g_file_test(name, G_FILE_TEST_IS_REGULAR))
+       {
+               return g_strdup(name);
+       }
+       return NULL;
+}
+
 static const gchar*
 lookup_attr_value(
        const gchar *name, 
@@ -138,9 +168,11 @@ start_element(
                } break;
                case R_ICON:
                {
-                       const gchar *filename, *name;
+                       gchar *filename;
+                       const gchar *name;
 
-                       filename = lookup_attr_value("file", attr_names, attr_values);
+                       name = lookup_attr_value("file", attr_names, attr_values);
+                       filename = find_file(inc_list, name);
                        name = lookup_attr_value("name", attr_names, attr_values);
                        if (filename && name)
                        {
@@ -153,44 +185,54 @@ start_element(
                                gval = ghb_rawdata_value_new(rd);
                                if (pd->key) g_free(pd->key);
                                pd->key = g_strdup(name);
+                               g_free(filename);
                        }
                        else
                        {
                                g_warning("%s:missing a requried attribute", name);
+                       exit(EXIT_FAILURE);
                        }
                } break;
                case R_PLIST:
                {
-                       const gchar *filename, *name;
+                       gchar *filename;
+                       const gchar *name;
 
-                       filename = lookup_attr_value("file", attr_names, attr_values);
+                       name = lookup_attr_value("file", attr_names, attr_values);
+                       filename = find_file(inc_list, name);
                        name = lookup_attr_value("name", attr_names, attr_values);
                        if (filename && name)
                        {
                                gval = ghb_plist_parse_file(filename);
                                if (pd->key) g_free(pd->key);
                                pd->key = g_strdup(name);
+                               g_free(filename);
                        }
                        else
                        {
                                g_warning("%s:missing a requried attribute", name);
+                       exit(EXIT_FAILURE);
                        }
                } break;
                case R_STRING:
                {
-                       const gchar *filename, *name;
+                       gchar *filename;
+                       const gchar *name;
 
-                       filename = lookup_attr_value("file", attr_names, attr_values);
+                       name = lookup_attr_value("file", attr_names, attr_values);
+                       filename = find_file(inc_list, name);
                        name = lookup_attr_value("name", attr_names, attr_values);
                        if (filename && name)
                        {
                                gval = read_string_from_file(filename);
                                if (pd->key) g_free(pd->key);
                                pd->key = g_strdup(name);
+                               g_free(filename);
                        }
                        else
                        {
                                g_warning("%s:missing a requried attribute", name);
+                       exit(EXIT_FAILURE);
                        }
                } break;
        }
@@ -400,25 +442,63 @@ ghb_resource_parse_file(FILE *fd)
        return gval;
 }
 
+static void
+usage(char *cmd)
+{
+    fprintf(stderr,
+"Usage: %s [-I <inc path>] <in resource list> <out resource plist>\n"
+"Summary:\n"
+"    Creates a resource plist from a resource list\n"
+"Options:\n"
+"    I - Include path to search for files\n"
+"    <in resource list>    Input resources file\n"
+"    <out resource plist>  Output resources plist file\n"
+, cmd);
+
+    exit(EXIT_FAILURE);
+}
+
+#define OPTS "I:"
 
 gint
 main(gint argc, gchar *argv[])
 {
        FILE *file;
        GValue *gval;
-
-       if (argc < 3)
+    int opt;
+       const gchar *src, *dst;
+
+    do
+    {
+        opt = getopt(argc, argv, OPTS);
+        switch (opt)
+        {
+        case -1: break;
+
+        case 'I':
+                       inc_list = g_list_prepend(inc_list, g_strdup(optarg));
+            break;
+        }
+    } while (opt != -1);
+
+       if (optind != argc - 2)
        {
-               fprintf(stderr, "Usage: <in resource list> <out resource plist>\n");
-               return 1;
+               usage(argv[0]);
+               return EXIT_FAILURE;
        }
+    src = argv[optind++];
+    dst = argv[optind++];
+
        g_type_init();
-       file = g_fopen(argv[1], "r");
+       file = g_fopen(src, "r");
        if (file == NULL)
-               return 1;
+       {
+               fprintf(stderr, "Error: failed to open %s\n", src);
+               return EXIT_FAILURE;
+       }
 
        gval = ghb_resource_parse_file(file);
-       ghb_plist_write_file(argv[2], gval);
+       ghb_plist_write_file(dst, gval);
        return 0;
 }
 
diff --git a/gtk/src/create_resources.py b/gtk/src/create_resources.py
new file mode 100644 (file)
index 0000000..69d9e7d
--- /dev/null
@@ -0,0 +1,164 @@
+#! /bin/python
+#
+
+import gtk
+import types
+import os
+import sys
+import time
+import datetime
+import plistlib
+import getopt
+from xml.parsers import expat
+
+
+pl = dict()
+stack = list()
+stack.append(pl)
+
+def top(ss):
+       return ss[len(ss)-1]
+
+def end_element_handler(tag):
+       global stack
+
+       if tag == "section":
+               stack.pop()
+
+def start_element_handler(tag, attr):
+       global pl, stack
+
+       current = top(stack)
+       key = val = None
+       if tag == "section":
+               key = attr["name"]
+               if key == "icons":
+                       val = dict()
+                       stack.append(val)
+       elif tag == "icon":
+               fbase = attr["file"]
+               fname = find_file(fbase)
+               key = attr["name"]
+               if fname != None and key != None:
+                       val = dict()
+                       pb = gtk.gdk.pixbuf_new_from_file(fname)
+                       val["colorspace"] = pb.get_colorspace()
+                       val["alpha"] = pb.get_has_alpha()
+                       val["bps"] = pb.get_bits_per_sample()
+                       val["width"] = pb.get_width()
+                       val["height"] = pb.get_height()
+                       val["rowstride"] = pb.get_rowstride()
+                       val["data"] = plistlib.Data(pb.get_pixels())
+               elif fname == None:
+                       print >> sys.stderr, ( "Error: No such icon file %s" % fbase )
+                       sys.exit(1)
+       elif tag == "plist":
+               fbase = attr["file"]
+               fname = find_file(fbase)
+               key = attr["name"]
+               if fname != None and key != None:
+                       val = plistlib.readPlist(fname)
+               elif fname == None:
+                       print >> sys.stderr, ( "Error: No such plist file %s" % fbase )
+                       sys.exit(1)
+       elif tag == "string":
+               fbase = attr["file"]
+               fname = find_file(fbase)
+               key = attr["name"]
+               if fname != None and key != None:
+                       try:
+                               ff = open(fname)
+                               val = ff.read()
+                       except Exception, err:
+                               print >> sys.stderr, ( "Error: %s"  % str(err) )
+                               sys.exit(1)
+               elif fname == None:
+                       print >> sys.stderr, ( "Error: No such string file %s" % fbase )
+                       sys.exit(1)
+               
+       if val != None:
+               if type(current) == types.DictType:
+                       current[key] = val
+               elif type(current) == types.TupleType:
+                       current.append(val)
+
+
+def cdata_handler(str):
+       return
+
+def resource_parse_file(infile):
+       parser = expat.ParserCreate()
+       parser.StartElementHandler = start_element_handler
+       parser.EndElementHandler = end_element_handler
+       parser.CharacterDataHandler = cdata_handler
+       parser.ParseFile(infile)
+
+def usage():
+       print >> sys.stderr, (
+               "Usage: %s [-I <inc path>] <resource list> [resource plist]\n"
+               "Summary:\n"
+               "    Creates a resource plist from a resource list\n\n"
+               "Options:\n"
+               "    I - Include path to search for files\n"
+               "    <resource list>    Input resources file\n"
+               "    <resource plist>  Output resources plist file\n"
+               % sys.argv[0]
+       )
+
+inc_list = list()
+
+def find_file(name):
+       global inc_list
+
+       for inc_dir in inc_list:
+               inc = "%s/%s" % (inc_dir, name)
+               if os.path.isfile(inc):
+                       return inc
+
+       if os.path.isfile(name):
+               return name
+
+       return None
+
+def main():
+       global inc_list
+
+       OPTS = "I:"
+       try:
+               opts, args = getopt.gnu_getopt(sys.argv[1:], OPTS)
+       except getopt.GetoptError, err:
+               print >> sys.stderr, str(err)
+               usage()
+               sys.exit(2)
+
+       for o, a in opts:
+               if o == "-I":
+                       # add to include list
+                       inc_list.append(a)
+               else:
+                       assert False, "unhandled option"
+
+       if len(args) > 2 or len(args) < 1:
+               usage()
+               sys.exit(2)
+
+       try:
+               infile = open(args[0])
+       except Exception, err:
+               print >> sys.stderr, ( "Error: %s"  % str(err) )
+               sys.exit(1)
+
+       if len(args) > 1:
+               try:
+                       outfile = open(args[1], "w")
+               except Exception, err:
+                       print >> sys.stderr, ( "Error: %s"  % str(err))
+                       sys.exit(1)
+       else:
+               outfile = sys.stdout
+
+       resource_parse_file(infile)
+       plistlib.writePlist(pl, outfile)
+
+main()
+
index c20b8fa..1d3422c 100644 (file)
  *     Free Software Foundation version 2 of the License.
  */
 
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
 #include <glib.h>
 #include <gio/gio.h>
 
@@ -315,7 +319,6 @@ ghb_dvd_volname(const gchar *device)
 }
 #endif
 
-#if defined(__linux__)
 gchar*
 ghb_resolve_symlink(const gchar *name)
 {
@@ -359,12 +362,11 @@ ghb_resolve_symlink(const gchar *name)
        g_object_unref(gfile);
        return file;
 }
-#endif
 
 void
 ghb_dvd_set_current(const gchar *name, signal_user_data_t *ud)
 {
-#if defined(__linux__)
+#if !defined(_WIN32)
        GFile *gfile;
        GFileInfo *info;
        gchar *resolved = ghb_resolve_symlink(name);
@@ -395,11 +397,19 @@ ghb_dvd_set_current(const gchar *name, signal_user_data_t *ud)
        }
        g_object_unref(gfile);
 #else
+       gchar drive[4];
+       guint dtype;
+
        if (ud->current_dvd_device != NULL)
        {
                g_free(ud->current_dvd_device);
                ud->current_dvd_device = NULL;
        }
-       ud->current_dvd_device = g_strdup(name);;
+       g_strlcpy(drive, name, 4);
+       dtype = GetDriveType(drive);
+       if (dtype == DRIVE_CDROM)
+       {
+               ud->current_dvd_device = g_strdup(name);
+       }
 #endif
 }
index d278f77..226e686 100644 (file)
     <property name="value">0</property>
   </object>
   <object class="GtkAdjustment" id="adjustment5">
-    <property name="upper">1</property>
+    <property name="upper">51</property>
     <property name="lower">0</property>
-    <property name="page_increment">1</property>
-    <property name="step_increment">0.1</property>
+    <property name="page_increment">5</property>
+    <property name="step_increment">0.25</property>
     <property name="page_size">0</property>
-    <property name="value">0.63</property>
+    <property name="value">20.25</property>
   </object>
   <object class="GtkAdjustment" id="adjustment6">
     <property name="upper">4</property>
-    <property name="lower">1</property>
+    <property name="lower">0</property>
     <property name="page_increment">1</property>
     <property name="step_increment">0.2</property>
     <property name="page_size">0</property>
     <property name="page_size">0</property>
     <property name="value">0</property>
   </object>
+  <object class="GtkAdjustment" id="adjustment21">
+    <property name="value">15</property>
+    <property name="lower">5</property>
+    <property name="upper">60</property>
+    <property name="step_increment">5</property>
+    <property name="page_increment">10</property>
+    <property name="page_size">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment22">
+    <property name="upper">1</property>
+    <property name="lower">0</property>
+    <property name="page_increment">0.5</property>
+    <property name="step_increment">0.1</property>
+    <property name="page_size">0</property>
+    <property name="value">1</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment23">
+    <property name="upper">1</property>
+    <property name="lower">0</property>
+    <property name="page_increment">0.5</property>
+    <property name="step_increment">0.1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment24">
+    <property name="upper">100</property>
+    <property name="lower">1</property>
+    <property name="page_increment">1</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">1</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment25">
+    <property name="upper">2000</property>
+    <property name="lower">0</property>
+    <property name="page_increment">16</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment26">
+    <property name="upper">1200</property>
+    <property name="lower">0</property>
+    <property name="page_increment">16</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment27">
+    <property name="upper">10</property>
+    <property name="lower">1</property>
+    <property name="page_increment">1</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">1</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment28">
+    <property name="upper">4</property>
+    <property name="lower">0.9</property>
+    <property name="page_increment">1</property>
+    <property name="step_increment">0.1</property>
+    <property name="page_size">0</property>
+    <property name="value">0.0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment29">
+    <property name="upper">2000</property>
+    <property name="lower">0</property>
+    <property name="page_increment">16</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment30">
+    <property name="upper">2000</property>
+    <property name="lower">0</property>
+    <property name="page_increment">16</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment31">
+    <property name="upper">30000</property>
+    <property name="lower">-30000</property>
+    <property name="page_increment">100</property>
+    <property name="step_increment">10</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="preview_progress_adj">
+    <property name="upper">100</property>
+    <property name="lower">0</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+    <property name="value">0</property>
+  </object>
+  <object class="GtkAdjustment" id="preview_count_adj">
+    <property name="upper">30</property>
+    <property name="lower">5</property>
+    <property name="page_increment">10</property>
+    <property name="step_increment">5</property>
+    <property name="page_size">0</property>
+    <property name="value">10</property>
+  </object>
+  <object class="GtkImage" id="subtitle_add_image">
+    <property name="visible">True</property>
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="stock">gtk-add</property>
+  </object>
+  <object class="GtkImage" id="srt_add_image">
+    <property name="visible">True</property>
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="stock">gtk-add</property>
+  </object>
   <object class="GtkUIManager" id="uimanager1">
     <child>
       <object class="GtkActionGroup" id="actiongroup1">
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="source1">
+          <object class="GtkAction" id="source_action">
             <property name="stock_id">gtk-open</property>
-            <property name="name">source1</property>
+            <property name="name">source_action</property>
             <property name="label">_Source</property>
             <signal handler="source_button_clicked_cb" name="activate"/>
           </object>
         </child>
         <child>
+          <object class="GtkAction" id="source_single_action">
+            <property name="icon-name">gtk-open</property>
+            <property name="name">source_single_action</property>
+            <property name="label">Single _Title</property>
+            <signal handler="single_title_source_cb" name="activate"/>
+          </object>
+        </child>
+        <child>
           <object class="GtkAction" id="destination1">
             <property name="stock_id">gtk-save-as</property>
             <property name="name">destination1</property>
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="queue_stop_menu">
-            <property name="sensitive">False</property>
-            <property name="icon-name">hb-stop</property>
-            <property name="name">queue_stop_menu</property>
-            <property name="label" translatable="yes">S_top Queue</property>
-            <signal handler="queue_stop_clicked_cb" name="activate"/>
-          </object>
-        </child>
-        <child>
           <object class="GtkAction" id="menuitem3">
             <property name="name">menuitem3</property>
             <property name="label" translatable="yes">_View</property>
           </object>
         </child>
         <child>
-          <object class="GtkAction" id="show_activity_menu">
-            <property name="icon-name">hb-activity</property>
-            <property name="name">show_activity_menu</property>
-            <property name="label" translatable="yes">Show _Activity</property>
-            <signal handler="show_activity_clicked_cb" name="activate"/>
+          <object class="GtkToggleAction" id="show_presets">
+            <property name="visible">True</property>
+            <property name="active">False</property>
+            <property name="name">show_presets</property>
+            <property name="label" translatable="yes">Show Presets</property>
+            <signal handler="show_presets_toggled_cb" name="toggled"/>
           </object>
         </child>
         <child>
           <object class="GtkAction" id="show_preview_menu">
+            <property name="icon-name">hb-picture</property>
             <property name="name">show_preview_menu</property>
-            <property name="label" translatable="yes">Show _Preview</property>
-            <signal handler="preview_button_clicked_cb" name="activate"/>
+            <property name="label" translatable="yes">_Picture Settings</property>
+            <signal handler="picture_settings_alt_clicked_cb" name="activate"/>
+          </object>
+        </child>
+        <child>
+          <object class="GtkAction" id="show_activity_menu">
+            <property name="icon-name">hb-activity</property>
+            <property name="name">show_activity_menu</property>
+            <property name="label" translatable="yes">_Activity Window</property>
+            <signal handler="show_activity_menu_clicked_cb" name="activate"/>
           </object>
         </child>
         <child>
             <property name="icon-name">hb-queue</property>
             <property name="name">show_queue_menu</property>
             <property name="label" translatable="yes">Show _Queue</property>
-            <signal handler="show_queue_clicked_cb" name="activate"/>
+            <signal handler="show_queue_menu_clicked_cb" name="activate"/>
           </object>
         </child>
         <child>
     <ui>
       <menubar name="menubar1">
         <menu action="menuitem1">
-          <menuitem action="source1"/>
+          <menuitem action="source_action"/>
+          <menuitem action="source_single_action"/>
           <menuitem action="destination1"/>
           <separator/>
           <menuitem action="preferences"/>
           <menuitem action="queue_add_menu"/>
           <menuitem action="queue_start_menu"/>
           <menuitem action="queue_pause_menu"/>
-          <menuitem action="queue_stop_menu"/>
         </menu>
         <menu action="menuitem3">
           <menuitem action="hbfd"/>
-          <menuitem action="show_activity_menu"/>
-          <menuitem action="show_preview_menu"/>
+          <menuitem action="show_presets"/>
           <menuitem action="show_queue_menu"/>
+          <menuitem action="show_preview_menu"/>
+          <menuitem action="show_activity_menu"/>
         </menu>
         <menu action="menuitem4">
           <menuitem action="about"/>
       </menubar>
     </ui>
   </object>
+  <object class="GtkListStore" id="device_list">
+    <columns>
+      <!-- column-name device -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+
+  <object class="GtkMenu" id="presets_menu">
+    <child>
+      <object class="GtkImageMenuItem" id="presets_default">
+        <property name="label">_Make Default</property>
+        <property name="image">image12</property>
+        <property name="visible">True</property>
+        <property name="use_underline">True</property>
+        <property name="use_stock">True</property>
+        <signal name="activate" handler="presets_default_clicked_cb"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkImageMenuItem" id="presets_new_folder">
+        <property name="label" translatable="yes">New _Folder</property>
+        <property name="use-underline">True</property>
+        <property name="visible">True</property>
+        <property name="use_stock">True</property>
+        <property name="image">image11</property>
+        <signal name="activate" handler="presets_new_folder_clicked_cb"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkImageMenuItem" id="preset_export">
+        <property name="label" translatable="yes">_Export</property>
+        <property name="use-underline">True</property>
+        <property name="visible">True</property>
+        <property name="image">image13</property>
+        <property name="use_stock">False</property>
+        <signal name="activate" handler="preset_export_clicked_cb"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkImageMenuItem" id="preset_import">
+        <property name="label" translatable="yes">_Import</property>
+        <property name="use-underline">True</property>
+        <property name="visible">True</property>
+        <property name="image">image14</property>
+        <property name="use_stock">False</property>
+        <signal name="activate" handler="preset_import_clicked_cb"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkImageMenuItem" id="presets_restore">
+        <property name="label" translatable="yes">_Update Built-in Presets</property>
+        <property name="image">image15</property>
+        <property name="visible">True</property>
+        <property name="use_underline">True</property>
+        <property name="use_stock">True</property>
+        <signal name="activate" handler="presets_restore_clicked_cb"/>
+      </object>
+    </child>
+  </object>
+
   <object class="GtkWindow" id="hb_window">
     <property name="visible">True</property>
+    <property name="resizable">False</property>
     <property name="title" translatable="yes">HandBrake</property>
     <property name="default_width">500</property>
     <property name="default_height">400</property>
     <property name="icon_name">hb-icon</property>
+    <property name="events">GDK_VISIBILITY_NOTIFY_MASK</property>
+    <signal handler="hb_visibility_event_cb" name="visibility_notify_event"/>
     <signal handler="window_destroy_event_cb" name="destroy_event"/>
     <signal handler="window_delete_event_cb" name="delete_event"/>
     <child>
+      <object class="GtkVBox" id="vbox48">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <child>
+          <object class="GtkMenuBar" constructor="uimanager1" id="menubar1">
+            <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToolbar" id="toolbar1">
+            <property name="visible">True</property>
+            <property name="icon_size">5</property>
+            <child>
+              <object class="GtkToolButton" id="sourcetoolbutton">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Choose Video Source</property>
+                <property name="label" translatable="yes">Source</property>
+                <property name="icon_name">hb-source</property>
+                <signal handler="source_button_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="queue_start1">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="sensitive">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Start Encoding</property>
+                <property name="label" translatable="yes">Start</property>
+                <property name="icon_name">hb-play</property>
+                <signal handler="queue_start_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="queue_pause1">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="sensitive">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Pause Encoding</property>
+                <property name="label" translatable="yes">Pause</property>
+                <property name="icon_name">hb-pause</property>
+                <signal handler="queue_pause_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="queue_add">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="sensitive">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Add to Queue</property>
+                <property name="label" translatable="yes">Add to Queue</property>
+                <property name="icon_name">hb-add-queue</property>
+                <signal handler="queue_add_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="show_queue">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Show Queue</property>
+                <property name="label" translatable="yes">Show Queue</property>
+                <property name="icon_name">hb-queue</property>
+                <signal handler="show_queue_clicked_cb" name="toggled"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="show_picture">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Open Picture Settings and Preview window.  Here you can adjust cropping, resolution, aspect ratio, and filters.</property>
+                <property name="label" translatable="yes">Picture Settings</property>
+                <property name="icon_name">hb-picture</property>
+                <signal name="toggled" handler="picture_settings_clicked_cb"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="show_activity">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="tooltip-text" translatable="yes">Show Activity Window</property>
+                <property name="label" translatable="yes">Activity Window</property>
+                <property name="icon_name">hb-activity</property>
+                <signal handler="show_activity_clicked_cb" name="toggled"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+
+    <child>
       <object class="GtkHBox" id="hbox1">
         <property name="visible">True</property>
         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
         <child>
-          <object class="GtkVBox" id="vbox1">
+          <object class="GtkVBox" id="vbox14">
             <property name="visible">True</property>
             <child>
-              <object class="GtkVBox" id="vbox2">
+              <object class="GtkVBox" id="vbox15">
                 <property name="visible">True</property>
                 <child>
-                  <object class="GtkMenuBar" constructor="uimanager1" id="menubar1">
+                  <object class="GtkAlignment" id="alignment1">
                     <property name="visible">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHBox" id="hbox3">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="left_padding">6</property>
+                    <property name="right_padding">12</property>
+                    <property name="top_padding">12</property>
+                    <property name="bottom_padding">6</property>
+                    <property name="xalign">0</property>
+                    <property name="xscale">1</property>
                     <child>
-                      <object class="GtkToolbar" id="toolbar1">
+                      <object class="GtkVBox" id="vbox16">
                         <property name="visible">True</property>
-                        <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
-                        <property name="icon_size">GTK_ICON_SIZE_DND</property>
+                        <property name="spacing">6</property>
                         <child>
-                          <object class="GtkToolButton" id="toolbutton1">
+                          <object class="GtkHBox" id="hbox54">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Choose Video Source</property>
-                            <property name="label" translatable="yes">Source</property>
-                            <property name="icon_name">hb-source</property>
-                            <signal handler="source_button_clicked_cb" name="clicked"/>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="label7">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">&lt;b&gt;Source:&lt;/b&gt;</property>
+                                <property name="use_markup">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="source_title">
+                                <property name="width_request">240</property>
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">None</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkAlignment" id="alignment68">
+                                <property name="visible">True</property>
+                                <property name="xscale">1</property>
+                                <property name="yscale">0</property>
+                                <child>
+                                  <object class="GtkProgressBar" id="scan_prog">
+                                    <property name="height_request">10</property>
+                                    <property name="visible">False</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="text" translatable="yes"/>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkToolButton" id="queue_start1">
+                          <object class="GtkAlignment" id="alignment65">
                             <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Start Encoding</property>
-                            <property name="label" translatable="yes">Start</property>
-                            <property name="icon_name">hb-play</property>
-                            <signal handler="queue_start_clicked_cb" name="clicked"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkToolButton" id="queue_pause1">
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Pause Encoding</property>
-                            <property name="label" translatable="yes">Pause</property>
-                            <property name="icon_name">hb-pause</property>
-                            <signal handler="queue_pause_clicked_cb" name="clicked"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkToolButton" id="queue_add">
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Add to Queue</property>
-                            <property name="label" translatable="yes">Add to Queue</property>
-                            <property name="icon_name">hb-add-queue</property>
-                            <signal handler="queue_add_clicked_cb" name="clicked"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkToolButton" id="show_queue">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Show Queue</property>
-                            <property name="label" translatable="yes">Show Queue</property>
-                            <property name="icon_name">hb-queue</property>
-                            <signal handler="show_queue_clicked_cb" name="clicked"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkToolButton" id="show_activity">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Show Activity Window</property>
-                            <property name="label" translatable="yes">Activity Window</property>
-                            <property name="icon_name">hb-activity</property>
-                            <signal handler="show_activity_clicked_cb" name="clicked"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="hbox48">
-                        <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="show_presets">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="tooltip-text" translatable="yes">Show/Hide the presets list</property>
-                            <property name="relief">GTK_RELIEF_NONE</property>
-                            <property name="active">True</property>
-                            <property name="draw_indicator">True</property>
-                            <signal handler="show_presets_toggled_cb" name="toggled"/>
-                            <child>
-                              <object class="GtkImage" id="drawerimage">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="icon_size">5</property>
-                                <property name="icon_name">hb-drawer</property>
-                              </object>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkFrame" id="frame1">
-                    <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">GTK_SHADOW_NONE</property>
-                    <child>
-                      <object class="GtkAlignment" id="alignment1">
-                        <property name="visible">True</property>
-                        <property name="left_padding">12</property>
-                        <child>
-                          <object class="GtkVBox" id="vbox3">
-                            <property name="visible">True</property>
-                            <child>
-                              <object class="GtkHBox" id="hbox2">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="spacing">5</property>
-                                <child>
-                                  <object class="GtkLabel" id="source_title">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Source Title</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                            </child>
+                            <property name="left_padding">6</property>
+                            <property name="bottom_padding">6</property>
                             <child>
                               <object class="GtkHBox" id="hbox5">
                                 <property name="visible">True</property>
                                 <property name="spacing">4</property>
                                 <child>
-                                  <object class="GtkLabel" id="label3">
+                                  <object class="GtkLabel" id="label20">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Title</property>
                                   </object>
                                 </child>
                                 <child>
                                   <object class="GtkComboBox" id="title">
-                                    <property name="width_request">150</property>
                                     <property name="visible">True</property>
                                     <property name="has_frame">False</property>
+                                    <property name="tooltip-text" translatable="yes">Set the title to encode. By default the longest title is chosen.  This is often the feature title of a DVD.</property>
                                     <signal handler="title_changed_cb" name="changed"/>
                                   </object>
                                   <packing>
                                   <object class="GtkAlignment" id="chapter_box">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0</property>
                                     <property name="xscale">0</property>
+                                    <property name="left_padding">8</property>
                                     <child>
                                       <object class="GtkHBox" id="hbox4">
                                         <property name="visible">True</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">Set the first chapter to encode.</property>
                                             <property name="adjustment">adjustment1</property>
                                             <signal handler="start_chapter_changed_cb" name="value_changed"/>
                                           </object>
                                         <child>
                                           <object class="GtkLabel" id="label5">
                                             <property name="visible">True</property>
-                                            <property name="label" translatable="yes"> thru </property>
+                                            <property name="label" translatable="yes"> through </property>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">Set the last chapter to encode.</property>
                                             <property name="adjustment">adjustment2</property>
                                             <signal handler="end_chapter_changed_cb" name="value_changed"/>
                                           </object>
                                     </child>
                                   </object>
                                   <packing>
+                                    <property name="expand">False</property>
                                     <property name="position">2</property>
                                   </packing>
                                 </child>
                                 <child>
+                                  <object class="GtkAlignment" id="alignment47">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0</property>
+                                    <property name="xscale">0</property>
+                                    <property name="left_padding">8</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox44">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="spacing">7</property>
+                                        <child>
+                                          <object class="GtkLabel" id="angle_label">
+                                            <property name="visible">True</property>
+                                            <property name="label" translatable="yes">Angle:</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">4</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkSpinButton" id="angle">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">For multi-angle DVD's, select the desired angle to encode.</property>
+                                            <property name="adjustment">adjustment27</property>
+                                            <signal name="value_changed" handler="setting_widget_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">5</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                                <child>
                                   <object class="GtkAlignment" id="alignment41">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="xalign">1</property>
+                                    <property name="xalign">0</property>
                                     <property name="xscale">0</property>
+                                    <property name="left_padding">8</property>
                                     <child>
                                       <object class="GtkHBox" id="hbox42">
                                         <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                             <property name="xalign">0</property>
                                             <property name="label" translatable="yes">hh:mm:ss</property>
-                                            <property name="width_chars">10</property>
+                                            <property name="width_chars">8</property>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
                                     </child>
                                   </object>
                                   <packing>
-                                    <property name="position">3</property>
+                                    <property name="expand">False</property>
+                                    <property name="position">4</property>
                                   </packing>
                                 </child>
                               </object>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
                             </child>
                           </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
                         </child>
                       </object>
                     </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label7">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Source&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator1">
-                    <property name="visible">True</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">3</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkFrame" id="frame2">
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment3">
+                      <object class="GtkAlignment" id="alignment44">
                         <property name="visible">True</property>
                         <property name="left_padding">12</property>
+                        <property name="top_padding">6</property>
+                        <property name="bottom_padding">6</property>
                         <child>
-                          <object class="GtkVBox" id="vbox4">
+                          <object class="GtkHBox" id="hbox67">
                             <property name="visible">True</property>
+                            <property name="spacing">12</property>
                             <child>
-                              <object class="GtkHBox" id="hbox6">
+                              <object class="GtkTable" id="table3">
                                 <property name="visible">True</property>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">2</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
                                 <child>
-                                  <object class="GtkLabel" id="label8">
+                                  <object class="GtkFileChooserButton" id="dest_dir">
                                     <property name="visible">True</property>
-                                    <property name="label" translatable="yes">File:</property>
+                                    <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+                                    <property name="title" translatable="yes">Destination Directory</property>
+                                    <property name="tooltip-text" translatable="yes">Destination directory for your encode.</property>
+                                    <signal name="selection_changed" handler="dest_dir_set_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkEntry" id="destination">
+                                  <object class="GtkEntry" id="dest_file">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="tooltip-text" translatable="yes">Destination path with file name for output.</property>
-                                    <property name="width_chars">41</property>
-                                    <signal handler="destination_entry_changed_cb" name="changed"/>
-                                    <signal handler="destination_grab_cb" name="grab-focus" after="yes"/>
+                                    <property name="width_chars">40</property>
+                                    <property name="tooltip-text" translatable="yes">Destination filename for your encode.</property>
+                                    <signal name="changed" handler="dest_file_changed_cb"/>
+                                    <signal name="grab_focus" handler="destination_grab_cb" after="yes"/>
                                     <accelerator key="d" signal="grab-focus" modifiers="GDK_MOD1_MASK"/>
                                   </object>
                                   <packing>
-                                    <property name="position">1</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="destination_browse">
+                                  <object class="GtkLabel" id="label18">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="relief">GTK_RELIEF_NONE</property>
-                                    <signal handler="destination_browse_clicked_cb" name="clicked"/>
-                                    <child>
-                                      <object class="GtkAlignment" id="alignment4">
-                                        <property name="visible">True</property>
-                                        <property name="xscale">0</property>
-                                        <property name="yscale">0</property>
-                                        <child>
-                                          <object class="GtkHBox" id="hbox7">
-                                            <property name="visible">True</property>
-                                            <property name="spacing">2</property>
-                                            <child>
-                                              <object class="GtkImage" id="image2">
-                                                <property name="visible">True</property>
-                                                <property name="stock">gtk-open</property>
-                                              </object>
-                                              <packing>
-                                                <property name="expand">False</property>
-                                                <property name="fill">False</property>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <object class="GtkLabel" id="label9">
-                                                <property name="visible">True</property>
-                                                <property name="label" translatable="yes">Browse</property>
-                                                <property name="use_underline">True</property>
-                                              </object>
-                                              <packing>
-                                                <property name="expand">False</property>
-                                                <property name="fill">False</property>
-                                                <property name="position">1</property>
-                                              </packing>
-                                            </child>
-                                          </object>
-                                        </child>
-                                      </object>
-                                    </child>
+                                    <property name="label" translatable="yes">File:</property>
                                   </object>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                    <property name="position">2</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
                             </child>
                             <child>
-                              <object class="GtkHBox" id="container_box">
+                              <object class="GtkTable" id="container_box">
                                 <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="spacing">8</property>
-                                <child>
-                                  <object class="GtkLabel" id="label10">
-                                    <property name="visible">True</property>
-                                    <property name="label" translatable="yes">Container:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="fill">False</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkComboBox" id="FileFormat">
-                                    <property name="visible">True</property>
-                                    <property name="tooltip-text" translatable="yes">Output file container type</property>
-                                    <signal handler="container_changed_cb" name="changed"/>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">False</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">2</property>
+                                <property name="column_spacing">4</property>
                                 <child>
-                                  <object class="GtkAlignment" id="alignment39">
+                                  <object class="GtkHBox" id="hbox3">
                                     <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="xalign">0.10000000149011612</property>
-                                    <property name="xscale">0</property>
+                                    <property name="spacing">4</property>
                                     <child>
-                                      <object class="GtkCheckButton" id="Mp4iPodCompatible">
+                                      <object class="GtkLabel" id="label45">
                                         <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">iPod 5G Support</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                        <property name="label" translatable="yes">Format:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="FileFormat">
+                                        <property name="visible">True</property>
+                                        <property name="tooltip-text" translatable="yes">Format to mux encoded tracks to.</property>
+                                        <signal name="changed" handler="container_changed_cb"/>
                                       </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
                                     </child>
                                   </object>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="position">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkCheckButton" id="Mp4HttpOptimize">
+                                  <object class="GtkCheckButton" id="Mp4iPodCompatible">
+                                    <property name="label" translatable="yes">iPod 5G Support</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="label" translatable="yes">Web optimized</property>
-                                    <property name="tooltip-text" translatable="yes">Tunes the MP4 to be better suited for streaming</property>
+                                    <property name="tooltip-text" translatable="yes">Add iPod Atom needed by some older iPods.</property>
+                                    <property name="xalign">0</property>
                                     <property name="draw_indicator">True</property>
-                                    <signal handler="http_opt_changed_cb" name="toggled"/>
+                                    <signal name="toggled" handler="setting_widget_changed_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="expand">False</property>
-                                    <property name="position">3</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkCheckButton" id="Mp4LargeFile">
+                                  <object class="GtkCheckButton" id="Mp4HttpOptimize">
+                                    <property name="label" translatable="yes">Web optimized</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="tooltip-text" translatable="yes">Caution: This option will likely break device compatiblity with all but the AppleTV Take 2. Checking this box enables a 64 bit mp4 file which can be over 4 GB.</property>
-                                    <property name="label" translatable="yes">Large file size (&gt;4GB)</property>
+                                    <property name="tooltip-text" translatable="yes">Optimize the layout of the MP4 file for progressive download.  This allows a player to initiate playback before downloading the entire file.</property>
+                                    <property name="xalign">0</property>
                                     <property name="draw_indicator">True</property>
-                                    <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                    <signal name="toggled" handler="http_opt_changed_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="position">4</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="Mp4LargeFile">
+                                    <property name="label" translatable="yes">Large file (&gt;4GB)</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-markup" translatable="yes">Allow 64 bit MP4 file which can be over 4GB.
+
+&lt;b&gt;Caution:&lt;/b&gt; This option may break device compatibility.</property>
+                                    <property name="xalign">0</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
                                 <property name="position">1</property>
+                                <property name="expand">False</property>
                               </packing>
                             </child>
                           </object>
                   </object>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="position">4</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkHSeparator" id="hseparator2">
-                    <property name="visible">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">5</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               </packing>
             </child>
             <child>
+              <object class="GtkAlignment" id="alignment67">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="top_padding">0</property>
+                <property name="left_padding">12</property>
+                <property name="right_padding">12</property>
+
+            <child>
               <object class="GtkNotebook" id="settings_box">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <property name="spacing">3</property>
+
                     <child>
-                      <object class="GtkVBox" id="vbox5">
+                      <object class="GtkAlignment" id="alignment55">
+                        <property name="visible">True</property>
+                        <property name="top_padding">10</property>
+                        <property name="left_padding">10</property>
+
+                    <child>
+                      <object class="GtkVBox" id="vbox43">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                       <property name="spacing">14</property>
                         <child>
                           <object class="GtkFrame" id="frame5">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">GTK_SHADOW_NONE</property>
                             <child>
                               <object class="GtkAlignment" id="alignment9">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
+                                <property name="top_padding">6</property>
                                 <property name="bottom_padding">2</property>
                                 <property name="left_padding">12</property>
                                 <child>
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                             <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Dimenstions:</property>
+                                            <property name="label" translatable="yes">Dimensions:</property>
                                             <property name="width_chars">15</property>
                                           </object>
                                           <packing>
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                         <child>
-                                          <object class="GtkLabel" id="label24">
+                                          <object class="GtkLabel" id="label42">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                             <property name="xalign">0</property>
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                         <child>
-                                          <object class="GtkLabel" id="label25">
+                                          <object class="GtkLabel" id="label43">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                             <property name="xalign">0</property>
                               </object>
                             </child>
                             <child type="label">
-                              <object class="GtkLabel" id="label26">
+                              <object class="GtkLabel" id="label44">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                 <property name="label" translatable="yes">&lt;b&gt;Source Picture Parameters&lt;/b&gt;</property>
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">GTK_SHADOW_NONE</property>
                             <child>
-                              <object class="GtkAlignment" id="alignment5">
+                              <object class="GtkAlignment" id="alignment52">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
+                                <property name="top_padding">6</property>
                                 <property name="bottom_padding">2</property>
                                 <property name="left_padding">12</property>
                                 <property name="right_padding">2</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox6">
+                                  <object class="GtkVBox" id="vbox44">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                     <child>
-                                      <object class="GtkHBox" id="hbox54">
+                                      <object class="GtkHBox" id="hbox61">
                                         <property name="visible">True</property>
                                         <child>
                                           <object class="GtkLabel" id="label13">
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkVBox" id="vbox7">
+                          <object class="GtkVBox" id="vbox45">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <child>
-                              <object class="GtkFrame" id="frame3">
+                              <object class="GtkFrame" id="frame16">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                 <property name="label_xalign">0</property>
-                                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                                <property name="shadow_type">GTK_SHADOW_NONE</property>
                                 <child>
-                                  <object class="GtkAlignment" id="alignment7">
+                                  <object class="GtkAlignment" id="alignment20">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="top_padding">2</property>
+                                    <property name="top_padding">6</property>
                                     <property name="bottom_padding">2</property>
                                     <property name="left_padding">12</property>
                                     <property name="right_padding">2</property>
                                     <child>
-                                      <object class="GtkVBox" id="vbox8">
+                                      <object class="GtkVBox" id="vbox46">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                         <child>
                                           </object>
                                         </child>
                                         <child>
-                                          <object class="GtkHBox" id="hbox26">
+                                          <object class="GtkHBox" id="hbox68">
                                             <property name="visible">True</property>
                                             <child>
                                               <object class="GtkLabel" id="label15">
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkHBox" id="hbox27">
+                                          <object class="GtkHBox" id="hbox69">
                                             <property name="visible">True</property>
                                             <child>
                                               <object class="GtkLabel" id="label17">
                         </child>
                       </object>
                     </child>
+
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+
+                    <child>
+                      <object class="GtkAlignment" id="alignment56">
+                        <property name="visible">True</property>
+                        <property name="right_padding">12</property>
+                        <property name="top_padding">12</property>
+
                     <child>
                       <object class="GtkVBox" id="vbox9">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+
                         <child>
-                          <object class="GtkFrame" id="frame4">
+                          <object class="GtkFrame" id="frame8">
                             <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">none</property>
                             <child>
-                              <object class="GtkAlignment" id="alignment8">
+                              <object class="GtkAlignment" id="alignment19">
                                 <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
-                                <property name="bottom_padding">2</property>
-                                <property name="left_padding">12</property>
+                                <property name="bottom_padding">4</property>
+                                <property name="left_padding">4</property>
+                                <property name="right_padding">4</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox10">
+                                  <object class="GtkImage" id="preview_button_image">
+                                    <property name="width_request">400</property>
+                                    <property name="height_request">200</property>
                                     <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <child>
-                                      <object class="GtkCheckButton" id="VideoGrayScale">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">This filter removes the color components of the picture.</property>
-                                        <property name="label" translatable="yes">Grayscale</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                      </object>
-                                      <packing>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkCheckButton" id="PictureDetelecine">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Remove interlacing artifacts caused by the telecine process often applied to movies.</property>
-                                        <property name="label" translatable="yes">Detelecine</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                        <signal handler="tweak_setting_cb" name="button-press-event"/>
-                                      </object>
-                                      <packing>
-                                        <property name="position">1</property>
-                                        <property name="expand">False</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkCheckButton" id="PictureDecomb">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="tooltip-text" translatable="yes">Decomb is a selective deinterlacer. It will only deinterlace frames that appear to need it. It generally produces better quality than the normal deinterlacer.</property>
-                                        <property name="label" translatable="yes">De-Comb</property>
-                                        <property name="active">True</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                        <signal handler="tweak_setting_cb" name="button-press-event"/>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox25">
-                                        <property name="visible">True</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label41">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Deblock:</property>
-                                            <property name="width_chars">10</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment20">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0.55</property>
-                                            <child>
-                                              <object class="GtkHScale" id="PictureDeblock">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="tooltip-text" translatable="yes">This is a filter that gets applied before encoding.  If the source looks blocky before encoding, you may want to use this.</property>
-                                                <property name="adjustment">adjustment20</property>
-                                                <property name="digits">0</property>
-                                                <property name="value_pos">GTK_POS_RIGHT</property>
-                                                <signal handler="setting_widget_changed_cb" name="value_changed"/>
-                                                <signal handler="format_deblock_cb" name="format-value"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="position">3</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox12">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label20">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="selectable">False</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Deinterlace:</property>
-                                            <property name="width_chars">10</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkComboBox" id="PictureDeinterlace">
-                                            <property name="width_request">100</property>
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Removes interlacing artifacts. Since deinterlacing degrades picture quality, leave it off unless you know you need it.</property>
-                                            <signal handler="setting_widget_changed_cb" name="changed"/>
-                                            <signal handler="tweak_setting_cb" name="button-press-event"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkComboBoxEntry" id="tweak_PictureDeinterlace">
-                                            <property name="visible">False</property>
-                                            <signal handler="setting_widget_changed_cb" name="changed"/>
-                                            <child internal-child="entry">
-                                              <object class="GtkEntry" id="comboboxentry-entry1">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="width_chars">15</property>
-                                                <signal handler="deint_tweak_focus_out_cb" name="focus_out_event"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="position">2</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="padding">2</property>
-                                        <property name="position">4</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox13">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label21">
-                                            <property name="visible">True</property>
-                                            <property name="selectable">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Denoise:</property>
-                                            <property name="width_chars">10</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkComboBox" id="PictureDenoise">
-                                            <property name="width_request">100</property>
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">This filter removes noise or grain from the picture.</property>
-                                            <signal handler="setting_widget_changed_cb" name="changed"/>
-                                            <signal handler="tweak_setting_cb" name="button-press-event"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkComboBoxEntry" id="tweak_PictureDenoise">
-                                            <property name="visible">False</property>
-                                            <signal handler="setting_widget_changed_cb" name="changed"/>
-                                            <child internal-child="entry">
-                                              <object class="GtkEntry" id="comboboxentry-entry2">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="width_chars">15</property>
-                                                <signal handler="denoise_tweak_focus_out_cb" name="focus_out_event"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="position">2</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="padding">2</property>
-                                        <property name="position">5</property>
-                                      </packing>
-                                    </child>
+                                    <property name="icon_name">hb-icon</property>
+                                    <property name="icon-size">6</property>
+                                    <signal name="size_allocate" handler="preview_button_size_allocate_cb"/>
                                   </object>
                                 </child>
                               </object>
                             </child>
-                            <child type="label">
-                              <object class="GtkLabel" id="label22">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">&lt;b&gt;Picture Cleanup&lt;/b&gt;</property>
-                                <property name="use_markup">True</property>
-                              </object>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
-                            <property name="padding">2</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
+
+                    <child>
+                      <object class="GtkAlignment" id="alignment57">
+                        <property name="visible">True</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <object class="GtkVBox" id="vbox16">
+                          <object class="GtkHBox" id="hbox7">
                             <property name="visible">True</property>
+                            <property name="spacing">4</property>
                             <child>
-                              <object class="GtkHBox" id="hbox56">
+                              <object class="GtkLabel" id="label10">
                                 <property name="visible">True</property>
-                                <child>
-                                  <object class="GtkLabel" id="label69">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0.75999999046325684</property>
-                                    <property name="yalign">1</property>
-                                    <property name="label" translatable="yes">&lt;b&gt;Preview:&lt;/b&gt;</property>
-                                    <property name="use_markup">True</property>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="preview_dims">
-                                    <property name="width_request">85</property>
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0.20999999344348907</property>
-                                    <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">--</property>
-                                  </object>
-                                  <packing>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
+                                <property name="label" translatable="yes">Presentation Dimensions:</property>
+                                <property name="justify">right</property>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
                             </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox35">
-                            <property name="visible">True</property>
                             <child>
-                              <object class="GtkButton" id="preview_button">
-                                <property name="width_request">118</property>
+                              <object class="GtkLabel" id="preview_dims">
+                                <property name="width_request">85</property>
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip-text" translatable="yes">Open the full size preview</property>
-                                <property name="relief">GTK_RELIEF_HALF</property>
-                                <signal handler="preview_button_clicked_cb" name="clicked"/>
-                                <signal handler="preview_button_size_allocate_cb" name="size_allocate"/>
-                                <child>
-                                  <object class="GtkHBox" id="hbox49">
-                                    <property name="visible">True</property>
-                                    <child>
-                                      <object class="GtkImage" id="preview_button_image">
-                                        <property name="visible">True</property>
-                                        <property name="icon_size">6</property>
-                                        <property name="icon_name">hb-icon</property>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
+                                <property name="xalign">0.2</property>
+                                <property name="yalign">0</property>
+                                <property name="label" translatable="yes">--</property>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
                             </child>
+
                           </object>
-                          <packing>
-                            <property name="position">2</property>
-                          </packing>
                         </child>
+
                       </object>
                       <packing>
-                        <property name="position">1</property>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+
+                      </object>
+                    </child>
+
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
+
                   </object>
                 </child>
                 <child type="tab">
                   <object class="GtkHBox" id="hbox17">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+
+                    <property name="spacing">48</property>
                     <child>
-                      <object class="GtkVBox" id="vbox12">
+                      <object class="GtkAlignment" id="alignment14">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">48</property>
+                        <property name="left_padding">24</property>
                         <child>
-                          <object class="GtkFrame" id="Encoding1">
+                          <object class="GtkVBox" id="vbox13">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="spacing">4</property>
                             <child>
-                              <object class="GtkAlignment" id="alignment10">
+                              <object class="GtkHBox" id="hbox18">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
-                                <property name="bottom_padding">2</property>
-                                <property name="left_padding">12</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox13">
+                                  <object class="GtkLabel" id="label46">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Video Codec:</property>
+                                    <property name="width_chars">11</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment11">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox18">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label28">
-                                            <property name="visible">True</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Video Codec:</property>
-                                            <property name="width_chars">11</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment11">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkComboBox" id="VideoEncoder">
-                                                <property name="visible">True</property>
-                                                <signal handler="vcodec_changed_cb" name="changed"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="padding">4</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox19">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label29">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Framerate:</property>
-                                            <property name="width_chars">11</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment12">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkComboBox" id="VideoFramerate">
-                                                <property name="visible">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <signal handler="setting_widget_changed_cb" name="changed"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="padding">4</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
+                                    <property name="xalign">0</property>
+                                    <property name="xscale">0</property>
                                     <child>
-                                      <object class="GtkCheckButton" id="VideoTwoPass">
+                                      <object class="GtkComboBox" id="VideoEncoder">
                                         <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">2-Pass Encoding</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                        <property name="tooltip-text" translatable="yes">Avaliable video encoders.</property>
+                                        <signal handler="vcodec_changed_cb" name="changed"/>
                                       </object>
-                                      <packing>
-                                        <property name="position">2</property>
-                                      </packing>
                                     </child>
+                                  </object>
+                                  <packing>
+                                    <property name="padding">4</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox19">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <child>
+                                  <object class="GtkLabel" id="label47">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Framerate:</property>
+                                    <property name="width_chars">11</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment12">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0</property>
+                                    <property name="xscale">0</property>
                                     <child>
-                                      <object class="GtkAlignment" id="alignment13">
+                                      <object class="GtkComboBox" id="VideoFramerate">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="xscale">0.23999999463558197</property>
-                                        <child>
-                                          <object class="GtkCheckButton" id="VideoTurboTwoPass">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Turbo First Pass</property>
-                                            <property name="active">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                          </object>
-                                        </child>
+                                        <property name="tooltip-text" translatable="yes">Output framerate.  'Same as source' is recomended. If your source video has a variable framerate, 'Same as source' will preserve it.</property>
+                                        <signal handler="setting_widget_changed_cb" name="changed"/>
                                       </object>
-                                      <packing>
-                                        <property name="position">3</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
                                     </child>
                                   </object>
+                                  <packing>
+                                    <property name="padding">4</property>
+                                    <property name="position">1</property>
+                                  </packing>
                                 </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="VideoTwoPass">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Perform 2 Pass Encoding.  'Bitrate' or 'Target Size' options are prerequisites. During the 1st pass, statistics about the video are collected.  Then in the second pass, those statistics are used to make bitrate allocation decisions.</property>
+                                <property name="label" translatable="yes">2-Pass Encoding</property>
+                                <property name="draw_indicator">True</property>
+                                <signal handler="setting_widget_changed_cb" name="toggled"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">2</property>
+                              </packing>
                             </child>
-                            <child type="label">
-                              <object class="GtkLabel" id="label30">
+                            <child>
+                              <object class="GtkAlignment" id="alignment13">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">&lt;b&gt;Encoding&lt;/b&gt;</property>
-                                <property name="use_markup">True</property>
+                                <property name="left_padding">16</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="VideoTurboTwoPass">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">During the 1st pass of a 2 pass encode, use settings that speed things along.</property>
+                                    <property name="label" translatable="yes">Turbo First Pass</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                  </object>
+                                </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">3</property>
+                              </packing>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="padding">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
                         </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
-                        <property name="padding">4</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkVBox" id="vbox14">
+                      <object class="GtkAlignment" id="alignment10">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">48</property>
+                        <property name="right_padding">24</property>
                         <child>
-                          <object class="GtkFrame" id="frame6">
+                          <object class="GtkVBox" id="vbox47">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
                             <child>
-                              <object class="GtkAlignment" id="alignment14">
+                              <object class="GtkHBox" id="hbox62">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
-                                <property name="bottom_padding">2</property>
-                                <property name="left_padding">12</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox15">
+                                  <object class="GtkRadioButton" id="vquality_type_bitrate">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the average bitrate. The instantaneous bitrate can be much higher or lower at any point in time.  But the average over a long duration will be the value set here.  If you need to limit instantaneous bitrate, look into x264's vbv-bufsize and vbv-maxrate settings.</property>
+                                    <property name="label" translatable="yes">Bitrate (kbps):    </property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment15">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0.11999999731779099</property>
+                                    <property name="xscale">0.10000000149011612</property>
                                     <child>
-                                      <object class="GtkHBox" id="hbox20">
+                                      <object class="GtkSpinButton" id="VideoAvgBitrate">
                                         <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkRadioButton" id="vquality_type_bitrate">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Bitrate (kbps):    </property>
-                                            <property name="draw_indicator">True</property>
-                                            <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment15">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0.11999999731779099</property>
-                                            <property name="xscale">0.10000000149011612</property>
-                                            <child>
-                                              <object class="GtkSpinButton" id="VideoAvgBitrate">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="adjustment">adjustment3</property>
-                                                <signal handler="setting_widget_changed_cb" name="value_changed"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
+                                        <property name="tooltip-text" translatable="yes">Set the average bitrate. The instantaneous bitrate can be much higher or lower at any point in time.  But the average over a long duration will be the value set here.  If you need to limit instantaneous bitrate, look into x264 vbv-bufsize and vbv-maxrate.</property>
+                                        <property name="adjustment">adjustment3</property>
+                                        <signal handler="setting_widget_changed_cb" name="value_changed"/>
                                       </object>
                                     </child>
+                                  </object>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox56">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <child>
+                                  <object class="GtkRadioButton" id="vquality_type_target">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the desired final size of the output file. This uses the known duration of the video to calculate the bitrate that will be required to achieve the desired size.</property>
+                                    <property name="label" translatable="yes">Target Size (MB):</property>
+                                    <property name="draw_indicator">True</property>
+                                    <property name="group">vquality_type_bitrate</property>
+                                    <signal handler="target_size_changed_cb" name="toggled"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment16">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="xalign">0.11999999731779099</property>
+                                    <property name="xscale">0.10000000149011612</property>
                                     <child>
-                                      <object class="GtkHBox" id="hbox21">
+                                      <object class="GtkSpinButton" id="VideoTargetSize">
                                         <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkRadioButton" id="vquality_type_target">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Target Size (MB):</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">vquality_type_bitrate</property>
-                                            <signal handler="target_size_changed_cb" name="toggled"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment16">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0.11999999731779099</property>
-                                            <property name="xscale">0.10000000149011612</property>
-                                            <child>
-                                              <object class="GtkSpinButton" id="VideoTargetSize">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="adjustment">adjustment4</property>
-                                                <signal handler="target_size_changed_cb" name="value_changed"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkHBox" id="hbox22">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkRadioButton" id="vquality_type_constant">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Quality:</property>
-                                            <property name="active">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">vquality_type_target</property>
-                                            <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkHScale" id="VideoQualitySlider">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="adjustment">adjustment5</property>
-                                            <property name="digits">3</property>
-                                            <property name="value_pos">GTK_POS_RIGHT</property>
-                                            <signal handler="setting_widget_changed_cb" name="value_changed"/>
-                                            <signal handler="format_vquality_cb" name="format-value"/>
-                                          </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="position">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkAlignment" id="alignment17">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="xscale">0.8399999737739563</property>
-                                        <child>
-                                          <object class="GtkCheckButton" id="constant_rate_factor">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Constant Rate Factor</property>
-                                            <property name="active">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                          </object>
-                                        </child>
+                                        <property name="tooltip-text" translatable="yes">Set the desired final size of the output file. This uses the known duration of the video to calculate the bitrate that will be required to achieve the desired size.</property>
+                                        <property name="adjustment">adjustment4</property>
+                                        <signal handler="target_size_changed_cb" name="value_changed"/>
                                       </object>
-                                      <packing>
-                                        <property name="position">3</property>
-                                      </packing>
                                     </child>
                                   </object>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox57">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <child>
+                                  <object class="GtkRadioButton" id="vquality_type_constant">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the desired quality factor. The encoder targets a certain quality.  The scale used by each video encoder is different.  
+
+x264's scale is logarithmic and lower values coorespond to higher quality.  So small decreases in value will result in progressively larger increases in the resulting file size.  A value of 0 means lossless and will result in a file size that is larger than the original source, unless the source was also lossless.
+
+FFmpeg's and Theora's scale is more linear.  These encoders do not have a lossless mode.</property>
+                                    <property name="label" translatable="yes">Constant Quality:</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <property name="group">vquality_type_target</property>
+                                    <signal handler="setting_widget_changed_cb" name="toggled"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
                                 </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">2</property>
+                              </packing>
                             </child>
-                            <child type="label">
-                              <object class="GtkLabel" id="label31">
+                            <child>
+                              <object class="GtkHScale" id="VideoQualitySlider">
                                 <property name="visible">True</property>
+                                <property name="can_focus">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">&lt;b&gt;Quality&lt;/b&gt;</property>
-                                <property name="use_markup">True</property>
+                                <property name="tooltip-text" translatable="yes">Set the desired quality factor. The encoder targets a certain quality.  The scale used by each video encoder is different.  
+
+x264's scale is logarithmic and lower values coorespond to higher quality.  So small decreases in value will result in progressively larger increases in the resulting file size.  A value of 0 means lossless and will result in a file size that is larger than the original source, unless the source was also lossless.
+
+FFmpeg's and Theora's scale is more linear.  These encoders do not have a lossless mode.</property>
+                                <property name="adjustment">adjustment5</property>
+                                <property name="digits">3</property>
+                                <property name="value_pos">GTK_POS_BOTTOM</property>
+                                <signal handler="vquality_changed_cb" name="value_changed"/>
+                                <signal handler="format_vquality_cb" name="format-value"/>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">3</property>
+                              </packing>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="padding">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
                         </child>
                       </object>
                       <packing>
                   </object>
                 </child>
                 <child type="tab">
-                  <object class="GtkLabel" id="label32">
+                  <object class="GtkLabel" id="label65">
                     <property name="visible">True</property>
                     <property name="label" translatable="yes">Video</property>
                   </object>
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
-                      <object class="GtkFrame" id="frame7">
+                      <object class="GtkAlignment" id="alignment18">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="label_xalign">0</property>
-                        <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                        <property name="top_padding">12</property>
+                        <property name="bottom_padding">2</property>
+                        <property name="left_padding">12</property>
+                        <property name="right_padding">2</property>
                         <child>
-                          <object class="GtkAlignment" id="alignment18">
+                          <object class="GtkVBox" id="vbox17">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="top_padding">2</property>
-                            <property name="bottom_padding">2</property>
-                            <property name="left_padding">12</property>
-                            <property name="right_padding">2</property>
+                            <property name="spacing">2</property>
                             <child>
-                              <object class="GtkVBox" id="vbox17">
+                              <object class="GtkHBox" id="hbox58">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="spacing">2</property>
+                                <property name="spacing">5</property>
                                 <child>
-                                  <object class="GtkHBox" id="hbox23">
+                                  <object class="GtkButton" id="audio_add">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">5</property>
-                                    <child>
-                                      <object class="GtkButton" id="audio_add">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Add new audio settings to the list</property>
-                                        <property name="relief">GTK_RELIEF_NONE</property>
-                                        <signal handler="audio_add_clicked_cb" name="clicked"/>
-                                        <child>
-                                          <object class="GtkImage" id="image4">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="stock">gtk-add</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkButton" id="audio_remove">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Remove the selected audio settings</property>
-                                        <property name="relief">GTK_RELIEF_NONE</property>
-                                        <signal handler="audio_remove_clicked_cb" name="clicked"/>
-                                        <child>
-                                          <object class="GtkImage" id="image8">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="stock">gtk-remove</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
+                                    <property name="tooltip-text" translatable="yes">Add new audio settings to the list</property>
+                                    <property name="relief">GTK_RELIEF_NONE</property>
+                                    <signal handler="audio_add_clicked_cb" name="clicked"/>
                                     <child>
-                                      <object class="GtkAlignment" id="alignment42">
+                                      <object class="GtkImage" id="image4">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="xalign">0.98000001907348633</property>
-                                        <property name="xscale">0.40000000596046448</property>
-                                        <child>
-                                          <object class="GtkVBox" id="vbox18">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <child>
-                                              <object class="GtkLabel" id="label2">
-                                                <property name="visible">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="label" translatable="yes">Dynamic Range Compression</property>
-                                              </object>
-                                            </child>
-                                            <child>
-                                              <object class="GtkHScale" id="AudioTrackDRCSlider">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="adjustment">adjustment6</property>
-                                                <property name="restrict_to_fill_level">False</property>
-                                                <property name="fill_level">3823.35009765625</property>
-                                                <property name="value_pos">GTK_POS_RIGHT</property>
-                                                <signal handler="audio_widget_changed_cb" name="value_changed"/>
-                                              </object>
-                                              <packing>
-                                                <property name="position">1</property>
-                                              </packing>
-                                            </child>
-                                          </object>
-                                        </child>
+                                        <property name="stock">gtk-add</property>
                                       </object>
-                                      <packing>
-                                        <property name="position">2</property>
-                                      </packing>
                                     </child>
                                   </object>
                                   <packing>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkTable" id="table2">
+                                  <object class="GtkButton" id="audio_remove">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="n_rows">2</property>
-                                    <property name="n_columns">5</property>
-                                    <child>
-                                      <object class="GtkComboBox" id="AudioTrack">
-                                        <property name="width_request">215</property>
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="audio_track_changed_cb" name="changed"/>
-                                      </object>
-                                      <packing>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkComboBox" id="AudioEncoder">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="audio_codec_changed_cb" name="changed"/>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkComboBox" id="AudioSamplerate">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="audio_widget_changed_cb" name="changed"/>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">3</property>
-                                        <property name="right_attach">4</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label35">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">Track</property>
-                                      </object>
-                                      <packing>
-                                        <property name="x_options">GTK_FILL</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label36">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">Codec</property>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">1</property>
-                                        <property name="right_attach">2</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                        <property name="x_padding">12</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label37">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">Bitrate</property>
-                                        <property name="justify">GTK_JUSTIFY_CENTER</property>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">2</property>
-                                        <property name="right_attach">3</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                        <property name="x_padding">10</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label38">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">Sample Rate</property>
-                                        <property name="justify">GTK_JUSTIFY_CENTER</property>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">3</property>
-                                        <property name="right_attach">4</property>
-                                        <property name="x_options"/>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label39">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="label" translatable="yes">Mix</property>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">4</property>
-                                        <property name="right_attach">5</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkComboBox" id="AudioMixdown">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="audio_mix_changed_cb" name="changed"/>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">4</property>
-                                        <property name="right_attach">5</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                        <property name="x_options">GTK_FILL</property>
-                                      </packing>
-                                    </child>
+                                    <property name="tooltip-text" translatable="yes">Remove the selected audio settings</property>
+                                    <property name="relief">GTK_RELIEF_NONE</property>
+                                    <signal handler="audio_remove_clicked_cb" name="clicked"/>
                                     <child>
-                                      <object class="GtkComboBox" id="AudioBitrate">
+                                      <object class="GtkImage" id="image8">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="audio_widget_changed_cb" name="changed"/>
+                                        <property name="stock">gtk-remove</property>
                                       </object>
-                                      <packing>
-                                        <property name="left_attach">2</property>
-                                        <property name="right_attach">3</property>
-                                        <property name="top_attach">1</property>
-                                        <property name="bottom_attach">2</property>
-                                      </packing>
                                     </child>
                                   </object>
                                   <packing>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
-                                <child>
-                                  <object class="GtkTreeView" id="audio_list">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="headers_clickable">True</property>
-                                  </object>
-                                  <packing>
-                                    <property name="position">2</property>
-                                  </packing>
-                                </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
                             </child>
-                          </object>
-                        </child>
-                        <child type="label">
-                          <object class="GtkLabel" id="label40">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label" translatable="yes">&lt;b&gt;Encoding&lt;/b&gt;</property>
-                            <property name="use_markup">True</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="hboxj01">
-                        <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="spacing">5</property>
-                        <child>
-                          <object class="GtkFrame" id="framej01">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
                             <child>
-                              <object class="GtkAlignment" id="alignmentj01">
+                              <object class="GtkTable" id="table1">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
-                                <property name="bottom_padding">2</property>
-                                <property name="left_padding">12</property>
-                                <property name="right_padding">2</property>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">7</property>
+                                <child>
+                                  <object class="GtkComboBox" id="AudioTrack">
+                                    <property name="width_request">180</property>
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">List of audio tracks available from your source.</property>
+                                    <signal handler="audio_track_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="AudioEncoder">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the audio codec to encode this track with.</property>
+                                    <signal handler="audio_codec_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="AudioSamplerate">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the sample rate of the output audio track.</property>
+                                    <signal handler="audio_widget_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">3</property>
+                                    <property name="right_attach">4</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label35">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Track</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label68">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Codec</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="x_padding">12</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label69">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Bitrate</property>
+                                    <property name="justify">GTK_JUSTIFY_CENTER</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="x_padding">10</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label38">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Sample Rate</property>
+                                    <property name="justify">GTK_JUSTIFY_CENTER</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">3</property>
+                                    <property name="right_attach">4</property>
+                                    <property name="x_options"/>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label24">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Mix</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">4</property>
+                                    <property name="right_attach">5</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label39">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">DRC</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">5</property>
+                                    <property name="right_attach">7</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="AudioMixdown">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the mixdown of the output audio track.</property>
+                                    <signal handler="audio_mix_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">4</property>
+                                    <property name="right_attach">5</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
                                 <child>
-                                  <object class="GtkHBox" id="hboxj02">
+                                  <object class="GtkScaleButton" id="AudioTrackDRCSlider">
                                     <property name="visible">True</property>
+                                    <property name="orientation">1</property>
+                                    <property name="icons">audio-volume-muted
+audio-volume-high
+audio-volume-low
+audio-volume-medium</property>
+                                    <property name="adjustment">adjustment28</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">5</property>
+                                    <property name="tooltip-markup" translatable="yes">&lt;b&gt;Dynamic Range Compression:&lt;/b&gt; Adjust the dynamic range of the output audio track. 
 
-                                    <child>
-                                      <object class="GtkComboBox" id="SourceAudioLang">
-                                        <property name="width_request">150</property>
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="setting_widget_changed_cb" name="changed"/>
-                                      </object>
-                                    </child>
+For source audio that has a wide dynamic range (very loud and very soft sequences), DRC allows you to 'compress' the range by making loud sections softer and soft sections louder.</property>
+                                    <signal handler="drc_widget_changed_cb" name="value_changed"/>
                                   </object>
+                                  <packing>
+                                    <property name="left_attach">5</property>
+                                    <property name="right_attach">6</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="drc_label">
+                                    <property name="visible">True</property>
+                                    <property name="width-chars">3</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Off</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">6</property>
+                                    <property name="right_attach">7</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="AudioBitrate">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the bitrate to encode this track with.</property>
+                                    <signal handler="audio_widget_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
                                 </child>
                               </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
                             </child>
-                            <child type="label">
-                              <object class="GtkLabel" id="labelj01">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">&lt;b&gt;Preferred Audio Language&lt;/b&gt;</property>
-                                <property name="use_markup">True</property>
-                              </object>
-                            </child>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkFrame" id="framej02">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
                             <child>
-                              <object class="GtkAlignment" id="alignmentj02">
+                              <object class="GtkScrolledWindow" id="scrolledwindow5">
                                 <property name="visible">True</property>
+                                <property name="can_focus">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
-                                <property name="bottom_padding">2</property>
-                                <property name="left_padding">12</property>
-                                <property name="right_padding">2</property>
+                                <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                                 <child>
-                                  <object class="GtkHBox" id="hboxj03">
+                                  <object class="GtkTreeView" id="audio_list">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">5</property>
-
-                                    <child>
-                                      <object class="GtkComboBox" id="Subtitles">
-                                        <property name="width_request">150</property>
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <signal handler="subtitle_changed_cb" name="changed"/>
-                                      </object>
-                                    </child>
-                                    <child>
-                                      <object class="GtkCheckButton" id="SubtitlesForced">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="has_tooltip">True</property>
-                                        <property name="tooltip-text" translatable="yes">These are subtitles that a regular DVD player would automatically show.</property>
-                                        <property name="label" translatable="yes">Allow only forced subtitles</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal handler="setting_widget_changed_cb" name="toggled"/>
-                                      </object>
-                                      <packing>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
+                                    <property name="headers_clickable">True</property>
                                   </object>
                                 </child>
                               </object>
-                            </child>
-                            <child type="label">
-                              <object class="GtkLabel" id="labelj02">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">&lt;b&gt;Subtitles&lt;/b&gt;</property>
-                                <property name="use_markup">True</property>
-                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
                             </child>
                           </object>
-                          <packing>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">3</property>
-                      </packing>
                     </child>
                   </object>
                 </child>
                 <child type="tab">
                   <object class="GtkLabel" id="label48">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Audio/Subtitles</property>
+                    <property name="label" translatable="yes">Audio</property>
                   </object>
                   <packing>
                     <property name="position">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHBox" id="x264_tab">
+                  <object class="GtkVBox" id="subtitle_tab">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="spacing">2</property>
                     <child>
-                      <object class="GtkVBox" id="vbox21">
+                      <object class="GtkAlignment" id="alignment23">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">12</property>
+                        <property name="bottom_padding">2</property>
+                        <property name="left_padding">12</property>
+                        <property name="right_padding">2</property>
                         <child>
-                          <object class="GtkFrame" id="frame9">
+                          <object class="GtkVBox" id="vbox12">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="spacing">2</property>
                             <child>
-                              <object class="GtkAlignment" id="alignment25">
+                              <object class="GtkHBox" id="hbox45">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="left_padding">12</property>
+                                <property name="spacing">5</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox22">
+                                  <object class="GtkButton" id="subtitle_add">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Add new subtitle to the list</property>
+                                    <property name="relief">GTK_RELIEF_NONE</property>
+                                    <property name="label">Subtitle</property>
+                                    <property name="image">subtitle_add_image</property>
+                                    <signal handler="subtitle_add_clicked_cb" name="clicked"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="srt_add">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Add new SRT subtitle to the list</property>
+                                    <property name="relief">GTK_RELIEF_NONE</property>
+                                    <property name="label">Import SRT</property>
+                                    <property name="image">srt_add_image</property>
+                                    <signal handler="srt_add_clicked_cb" name="clicked"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="subtitle_remove">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Remove the selected subtitle settings</property>
+                                    <property name="relief">GTK_RELIEF_NONE</property>
+                                    <signal handler="subtitle_remove_clicked_cb" name="clicked"/>
                                     <child>
-                                      <object class="GtkHBox" id="hbox31">
+                                      <object class="GtkImage" id="image2">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label49">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="label" translatable="yes">Number:  </property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkSpinButton" id="x264_refs">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="tooltip-text" translatable="yes">Selects the number of reference frames that can be used. Slows down encoding.  Good typical values are 3 to 5. Animation can benefit from more (8 to 10).</property>
+                                        <property name="stock">gtk-remove</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkTable" id="subtitle_table">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">5</property>
+                                <property name="column-spacing">4</property>
+                                <child>
+                                  <object class="GtkLabel" id="subtitle_track_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Track</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="left_attach">0</property>
+                                    <property name="right_attach">1</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="srt_lang_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Language</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="srt_code_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Character Code</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="srt_file_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">File</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="left_attach">3</property>
+                                    <property name="right_attach">4</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="srt_offset_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Offset (ms)</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="left_attach">4</property>
+                                    <property name="right_attach">5</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="SubtitleTrack">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">List of subtitle tracks available from your source.</property>
+                                    <signal handler="subtitle_track_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options"></property>
+                                    <property name="left_attach">0</property>
+                                    <property name="right_attach">1</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="SrtLanguage">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the language of this subtitle. This value will be used by players in subtitle menus.</property>
+                                    <signal handler="srt_lang_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options"></property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBoxEntry" id="SrtCodeset">
+                                    <property name="width_request">150</property>
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Set the character code used by the SRT file you are importing. SRTs come in all flavours of character sets.  We translate the character set to UTF-8. The source's character code is needed in order to perform this translation.</property>
+                                    <signal handler="srt_changed_cb" name="changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options"></property>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkFileChooserButton" id="SrtFile">
+                                    <property name="visible">True</property>
+                                    <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
+                                    <property name="title" translatable="yes">Srt File</property>
+                                    <property name="tooltip-text" translatable="yes">Select the SRT file to import.</property>
+                                    <signal name="selection_changed" handler="srt_file_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL|GTK_EXPAND</property>
+                                    <property name="y_options"></property>
+                                    <property name="left_attach">3</property>
+                                    <property name="right_attach">4</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="SrtOffset">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Adjust the offset in milliseconds between video and SRT timestamps</property>
+                                    <property name="adjustment">adjustment31</property>
+                                    <signal handler="srt_changed_cb" name="value_changed"/>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options"></property>
+                                    <property name="left_attach">4</property>
+                                    <property name="right_attach">5</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkScrolledWindow" id="scrolledwindow4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                                <child>
+                                  <object class="GtkTreeView" id="subtitle_list">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="headers_clickable">True</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="tab">
+                  <object class="GtkLabel" id="label9">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Subtitles</property>
+                  </object>
+                  <packing>
+                    <property name="position">3</property>
+                    <property name="tab_fill">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="x264_tab">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="spacing">2</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox21">
+                        <property name="visible">True</property>
+                        <property name="spacing">10</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <child>
+                          <object class="GtkFrame" id="frame9">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment25">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="top_padding">6</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkVBox" id="vbox22">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox31">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="spacing">4</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label49">
+                                            <property name="visible">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="label" translatable="yes">Number:</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkSpinButton" id="x264_refs">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">Selects the number of reference frames that can be used. Slows down encoding.  Good typical values are 3 to 5. Animation can benefit from more (8 to 10).</property>
                                             <property name="adjustment">adjustment8</property>
                                             <signal handler="x264_widget_changed_cb" name="value_changed"/>
                                           </object>
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">none</property>
                             <child>
                               <object class="GtkAlignment" id="alignment26">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
+                                <property name="top_padding">6</property>
                                 <property name="bottom_padding">2</property>
                                 <property name="left_padding">12</property>
                                 <property name="right_padding">2</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox24">
+                                  <object class="GtkTable" id="table6">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">2</property>
+                                    <property name="n_rows">4</property>
+                                    <property name="n_columns">2</property>
+                                    <property name="column-spacing">4</property>
+                                    <property name="row-spacing">2</property>
+                                    <child>
+                                      <object class="GtkLabel" id="label51">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Number:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                      </packing>
+                                    </child>
                                     <child>
-                                      <object class="GtkHBox" id="hbox32">
+                                      <object class="GtkAlignment" id="alignment38">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
                                         <child>
-                                          <object class="GtkLabel" id="label51">
+                                          <object class="GtkSpinButton" id="x264_bframes">
                                             <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Number:  </property>
-                                            <property name="width_chars">14</property>
+                                            <property name="tooltip-text" translatable="yes">B-Frames cost little in speed, unless you are using b-adapt=2 (optimal). So you generally want to choose a high value. 16 isn't unreasonable.</property>
+                                            <property name="adjustment">adjustment9</property>
+                                            <signal handler="x264_widget_changed_cb" name="value_changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
                                         </child>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label52">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Direct Prediction:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="top_attach">1</property>
+                                        <property name="bottom_attach">2</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment39">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
                                         <child>
-                                          <object class="GtkAlignment" id="alignment27">
+                                          <object class="GtkComboBox" id="x264_direct">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkSpinButton" id="x264_bframes">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">Sane values are 1-6. B-Frames are smaller than other frames, so they let you pack in more quality at the same bitrate. Use more of them with animated material: 9-16.</property>
-                                                <property name="adjustment">adjustment9</property>
-                                                <signal handler="x264_widget_changed_cb" name="value_changed"/>
-                                              </object>
-                                            </child>
+                                            <property name="tooltip-text" translatable="yes">Set prediction mode for 'direct' motion vectors. This option improves compression efficiency.</property>
+                                            <signal handler="x264_widget_changed_cb" name="changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
                                         </child>
                                       </object>
                                       <packing>
-                                        <property name="expand">False</property>
+                                        <property name="top_attach">1</property>
+                                        <property name="bottom_attach">2</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label84">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Adaptive B-Frames:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="top_attach">2</property>
+                                        <property name="bottom_attach">3</property>
+                                        <property name="x_options">GTK_FILL</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkHBox" id="hbox33">
+                                      <object class="GtkAlignment" id="alignment40">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
                                         <child>
-                                          <object class="GtkLabel" id="label52">
+                                          <object class="GtkComboBox" id="x264_b_adapt">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Direct Prediction:  </property>
-                                            <property name="width_chars">14</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment28">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkComboBox" id="x264_direct">
-                                                <property name="visible">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">This option can improve compression efficiency. </property>
-                                                <signal handler="x264_widget_changed_cb" name="changed"/>
-                                              </object>
-                                            </child>
+                                            <property name="tooltip-markup" translatable="yes">This setting controls how x264 decides between 
+placing a P or B-frame.
+&lt;small&gt;
+Off            - Pick B-frames always
+Fast           - Speed slightly increases with higher B-frames setting
+Optimal        - Speed significantly decreases with higher B-frames setting
+&lt;/small&gt;
+This option can improve compression efficiency. Use 'Optimal' if you can afford the time.</property>
+                                            <signal handler="x264_widget_changed_cb" name="changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
                                         </child>
                                       </object>
                                       <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">1</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="bottom_attach">3</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
                                       </packing>
                                     </child>
-
-                                    <child>
-                                      <object class="GtkTable" id="table8">
-                                        <property name="visible">True</property>
-                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="n_rows">2</property>
-                                        <property name="n_columns">2</property>
-
                                     <child>
                                       <object class="GtkCheckButton" id="x264_bpyramid">
                                         <property name="visible">True</property>
                                         <property name="draw_indicator">True</property>
                                         <signal handler="x264_widget_changed_cb" name="toggled"/>
                                       </object>
+                                      <packing>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                      </packing>
                                     </child>
                                     <child>
                                       <object class="GtkCheckButton" id="x264_weighted_bframes">
                                         <signal handler="x264_widget_changed_cb" name="toggled"/>
                                       </object>
                                       <packing>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
                                         <property name="left_attach">1</property>
                                         <property name="right_attach">2</property>
                                       </packing>
                                     </child>
-
-                                      </object>
-                                      <packing>
-                                        <property name="position">2</property>
-                                      </packing>
-                                    </child>
-
                                   </object>
                                 </child>
                               </object>
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">none</property>
                             <child>
                               <object class="GtkAlignment" id="alignment29">
                                 <property name="visible">True</property>
                                 <property name="left_padding">12</property>
                                 <property name="right_padding">2</property>
                                 <child>
-                                  <object class="GtkTextView" id="x264Option">
+                                  <object class="GtkScrolledWindow" id="scrolledwindow6">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                        <property name="tooltip-text" translatable="yes">Your selected options will appear here. 
+                                    <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                                    <property name="shadow_type">etched-in</property>
+                                    <child>
+                                      <object class="GtkTextView" id="x264Option">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                            <property name="tooltip-text" translatable="yes">Your selected options will appear here. 
 You can edit these and add additional options.  
 
 Default values will not be shown. The defaults are:
-ref=1:mixed-refs=0:bframes=0:direct=spatial:b-pyramid=0:
-weightb=0:me=hex:merange=16:subme=5:
-analyse=some:8x8dct=0:deblock=0,0:trellis=0:
-no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
-                                    <property name="wrap_mode">GTK_WRAP_CHAR</property>
-                                    <property name="accepts_tab">False</property>
-                                    <signal handler="x264_focus_out_cb" name="focus_out_event"/>
+ref=3:mixed-refs=1:bframes=3:direct=spatial:b-pyramid=0:
+weightb=1:me=hex:merange=16:subme=7:analyse=some:8x8dct=1:
+deblock=0,0:trellis=1:psy-rd=1,0:no-fast-pskip=0:
+no-dct-decimate=0:cabac=1</property>
+                                        <property name="wrap_mode">GTK_WRAP_CHAR</property>
+                                        <property name="accepts_tab">False</property>
+                                        <signal handler="x264_focus_out_cb" name="focus_out_event"/>
+                                      </object>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -2684,145 +2887,188 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkVSeparator" id="vseparator1">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkVBox" id="vbox25">
                         <property name="visible">True</property>
+                        <property name="spacing">10</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <child>
                           <object class="GtkFrame" id="frame12">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">none</property>
                             <child>
                               <object class="GtkAlignment" id="alignment30">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
+                                <property name="top_padding">6</property>
                                 <property name="bottom_padding">2</property>
                                 <property name="left_padding">12</property>
                                 <property name="right_padding">2</property>
                                 <child>
-                                  <object class="GtkVBox" id="vbox26">
+                                  <object class="GtkTable" id="table5">
                                     <property name="visible">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="spacing">2</property>
+                                    <property name="n_rows">4</property>
+                                    <property name="n_columns">2</property>
+                                    <property name="row-spacing">2</property>
+                                    <property name="column-spacing">4</property>
                                     <child>
-                                      <object class="GtkHBox" id="hbox34">
+                                      <object class="GtkLabel" id="label55">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <child>
-                                          <object class="GtkLabel" id="label55">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Method: </property>
-                                            <property name="width_chars">14</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment31">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkComboBox" id="x264_me">
-                                                <property name="visible">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">This sets the shape of the area x264 searches when estimating motion. Your choices are a diamond, a hexagon, a more complex hexagonal shape, or searching the entire frame. You are best off using Uneven Multi-Hexagonal searching.</property>
-                                                <signal handler="x264_widget_changed_cb" name="changed"/>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Method: </property>
                                       </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
+                                      </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkHBox" id="hbox36">
+                                      <object class="GtkAlignment" id="alignment31">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
                                         <child>
-                                          <object class="GtkLabel" id="label57">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Range: </property>
-                                            <property name="width_chars">14</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment32">
+                                          <object class="GtkComboBox" id="x264_me">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0</property>
-                                            <child>
-                                              <object class="GtkSpinButton" id="x264_merange">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">This range is the radius, in pixels, x264 should use for motion estimation searches. It only has an effect when you use Uneven Multi-Hexagonal or Exhaustive searching. 24, 32, and 64 are good values.</property>
-                                                <property name="adjustment">adjustment10</property>
-                                                <signal handler="x264_widget_changed_cb" name="value_changed"/>
-                                              </object>
-                                            </child>
+                                            <property name="tooltip-text" translatable="yes">This sets the search pattern x264 uses when estimating motion. Uneven Multi-Hexagonal provides some benefit over Hex with a modest hit in speed. Exhaustive and Hadamard Exhaustive are very slow and generally not useful for everyday encoding.</property>
+                                            <signal handler="x264_me_changed_cb" name="changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
                                         </child>
                                       </object>
                                       <packing>
-                                        <property name="position">1</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label57">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Range: </property>
+                                      </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="top_attach">1</property>
+                                        <property name="bottom_attach">2</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkHBox" id="hbox37">
+                                      <object class="GtkAlignment" id="alignment32">
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
                                         <child>
-                                          <object class="GtkLabel" id="label58">
+                                          <object class="GtkSpinButton" id="x264_merange">
                                             <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Subpixel Method:</property>
-                                            <property name="width_chars">14</property>
+                                            <property name="tooltip-text" translatable="yes">The radius, in pixels, x264 should use for motion estimation searches. Higher values can be useful on HiDef or high-motion footage.</property>
+                                            <property name="adjustment">adjustment10</property>
+                                            <signal handler="x264_widget_changed_cb" name="value_changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
                                         </child>
+                                      </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">1</property>
+                                        <property name="bottom_attach">2</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label58">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Subpixel Method:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="bottom_attach">3</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment33">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0.05000000074505806</property>
                                         <child>
-                                          <object class="GtkAlignment" id="alignment33">
+                                          <object class="GtkComboBox" id="x264_subme">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="xscale">0.05000000074505806</property>
-                                            <child>
-                                              <object class="GtkComboBox" id="x264_subme">
-                                                <property name="visible">True</property>
-                                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">Determines how motion estimation decisions are made. 1 is lowest quality and fastest. 9 is highest quality and slowest.  5 or 6 are commonly used values.</property>
-                                                <signal handler="x264_widget_changed_cb" name="changed"/>
-                                              </object>
-                                            </child>
+                                            <property name="tooltip-markup" translatable="yes">Determines how motion estimation decisions are made. Higher numbers provide greater compression efficiency and are slower.
+&lt;small&gt;
+1      - QPel SAD 1 iteration
+2      - QPel SATD 2 iterations
+3      - HPel on MB then QPel
+4      - Always QPel
+5      - Multi QPel + bime
+6      - RD on I/P frames
+7      - RD on all frames
+8      - RD refinement on I/P frames
+9      - RD refinement on all frames
+10     - QP-RD (requires trellis=2 and aq-mode > 0) &lt;/small&gt;</property>
+                                            <signal handler="x264_widget_changed_cb" name="changed"/>
                                           </object>
-                                          <packing>
-                                            <property name="position">1</property>
-                                          </packing>
                                         </child>
                                       </object>
                                       <packing>
-                                        <property name="position">2</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="bottom_attach">3</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label59">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Analysis:</property>
+                                      </object>
+                                      <packing>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
                                       </packing>
                                     </child>
                                     <child>
@@ -2830,19 +3076,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                         <property name="visible">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                         <child>
-                                          <object class="GtkLabel" id="label59">
-                                            <property name="visible">True</property>
-                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="xalign">0</property>
-                                            <property name="label" translatable="yes">Analysis:</property>
-                                            <property name="width_chars">14</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkAlignment" id="alignment34">
+                                          <object class="GtkAlignment" id="alignment37">
                                             <property name="visible">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                             <property name="xalign">0</property>
@@ -2852,14 +3086,14 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                                 <property name="visible">True</property>
                                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                                 <property name="tooltip-text" translatable="yes">Determines which macroblock partitions are analyzed.
-"Some" is p8x8, b8x8, i8x8, i4x4.</property>
+"Some" is recommended.  "All" is slow and generally not useful.</property>
                                                 <signal handler="x264_widget_changed_cb" name="changed"/>
                                               </object>
                                             </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="position">1</property>
+                                            <property name="position">0</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -2873,7 +3107,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                                <property name="tooltip-text" translatable="yes">High profile feature. Breaks picture into 8x8 blocks for analysis. Improves coding efficiency.</property>
+                                                <property name="tooltip-text" translatable="yes">Enables the intelligent adaptive use of 8x8 transforms in I-frames. Improves coding efficiency.</property>
                                                 <property name="label" translatable="yes">8x8dct</property>
                                                 <property name="active">True</property>
                                                 <property name="draw_indicator">True</property>
@@ -2882,12 +3116,17 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                             </child>
                                           </object>
                                           <packing>
-                                            <property name="position">2</property>
+                                            <property name="position">1</property>
                                           </packing>
                                         </child>
                                       </object>
                                       <packing>
-                                        <property name="position">3</property>
+                                        <property name="x_options">GTK_FILL</property>
+                                        <property name="y_options">GTK_FILL</property>
+                                        <property name="left_attach">1</property>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
                                       </packing>
                                     </child>
                                   </object>
@@ -2913,12 +3152,12 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label_xalign">0</property>
-                            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                            <property name="shadow_type">none</property>
                             <child>
                               <object class="GtkAlignment" id="alignment35">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="top_padding">2</property>
+                                <property name="top_padding">6</property>
                                 <property name="bottom_padding">2</property>
                                 <property name="left_padding">12</property>
                                 <property name="right_padding">2</property>
@@ -2947,7 +3186,9 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="tooltip-text" translatable="yes">Deblocking filter. Alpha: determines the strength of the deblocking action.</property>
+                                            <property name="tooltip-markup" translatable="yes">Controls the loop filter which is part of the H.264 standard.
+
+&lt;b&gt;Alpha:&lt;/b&gt; determines the strength of the deblocking action. Higher values will produce stronger 'blurring'.</property>
                                             <property name="adjustment">adjustment11</property>
                                             <signal handler="x264_widget_changed_cb" name="value_changed"/>
                                           </object>
@@ -2961,7 +3202,9 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                            <property name="tooltip-text" translatable="yes">Deblocking filter. Beta: determines when something is a block. Higher values increase sensitivity and will flag more blocks.</property>
+                                            <property name="tooltip-markup" translatable="yes">Controls the loop filter which is part of the H.264 standard. 
+
+&lt;b&gt;Beta:&lt;/b&gt; determines when something is a block. Higher values increase sensitivity and will flag more blocks.</property>
                                             <property name="adjustment">adjustment12</property>
                                             <signal handler="x264_widget_changed_cb" name="value_changed"/>
                                           </object>
@@ -3024,7 +3267,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Only use this with constant quality encoding. It increases quality but also bitrate/file size.</property>
+                                        <property name="tooltip-text" translatable="yes">Disables coefficient thresholding on P-frames. Only use this with constant quality encoding. It increases quality but also bitrate/file size.</property>
                                         <property name="label" translatable="yes">No DCT Decimate</property>
                                         <property name="active">True</property>
                                         <property name="draw_indicator">True</property>
@@ -3039,7 +3282,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                        <property name="tooltip-text" translatable="yes">Context Adaptive Binary Arithmetic Coding. Improves encoding efficiency at the expense of playback/decoding efficiency. </property>
+                                        <property name="tooltip-text" translatable="yes">Context Adaptive Binary Arithmetic Coding. Improves compression efficiency at the expense of playback/decoding efficiency. Use CABAC unless your decoder really sucks.</property>
                                         <property name="label" translatable="yes">CABAC Entropy Encoding</property>
                                         <property name="active">True</property>
                                         <property name="draw_indicator">True</property>
@@ -3049,6 +3292,78 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                                         <property name="position">4</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkTable" id="table9">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="n_rows">2</property>
+                                        <property name="n_columns">2</property>
+                                        <property name="visible">True</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label82">
+                                            <property name="visible">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">Psychovisual Rate Distortion: </property>
+                                          </object>
+                                          <packing>
+                                            <property name="x_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkHScale" id="x264_psy_rd">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">Sets the strength of Psy-RDO.
+Requires subme >= 6.</property>
+                                            <property name="adjustment">adjustment22</property>
+                                            <property name="restrict_to_fill_level">False</property>
+                                            <property name="value_pos">GTK_POS_RIGHT</property>
+                                            <signal handler="x264_widget_changed_cb" name="value_changed"/>
+                                          </object>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="label83">
+                                            <property name="visible">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">Psychovisual Trellis: </property>
+                                          </object>
+                                          <packing>
+                                            <property name="top_attach">1</property>
+                                            <property name="bottom_attach">2</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkHScale" id="x264_psy_trell">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                            <property name="tooltip-text" translatable="yes">Sets the strength of Psy-Trellis.
+Requires subme >= 6 and trellis >= 1.</property>
+                                            <property name="adjustment">adjustment23</property>
+                                            <property name="restrict_to_fill_level">False</property>
+                                            <property name="value_pos">GTK_POS_RIGHT</property>
+                                            <signal handler="x264_widget_changed_cb" name="value_changed"/>
+                                          </object>
+                                          <packing>
+                                            <property name="top_attach">1</property>
+                                            <property name="bottom_attach">2</property>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="position">5</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -3069,8 +3384,8 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
+                        <property name="expand">True</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                   </object>
@@ -3081,7 +3396,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                     <property name="label" translatable="yes">H.264</property>
                   </object>
                   <packing>
-                    <property name="position">3</property>
+                    <property name="position">4</property>
                     <property name="tab_fill">False</property>
                   </packing>
                 </child>
@@ -3096,9 +3411,10 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="tooltip-text" translatable="yes">Add chapter markers to output file.</property>
                             <property name="label" translatable="yes">Chapter Markers</property>
                             <property name="draw_indicator">True</property>
-                            <signal handler="setting_widget_changed_cb" name="toggled"/>
+                            <signal handler="chapter_markers_changed_cb" name="toggled"/>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -3146,33 +3462,79 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                     <property name="label" translatable="yes">Chapters</property>
                   </object>
                   <packing>
-                    <property name="position">4</property>
+                    <property name="position">5</property>
                     <property name="tab_fill">False</property>
                   </packing>
                 </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
             </child>
-            <child>
-              <object class="GtkLabel" id="label80">
-                <property name="height_request">1</property>
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+
               </object>
               <packing>
-                <property name="position">2</property>
+                <property name="expand">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
+
             <child>
-              <object class="GtkProgressBar" id="progressbar">
+              <object class="GtkAlignment" id="alignment66">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="text" translatable="yes"/>
-              </object>
-              <packing>
+                <property name="top_padding">4</property>
+                <property name="bottom_padding">4</property>
+                <property name="left_padding">12</property>
+                <property name="right_padding">12</property>
+                <property name="xalign">0.0</property>
+                <property name="yalign">1.0</property>
+                <child>
+                  <object class="GtkHBox" id="hbox46">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <child>
+                      <object class="GtkLabel" id="work_status">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="pending_status">
+                        <property name="visible">True</property>
+                        <property name="xalign">1</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkAlignment" id="alignment71">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="left_padding">12</property>
+                <property name="right_padding">12</property>
+                <property name="bottom_padding">6</property>
+                <child>
+                  <object class="GtkProgressBar" id="progressbar">
+                    <property name="height_request">10</property>
+                    <property name="visible">False</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="text" translatable="yes"/>
+                  </object>
+                </child>
+              </object>
+              <packing>
                 <property name="expand">False</property>
                 <property name="position">3</property>
               </packing>
@@ -3182,18 +3544,26 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
             <property name="expand">False</property>
           </packing>
         </child>
+
         <child>
-          <object class="GtkFrame" id="presets_frame">
+          <object class="GtkAlignment" id="alignment69">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="border_width">3</property>
+            <property name="top_padding">6</property>
+            <property name="right_padding">6</property>
+
+        <child>
+          <object class="GtkFrame" id="presets_frame">
+            <property name="visible">False</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <property name="label_xalign">0</property>
-            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+            <property name="shadow_type">none</property>
             <signal handler="presets_frame_size_allocate_cb" name="size_allocate"/>
             <child>
               <object class="GtkAlignment" id="alignment21">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="top_padding">6</property>
                 <property name="left_padding">8</property>
                 <child>
                   <object class="GtkVBox" id="presets_vbox">
@@ -3205,6 +3575,7 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                         <property name="can_focus">True</property>
                         <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                        <property name="shadow_type">etched-in</property>
                         <child>
                           <object class="GtkTreeView" id="presets_list">
                             <property name="width_request">206</property>
@@ -3218,105 +3589,65 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkVBox" id="vbox31">
+                      <object class="GtkToolbar" id="presets_toolbar">
+                        <property name="icon-size">2</property>
                         <property name="visible">True</property>
+                        <property name="show_arrow">False</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <child>
-                          <object class="GtkHBox" id="hbox29">
+                          <object class="GtkToolButton" id="presets_save">
+                            <property name="visible">True</property>
+                            <property name="sensitive">True</property>
+                            <property name="is_important">False</property>
+                            <property name="label" translatable="yes">_Save</property>
+                            <property name="use_underline">True</property>
+                            <property name="tooltip-text" translatable="yes">Save current settings to new preset.</property>
+                            <property name="icon_name">gtk-save</property>
+                            <signal name="clicked" handler="presets_save_clicked_cb"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkToolButton" id="presets_remove">
+                            <property name="visible">True</property>
+                            <property name="sensitive">True</property>
+                            <property name="is_important">False</property>
+                            <property name="label" translatable="yes">_Delete</property>
+                            <property name="use_underline">True</property>
+                            <property name="tooltip-text" translatable="yes">Delete the currently selected preset.</property>
+                            <property name="icon_name">gtk-delete</property>
+                            <signal name="clicked" handler="presets_remove_clicked_cb"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSeparatorToolItem" id="toolbutton2">
+                            <property name="visible">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="homogeneous">True</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkToolButton" id="presets_menu_button">
                             <property name="visible">True</property>
+                            <property name="sensitive">True</property>
+                            <property name="is_important">True</property>
+                            <property name="label" translatable="yes">_Options</property>
+                            <property name="use_underline">True</property>
+                            <property name="tooltip-text" translatable="yes">Preset Options</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <child>
-                              <object class="GtkButton" id="presets_save">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="tooltip-text" translatable="yes">Save current settings as new preset</property>
-                                <property name="relief">GTK_RELIEF_NONE</property>
-                                <signal handler="presets_save_clicked_cb" name="clicked"/>
-                                <child>
-                                  <object class="GtkImage" id="image5">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="stock">gtk-add</property>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="presets_remove">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="tooltip-text" translatable="yes">Remove the selected preset</property>
-                                <property name="relief">GTK_RELIEF_NONE</property>
-                                <signal handler="presets_remove_clicked_cb" name="clicked"/>
-                                <child>
-                                  <object class="GtkImage" id="image6">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="stock">gtk-remove</property>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label1">
-                                <property name="width_request">41</property>
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                              </object>
-                              <packing>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="presets_default">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip-text" translatable="yes">Make the current preset the default.</property>
-                                <property name="relief">GTK_RELIEF_NONE</property>
-                                <signal handler="presets_default_clicked_cb" name="clicked"/>
-                                <child>
-                                  <object class="GtkImage" id="image1">
-                                    <property name="visible">True</property>
-                                    <property name="stock">gtk-apply</property>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="position">3</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="presets_restore">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip-text" translatable="yes">Reload HandBrakes standard presets</property>
-                                <property name="relief">GTK_RELIEF_NONE</property>
-                                <signal handler="presets_restore_clicked_cb" name="clicked"/>
-                                <child>
-                                  <object class="GtkImage" id="image7">
-                                    <property name="visible">True</property>
-                                    <property name="stock">gtk-refresh</property>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="position">4</property>
-                              </packing>
-                            </child>
+                            <property name="icon_name">gtk-execute</property>
+                            <signal handler="presets_menu_clicked_cb" name="clicked"/>
                           </object>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>
@@ -3337,18 +3668,30 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
               </object>
             </child>
           </object>
+        </child>
+
+          </object>
           <packing>
             <property name="position">1</property>
           </packing>
         </child>
+
+      </object>
+      <packing>
+        <property name="position">2</property>
+      </packing>
+    </child>
+
       </object>
     </child>
+
   </object>
   <object class="GtkDialog" id="prefs_dialog">
     <property name="border_width">5</property>
+    <property name="title" translatable="yes">Preferences</property>
     <property name="modal">True</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="type_hint">dialog</property>
     <property name="skip_taskbar_hint">True</property>
     <property name="skip_pager_hint">True</property>
     <property name="has_separator">False</property>
@@ -3358,1183 +3701,2483 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child>
-          <object class="GtkHBox" id="hbox24">
+          <object class="GtkHBox" id="hbox59">
             <property name="visible">True</property>
             <child>
-              <object class="GtkVBox" id="vbox19">
+              <object class="GtkVBox" id="vbox20">
                 <property name="visible">True</property>
                 <child>
                   <object class="GtkEventBox" id="eventbox1">
                     <property name="visible">True</property>
                     <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property>
-                    <property name="visible_window">True</property>
                     <property name="above_child">True</property>
                     <signal name="button_press_event" handler="easter_egg_cb"/>
                     <child>
                       <object class="GtkImage" id="image3">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="icon_size">6</property>
                         <property name="icon_name">hb-icon</property>
+                        <property name="icon-size">6</property>
                       </object>
                     </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <placeholder/>
                 </child>
               </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
-              <object class="GtkFrame" id="frame16">
+              <object class="GtkAlignment" id="alignment22">
                 <property name="visible">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                <property name="left_padding">12</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment6">
+                  <object class="GtkNotebook" id="notebook2">
                     <property name="visible">True</property>
-                    <property name="left_padding">12</property>
+                    <property name="can_focus">True</property>
+                    <property name="show-border">False</property>
                     <child>
-                      <object class="GtkVBox" id="vbox29">
+                      <object class="GtkVBox" id="vbox42">
                         <property name="visible">True</property>
                         <child>
-                          <object class="GtkCheckButton" id="use_source_name">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text">The destination filename will be automatically
-generated from the source filename or volume
-label.</property>
-                            <property name="label" translatable="yes">Automatically generate destination</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="pref_changed_cb"/>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="chapters_in_destination">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text">Add chapter numbers to the 
-auto-generated destination name.</property>
-                            <property name="label" translatable="yes">Add chapters to destination name</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="pref_changed_cb"/>
-                          </object>
-                          <packing>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="reduce_hd_preview">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text"> Automatically reduce the size of High Definition previews.
-This is helpfull when working on laptops or similar
-non-hidef screens.  </property>
-                            <property name="label" translatable="yes">Scale down High Definition previews</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="pref_changed_cb"/>
-                          </object>
-                          <packing>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="noscale">
+                          <object class="GtkAlignment" id="alignment60">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text">When picture settings require that the image 
-dimensions be rounded to some multiple number
-of pixels. This setting will crop a few extra pixels
-instead of doing exact cropping and scaling to
-the required multiple.</property>
-                            <property name="label" translatable="yes">Loose cropping</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="pref_changed_cb"/>
+                            <property name="left_padding">12</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox80">
+                                <property name="visible">True</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkComboBox" id="check_updates">
+                                    <property name="visible">True</property>
+                                    <signal name="changed" handler="pref_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label74">
+                                    <property name="visible">True</property>
+                                    <property name="label" translatable="yes">Automatically check for updates</property>
+                                    <property name="use_markup">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                           <packing>
-                            <property name="position">3</property>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkCheckButton" id="directqp">
+                          <object class="GtkAlignment" id="alignment62">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text">HandBrake allows entry of QP/CRF values for x264 
-and FFMPEG instead of the percentage metric.
-This preference is associated with the current
-preset only.
-
-You *MUST* save the current preset to preserve
-this setting.</property>
-                            <property name="label" translatable="yes">Allow direct QP/CRF</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="vcodec_changed_cb"/>
+                            <property name="left_padding">12</property>
+                            <property name="right_padding">12</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox82">
+                                <property name="visible">True</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkComboBox" id="WhenComplete">
+                                    <property name="visible">True</property>
+                                    <signal name="changed" handler="pref_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="labela1">
+                                    <property name="visible">True</property>
+                                    <property name="label" translatable="yes">When all encodes are complete</property>
+                                    <property name="use_markup">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                           <packing>
-                            <property name="position">4</property>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkCheckButton" id="EncodeLogLocation">
+                          <object class="GtkAlignment" id="alignment5">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="tooltip_text"> HandBrake produces 2 activity logs.  
-One for the session and one for each encoding.
-Store the individual encode logs in the same
-location as the movie.</property>
-                            <property name="label" translatable="yes">Store logs in destination video directory</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="pref_changed_cb"/>
-                          </object>
-                          <packing>
-                            <property name="position">5</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="allow_tweaks">
-                            <property name="can_focus">True</property>
-                            <property name="label" translatable="yes">Allow Tweaks</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="tweaks_changed_cb"/>
-                          </object>
-                          <packing>
-                            <property name="position">6</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="hbfd_feature">
-                            <property name="can_focus">True</property>
-                            <property name="label" translatable="yes">Allow HandBrake For Dummies</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="hbfd_feature_changed_cb"/>
-                          </object>
-                          <packing>
-                            <property name="position">7</property>
+                            <property name="left_padding">12</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox5">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="use_source_name">
+                                    <property name="label" translatable="yes">Use automatic naming (uses DVD name)</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="pref_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment6">
+                                    <property name="visible">True</property>
+                                    <property name="left_padding">18</property>
+                                    <child>
+                                      <object class="GtkVBox" id="vbox29">
+                                        <property name="visible">True</property>
+                                        <child>
+                                          <object class="GtkCheckButton" id="chapters_in_destination">
+                                            <property name="label" translatable="yes">Add chapters to destination name</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkCheckButton" id="title_no_in_destination">
+                                            <property name="label" translatable="yes">Add title # to destination name</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="UseM4v">
+                                    <property name="label" translatable="yes">Use iPod/iTunes friendly (.m4v) file extension for MP4</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="use_m4v_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment50">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox66">
+                                <property name="visible">True</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkSpinButton" id="preview_count">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="max_length">2</property>
+                                    <property name="invisible_char">&#x25CF;</property>
+                                    <property name="shadow_type">none</property>
+                                    <property name="adjustment">preview_count_adj</property>
+                                    <property name="numeric">True</property>
+                                    <signal name="value_changed" handler="pref_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label77">
+                                    <property name="visible">True</property>
+                                    <property name="label" translatable="yes">Number of previews</property>
+                                    <property name="use_markup">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment64">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkCheckButton" id="show_status">
+                                <property name="label" translatable="yes">Show system tray icon</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="show_status_cb"/>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">4</property>
                           </packing>
                         </child>
                       </object>
                     </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label18">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Preferences&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area6">
-            <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="pref_ok">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="label" translatable="yes">gtk-ok</property>
-                <property name="use_stock">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-5">pref_ok</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkDialog" id="tweak_dialog">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="border_width">5</property>
-    <property name="modal">True</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox7">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkHBox" id="hbox9">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <child>
-              <object class="GtkLabel" id="label33">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Setting:</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="tweak_setting">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="max_length">40</property>
-                <property name="activates_default">True</property>
-                <property name="width_chars">30</property>
-                <property name="truncate_multiline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area7">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="tweak_cancel">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="use_stock">True</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton" id="tweak_ok">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">gtk-ok</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">tweak_cancel</action-widget>
-      <action-widget response="-5">tweak_ok</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkDialog" id="preset_save_dialog">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="border_width">5</property>
-    <property name="modal">True</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox3">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkVBox" id="vbox28">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <child>
-              <object class="GtkHBox" id="hbox41">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <child>
-                  <object class="GtkLabel" id="label64">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">Preset Name:</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="PresetName">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="max_length">40</property>
-                    <property name="activates_default">True</property>
-                    <property name="width_chars">30</property>
-                    <property name="truncate_multiline">True</property>
-                    <signal handler="preset_name_changed_cb" name="changed"/>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkFrame" id="frame14">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment36">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="top_padding">2</property>
-                    <property name="bottom_padding">4</property>
-                    <property name="left_padding">12</property>
-                    <property name="right_padding">4</property>
+                    <child type="tab">
+                      <object class="GtkLabel" id="label2">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">General</property>
+                      </object>
+                      <packing>
+                        <property name="tab_fill">False</property>
+                      </packing>
+                    </child>
                     <child>
-                      <object class="GtkTextView" id="PresetDescription">
-                        <property name="height_request">60</property>
+                      <object class="GtkVBox" id="vbox18">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="wrap_mode">GTK_WRAP_WORD</property>
-                        <property name="accepts_tab">False</property>
+                        <child>
+                          <object class="GtkAlignment" id="alignment61">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="yscale">0</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox7">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox81">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="spacing">4</property>
+                                    <child>
+                                      <object class="GtkLabel" id="label87">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <property name="label" translatable="yes">Preferred Language:</property>
+                                        <property name="use_markup">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkComboBox" id="PreferredLanguage">
+                                        <property name="width_request">150</property>
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <signal name="changed" handler="pref_changed_cb"/>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment8">
+                                    <property name="visible">True</property>
+                                    <property name="left_padding">17</property>
+                                    <child>
+                                      <object class="GtkVBox" id="vbox49">
+                                        <property name="visible">True</property>
+                                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                        <child>
+                                          <object class="GtkRadioButton" id="AudioDUB">
+                                            <property name="label" translatable="yes">DUB Foreign language audio</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkRadioButton" id="NotAudioDUB">
+                                            <property name="label" translatable="yes">Use foreign language audio and add subtitles</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="draw_indicator">True</property>
+                                            <property name="group">AudioDUB</property>
+                                            <signal name="toggled" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment70">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="yscale">0</property>
+                            <property name="left_padding">12</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <child>
+                              <object class="GtkCheckButton" id="AddCC">
+                                <property name="label" translatable="yes">Add Closed Captions when available</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="pref_changed_cb"/>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
                       </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label67">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="padding">2</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHBox" id="hbox43">
-                <property name="visible">True</property>
-                <child>
-                  <object class="GtkRadioButton" id="preset_type_folder">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Folder</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="preset_type_changed_cb"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="preset_type_normal">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Preset</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">preset_type_folder</property>
-                    <signal name="toggled" handler="preset_type_changed_cb"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area3">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="preset_cancel">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="use_stock">True</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton" id="preset_ok">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">gtk-ok</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">preset_cancel</action-widget>
-      <action-widget response="-5">preset_ok</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkWindow" id="activity_window">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="skip_pager_hint">True</property>
-    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <child>
-      <object class="GtkVBox" id="vbox37">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <object class="GtkLabel" id="activity_location">
-            <property name="justify">GTK_JUSTIFY_LEFT</property>
-            <property name="visible">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
+                    <child type="tab">
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Audio/Subtitles</property>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                        <property name="tab_fill">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkVBox" id="vbox1">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkAlignment" id="alignment3">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox3">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox6">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">4</property>
+                                    <child>
+                                      <object class="GtkComboBox" id="VideoQualityGranularity">
+                                        <property name="width_request">55</property>
+                                        <property name="visible">True</property>
+                                        <signal name="changed" handler="vqual_granularity_changed_cb"/>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label85">
+                                        <property name="visible">True</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label" translatable="yes">Constant Quality fractional granularity</property>
+                                      </object>
+                                      <packing>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment2">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkCheckButton" id="use_dvdnav">
+                                <property name="label" translatable="yes">Use dvdnav (instead of libdvdread)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="pref_changed_cb"/>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment17">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox2">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="EncodeLogLocation">
+                                    <property name="label" translatable="yes">Put individual encode logs in same location as movie</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="pref_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment51">
+                                    <property name="visible">True</property>
+                                    <property name="left_padding">21</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox50">
+                                        <property name="visible">True</property>
+                                        <property name="spacing">4</property>
+                                        <child>
+                                          <object class="GtkComboBox" id="LoggingLevel">
+                                            <property name="width_request">55</property>
+                                            <property name="visible">True</property>
+                                            <signal name="changed" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="label1">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Activity Log Verbosity Level</property>
+                                          </object>
+                                          <packing>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkAlignment" id="alignment63">
+                                    <property name="visible">True</property>
+                                    <property name="left_padding">21</property>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox83">
+                                        <property name="visible">True</property>
+                                        <property name="spacing">4</property>
+                                        <child>
+                                          <object class="GtkComboBox" id="LogLongevity">
+                                            <property name="visible">True</property>
+                                            <signal name="changed" handler="pref_changed_cb"/>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="labela2">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Activity Log Longevity</property>
+                                          </object>
+                                          <packing>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment49">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkCheckButton" id="reduce_hd_preview">
+                                <property name="label" translatable="yes">Scale down High Definition previews</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="pref_changed_cb"/>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="alignment48">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkCheckButton" id="AutoScan">
+                                <property name="label" translatable="yes">Automatically Scan DVD when loaded</property>
+                                <property name="tooltip-text" translatable="yes">Scans the DVD whenever a new disc is loaded</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="pref_changed_cb"/>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkAlignment" id="hidden_prefs">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox4">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="allow_tweaks">
+                                    <property name="label" translatable="yes">Allow Tweaks</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="tweaks_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="hbfd_feature">
+                                    <property name="label" translatable="yes">Allow HandBrake For Dummies</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="hbfd_feature_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">5</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child type="tab">
+                      <object class="GtkLabel" id="label36">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Advanced</property>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                        <property name="tab_fill">False</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
             <property name="position">1</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkScrolledWindow" id="activity_scroll">
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area5">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <property name="shadow_type">GTK_SHADOW_IN</property>
+            <property name="layout_style">end</property>
             <child>
-              <object class="GtkTextView" id="activity_view">
-                <property name="width_request">400</property>
-                <property name="height_request">500</property>
+              <object class="GtkButton" id="pref_ok">
+                <property name="label" translatable="yes">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="editable">False</property>
-                <property name="cursor-visible">False</property>
-                <property name="wrap_mode">GTK_WRAP_CHAR</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
             </child>
           </object>
           <packing>
-            <property name="position">2</property>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
-        <child>
-          <placeholder/>
-        </child>
       </object>
     </child>
+    <action-widgets>
+      <action-widget response="-5">pref_ok</action-widget>
+    </action-widgets>
   </object>
-  <object class="GtkWindow" id="queue_window">
+  <object class="GtkDialog" id="tweak_dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="title" translatable="yes">HandBrake Queue</property>
-    <property name="icon_name">hb-queue</property>
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
     <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="skip_pager_hint">True</property>
+    <property name="has_separator">False</property>
     <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <child>
-      <object class="GtkVBox" id="vbox34">
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox7">
         <property name="visible">True</property>
         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
         <child>
-          <object class="GtkToolbar" id="queue_toolbar">
+          <object class="GtkHBox" id="hbox9">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <child>
-              <object class="GtkToolButton" id="queue_start2">
+              <object class="GtkLabel" id="label33">
                 <property name="visible">True</property>
-                <property name="sensitive">False</property>
-                <property name="label" translatable="yes">Start</property>
-                <property name="icon_name">hb-play</property>
-                <signal handler="queue_start_clicked_cb" name="clicked"/>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Setting:</property>
               </object>
               <packing>
                 <property name="expand">False</property>
               </packing>
             </child>
             <child>
-              <object class="GtkToolButton" id="queue_pause2">
+              <object class="GtkEntry" id="tweak_setting">
                 <property name="visible">True</property>
-                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Pause</property>
-                <property name="icon_name">hb-pause</property>
-                <signal handler="queue_pause_clicked_cb" name="clicked"/>
+                <property name="max_length">40</property>
+                <property name="activates_default">True</property>
+                <property name="width_chars">30</property>
+                <property name="truncate_multiline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area7">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <object class="GtkButton" id="tweak_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
             <child>
-              <object class="GtkToolButton" id="queue_stop">
+              <object class="GtkButton" id="tweak_ok">
                 <property name="visible">True</property>
-                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Stop</property>
-                <property name="icon_name">hb-stop</property>
-                <signal handler="queue_stop_clicked_cb" name="clicked"/>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
-                <property name="expand">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">tweak_cancel</action-widget>
+      <action-widget response="-5">tweak_ok</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="preset_save_dialog">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox3">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox28">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <child>
-              <object class="GtkToolButton" id="queue_edit">
+              <object class="GtkHBox" id="hbox41">
                 <property name="visible">True</property>
-                <property name="sensitive">False</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Edit</property>
-                <property name="icon_name">hb-edit</property>
-                <signal handler="queue_edit_clicked_cb" name="clicked"/>
+                <child>
+                  <object class="GtkLabel" id="label64">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">Preset Name:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="PresetName">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="max_length">40</property>
+                    <property name="activates_default">True</property>
+                    <property name="width_chars">30</property>
+                    <property name="truncate_multiline">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkFrame" id="frame14">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment36">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="top_padding">6</property>
+                    <property name="bottom_padding">4</property>
+                    <property name="left_padding">12</property>
+                    <property name="right_padding">4</property>
+                    <child>
+                      <object class="GtkTextView" id="PresetDescription">
+                        <property name="height_request">60</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="wrap_mode">GTK_WRAP_WORD</property>
+                        <property name="accepts_tab">False</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label67">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Description&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="padding">2</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area3">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <object class="GtkButton" id="preset_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="preset_ok">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">preset_cancel</action-widget>
+      <action-widget response="-5">preset_ok</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkWindow" id="activity_window">
+    <property name="visible">False</property>
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="transient-for">hb_window</property>
+    <signal handler="activity_window_delete_cb" name="delete_event"/>
+    <child>
+      <object class="GtkVBox" id="vbox37">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkLabel" id="activity_location">
+            <property name="justify">GTK_JUSTIFY_LEFT</property>
+            <property name="visible">True</property>
           </object>
           <packing>
+            <property name="padding">5</property>
             <property name="expand">False</property>
+            <property name="position">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox38">
+          <object class="GtkScrolledWindow" id="activity_scroll">
             <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <property name="shadow_type">GTK_SHADOW_IN</property>
             <child>
-              <object class="GtkLabel" id="current_encode">
+              <object class="GtkTextView" id="activity_view">
+                <property name="width_request">600</property>
+                <property name="height_request">600</property>
                 <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="editable">False</property>
+                <property name="cursor-visible">False</property>
+                <property name="wrap_mode">GTK_WRAP_CHAR</property>
               </object>
             </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="queue_window">
+    <property name="visible">False</property>
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="title" translatable="yes">HandBrake Queue</property>
+    <property name="icon_name">hb-queue</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="transient-for">hb_window</property>
+    <signal handler="queue_window_delete_cb" name="delete_event"/>
+    <child>
+      <object class="GtkVBox" id="vbox34">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <child>
+          <object class="GtkToolbar" id="queue_toolbar">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <child>
-              <object class="GtkHBox" id="hbox28">
+              <object class="GtkToolButton" id="queue_start2">
                 <property name="visible">True</property>
-                <child>
+                <property name="sensitive">False</property>
+                <property name="is_important">True</property>
+                <property name="label" translatable="yes">Start</property>
+                <property name="icon_name">hb-play</property>
+                <signal handler="queue_start_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="queue_pause2">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="sensitive">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Pause</property>
+                <property name="icon_name">hb-pause</property>
+                <signal handler="queue_pause_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="queue_edit">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="sensitive">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">Edit</property>
+                <property name="icon_name">hb-edit</property>
+                <signal handler="queue_edit_clicked_cb" name="clicked"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox38">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkLabel" id="current_encode">
+                <property name="visible">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox28">
+                <property name="visible">True</property>
+                <child>
                   <object class="GtkLabel" id="queue_status">
                     <property name="justify">GTK_JUSTIFY_LEFT</property>
                     <property name="visible">True</property>
                   </object>
                   <packing>
-                    <property name="padding">10</property>
+                    <property name="padding">10</property>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+            <property name="expand">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow2">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <child>
+              <object class="GtkTreeView" id="queue_list">
+                <property name="width_request">900</property>
+                <property name="height_request">300</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="headers_visible">False</property>
+                <property name="headers_clickable">False</property>
+                <property name="hover_expand">False</property>
+                <signal handler="queue_key_press_cb" name="key-press-event"/>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+            <property name="expand">True</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="settings_window">
+    <property name="visible">False</property>
+    <property name="title" translatable="yes">Picture Settings</property>
+    <property name="window_position">GTK_WIN_POS_NONE</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="allow-grow">False</property>
+    <property name="transient-for">preview_window</property>
+    <property name="events">GDK_STRUCTURE_MASK</property>
+    <signal handler="settings_configure_cb" name="configure-event"/>
+    <signal handler="settings_window_delete_cb" name="delete_event"/>
+    <child>
+      <object class="GtkVBox" id="vbox40">
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkCheckButton" id="show_preview">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="tooltip-text" translatable="yes">Open Preview Window</property>
+            <property name="label" translatable="yes">Show Preview</property>
+            <signal name="toggled" handler="preview_button_clicked_cb"/>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+
+        <child>
+          <object class="GtkAlignment" id="alignment54">
+            <property name="visible">True</property>
+            <property name="top_padding">6</property>
+            <property name="bottom_padding">6</property>
+            <child>
+              <object class="GtkHBox" id="hbox75">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkFrame" id="Cropping2">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment46">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">6</property>
+                        <property name="bottom_padding">2</property>
+                        <property name="left_padding">12</property>
+                        <property name="right_padding">2</property>
+
+                    <child>
+                      <object class="GtkVBox" id="vbox6">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <child>
+                          <object class="GtkTable" id="table2">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="n_rows">5</property>
+                            <property name="n_columns">6</property>
+                            <child>
+                              <object class="GtkSpinButton" id="PictureLeftCrop">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Left Crop</property>
+                                <property name="adjustment">adjustment13</property>
+                                <signal name="value_changed" handler="crop_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="right_attach">1</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options"></property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="PictureTopCrop">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Top Crop</property>
+                                <property name="adjustment">adjustment14</property>
+                                <signal name="value_changed" handler="crop_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">0</property>
+                                <property name="bottom_attach">1</property>
+                                <property name="x_options"></property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="PictureBottomCrop">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Bottom Crop</property>
+                                <property name="adjustment">adjustment15</property>
+                                <signal name="value_changed" handler="crop_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                                <property name="x_options"></property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="PictureRightCrop">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Right Crop</property>
+                                <property name="adjustment">adjustment16</property>
+                                <signal name="value_changed" handler="crop_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options"></property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="PictureAutoCrop">
+                                <property name="label" translatable="yes">Auto Crop</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">Automatically crop black borders around edges of the video.</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="scale_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="y_options"></property>
+                                <property name="left_attach">0</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="PictureLooseCrop">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="tooltip_text">When picture settings require that the image 
+dimensions be rounded to some multiple number
+of pixels. This setting will crop a few extra pixels
+instead of doing exact cropping and then scaling to
+the required multiple.</property>
+                                <property name="label" translatable="yes">Loose Crop</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="scale_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="y_options"></property>
+                                <property name="left_attach">0</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">4</property>
+                                <property name="bottom_attach">5</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox78">
+                            <property name="visible">True</property>
+                            <property name="spacing">4</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <child>
+                              <object class="GtkLabel" id="label97">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Crop Dimensions:</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="crop_dimensions2">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="label" translatable="yes">--</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label26">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Cropping&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame3">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment4">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">6</property>
+                        <property name="bottom_padding">2</property>
+                        <property name="left_padding">12</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox30">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox51">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkLabel" id="label27">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">width:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="scale_width">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">This is the width that the video will be stored at.  The actual display dimensions will differ if the pixel aspect ratio is not 1:1.</property>
+                                    <property name="adjustment">adjustment17</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <signal name="value_changed" handler="scale_width_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label28">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">height:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="scale_height">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">This is the height that the video will be stored at.  The actual display dimensions will differ if the pixel aspect ratio is not 1:1.</property>
+                                    <property name="adjustment">adjustment18</property>
+                                    <signal name="value_changed" handler="scale_height_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox71">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="autoscale">
+                                    <property name="label" translatable="yes">Optimal for source</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="tooltip-text" translatable="yes">If enabled, select the 'optimal' storage resolution.  This will be the resolution that most closely matches the source resolution after cropping.</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="scale_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox20">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">5</property>
+                                <child>
+                                  <object class="GtkLabel" id="label96">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Anamorphic:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="PicturePAR">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-markup" translatable="yes">&lt;b&gt;Anamorphic Modes:&lt;/b&gt;
+&lt;small&gt;&lt;tt&gt;
+None   - Force pixel aspect ration to 1:1.
+Loose  - Align dimensions to chosen 'Alignment' value 
+         and pick pixel aspect ratio that preserves the
+         original display aspect ratio
+Strict - Keep original source dimensions and pixel 
+         aspect ratio&lt;/tt&gt;&lt;/small&gt;</property>
+                                    <signal name="changed" handler="scale_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox72">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">5</property>
+                                <child>
+                                  <object class="GtkLabel" id="label95">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Alignment:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="PictureModulus">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Align storage dimensions to multiples of this value.
+
+Encoders are most effecient when the video dimensions are aligned to some specific value (usually 16). Setting this to some other value will result in slightly larger file size.</property>
+                                    <signal name="changed" handler="scale_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label25">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Storage&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame" id="frame4">
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment7">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="top_padding">6</property>
+                        <property name="bottom_padding">2</property>
+                        <property name="left_padding">12</property>
+                        <property name="right_padding">2</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox10">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <object class="GtkHBox" id="hbox52">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkLabel" id="label91">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">width:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="PictureDisplayWidth">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">This is the display width. It is the result of scaling the storage dimensions by the pixel aspect.</property>
+                                    <property name="adjustment">adjustment25</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <signal name="value_changed" handler="display_width_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label92">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">height:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="PictureDisplayHeight">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="adjustment">adjustment26</property>
+                                    <signal name="value_changed" handler="display_height_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox79">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkLabel" id="label98">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Pixel Aspect:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="PicturePARWidth">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Pixel aspect defines the shape of the pixels. A 1:1 ratio defines a square pixel.  Other values define rectangular shapes. Players will scale the image in order to achieve the specified aspect.</property>
+                                    <property name="adjustment">adjustment29</property>
+                                    <property name="snap_to_ticks">True</property>
+                                    <signal name="value_changed" handler="par_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label99">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="PicturePARHeight">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">Pixel aspect defines the shape of the pixels. A 1:1 ratio defines a square pixel.  Other values define rectangular shapes. Players will scale the image in order to achieve the specified aspect.</property>
+                                    <property name="adjustment">adjustment30</property>
+                                    <signal name="value_changed" handler="par_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="PictureKeepRatio">
+                                <property name="label" translatable="yes">Keep Aspect</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="tooltip-text" translatable="yes">If enabled, the original display aspect of the source will be maintained.</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="scale_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkHBox" id="hbox53">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <object class="GtkLabel" id="label93">
+                                    <property name="width_request">100</property>
+                                    <property name="xalign">0</property>
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">Display Aspect:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="display_aspect">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">--:--</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label29">
+                        <property name="visible">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Display&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
                     <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-            <property name="expand">False</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow2">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <child>
-              <object class="GtkTreeView" id="queue_list">
-                <property name="width_request">900</property>
-                <property name="height_request">300</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="headers_visible">False</property>
-                <property name="headers_clickable">False</property>
-                <property name="hover_expand">False</property>
-                <signal handler="queue_key_press_cb" name="key-press-event"/>
               </object>
             </child>
           </object>
-          <packing>
-            <property name="position">2</property>
-            <property name="expand">True</property>
-          </packing>
         </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-  </object>
-  <object class="GtkWindow" id="preview_window">
-    <property name="title" translatable="yes">Preview</property>
-    <property name="window_position">GTK_WIN_POS_CENTER</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="skip_pager_hint">True</property>
-    <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
-    <child>
-      <object class="GtkVBox" id="vbox32">
-        <property name="visible">True</property>
-        <child>
-          <object class="GtkFrame" id="frame15">
-            <property name="visible">True</property>
-            <property name="label_xalign">0</property>
-            <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
-            <child>
-              <object class="GtkAlignment" id="alignment22">
-                <property name="visible">True</property>
-                <property name="top_padding">4</property>
-                <property name="bottom_padding">4</property>
-                <property name="left_padding">12</property>
-                <property name="right_padding">4</property>
-                <child>
-                  <object class="GtkImage" id="preview_image">
-                    <property name="visible">True</property>
-                    <property name="icon_name">hb-icon</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child type="label">
-              <object class="GtkLabel" id="label56">
+            <child type="tab">
+              <object class="GtkLabel" id="label79">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">&lt;b&gt;Preview&lt;/b&gt;</property>
-                <property name="use_markup">True</property>
+                <property name="label" translatable="yes">Dimensions</property>
               </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
             </child>
-          </object>
-        </child>
+
         <child>
-          <object class="GtkHBox" id="hbox8">
+          <object class="GtkAlignment" id="alignment43">
             <property name="visible">True</property>
+            <property name="top_padding">6</property>
+            <property name="bottom_padding">6</property>
+            <property name="left_padding">6</property>
+            <property name="right_padding">6</property>
             <child>
-              <object class="GtkFrame" id="Cropping3">
+              <object class="GtkHBox" id="hbox77">
                 <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment24">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="top_padding">2</property>
-                    <property name="bottom_padding">2</property>
-                    <property name="left_padding">12</property>
-                    <property name="right_padding">2</property>
-                    <child>
-                      <object class="GtkVBox" id="vbox39">
-                        <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="spacing">16</property>
                         <child>
-                          <object class="GtkAlignment" id="alignment37">
+                          <object class="GtkVBox" id="vbox8">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="xalign">0.34000000357627869</property>
-                            <property name="xscale">0.37999999523162842</property>
                             <child>
-                              <object class="GtkTable" id="table6">
+                              <object class="GtkCheckButton" id="VideoGrayScale">
+                                <property name="label" translatable="yes">Grayscale</property>
                                 <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="n_rows">5</property>
-                                <property name="n_columns">5</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
+                                <property name="tooltip-text" translatable="yes">If enabled, filter colour components out of video.</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="setting_widget_changed_cb"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkAlignment" id="alignment27">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xscale">0</property>
+
+                            <child>
+                              <object class="GtkTable" id="table90">
+                                <property name="visible">True</property>
+                                <property name="n_rows">3</property>
+                                <property name="n_columns">2</property>
+                                <property name="column_spacing">5</property>
+
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkLabel" id="label41">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Deblock:</property>
+                                  </object>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkHScale" id="PictureDeblock">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="adjustment">adjustment20</property>
+                                    <property name="digits">0</property>
+                                    <property name="value_pos">right</property>
+                                    <property name="tooltip-text" translatable="yes">The deblocking filter removes a common type of compression artifact. If your source exhibits 'blockiness', this filter may help clean it up.</property>
+                                    <signal name="value_changed" handler="setting_widget_changed_cb"/>
+                                    <signal name="format_value" handler="format_deblock_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                  </packing>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkLabel" id="label32">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Denoise:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                  </packing>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkComboBox" id="PictureDenoise">
+                                    <property name="width_request">100</property>
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">The denoise filter is a low pass filter that removes noise. Film grain and other types of high frequency noise are difficult to compress. Using this filter on such sources can result in smaller file sizes.</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                  </packing>
                                 </child>
                                 <child>
                                   <placeholder/>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkEntry" id="PictureDenoiseCustom">
+                                    <property name="width_chars">8</property>
+                                    <property name="tooltip-text" translatable="yes">Custom denoise filter string format
+       SpatialLuma:SpatialChroma:TemporalLuma:TemporalChroma</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">2</property>
+                                    <property name="bottom_attach">3</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                  </packing>
                                 </child>
+                              </object>
+                            </child>
+
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="padding">2</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox39">
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment45">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="yalign">0</property>
+                                <property name="xscale">0</property>
+                                <property name="yscale">0</property>
+
+                            <child>
+                              <object class="GtkTable" id="table10">
+                                <property name="visible">True</property>
+                                <property name="n_rows">7</property>
+                                <property name="n_columns">2</property>
+                                <property name="column_spacing">5</property>
+
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkLabel" id="label86">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Detelecine:</property>
+                                  </object>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkComboBox" id="PictureDetelecine">
+                                    <property name="width_request">100</property>
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="tooltip-text" translatable="yes">This filter removes 'combing' artifacts that are the result of telecining. Telecining is a process that adjusts film framerates that are 24fps to NTSC video frame rates which are 30fps.</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">0</property>
+                                    <property name="bottom_attach">1</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                  </packing>
                                 </child>
                                 <child>
                                   <placeholder/>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkEntry" id="PictureDetelecineCustom">
+                                    <property name="width_chars">8</property>
+                                    <property name="tooltip-text" translatable="yes">Custom detelecine filter string format
+       JunkLeft:JunkRight:JunkTop:JunkBottom:StrictBreaks:MetricPlane:Parity</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                  </packing>
                                 </child>
+
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkRadioButton" id="PictureDecombDeinterlace">
+                                    <property name="label" translatable="yes">Decomb</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="tooltip-text" translatable="yes">Choose decomb or deinterlace filter options.
+
+The decomb filter selectively deinterlaces frames that appear to be interlaced.  This will preserve quality in frames that are not interlaced.
+
+The classic deinterlace filter is applied to all frames. Frames that are not interlaced will suffer some quality degradation.</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <signal name="toggled" handler="setting_widget_changed_cb"/>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">2</property>
+                                    <property name="bottom_attach">3</property>
+                                  </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkLabel" id="label77">
+                                  <object class="GtkRadioButton" id="PictureDeinterlaceDecomb">
+                                    <property name="label" translatable="yes">Deinterlace</property>
                                     <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="label" translatable="yes">Left</property>
-                                    <property name="width_chars">4</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="tooltip-text" translatable="yes">Choose decomb or deinterlace filter options.
+
+The decomb filter selectively deinterlaces frames that appear to be interlaced.  This will preserve quality in frames that are not interlaced.
+
+The classic deinterlace filter is applied to all frames. Frames that are not interlaced will suffer some quality degradation.</property>
+                                    <property name="draw_indicator">True</property>
+                                    <property name="group">PictureDecombDeinterlace</property>
                                   </object>
                                   <packing>
                                     <property name="top_attach">2</property>
                                     <property name="bottom_attach">3</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkLabel" id="label74">
+                                  <object class="GtkLabel" id="PictureDecombLabel">
                                     <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="yalign">1</property>
-                                    <property name="label" translatable="yes">Top</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Decomb:</property>
                                   </object>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkSpinButton" id="PictureLeftCrop">
+                                  <object class="GtkComboBox" id="PictureDecomb">
+                                    <property name="width_request">100</property>
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="adjustment">adjustment13</property>
-                                    <signal handler="crop_changed_cb" name="value_changed"/>
+                                    <property name="tooltip-text" translatable="yes">The decomb filter selectively deinterlaces frames that appear to be interlaced.  This will preserve quality in frames that are not interlaced.</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
                                   </object>
                                   <packing>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
                                     <property name="left_attach">1</property>
                                     <property name="right_attach">2</property>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
-                                    <property name="x_options"/>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkLabel" id="label73">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">Bottom</property>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <object class="GtkEntry" id="PictureDecombCustom">
+                                    <property name="width_chars">8</property>
+                                    <property name="tooltip-text" translatable="yes">Custom decomb filter string format
+       Mode:SpatialMetric:MotionThresh:SpatialThresh:BlockThresh:BlockWidth:BlockHeight:MagnitudeThres:VarianceThres:LaplacianThresh:DilationThresh:ErosionThresh:NoiseThresh:MaxSearchDistance:PostProcessing:Parity</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
                                     <property name="top_attach">4</property>
                                     <property name="bottom_attach">5</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
                                   </packing>
                                 </child>
+
                                 <child>
-                                  <object class="GtkSpinButton" id="PictureTopCrop">
+                                  <object class="GtkLabel" id="PictureDeinterlaceLabel">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="adjustment">adjustment14</property>
-                                    <signal handler="crop_changed_cb" name="value_changed"/>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Deinterlace:</property>
                                   </object>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
-                                    <property name="x_options"/>
+                                    <property name="top_attach">5</property>
+                                    <property name="bottom_attach">6</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkSpinButton" id="PictureBottomCrop">
+                                  <object class="GtkComboBox" id="PictureDeinterlace">
+                                    <property name="width_request">100</property>
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="adjustment">adjustment15</property>
-                                    <signal handler="crop_changed_cb" name="value_changed"/>
+                                    <property name="tooltip-text" translatable="yes">The classic deinterlace filter is applied to all frames. Frames that are not interlaced will suffer some quality degradation.</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
-                                    <property name="top_attach">3</property>
-                                    <property name="bottom_attach">4</property>
-                                    <property name="x_options"/>
+                                    <property name="top_attach">5</property>
+                                    <property name="bottom_attach">6</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkSpinButton" id="PictureRightCrop">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="adjustment">adjustment16</property>
-                                    <signal handler="crop_changed_cb" name="value_changed"/>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">3</property>
-                                    <property name="right_attach">4</property>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
-                                    <property name="x_options"/>
-                                  </packing>
+                                  <placeholder/>
                                 </child>
                                 <child>
-                                  <object class="GtkLabel" id="label72">
-                                    <property name="visible">True</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                    <property name="label" translatable="yes">Right</property>
-                                    <property name="width_chars">4</property>
+                                  <object class="GtkEntry" id="PictureDeinterlaceCustom">
+                                    <property name="width_chars">8</property>
+                                    <property name="tooltip-text" translatable="yes">Custom deinterlace filter string format
+       YadifMode:YadifParity:McdintMode:McdeintQp</property>
+                                    <signal name="changed" handler="setting_widget_changed_cb"/>
                                   </object>
                                   <packing>
-                                    <property name="left_attach">4</property>
-                                    <property name="right_attach">5</property>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
+                                    <property name="top_attach">6</property>
+                                    <property name="bottom_attach">7</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
                                   </packing>
                                 </child>
                               </object>
                             </child>
+
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="PictureAutoCrop">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="label" translatable="yes">Auto Crop</property>
-                            <property name="draw_indicator">True</property>
-                            <signal handler="scale_changed_cb" name="toggled"/>
-                          </object>
-                          <packing>
+                            <property name="padding">2</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label82">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Cropping&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+
+            <child type="tab">
+              <object class="GtkLabel" id="label81">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Filters</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="padding">2</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+
+  <object class="GtkAlignment" id="preview_image_align">
+    <property name="visible">True</property>
+    <property name="xalign">.5</property>
+    <property name="yalign">.5</property>
+    <property name="xscale">0</property>
+    <property name="yscale">0</property>
+    <child>
+      <object class="GtkDrawingArea" id="preview_image">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK</property>
+        <property name="app_paintable">True</property>
+        <signal name="motion-notify-event" handler="preview_motion_cb"/>
+        <signal name="leave-notify-event" handler="preview_leave_cb"/>
+      </object>
+    </child>
+  </object>
+
+  <object class="GtkAlignment" id="preview_hud">
+    <property name="visible">False</property>
+    <property name="xalign">.5</property>
+    <property name="yalign">.9</property>
+    <property name="xscale">0</property>
+    <property name="yscale">0</property>
+    <child>
+      <object class="GtkEventBox" id="preview_event_box">
+        <property name="visible">True</property>
+        <property name="app-paintable">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
+        <signal name="enter-notify-event" handler="hud_enter_cb"/>
+        <signal handler="preview_hud_size_alloc_cb" name="size-allocate"/>
+        <child>
+          <object class="GtkAlignment" id="alignment53">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="left_padding">10</property>
+            <property name="right_padding">10</property>
+            <property name="top_padding">5</property>
+            <property name="bottom_padding">5</property>
             <child>
-              <object class="GtkFrame" id="frame19">
+              <object class="GtkVBox" id="vbox35">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment43">
+                  <object class="GtkHScale" id="preview_frame">
                     <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="top_padding">2</property>
-                    <property name="bottom_padding">2</property>
-                    <property name="left_padding">12</property>
-                    <property name="right_padding">2</property>
+                    <property name="can_focus">True</property>
+                    <property name="adjustment">adjustment19</property>
+                    <property name="digits">0</property>
+                    <property name="value_pos">bottom</property>
+                    <property name="tooltip-text" translatable="yes">Select preview frames.</property>
+                    <signal name="value_changed" handler="preview_frame_value_changed_cb"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox70">
+                    <property name="visible">True</property>
+                    <property name="spacing">5</property>
                     <child>
-                      <object class="GtkVBox" id="vbox41">
+                      <object class="GtkButton" id="live_preview_play">
+                        <property name="height_request">30</property>
                         <property name="visible">True</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkHBox" id="hbox50">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <child>
-                              <object class="GtkLabel" id="label85">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">width:</property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkSpinButton" id="scale_width">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="adjustment">adjustment17</property>
-                                <property name="snap_to_ticks">True</property>
-                                <signal handler="scale_width_changed_cb" name="value_changed"/>
-                              </object>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label86">
-                                <property name="visible">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="label" translatable="yes">height:</property>
-                              </object>
-                              <packing>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkSpinButton" id="scale_height">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="adjustment">adjustment18</property>
-                                <signal handler="scale_height_changed_cb" name="value_changed"/>
-                              </object>
-                              <packing>
-                                <property name="position">3</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox51">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <child>
-                              <object class="GtkCheckButton" id="autoscale">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="label" translatable="yes">Optimal for source</property>
-                                <property name="draw_indicator">True</property>
-                                <signal handler="scale_changed_cb" name="toggled"/>
-                              </object>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="relief">none</property>
+                        <property name="tooltip-text" translatable="yes">Encode and play a short sequence of video starting from the current preview position.</property>
+                        <signal name="clicked" handler="live_preview_start_cb"/>
                         <child>
-                          <object class="GtkHBox" id="hbox52">
+                          <object class="GtkImage" id="live_preview_play_image">
                             <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <child>
-                              <object class="GtkCheckButton" id="ModDimensions">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="tooltip-text" translatable="yes">Constrain dimensions to multiples of 16. 
-If not checked, encoding efficiency may be reduced.</property>
-                                <property name="label" translatable="yes">Align Dimensions (mod 16)</property>
-                                <property name="draw_indicator">True</property>
-                                <signal handler="scale_changed_cb" name="toggled"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                              </packing>
-                            </child>
+                            <property name="stock">gtk-media-play</property>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">2</property>
-                          </packing>
                         </child>
-                        <child>
-                          <object class="GtkHBox" id="hbox53">
-                            <property name="visible">True</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="spacing">45</property>
-                            <child>
-                              <object class="GtkCheckButton" id="anamorphic">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="tooltip-text" translatable="yes">Allow non-square pixels. Pixel aspect ratio will be
-adjusted to keep the video's original aspect ratio.</property>
-                                <property name="label" translatable="yes">Anamorphic</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                                <signal handler="scale_changed_cb" name="toggled"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="PictureKeepRatio">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="tooltip-text" translatable="yes">Changing either dimension automatically adjusts
-the other to maintain the video's original aspect ratio.</property>
-                                <property name="label" translatable="yes">Keep Aspect</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                                <signal handler="scale_changed_cb" name="toggled"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHScale" id="live_preview_progress">
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">preview_progress_adj</property>
+                        <property name="draw_value">False</property>
+                        <property name="value_pos">right</property>
+                        <signal name="value_changed" handler="live_preview_seek_cb"/>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkVBox" id="live_progress_box">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkLabel" id="label71">
+                            <property name="height_request">1</property>
+                            <property name="visible">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkProgressBar" id="live_encode_progress">
+                            <property name="height_request">20</property>
+                            <property name="visible">True</property>
+                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
-                            <property name="position">3</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="label72">
+                            <property name="height_request">1</property>
+                            <property name="visible">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
                     </child>
                   </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label87">
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Scaling&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="padding">2</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox42">
-                <property name="visible">True</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment6">
+                  <object class="GtkHBox" id="hbox26">
                     <property name="visible">True</property>
-                    <property name="xscale">0</property>
+                    <property name="spacing">10</property>
                     <child>
-                      <object class="GtkHBox" id="hbox45">
+                      <object class="GtkHBox" id="hbox60">
                         <property name="visible">True</property>
+                        <property name="spacing">2</property>
                         <child>
-                          <object class="GtkLabel" id="label18">
+                          <object class="GtkLabel" id="label37">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;b&gt;Frame&lt;/b&gt;</property>
+                            <property name="label" translatable="yes">&lt;b&gt;Duration:&lt;/b&gt;</property>
                             <property name="use_markup">True</property>
                           </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
                         </child>
                         <child>
-                          <object class="GtkSpinButton" id="preview_frame">
+                          <object class="GtkSpinButton" id="live_duration">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="tooltip-text" translatable="yes">View other frames</property>
-                            <property name="max_length">2</property>
-                            <property name="has_frame">False</property>
-                            <property name="shadow_type">GTK_SHADOW_NONE</property>
-                            <property name="adjustment">adjustment19</property>
+                            <property name="adjustment">adjustment21</property>
                             <property name="numeric">True</property>
-                            <signal handler="preview_frame_value_changed_cb" name="value_changed"/>
+                            <property name="tooltip-text" translatable="yes">Set the duration of the live preview in seconds.</property>
+                            <signal name="value_changed" handler="preview_duration_changed_cb"/>
                           </object>
                           <packing>
+                            <property name="expand">False</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="show_crop">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip-text" translatable="yes">Show Cropped area of the preview</property>
+                        <property name="label" translatable="yes">Show Crop</property>
+                        <signal name="toggled" handler="show_crop_changed_cb"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkToggleButton" id="preview_fullscreen">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip-text" translatable="yes">View Fullscreen Preview</property>
+                        <property name="label" translatable="yes">Fullscreen</property>
+                        <signal handler="fullscreen_clicked_cb" name="toggled"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkToggleButton" id="hide_settings">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip-text" translatable="yes">Hide the picture settings window while leaving the preview visible.</property>
+                        <property name="label" translatable="yes">Hide Settings</property>
+                        <signal handler="picture_settings_alt2_clicked_cb" name="clicked"/>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">3</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
-              <packing>
-                <property name="position">2</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
     </child>
   </object>
+
+  <object class="GtkWindow" id="preview_window">
+    <property name="visible">False</property>
+    <property name="title" translatable="yes">Preview</property>
+    <property name="window_position">GTK_WIN_POS_CENTER</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="resizable">False</property>
+    <property name="transient-for">hb_window</property>
+    <property name="events">GDK_STRUCTURE_MASK | GDK_POINTER_MOTION_MASK</property>
+    <signal handler="preview_configure_cb" name="configure-event"/>
+    <signal handler="preview_window_delete_cb" name="delete_event"/>
+    <child>
+      <object class="GtkAlignment" id="preview_window_alignment">
+        <property name="visible">True</property>
+        <property name="xalign">.5</property>
+        <property name="yalign">.5</property>
+        <property name="xscale">0</property>
+        <property name="yscale">0</property>
+      </object>
+    </child>
+  </object>
+
   <object class="GtkAboutDialog" id="hb_about">
     <property name="border_width">5</property>
     <property name="title" translatable="yes">About HandBrake</property>
@@ -4544,7 +6187,7 @@ the other to maintain the video's original aspect ratio.</property>
     <property name="program_name">HandBrake</property>
     <property name="version">0.9.2</property>
     <property name="copyright" translatable="yes">Copyright &#xA9; 2008 John Stebbins
-Copyright &#xA9; Copyright Â© 2004 - 2008, HandBrake Devs</property>
+Copyright &#xA9; 2004 - 2008, HandBrake Devs</property>
     <property name="comments" translatable="yes">HandBrake is a GPL-licensed, multiplatform, multithreaded video transcoder.</property>
     <property name="website">http://handbrake.fr</property>
     <property name="website_label" translatable="yes">http://handbrake.fr</property>
@@ -4708,6 +6351,7 @@ libmpeg2 authors:
   Brion Vibber
   Martin Vogt
   Fredrik Vraalsen
+
 libogg authors:
   Christopher Montgomery
 
@@ -4720,19 +6364,6 @@ libvorbis authors:
 libx264 authors:
   Laurent Aimar
 
-libxvidcore authors:
-  Christoph Lampert
-  Michael Militzer
-  Peter Ross
-  Benjamin Herrenschmidt
-  Daniel Smith
-  Dirk Knop
-  Edouard Gomez
-  Guillaume Morin
-  MinChen
-  Pascal Massimino
-  Radoslaw Czyz
-
 </property>
     <property name="logo_icon_name">hb-icon</property>
     <property name="wrap_license">True</property>
@@ -4758,6 +6389,11 @@ libxvidcore authors:
       </object>
     </child>
   </object>
+  <object class="GtkStatusIcon" id="hb_status">
+    <property name="visible">False</property>
+    <property name="icon_name">hb-icon</property>
+    <signal handler="status_activate_cb" name="activate"/>
+  </object>
   <object class="GtkDialog" id="update_dialog">
     <property name="border_width">5</property>
     <property name="modal">True</property>
@@ -4767,7 +6403,7 @@ libxvidcore authors:
     <property name="skip_pager_hint">True</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox6">
+      <object class="GtkVBox" id="dialog-vbox8">
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child>
@@ -4783,7 +6419,7 @@ libxvidcore authors:
                     <property name="visible_window">False</property>
                     <property name="above_child">True</property>
                     <child>
-                      <object class="GtkImage" id="image3">
+                      <object class="GtkImage" id="image10">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <property name="icon_name">hb-icon</property>
@@ -4806,10 +6442,10 @@ libxvidcore authors:
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox1">
+              <object class="GtkVBox" id="vbox41">
                 <property name="visible">True</property>
                 <child>
-                  <object class="GtkLabel" id="label3">
+                  <object class="GtkLabel" id="label22">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="xpad">10</property>
@@ -4836,12 +6472,12 @@ libxvidcore authors:
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkFrame" id="frame2">
+                  <object class="GtkFrame" id="frame15">
                     <property name="visible">True</property>
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">etched-out</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment2">
+                      <object class="GtkAlignment" id="alignment28">
                         <property name="visible">True</property>
                         <property name="left_padding">12</property>
                         <child>
@@ -4880,7 +6516,7 @@ libxvidcore authors:
           </packing>
         </child>
         <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area6">
+          <object class="GtkHButtonBox" id="dialog-action_area8">
             <property name="visible">True</property>
             <property name="layout_style">end</property>
             <child>
@@ -4919,4 +6555,186 @@ libxvidcore authors:
       <action-widget response="0">update_remind</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkFileChooserDialog" id="source_dialog">
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <property name="has_separator">False</property>
+    <signal handler="chooser_file_selected_cb" name="selection-changed"/>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox9">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="source_extra">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkHBox" id="single_title_box">
+                <property name="visible">True</property>
+                <property name="spacing">4</property>
+                <child>
+                  <object class="GtkLabel" id="label89">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Title Number:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment24">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="xscale">0</property>
+                    <child>
+                      <object class="GtkSpinButton" id="single_title">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                        <property name="adjustment">adjustment24</property>
+                        <signal name="value_changed" handler="setting_widget_changed_cb"/>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="source_folder_flag">
+                <property name="label" translatable="yes">Open VIDEO_TS folder</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+                <signal handler="source_type_changed_cb" name="toggled"/>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox74">
+                <property name="visible">True</property>
+                <property name="spacing">4</property>
+                <child>
+                  <object class="GtkLabel" id="label90">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Detected DVD devices:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment42">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="xscale">0</property>
+                    <child>
+                      <object class="GtkComboBox" id="source_device">
+                        <property name="visible">True</property>
+                        <property name="model">device_list</property>
+                        <signal handler="dvd_device_changed_cb" name="changed"/>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area6">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="source_cancel">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="source_ok">
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">source_cancel</action-widget>
+      <action-widget response="-3">source_ok</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="image11">
+    <property name="visible">True</property>
+    <property name="stock">gtk-new</property>
+  </object>
+  <object class="GtkImage" id="image12">
+    <property name="visible">True</property>
+    <property name="stock">gtk-apply</property>
+  </object>
+  <object class="GtkImage" id="image13">
+    <property name="visible">True</property>
+    <property name="stock">gtk-save-as</property>
+  </object>
+  <object class="GtkImage" id="image14">
+    <property name="visible">True</property>
+    <property name="stock">gtk-open</property>
+  </object>
+  <object class="GtkImage" id="image15">
+    <property name="visible">True</property>
+    <property name="stock">gtk-refresh</property>
+  </object>
 </interface>
index 849cdd2..0da8b3c 100644 (file)
@@ -1844,8 +1844,8 @@ ghb_cell_renderer_text_focus_out_event (GtkWidget *entry,
     return FALSE;
 
   GTK_ENTRY (entry)->editing_canceled = TRUE;
-  gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
   gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
+  gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
 
   /* entry needs focus-out-event */
   return FALSE;
diff --git a/gtk/src/ghbcompositor.c b/gtk/src/ghbcompositor.c
new file mode 100644 (file)
index 0000000..81628b6
--- /dev/null
@@ -0,0 +1,652 @@
+/* "Borrowed" from: */
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkprivate.h>
+#include <gtk/gtkmarshal.h>
+#include "ghbcompositor.h"
+
+enum {
+    PROP_0,
+};
+
+enum {
+    CHILD_PROP_0,
+    CHILD_PROP_Z_POS,
+    CHILD_PROP_OPACITY
+};
+
+#define GHB_COMPOSITOR_GET_PRIVATE(obj)  G_TYPE_INSTANCE_GET_PRIVATE((obj), GHB_TYPE_COMPOSITOR, GhbCompositorPrivate)
+
+static void     ghb_compositor_finalize      (GObject        *object);
+static void     ghb_compositor_realize       (GtkWidget      *widget);
+static void     ghb_compositor_unrealize     (GtkWidget      *widget);
+static void     ghb_compositor_size_request  (GtkWidget      *widget,
+                                             GtkRequisition  *requisition);
+static void     ghb_compositor_size_allocate (GtkWidget      *widget,
+                                             GtkAllocation   *allocation);
+static gboolean ghb_compositor_expose        (GtkWidget      *widget,
+                                             GdkEventExpose  *event);
+static void     ghb_compositor_set_property  (GObject        *object,
+                                             guint            prop_id,
+                                             const GValue    *value,
+                                             GParamSpec      *pspec);
+static void     ghb_compositor_get_property  (GObject        *object,
+                                             guint            prop_id,
+                                             GValue          *value,
+                                             GParamSpec      *pspec);
+static void     ghb_compositor_add          (GtkContainer    *container,
+                                             GtkWidget       *widget);
+static void     ghb_compositor_remove       (GtkContainer    *container,
+                                             GtkWidget       *widget);
+static void     ghb_compositor_forall       (GtkContainer    *container,
+                                             gboolean         include_internals,
+                                             GtkCallback      callback,
+                                             gpointer         data);
+static GType    ghb_compositor_child_type   (GtkContainer    *container);
+static void     ghb_compositor_set_child_property  (GtkContainer *container,
+                                             GtkWidget       *child,
+                                             guint            prop_id,
+                                             const GValue    *value,
+                                             GParamSpec      *pspec);
+static void     ghb_compositor_get_child_property  (GtkContainer *container,
+                                             GtkWidget       *child,
+                                             guint            prop_id,
+                                             GValue          *value,
+                                             GParamSpec      *pspec);
+
+G_DEFINE_TYPE (GhbCompositor, ghb_compositor, GTK_TYPE_BIN)
+
+static void
+ghb_compositor_class_init (GhbCompositorClass *class)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+    GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
+
+    gobject_class->finalize = ghb_compositor_finalize;
+
+    gobject_class->set_property = ghb_compositor_set_property;
+    gobject_class->get_property = ghb_compositor_get_property;
+
+    widget_class->size_request = ghb_compositor_size_request;
+    widget_class->size_allocate = ghb_compositor_size_allocate;
+
+    widget_class->realize = ghb_compositor_realize;
+    widget_class->unrealize = ghb_compositor_unrealize;
+
+    widget_class->expose_event = ghb_compositor_expose;
+
+    container_class->add = ghb_compositor_add;
+    container_class->remove = ghb_compositor_remove;
+    container_class->forall = ghb_compositor_forall;
+    container_class->child_type = ghb_compositor_child_type;
+    container_class->set_child_property = ghb_compositor_set_child_property;
+    container_class->get_child_property = ghb_compositor_get_child_property;
+
+    gtk_container_class_install_child_property (container_class,
+                        CHILD_PROP_Z_POS,
+                        g_param_spec_uint ("z-pos",
+                            "Position in Z-List",
+                            "Sets the blending order of the child.",
+                            0, 65535, 0,
+                            GTK_PARAM_READWRITE));
+
+    gtk_container_class_install_child_property (container_class,
+                        CHILD_PROP_OPACITY,
+                        g_param_spec_double ("opacity",
+                            "Opacity",
+                            "Sets the opacity of the child.",
+                            0.0, 1.0, 1.0,
+                            GTK_PARAM_READWRITE));
+
+}
+
+static GType
+ghb_compositor_child_type(GtkContainer *container)
+{
+    return GTK_TYPE_WIDGET;
+}
+
+static void 
+ghb_compositor_get_property (
+    GObject    *object,
+    guint       prop_id,
+    GValue     *value,
+    GParamSpec *pspec)
+{
+    GhbCompositor *compositor;
+
+    compositor = GHB_COMPOSITOR (object);
+
+    switch (prop_id)
+    {
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static void 
+ghb_compositor_set_property (
+    GObject      *object,
+    guint         prop_id,
+    const GValue *value,
+    GParamSpec   *pspec)
+{
+    GhbCompositor *compositor;
+
+    compositor = GHB_COMPOSITOR (object);
+
+    switch (prop_id)
+    {
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        break;
+    }
+}
+
+static gint
+zsort(gconstpointer a, gconstpointer b)
+{
+    GhbCompositorChild *cca, *ccb;
+
+    cca = (GhbCompositorChild*)a;
+    ccb = (GhbCompositorChild*)b;
+
+    return (cca->z_pos - ccb->z_pos);
+}
+
+static void 
+ghb_compositor_set_child_property(
+    GtkContainer *container,
+    GtkWidget    *child,
+    guint         prop_id,
+    const GValue *value,
+    GParamSpec   *pspec)
+{
+    GhbCompositor *compositor;
+    GhbCompositorChild *cc;
+    GList *link;
+
+    compositor = GHB_COMPOSITOR(container);
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        if (cc->widget == child)
+            break;
+    }
+    if (link == NULL)
+    {
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(container, prop_id, pspec);
+        return;
+    }
+
+    switch (prop_id)
+    {
+    case CHILD_PROP_Z_POS:
+    {
+        cc->z_pos = g_value_get_uint(value);
+        compositor->children = g_list_sort(compositor->children, zsort);
+    } break;
+    case CHILD_PROP_OPACITY:
+    {
+        cc->opacity = g_value_get_double(value);
+    } break;
+    default:
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(container, prop_id, pspec);
+        break;
+    }
+
+    if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (compositor))
+        gtk_widget_queue_resize (child);
+
+}
+
+static void 
+ghb_compositor_get_child_property(
+    GtkContainer *container,
+    GtkWidget    *child,
+    guint         prop_id,
+    GValue       *value,
+    GParamSpec   *pspec)
+{
+    GhbCompositor *compositor;
+    GhbCompositorChild *cc;
+    GList *link;
+
+    compositor = GHB_COMPOSITOR(container);
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        if (cc->widget == child)
+            break;
+    }
+    if (link == NULL)
+    {
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(container, prop_id, pspec);
+        return;
+    }
+
+    switch (prop_id)
+    {
+    case CHILD_PROP_Z_POS:
+    {
+        g_value_set_uint(value, cc->z_pos);
+    } break;
+    case CHILD_PROP_OPACITY:
+    {
+        g_value_set_double(value, cc->opacity);
+    } break;
+    default:
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(container, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+ghb_compositor_init (GhbCompositor *compositor)
+{
+    GTK_WIDGET_UNSET_FLAGS (compositor, GTK_NO_WINDOW);
+}
+
+GtkWidget*
+ghb_compositor_new (void)
+{
+    return GTK_WIDGET(g_object_new (GHB_TYPE_COMPOSITOR, NULL));
+}
+
+#if 0
+static void
+showtype(const gchar *msg, GtkWidget *widget)
+{
+    GType type;
+    gchar *str;
+
+    type = GTK_WIDGET_TYPE(widget);
+    if (type == GTK_TYPE_DRAWING_AREA)
+        str = "drawing area";
+    else if (type == GTK_TYPE_ALIGNMENT)
+        str = "alignment";
+    else if (type == GTK_TYPE_EVENT_BOX)
+        str = "event box";
+    else if (type == GTK_TYPE_EVENT_BOX)
+        str = "event box";
+    else
+        str = "unknown";
+    g_message("%s: %s", msg, str);
+}
+#endif
+
+static GList*
+find_drawables(GList *drawables, GtkWidget *widget)
+{
+    if (!GTK_WIDGET_NO_WINDOW(widget))
+    {
+        drawables = g_list_append(drawables, widget);
+        return drawables;
+    }
+    if (GTK_IS_CONTAINER(widget))
+    {
+        GList *children, *link;
+
+        children = gtk_container_get_children(GTK_CONTAINER(widget));
+        // Look for a child with a window
+        for (link = children; link != NULL; link = link->next)
+        {
+            if (!GTK_WIDGET_NO_WINDOW(GTK_WIDGET(link->data)))
+            {
+                drawables = g_list_append(drawables, link->data);
+            }
+            else
+            {
+                drawables = find_drawables(drawables, GTK_WIDGET(link->data));
+            }
+        }
+    }
+    return drawables;
+}
+
+/**
+ * ghb_compositor_zlist_insert:
+ * @compositor: a #GhbCompositor
+ * @child: widgets to insert
+ * @z_pos: position
+ * @opacity: global opacity for this widget
+ *
+ * Insert in the given position of the zlist in the compositor.
+ * All children in the zlist must have associated GdkDrawable's
+ * This means they must be GtkDrawingArea or GtkEventBox
+ * 
+ **/
+void
+ghb_compositor_zlist_insert (
+    GhbCompositor *compositor,
+    GtkWidget *child, 
+    gint z_pos, 
+    gdouble opacity)
+{
+    GhbCompositorChild *cc;
+    GdkDisplay *display;
+
+    g_return_if_fail (GHB_IS_COMPOSITOR (compositor));
+    g_return_if_fail (GTK_IS_WIDGET (child));
+    g_return_if_fail (child->parent == NULL);
+
+    gtk_widget_set_parent(child, GTK_WIDGET(compositor));
+
+    display = gtk_widget_get_display (GTK_WIDGET(compositor));
+
+    cc = g_new(GhbCompositorChild, 1);
+    cc->widget = child;
+    cc->z_pos = z_pos;
+    cc->opacity = opacity;
+    cc->drawables = NULL;
+    compositor->children = g_list_insert_sorted(
+                                compositor->children, cc, zsort);
+
+    if (gdk_display_supports_composite(display))
+    {
+        GList *link;
+
+        cc->drawables = find_drawables(NULL, cc->widget);
+
+        for (link = cc->drawables; link != NULL; link = link->next)
+        {
+            gtk_widget_realize(GTK_WIDGET(link->data));
+            gdk_window_set_composited(GTK_WIDGET(link->data)->window, TRUE);
+        }
+    }
+}
+
+static void
+ghb_compositor_add(GtkContainer *container, GtkWidget *child)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR(container);
+    GhbCompositorChild *cc;
+    gint z_pos = 0;
+    GList *last = g_list_last(compositor->children);
+
+    if (last != NULL)
+    {
+        cc = (GhbCompositorChild*)last->data;
+        z_pos = cc->z_pos + 1;
+    }
+    ghb_compositor_zlist_insert(compositor, child, z_pos, 1.0);
+}
+
+static void
+ghb_compositor_remove(GtkContainer *container, GtkWidget *child)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR(container);
+    GhbCompositorChild *cc;
+    GList *link;
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        if (cc->widget == child)
+        {
+            gboolean was_visible = GTK_WIDGET_VISIBLE( child );
+            gtk_widget_unparent(child);
+            compositor->children = g_list_remove(compositor->children, child);
+            g_free(child);
+
+            if (was_visible && GTK_WIDGET_VISIBLE (container))
+                gtk_widget_queue_resize(GTK_WIDGET(container));
+            break;
+        }
+    }
+}
+
+static void
+ghb_compositor_forall(
+    GtkContainer *container,
+    gboolean      include_internals,
+    GtkCallback   callback,
+    gpointer      data)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR (container);
+    GhbCompositorChild *cc;
+    GList *link;
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        (*callback)(cc->widget, data);
+    }
+}
+
+static void
+ghb_compositor_finalize (GObject *object)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR (object);
+    GhbCompositorChild *cc;
+    GList *link;
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        g_list_free(cc->drawables);
+        g_free(cc);
+    }
+    g_list_free(compositor->children);
+    G_OBJECT_CLASS (ghb_compositor_parent_class)->finalize (object);
+}
+
+
+static void
+ghb_compositor_realize (GtkWidget *widget)
+{
+    GdkWindowAttr attributes;
+    gint attributes_mask;
+    gint border_width;
+    gboolean visible_window;
+
+    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+    border_width = GTK_CONTAINER (widget)->border_width;
+
+    attributes.x = widget->allocation.x + border_width;
+    attributes.y = widget->allocation.y + border_width;
+    attributes.width = widget->allocation.width - 2*border_width;
+    attributes.height = widget->allocation.height - 2*border_width;
+    attributes.window_type = GDK_WINDOW_CHILD;
+    attributes.event_mask = gtk_widget_get_events (widget)
+            | GDK_BUTTON_MOTION_MASK
+            | GDK_BUTTON_PRESS_MASK
+            | GDK_BUTTON_RELEASE_MASK
+            | GDK_EXPOSURE_MASK
+            | GDK_ENTER_NOTIFY_MASK
+            | GDK_LEAVE_NOTIFY_MASK;
+
+    visible_window = !GTK_WIDGET_NO_WINDOW (widget);
+    if (visible_window)
+    {
+        attributes.visual = gtk_widget_get_visual (widget);
+        attributes.colormap = gtk_widget_get_colormap (widget);
+        attributes.wclass = GDK_INPUT_OUTPUT;
+
+        attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+        widget->window = gdk_window_new(gtk_widget_get_parent_window (widget),
+                                        &attributes, attributes_mask);
+        gdk_window_set_user_data (widget->window, widget);
+    }
+    else
+    {
+        widget->window = gtk_widget_get_parent_window (widget);
+        g_object_ref (widget->window);
+    }
+
+    widget->style = gtk_style_attach (widget->style, widget->window);
+
+    if (visible_window)
+        gtk_style_set_background(widget->style, widget->window, 
+                                GTK_STATE_NORMAL);
+}
+
+static void
+ghb_compositor_unrealize (GtkWidget *widget)
+{
+    GTK_WIDGET_CLASS (ghb_compositor_parent_class)->unrealize (widget);
+}
+
+static void
+ghb_compositor_size_request(
+    GtkWidget      *widget,
+    GtkRequisition *requisition)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR (widget);
+    GList *link;
+    GhbCompositorChild *cc;
+    gint width = 0, height = 0;
+    GtkRequisition child_requisition;
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+        if (GTK_WIDGET_VISIBLE(cc->widget))
+        {
+            gtk_widget_size_request(cc->widget, NULL);
+            gtk_widget_get_child_requisition(cc->widget, &child_requisition);
+            width = MAX(child_requisition.width, width);
+            height = MAX(child_requisition.height, height);
+        }
+    }
+
+    requisition->width = width + GTK_CONTAINER (widget)->border_width * 2;
+    requisition->height = height + GTK_CONTAINER (widget)->border_width * 2;
+}
+
+static void
+ghb_compositor_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+    GhbCompositor *compositor;
+    GtkAllocation child_allocation;
+    GhbCompositorChild *cc;
+    GList *link;
+
+    widget->allocation = *allocation;
+    compositor = GHB_COMPOSITOR (widget);
+
+    if (GTK_WIDGET_NO_WINDOW (widget))
+    {
+        child_allocation.x = allocation->x + 
+                            GTK_CONTAINER(widget)->border_width;
+        child_allocation.y = allocation->y + 
+                            GTK_CONTAINER(widget)->border_width;
+    }
+    else
+    {
+        child_allocation.x = 0;
+        child_allocation.y = 0;
+    }
+
+    child_allocation.width = MAX (allocation->width - 
+                                GTK_CONTAINER (widget)->border_width * 2, 0);
+    child_allocation.height = MAX (allocation->height - 
+                                GTK_CONTAINER (widget)->border_width * 2, 0);
+
+    if (GTK_WIDGET_REALIZED (widget))
+    {
+        if (!GTK_WIDGET_NO_WINDOW (widget))
+        {
+            gdk_window_move_resize (widget->window,
+                allocation->x + GTK_CONTAINER (widget)->border_width,
+                allocation->y + GTK_CONTAINER (widget)->border_width,
+                child_allocation.width,
+                child_allocation.height);
+        }
+    }
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+        cc = (GhbCompositorChild*)link->data;
+       if (GTK_WIDGET_REALIZED (cc->widget))
+               gtk_widget_size_allocate (cc->widget, &child_allocation);
+    }
+}
+
+static void
+ghb_compositor_blend (GtkWidget *widget, GdkEventExpose *event)
+{
+    GhbCompositor *compositor = GHB_COMPOSITOR (widget);
+    GList *link, *draw;
+    GdkRegion *region;
+    GtkWidget *child;
+    cairo_t *cr;
+    GhbCompositorChild *cc;
+
+    if (compositor->children == NULL) return;
+    /* create a cairo context to draw to the window */
+    cr = gdk_cairo_create (widget->window);
+
+    for (link = compositor->children; link != NULL; link = link->next)
+    {
+
+        cc = (GhbCompositorChild*)link->data;
+        for (draw = cc->drawables; draw != NULL; draw = draw->next)
+        {
+            /* get our child */
+            child = GTK_WIDGET(draw->data);
+            /* the source data is the (composited) event box */
+            gdk_cairo_set_source_pixmap (cr, child->window,
+                                        child->allocation.x,
+                                        child->allocation.y);
+            /* draw no more than our expose event intersects our child */
+            region = gdk_region_rectangle (&child->allocation);
+            gdk_region_intersect (region, event->region);
+            gdk_cairo_region (cr, region);
+            cairo_clip (cr);
+            /* composite, with an opacity */
+            cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+            cairo_paint_with_alpha (cr, cc->opacity);
+            cairo_reset_clip(cr);
+        }
+    }
+    /* we're done */
+    cairo_destroy (cr);
+}
+
+static gboolean
+ghb_compositor_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+    if (GTK_WIDGET_DRAWABLE (widget))
+    {
+        if (!GTK_WIDGET_NO_WINDOW (widget))
+            ghb_compositor_blend (widget, event);
+
+        GTK_WIDGET_CLASS(
+            ghb_compositor_parent_class)->expose_event(widget, event);
+    }
+
+    return FALSE;
+}
diff --git a/gtk/src/ghbcompositor.h b/gtk/src/ghbcompositor.h
new file mode 100644 (file)
index 0000000..2dd62c5
--- /dev/null
@@ -0,0 +1,74 @@
+/* "Borrowed" from: */
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+#ifndef __GHB_COMPOSITOR_H__
+#define __GHB_COMPOSITOR_H__
+
+
+#include <gtk/gtkbin.h>
+
+
+G_BEGIN_DECLS
+
+#define GHB_TYPE_COMPOSITOR              (ghb_compositor_get_type ())
+#define GHB_COMPOSITOR(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GHB_TYPE_COMPOSITOR, GhbCompositor))
+#define GHB_COMPOSITOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GHB_TYPE_COMPOSITOR, GhbCompositorClass))
+#define GHB_IS_COMPOSITOR(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHB_TYPE_COMPOSITOR))
+#define GHB_IS_COMPOSITOR_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GHB_TYPE_COMPOSITOR))
+#define GHB_COMPOSITOR_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GHB_TYPE_COMPOSITOR, GhbCompositorClass))
+
+typedef struct _GhbCompositor       GhbCompositor;
+typedef struct _GhbCompositorClass  GhbCompositorClass;
+typedef struct _GhbCompositorChild  GhbCompositorChild;
+
+struct _GhbCompositor
+{
+    GtkContainer  container;
+    GList        *children;
+};
+
+struct _GhbCompositorClass
+{
+    GtkContainerClass parent_class;
+};
+
+struct _GhbCompositorChild
+{
+    GtkWidget *widget;
+    GList     *drawables;
+    guint      z_pos;
+    gdouble    opacity;
+};
+
+GType      ghb_compositor_get_type           (void) G_GNUC_CONST;
+GtkWidget* ghb_compositor_new                (void);
+void       ghb_compositor_zlist_insert       (GhbCompositor *compositor,
+                                              GtkWidget *child, 
+                                              gint z_pos, gdouble opacity);
+
+G_END_DECLS
+
+#endif /* __GHB_COMPOSITOR_H__ */
index 3bc95e3..bb41aa4 100644 (file)
 #include <limits.h>
 #include <math.h>
 #include "hb.h"
-#include "hbversion.h"
 #include <gtk/gtk.h>
 #include <glib/gstdio.h>
 #include "hb-backend.h"
 #include "settings.h"
 #include "callbacks.h"
+#include "subtitlehandler.h"
+#include "audiohandler.h"
+#include "x264handler.h"
+#include "preview.h"
 #include "values.h"
 #include "lang.h"
 
@@ -38,7 +41,7 @@ typedef struct
 {
        const gchar *option;
        const gchar *shortOpt;
-       gint ivalue;
+       gdouble ivalue;
        const gchar *svalue;
 } options_map_t;
 
@@ -48,28 +51,119 @@ typedef struct
        options_map_t *map;
 } combo_opts_t;
 
-static const gchar *index_str[] =
-{
-       "0",
-       "1",
-       "2",
-       "3",
-       "4",
-       "5",
-       "6",
-       "7",
-       "8",
-       "9",
-       "10",
+static gchar **index_str = NULL;
+static gint index_str_size = 0;
+
+static void 
+index_str_init(gint max_index)
+{
+       int ii;
+
+       if (max_index+1 > index_str_size)
+       {
+               index_str = realloc(index_str, (max_index+1) * sizeof(char*));
+               for (ii = index_str_size; ii <= max_index; ii++)
+               {
+                       index_str[ii] = g_strdup_printf("%d", ii);
+               }
+               index_str_size = max_index + 1;
+       }
+}
+
+static options_map_t d_when_complete_opts[] =
+{
+       {"Do Nothing",            "nothing",  0, "0"},
+       {"Show Notification",     "notify",   1, "1"},
+       {"Put Computer To Sleep", "sleep",    2, "2"},
+       {"Shutdown Computer",     "shutdown", 3, "3"},
+};
+combo_opts_t when_complete_opts =
+{
+       sizeof(d_when_complete_opts)/sizeof(options_map_t),
+       d_when_complete_opts
+};
+
+static options_map_t d_par_opts[] =
+{
+       {"Off", "0", 0, "0"},
+       {"Strict", "1", 1, "1"},
+       {"Loose", "2", 2, "2"},
+       {"Custom", "3", 3, "3"},
+};
+combo_opts_t par_opts =
+{
+       sizeof(d_par_opts)/sizeof(options_map_t),
+       d_par_opts
+};
+
+static options_map_t d_alignment_opts[] =
+{
+       {"2", "2", 2, "2"},
+       {"4", "4", 4, "4"},
+       {"8", "8", 8, "8"},
+       {"16", "16", 16, "16"},
+};
+combo_opts_t alignment_opts =
+{
+       sizeof(d_alignment_opts)/sizeof(options_map_t),
+       d_alignment_opts
+};
+
+static options_map_t d_logging_opts[] =
+{
+       {"0", "0", 0, "0"},
+       {"1", "1", 1, "1"},
+       {"2", "2", 2, "2"},
+};
+combo_opts_t logging_opts =
+{
+       sizeof(d_logging_opts)/sizeof(options_map_t),
+       d_logging_opts
+};
+
+static options_map_t d_log_longevity_opts[] =
+{
+       {"Week",     "week",     7, "7"},
+       {"Month",    "month",    30, "30"},
+       {"Year",     "year",     365, "365"},
+       {"Immortal", "immortal", 366, "366"},
+};
+combo_opts_t log_longevity_opts =
+{
+       sizeof(d_log_longevity_opts)/sizeof(options_map_t),
+       d_log_longevity_opts
+};
+
+static options_map_t d_appcast_update_opts[] =
+{
+       {"Never", "never", 0, "never"},
+       {"Daily", "daily", 1, "daily"},
+       {"Weekly", "weekly", 2, "weekly"},
+       {"Monthly", "monthly", 3, "monthly"},
+};
+combo_opts_t appcast_update_opts =
+{
+       sizeof(d_appcast_update_opts)/sizeof(options_map_t),
+       d_appcast_update_opts
+};
+
+static options_map_t d_vqual_granularity_opts[] =
+{
+       {"0.2",  "0.2",  0.2,  "0.2"},
+       {"0.25", "0.25", 0.25, "0.25"},
+       {"0.5",  "0.5",  0.5,  "0.5"},
+       {"1",    "1",    1,    "1"},
+};
+combo_opts_t vqual_granularity_opts =
+{
+       sizeof(d_vqual_granularity_opts)/sizeof(options_map_t),
+       d_vqual_granularity_opts
 };
 
 static options_map_t d_container_opts[] =
 {
        {"MKV", "mkv", HB_MUX_MKV, "mkv"},
        {"MP4", "mp4", HB_MUX_MP4, "mp4"},
-       {"M4V", "m4v", HB_MUX_MP4, "m4v"},
-       {"AVI", "avi", HB_MUX_AVI, "avi"},
-       {"OGM", "ogm", HB_MUX_OGM, "ogm"},
 };
 combo_opts_t container_opts =
 {
@@ -77,12 +171,37 @@ combo_opts_t container_opts =
        d_container_opts
 };
 
+static options_map_t d_detel_opts[] =
+{
+       {"Off",    "off",   0, ""},
+       {"Custom", "custom", 1, ""},
+       {"Default","default",2, NULL},
+};
+combo_opts_t detel_opts =
+{
+       sizeof(d_detel_opts)/sizeof(options_map_t),
+       d_detel_opts
+};
+
+static options_map_t d_decomb_opts[] =
+{
+       {"Off",    "off",   0, ""},
+       {"Custom", "custom", 1, ""},
+       {"Default","default",2, NULL},
+};
+combo_opts_t decomb_opts =
+{
+       sizeof(d_decomb_opts)/sizeof(options_map_t),
+       d_decomb_opts
+};
+
 static options_map_t d_deint_opts[] =
 {
-       {"None",   "none",   0, ""},
-       {"Fast",   "fast",   1, "-1:-1:-1:0:1"},
-       {"Slow",   "slow",   2, "2:-1:-1:0:1"},
-       {"Slower", "slower", 3, "0:-1:-1:0:1"},
+       {"Off",    "off",   0, ""},
+       {"Custom", "custom", 1, ""},
+       {"Fast",   "fast",   2, "-1:-1:-1:0:1"},
+       {"Slow",   "slow",   3, "2:-1:-1:0:1"},
+       {"Slower", "slower", 4, "0:-1:-1:0:1"},
 };
 combo_opts_t deint_opts =
 {
@@ -92,10 +211,11 @@ combo_opts_t deint_opts =
 
 static options_map_t d_denoise_opts[] =
 {
-       {"None",   "none",   0, ""},
-       {"Weak",   "weak",   1, "2:1:2:3"},
-       {"Medium", "medium", 2, "3:2:2:3"},
-       {"Strong", "strong", 3, "7:7:5:5"},
+       {"Off",    "off",   0, ""},
+       {"Custom", "custom", 1, ""},
+       {"Weak",   "weak",   2, "2:1:2:3"},
+       {"Medium", "medium", 3, "3:2:2:3"},
+       {"Strong", "strong", 4, "7:7:5:5"},
 };
 combo_opts_t denoise_opts =
 {
@@ -106,9 +226,8 @@ combo_opts_t denoise_opts =
 static options_map_t d_vcodec_opts[] =
 {
        {"H.264 (x264)",    "x264",   HB_VCODEC_X264, ""},
-       {"MPEG-4 (XviD)",   "xvid",   HB_VCODEC_XVID, ""},
-       {"MPEG-4 (FFMPEG)", "ffmpeg", HB_VCODEC_FFMPEG, ""},
-       {"Theora",          "theora", HB_VCODEC_THEORA, ""},
+       {"MPEG-4 (FFmpeg)", "ffmpeg", HB_VCODEC_FFMPEG, ""},
+       {"VP3 (Theora)",    "theora", HB_VCODEC_THEORA, ""},
 };
 combo_opts_t vcodec_opts =
 {
@@ -118,10 +237,12 @@ combo_opts_t vcodec_opts =
 
 static options_map_t d_acodec_opts[] =
 {
-       {"AAC (faac)",      "faac",   HB_ACODEC_FAAC, "faac"},
-       {"MP3 (lame)",      "lame",   HB_ACODEC_LAME, "lame"},
+       {"AAC (faac)",      "faac",   HB_ACODEC_FAAC,   "faac"},
+       {"MP3 (lame)",      "lame",   HB_ACODEC_LAME,   "lame"},
        {"Vorbis",          "vorbis", HB_ACODEC_VORBIS, "vorbis"},
-       {"AC3 (pass-thru)", "ac3",    HB_ACODEC_AC3, "ac3"},
+       {"AC3 (pass-thru)", "ac3",    HB_ACODEC_AC3,    "ac3"},
+       {"DTS (pass-thru)", "dts",    HB_ACODEC_DCA,    "dts"},
+       {"Choose For Me",   "auto",   HB_ACODEC_MASK,   "auto"},
 };
 combo_opts_t acodec_opts =
 {
@@ -142,12 +263,25 @@ combo_opts_t direct_opts =
        d_direct_opts
 };
 
+static options_map_t d_badapt_opts[] =
+{
+       {"Off",             "0", 0, "0"},
+       {"Fast",            "1", 1, "1"},
+       {"Optimal",         "2", 2, "2"},
+};
+combo_opts_t badapt_opts =
+{
+       sizeof(d_badapt_opts)/sizeof(options_map_t),
+       d_badapt_opts
+};
+
 static options_map_t d_me_opts[] =
 {
-       {"Diamond",              "dia", 0, "dia"},
-       {"Hexagon",              "hex", 1, "hex"},
-       {"Uneven Multi-Hexagon", "umh", 2, "umh"},
-       {"Exhaustive",           "esa", 3, "esa"},
+       {"Diamond",              "dia",  0, "dia"},
+       {"Hexagon",              "hex",  1, "hex"},
+       {"Uneven Multi-Hexagon", "umh",  2, "umh"},
+       {"Exhaustive",           "esa",  3, "esa"},
+       {"Hadamard Exhaustive",  "tesa", 4, "tesa"},
 };
 combo_opts_t me_opts =
 {
@@ -166,6 +300,7 @@ static options_map_t d_subme_opts[] =
        {"7", "7", 7, "7"},
        {"8", "8", 8, "8"},
        {"9", "9", 9, "9"},
+       {"10", "10", 10, "10"},
 };
 combo_opts_t subme_opts =
 {
@@ -188,8 +323,8 @@ combo_opts_t analyse_opts =
 
 static options_map_t d_trellis_opts[] =
 {
-       {"Disabled",          "0",    0, "0"},
-       {"Final Macro Block", "1",    1, "1"},
+       {"Disabled",          "0", 0, "0"},
+       {"Final Macro Block", "1", 1, "1"},
        {"Always",            "2", 2, "2"},
 };
 combo_opts_t trellis_opts =
@@ -224,24 +359,73 @@ typedef struct
 
 combo_name_map_t combo_name_map[] =
 {
+       {"WhenComplete", &when_complete_opts},
+       {"PicturePAR", &par_opts},
+       {"PictureModulus", &alignment_opts},
+       {"LoggingLevel", &logging_opts},
+       {"LogLongevity", &log_longevity_opts},
+       {"check_updates", &appcast_update_opts},
+       {"VideoQualityGranularity", &vqual_granularity_opts},
        {"FileFormat", &container_opts},
        {"PictureDeinterlace", &deint_opts},
-       {"tweak_PictureDeinterlace", &deint_opts},
+       {"PictureDecomb", &decomb_opts},
+       {"PictureDetelecine", &detel_opts},
        {"PictureDenoise", &denoise_opts},
-       {"tweak_PictureDenoise", &denoise_opts},
        {"VideoEncoder", &vcodec_opts},
        {"AudioEncoder", &acodec_opts},
        {"x264_direct", &direct_opts},
+       {"x264_b_adapt", &badapt_opts},
        {"x264_me", &me_opts},
        {"x264_subme", &subme_opts},
        {"x264_analyse", &analyse_opts},
        {"x264_trellis", &trellis_opts},
-       {"Subtitles", &subtitle_opts},
+       {"SubtitleTrack", &subtitle_opts},
        {"title", &title_opts},
        {"AudioTrack", &audio_track_opts},
        {NULL, NULL}
 };
 
+const gchar *srt_codeset_table[] =
+{
+       "ANSI_X3.4-1968",
+       "ANSI_X3.4-1986",
+       "ANSI_X3.4",
+       "ANSI_X3.110-1983",
+       "ANSI_X3.110",
+       "ASCII",
+       "ECMA-114",
+       "ECMA-118",
+       "ECMA-128",
+       "ECMA-CYRILLIC",
+       "IEC_P27-1",
+       "ISO-8859-1",
+       "ISO-8859-2",
+       "ISO-8859-3",
+       "ISO-8859-4",
+       "ISO-8859-5",
+       "ISO-8859-6",
+       "ISO-8859-7",
+       "ISO-8859-8",
+       "ISO-8859-9",
+       "ISO-8859-9E",
+       "ISO-8859-10",
+       "ISO-8859-11",
+       "ISO-8859-13",
+       "ISO-8859-14",
+       "ISO-8859-15",
+       "ISO-8859-16",
+       "UTF-7",
+       "UTF-8",
+       "UTF-16",
+       "UTF-16LE",
+       "UTF-16BE",
+       "UTF-32",
+       "UTF-32LE",
+       "UTF-32BE",
+       NULL
+};
+#define        SRT_TABLE_SIZE (sizeof(srt_codeset_table)/ sizeof(char*)-1)
+
 #if 0
 typedef struct iso639_lang_t
 {
@@ -292,21 +476,20 @@ const iso639_lang_t ghb_language_table[] =
        { "Cree", "", "cr", "cre" },
        { "Czech", "", "cs", "ces", "cze" },
        { "Danish", "Dansk", "da", "dan" },
+       { "German", "Deutsch", "de", "deu", "ger" },
        { "Divehi", "", "dv", "div" },
-       { "Dutch", "Nederlands", "nl", "nld", "dut" },
        { "Dzongkha", "", "dz", "dzo" },
        { "English", "English", "en", "eng" },
+       { "Spanish", "Espanol", "es", "spa" },
        { "Esperanto", "", "eo", "epo" },
        { "Estonian", "", "et", "est" },
        { "Ewe", "", "ee", "ewe" },
        { "Faroese", "", "fo", "fao" },
        { "Fijian", "", "fj", "fij" },
-       { "Finnish", "Suomi", "fi", "fin" },
        { "French", "Francais", "fr", "fra", "fre" },
        { "Western Frisian", "", "fy", "fry" },
        { "Fulah", "", "ff", "ful" },
        { "Georgian", "", "ka", "kat", "geo" },
-       { "German", "Deutsch", "de", "deu", "ger" },
        { "Gaelic (Scots)", "", "gd", "gla" },
        { "Irish", "", "ga", "gle" },
        { "Galician", "", "gl", "glg" },
@@ -320,10 +503,10 @@ const iso639_lang_t ghb_language_table[] =
        { "Herero", "", "hz", "her" },
        { "Hindi", "", "hi", "hin" },
        { "Hiri Motu", "", "ho", "hmo" },
-       { "Hungarian", "Magyar", "hu", "hun" },
+       { "Croatian", "Hrvatski", "hr", "hrv", "scr" },
        { "Igbo", "", "ig", "ibo" },
-       { "Icelandic", "Islenska", "is", "isl", "ice" },
        { "Ido", "", "io", "ido" },
+       { "Icelandic", "Islenska", "is", "isl", "ice" },
        { "Sichuan Yi", "", "ii", "iii" },
        { "Inuktitut", "", "iu", "iku" },
        { "Interlingue", "", "ie", "ile" },
@@ -357,6 +540,7 @@ const iso639_lang_t ghb_language_table[] =
        { "Luba-Katanga", "", "lu", "lub" },
        { "Ganda", "", "lg", "lug" },
        { "Macedonian", "", "mk", "mkd", "mac" },
+       { "Hungarian", "Magyar", "hu", "hun" },
        { "Marshallese", "", "mh", "mah" },
        { "Malayalam", "", "ml", "mal" },
        { "Maori", "", "mi", "mri", "mao" },
@@ -368,13 +552,14 @@ const iso639_lang_t ghb_language_table[] =
        { "Mongolian", "", "mn", "mon" },
        { "Nauru", "", "na", "nau" },
        { "Navajo", "", "nv", "nav" },
+       { "Dutch", "Nederlands", "nl", "nld", "dut" },
        { "Ndebele, South", "", "nr", "nbl" },
        { "Ndebele, North", "", "nd", "nde" },
        { "Ndonga", "", "ng", "ndo" },
        { "Nepali", "", "ne", "nep" },
+       { "Norwegian", "Norsk", "no", "nor" },
        { "Norwegian Nynorsk", "", "nn", "nno" },
        { "Norwegian BokmÃ¥l", "", "nb", "nob" },
-       { "Norwegian", "Norsk", "no", "nor" },
        { "Chichewa; Nyanja", "", "ny", "nya" },
        { "Occitan", "", "oc", "oci" },
        { "Ojibwa", "", "oj", "oji" },
@@ -395,7 +580,6 @@ const iso639_lang_t ghb_language_table[] =
        { "Sango", "", "sg", "sag" },
        { "Sanskrit", "", "sa", "san" },
        { "Serbian", "", "sr", "srp", "scc" },
-       { "Croatian", "Hrvatski", "hr", "hrv", "scr" },
        { "Sinhala", "", "si", "sin" },
        { "Slovak", "", "sk", "slk", "slo" },
        { "Slovenian", "", "sl", "slv" },
@@ -405,10 +589,10 @@ const iso639_lang_t ghb_language_table[] =
        { "Sindhi", "", "sd", "snd" },
        { "Somali", "", "so", "som" },
        { "Sotho, Southern", "", "st", "sot" },
-       { "Spanish", "Espanol", "es", "spa" },
        { "Sardinian", "", "sc", "srd" },
        { "Swati", "", "ss", "ssw" },
        { "Sundanese", "", "su", "sun" },
+       { "Finnish", "Suomi", "fi", "fin" },
        { "Swahili", "", "sw", "swa" },
        { "Swedish", "Svenska", "sv", "swe" },
        { "Tahitian", "", "ty", "tah" },
@@ -477,7 +661,7 @@ del_tree(const gchar *name, gboolean del_top)
 const gchar*
 ghb_version()
 {
-       return HB_VERSION;
+       return hb_get_version(NULL);
 }
 
 void
@@ -487,42 +671,71 @@ ghb_vquality_range(
        gdouble *max,
        gdouble *step,
        gdouble *page,
-       gint *digits)
+       gint *digits,
+       gboolean *inverted)
 {
-       if (ghb_settings_get_boolean(ud->settings, "directqp"))
+       gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
+       *page = 10;
+       *digits = 0;
+       switch (vcodec)
        {
-               gint vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
-               // Only x264 and ffmpeg currently support direct qp/crf entry
-               *step = 1;
-               *page = 10;
-               *digits = 0;
-               if (vcodec == HB_VCODEC_X264)
+               case HB_VCODEC_X264:
                {
                        *min = 0;
                        *max = 51;
-               }
-               else if (vcodec == HB_VCODEC_FFMPEG)
+                       *step = ghb_settings_combo_double(ud->settings, 
+                                                                                       "VideoQualityGranularity");
+                       if (*step == 0.2 || *step == 0.5)
+                               *digits = 1;
+                       else if (*step == 0.25)
+                               *digits = 2;
+                       *inverted = TRUE;
+               } break;
+
+               case HB_VCODEC_FFMPEG:
                {
-                       *min = 0;
+                       *min = 1;
                        *max = 31;
-               }
-               else
+                       *step = 1;
+                       *inverted = TRUE;
+               } break;
+
+               case HB_VCODEC_THEORA:
                {
                        *min = 0;
-                       *max = 1.0;
-                       *step = 0.001;
-                       *page = 0.1;
-                       *digits = 3;
-               }
+                       *max = 63;
+                       *step = 1;
+                       *inverted = FALSE;
+               } break;
+
+               default:
+               {
+                       *min = 0;
+                       *max = 100;
+                       *step = 1;
+                       *inverted = FALSE;
+               } break;
        }
-       else
+}
+
+static const gchar*
+lookup_generic_string(combo_opts_t *opts, const GValue *gval)
+{
+       gint ii;
+       gchar *str;
+       const gchar *result = "";
+
+       str = ghb_value_string(gval);
+       for (ii = 0; ii < opts->count; ii++)
        {
-               *min = 0;
-               *max = 1.0;
-               *step = 0.001;
-               *page = 0.1;
-               *digits = 3;
+               if (strcmp(opts->map[ii].shortOpt, str) == 0)
+               {
+                       result = opts->map[ii].svalue;
+                       break;
+               }
        }
+       g_free(str);
+       return result;
 }
 
 static gint
@@ -545,6 +758,26 @@ lookup_generic_int(combo_opts_t *opts, const GValue *gval)
        return result;
 }
 
+static gdouble
+lookup_generic_double(combo_opts_t *opts, const GValue *gval)
+{
+       gint ii;
+       gchar *str;
+       gdouble result = -1;
+
+       str = ghb_value_string(gval);
+       for (ii = 0; ii < opts->count; ii++)
+       {
+               if (strcmp(opts->map[ii].shortOpt, str) == 0)
+               {
+                       result = opts->map[ii].ivalue;
+                       break;
+               }
+       }
+       g_free(str);
+       return result;
+}
+
 static const gchar*
 lookup_generic_option(combo_opts_t *opts, const GValue *gval)
 {
@@ -773,7 +1006,10 @@ lookup_audio_lang_option(const GValue *rate)
        {
                if (strcmp(ghb_language_table[ii].iso639_2, str) == 0)
                {
-                       result = ghb_language_table[ii].eng_name;
+                       if (ghb_language_table[ii].native_name[0] != 0)
+                               result = ghb_language_table[ii].native_name;
+                       else
+                               result = ghb_language_table[ii].eng_name;
                        break;
                }
        }
@@ -789,7 +1025,7 @@ get_acodec_value(gint val)
 
        for (ii = 0; ii < acodec_opts.count; ii++)
        {
-               if (acodec_opts.map[ii].ivalue == val)
+               if ((int)acodec_opts.map[ii].ivalue == val)
                {
                        value = ghb_string_value_new(acodec_opts.map[ii].shortOpt);
                        break;
@@ -798,25 +1034,6 @@ get_acodec_value(gint val)
        return value;
 }
 
-#if 0
-static GValue*
-get_abitrate_value(gint val)
-{
-       GValue *value = NULL;
-       gint ii;
-
-       for (ii = 0; ii < hb_audio_bitrates_count; ii++)
-       {
-               if (hb_audio_bitrates[ii].rate == val)
-               {
-                       value = ghb_string_value_new(hb_audio_bitrates[ii].string);
-                       break;
-               }
-       }
-       return value;
-}
-#endif
-
 static GValue*
 get_amix_value(gint val)
 {
@@ -840,6 +1057,15 @@ static hb_handle_t * h_queue = NULL;
 
 extern void hb_get_tempory_directory(hb_handle_t *h, char path[512]);
 
+gchar*
+ghb_get_tmp_dir()
+{
+       char dir[512];
+
+       hb_get_tempory_directory(h_scan, dir);
+       return g_strdup(dir);
+}
+
 void
 ghb_hb_cleanup(gboolean partial)
 {
@@ -850,6 +1076,135 @@ ghb_hb_cleanup(gboolean partial)
 }
 
 gint
+ghb_subtitle_track_source(signal_user_data_t *ud, gint track)
+{
+       gint titleindex;
+
+       if (track == -2)
+               return SRTSUB;
+       if (track < 0)
+               return VOBSUB;
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0)
+               return VOBSUB;
+
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * sub;
+       
+       if (h_scan == NULL) return VOBSUB;
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               /* No valid title, stop right there */
+               return VOBSUB;
+       }
+       title = hb_list_item( list, titleindex );
+       if (title == NULL) return VOBSUB;       // Bad titleindex
+       sub = hb_list_item( title->list_subtitle, track);
+       if (sub != NULL)
+               return sub->source;
+       else
+               return VOBSUB;
+}
+
+const char*
+ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track)
+{
+       gint titleindex;
+       const gchar * name = "Unknown";
+
+       if (track == -2)
+       {
+               name = "SRT";
+               goto done;
+       }
+       if (track == -1)
+       {
+               name = "Bitmap";
+               goto done;
+       }
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0)
+               goto done;
+
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * sub;
+       
+       if (h_scan == NULL) 
+               goto done;
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+               goto done;
+
+       title = hb_list_item( list, titleindex );
+       if (title == NULL)
+               goto done;
+
+       sub = hb_list_item( title->list_subtitle, track);
+       if (sub != NULL)
+       {
+               switch (sub->source)
+               {
+                       case VOBSUB:
+                               name = "Bitmap";
+                               break;
+                       case CC708SUB:
+                       case CC608SUB:
+                               name = "Text";
+                               break;
+                       case SRTSUB:
+                               name = "SRT";
+                               break;
+                       default:
+                               break;
+               }
+       }
+
+done:
+       return name;
+}
+
+gchar*
+ghb_subtitle_track_lang(signal_user_data_t *ud, gint track)
+{
+       gint titleindex;
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0)
+               goto fail;
+       if (track == -1)
+               return ghb_get_user_audio_lang(ud, titleindex, 0);
+       if (track < 0)
+               goto fail;
+
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * sub;
+       
+       if (h_scan == NULL)
+               goto fail;
+
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               /* No valid title, stop right there */
+               goto fail;
+       }
+       title = hb_list_item( list, titleindex );
+       if (title == NULL)      // Bad titleindex
+               goto fail;
+       sub = hb_list_item( title->list_subtitle, track);
+       if (sub != NULL)
+               return g_strdup(sub->iso639_2);
+
+fail:
+       return g_strdup("und");
+}
+
+gint
 ghb_get_title_number(gint titleindex)
 {
        hb_list_t  * list;
@@ -960,20 +1315,22 @@ ghb_grey_combo_options(GtkBuilder *builder)
        grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_LAME, FALSE);
        grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, FALSE);
 
-       gboolean allow_ac3 = TRUE;
-       allow_ac3 = (container != HB_MUX_OGM);
+       gboolean allow_dca = TRUE;
+       allow_dca = (container != HB_MUX_MP4);
 
-       if (allow_ac3)
-       {
-               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3, FALSE);
-       }
+       grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3, FALSE);
+       if (allow_dca)
+               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA, FALSE);
        else
+               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA, TRUE);
+
+       if (audio && audio->in.codec != HB_ACODEC_AC3)
        {
                grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3, TRUE);
        }
-       if (audio && audio->in.codec != HB_ACODEC_AC3)
+       if (audio && audio->in.codec != HB_ACODEC_DCA)
        {
-               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3, TRUE);
+               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA, TRUE);
        }
        grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, FALSE);
 
@@ -991,27 +1348,18 @@ ghb_grey_combo_options(GtkBuilder *builder)
                grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, TRUE);
                grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, TRUE);
        }
-       else if (container == HB_MUX_AVI)
-       {
-               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_FAAC, TRUE);
-               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, TRUE);
-               grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, TRUE);
-       }
-       else if (container == HB_MUX_OGM)
-       {
-               grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_FAAC, TRUE);
-       }
 
        gboolean allow_mono = TRUE;
        gboolean allow_stereo = TRUE;
        gboolean allow_dolby = TRUE;
        gboolean allow_dpl2 = TRUE;
        gboolean allow_6ch = TRUE;
+       allow_mono = acodec & ~HB_ACODEC_LAME;
+       allow_6ch = acodec & ~HB_ACODEC_LAME;
        if (audio)
        {
-               allow_mono =
-                       (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (acodec != HB_ACODEC_LAME);
+               allow_mono = allow_mono &&
+                       (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA));
                gint layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
                allow_stereo =
                        ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
@@ -1020,9 +1368,8 @@ ghb_grey_combo_options(GtkBuilder *builder)
                        (layout == HB_INPUT_CH_LAYOUT_3F2R) || 
                        (layout == HB_INPUT_CH_LAYOUT_DOLBY);
                allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
-               allow_6ch =
+               allow_6ch = allow_6ch &&
                        (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (acodec != HB_ACODEC_LAME) &&
                        (layout == HB_INPUT_CH_LAYOUT_3F2R) && 
                        (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
        }
@@ -1034,6 +1381,18 @@ ghb_grey_combo_options(GtkBuilder *builder)
 }
 
 gint
+ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels)
+{
+       if (acodec & HB_ACODEC_FAAC)
+       {
+       int maxbr = channels * 80;
+               if (br > maxbr)
+                       br = maxbr;
+       }
+       return br;
+}
+
+gint
 ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix)
 {
     hb_audio_config_t *audio = NULL;
@@ -1053,7 +1412,7 @@ ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix)
        {
                allow_mono =
                        (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (acodec != HB_ACODEC_LAME);
+                       (acodec & ~HB_ACODEC_LAME);
                gint layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
                allow_stereo =
                        ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
@@ -1064,7 +1423,7 @@ ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix)
                allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
                allow_6ch =
                        (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (acodec != HB_ACODEC_LAME) &&
+                       (acodec & ~HB_ACODEC_LAME) &&
                        (layout == HB_INPUT_CH_LAYOUT_3F2R) && 
                        (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
        }
@@ -1117,6 +1476,8 @@ init_combo_box(GtkBuilder *builder, const gchar *name)
        g_debug("init_combo_box() %s\n", name);
        // First modify the combobox model to allow greying out of options
        combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+       if (combo == NULL)
+               return;
        // Store contains:
        // 1 - String to display
        // 2 - bool indicating whether the entry is selectable (grey or not)
@@ -1124,7 +1485,7 @@ init_combo_box(GtkBuilder *builder, const gchar *name)
        // 4 - Int value determined by backend
        // 5 - String value determined by backend
        store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN, 
-                                                          G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
+                                                          G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_STRING);
        gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store));
 
        if (GTK_WIDGET_TYPE(combo) == GTK_TYPE_COMBO_BOX)
@@ -1133,7 +1494,7 @@ init_combo_box(GtkBuilder *builder, const gchar *name)
        cell = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell,
-               "text", 0, "sensitive", 1, NULL);
+               "markup", 0, "sensitive", 1, NULL);
        }
        else
        { // Combo box entry
@@ -1147,6 +1508,7 @@ audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rat
        GtkTreeIter iter;
        GtkListStore *store;
        gint ii;
+       gchar *str;
        
        g_debug("audio_samplerate_opts_set ()\n");
        store = get_combo_box_store(builder, name);
@@ -1154,22 +1516,24 @@ audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rat
        // Add an item for "Same As Source"
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 
-                                          0, "Same as source", 
+                                          0, "<small>Same as source</small>", 
                                           1, TRUE, 
                                           2, "source", 
-                                          3, 0, 
+                                          3, 0.0
                                           4, "source", 
                                           -1);
        for (ii = 0; ii < count; ii++)
        {
                gtk_list_store_append(store, &iter);
+               str = g_strdup_printf("<small>%s</small>", rates[ii].string);
                gtk_list_store_set(store, &iter, 
-                                                  0, rates[ii].string, 
+                                                  0, str,
                                                   1, TRUE, 
                                                   2, rates[ii].string, 
-                                                  3, rates[ii].rate, 
+                                                  3, (gdouble)rates[ii].rate, 
                                                   4, rates[ii].string, 
                                                   -1);
+               g_free(str);
        }
 }
 
@@ -1189,7 +1553,7 @@ video_rate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gi
                                           0, "Same as source", 
                                           1, TRUE, 
                                           2, "source", 
-                                          3, 0, 
+                                          3, 0.0
                                           4, "source", 
                                           -1);
        for (ii = 0; ii < count; ii++)
@@ -1214,7 +1578,7 @@ video_rate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gi
                                                   0, option, 
                                                   1, TRUE, 
                                                   2, rates[ii].string, 
-                                                  3, rates[ii].rate, 
+                                                  3, (gdouble)rates[ii].rate, 
                                                   4, rates[ii].string, 
                                                   -1);
                g_free(option);
@@ -1227,55 +1591,93 @@ mix_opts_set(GtkBuilder *builder, const gchar *name)
        GtkTreeIter iter;
        GtkListStore *store;
        gint ii;
+       gchar *str;
        
        g_debug("mix_opts_set ()\n");
        store = get_combo_box_store(builder, name);
        gtk_list_store_clear(store);
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 
-                                          0, "None", 
+                                          0, "<small>None</small>", 
                                           1, TRUE, 
                                           2, "none", 
-                                          3, 0, 
+                                          3, 0.0
                                           4, "none", 
                                           -1);
        for (ii = 0; ii < hb_audio_mixdowns_count; ii++)
        {
                gtk_list_store_append(store, &iter);
+               str = g_strdup_printf("<small>%s</small>",
+                       hb_audio_mixdowns[ii].human_readable_name);
                gtk_list_store_set(store, &iter, 
-                                                  0, hb_audio_mixdowns[ii].human_readable_name, 
+                                                  0, str,
                                                   1, TRUE, 
                                                   2, hb_audio_mixdowns[ii].short_name, 
-                                                  3, hb_audio_mixdowns[ii].amixdown, 
+                                                  3, (gdouble)hb_audio_mixdowns[ii].amixdown, 
                                                   4, hb_audio_mixdowns[ii].internal_name, 
                                                   -1);
+               g_free(str);
        }
 }
 
 static void
-language_opts_set(GtkBuilder *builder, const gchar *name)
+srt_codeset_opts_set(GtkBuilder *builder, const gchar *name)
 {
        GtkTreeIter iter;
        GtkListStore *store;
        gint ii;
        
-       g_debug("language_opts_set ()\n");
+       g_debug("srt_codeset_opts_set ()\n");
        store = get_combo_box_store(builder, name);
        gtk_list_store_clear(store);
-       for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
+       for (ii = 0; ii < SRT_TABLE_SIZE; ii++)
        {
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
-                                                  0, ghb_language_table[ii].eng_name, 
+                                                  0, srt_codeset_table[ii],
                                                   1, TRUE, 
-                                                  2, ghb_language_table[ii].iso639_2, 
-                                                  3, ii, 
-                                                  4, ghb_language_table[ii].iso639_1, 
+                                                  2, srt_codeset_table[ii],
+                                                  3, (gdouble)ii, 
+                                                  4, srt_codeset_table[ii],
                                                   -1);
        }
+       GtkComboBoxEntry *cbe;
+
+       cbe = GTK_COMBO_BOX_ENTRY(GHB_WIDGET(builder, name));
+       //gtk_combo_box_entry_set_text_column(cbe, 0);
 }
 
-static gchar **titles = NULL;
+static void
+language_opts_set(GtkBuilder *builder, const gchar *name)
+{
+       GtkTreeIter iter;
+       GtkListStore *store;
+       gint ii;
+       
+       g_debug("language_opts_set ()\n");
+       store = get_combo_box_store(builder, name);
+       gtk_list_store_clear(store);
+       for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
+       {
+               const gchar *lang;
+
+               if (ghb_language_table[ii].native_name[0] != 0)
+                       lang = ghb_language_table[ii].native_name;
+               else
+                       lang = ghb_language_table[ii].eng_name;
+               
+               gtk_list_store_append(store, &iter);
+               gtk_list_store_set(store, &iter, 
+                                                  0, lang,
+                                                  1, TRUE, 
+                                                  2, ghb_language_table[ii].iso639_2, 
+                                                  3, (gdouble)ii, 
+                                                  4, ghb_language_table[ii].iso639_1, 
+                                                  -1);
+       }
+}
+
+static gchar **titles = NULL;
 
 void
 title_opts_set(GtkBuilder *builder, const gchar *name)
@@ -1318,7 +1720,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
                                                   0, "No Titles", 
                                                   1, TRUE, 
                                                   2, "none", 
-                                                  3, -1, 
+                                                  3, -1.0
                                                   4, "none", 
                                                   -1);
                title_opts.map[0].option = "No Titles";
@@ -1344,7 +1746,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
                                                   0, titles[ii], 
                                                   1, TRUE, 
                                                   2, titles[ii], 
-                                                  3, ii, 
+                                                  3, (gdouble)ii, 
                                                   4, titles[ii], 
                                                   -1);
                title_opts.map[ii].option = titles[ii];
@@ -1358,7 +1760,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
 static gboolean
 find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter)
 {
-       gint ivalue;
+       gdouble ivalue;
        gboolean foundit = FALSE;
        
        if (gtk_tree_model_get_iter_first (store, iter))
@@ -1366,7 +1768,7 @@ find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter)
                do
                {
                        gtk_tree_model_get(store, iter, 3, &ivalue, -1);
-                       if (value == ivalue)
+                       if (value == (int)ivalue)
                        {
                                foundit = TRUE;
                                break;
@@ -1386,6 +1788,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
     hb_audio_config_t * audio;
        gint ii;
        gint count = 0;
+       gchar *str;
        
        g_debug("audio_track_opts_set ()\n");
        store = get_combo_box_store(builder, name);
@@ -1399,7 +1802,7 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
                        count = hb_list_count( title->list_audio );
                }
        }
-       if (count > 10) count = 10;
+       if (count > 100) count = 100;
        if (audio_track_opts.map) g_free(audio_track_opts.map);
        if (count > 0)
        {
@@ -1416,10 +1819,10 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
                // No audio. set some default
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
-                                                  0, "No Audio", 
+                                                  0, "<small>No Audio</small>", 
                                                   1, TRUE, 
                                                   2, "none", 
-                                                  3, -1, 
+                                                  3, -1.0
                                                   4, "none", 
                                                   -1);
                audio_track_opts.map[0].option = "No Audio";
@@ -1428,17 +1831,20 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
                audio_track_opts.map[0].svalue = "none";
                return;
        }
+       index_str_init(count-1);
        for (ii = 0; ii < count; ii++)
        {
         audio = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, ii );
                gtk_list_store_append(store, &iter);
+               str = g_strdup_printf("<small>%s</small>", audio->lang.description);
                gtk_list_store_set(store, &iter, 
-                                                  0, audio->lang.description, 
+                                                  0, str,
                                                   1, TRUE, 
                                                   2, index_str[ii], 
-                                                  3, ii, 
+                                                  3, (gdouble)ii, 
                                                   4, index_str[ii], 
                                                   -1);
+               g_free(str);
                audio_track_opts.map[ii].option = audio->lang.description,
                audio_track_opts.map[ii].shortOpt = index_str[ii];
                audio_track_opts.map[ii].ivalue = ii;
@@ -1446,19 +1852,18 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
        }
 }
 
-
 void
-subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
+subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
 {
        GtkTreeIter iter;
        GtkListStore *store;
        hb_list_t  * list = NULL;
        hb_title_t * title = NULL;
-    hb_subtitle_t * subtitle;
-       gint ii;
-       gint count = 0;
+       hb_subtitle_t * subtitle;
+       gint ii, count = 0;
+       static char ** options = NULL;
        
-       g_debug("subtitle_opts_set () %s\n", name);
+       g_debug("subtitle_track_opts_set ()\n");
        store = get_combo_box_store(builder, name);
        gtk_list_store_clear(store);
        if (h_scan != NULL)
@@ -1470,78 +1875,81 @@ subtitle_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
                        count = hb_list_count( title->list_subtitle );
                }
        }
-       if (count > 10) count = 10;
+       if (count > 100) count = 100;
        if (subtitle_opts.map) g_free(subtitle_opts.map);
        if (count > 0)
        {
-               subtitle_opts.count = count+2;
-               subtitle_opts.map = g_malloc((count+2)*sizeof(options_map_t));
+               subtitle_opts.count = count+1;
+               subtitle_opts.map = g_malloc((count+1)*sizeof(options_map_t));
        }
        else
        {
-               subtitle_opts.count = LANG_TABLE_SIZE+2;
-               subtitle_opts.map = g_malloc((LANG_TABLE_SIZE+2)*sizeof(options_map_t));
+               subtitle_opts.count = LANG_TABLE_SIZE+1;
+               subtitle_opts.map = g_malloc((LANG_TABLE_SIZE+1)*sizeof(options_map_t));
        }
-       // Add options for "none" and "autoselect"
-       gtk_list_store_append(store, &iter);
-       gtk_list_store_set(store, &iter, 
-                                          0, "None", 
-                                          1, TRUE, 
-                                          2, "none", 
-                                          3, -2, 
-                                          4, "none", 
-                                          -1);
-       subtitle_opts.map[0].option = "None";
-       subtitle_opts.map[0].shortOpt = "none";
-       subtitle_opts.map[0].ivalue = -2;
-       subtitle_opts.map[0].svalue = "none";
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 
-                                          0, "Autoselect", 
+                                          0, "Foreign Audio Search", 
                                           1, TRUE, 
-                                          2, "auto", 
-                                          3, -1, 
+                                          2, "-1", 
+                                          3, -1.0
                                           4, "auto", 
                                           -1);
-       subtitle_opts.map[0].option = "Same as audio";
-       subtitle_opts.map[0].shortOpt = "auto";
+       subtitle_opts.map[0].option = "Foreign Audio Search";
+       subtitle_opts.map[0].shortOpt = "-1";
        subtitle_opts.map[0].ivalue = -1;
        subtitle_opts.map[0].svalue = "auto";
-       if (count >0)
+       if (count > 0)
        {
+               if (options != NULL)
+                       g_strfreev(options);
+               options = g_malloc((count+1)*sizeof(gchar*));
+               index_str_init(count-1);
                for (ii = 0; ii < count; ii++)
                {
                        subtitle = (hb_subtitle_t *)hb_list_item(title->list_subtitle, ii);
+                       // Skip subtitles that must be burned if there is already
+                       // a burned subtitle in the list
+                       options[ii] = g_strdup_printf("%d - %s", ii+1, subtitle->lang);
+                       subtitle_opts.map[ii+1].option = options[ii];
+                       subtitle_opts.map[ii+1].shortOpt = index_str[ii];
+                       subtitle_opts.map[ii+1].ivalue = ii;
+                       subtitle_opts.map[ii+1].svalue = subtitle->iso639_2;
                        gtk_list_store_append(store, &iter);
                        gtk_list_store_set(store, &iter, 
-                                               0, subtitle->lang
+                                               0, options[ii]
                                                1, TRUE, 
-                                               2, subtitle->iso639_2
-                                               3, ii, 
+                                               2, index_str[ii]
+                                               3, (gdouble)ii, 
                                                4, subtitle->iso639_2, 
                                                -1);
-                       subtitle_opts.map[ii+2].option = subtitle->lang;
-                       subtitle_opts.map[ii+2].shortOpt = subtitle->iso639_2;
-                       subtitle_opts.map[ii+2].ivalue = ii;
-                       subtitle_opts.map[ii+2].svalue = subtitle->iso639_2;
                }
+               options[count] = NULL;
        }
        else
        {
+               index_str_init(LANG_TABLE_SIZE-1);
                for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
                {
+                       const gchar *lang;
+
+                       if (ghb_language_table[ii].native_name[0] != 0)
+                               lang = ghb_language_table[ii].native_name;
+                       else
+                               lang = ghb_language_table[ii].eng_name;
+
+                       subtitle_opts.map[ii+1].option = lang;
+                       subtitle_opts.map[ii+1].shortOpt = index_str[ii];
+                       subtitle_opts.map[ii+1].ivalue = ii;
+                       subtitle_opts.map[ii+1].svalue = ghb_language_table[ii].iso639_2;
                        gtk_list_store_append(store, &iter);
                        gtk_list_store_set(store, &iter, 
-                               0, ghb_language_table[ii].eng_name, 
-                               1, TRUE, 
-                               2, ghb_language_table[ii].iso639_2, 
-                               3, ii, 
-                               4, ghb_language_table[ii].iso639_2, 
-                               -1);
-                       subtitle_opts.map[ii+2].option = ghb_language_table[ii].eng_name;
-                       subtitle_opts.map[ii+2].shortOpt = ghb_language_table[ii].iso639_2;
-                       subtitle_opts.map[ii+2].ivalue = ii;
-                       subtitle_opts.map[ii+2].svalue = ghb_language_table[ii].iso639_2;
+                                       0, lang,
+                                       1, TRUE, 
+                                       2, index_str[ii],
+                                       3, (gdouble)ii, 
+                                       4, ghb_language_table[ii].iso639_2, 
+                                       -1);
                }
        }
 }
@@ -1573,8 +1981,38 @@ ghb_longest_title()
        return titleindex;
 }
 
+gchar*
+ghb_get_source_audio_lang(gint titleindex, gint track)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+    hb_audio_config_t * audio;
+       gchar *lang = NULL;
+       
+       g_debug("ghb_lookup_1st_audio_lang ()\n");
+       if (h_scan == NULL) 
+               return NULL;
+       list = hb_get_titles( h_scan );
+    title = (hb_title_t*)hb_list_item( list, titleindex );
+       if (title == NULL)
+               return NULL;
+       if (hb_list_count( title->list_audio ) <= track)
+               return NULL;
+
+       audio = hb_list_audio_config_item(title->list_audio, track);
+       if (audio == NULL)
+               return NULL;
+
+       lang = g_strdup(audio->lang.iso639_2);
+       return lang;
+}
+
 gint
-ghb_find_audio_track(gint titleindex, const gchar *lang, gint index)
+ghb_find_audio_track(
+       gint titleindex, 
+       const gchar *lang, 
+       gint acodec,
+       GHashTable *track_indices)
 {
        hb_list_t  * list;
        hb_title_t * title;
@@ -1582,39 +2020,255 @@ ghb_find_audio_track(gint titleindex, const gchar *lang, gint index)
        gint ii;
        gint count = 0;
        gint track = -1;
-       gint match = 0;
+       gint max_chan = 0;
+       gboolean *used;
        
        g_debug("find_audio_track ()\n");
-       if (h_scan != NULL)
+       if (h_scan == NULL) return -1;
+       list = hb_get_titles( h_scan );
+    title = (hb_title_t*)hb_list_item( list, titleindex );
+       if (title != NULL)
        {
-               list = hb_get_titles( h_scan );
-           title = (hb_title_t*)hb_list_item( list, titleindex );
-               if (title != NULL)
+               count = hb_list_count( title->list_audio );
+       }
+       if (count > 10) count = 10;
+       used = g_hash_table_lookup(track_indices, &acodec);
+       if (used == NULL)
+       {
+               used = g_malloc0(count * sizeof(gboolean));
+               g_hash_table_insert(track_indices, &acodec, used);
+       }
+       // Try to find an item that matches the preferred language and
+       // the passthru codec type
+       if (acodec & (HB_ACODEC_AC3 | HB_ACODEC_DCA))
+       {
+               for (ii = 0; ii < count; ii++)
                {
-                       count = hb_list_count( title->list_audio );
+                       gint channels;
+
+                       if (used[ii])
+                               continue;
+
+               audio = (hb_audio_config_t*)hb_list_audio_config_item( 
+                                                                                                       title->list_audio, ii );
+                       channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+                                                                                                       audio->in.channel_layout);
+                       // Find a track that is not visually impaired or dirctor's
+                       // commentary, and has the highest channel count.
+                       if ((audio->in.codec & acodec) &&
+                               (audio->lang.type < 2) &&
+                               ((strcmp(lang, audio->lang.iso639_2) == 0) ||
+                               (strcmp(lang, "und") == 0)))
+                       {
+                               if (channels > max_chan)
+                               {
+                                       track = ii;
+                                       max_chan = channels;
+                               }
+                       }
                }
        }
-       if (count > 10) count = 10;
+       if (track > -1)
+       {
+               used[track] = TRUE;
+               return track;
+       }
+       // Try to find an item that matches the preferred language
        for (ii = 0; ii < count; ii++)
        {
-        audio = (hb_audio_config_t*)hb_list_audio_config_item( title->list_audio, ii );
-               if ((strcmp(lang, audio->lang.iso639_2) == 0) ||
-                       (strcmp(lang, "und") == 0))
+               if (used[ii])
+                       continue;
+        audio = (hb_audio_config_t*)hb_list_audio_config_item( 
+                                                                                                       title->list_audio, ii );
+               // Find a track that is not visually impaired or dirctor's commentary
+               if ((audio->lang.type < 2) &&
+                       ((strcmp(lang, audio->lang.iso639_2) == 0) ||
+                       (strcmp(lang, "und") == 0)))
                {
-                       if (index == match)
+                       track = ii;
+                       break;
+               }
+       }
+       if (track > -1)
+       {
+               used[track] = TRUE;
+               return track;
+       }
+       // Try to fine an item that does not match the preferred language and
+       // matches the passthru codec type
+       if (acodec & (HB_ACODEC_AC3 | HB_ACODEC_DCA))
+       {
+               for (ii = 0; ii < count; ii++)
+               {
+                       gint channels;
+
+                       if (used[ii])
+                               continue;
+
+               audio = (hb_audio_config_t*)hb_list_audio_config_item( 
+                                                                                                       title->list_audio, ii );
+                       channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+                                                                                                       audio->in.channel_layout);
+                       // Find a track that is not visually impaired or dirctor's
+                       // commentary, and has the highest channel count.
+                       if ((audio->in.codec & acodec) &&
+                               (audio->lang.type < 2))
                        {
-                               track = ii;
-                               break;
+                               if (channels > max_chan)
+                               {
+                                       track = ii;
+                                       max_chan = channels;
+                               }
                        }
-                       match++;
                }
        }
-       if (match) return track;
-       if (index < count)
-               track = index;
+       if (track > -1)
+       {
+               used[track] = TRUE;
+               return track;
+       }
+       // Try to fine an item that does not match the preferred language
+       for (ii = 0; ii < count; ii++)
+       {
+               if (used[ii])
+                       continue;
+        audio = (hb_audio_config_t*)hb_list_audio_config_item( 
+                                                                                                       title->list_audio, ii );
+               // Find a track that is not visually impaired or dirctor's commentary
+               if (audio->lang.type < 2)
+               {
+                       track = ii;
+                       break;
+               }
+       }
+       if (track > -1)
+       {
+               used[track] = TRUE;
+               return track;
+       }
+       // Last ditch, anything goes
+       for (ii = 0; ii < count; ii++)
+       {
+        audio = (hb_audio_config_t*)hb_list_audio_config_item( 
+                                                                                                       title->list_audio, ii );
+               if (!used[ii])
+               {
+                       track = ii;
+                       break;
+               }
+       }
+       if (track > -1)
+       {
+               used[track] = TRUE;
+       }
        return track;
 }
 
+gint
+ghb_find_pref_subtitle_track(const gchar *lang)
+{
+       gint ii, count;
+       count = subtitle_opts.count;
+       for (ii = 0; ii < count; ii++)
+       {
+               if (strcmp(lang, subtitle_opts.map[ii].svalue) == 0)
+               {
+                       return subtitle_opts.map[ii].ivalue;
+               }
+       }
+       return -2;
+}
+
+gint
+ghb_find_cc_track(gint titleindex)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * subtitle;
+       gint count, ii;
+       
+       g_debug("ghb_find_cc_track ()\n");
+       if (h_scan == NULL) return -2;
+       list = hb_get_titles( h_scan );
+       title = (hb_title_t*)hb_list_item( list, titleindex );
+       if (title != NULL)
+       {
+               count = hb_list_count( title->list_subtitle );
+               // Try to find an item that matches the preferred language
+               for (ii = 0; ii < count; ii++)
+               {
+                       subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+                       if (subtitle->source == CC608SUB || subtitle->source == CC708SUB)
+                               return ii;
+               }
+       }
+       return -2;
+}
+
+gint
+ghb_find_subtitle_track(
+       gint          titleindex, 
+       const gchar * lang, 
+       gboolean      burn,
+       gboolean      force,
+       gint          source,
+       GHashTable  * track_indices)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_subtitle_t * subtitle;
+       gint count, ii;
+       gboolean *used;
+       
+       g_debug("find_subtitle_track ()\n");
+       if (strcmp(lang, "auto") == 0)
+               return -1;
+       if (h_scan == NULL) return -1;
+       list = hb_get_titles( h_scan );
+       title = (hb_title_t*)hb_list_item( list, titleindex );
+       if (title != NULL)
+       {
+               count = hb_list_count( title->list_subtitle );
+               used = g_hash_table_lookup(track_indices, lang);
+               if (used == NULL)
+               {
+                       used = g_malloc0(count * sizeof(gboolean));
+                       g_hash_table_insert(track_indices, g_strdup(lang), used);
+               }
+               // Try to find an item that matches the preferred language and source
+               for (ii = 0; ii < count; ii++)
+               {
+                       if (used[ii])
+                               continue;
+
+                       subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+                       if (source == subtitle->source &&
+                               ((strcmp(lang, subtitle->iso639_2) == 0) ||
+                                (strcmp(lang, "und") == 0)))
+                       {
+                               used[ii] = TRUE;
+                               return ii;
+                       }
+               }
+               // Try to find an item that matches the preferred language
+               for (ii = 0; ii < count; ii++)
+               {
+                       if (used[ii])
+                               continue;
+
+                       subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+                       if (((burn || force) && (subtitle->source == VOBSUB)) &&
+                               ((strcmp(lang, subtitle->iso639_2) == 0) ||
+                                (strcmp(lang, "und") == 0)))
+                       {
+                               used[ii] = TRUE;
+                               return ii;
+                       }
+               }
+       }
+       return -2;
+}
+
 static void
 generic_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
 {
@@ -1639,6 +2293,33 @@ generic_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
        }
 }
 
+static void
+small_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
+{
+       GtkTreeIter iter;
+       GtkListStore *store;
+       gint ii;
+       gchar *str;
+       
+       g_debug("generic_opts_set ()\n");
+       if (name == NULL || opts == NULL) return;
+       store = get_combo_box_store(builder, name);
+       gtk_list_store_clear(store);
+       for (ii = 0; ii < opts->count; ii++)
+       {
+               gtk_list_store_append(store, &iter);
+               str = g_strdup_printf("<small>%s</small>", opts->map[ii].option);
+               gtk_list_store_set(store, &iter, 
+                                                  0, str,
+                                                  1, TRUE, 
+                                                  2, opts->map[ii].shortOpt, 
+                                                  3, opts->map[ii].ivalue, 
+                                                  4, opts->map[ii].svalue, 
+                                                  -1);
+               g_free(str);
+       }
+}
+
 combo_opts_t*
 find_combo_table(const gchar *name)
 {
@@ -1657,6 +2338,8 @@ find_combo_table(const gchar *name)
 gint
 ghb_lookup_combo_int(const gchar *name, const GValue *gval)
 {
+       if (gval == NULL)
+               return 0;
        if (strcmp(name, "AudioBitrate") == 0)
                return lookup_audio_bitrate_int(gval);
        else if (strcmp(name, "AudioSamplerate") == 0)
@@ -1665,7 +2348,9 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval)
                return lookup_video_rate_int(gval);
        else if (strcmp(name, "AudioMixdown") == 0)
                return lookup_mix_int(gval);
-       else if (strcmp(name, "SourceAudioLang") == 0)
+       else if (strcmp(name, "SrtLanguage") == 0)
+               return lookup_audio_lang_int(gval);
+       else if (strcmp(name, "PreferredLanguage") == 0)
                return lookup_audio_lang_int(gval);
        else
        {
@@ -1675,9 +2360,36 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval)
        return 0;
 }
 
+gdouble
+ghb_lookup_combo_double(const gchar *name, const GValue *gval)
+{
+       if (gval == NULL)
+               return 0;
+       if (strcmp(name, "AudioBitrate") == 0)
+               return lookup_audio_bitrate_int(gval);
+       else if (strcmp(name, "AudioSamplerate") == 0)
+               return lookup_audio_rate_int(gval);
+       else if (strcmp(name, "VideoFramerate") == 0)
+               return lookup_video_rate_int(gval);
+       else if (strcmp(name, "AudioMixdown") == 0)
+               return lookup_mix_int(gval);
+       else if (strcmp(name, "SrtLanguage") == 0)
+               return lookup_audio_lang_int(gval);
+       else if (strcmp(name, "PreferredLanguage") == 0)
+               return lookup_audio_lang_int(gval);
+       else
+       {
+               return lookup_generic_double(find_combo_table(name), gval);
+       }
+       g_warning("ghb_lookup_combo_double() couldn't find %s", name);
+       return 0;
+}
+
 const gchar*
 ghb_lookup_combo_option(const gchar *name, const GValue *gval)
 {
+       if (gval == NULL)
+               return NULL;
        if (strcmp(name, "AudioBitrate") == 0)
                return lookup_audio_bitrate_option(gval);
        else if (strcmp(name, "AudioSamplerate") == 0)
@@ -1686,30 +2398,61 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval)
                return lookup_video_rate_option(gval);
        else if (strcmp(name, "AudioMixdown") == 0)
                return lookup_mix_option(gval);
-       else if (strcmp(name, "SourceAudioLang") == 0)
+       else if (strcmp(name, "SrtLanguage") == 0)
+               return lookup_audio_lang_option(gval);
+       else if (strcmp(name, "PreferredLanguage") == 0)
                return lookup_audio_lang_option(gval);
        else
        {
                return lookup_generic_option(find_combo_table(name), gval);
        }
        g_warning("ghb_lookup_combo_int() couldn't find %s", name);
-       return 0;
+       return NULL;
+}
+
+const gchar*
+ghb_lookup_combo_string(const gchar *name, const GValue *gval)
+{
+       if (gval == NULL)
+               return NULL;
+       if (strcmp(name, "AudioBitrate") == 0)
+               return lookup_audio_bitrate_option(gval);
+       else if (strcmp(name, "AudioSamplerate") == 0)
+               return lookup_audio_rate_option(gval);
+       else if (strcmp(name, "VideoFramerate") == 0)
+               return lookup_video_rate_option(gval);
+       else if (strcmp(name, "AudioMixdown") == 0)
+               return lookup_mix_option(gval);
+       else if (strcmp(name, "SrtLanguage") == 0)
+               return lookup_audio_lang_option(gval);
+       else if (strcmp(name, "PreferredLanguage") == 0)
+               return lookup_audio_lang_option(gval);
+       else
+       {
+               return lookup_generic_string(find_combo_table(name), gval);
+       }
+       g_warning("ghb_lookup_combo_int() couldn't find %s", name);
+       return NULL;
 }
 
 void
-ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data, gboolean all)
+ghb_update_ui_combo_box(
+       signal_user_data_t *ud, 
+       const gchar *name, 
+       gint user_data, 
+       gboolean all)
 {
        GtkComboBox *combo = NULL;
        gint signal_id;
        gint handler_id = 0;
 
-       g_debug("ghb_update_ui_combo_box() %s\n", name);
        if (name != NULL)
        {               
+               g_debug("ghb_update_ui_combo_box() %s\n", name);
                // Clearing a combo box causes a rash of "changed" events, even when
                // the active item is -1 (inactive).  To control things, I'm disabling
                // the event till things are settled down.
-               combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+               combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, name));
                signal_id = g_signal_lookup("changed", GTK_TYPE_COMBO_BOX);
                if (signal_id > 0)
                {
@@ -1725,47 +2468,61 @@ ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data,
        }       
        if (all)
        {
-               audio_bitrate_opts_set(builder, "AudioBitrate");
-               audio_samplerate_opts_set(builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
-               video_rate_opts_set(builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
-               mix_opts_set(builder, "AudioMixdown");
-               language_opts_set(builder, "SourceAudioLang");
-               subtitle_opts_set(builder, "Subtitles", user_data);
-               title_opts_set(builder, "title");
-               audio_track_opts_set(builder, "AudioTrack", user_data);
-               generic_opts_set(builder, "FileFormat", &container_opts);
-               generic_opts_set(builder, "PictureDeinterlace", &deint_opts);
-               generic_opts_set(builder, "tweak_PictureDeinterlace", &deint_opts);
-               generic_opts_set(builder, "PictureDenoise", &denoise_opts);
-               generic_opts_set(builder, "tweak_PictureDenoise", &denoise_opts);
-               generic_opts_set(builder, "VideoEncoder", &vcodec_opts);
-               generic_opts_set(builder, "AudioEncoder", &acodec_opts);
-               generic_opts_set(builder, "x264_direct", &direct_opts);
-               generic_opts_set(builder, "x264_me", &me_opts);
-               generic_opts_set(builder, "x264_subme", &subme_opts);
-               generic_opts_set(builder, "x264_analyse", &analyse_opts);
-               generic_opts_set(builder, "x264_trellis", &trellis_opts);
+               audio_bitrate_opts_set(ud->builder, "AudioBitrate");
+               audio_samplerate_opts_set(ud->builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
+               video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
+               mix_opts_set(ud->builder, "AudioMixdown");
+               language_opts_set(ud->builder, "SrtLanguage");
+               language_opts_set(ud->builder, "PreferredLanguage");
+               srt_codeset_opts_set(ud->builder, "SrtCodeset");
+               title_opts_set(ud->builder, "title");
+               audio_track_opts_set(ud->builder, "AudioTrack", user_data);
+               subtitle_track_opts_set(ud->builder, "SubtitleTrack", user_data);
+               generic_opts_set(ud->builder, "VideoQualityGranularity", &vqual_granularity_opts);
+               generic_opts_set(ud->builder, "WhenComplete", &when_complete_opts);
+               generic_opts_set(ud->builder, "PicturePAR", &par_opts);
+               generic_opts_set(ud->builder, "PictureModulus", &alignment_opts);
+               generic_opts_set(ud->builder, "LoggingLevel", &logging_opts);
+               generic_opts_set(ud->builder, "LogLongevity", &log_longevity_opts);
+               generic_opts_set(ud->builder, "check_updates", &appcast_update_opts);
+               generic_opts_set(ud->builder, "FileFormat", &container_opts);
+               generic_opts_set(ud->builder, "PictureDeinterlace", &deint_opts);
+               generic_opts_set(ud->builder, "PictureDetelecine", &detel_opts);
+               generic_opts_set(ud->builder, "PictureDecomb", &decomb_opts);
+               generic_opts_set(ud->builder, "PictureDenoise", &denoise_opts);
+               generic_opts_set(ud->builder, "VideoEncoder", &vcodec_opts);
+               small_opts_set(ud->builder, "AudioEncoder", &acodec_opts);
+               generic_opts_set(ud->builder, "x264_direct", &direct_opts);
+               generic_opts_set(ud->builder, "x264_b_adapt", &badapt_opts);
+               generic_opts_set(ud->builder, "x264_me", &me_opts);
+               generic_opts_set(ud->builder, "x264_subme", &subme_opts);
+               generic_opts_set(ud->builder, "x264_analyse", &analyse_opts);
+               generic_opts_set(ud->builder, "x264_trellis", &trellis_opts);
        }
        else
        {
                if (strcmp(name, "AudioBitrate") == 0)
-                       audio_bitrate_opts_set(builder, "AudioBitrate");
+                       audio_bitrate_opts_set(ud->builder, "AudioBitrate");
                else if (strcmp(name, "AudioSamplerate") == 0)
-                       audio_samplerate_opts_set(builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
+                       audio_samplerate_opts_set(ud->builder, "AudioSamplerate", hb_audio_rates, hb_audio_rates_count);
                else if (strcmp(name, "VideoFramerate") == 0)
-                       video_rate_opts_set(builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
+                       video_rate_opts_set(ud->builder, "VideoFramerate", hb_video_rates, hb_video_rates_count);
                else if (strcmp(name, "AudioMixdown") == 0)
-                       mix_opts_set(builder, "AudioMixdown");
-               else if (strcmp(name, "SourceAudioLang") == 0)
-                       language_opts_set(builder, "SourceAudioLang");
-               else if (strcmp(name, "Subtitles") == 0)
-                       subtitle_opts_set(builder, "Subtitles", user_data);
+                       mix_opts_set(ud->builder, "AudioMixdown");
+               else if (strcmp(name, "SrtLanguage") == 0)
+                       language_opts_set(ud->builder, "SrtLanguage");
+               else if (strcmp(name, "PreferredLanguage") == 0)
+                       language_opts_set(ud->builder, "PreferredLanguage");
+               else if (strcmp(name, "SrtCodeset") == 0)
+                       srt_codeset_opts_set(ud->builder, "SrtCodeset");
                else if (strcmp(name, "title") == 0)
-                       title_opts_set(builder, "title");
+                       title_opts_set(ud->builder, "title");
+               else if (strcmp(name, "SubtitleTrack") == 0)
+                       subtitle_track_opts_set(ud->builder, "SubtitleTrack", user_data);
                else if (strcmp(name, "AudioTrack") == 0)
-                       audio_track_opts_set(builder, "AudioTrack", user_data);
+                       audio_track_opts_set(ud->builder, "AudioTrack", user_data);
                else
-                       generic_opts_set(builder, name, find_combo_table(name));
+                       generic_opts_set(ud->builder, name, find_combo_table(name));
        }
        if (handler_id > 0)
        {
@@ -1782,8 +2539,9 @@ init_ui_combo_boxes(GtkBuilder *builder)
        init_combo_box(builder, "AudioSamplerate");
        init_combo_box(builder, "VideoFramerate");
        init_combo_box(builder, "AudioMixdown");
-       init_combo_box(builder, "SourceAudioLang");
-       init_combo_box(builder, "Subtitles");
+       init_combo_box(builder, "SrtLanguage");
+       init_combo_box(builder, "PreferredLanguage");
+       init_combo_box(builder, "SrtCodeset");
        init_combo_box(builder, "title");
        init_combo_box(builder, "AudioTrack");
        for (ii = 0; combo_name_map[ii].name != NULL; ii++)
@@ -1793,8 +2551,8 @@ init_ui_combo_boxes(GtkBuilder *builder)
 }
        
 static const char * turbo_opts = 
-       "ref=1:subme=1:me=dia:analyse=none:trellis=0:"
-       "no-fast-pskip=0:8x8dct=0:weightb=0";
+       "ref=1:subme=2:me=dia:analyse=none:trellis=0:"
+       "no-fast-pskip=0:8x8dct=0";
 
 // Construct the x264 options string
 // The result is allocated, so someone must free it at some point.
@@ -1814,6 +2572,29 @@ ghb_build_x264opts_string(GValue *settings)
        return result;
 }
 
+void
+ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+    hb_chapter_t * chapter;
+       gint count;
+       
+       g_debug("ghb_get_chapter_duration (title = %d)\n", ti);
+       *hh = *mm = *ss = 0;
+       if (h_scan == NULL) return;
+       list = hb_get_titles( h_scan );
+    title = (hb_title_t*)hb_list_item( list, ti );
+       if (title == NULL) return;
+       count = hb_list_count( title->list_chapter );
+       if (ii >= count) return;
+       chapter = hb_list_item(title->list_chapter, ii);
+       if (chapter == NULL) return;
+       *hh = chapter->hours;
+       *mm = chapter->minutes;
+       *ss = chapter->seconds;
+}
+
 GValue*
 ghb_get_chapters(gint titleindex)
 {
@@ -1862,7 +2643,7 @@ ghb_ac3_in_audio_list(const GValue *audio_list)
 
                asettings = ghb_array_get_nth(audio_list, ii);
                acodec = ghb_settings_combo_int(asettings, "AudioEncoder");
-               if (acodec == HB_ACODEC_AC3)
+               if (acodec & HB_ACODEC_AC3)
                        return TRUE;
        }
        return FALSE;
@@ -1875,17 +2656,20 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
        GtkListStore *store;
        gchar *str;
        
-       g_debug("audio_rate_opts_add ()\n");
+       g_debug("audio_bitrate_opts_add ()\n");
+
+       if (rate < 8) return;
+
        store = get_combo_box_store(builder, name);
        if (!find_combo_item_by_int(GTK_TREE_MODEL(store), rate, &iter))
        {
-               str = g_strdup_printf ("%d", rate);
+               str = g_strdup_printf ("<small>%d</small>", rate);
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
                                                   0, str, 
                                                   1, TRUE, 
                                                   2, str, 
-                                                  3, rate, 
+                                                  3, (gdouble)rate, 
                                                   4, str, 
                                                   -1);
                g_free(str);
@@ -1893,14 +2677,19 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
 }
 
 static void
-audio_bitrate_opts_clean(GtkBuilder *builder, const gchar *name, gint last_rate)
+audio_bitrate_opts_clean(
+       GtkBuilder *builder, 
+       const gchar *name, 
+       gint first_rate, 
+       gint last_rate)
 {
        GtkTreeIter iter;
        GtkListStore *store;
-       gint ivalue;
+       gdouble ivalue;
        gboolean done = FALSE;
        gint ii = 0;
        guint last = (guint)last_rate;
+       guint first = (guint)first_rate;
        
        g_debug("audio_bitrate_opts_clean ()\n");
        store = get_combo_box_store(builder, name);
@@ -1914,7 +2703,7 @@ audio_bitrate_opts_clean(GtkBuilder *builder, const gchar *name, gint last_rate)
                        {
                                done = !gtk_list_store_remove(store, &iter);
                        }
-                       else if (ivalue > last)
+                       else if (ivalue < first || ivalue > last)
                        {
                                ii++;
                                gtk_list_store_set(store, &iter, 1, FALSE, -1);
@@ -1936,6 +2725,7 @@ audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name)
        GtkTreeIter iter;
        GtkListStore *store;
        gint ii;
+       gchar *str;
        
        g_debug("audio_bitrate_opts_set ()\n");
        store = get_combo_box_store(builder, name);
@@ -1943,13 +2733,16 @@ audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name)
        for (ii = 0; ii < hb_audio_bitrates_count; ii++)
        {
                gtk_list_store_append(store, &iter);
+               str = g_strdup_printf ("<small>%s</small>", 
+                       hb_audio_bitrates[ii].string);
                gtk_list_store_set(store, &iter, 
-                                                  0, hb_audio_bitrates[ii].string, 
+                                                  0, str,
                                                   1, TRUE, 
                                                   2, hb_audio_bitrates[ii].string, 
-                                                  3, hb_audio_bitrates[ii].rate, 
+                                                  3, (gdouble)hb_audio_bitrates[ii].rate, 
                                                   4, hb_audio_bitrates[ii].string, 
                                                   -1);
+               g_free(str);
        }
 }
 
@@ -1960,23 +2753,31 @@ ghb_set_passthru_bitrate_opts(GtkBuilder *builder, gint bitrate)
 }
 
 void
-ghb_set_default_bitrate_opts(GtkBuilder *builder, gint last_rate)
+ghb_set_default_bitrate_opts(
+       GtkBuilder *builder, 
+       gint first_rate, 
+       gint last_rate)
 {
-       audio_bitrate_opts_clean(builder, "AudioBitrate", last_rate);
+       audio_bitrate_opts_clean(builder, "AudioBitrate", first_rate, last_rate);
 }
 
 static ghb_status_t hb_status;
 
 void
-ghb_backend_init(GtkBuilder *builder, gint debug, gint update)
+ghb_combo_init(signal_user_data_t *ud)
 {
-    /* Init libhb */
-    h_scan = hb_init( debug, update );
-    h_queue = hb_init( debug, 0 );
        // Set up the list model for the combos
-       init_ui_combo_boxes(builder);
+       init_ui_combo_boxes(ud->builder);
        // Populate all the combos
-       ghb_update_ui_combo_box(builder, NULL, 0, TRUE);
+       ghb_update_ui_combo_box(ud, NULL, 0, TRUE);
+}
+
+void
+ghb_backend_init(gint debug)
+{
+    /* Init libhb */
+    h_scan = hb_init( debug, 0 );
+    h_queue = hb_init( debug, 0 );
 }
 
 void
@@ -1987,58 +2788,58 @@ ghb_backend_close()
 }
 
 void
-ghb_backend_scan(const gchar *path, gint titleindex)
+ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count)
 {
-    hb_scan( h_scan, path, titleindex );
-       hb_status.state |= GHB_STATE_SCANNING;
+    hb_scan( h_scan, path, titleindex, preview_count, 1 );
+       hb_status.scan.state |= GHB_STATE_SCANNING;
        // initialize count and cur to something that won't cause FPE
        // when computing progress
-       hb_status.title_count = 1;
-       hb_status.title_cur = 0;
+       hb_status.scan.title_count = 1;
+       hb_status.scan.title_cur = 0;
 }
 
 void
 ghb_backend_queue_scan(const gchar *path, gint titlenum)
 {
        g_debug("ghb_backend_queue_scan()");
-       hb_scan( h_queue, path, titlenum );
-       hb_status.queue_state |= GHB_STATE_SCANNING;
+       hb_scan( h_queue, path, titlenum, 10, 0 );
+       hb_status.queue.state |= GHB_STATE_SCANNING;
 }
 
 gint
-ghb_get_state()
+ghb_get_scan_state()
 {
-       return hb_status.state;
+       return hb_status.scan.state;
 }
 
 gint
 ghb_get_queue_state()
 {
-       return hb_status.queue_state;
+       return hb_status.queue.state;
 }
 
 void
-ghb_clear_state(gint state)
+ghb_clear_scan_state(gint state)
 {
-       hb_status.state &= ~state;
+       hb_status.scan.state &= ~state;
 }
 
 void
 ghb_clear_queue_state(gint state)
 {
-       hb_status.queue_state &= ~state;
+       hb_status.queue.state &= ~state;
 }
 
 void
-ghb_set_state(gint state)
+ghb_set_scan_state(gint state)
 {
-       hb_status.state |= state;
+       hb_status.scan.state |= state;
 }
 
 void
 ghb_set_queue_state(gint state)
 {
-       hb_status.queue_state |= state;
+       hb_status.queue.state |= state;
 }
 
 void
@@ -2050,66 +2851,125 @@ ghb_get_status(ghb_status_t *status)
 void 
 ghb_track_status()
 {
-    hb_state_t s;
+    hb_state_t s_scan;
     hb_state_t s_queue;
 
        if (h_scan == NULL) return;
-    hb_get_state( h_scan, &s );
-       switch( s.state )
+    hb_get_state( h_scan, &s_scan );
+       switch( s_scan.state )
     {
-#define p s.param.scanning
+#define p s_scan.param.scanning
         case HB_STATE_SCANNING:
                {
-                       hb_status.state |= GHB_STATE_SCANNING;
-                       hb_status.title_count = p.title_count;
-                       hb_status.title_cur = p.title_cur;
+                       hb_status.scan.state |= GHB_STATE_SCANNING;
+                       hb_status.scan.title_count = p.title_count;
+                       hb_status.scan.title_cur = p.title_cur;
                } break;
 #undef p
 
         case HB_STATE_SCANDONE:
         {
-                       hb_status.state &= ~GHB_STATE_SCANNING;
-                       hb_status.state |= GHB_STATE_SCANDONE;
+                       hb_status.scan.state &= ~GHB_STATE_SCANNING;
+                       hb_status.scan.state |= GHB_STATE_SCANDONE;
         } break;
 
-    }
-    hb_get_state( h_queue, &s_queue );
-       switch( s_queue.state )
-    {
-        case HB_STATE_SCANNING:
+#define p s_scan.param.working
+        case HB_STATE_WORKING:
+                       hb_status.scan.state |= GHB_STATE_WORKING;
+                       hb_status.scan.state &= ~GHB_STATE_PAUSED;
+                       hb_status.scan.job_cur = p.job_cur;
+                       hb_status.scan.job_count = p.job_count;
+                       hb_status.scan.progress = p.progress;
+                       hb_status.scan.rate_cur = p.rate_cur;
+                       hb_status.scan.rate_avg = p.rate_avg;
+                       hb_status.scan.hours = p.hours;
+                       hb_status.scan.minutes = p.minutes;
+                       hb_status.scan.seconds = p.seconds;
+                       hb_status.scan.unique_id = p.sequence_id & 0xFFFFFF;
+            break;
+#undef p
+
+        case HB_STATE_PAUSED:
+                       hb_status.scan.state |= GHB_STATE_PAUSED;
+            break;
+                               
+        case HB_STATE_MUXING:
+        {
+                       hb_status.scan.state |= GHB_STATE_MUXING;
+        } break;
+
+#define p s_scan.param.workdone
+        case HB_STATE_WORKDONE:
                {
-                       hb_status.queue_state |= GHB_STATE_SCANNING;
+            hb_job_t *job;
+
+                       hb_status.scan.state |= GHB_STATE_WORKDONE;
+                       hb_status.scan.state &= ~GHB_STATE_MUXING;
+                       hb_status.scan.state &= ~GHB_STATE_PAUSED;
+                       hb_status.scan.state &= ~GHB_STATE_WORKING;
+                       switch (p.error)
+                       {
+                       case HB_ERROR_NONE:
+                               hb_status.scan.error = GHB_ERROR_NONE;
+                               break;
+                       case HB_ERROR_CANCELED:
+                               hb_status.scan.error = GHB_ERROR_CANCELED;
+                               break;
+                       default:
+                               hb_status.scan.error = GHB_ERROR_FAIL;
+                               break;
+                       }
+                       // Delete all remaining jobs of this encode.
+                       // An encode can be composed of multiple associated jobs.
+                       // When a job is stopped, libhb removes it from the job list,
+                       // but does not remove other jobs that may be associated with it.
+                       // Associated jobs are taged in the sequence id.
+            while ((job = hb_job(h_scan, 0)) != NULL) 
+                hb_rem( h_scan, job );
                } break;
+#undef p
+    }
+    hb_get_state( h_queue, &s_queue );
+       switch( s_queue.state )
+    {
+#define p s_queue.param.scanning
+        case HB_STATE_SCANNING:
+               {
+                       hb_status.queue.state |= GHB_STATE_SCANNING;
+                       hb_status.queue.title_count = p.title_count;
+                       hb_status.queue.title_cur = p.title_cur;
+               } break;
+#undef p
 
         case HB_STATE_SCANDONE:
         {
-                       hb_status.queue_state &= ~GHB_STATE_SCANNING;
-                       hb_status.queue_state |= GHB_STATE_SCANDONE;
+                       hb_status.queue.state &= ~GHB_STATE_SCANNING;
+                       hb_status.queue.state |= GHB_STATE_SCANDONE;
         } break;
 
 #define p s_queue.param.working
         case HB_STATE_WORKING:
-                       hb_status.queue_state |= GHB_STATE_WORKING;
-                       hb_status.queue_state &= ~GHB_STATE_PAUSED;
-                       hb_status.job_cur = p.job_cur;
-                       hb_status.job_count = p.job_count;
-                       hb_status.progress = p.progress;
-                       hb_status.rate_cur = p.rate_cur;
-                       hb_status.rate_avg = p.rate_avg;
-                       hb_status.hours = p.hours;
-                       hb_status.minutes = p.minutes;
-                       hb_status.seconds = p.seconds;
-                       hb_status.unique_id = p.sequence_id & 0xFFFFFF;
+                       hb_status.queue.state |= GHB_STATE_WORKING;
+                       hb_status.queue.state &= ~GHB_STATE_PAUSED;
+                       hb_status.queue.job_cur = p.job_cur;
+                       hb_status.queue.job_count = p.job_count;
+                       hb_status.queue.progress = p.progress;
+                       hb_status.queue.rate_cur = p.rate_cur;
+                       hb_status.queue.rate_avg = p.rate_avg;
+                       hb_status.queue.hours = p.hours;
+                       hb_status.queue.minutes = p.minutes;
+                       hb_status.queue.seconds = p.seconds;
+                       hb_status.queue.unique_id = p.sequence_id & 0xFFFFFF;
             break;
 #undef p
 
         case HB_STATE_PAUSED:
-                       hb_status.queue_state |= GHB_STATE_PAUSED;
+                       hb_status.queue.state |= GHB_STATE_PAUSED;
             break;
                                
         case HB_STATE_MUXING:
         {
-                       hb_status.queue_state |= GHB_STATE_MUXING;
+                       hb_status.queue.state |= GHB_STATE_MUXING;
         } break;
 
 #define p s_queue.param.workdone
@@ -2117,20 +2977,22 @@ ghb_track_status()
                {
             hb_job_t *job;
 
-                       hb_status.queue_state |= GHB_STATE_WORKDONE;
-                       hb_status.queue_state &= ~GHB_STATE_MUXING;
-                       hb_status.queue_state &= ~GHB_STATE_PAUSED;
-                       hb_status.queue_state &= ~GHB_STATE_WORKING;
+                       hb_status.queue.state |= GHB_STATE_WORKDONE;
+                       hb_status.queue.state &= ~GHB_STATE_MUXING;
+                       hb_status.queue.state &= ~GHB_STATE_PAUSED;
+                       hb_status.queue.state &= ~GHB_STATE_WORKING;
                        switch (p.error)
                        {
                        case HB_ERROR_NONE:
-                               hb_status.error = GHB_ERROR_NONE;
+                               hb_status.queue.error = GHB_ERROR_NONE;
+                               break;
                        case HB_ERROR_CANCELED:
-                               hb_status.error = GHB_ERROR_CANCELED;
+                               hb_status.queue.error = GHB_ERROR_CANCELED;
+                               break;
                        default:
-                               hb_status.error = GHB_ERROR_FAIL;
+                               hb_status.queue.error = GHB_ERROR_FAIL;
+                               break;
                        }
-                       hb_status.error = p.error;
                        // Delete all remaining jobs of this encode.
                        // An encode can be composed of multiple associated jobs.
                        // When a job is stopped, libhb removes it from the job list,
@@ -2177,6 +3039,8 @@ ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex)
        tinfo->minutes = title->minutes;
        tinfo->seconds = title->seconds;
        tinfo->duration = title->duration;
+
+       tinfo->angle_count = title->angle_count;
        return TRUE;
 }
 
@@ -2197,8 +3061,7 @@ gboolean
 ghb_audio_is_passthru(gint acodec)
 {
        g_debug("ghb_audio_is_passthru () \n");
-       g_debug("acodec %d\n", acodec);
-       return (acodec == HB_ACODEC_AC3);
+       return (acodec & (HB_ACODEC_AC3 | HB_ACODEC_DCA));
 }
 
 gint
@@ -2207,28 +3070,80 @@ ghb_get_default_acodec()
        return HB_ACODEC_FAAC;
 }
 
+static void
+picture_settings_deps(signal_user_data_t *ud)
+{
+       gboolean autoscale, keep_aspect, enable_keep_aspect;
+       gboolean enable_scale_width, enable_scale_height;
+       gboolean enable_disp_width, enable_disp_height, enable_par;
+       gint pic_par;
+       GtkWidget *widget;
+
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
+       if (pic_par == 1)
+       {
+               ghb_ui_update(ud, "autoscale", ghb_boolean_value(TRUE));
+               ghb_ui_update(ud, "PictureModulus", ghb_int_value(2));
+               ghb_ui_update(ud, "PictureLooseCrop", ghb_boolean_value(TRUE));
+       }
+       enable_keep_aspect = (pic_par != 1 && pic_par != 2);
+       if (!enable_keep_aspect)
+       {
+               ghb_ui_update(ud, "PictureKeepRatio", ghb_boolean_value(TRUE));
+       }
+       keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
+       autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
+
+       enable_scale_width = !autoscale && (pic_par != 1);
+       enable_scale_height = !autoscale && (pic_par != 1);
+       enable_disp_width = (pic_par == 3) && !keep_aspect;
+       enable_par = (pic_par == 3) && !keep_aspect;
+       enable_disp_height = FALSE;
+
+       widget = GHB_WIDGET(ud->builder, "PictureModulus");
+       gtk_widget_set_sensitive(widget, pic_par != 1);
+       widget = GHB_WIDGET(ud->builder, "PictureLooseCrop");
+       gtk_widget_set_sensitive(widget, pic_par != 1);
+       widget = GHB_WIDGET(ud->builder, "scale_width");
+       gtk_widget_set_sensitive(widget, enable_scale_width);
+       widget = GHB_WIDGET(ud->builder, "scale_height");
+       gtk_widget_set_sensitive(widget, enable_scale_height);
+       widget = GHB_WIDGET(ud->builder, "PictureDisplayWidth");
+       gtk_widget_set_sensitive(widget, enable_disp_width);
+       widget = GHB_WIDGET(ud->builder, "PictureDisplayHeight");
+       gtk_widget_set_sensitive(widget, enable_disp_height);
+       widget = GHB_WIDGET(ud->builder, "PicturePARWidth");
+       gtk_widget_set_sensitive(widget, enable_par);
+       widget = GHB_WIDGET(ud->builder, "PicturePARHeight");
+       gtk_widget_set_sensitive(widget, enable_par);
+       widget = GHB_WIDGET(ud->builder, "PictureKeepRatio");
+       gtk_widget_set_sensitive(widget, enable_keep_aspect);
+       widget = GHB_WIDGET(ud->builder, "autoscale");
+       gtk_widget_set_sensitive(widget, pic_par != 1);
+}
+
 void
 ghb_set_scale(signal_user_data_t *ud, gint mode)
 {
        hb_list_t  * list;
        hb_title_t * title;
        hb_job_t   * job;
-       gboolean keep_aspect, round_dims, anamorphic;
+       gboolean keep_aspect;
+       gint pic_par;
        gboolean autocrop, autoscale, noscale;
        gint crop[4], width, height, par_width, par_height;
        gint crop_width, crop_height;
        gint aspect_n, aspect_d;
-       gboolean keep_width = (mode == GHB_SCALE_KEEP_WIDTH);
-       gboolean keep_height = (mode == GHB_SCALE_KEEP_HEIGHT);
+       gboolean keep_width = (mode & GHB_PIC_KEEP_WIDTH);
+       gboolean keep_height = (mode & GHB_PIC_KEEP_HEIGHT);
        gint step;
        GtkWidget *widget;
-       gint modshift;
-       gint modround;
+       gint mod;
        gint max_width = 0;
        gint max_height = 0;
+       static gboolean busy = FALSE;
        
        g_debug("ghb_set_scale ()\n");
-
        if (h_scan == NULL) return;
        list = hb_get_titles( h_scan );
        if( !hb_list_count( list ) )
@@ -2243,74 +3158,105 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
        if (title == NULL) return;
        job   = title->job;
        if (job == NULL) return;
-       
+
+       picture_settings_deps(ud);
+       if (busy) return;
+       busy = TRUE;
+
+       if (!ud->dont_clear_presets && (keep_width || keep_height))
+       {
+               ghb_settings_set_int(ud->settings, "PictureWidth", 0);
+               ghb_settings_set_int(ud->settings, "PictureHeight", 0);
+       }
+
        // First configure widgets
-       round_dims = ghb_settings_get_boolean(ud->settings, "ModDimensions");
-       anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic");
+       mod = ghb_settings_combo_int(ud->settings, "PictureModulus");
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
        keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
        autocrop = ghb_settings_get_boolean(ud->settings, "PictureAutoCrop");
        autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
        // "Noscale" is a flag that says we prefer to crop extra to satisfy
        // alignment constraints rather than scaling to satisfy them.
-       noscale = ghb_settings_get_boolean(ud->settings, "noscale");
+       noscale = ghb_settings_get_boolean(ud->settings, "PictureLooseCrop");
        // Align dimensions to either 16 or 2 pixels
        // The scaler crashes if the dimensions are not divisible by 2
        // x264 also will not accept dims that are not multiple of 2
-       modshift = round_dims ? 4 : 1;
-       modround = round_dims ? 8 : 1;
        if (autoscale)
        {
                keep_width = FALSE;
                keep_height = FALSE;
        }
-       if (anamorphic || keep_aspect)
-       {
-               keep_height = FALSE;
-       }
        // Step needs to be at least 2 because odd widths cause scaler crash
-       step = round_dims ? 16 : 2;
+       step = mod;
        widget = GHB_WIDGET (ud->builder, "scale_width");
        gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
        widget = GHB_WIDGET (ud->builder, "scale_height");
        gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
+       if (noscale)
+       {
+               widget = GHB_WIDGET (ud->builder, "PictureTopCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureBottomCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureLeftCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureRightCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), step, 16);
+       }
+       else
+       {
+               widget = GHB_WIDGET (ud->builder, "PictureTopCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureBottomCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureLeftCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16);
+               widget = GHB_WIDGET (ud->builder, "PictureRightCrop");
+               gtk_spin_button_set_increments (GTK_SPIN_BUTTON(widget), 1, 16);
+       }
+       ghb_title_info_t tinfo;
+       ghb_get_title_info (&tinfo, titleindex);
        if (autocrop)
        {
-               ghb_title_info_t tinfo;
-
-               if (ghb_get_title_info (&tinfo, titleindex))
-               {
-                       crop[0] = tinfo.crop[0];
-                       crop[1] = tinfo.crop[1];
-                       crop[2] = tinfo.crop[2];
-                       crop[3] = tinfo.crop[3];
-                       if (noscale)
-                       {
-                               gint need1, need2;
-
-                               // Adjust the cropping to accomplish the desired width and height
-                               crop_width = tinfo.width - crop[2] - crop[3];
-                               crop_height = tinfo.height - crop[0] - crop[1];
-                               width = (crop_width >> modshift) << modshift;
-                               height = (crop_height >> modshift) << modshift;
-                               need1 = (crop_height - height) / 2;
-                               need2 = crop_height - height - need1;
-                               crop[0] += need1;
-                               crop[1] += need2;
-                               need1 = (crop_width - width) / 2;
-                               need2 = crop_width - width - need1;
-                               crop[2] += need1;
-                               crop[3] += need2;
-                       }
-                       ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0]));
-                       ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1]));
-                       ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2]));
-                       ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3]));
-               }
+               crop[0] = tinfo.crop[0];
+               crop[1] = tinfo.crop[1];
+               crop[2] = tinfo.crop[2];
+               crop[3] = tinfo.crop[3];
+               ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0]));
+               ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1]));
+               ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2]));
+               ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3]));
+       }
+       else
+       {
+               crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop");
+               crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop");
+               crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop");
+               crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop");
+       }
+       if (noscale)
+       {
+               gint need1, need2;
+
+               // Adjust the cropping to accomplish the desired width and height
+               crop_width = tinfo.width - crop[2] - crop[3];
+               crop_height = tinfo.height - crop[0] - crop[1];
+               width = MOD_DOWN(crop_width, mod);
+               height = MOD_DOWN(crop_height, mod);
+
+               need1 = (crop_height - height) / 2;
+               need2 = crop_height - height - need1;
+               crop[0] += need1;
+               crop[1] += need2;
+               need1 = (crop_width - width) / 2;
+               need2 = crop_width - width - need1;
+               crop[2] += need1;
+               crop[3] += need2;
+               ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(crop[0]));
+               ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(crop[1]));
+               ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(crop[2]));
+               ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(crop[3]));
        }
-       crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop");
-       crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop");
-       crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop");
-       crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop");
        hb_reduce(&aspect_n, &aspect_d, 
                                title->width * title->pixel_aspect_width, 
                                title->height * title->pixel_aspect_height);
@@ -2320,81 +3266,107 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
        {
                width = crop_width;
                height = crop_height;
-               max_width = 0; //crop_width;
-               max_height = 0; //crop_height;
        }
        else
        {
                width = ghb_settings_get_int(ud->settings, "scale_width");
                height = ghb_settings_get_int(ud->settings, "scale_height");
-               max_width = ghb_settings_get_int(ud->settings, "PictureWidth");
-               max_height = ghb_settings_get_int(ud->settings, "PictureHeight");
-               // Align max dims 
-               max_width = (max_width >> modshift) << modshift;
-               max_height = (max_height >> modshift) << modshift;
-               // Adjust dims according to max values
-               if (!max_height)
-               {
-                       max_height = crop_height;
-               }
-               if (!max_width)
-               {
-                       max_width = crop_width;
-               }
-               height = MIN(height, max_height);
-               width = MIN(width, max_width);
-               g_debug("max_width %d, max_height %d\n", max_width, max_height);
+               max_width = MOD_DOWN(
+                       ghb_settings_get_int(ud->settings, "PictureWidth"), mod);
+               max_height = MOD_DOWN(
+                       ghb_settings_get_int(ud->settings, "PictureHeight"), mod);
        }
+       g_debug("max_width %d, max_height %d\n", max_width, max_height);
+
        if (width < 16)
                width = title->width - crop[2] - crop[3];
        if (height < 16)
                height = title->height - crop[0] - crop[1];
 
-       if (anamorphic)
+       width = MOD_ROUND(width, mod);
+       height = MOD_ROUND(height, mod);
+
+       // Adjust dims according to max values
+       if (max_height)
+               height = MIN(height, max_height);
+       if (max_width)
+               width = MIN(width, max_width);
+
+       if (pic_par)
        {
-               if (round_dims)
+               job->anamorphic.mode = pic_par;
+               // The scaler crashes if the dimensions are not divisible by 2
+               // Align mod 2.  And so does something in x264_encoder_headers()
+               job->anamorphic.modulus = mod;
+               job->anamorphic.par_width = title->pixel_aspect_width;
+               job->anamorphic.par_height = title->pixel_aspect_height;
+               job->anamorphic.dar_width = 0;
+               job->anamorphic.dar_height = 0;
+
+               if (keep_height && pic_par == 2)
+                       width = ((double)height * crop_width / crop_height) + mod / 2;
+               job->width = width;
+               job->height = height;
+               job->maxWidth = max_width;
+               job->maxHeight = max_height;
+               job->crop[0] = crop[0]; job->crop[1] = crop[1];
+               job->crop[2] = crop[2]; job->crop[3] = crop[3];
+               if (job->anamorphic.mode == 3 && !keep_aspect)
                {
-                       job->modulus = 0;
+                       job->anamorphic.keep_display_aspect = 0;
+                       if (mode & GHB_PIC_KEEP_PAR)
+                       {
+                               job->anamorphic.par_width = 
+                                       ghb_settings_get_int(ud->settings, "PicturePARWidth");
+                               job->anamorphic.par_height = 
+                                       ghb_settings_get_int(ud->settings, "PicturePARHeight");
+                       }
+                       else
+                       {
+                               job->anamorphic.dar_width = 
+                                       ghb_settings_get_int(ud->settings, 
+                                                                               "PictureDisplayWidth");
+                               job->anamorphic.dar_height = height;
+                       }
                }
                else
                {
-                       // The scaler crashes if the dimensions are not divisible by 2
-                       // Align mod 2.  And so does something in x264_encoder_headers()
-                       job->modulus = 2;
+                       job->anamorphic.keep_display_aspect = 1;
                }
-               job->width = width;
-               if (max_height) 
-                       job->maxHeight = max_height;
-               job->crop[0] = crop[0]; job->crop[1] = crop[1];
-               job->crop[2] = crop[2]; job->crop[3] = crop[3];
                hb_set_anamorphic_size( job, &width, &height, 
                                                                &par_width, &par_height );
+               if (job->anamorphic.mode == 3 && !keep_aspect && 
+                       mode & GHB_PIC_KEEP_PAR)
+               {
+                       // hb_set_anamorphic_size reduces the par, which we
+                       // don't want in this case because the user is
+                       // explicitely specifying it.
+                       par_width = ghb_settings_get_int(ud->settings, 
+                                                                                       "PicturePARWidth");
+                       par_height = ghb_settings_get_int(ud->settings, 
+                                                                                               "PicturePARHeight");
+               }
        }
        else 
        {
+               job->anamorphic.mode = pic_par;
                if (keep_aspect)
                {
                        gdouble par;
                        gint new_width, new_height;
                        
-                       g_debug("kw %s kh %s\n", keep_width ? "y":"n", keep_height ? "y":"n");
-                       g_debug("w %d h %d\n", width, height);
                        // Compute pixel aspect ration.  
                        par = (gdouble)(title->height * aspect_n) / (title->width * aspect_d);
                        // Must scale so that par becomes 1:1
                        // Try to keep largest dimension
                        new_height = (crop_height * ((gdouble)width/crop_width) / par);
                        new_width = (crop_width * ((gdouble)height/crop_height) * par);
-                       // Height and width are always multiples of 2, so do the rounding
-                       new_height = ((new_height + 1) >> 1) << 1;
-                       new_width = ((new_width + 1) >> 1) << 1;
-                       if ((max_width && new_width > max_width) || 
-                               new_width > title->width)
+
+                       if (max_width && new_width > max_width)
                        {
                                height = new_height;
                        }
-                       else if ((max_height && new_height > max_height) || 
-                                               new_height > title->height)
+                       else if (max_height && new_height > max_height)
                        {
                                width = new_width;
                        }
@@ -2416,11 +3388,47 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
                        }
                        g_debug("new w %d h %d\n", width, height);
                }
-               width = ((width + modround) >> modshift) << modshift;
-               height = ((height + modround) >> modshift) << modshift;
+               width = MOD_ROUND(width, mod);
+               height = MOD_ROUND(height, mod);
+               if (max_height)
+                       height = MIN(height, max_height);
+               if (max_width)
+                       width = MIN(width, max_width);
+               par_width = par_height = 1;
        }
        ghb_ui_update(ud, "scale_width", ghb_int64_value(width));
        ghb_ui_update(ud, "scale_height", ghb_int64_value(height));
+
+       gint disp_width, dar_width, dar_height;
+       gchar *str;
+
+       disp_width = (gdouble)(width * par_width / par_height) + 0.5;
+       hb_reduce(&dar_width, &dar_height, disp_width, height);
+               
+       gint iaspect = dar_width * 9 / dar_height;
+       if (dar_width > 2 * dar_height)
+       {
+               str = g_strdup_printf("%.2f : 1", (gdouble)dar_width / dar_height);
+       }
+       else if (iaspect <= 16 && iaspect >= 15)
+       {
+               str = g_strdup_printf("%.2f : 9", (gdouble)dar_width * 9 / dar_height);
+       }
+       else if (iaspect <= 12 && iaspect >= 11)
+       {
+               str = g_strdup_printf("%.2f : 3", (gdouble)dar_width * 3 / dar_height);
+       }
+       else
+       {
+               str = g_strdup_printf("%d : %d", dar_width, dar_height);
+       }
+       ghb_ui_update(ud, "display_aspect", ghb_string_value(str));
+       g_free(str);
+       ghb_ui_update(ud, "PicturePARWidth", ghb_int64_value(par_width));
+       ghb_ui_update(ud, "PicturePARHeight", ghb_int64_value(par_height));
+       ghb_ui_update(ud, "PictureDisplayWidth", ghb_int64_value(disp_width));
+       ghb_ui_update(ud, "PictureDisplayHeight", ghb_int64_value(height));
+       busy = FALSE;
 }
 
 static void
@@ -2431,29 +3439,61 @@ set_preview_job_settings(hb_job_t *job, GValue *settings)
        job->crop[2] = ghb_settings_get_int(settings, "PictureLeftCrop");
        job->crop[3] = ghb_settings_get_int(settings, "PictureRightCrop");
 
-       gboolean anamorphic, round_dimensions;
-       anamorphic = ghb_settings_get_boolean(settings, "anamorphic");
-       round_dimensions = ghb_settings_get_boolean(settings, "ModDimensions");
-       if (round_dimensions && anamorphic)
+       job->anamorphic.mode = ghb_settings_combo_int(settings, "PicturePAR");
+       job->anamorphic.modulus = 
+               ghb_settings_combo_int(settings, "PictureModulus");
+       job->width = ghb_settings_get_int(settings, "scale_width");
+       job->height = ghb_settings_get_int(settings, "scale_height");
+       if (ghb_settings_get_boolean(settings, "show_crop"))
        {
-               job->modulus = 16;
-               job->pixel_ratio = 2;
+               gdouble xscale = (gdouble)job->width / 
+                       (gdouble)(job->title->width - job->crop[2] - job->crop[3]);
+               gdouble yscale = (gdouble)job->height / 
+                       (gdouble)(job->title->height - job->crop[0] - job->crop[1]);
+       
+               job->width += xscale * (job->crop[2] + job->crop[3]);
+               job->height += yscale * (job->crop[0] + job->crop[1]);
+               job->crop[0] = 0;
+               job->crop[1] = 0;
+               job->crop[2] = 0;
+               job->crop[3] = 0;
+               job->anamorphic.modulus = 2;
        }
-       else if (anamorphic)
+
+       gboolean decomb_deint = ghb_settings_get_boolean(settings, "PictureDecombDeinterlace");
+       if (decomb_deint)
        {
-               job->modulus = 2;
-               job->pixel_ratio = 2;
+               gint decomb = ghb_settings_combo_int(settings, "PictureDecomb");
+               job->deinterlace = (decomb == 0) ? 0 : 1;
        }
        else
        {
-               job->modulus = 2;
-               job->pixel_ratio = 0;
+               gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
+               job->deinterlace = (deint == 0) ? 0 : 1;
+       }
+
+       gboolean keep_aspect;
+       keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio");
+       if (job->anamorphic.mode)
+       {
+               job->anamorphic.par_width = job->title->pixel_aspect_width;
+               job->anamorphic.par_height = job->title->pixel_aspect_height;
+               job->anamorphic.dar_width = 0;
+               job->anamorphic.dar_height = 0;
+
+               if (job->anamorphic.mode == 3 && !keep_aspect)
+               {
+                       job->anamorphic.keep_display_aspect = 0;
+                       job->anamorphic.par_width = 
+                               ghb_settings_get_int(settings, "PicturePARWidth");
+                       job->anamorphic.par_height = 
+                               ghb_settings_get_int(settings, "PicturePARHeight");
+               }
+               else
+               {
+                       job->anamorphic.keep_display_aspect = 1;
+               }
        }
-       job->width = ghb_settings_get_int(settings, "scale_width");
-       job->height = ghb_settings_get_int(settings, "scale_height");
-       gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
-       gboolean decomb = ghb_settings_get_boolean(settings, "PictureDecomb");
-       job->deinterlace = (!decomb && deint == 0) ? 0 : 1;
 }
 
 gint
@@ -2505,79 +3545,78 @@ ghb_validate_filter_string(const gchar *str, gint max_fields)
 gboolean
 ghb_validate_filters(signal_user_data_t *ud)
 {
-       gboolean tweaks;
        gchar *str;
        gint index;
        gchar *message;
-       gboolean enabled;
 
-       tweaks = ghb_settings_get_boolean(ud->settings, "allow_tweaks");
-       if (tweaks)
+       gboolean decomb_deint = ghb_settings_get_boolean(ud->settings, "PictureDecombDeinterlace");
+       // deinte
+       index = ghb_settings_combo_int(ud->settings, "PictureDeinterlace");
+       if (!decomb_deint && index == 1)
        {
-               // detele 6
-               str = ghb_settings_get_string(ud->settings, "tweak_PictureDetelecine");
-               enabled = ghb_settings_get_boolean(ud->settings, "PictureDetelecine");
-               if (enabled && !ghb_validate_filter_string(str, 6))
+               str = ghb_settings_get_string(ud->settings, "PictureDeinterlaceCustom");
+               if (!ghb_validate_filter_string(str, -1))
                {
                        message = g_strdup_printf(
-                                               "Invalid Detelecine Settings:\n\n%s\n",
+                                               "Invalid Deinterlace Settings:\n\n%s\n",
                                                str);
                        ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
-                       g_free(str);
                        g_free(message);
+                       g_free(str);
                        return FALSE;
                }
                g_free(str);
-               // decomb 7
-               str = ghb_settings_get_string(ud->settings, "tweak_PictureDecomb");
-               enabled = ghb_settings_get_boolean(ud->settings, "PictureDecomb");
-               if (enabled && !ghb_validate_filter_string(str, 7))
+       }
+       // detel
+       index = ghb_settings_combo_int(ud->settings, "PictureDetelecine");
+       if (index == 1)
+       {
+               str = ghb_settings_get_string(ud->settings, "PictureDetelecineCustom");
+               if (!ghb_validate_filter_string(str, -1))
                {
                        message = g_strdup_printf(
-                                               "Invalid Decomb Settings:\n\n%s\n",
+                                               "Invalid Detelecine Settings:\n\n%s\n",
                                                str);
                        ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
-                       g_free(str);
                        g_free(message);
+                       g_free(str);
                        return FALSE;
                }
                g_free(str);
-               // deinte 4
-               index = ghb_lookup_combo_int("tweak_PictureDeinterlace", 
-                       ghb_settings_get_value(ud->settings, "tweak_PictureDeinterlace"));
-               if (index < 0)
+       }
+       // decomb
+       index = ghb_settings_combo_int(ud->settings, "PictureDecomb");
+       if (decomb_deint && index == 1)
+       {
+               str = ghb_settings_get_string(ud->settings, "PictureDecombCustom");
+               if (!ghb_validate_filter_string(str, -1))
                {
-                       str = ghb_settings_get_string(ud->settings, "tweak_PictureDeinterlace");
-                       if (!ghb_validate_filter_string(str, 4))
-                       {
-                               message = g_strdup_printf(
-                                                       "Invalid Deinterlace Settings:\n\n%s\n",
-                                                       str);
-                               ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
-                               g_free(message);
-                               g_free(str);
-                               return FALSE;
-                       }
+                       message = g_strdup_printf(
+                                               "Invalid Decomb Settings:\n\n%s\n",
+                                               str);
+                       ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+                       g_free(message);
                        g_free(str);
+                       return FALSE;
                }
-               // denois 4
-               index = ghb_lookup_combo_int("tweak_PictureDenoise", 
-                               ghb_settings_get_value(ud->settings, "tweak_PictureDenoise"));
-               if (index < 0)
+               g_free(str);
+       }
+       // denois
+       index = ghb_settings_combo_int(ud->settings, "PictureDenoise");
+       if (index == 1)
+       {
+               str = ghb_settings_get_string(ud->settings, "PictureDenoiseCustom");
+               if (!ghb_validate_filter_string(str, -1))
                {
-                       str = ghb_settings_get_string(ud->settings, "tweak_PictureDenoise");
-                       if (!ghb_validate_filter_string(str, 4))
-                       {
-                               message = g_strdup_printf(
-                                                       "Invalid Denoise Settings:\n\n%s\n",
-                                                       str);
-                               ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
-                               g_free(str);
-                               g_free(message);
-                               return FALSE;
-                       }
+                       message = g_strdup_printf(
+                                               "Invalid Denoise Settings:\n\n%s\n",
+                                               str);
+                       ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
                        g_free(str);
+                       g_free(message);
+                       return FALSE;
                }
+               g_free(str);
        }
        return TRUE;
 }
@@ -2590,24 +3629,176 @@ ghb_validate_video(signal_user_data_t *ud)
 
        mux = ghb_settings_combo_int(ud->settings, "FileFormat");
        vcodec = ghb_settings_combo_int(ud->settings, "VideoEncoder");
-       if ((mux == HB_MUX_MP4 || mux == HB_MUX_AVI) && 
-               (vcodec == HB_VCODEC_THEORA))
+       if ((mux == HB_MUX_MP4) && (vcodec == HB_VCODEC_THEORA))
        {
-               // mp4|avi/theora combination is not supported.
+               // mp4/theora combination is not supported.
                message = g_strdup_printf(
-                                       "Theora is not supported in the MP4 and AVI containers.\n\n"
+                                       "Theora is not supported in the MP4 container.\n\n"
                                        "You should choose a different video codec or container.\n"
-                                       "If you continue, XviD will be chosen for you.");
+                                       "If you continue, FFMPEG will be chosen for you.");
                if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, "Cancel", "Continue"))
                {
                        g_free(message);
                        return FALSE;
                }
                g_free(message);
-               vcodec = HB_VCODEC_XVID;
+               vcodec = HB_VCODEC_FFMPEG;
                ghb_ui_update(ud, "VideoEncoder", ghb_int64_value(vcodec));
        }
-       return TRUE;
+       return TRUE;
+}
+
+gboolean
+ghb_validate_subtitles(signal_user_data_t *ud)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+       gchar *message;
+
+       if (h_scan == NULL) return FALSE;
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               /* No valid title, stop right there */
+               g_message("No title found.\n");
+               return FALSE;
+       }
+
+       gint titleindex;
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+    title = hb_list_item( list, titleindex );
+       if (title == NULL) return FALSE;
+       gint mux = ghb_settings_combo_int(ud->settings, "FileFormat");
+
+       const GValue *slist, *settings;
+       gint count, ii, source;
+       gboolean burned, one_burned = FALSE;
+
+       slist = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(slist);
+       for (ii = 0; ii < count; ii++)
+       {
+               settings = ghb_array_get_nth(slist, ii);
+               source = ghb_settings_get_int(settings, "SubtitleSource");
+               burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+               if (burned && one_burned)
+               {
+                       // MP4 can only handle burned vobsubs.  make sure there isn't
+                       // already something burned in the list
+                       message = g_strdup_printf(
+                       "Only one subtitle may be burned into the video.\n\n"
+                               "You should change your subtitle selections.\n"
+                               "If you continue, some subtitles will be lost.");
+                       if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, "Cancel", "Continue"))
+                       {
+                               g_free(message);
+                               return FALSE;
+                       }
+                       g_free(message);
+                       break;
+               }
+               else if (burned)
+               {
+                       one_burned = TRUE;
+               }
+               if (!burned && mux == HB_MUX_MP4 && source == VOBSUB)
+               {
+                       // MP4 can only handle burned vobsubs.  make sure there isn't
+                       // already something burned in the list
+                       message = g_strdup_printf(
+                       "Your chosen container does not support soft bitmap subtitles.\n\n"
+                               "You should change your subtitle selections.\n"
+                               "If you continue, some subtitles will be lost.");
+                       if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, 
+                               "Cancel", "Continue"))
+                       {
+                               g_free(message);
+                               return FALSE;
+                       }
+                       g_free(message);
+                       break;
+               }
+               if (source == SRTSUB)
+               {
+                       gchar *filename;
+
+                       filename = ghb_settings_get_string(settings, "SrtFile");
+                       if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+                       {
+                               message = g_strdup_printf(
+                               "Srt file does not exist or not a regular file.\n\n"
+                                       "You should choose a valid file.\n"
+                                       "If you continue, this subtitle will be ignored.");
+                               if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, 
+                                       "Cancel", "Continue"))
+                               {
+                                       g_free(message);
+                                       return FALSE;
+                               }
+                               g_free(message);
+                               break;
+                       }
+               }
+       }
+       return TRUE;
+}
+
+gint
+ghb_select_audio_codec(signal_user_data_t *ud, gint track)
+{
+       hb_list_t  * list;
+       hb_title_t * title;
+       hb_audio_config_t *audio;
+
+       if (h_scan == NULL) return -1;
+       list = hb_get_titles( h_scan );
+       if( !hb_list_count( list ) )
+       {
+               return -1;
+       }
+
+       gint titleindex;
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+    title = hb_list_item( list, titleindex );
+       if (title == NULL) return -1;
+
+       gint mux = ghb_settings_combo_int(ud->settings, "FileFormat");
+
+       if (track < 0 || track >= hb_list_count(title->list_audio))
+               return -1;
+
+       audio = (hb_audio_config_t *) hb_list_audio_config_item(
+                                                                       title->list_audio, track );
+       if (mux == HB_MUX_MP4)
+       {
+               if (audio->in.codec == HB_ACODEC_AC3)
+                       return audio->in.codec;
+               else
+                       return HB_ACODEC_FAAC;
+       }
+       else
+       {
+               if (audio->in.codec == HB_ACODEC_AC3 || audio->in.codec == HB_ACODEC_DCA)
+                       return audio->in.codec;
+               else
+                       return HB_ACODEC_LAME;
+       }
+}
+
+const gchar*
+ghb_select_audio_codec_str(signal_user_data_t *ud, gint track)
+{
+       gint acodec, ii;
+
+       acodec = ghb_select_audio_codec(ud, track);
+       for (ii = 0; ii < acodec_opts.count; ii++)
+       {
+               if (acodec_opts.map[ii].ivalue == acodec)
+                       return acodec_opts.map[ii].option;
+       }
+       return "Unknown";
 }
 
 gboolean
@@ -2647,13 +3838,17 @@ ghb_validate_audio(signal_user_data_t *ud)
                asettings = ghb_array_get_nth(audio_list, ii);
                gint track = ghb_settings_combo_int(asettings, "AudioTrack");
                gint codec = ghb_settings_combo_int(asettings, "AudioEncoder");
+               if (codec == HB_ACODEC_MASK)
+                       continue;
+
         taudio = (hb_audio_config_t *) hb_list_audio_config_item(
                                                                                        title->list_audio, track );
-               if ((taudio->in.codec != HB_ACODEC_AC3) && (codec == HB_ACODEC_AC3))
+               if (!(taudio->in.codec & codec) && 
+                       (codec & (HB_ACODEC_AC3 | HB_ACODEC_DCA)))
                {
                        // Not supported.  AC3 is passthrough only, so input must be AC3
                        message = g_strdup_printf(
-                                               "The source does not support AC3 Pass-Thru.\n\n"
+                                               "The source does not support Pass-Thru.\n\n"
                                                "You should choose a different audio codec.\n"
                                                "If you continue, one will be chosen for you.");
                        if (!ghb_message_dialog(GTK_MESSAGE_WARNING, message, "Cancel", "Continue"))
@@ -2662,7 +3857,7 @@ ghb_validate_audio(signal_user_data_t *ud)
                                return FALSE;
                        }
                        g_free(message);
-                       if (mux == HB_MUX_AVI)
+                       if (mux == HB_MUX_MKV)
                        {
                                codec = HB_ACODEC_LAME;
                        }
@@ -2689,35 +3884,10 @@ ghb_validate_audio(signal_user_data_t *ud)
                                a_unsup = "Vorbis";
                                codec = HB_ACODEC_FAAC;
                        }
-               }
-               else if (mux == HB_MUX_AVI)
-               {
-                       mux_s = "AVI";
-                       // avi/faac|vorbis combination is not supported.
-                       if (codec == HB_ACODEC_FAAC)
-                       {
-                               a_unsup = "FAAC";
-                               codec = HB_ACODEC_LAME;
-                       }
-                       if (codec == HB_ACODEC_VORBIS)
-                       {
-                               a_unsup = "Vorbis";
-                               codec = HB_ACODEC_LAME;
-                       }
-               }
-               else if (mux == HB_MUX_OGM)
-               {
-                       mux_s = "OGM";
-                       // avi/faac|vorbis combination is not supported.
-                       if (codec == HB_ACODEC_FAAC)
-                       {
-                               a_unsup = "FAAC";
-                               codec = HB_ACODEC_VORBIS;
-                       }
-                       if (codec == HB_ACODEC_AC3)
+                       if (codec == HB_ACODEC_DCA)
                        {
-                               a_unsup = "AC-3";
-                               codec = HB_ACODEC_VORBIS;
+                               a_unsup = "DTS";
+                               codec = HB_ACODEC_FAAC;
                        }
                }
                if (a_unsup)
@@ -2743,7 +3913,7 @@ ghb_validate_audio(signal_user_data_t *ud)
                gboolean allow_6ch = TRUE;
                allow_mono =
                        (taudio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (codec != HB_ACODEC_LAME);
+                       (codec & ~HB_ACODEC_LAME);
                gint layout = taudio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
                allow_stereo =
                        ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
@@ -2754,7 +3924,7 @@ ghb_validate_audio(signal_user_data_t *ud)
                allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
                allow_6ch =
                        (taudio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
-                       (codec != HB_ACODEC_LAME) &&
+                       (codec & ~HB_ACODEC_LAME) &&
                        (layout == HB_INPUT_CH_LAYOUT_3F2R) && 
                        (taudio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
 
@@ -2812,38 +3982,31 @@ ghb_validate_vquality(GValue *settings)
        vquality = ghb_settings_get_double(settings, "VideoQualitySlider");
        if (ghb_settings_get_boolean(settings, "vquality_type_constant"))
        {
-               if (!ghb_settings_get_boolean(settings, "directqp"))
-               {
-                       vquality *= 100.0;
-                       if (vcodec != HB_VCODEC_X264)
-                       {
-                               min = 68;
-                               max = 97;
-                       }
-                       else
-                       {
-                               min = 40;
-                               max = 70;
-                       }
-               }
-               else
+               switch (vcodec)
                {
-                       if (vcodec == HB_VCODEC_X264)
+                       case HB_VCODEC_X264:
                        {
                                min = 16;
                                max = 30;
-                       }
-                       else if (vcodec == HB_VCODEC_FFMPEG)
+                       } break;
+
+                       case HB_VCODEC_FFMPEG:
                        {
                                min = 1;
                                max = 8;
-                       }
-                       else
+                       } break;
+
+                       case HB_VCODEC_THEORA:
                        {
-                               min = 68;
-                               max = 97;
-                               vquality *= 100.0;
-                       }
+                               min = 0;
+                               max = 63;
+                       } break;
+
+                       default:
+                       {
+                               min = 48;
+                               max = 62;
+                       } break;
                }
                if (vquality < min || vquality > max)
                {
@@ -2864,8 +4027,8 @@ ghb_validate_vquality(GValue *settings)
        return TRUE;
 }
 
-void
-ghb_add_job(GValue *js, gint unique_id)
+static void
+add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
 {
        hb_list_t  * list;
        hb_title_t * title;
@@ -2880,19 +4043,15 @@ ghb_add_job(GValue *js, gint unique_id)
        gchar *denoise_str = NULL;
        gchar *dest_str = NULL;
 
-       g_debug("ghb_add_job()\n");
-       if (h_queue == NULL) return;
-       list = hb_get_titles( h_queue );
+       g_debug("add_job()\n");
+       if (h == NULL) return;
+       list = hb_get_titles( h );
        if( !hb_list_count( list ) )
        {
                /* No valid title, stop right there */
                return;
        }
 
-       // Since I'm doing a scan of the single title I want just prior 
-       // to adding the job, there is only the one title to choose from.
-       //gint titleindex = ghb_settings_get_int(js, "title");
-    gint titleindex = 0;
     title = hb_list_item( list, titleindex );
        if (title == NULL) return;
 
@@ -2900,6 +4059,14 @@ ghb_add_job(GValue *js, gint unique_id)
        job   = title->job;
        if (job == NULL) return;
 
+       job->angle = ghb_settings_get_int(js, "angle");
+       job->start_at_preview = ghb_settings_get_int(js, "start_frame") + 1;
+       if (job->start_at_preview)
+       {
+               job->seek_points = ghb_settings_get_int(js, "preview_count");
+               job->pts_to_stop = ghb_settings_get_int(js, "live_duration") * 90000LL;
+       }
+
        tweaks = ghb_settings_get_boolean(js, "allow_tweaks");
        job->mux = ghb_settings_combo_int(js, "FileFormat");
        if (job->mux == HB_MUX_MP4)
@@ -2912,42 +4079,47 @@ ghb_add_job(GValue *js, gint unique_id)
                job->largeFileSize = FALSE;
                job->mp4_optimize = FALSE;
        }
-       gint chapter_start, chapter_end;
-       chapter_start = ghb_settings_get_int(js, "start_chapter");
-       chapter_end = ghb_settings_get_int(js, "end_chapter");
-       gint num_chapters = hb_list_count(title->list_chapter);
-       job->chapter_start = MIN( num_chapters, chapter_start );
-       job->chapter_end   = MAX( job->chapter_start, chapter_end );
-
-       job->chapter_markers = ghb_settings_get_boolean(js, "ChapterMarkers");
-       if ( job->chapter_markers )
+       if (!job->start_at_preview)
        {
-               GValue *chapters;
-               GValue *chapter;
-               gint chap;
-               gint count;
-               
-               chapters = ghb_settings_get_value(js, "chapter_list");
-               count = ghb_array_len(chapters);
-               for(chap = chapter_start; chap <= chapter_end; chap++)
+               gint chapter_start, chapter_end;
+               chapter_start = ghb_settings_get_int(js, "start_chapter");
+               chapter_end = ghb_settings_get_int(js, "end_chapter");
+               gint num_chapters = hb_list_count(title->list_chapter);
+               job->chapter_start = MIN( num_chapters, chapter_start );
+               job->chapter_end   = MAX( job->chapter_start, chapter_end );
+
+               job->chapter_markers = ghb_settings_get_boolean(js, "ChapterMarkers");
+               if (job->chapter_start == job->chapter_end)
+                       job->chapter_markers = 0;
+               if ( job->chapter_markers )
                {
-                       hb_chapter_t * chapter_s;
-                       gchar *name;
-                       
-                       name = NULL;
-                       if (chap-1 < count)
-                       {
-                               chapter = ghb_array_get_nth(chapters, chap-1);
-                               name = ghb_value_string(chapter); 
-                       }
-                       if (name == NULL)
+                       GValue *chapters;
+                       GValue *chapter;
+                       gint chap;
+                       gint count;
+               
+                       chapters = ghb_settings_get_value(js, "chapter_list");
+                       count = ghb_array_len(chapters);
+                       for(chap = chapter_start; chap <= chapter_end; chap++)
                        {
-                               name = g_strdup_printf ("Chapter %2d", chap);
+                               hb_chapter_t * chapter_s;
+                               gchar *name;
+                               
+                               name = NULL;
+                               if (chap-1 < count)
+                               {
+                                       chapter = ghb_array_get_nth(chapters, chap-1);
+                                       name = ghb_value_string(chapter); 
+                               }
+                               if (name == NULL)
+                               {
+                                       name = g_strdup_printf ("Chapter %2d", chap);
+                               }
+                               chapter_s = hb_list_item( job->title->list_chapter, chap - 1);
+                               strncpy(chapter_s->title, name, 1023);
+                               chapter_s->title[1023] = '\0';
+                               g_free(name);
                        }
-                       chapter_s = hb_list_item( job->title->list_chapter, chap - 1);
-                       strncpy(chapter_s->title, name, 1023);
-                       chapter_s->title[1023] = '\0';
-                       g_free(name);
                }
        }
        job->crop[0] = ghb_settings_get_int(js, "PictureTopCrop");
@@ -2956,78 +4128,76 @@ ghb_add_job(GValue *js, gint unique_id)
        job->crop[3] = ghb_settings_get_int(js, "PictureRightCrop");
 
        
-       gboolean decomb = ghb_settings_get_boolean(js, "PictureDecomb");
-       gint deint = ghb_settings_combo_int(js, 
-                                       tweaks ? "tweak_PictureDeinterlace":"PictureDeinterlace");
-       if (!decomb)
+       gboolean decomb_deint = ghb_settings_get_boolean(js, "PictureDecombDeinterlace");
+       gint decomb = ghb_settings_combo_int(js, "PictureDecomb");
+       gint deint = ghb_settings_combo_int(js, "PictureDeinterlace");
+       if (!decomb_deint)
                job->deinterlace = (deint != 0) ? 1 : 0;
        else
                job->deinterlace = 0;
     job->grayscale   = ghb_settings_get_boolean(js, "VideoGrayScale");
 
-       gboolean anamorphic = ghb_settings_get_boolean(js, "anamorphic");
-       gboolean round_dimensions = ghb_settings_get_boolean(js, "ModDimensions");
-       if (round_dimensions && anamorphic)
-       {
-               job->pixel_ratio = 2;
-               job->modulus = 16;
-       }
-       else if (anamorphic)
-       {
-               // Huh! I thought I wanted to use pixel_ratio 1 for this case, but
-               // when its 1, libhb discards the width and height and uses original
-               // title dims - crop.  Thats not what I want.
-               // Also, x264 requires things to divisible by 2.
-               job->pixel_ratio = 2;
-               job->modulus = 2;
-       }
-       else
+       gboolean keep_aspect;
+       keep_aspect = ghb_settings_get_boolean(js, "PictureKeepRatio");
+       job->anamorphic.mode = ghb_settings_combo_int(js, "PicturePAR");
+       job->anamorphic.modulus = ghb_settings_combo_int(js, "PictureModulus");
+       if (job->anamorphic.mode)
        {
-               job->pixel_ratio = 0;
-               job->modulus = 2;
+               job->anamorphic.par_width = title->pixel_aspect_width;
+               job->anamorphic.par_height = title->pixel_aspect_height;
+               job->anamorphic.dar_width = 0;
+               job->anamorphic.dar_height = 0;
+
+               if (job->anamorphic.mode == 3 && !keep_aspect)
+               {
+                       job->anamorphic.keep_display_aspect = 0;
+                       job->anamorphic.par_width = 
+                               ghb_settings_get_int(js, "PicturePARWidth");
+                       job->anamorphic.par_height = 
+                               ghb_settings_get_int(js, "PicturePARHeight");
+               }
+               else
+               {
+                       job->anamorphic.keep_display_aspect = 1;
+               }
        }
+
        /* Add selected filters */
        job->filters = hb_list_init();
-       gint vrate = ghb_settings_combo_int(js, "VideoFramerate");
-       if( vrate == 0 && ghb_settings_get_boolean(js, "PictureDetelecine" ) )
-               job->vfr = 1;
-       else
-               job->vfr = 0;
-
-       if( ghb_settings_get_boolean(js, "PictureDetelecine" ) )
+       gint detel = ghb_settings_combo_int(js, "PictureDetelecine");
+       if ( detel )
        {
-               hb_filter_detelecine.settings = NULL;
-               if (tweaks)
+               if (detel != 1)
                {
-                       detel_str = ghb_settings_get_string(js, "tweak_PictureDetelecine");
-                       if (detel_str && detel_str[0])
-                       {
-                               hb_filter_detelecine.settings = detel_str;
-                       }
+                       if (detel_opts.map[detel].svalue != NULL)
+                               detel_str = g_strdup(detel_opts.map[detel].svalue);
                }
+               else
+                       detel_str = ghb_settings_get_string(js, "PictureDetelecineCustom");
+               hb_filter_detelecine.settings = detel_str;
                hb_list_add( job->filters, &hb_filter_detelecine );
        }
-       if( decomb )
+       if ( decomb_deint && decomb )
        {
-               // Use default settings
-               hb_filter_decomb.settings = NULL;
-               if (tweaks)
+               if (decomb != 1)
                {
-                       decomb_str = ghb_settings_get_string(js, "tweak_PictureDecomb");
-                       if (decomb_str && decomb_str[0])
-                       {
-                               hb_filter_decomb.settings = (gchar*)decomb_str;
-                       }
+                       if (decomb_opts.map[decomb].svalue != NULL)
+                               decomb_str = g_strdup(decomb_opts.map[decomb].svalue);
                }
+               else
+                       decomb_str = ghb_settings_get_string(js, "PictureDecombCustom");
+               hb_filter_decomb.settings = decomb_str;
                hb_list_add( job->filters, &hb_filter_decomb );
        }
        if( job->deinterlace )
        {
-               if (deint > 0)
-                       deint_str = g_strdup(deint_opts.map[deint].svalue);
+               if (deint != 1)
+               {
+                       if (deint_opts.map[deint].svalue != NULL)
+                               deint_str = g_strdup(deint_opts.map[deint].svalue);
+               }
                else
-                       deint_str = ghb_settings_get_string(js, 
-                                       tweaks ? "tweak_PictureDeinterlace" : "PictureDeinterlace");
+                       deint_str = ghb_settings_get_string(js, "PictureDeinterlaceCustom");
                hb_filter_deinterlace.settings = deint_str;
                hb_list_add( job->filters, &hb_filter_deinterlace );
        }
@@ -3038,15 +4208,16 @@ ghb_add_job(GValue *js, gint unique_id)
                hb_filter_deblock.settings = deblock_str;
                hb_list_add( job->filters, &hb_filter_deblock );
        }
-       gint denoise = ghb_settings_combo_int(js, 
-                                       tweaks ? "tweak_PictureDenoise" : "PictureDenoise");
-       if( denoise != 0 )
+       gint denoise = ghb_settings_combo_int(js, "PictureDenoise");
+       if( denoise )
        {
-               if (denoise > 0)
-                       denoise_str = g_strdup(denoise_opts.map[denoise].svalue);
+               if (denoise != 1)
+               {
+                       if (denoise_opts.map[denoise].svalue != NULL)
+                               denoise_str = g_strdup(denoise_opts.map[denoise].svalue);
+               }
                else
-                       denoise_str = (gchar*)ghb_settings_get_string(
-                               js, tweaks ? "tweak_PictureDenoise" : "PictureDenoise");
+                       denoise_str = ghb_settings_get_string(js, "PictureDenoiseCustom");
                hb_filter_denoise.settings = denoise_str;
                hb_list_add( job->filters, &hb_filter_denoise );
        }
@@ -3054,11 +4225,10 @@ ghb_add_job(GValue *js, gint unique_id)
        job->height = ghb_settings_get_int(js, "scale_height");
 
        job->vcodec = ghb_settings_combo_int(js, "VideoEncoder");
-       if ((job->mux == HB_MUX_MP4 || job->mux == HB_MUX_AVI) && 
-               (job->vcodec == HB_VCODEC_THEORA))
+       if ((job->mux == HB_MUX_MP4 ) && (job->vcodec == HB_VCODEC_THEORA))
        {
-               // mp4|avi/theora combination is not supported.
-               job->vcodec = HB_VCODEC_XVID;
+               // mp4/theora combination is not supported.
+               job->vcodec = HB_VCODEC_FFMPEG;
        }
        if ((job->vcodec == HB_VCODEC_X264) && (job->mux == HB_MUX_MP4))
        {
@@ -3068,11 +4238,6 @@ ghb_add_job(GValue *js, gint unique_id)
        {
                gdouble vquality;
                vquality = ghb_settings_get_double(js, "VideoQualitySlider");
-               if (!ghb_settings_get_boolean(js, "directqp"))
-               {
-                       if (vquality == 0.0) vquality = 0.01;
-                       if (vquality == 1.0) vquality = 0.0;
-               }
                job->vquality =  vquality;
                job->vbitrate = 0;
        }
@@ -3081,13 +4246,8 @@ ghb_add_job(GValue *js, gint unique_id)
                job->vquality = -1.0;
                job->vbitrate = ghb_settings_get_int(js, "VideoAvgBitrate");
        }
-       // AVI container does not support variable frame rate.
-       if (job->mux == HB_MUX_AVI)
-       {
-               job->vfr = FALSE;
-               job->cfr = 1;
-       }
 
+       gint vrate = ghb_settings_combo_int(js, "VideoFramerate");
        if( vrate == 0 )
        {
                job->vrate = title->rate;
@@ -3100,18 +4260,9 @@ ghb_add_job(GValue *js, gint unique_id)
                job->vrate_base = vrate;
                job->cfr = 1;
        }
-       // First remove any audios that are already in the list
-       // This happens if you are encoding the same title a second time.
-       gint num_audio_tracks = hb_list_count(job->list_audio);
-       gint ii;
-    for(ii = 0; ii < num_audio_tracks; ii++)
-    {
-        hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
-        hb_list_rem(job->list_audio, audio);
-    }
 
        const GValue *audio_list;
-       gint count;
+       gint count, ii;
        gint tcount = 0;
        
        audio_list = ghb_settings_get_value(js, "audio_list");
@@ -3129,49 +4280,56 @@ ghb_add_job(GValue *js, gint unique_id)
                audio.out.codec = ghb_settings_combo_int(asettings, "AudioEncoder");
         taudio = (hb_audio_config_t *) hb_list_audio_config_item(
                                                                        title->list_audio, audio.in.track );
-               if ((taudio->in.codec != HB_ACODEC_AC3) && (audio.out.codec == HB_ACODEC_AC3))
+               if (audio.out.codec & (HB_ACODEC_AC3 | HB_ACODEC_DCA))
                {
-                       // Not supported.  AC3 is passthrough only, so input must be AC3
-                       if (job->mux == HB_MUX_AVI)
+                       if (!(taudio->in.codec & (HB_ACODEC_AC3 | HB_ACODEC_DCA)))
                        {
-                               audio.out.codec = HB_ACODEC_LAME;
+                               // Not supported.  
+                               // AC3/DTS is passthrough only, so input must be AC3/DTS
+                               if (job->mux == HB_MUX_MKV)
+                               {
+                                       audio.out.codec = HB_ACODEC_LAME;
+                               }
+                               else
+                               {
+                                       audio.out.codec = HB_ACODEC_FAAC;
+                               }
                        }
                        else
                        {
-                               audio.out.codec = HB_ACODEC_FAAC;
+                               audio.out.codec &= taudio->in.codec;
                        }
                }
                if ((job->mux == HB_MUX_MP4) && 
-                       ((audio.out.codec == HB_ACODEC_LAME) ||
-                       (audio.out.codec == HB_ACODEC_VORBIS)))
+                       ((audio.out.codec & HB_ACODEC_LAME) ||
+                       (audio.out.codec & HB_ACODEC_DCA) ||
+                       (audio.out.codec & HB_ACODEC_VORBIS)))
                {
-                       // mp4/mp3|vorbis combination is not supported.
+                       // mp4/mp3|dts|vorbis combination is not supported.
                        audio.out.codec = HB_ACODEC_FAAC;
                }
-               if ((job->mux == HB_MUX_AVI) && 
-                       ((audio.out.codec == HB_ACODEC_FAAC) ||
-                       (audio.out.codec == HB_ACODEC_VORBIS)))
-               {
-                       // avi/faac|vorbis combination is not supported.
-                       audio.out.codec = HB_ACODEC_LAME;
-               }
-               if ((job->mux == HB_MUX_OGM) && 
-                       ((audio.out.codec == HB_ACODEC_FAAC) ||
-                       (audio.out.codec == HB_ACODEC_AC3)))
-               {
-                       // ogm/faac|ac3 combination is not supported.
-                       audio.out.codec = HB_ACODEC_VORBIS;
-               }
         audio.out.dynamic_range_compression = 
                        ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
+        if (audio.out.dynamic_range_compression < 1.0)
+               audio.out.dynamic_range_compression = 0.0;
+
                // It would be better if this were done in libhb for us, but its not yet.
-               if (audio.out.codec == HB_ACODEC_AC3 || audio.out.codec == HB_ACODEC_DCA)
+               if (audio.out.codec & (HB_ACODEC_AC3 | HB_ACODEC_DCA))
                {
                        audio.out.mixdown = 0;
                }
                else
                {
+                       int channels;
+
                        audio.out.mixdown = ghb_settings_combo_int(asettings, "AudioMixdown");
+                       if (audio.out.mixdown == HB_AMIXDOWN_MONO)
+                               channels = 1;
+                       else if (audio.out.mixdown == HB_AMIXDOWN_6CH)
+                               channels = 6;
+                       else
+                               channels = 2;
+
                        // Make sure the mixdown is valid and pick a new one if not.
                        audio.out.mixdown = ghb_get_best_mix(titleindex, 
                                audio.in.track, audio.out.codec, audio.out.mixdown);
@@ -3182,6 +4340,9 @@ ghb_add_job(GValue *js, gint unique_id)
                                audio.out.samplerate = taudio->in.samplerate;
                        else
                                audio.out.samplerate = srate;
+
+                       audio.out.bitrate = ghb_get_best_audio_bitrate(
+                               audio.out.codec, audio.out.bitrate, channels);
                }
 
                // Add it to the jobs audio list
@@ -3202,7 +4363,112 @@ ghb_add_job(GValue *js, gint unique_id)
 
        dest_str = ghb_settings_get_string(js, "destination");
        job->file = dest_str;
-       job->crf = ghb_settings_get_boolean(js, "constant_rate_factor");
+
+       const GValue *subtitle_list;
+       gint subtitle;
+       gboolean force, burned, def, one_burned = FALSE;
+       
+       ghb_settings_set_boolean(js, "subtitle_scan", FALSE);
+       subtitle_list = ghb_settings_get_value(js, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               GValue *ssettings;
+               gint source;
+
+               ssettings = ghb_array_get_nth(subtitle_list, ii);
+
+               force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
+               burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
+               def = ghb_settings_get_boolean(ssettings, "SubtitleDefaultTrack");
+               source = ghb_settings_get_int(ssettings, "SubtitleSource");
+
+               if (source == SRTSUB)
+               {
+               hb_subtitle_config_t sub_config;
+                       gchar *filename, *lang, *code;
+
+                       filename = ghb_settings_get_string(ssettings, "SrtFile");
+                       if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+                       {
+                               continue;
+                       }
+                       sub_config.offset = ghb_settings_get_int(ssettings, "SrtOffset");
+                       lang = ghb_settings_get_string(ssettings, "SrtLanguage");
+                       code = ghb_settings_get_string(ssettings, "SrtCodeset");
+                       strncpy(sub_config.src_filename, filename, 128);
+                       strncpy(sub_config.src_codeset, code, 40);
+                       sub_config.force = 0;
+                       sub_config.dest = PASSTHRUSUB;
+                       sub_config.default_track = def;
+
+                       hb_srt_add( job, &sub_config, lang);
+
+                       g_free(filename);
+                       g_free(lang);
+                       g_free(code);
+                       continue;
+               }
+
+               subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack");
+               if (subtitle == -1)
+               {
+                       if (!burned && job->mux == HB_MUX_MKV)
+                       {
+                               job->select_subtitle_config.dest = PASSTHRUSUB;
+                       }
+                       else if (!burned && job->mux == HB_MUX_MP4)
+                       {
+                               // Skip any non-burned vobsubs when output is mp4
+                               continue;
+                       }
+                       else if (burned)
+                       {
+                               // Only allow one subtitle to be burned into the video
+                               if (one_burned)
+                                       continue;
+                               job->select_subtitle_config.dest = RENDERSUB;
+                               one_burned = TRUE;
+                       }
+                       job->select_subtitle_config.force = force;
+                       job->select_subtitle_config.default_track = def;
+                       job->indepth_scan = 1;
+                       ghb_settings_set_boolean(js, "subtitle_scan", TRUE);
+               }
+               else if (subtitle >= 0)
+               {
+               hb_subtitle_t * subt;
+               hb_subtitle_config_t sub_config;
+
+                       subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
+                       sub_config = subt->config;
+                       if (subt != NULL)
+                       {
+                               if (!burned && job->mux == HB_MUX_MKV && 
+                                       subt->format == PICTURESUB)
+                               {
+                                       sub_config.dest = PASSTHRUSUB;
+                               }
+                               else if (!burned && job->mux == HB_MUX_MP4 && 
+                                       subt->format == PICTURESUB)
+                               {
+                                       // Skip any non-burned vobsubs when output is mp4
+                                       continue;
+                               }
+                               else if ( burned && subt->format == PICTURESUB )
+                               {
+                                       // Only allow one subtitle to be burned into the video
+                                       if (one_burned)
+                                               continue;
+                                       one_burned = TRUE;
+                               }
+                               sub_config.force = force;
+                               sub_config.default_track = def;
+                       hb_subtitle_add( job, &sub_config, subtitle );
+                       }
+               }
+       }
+
        // TODO: libhb holds onto a reference to the x264opts and is not
        // finished with it until encoding the job is done.  But I can't
        // find a way to get at the job before it is removed in order to
@@ -3210,47 +4476,15 @@ ghb_add_job(GValue *js, gint unique_id)
        // The short story is THIS LEAKS.
        x264opts = ghb_build_x264opts_string(js);
        
-       if( x264opts != NULL && *x264opts != '\0' )
+       if( *x264opts == '\0' )
        {
-               job->x264opts = x264opts;
-       }
-       else /*avoids a bus error crash when options aren't specified*/
-       {
-               job->x264opts =  NULL;
-       }
-       gint subtitle;
-       gchar *slang = ghb_settings_get_string(js, "Subtitles");
-       subtitle = -2; // default to none
-       if (strcmp(slang, "auto") == 0)
-       {
-               subtitle = -1;
+               g_free(x264opts);
+               x264opts = NULL;
        }
-       else
-       {
-               gint scount;
-       hb_subtitle_t * subt;
 
-               scount = hb_list_count(title->list_subtitle);
-               for (ii = 0; ii < scount; ii++)
-               {
-               subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, ii);
-                       if (strcmp(slang, subt->iso639_2) == 0)
-                       {
-                               subtitle = ii;
-                               break;
-                       }
-               }
-       }
-       gboolean forced_subtitles = ghb_settings_get_boolean(js, "SubtitlesForced");
-       job->subtitle_force = forced_subtitles;
-       if (subtitle >= 0)
-               job->subtitle = subtitle;
-       else
-               job->subtitle = -1;
-       if (subtitle == -1)
+       if (job->indepth_scan == 1)
        {
                // Subtitle scan. Look for subtitle matching audio language
-               char *x264opts_tmp;
 
                /*
                 * When subtitle scan is enabled do a fast pre-scan job
@@ -3258,27 +4492,15 @@ ghb_add_job(GValue *js, gint unique_id)
                 */
                job->pass = -1;
                job->indepth_scan = 1;
-
-               x264opts_tmp = job->x264opts;
                job->x264opts = NULL;
 
-               job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
-               *(job->select_subtitle) = NULL;
-
                /*
                 * Add the pre-scan job
                 */
                job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
-               hb_add( h_queue, job );
-               //if (job->x264opts != NULL)
-               //      g_free(job->x264opts);
-
-               job->x264opts = x264opts_tmp;
-       }
-       else
-       {
-               job->select_subtitle = NULL;
+               hb_add( h, job );
        }
+
        if( ghb_settings_get_boolean(js, "VideoTwoPass") &&
                !ghb_settings_get_boolean(js, "vquality_type_constant"))
        {
@@ -3287,27 +4509,32 @@ ghb_add_job(GValue *js, gint unique_id)
                 * for the second pass and then off again for the
                 * second.
                 */
-               hb_subtitle_t **subtitle_tmp = job->select_subtitle;
-               job->select_subtitle = NULL;
                job->pass = 1;
                job->indepth_scan = 0;
-               gchar *x264opts2 = NULL;
-               if (x264opts)
-               {
-                       x264opts2 = g_strdup(x264opts);
-               }
+
                /*
                 * If turbo options have been selected then append them
                 * to the x264opts now (size includes one ':' and the '\0')
                 */
                if( ghb_settings_get_boolean(js, "VideoTurboTwoPass") )
                {
-                       char *tmp_x264opts;
+                       gchar *tmp_x264opts;
+                       gchar *extra_opts;
+                       gint badapt;
 
+                       badapt = ghb_lookup_badapt(x264opts);
+                       if (badapt == 2)
+                       {
+                               extra_opts = g_strdup_printf("%s", turbo_opts);
+                       }
+                       else
+                       {
+                               extra_opts = g_strdup_printf("%s:weightb=0", turbo_opts);
+                       }
+       
                        if ( x264opts )
                        {
-                               tmp_x264opts = g_strdup_printf("%s:%s", x264opts, turbo_opts);
-                               g_free(x264opts);
+                               tmp_x264opts = g_strdup_printf("%s:%s", x264opts, extra_opts);
                        } 
                        else 
                        {
@@ -3315,18 +4542,21 @@ ghb_add_job(GValue *js, gint unique_id)
                                 * No x264opts to modify, but apply the turbo options
                                 * anyway as they may be modifying defaults
                                 */
-                               tmp_x264opts = g_strdup_printf("%s", turbo_opts);
+                               tmp_x264opts = g_strdup_printf("%s", extra_opts);
                        }
-                       x264opts = tmp_x264opts;
+                       g_free(extra_opts);
 
+                       job->x264opts = tmp_x264opts;
+               }
+               else
+               {
                        job->x264opts = x264opts;
                }
                job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
-               hb_add( h_queue, job );
+               hb_add( h, job );
                //if (job->x264opts != NULL)
                //      g_free(job->x264opts);
 
-               job->select_subtitle = subtitle_tmp;
                job->pass = 2;
                /*
                 * On the second pass we turn off subtitle scan so that we
@@ -3335,21 +4565,41 @@ ghb_add_job(GValue *js, gint unique_id)
                 * attribute of the job).
                 */
                job->indepth_scan = 0;
-               job->x264opts = x264opts2;
+               job->x264opts = x264opts;
                job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
-               hb_add( h_queue, job );
+               hb_add( h, job );
                //if (job->x264opts != NULL)
                //      g_free(job->x264opts);
        }
        else
        {
+               job->x264opts = x264opts;
                job->indepth_scan = 0;
                job->pass = 0;
                job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
-               hb_add( h_queue, job );
+               hb_add( h, job );
                //if (job->x264opts != NULL)
                //      g_free(job->x264opts);
        }
+
+       // clean up audio list
+       gint num_audio_tracks = hb_list_count(job->list_audio);
+       for(ii = 0; ii < num_audio_tracks; ii++)
+       {
+               hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
+               hb_list_rem(job->list_audio, audio);
+               free(audio);
+       }
+
+       // clean up subtitle list
+       gint num_subtitle_tracks = hb_list_count(job->list_subtitle);
+       for(ii = 0; ii < num_subtitle_tracks; ii++)
+       {
+               hb_subtitle_t *subtitle = hb_list_item(job->list_subtitle, 0);
+               hb_list_rem(job->list_subtitle, subtitle);
+               free(subtitle);
+       }
+
        if (detel_str) g_free(detel_str);
        if (decomb_str) g_free(decomb_str);
        if (deint_str) g_free(deint_str);
@@ -3359,6 +4609,23 @@ ghb_add_job(GValue *js, gint unique_id)
 }
 
 void
+ghb_add_job(GValue *js, gint unique_id)
+{
+       // Since I'm doing a scan of the single title I want just prior 
+       // to adding the job, there is only the one title to choose from.
+       add_job(h_queue, js, unique_id, 0);
+}
+
+void
+ghb_add_live_job(GValue *js, gint unique_id)
+{
+       // Since I'm doing a scan of the single title I want just prior 
+       // to adding the job, there is only the one title to choose from.
+       gint titleindex = ghb_settings_combo_int(js, "title");
+       add_job(h_scan, js, unique_id, titleindex);
+}
+
+void
 ghb_remove_job(gint unique_id)
 {
     hb_job_t * job;
@@ -3388,6 +4655,18 @@ ghb_stop_queue()
 }
 
 void
+ghb_start_live_encode()
+{
+       hb_start( h_scan );
+}
+
+void
+ghb_stop_live_encode()
+{
+       hb_stop( h_scan );
+}
+
+void
 ghb_pause_queue()
 {
     hb_state_t s;
@@ -3395,27 +4674,127 @@ ghb_pause_queue()
 
     if( s.state == HB_STATE_PAUSED )
     {
-        hb_resume( h_queue );
+               hb_status.queue.state &= ~GHB_STATE_PAUSED;
+               hb_resume( h_queue );
     }
     else
     {
-        hb_pause( h_queue );
+               hb_status.queue.state |= GHB_STATE_PAUSED;
+               hb_pause( h_queue );
     }
 }
 
-#define RED_HEIGHT     720.0
-#define RED_WIDTH      1280.0
+static void
+vert_line(
+       GdkPixbuf * pb, 
+       guint8 r, 
+       guint8 g, 
+       guint8 b, 
+       gint x, 
+       gint y, 
+       gint len, 
+       gint width)
+{
+       guint8 *pixels = gdk_pixbuf_get_pixels (pb);
+       guint8 *dst;
+       gint ii, jj;
+       gint channels = gdk_pixbuf_get_n_channels (pb);
+       gint stride = gdk_pixbuf_get_rowstride (pb);
+
+       for (jj = 0; jj < width; jj++)
+       {
+               dst = pixels + y * stride + (x+jj) * channels;
+               for (ii = 0; ii < len; ii++)
+               {
+                       dst[0] = r;
+                       dst[1] = g;
+                       dst[2] = b;
+                       dst += stride;
+               }
+       }
+}
+
+static void
+horz_line(
+       GdkPixbuf * pb, 
+       guint8 r, 
+       guint8 g, 
+       guint8 b, 
+       gint x, 
+       gint y, 
+       gint len,
+       gint width)
+{
+       guint8 *pixels = gdk_pixbuf_get_pixels (pb);
+       guint8 *dst;
+       gint ii, jj;
+       gint channels = gdk_pixbuf_get_n_channels (pb);
+       gint stride = gdk_pixbuf_get_rowstride (pb);
+
+       for (jj = 0; jj < width; jj++)
+       {
+               dst = pixels + (y+jj) * stride + x * channels;
+               for (ii = 0; ii < len; ii++)
+               {
+                       dst[0] = r;
+                       dst[1] = g;
+                       dst[2] = b;
+                       dst += channels;
+               }
+       }
+}
+
+static void
+hash_pixbuf(
+       GdkPixbuf * pb,
+       gint        x,
+       gint        y,
+       gint        w,
+       gint        h,
+       gint        step,
+       gint            orientation)
+{
+       gint ii, jj;
+       gint line_width = 8;
+       struct
+       {
+               guint8 r;
+               guint8 g;
+               guint8 b;
+       } c[4] = 
+       {{0x80, 0x80, 0x80},{0xC0, 0x80, 0x70},{0x80, 0xA0, 0x80},{0x70, 0x80, 0xA0}};
+
+       if (!orientation)
+       {
+               // vertical lines
+               for (ii = x, jj = 0; ii+line_width < x+w; ii += step, jj++)
+               {
+                       vert_line(pb, c[jj&3].r, c[jj&3].g, c[jj&3].b, ii, y, h, line_width);
+               }
+       }
+       else
+       {
+               // horizontal lines
+               for (ii = y, jj = 0; ii+line_width < y+h; ii += step, jj++)
+               {
+                       horz_line(pb, c[jj&3].r, c[jj&3].g, c[jj&3].b, x, ii, w, line_width);
+               }
+       }
+}
 
 GdkPixbuf*
 ghb_get_preview_image(
        gint titleindex, 
        gint index, 
-       GValue *settings, 
-       gboolean borders)
+       signal_user_data_t *ud,
+       gint *out_width,
+       gint *out_height)
 {
+       GValue *settings;
        hb_title_t *title;
        hb_list_t  *list;
        
+       settings = ud->settings;
        list = hb_get_titles( h_scan );
        if( !hb_list_count( list ) )
        {
@@ -3427,70 +4806,25 @@ ghb_get_preview_image(
        if (title->job == NULL) return NULL;
        set_preview_job_settings(title->job, settings);
 
-       // hb_get_preview can't handle sizes that are larger than the original title
-       // dimensions
-       if (title->job->width > title->width)
-               title->job->width = title->width;
-       
-       if (title->job->height > title->height)
-               title->job->height = title->height;
-       // And also creates artifacts if the width is not a multiple of 8
-       //title->job->width = ((title->job->width + 4) >> 3) << 3;
-       // And the height must be a multiple of 2
-       //title->job->height = ((title->job->height + 1) >> 1) << 1;
-       
-       // Make sure we have a big enough buffer to receive the image from libhb. libhb
-       // creates images with a one-pixel border around the original content. Hence we
-       // add 2 pixels horizontally and vertically to the buffer size.
-       gint srcWidth = title->width + 2;
-       gint srcHeight= title->height + 2;
-       gint dstWidth = title->width;
-       gint dstHeight= title->height;
-       gint borderTop = 1;
-       gint borderLeft = 1;
-    if (borders)
-    {
-        //     |<---------- title->width ----------->|
-        //     |   |<---- title->job->width ---->|   |
-        //     |   |                             |   |
-        //     .......................................
-        //     ....+-----------------------------+....
-        //     ....|                             |....<-- gray border
-        //     ....|                             |....
-        //     ....|                             |....
-        //     ....|                             |<------- image
-        //     ....|                             |....
-        //     ....|                             |....
-        //     ....|                             |....
-        //     ....|                             |....
-        //     ....|                             |....
-        //     ....+-----------------------------+....
-        //     .......................................
-               dstWidth = title->job->width;
-        dstHeight = title->job->height;
-               borderTop = (srcHeight - dstHeight) / 2;
-               borderLeft = (srcWidth - dstWidth) / 2;
-               g_debug("boarders removed\n");
-       }
-
-       g_debug("src %d x %d\n", srcWidth, srcHeight);
-       g_debug("dst %d x %d\n", dstWidth, dstHeight);
-       g_debug("job dim %d x %d\n", title->job->width, title->job->height);
-       g_debug("title crop %d:%d:%d:%d\n", 
-                       title->crop[0],
-                       title->crop[1],
-                       title->crop[2],
-                       title->crop[3]);
-       g_debug("job crop %d:%d:%d:%d\n", 
-                       title->job->crop[0],
-                       title->job->crop[1],
-                       title->job->crop[2],
-                       title->job->crop[3]);
+       // hb_get_preview doesn't compensate for anamorphic, so lets
+       // calculate scale factors
+       gint width, height, par_width = 1, par_height = 1;
+       gint pic_par = ghb_settings_combo_int(settings, "PicturePAR");
+       if (pic_par)
+       {
+               hb_set_anamorphic_size( title->job, &width, &height, 
+                                                               &par_width, &par_height );
+       }
+
+       // Make sure we have a big enough buffer to receive the image from libhb
+       gint dstWidth = title->job->width;
+       gint dstHeight= title->job->height;
+
        static guint8 *buffer = NULL;
        static gint bufferSize = 0;
-
        gint newSize;
-       newSize = srcWidth * srcHeight * 4;
+
+       newSize = dstWidth * dstHeight * 4;
        if( bufferSize < newSize )
        {
                bufferSize = newSize;
@@ -3499,23 +4833,22 @@ ghb_get_preview_image(
        hb_get_preview( h_scan, title, index, buffer );
 
        // Create an GdkPixbuf and copy the libhb image into it, converting it from
-       // libhb's format something suitable. Along the way, we'll strip off the
-       // border around libhb's image.
+       // libhb's format something suitable.
        
-       // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
-       // Alpha is ignored.
+       // The image data returned by hb_get_preview is 4 bytes per pixel, 
+       // BGRA format. Alpha is ignored.
 
        GdkPixbuf *preview = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, dstWidth, dstHeight);
        guint8 *pixels = gdk_pixbuf_get_pixels (preview);
        
        guint32 *src = (guint32*)buffer;
        guint8 *dst = pixels;
-       src += borderTop * srcWidth;    // skip top rows in src to get to first row of dst
-       src += borderLeft;              // skip left pixels in src to get to first pixel of dst
+
        gint ii, jj;
        gint channels = gdk_pixbuf_get_n_channels (preview);
        gint stride = gdk_pixbuf_get_rowstride (preview);
        guint8 *tmp;
+
        for (ii = 0; ii < dstHeight; ii++)
        {
                tmp = dst;
@@ -3528,39 +4861,72 @@ ghb_get_preview_image(
                        src++;
                }
                dst += stride;
-               src += (srcWidth - dstWidth);   // skip to next row in src
-       }
-       // Got it, but hb_get_preview doesn't compensate for anamorphic, so lets
-       // scale
-       gint width, height, par_width, par_height;
-       gboolean anamorphic = ghb_settings_get_boolean(settings, "anamorphic");
-       if (anamorphic)
-       {
-               hb_set_anamorphic_size( title->job, &width, &height, &par_width, &par_height );
-               if (par_width > par_height)
-                       dstWidth = dstWidth * par_width / par_height;
-               else
-                       dstHeight = dstHeight * par_height / par_width;
        }
+       gint w = ghb_settings_get_int(settings, "scale_width");
+       gint h = ghb_settings_get_int(settings, "scale_height");
+       ghb_par_scale(ud, &w, &h, par_width, par_height);
+
+       gint c0, c1, c2, c3;
+       c0 = ghb_settings_get_int(settings, "PictureTopCrop");
+       c1 = ghb_settings_get_int(settings, "PictureBottomCrop");
+       c2 = ghb_settings_get_int(settings, "PictureLeftCrop");
+       c3 = ghb_settings_get_int(settings, "PictureRightCrop");
+
+       gdouble xscale = (gdouble)w / (gdouble)(title->width - c2 - c3);
+       gdouble yscale = (gdouble)h / (gdouble)(title->height - c0 - c1);
+       
+       ghb_par_scale(ud, &dstWidth, &dstHeight, par_width, par_height);
+       *out_width = w;
+       *out_height = h;
        if (ghb_settings_get_boolean(settings, "reduce_hd_preview"))
        {
-               gdouble factor = 1.0;
+               GdkScreen *ss;
+               gint s_w, s_h;
+               gint orig_w, orig_h;
+               gint factor = 80;
 
-               if (dstHeight > RED_HEIGHT)
+               if (ghb_settings_get_boolean(settings, "preview_fullscreen"))
                {
-                       factor = RED_HEIGHT / (gdouble)dstHeight;
+                       factor = 100;
                }
-               if (dstWidth * factor > RED_WIDTH)
+               ss = gdk_screen_get_default();
+               s_w = gdk_screen_get_width(ss);
+               s_h = gdk_screen_get_height(ss);
+               orig_w = dstWidth;
+               orig_h = dstHeight;
+
+               if (dstWidth > s_w * factor / 100)
+               {
+                       dstWidth = s_w * factor / 100;
+                       dstHeight = dstHeight * dstWidth / orig_w;
+               }
+               if (dstHeight > s_h * factor / 100)
                {
-                       factor = RED_WIDTH / (gdouble)dstWidth;
+                       dstHeight = s_h * factor / 100;
+                       dstWidth = dstWidth * dstHeight / orig_h;
                }
-               dstHeight = dstHeight * factor + 0.5;
-               dstWidth = dstWidth * factor + 0.5;
+               xscale *= (gdouble)dstWidth / orig_w;
+               yscale *= (gdouble)dstHeight / orig_h;
+               w *= (gdouble)dstWidth / orig_w;
+               h *= (gdouble)dstHeight / orig_h;
        }
-       
-       g_debug("scaled %d x %d\n", dstWidth, dstHeight);
        GdkPixbuf *scaled_preview;
        scaled_preview = gdk_pixbuf_scale_simple(preview, dstWidth, dstHeight, GDK_INTERP_HYPER);
+       if (ghb_settings_get_boolean(settings, "show_crop"))
+       {
+               c0 *= yscale;
+               c1 *= yscale;
+               c2 *= xscale;
+               c3 *= xscale;
+               // Top
+               hash_pixbuf(scaled_preview, c2, 0, w, c0, 32, 0);
+               // Bottom
+               hash_pixbuf(scaled_preview, c2, dstHeight-c1, w, c1, 32, 0);
+               // Left
+               hash_pixbuf(scaled_preview, 0, c0, c2, h, 32, 1);
+               // Right
+               hash_pixbuf(scaled_preview, dstWidth-c3, c0, c3, h, 32, 1);
+       }
        g_object_unref (preview);
        return scaled_preview;
 }
@@ -3595,10 +4961,11 @@ ghb_dvd_volname(const gchar *device)
 {
        gchar *name;
        name = hb_dvd_name((gchar*)device);
-       if (name != NULL)
+       if (name != NULL && name[0] != 0)
        {
+               name = g_strdup(name);
                sanitize_volname(name);
-               return g_strdup(name);
+               return name;
        }
-       return name;
+       return NULL;
 }
index 48e85a9..92b006f 100644 (file)
@@ -26,10 +26,9 @@ enum
        GHB_ERROR_FAIL,
 };
 
-typedef struct ghb_status_s
+typedef struct
 {
        gint state;
-       gint queue_state;
 
        // SCANNING
        gint title_count;
@@ -46,11 +45,20 @@ typedef struct ghb_status_s
        gint minutes;
        gint seconds;
        gint error;
+} ghb_instance_status_t;
+
+typedef struct
+{
+       ghb_instance_status_t scan;
+       ghb_instance_status_t queue;
 } ghb_status_t;
 
-#define GHB_SCALE_KEEP_NONE 0
-#define GHB_SCALE_KEEP_WIDTH 1
-#define GHB_SCALE_KEEP_HEIGHT 2
+#define GHB_PIC_KEEP_WIDTH          0x01
+#define GHB_PIC_KEEP_HEIGHT         0x02
+#define GHB_PIC_KEEP_DISPLAY_WIDTH  0x04
+#define GHB_PIC_KEEP_DISPLAY_HEIGHT 0x08
+#define GHB_PIC_KEEP_DAR            0x10
+#define GHB_PIC_KEEP_PAR            0x20
 
 typedef struct
 {
@@ -66,6 +74,7 @@ typedef struct
        gint minutes;
        gint seconds;
        gint64 duration;
+       gint angle_count;
 } ghb_title_info_t;
 
 typedef struct
@@ -86,9 +95,11 @@ void ghb_vquality_range(
        gdouble *max,
        gdouble *step,
        gdouble *page,
-       gint *digits);
+       gint *digits,
+       gboolean *inverted);
 //const gchar* ghb_get_rate_string(gint rate, gint type);
-void ghb_backend_init(GtkBuilder *builder, gint debug, gint update);
+void ghb_combo_init(signal_user_data_t *ud);
+void ghb_backend_init(gint debug);
 void ghb_backend_close(void);
 void ghb_add_job(GValue *js, gint unique_id);
 void ghb_remove_job(gint unique_id);
@@ -96,19 +107,25 @@ void ghb_start_queue(void);
 void ghb_stop_queue(void);
 void ghb_pause_queue(void);
 
-gint ghb_get_state(void);
-void ghb_clear_state(gint state);
+void ghb_add_live_job(GValue *js, gint unique_id);
+void ghb_start_live_encode();
+void ghb_stop_live_encode();
+
+void ghb_clear_scan_state(gint state);
 void ghb_clear_queue_state(gint state);
 
 void ghb_set_state(gint state);
+gint ghb_get_scan_state();
 gint ghb_get_queue_state();
 void ghb_get_status(ghb_status_t *status);
 void ghb_track_status(void);
-void ghb_backend_scan(const gchar *path, gint titleindex);
+void ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count);
 void ghb_backend_queue_scan(const gchar *path, gint titleindex);
 gboolean ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex);
+void ghb_par_init(signal_user_data_t *ud);
 void ghb_set_scale(signal_user_data_t *ud, gint mode);
 GValue* ghb_get_chapters(gint titleindex);
+void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss);
 gint ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix);
 gboolean ghb_ac3_in_audio_list(const GValue *audio_list);
 gboolean ghb_audio_is_passthru(gint acodec);
@@ -116,26 +133,46 @@ gint ghb_get_default_acodec(void);
 gboolean ghb_get_audio_info(
        ghb_audio_info_t *ainfo, gint titleindex, gint audioindex);
 void ghb_set_passthru_bitrate_opts(GtkBuilder *builder, gint bitrate);
-void ghb_set_default_bitrate_opts(GtkBuilder *builder, gint last_rate);
+void ghb_set_default_bitrate_opts(
+       GtkBuilder *builder, gint first_rate, gint last_rate);
 void ghb_grey_combo_options(GtkBuilder *builder);
 void ghb_update_ui_combo_box(
-       GtkBuilder *builder, const gchar *name, gint user_data, gboolean all);
-gint ghb_find_audio_track(gint titleindex, const gchar *lang, gint index);
+       signal_user_data_t *ud, const gchar *name, gint user_data, gboolean all);
+gchar* ghb_get_source_audio_lang(gint titleindex, gint track);
+gint ghb_find_audio_track(
+       gint titleindex, const gchar *lang, gint acodec, GHashTable *track_indices);
+void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex);
+gint ghb_find_pref_subtitle_track(const gchar *lang);
+gint ghb_find_subtitle_track(
+       gint titleindex, const gchar *lang, gboolean burn, 
+       gboolean force, gint source, GHashTable *track_indices);
+gint ghb_pick_subtitle_track(signal_user_data_t *ud);
+gint ghb_find_cc_track(gint titleindex);
 gint ghb_longest_title(void);
 gchar* ghb_build_x264opts_string(GValue *settings);
 GdkPixbuf* ghb_get_preview_image(
-       gint titleindex, gint index, GValue *settings, gboolean borders);
+       gint titleindex, gint index, signal_user_data_t *ud,
+       gint *width, gint *height);
 gint ghb_calculate_target_bitrate(GValue *settings, gint titleindex);
 gchar* ghb_dvd_volname(const gchar *device);
 gint ghb_get_title_number(gint titleindex);
+gint ghb_subtitle_track_source(signal_user_data_t *ud, gint track);
+const char* ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track);
+gchar* ghb_subtitle_track_lang(signal_user_data_t *ud, gint track);
 
 gboolean ghb_validate_vquality(GValue *settings);
 gboolean ghb_validate_audio(signal_user_data_t *ud);
+gboolean ghb_validate_subtitles(signal_user_data_t *ud);
 gboolean ghb_validate_video(signal_user_data_t *ud);
 gboolean ghb_validate_filters(signal_user_data_t *ud);
 gboolean ghb_validate_filter_string(const gchar *str, gint max_fields);
 void ghb_hb_cleanup(gboolean partial);
-gint ghb_lookup_combo_int(const gchar *name, const GValue *acodec);
-const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *acodec);
+gint ghb_lookup_combo_int(const gchar *name, const GValue *gval);
+gdouble ghb_lookup_combo_double(const gchar *name, const GValue *gval);
+const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval);
+const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval);
+gchar* ghb_get_tmp_dir();
+gint ghb_select_audio_codec(signal_user_data_t *ud, gint track);
+const gchar* ghb_select_audio_codec_str(signal_user_data_t *ud, gint track);
 
 #endif // _HBBACKEND_H_
diff --git a/gtk/src/hb-picture.32.png b/gtk/src/hb-picture.32.png
new file mode 100644 (file)
index 0000000..fb8263e
Binary files /dev/null and b/gtk/src/hb-picture.32.png differ
diff --git a/gtk/src/hb-status-empty.32.png b/gtk/src/hb-status-empty.32.png
new file mode 100644 (file)
index 0000000..b00800b
Binary files /dev/null and b/gtk/src/hb-status-empty.32.png differ
diff --git a/gtk/src/hb-status.32.png b/gtk/src/hb-status.32.png
new file mode 100644 (file)
index 0000000..41b2b57
Binary files /dev/null and b/gtk/src/hb-status.32.png differ
index af7d84e..948213d 100644 (file)
@@ -3,6 +3,46 @@
 #include "values.h"
 #include "resources.h"
 
+#if 0
+void
+ghb_load_icons()
+{
+       GHashTableIter iter;
+       gchar *name;
+       GValue *gval;
+
+       GValue *icons = ghb_resource_get("icons");
+       ghb_dict_iter_init(&iter, icons);
+       // middle (void*) cast prevents gcc warning "defreferencing type-punned
+       // pointer will break strict-aliasing rules"
+       while (g_hash_table_iter_next(
+                       &iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval))
+       {
+               gint colorspace, bps, width, height, rowstride;
+               gboolean alpha;
+               ghb_rawdata_t *rd;
+               gint size;
+               GdkPixbuf *pb;
+
+               colorspace = ghb_value_int(ghb_dict_lookup(gval, "colorspace"));
+               alpha = ghb_value_boolean(ghb_dict_lookup(gval, "alpha"));
+               bps = ghb_value_int(ghb_dict_lookup(gval, "bps"));
+               width = ghb_value_int(ghb_dict_lookup(gval, "width"));
+               height = ghb_value_int(ghb_dict_lookup(gval, "height"));
+               rowstride = ghb_value_int(ghb_dict_lookup(gval, "rowstride"));
+               rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
+               pb = gdk_pixbuf_new_from_data(
+                               rd->data, colorspace, alpha, bps,
+                               width, height, rowstride,
+                               NULL, NULL);
+               size = gdk_pixbuf_get_height(pb);
+               gtk_icon_theme_add_builtin_icon(name, size, pb);
+               gdk_pixbuf_unref(pb);
+       }
+}
+
+#else
+
 void
 ghb_load_icons()
 {
@@ -27,3 +67,4 @@ ghb_load_icons()
                gdk_pixbuf_unref(pb);
        }
 }
+#endif
index 143223c..ec68024 100644 (file)
@@ -4,10 +4,16 @@
 <dict>
        <key>Initialization</key>
        <dict>
+               <key>angle</key>
+               <integer>1</integer>
                <key>anamorphic</key>
                <true />
                <key>autoscale</key>
                <false />
+               <key>dest_dir</key>
+               <string></string>
+               <key>dest_file</key>
+               <string>new_video.mp4</string>
                <key>end_chapter</key>
                <integer>100</integer>
                <key>folder</key>
                <array>
                        <string>Normal</string>
                </array>
-               <key>preset_type_folder</key>
-               <false />
-               <key>preset_type_normal</key>
-               <true />
+               <key>PictureDisplayWidth</key>
+               <integer>720</integer>
+               <key>PictureDisplayHeight</key>
+               <integer>480</integer>
                <key>scale_height</key>
                <integer>0</integer>
                <key>scale_width</key>
                <integer>0</integer>
+               <key>show_crop</key>
+               <false />
+               <key>hide_settings</key>
+               <false />
+               <key>show_picture</key>
+               <false />
+               <key>single_title</key>
+               <integer>1</integer>
                <key>start_chapter</key>
                <integer>1</integer>
+               <key>start_frame</key>
+               <integer>-1</integer>
                <key>title</key>
                <string>none</string>
                <key>volume_label</key>
@@ -40,6 +56,8 @@
                <string>some</string>
                <key>x264_bframes</key>
                <integer>0</integer>
+               <key>x264_mbtree</key>
+               <true />
                <key>x264_bpyramid</key>
                <false />
                <key>x264_cabac</key>
@@ -50,6 +68,8 @@
                <integer>0</integer>
                <key>x264_direct</key>
                <string>spatial</string>
+               <key>x264_b_adapt</key>
+               <string>1</string>
                <key>x264_me</key>
                <string>hex</string>
                <key>x264_merange</key>
                <key>audio_list</key>
                <array>
                </array>
-               <key>tweak_PictureDecomb</key>
-               <string></string>
-               <key>tweak_PictureDetelecine</key>
-               <string></string>
+               <key>subtitle_list</key>
+               <array>
+               </array>
                <key>vquality_type_bitrate</key>
                <false />
                <key>vquality_type_constant</key>
                <false />
                <key>vquality_type_target</key>
                <false />
+               <key>SrtLanguage</key>
+               <string>und</string>
+               <key>SrtCodeset</key>
+               <string>ISO-8859-1</string>
+               <key>SrtFile</key>
+               <string></string>
+               <key>SrtOffset</key>
+               <integer>0</integer>
        </dict>
        <key>Preferences</key>
        <dict>
+               <key>AutoScan</key>
+               <false />
+               <key>AddCC</key>
+               <false />
                <key>EncodeLogLocation</key>
                <false />
+               <key>show_status</key>
+               <true />
                <key>allow_tweaks</key>
                <false />
+               <key>title_no_in_destination</key>
+               <false />
+               <key>last_update_check</key>
+               <integer>0</integer>
+               <key>check_updates</key>
+               <string>weekly</string>
                <key>chapters_in_destination</key>
                <false />
                <key>default_source</key>
                <string>/dev/dvd</string>
+               <key>ExportDirectory</key>
+               <string></string>
                <key>destination_dir</key>
                <string></string>
                <key>hbfd</key>
                <false />
                <key>hbfd_feature</key>
                <false />
+               <key>live_duration</key>
+               <integer>15</integer>
+               <key>LoggingLevel</key>
+               <string>1</string>
+               <key>LogLongevity</key>
+               <string>immortal</string>
                <key>nocheckvquality</key>
                <false />
+               <key>use_dvdnav</key>
+               <true />
                <key>reduce_hd_preview</key>
                <true />
-               <key>noscale</key>
-               <false />
+               <key>preview_count</key>
+               <integer>10</integer>
+               <key>preview_fullscreen</key>
+               <false />
+               <key>preview_x</key>
+               <integer>-1</integer>
+               <key>preview_y</key>
+               <integer>-1</integer>
+               <key>settings_x</key>
+               <integer>-1</integer>
+               <key>settings_y</key>
+               <integer>-1</integer>
                <key>show_presets</key>
                <true />
+               <key>show_preview</key>
+               <true />
+               <key>UseM4v</key>
+               <true />
                <key>use_source_name</key>
                <true />
                <key>update_skip_version</key>
                <integer>0</integer>
+               <key>VideoQualityGranularity</key>
+               <string>1</string>
                <key>version</key>
                <string>0.1</string>
+               <key>PreferredLanguage</key>
+               <string>und</string>
+               <key>AudioDUB</key>
+               <false />
+               <key>NotAudioDUB</key>
+               <true />
+               <key>constant_rate_factor</key>
+               <true />
+               <key>WhenComplete</key>
+               <string>notify</string>
+               <key>SrtDir</key>
+               <string></string>
        </dict>
        <key>XlatPresets</key>
        <dict>
                <true />
                <key>autoscale</key>
                <false />
+               <key>par_width</key>
+               <integer>0</integer>
+               <key>par_height</key>
+               <integer>0</integer>
                <key>vquality_type_bitrate</key>
                <false />
                <key>vquality_type_constant</key>
        </dict>
        <key>Presets</key>
        <dict>
+               <key>PresetBuildNumber</key>
+               <string></string>
                <key>PictureAutoCrop</key>
                <true />
                <key>ChapterMarkers</key>
                <true />
-               <key>constant_rate_factor</key>
-               <true />
                <key>FileFormat</key>
                <string>mp4</string>
                <key>Folder</key>
                <false />
+               <key>PictureLooseCrop</key>
+               <false />
+               <key>PictureModulus</key>
+               <integer>16</integer>
                <key>PictureDeblock</key>
                <integer>0</integer>
+               <key>PictureDecombDeinterlace</key>
+               <true />
                <key>PictureDecomb</key>
-               <false />
+               <string>off</string>
+               <key>PictureDecombCustom</key>
+               <string></string>
                <key>Default</key>
                <false />
                <key>PictureBottomCrop</key>
                <key>PictureTopCrop</key>
                <integer>0</integer>
                <key>PictureDeinterlace</key>
-               <string>none</string>
+               <string>off</string>
+               <key>PictureDeinterlaceCustom</key>
+               <string></string>
                <key>PictureDenoise</key>
-               <string>none</string>
+               <string>off</string>
+               <key>PictureDenoiseCustom</key>
+               <string></string>
                <key>PictureDetelecine</key>
-               <true />
-               <key>directqp</key>
-               <false />
-               <key>SubtitlesForced</key>
-               <true />
+               <string>off</string>
+               <key>PictureDetelecineCustom</key>
+               <string></string>
+               <key>PicturePAR</key>
+               <integer>2</integer>
+               <key>PicturePARWidth</key>
+               <integer>853</integer>
+               <key>PicturePARHeight</key>
+               <integer>720</integer>
+               <key>PictureHeight</key>
+               <integer>0</integer>
+               <key>PictureWidth</key>
+               <integer>0</integer>
                <key>VideoFramerate</key>
                <string>source</string>
                <key>VideoGrayScale</key>
                <true />
                <key>Mp4LargeFile</key>
                <false />
-               <key>ModDimensions</key>
-               <true />
-               <key>PicturePAR</key>
-               <integer>2</integer>
-               <key>PictureHeight</key>
-               <integer>0</integer>
-               <key>PictureWidth</key>
-               <integer>0</integer>
                <key>AudioList</key>
                <array>
                        <dict>
                                <key>AudioTrackDescription</key>
                                <string></string>
                                <key>AudioTrackDRCSlider</key>
-                               <real>1</real>
+                               <real>0</real>
                                <key>AudioMixdown</key>
                                <string>dpl2</string>
                                <key>AudioSamplerate</key>
                <string>Name Missing</string>
                <key>Type</key>
                <integer>1</integer>
-               <key>SourceAudioLang</key>
-               <string>und</string>
-               <key>Subtitles</key>
-               <string>none</string>
+               <key>SubtitleList</key>
+               <array>
+                       <dict>
+                               <key>SubtitleLanguage</key>
+                               <string>und</string>
+                               <key>SubtitleForced</key>
+                               <true />
+                               <key>SubtitleSource</key>
+                               <integer>0</integer>
+                               <key>SubtitleBurned</key>
+                               <true />
+                               <key>SubtitleDefaultTrack</key>
+                               <false />
+                       </dict>
+               </array>
                <key>VideoTurboTwoPass</key>
                <false />
                <key>UsesPictureFilters</key>
index 08d7ff1..e92f974 100644 (file)
 #include <config.h>
 
 #include <gtk/gtk.h>
+
+#if !defined(_WIN32)
+#include <gst/gst.h>
+#include <libnotify/notify.h>
+#else
+#include <windows.h>
+#include <io.h>
+//#include <pthread/pthread.h>
+#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
+#endif
+
 #include <glib/gstdio.h>
 #include <gio/gio.h>
-#include "hbversion.h"
+#include "hb.h"
 #include "renderer_button.h"
 #include "hb-backend.h"
 #include "ghb-dvd.h"
 #include "values.h"
 #include "icons.h"
 #include "callbacks.h"
+#include "queuehandler.h"
 #include "x264handler.h"
 #include "settings.h"
 #include "resources.h"
 #include "presets.h"
+#include "preview.h"
+#include "ghbcompositor.h"
 
 
 /*
 #endif
 
 
-
 #define BUILDER_NAME "ghb"
 
 GtkBuilder*
 create_builder_or_die(const gchar * name)
 {
-       guint res;
+       guint res = 0;
        GValue *gval;
+       GError *error = NULL;
        const gchar *ghb_ui;
 
     const gchar *markup =
         N_("<b><big>Unable to create %s.</big></b>\n"
         "\n"
-        "Internal error. Could not parse UI description.\n");
+        "Internal error. Could not parse UI description.\n"
+               "%s");
        g_debug("create_builder_or_die ()\n");
        GtkBuilder *xml = gtk_builder_new();
        gval = ghb_resource_get("ghb-ui");
        ghb_ui = g_value_get_string(gval);
        if (xml != NULL)
-               res = gtk_builder_add_from_string(xml, ghb_ui, -1, NULL);
+               res = gtk_builder_add_from_string(xml, ghb_ui, -1, &error);
     if (!xml || !res) 
        {
         GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL,
@@ -99,7 +114,7 @@ create_builder_or_die(const gchar * name)
             GTK_MESSAGE_ERROR,
             GTK_BUTTONS_CLOSE,
             _(markup),
-            name);
+            name, error->message);
         gtk_dialog_run(GTK_DIALOG(dialog));
         gtk_widget_destroy(dialog);
         exit(EXIT_FAILURE);
@@ -187,9 +202,8 @@ change_font(GtkWidget *widget, gpointer data)
     //gtk_container_foreach((GtkContainer*)window, change_font, "sans 20");
 #endif
 
-extern void chapter_list_selection_changed_cb(void);
-extern void chapter_edited_cb(void);
-extern void chapter_keypress_cb(void);
+extern G_MODULE_EXPORT void chapter_edited_cb(void);
+extern G_MODULE_EXPORT void chapter_keypress_cb(void);
 
 // Create and bind the tree model to the tree view for the chapter list
 // Also, connect up the signal that lets us know the selection has changed
@@ -205,30 +219,35 @@ bind_chapter_tree_model (signal_user_data_t *ud)
        g_debug("bind_chapter_tree_model ()\n");
        treeview = GTK_TREE_VIEW(GHB_WIDGET (ud->builder, "chapters_list"));
        selection = gtk_tree_view_get_selection (treeview);
-       treestore = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN);
+       treestore = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
        gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
 
        cell = ghb_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
-                                                                       _("Chapter No."), cell, "text", 0, NULL);
+                                                                       _("Index"), cell, "text", 0, NULL);
+    gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+
+       cell = ghb_cell_renderer_text_new();
+       column = gtk_tree_view_column_new_with_attributes(
+                                                                       _("Duration"), cell, "text", 1, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
 
        cell = ghb_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
-                                       _("Chapter Title"), cell, "text", 1, "editable", 2, NULL);
+                                       _("Title"), cell, "text", 2, "editable", 3, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
 
        g_signal_connect(cell, "key-press-event", chapter_keypress_cb, ud);
        g_signal_connect(cell, "edited", chapter_edited_cb, ud);
-       g_signal_connect(selection, "changed", chapter_list_selection_changed_cb, ud);
        g_debug("Done\n");
 }
 
-extern void queue_list_selection_changed_cb(void);
-extern void queue_remove_clicked_cb(void);
-extern void queue_list_size_allocate_cb(void);
-extern void queue_drag_cb(void);
-extern void queue_drag_motion_cb(void);
+
+extern G_MODULE_EXPORT void queue_list_selection_changed_cb(void);
+extern G_MODULE_EXPORT void queue_remove_clicked_cb(void);
+extern G_MODULE_EXPORT void queue_list_size_allocate_cb(void);
+extern G_MODULE_EXPORT void queue_drag_cb(void);
+extern G_MODULE_EXPORT void queue_drag_motion_cb(void);
 
 // Create and bind the tree model to the tree view for the queue list
 // Also, connect up the signal that lets us know the selection has changed
@@ -292,7 +311,7 @@ bind_queue_tree_model (signal_user_data_t *ud)
        gtk_widget_hide (widget);
 }
 
-extern void audio_list_selection_changed_cb(void);
+extern G_MODULE_EXPORT void audio_list_selection_changed_cb(void);
 
 // Create and bind the tree model to the tree view for the audio track list
 // Also, connect up the signal that lets us know the selection has changed
@@ -323,26 +342,32 @@ bind_audio_tree_model (signal_user_data_t *ud)
        column = gtk_tree_view_column_new_with_attributes(
                                                                        _("Track"), cell, "text", 0, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 200);
+       gtk_tree_view_column_set_max_width (column, 200);
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
                                                                        _("Codec"), cell, "text", 1, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 110);
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
                                                                        _("Bitrate"), cell, "text", 2, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 50);
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
                                                                        _("Sample Rate"), cell, "text", 3, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 100);
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
                                                                        _("Mix"), cell, "text", 4, NULL);
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 115);
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
@@ -357,9 +382,93 @@ bind_audio_tree_model (signal_user_data_t *ud)
        g_debug("Done\n");
 }
 
-extern void presets_list_selection_changed_cb(void);
-extern void presets_drag_cb(void);
-extern void presets_drag_motion_cb(void);
+extern G_MODULE_EXPORT void subtitle_list_selection_changed_cb(void);
+extern G_MODULE_EXPORT void subtitle_forced_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_burned_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_default_toggled_cb(void);
+
+// Create and bind the tree model to the tree view for the subtitle track list
+// Also, connect up the signal that lets us know the selection has changed
+static void
+bind_subtitle_tree_model (signal_user_data_t *ud)
+{
+       GtkCellRenderer *cell;
+       GtkTreeViewColumn *column;
+       GtkListStore *treestore;
+       GtkTreeView  *treeview;
+       GtkTreeSelection *selection;
+       GtkWidget *widget;
+
+       g_debug("bind_subtitle_tree_model ()\n");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET (ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       // 6 columns in model.  5 are visible, the other 1 is for storing
+       // values that I need
+       // Track, force, burn, default, type, srt offset, track short, source
+       // force visible, burn visible, offset visible
+       treestore = gtk_list_store_new(11, 
+                                                                       G_TYPE_STRING,
+                                                                       G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+                                                                       G_TYPE_BOOLEAN, G_TYPE_STRING,  
+                                                                       G_TYPE_INT,     G_TYPE_STRING,
+                                                                       G_TYPE_INT,
+                                                                       G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+                                                                       G_TYPE_BOOLEAN);
+       gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
+
+       cell = gtk_cell_renderer_text_new();
+       column = gtk_tree_view_column_new_with_attributes(
+                                                                       _("Track"), cell, "text", 0, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 190);
+       gtk_tree_view_column_set_max_width (column, 190);
+
+       cell = gtk_cell_renderer_toggle_new();
+       column = gtk_tree_view_column_new_with_attributes(
+                       _("Forced Only"), cell, "active", 1, "visible", 8, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       g_signal_connect(cell, "toggled", subtitle_forced_toggled_cb, ud);
+
+       cell = gtk_cell_renderer_toggle_new();
+       gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+       column = gtk_tree_view_column_new_with_attributes(
+                       _("Burned In"), cell, "active", 2, "visible", 9, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       g_signal_connect(cell, "toggled", subtitle_burned_toggled_cb, ud);
+
+       cell = gtk_cell_renderer_toggle_new();
+       gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+       column = gtk_tree_view_column_new_with_attributes(
+                               _("Default"), cell, "active", 3, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       g_signal_connect(cell, "toggled", subtitle_default_toggled_cb, ud);
+
+       cell = gtk_cell_renderer_text_new();
+       column = gtk_tree_view_column_new_with_attributes(
+                                                                       _("Type"), cell, "text", 4, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       gtk_tree_view_column_set_min_width (column, 190);
+       gtk_tree_view_column_set_max_width (column, 190);
+
+       cell = gtk_cell_renderer_text_new();
+       column = gtk_tree_view_column_new_with_attributes(
+                       _("Srt Offset"), cell, "text", 5, "visible", 10, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+
+
+       g_signal_connect(selection, "changed", subtitle_list_selection_changed_cb, ud);
+       // Need to disable remove and update buttons since there are initially
+       // no selections
+       widget = GHB_WIDGET (ud->builder, "subtitle_remove");
+       gtk_widget_set_sensitive(widget, FALSE);
+       g_debug("Done\n");
+}
+
+extern G_MODULE_EXPORT void presets_list_selection_changed_cb(void);
+extern G_MODULE_EXPORT void presets_drag_cb(void);
+extern G_MODULE_EXPORT void presets_drag_motion_cb(void);
+extern G_MODULE_EXPORT void preset_edited_cb(void);
+extern void presets_row_expanded_cb(void);
 
 // Create and bind the tree model to the tree view for the preset list
 // Also, connect up the signal that lets us know the selection has changed
@@ -379,13 +488,17 @@ bind_presets_tree_model (signal_user_data_t *ud)
        g_debug("bind_presets_tree_model ()\n");
        treeview = GTK_TREE_VIEW(GHB_WIDGET (ud->builder, "presets_list"));
        selection = gtk_tree_view_get_selection (treeview);
-       treestore = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, 
-                                                                  G_TYPE_STRING, G_TYPE_STRING);
+       treestore = gtk_tree_store_new(6, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, 
+                                                                 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
        gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
 
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(_("Preset Name"), cell, 
-                                       "text", 0, "weight", 1, "style", 2, "foreground", 3, NULL);
+               "text", 0, "weight", 1, "style", 2, 
+               "foreground", 3, "editable", 5, NULL);
+
+       g_signal_connect(cell, "edited", preset_edited_cb, ud);
+
     gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
        gtk_tree_view_column_set_expand (column, TRUE);
        gtk_tree_view_set_tooltip_column (treeview, 4);
@@ -397,6 +510,8 @@ bind_presets_tree_model (signal_user_data_t *ud)
 
        g_signal_connect(treeview, "drag_data_received", presets_drag_cb, ud);
        g_signal_connect(treeview, "drag_motion", presets_drag_motion_cb, ud);
+       g_signal_connect(treeview, "row_expanded", presets_row_expanded_cb, ud);
+       g_signal_connect(treeview, "row_collapsed", presets_row_expanded_cb, ud);
        g_signal_connect(selection, "changed", presets_list_selection_changed_cb, ud);
        widget = GHB_WIDGET (ud->builder, "presets_remove");
        gtk_widget_set_sensitive(widget, FALSE);
@@ -408,7 +523,7 @@ IoRedirect(signal_user_data_t *ud)
 {
        GIOChannel *channel;
        gint pfd[2];
-       gchar *config, *path;
+       gchar *config, *path, *str;
 
        // I'm opening a pipe and attaching the writer end to stderr
        // The reader end will be polled by main event loop and I'll get
@@ -424,13 +539,19 @@ IoRedirect(signal_user_data_t *ud)
        path = g_strdup_printf("%s/%s", config, "Activity.log");
        ud->activity_log = g_io_channel_new_file (path, "w", NULL);
        ud->job_activity_log = NULL;
-       ghb_ui_update(ud, "activity_location", ghb_string_value(path));
+       str = g_strdup_printf("<big><b>%s</b></big>", path);
+       ghb_ui_update(ud, "activity_location", ghb_string_value(str));
+       g_free(str);
        g_free(path);
        g_free(config);
        // Set encoding to raw.
        g_io_channel_set_encoding (ud->activity_log, NULL, NULL);
+#if !defined(_WIN32)
        stderr->_fileno = pfd[1];
-       stdin->_fileno = pfd[0];
+#else
+       stderr->_file = pfd[1];
+#endif
+       setvbuf(stderr, NULL, _IONBF, 0);
        channel = g_io_channel_unix_new (pfd[0]);
        // I was getting an this error:
        // "Invalid byte sequence in conversion input"
@@ -457,36 +578,85 @@ static GOptionEntry entries[] =
        { NULL }
 };
 
-#if defined(__linux__)
-void drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud);
-//void drive_disconnected_cb(GnomeVFSVolumeMonitor *gvm, GnomeVFSDrive *gd, signal_user_data_t *ud);
+G_MODULE_EXPORT void drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud);
+
+#if defined(_WIN32)
+G_MODULE_EXPORT GdkFilterReturn
+win_message_cb(GdkXEvent *wmevent, GdkEvent *event, gpointer data)
+{
+       signal_user_data_t *ud = (signal_user_data_t*)data;
+       MSG *msg = (MSG*)wmevent;
+
+       if (msg->message == WM_DEVICECHANGE)
+       {
+               wm_drive_changed(wmevent, ud);
+       }
+       return GDK_FILTER_CONTINUE;
+}
+#endif
 
 void
 watch_volumes(signal_user_data_t *ud)
 {
+#if !defined(_WIN32)
        GVolumeMonitor *gvm;
        gvm = g_volume_monitor_get ();
 
        g_signal_connect(gvm, "drive-changed", (GCallback)drive_changed_cb, ud);
-       //g_signal_connect(gvm, "drive-connected", (GCallback)drive_connected_cb, ud);
-}
 #else
-void
-watch_volumes(signal_user_data_t *ud)
-{
-}
+       GdkWindow *window;
+       GtkWidget *widget;
+
+       widget = GHB_WIDGET (ud->builder, "hb_window");
+       window = gtk_widget_get_parent_window(widget);
+       gdk_window_add_filter(window, win_message_cb, ud);
 #endif
+}
 
 // Hack to avoid a segfault in libavcodec
 extern int mm_flags;
 int mm_support();
 
-void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud);
+G_MODULE_EXPORT void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud);
+void preview_window_expose_cb(void);
+
+// Some style definitions for the preview window and hud
+const gchar *hud_rcstyle =
+"style \"ghb-entry\" {\n"
+"GtkEntry::inner-border = {2,2,1,1}\n"
+"}\n"
+"style \"ghb-combo\" {\n"
+"xthickness = 1\n"
+"ythickness = 1\n"
+"}\n"
+"style \"ghb-preview\" {\n"
+"bg[NORMAL]=\"black\"\n"
+"}\n"
+"style \"ghb-hud\" {\n"
+"bg[NORMAL]=\"gray18\"\n"
+"bg[ACTIVE]=\"gray32\"\n"
+"bg[PRELIGHT]=\"gray46\"\n"
+"bg[SELECTED]=\"black\"\n"
+"base[NORMAL]=\"gray40\"\n"
+"text[NORMAL]=\"white\"\n"
+"text[ACTIVE]=\"white\"\n"
+"fg[NORMAL]=\"white\"\n"
+"fg[ACTIVE]=\"white\"\n"
+"fg[PRELIGHT]=\"white\"\n"
+"}\n"
+"widget_class \"*.GtkComboBox.GtkToggleButton\" style \"ghb-combo\"\n"
+"widget_class \"*.GtkScaleButton\" style \"ghb-combo\"\n"
+"widget_class \"*.GtkEntry\" style \"ghb-entry\"\n"
+"widget \"preview_window.*.preview_hud.*\" style \"ghb-hud\"\n"
+"widget \"preview_window\" style \"ghb-preview\"\n";
+
+#if GTK_CHECK_VERSION(2, 16, 0)
+extern G_MODULE_EXPORT void status_icon_query_tooltip_cb(void);
+#endif
 
 int
 main (int argc, char *argv[])
 {
-       GtkWidget *window;
        signal_user_data_t *ud;
        GValue *preset;
        GError *error = NULL;
@@ -499,32 +669,86 @@ main (int argc, char *argv[])
        textdomain (GETTEXT_PACKAGE);
 #endif
 
+#ifdef PTW32_STATIC_LIB
+       pthread_win32_process_attach_np();
+       pthread_win32_thread_attach_np();
+#endif
+
+       if (!g_thread_supported())
+               g_thread_init(NULL);
        context = g_option_context_new ("- Rip and encode DVD or MPEG file");
        g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
        g_option_context_add_group (context, gtk_get_option_group (TRUE));
+#if !defined(_WIN32)
+       g_option_context_add_group (context, gst_init_get_option_group ());
+#endif
        g_option_context_parse (context, &argc, &argv, &error);
        g_option_context_free(context);
        
        gtk_set_locale ();
        gtk_init (&argc, &argv);
+       gtk_rc_parse_string(hud_rcstyle);
+       g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
+       g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL);
+#if !defined(_WIN32)
+       notify_init("HandBrake");
+#endif
        ghb_register_transforms();
        ghb_resource_init();
        ghb_load_icons();
 
-#if defined(__linux__)
+#if !defined(_WIN32)
        ghb_hal_init();
 #endif
 
+       if (!ghb_lock_file("queue_lock"))
+       {
+       const gchar *markup =
+               N_("<b><big>Another instance of HandBrake is already running.</big></b>\n"
+               "\n"
+               "Only one instance of HandBrake may run.\n");
+        GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL,
+            GTK_DIALOG_MODAL,
+            GTK_MESSAGE_ERROR,
+            GTK_BUTTONS_CLOSE,
+            _(markup));
+        gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_destroy(dialog);
+        exit(EXIT_FAILURE);
+       }
        ud = g_malloc0(sizeof(signal_user_data_t));
        ud->debug = ghb_debug;
        g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud);
+       g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud);
+       //g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud);
        ud->settings = ghb_settings_new();
+       ud->builder = create_builder_or_die (BUILDER_NAME);
        // Enable events that alert us to media change events
        watch_volumes (ud);
-       ud->builder = create_builder_or_die (BUILDER_NAME);
+
+       //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom");
+       //gtk_entry_set_inner_border(widget, 2);
+
+       // Set up the "hud" control overlay for the preview window
+       GtkWidget *draw, *hud, *blender, *align;
+
+       align = GHB_WIDGET(ud->builder, "preview_window_alignment");
+       draw = GHB_WIDGET(ud->builder, "preview_image_align");
+       hud = GHB_WIDGET(ud->builder, "preview_hud");
+
+       // Set up compositing for hud
+       blender = ghb_compositor_new();
+
+       gtk_container_add(GTK_CONTAINER(align), blender);
+       ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1);
+       ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85);
+       gtk_widget_show(blender);
+
        // Redirect stderr to the activity window
+       ghb_preview_init(ud);
        IoRedirect(ud);
-       ghb_log("Handbrake Version: %s (%d)", HB_VERSION, HB_BUILD);
+       ghb_log( "%s - %s - %s",
+               HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
        ghb_init_dep_map();
 
        // Need to connect x264_options textview buffer to the changed signal
@@ -535,13 +759,13 @@ main (int argc, char *argv[])
        buffer = gtk_text_view_get_buffer (textview);
        g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);
 
-       ghb_file_menu_add_dvd(ud);
-       ghb_backend_init(ud->builder, 1, 0);
+       ghb_combo_init(ud);
 
        g_debug("ud %p\n", ud);
        g_debug("ud->builder %p\n", ud->builder);
 
        bind_audio_tree_model(ud);
+       bind_subtitle_tree_model(ud);
        bind_presets_tree_model(ud);
        bind_queue_tree_model(ud);
        bind_chapter_tree_model(ud);
@@ -553,31 +777,19 @@ main (int argc, char *argv[])
        // Load all internal settings
        ghb_settings_init(ud);
        // Load the presets files
-       ghb_presets_load();
+       ghb_presets_load(ud);
        ghb_prefs_load(ud);
 
-       // Start the show.
-       window = GHB_WIDGET (ud->builder, "hb_window");
-       gtk_widget_show (window);
-
        ghb_prefs_to_ui(ud);
 
+       gint logLevel;
+       logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel");
+       ghb_backend_init(logLevel);
+
        if (ghb_settings_get_boolean(ud->settings, "hbfd"))
        {
                ghb_hbfd(ud, TRUE);
        }
-       gboolean tweaks = ghb_settings_get_boolean(ud->settings, "allow_tweaks");
-       GtkWidget *widget;
-       widget = GHB_WIDGET(ud->builder, "PictureDeinterlace");
-       tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-       widget = GHB_WIDGET(ud->builder, "tweak_PictureDeinterlace");
-       !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-
-       widget = GHB_WIDGET(ud->builder, "PictureDenoise");
-       tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-       widget = GHB_WIDGET(ud->builder, "tweak_PictureDenoise");
-       !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget);
-
        gchar *source = ghb_settings_get_string(ud->settings, "default_source");
        ghb_dvd_set_current(source, ud);
        g_free(source);
@@ -612,18 +824,60 @@ main (int argc, char *argv[])
        }
        // Reload and check status of the last saved queue
        g_idle_add((GSourceFunc)ghb_reload_queue, ud);
-       g_idle_add((GSourceFunc)ghb_check_update, ud);
+
        // Start timer for monitoring libhb status, 500ms
        g_timeout_add (500, ghb_timer_cb, (gpointer)ud);
+
+       // Add dvd devices to File menu
+       ghb_volname_cache_init();
+       g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);
+
+       GtkStatusIcon *si;
+       si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));
+
+       gtk_status_icon_set_visible(si,
+                       ghb_settings_get_boolean(ud->settings, "show_status"));
+
+#if GTK_CHECK_VERSION(2, 16, 0)
+       gtk_status_icon_set_has_tooltip(si, TRUE);
+       g_signal_connect(si, "query-tooltip", 
+                                       status_icon_query_tooltip_cb, ud);
+#else
+       gtk_status_icon_set_tooltip(si, "HandBrake");
+#endif
+
+       // Ugly hack to keep subtitle table from bouncing around as I change
+       // which set of controls are visible
+       GtkRequisition req;
+       GtkWidget *widget;
+       gint height;
+       
+       widget = GHB_WIDGET(ud->builder, "SrtCodeset");
+       gtk_widget_size_request( widget, &req );
+       height = req.height;
+       widget = GHB_WIDGET(ud->builder, "srt_code_label");
+       gtk_widget_size_request( widget, &req );
+       height += req.height;
+       widget = GHB_WIDGET(ud->builder, "subtitle_table");
+       gtk_widget_set_size_request(widget, -1, height);
+       
        // Everything should be go-to-go.  Lets rock!
+
        gtk_main ();
+       gtk_status_icon_set_visible(si, FALSE);
        ghb_backend_close();
        if (ud->queue)
                ghb_value_free(ud->queue);
        ghb_value_free(ud->settings);
        g_io_channel_unref(ud->activity_log);
        ghb_settings_close();
+#if !defined(_WIN32)
+       notify_uninit();
+#endif
        g_free(ud);
+#ifdef PTW32_STATIC_LIB
+       pthread_win32_thread_detach_np();
+       pthread_win32_process_detach_np();
+#endif
        return 0;
 }
-
diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py
new file mode 100644 (file)
index 0000000..9b5359e
--- /dev/null
@@ -0,0 +1,111 @@
+#! /usr/bin/python
+
+import collections
+import plistlib
+
+DepEntry = collections.namedtuple('DepEntry', 'widget dep enable die hide')
+dep_map = (
+       DepEntry("title", "queue_add", "none", True, False),
+       DepEntry("title", "queue_add_menu", "none", True, False),
+       DepEntry("title", "show_picture", "none", True, False),
+       DepEntry("title", "show_preview_menu", "none", True, False),
+       DepEntry("title", "preview_frame", "none", True, False),
+       DepEntry("title", "picture_label", "none", True, False),
+       DepEntry("title", "picture_tab", "none", True, False),
+       DepEntry("title", "chapters_label", "none", True, False),
+       DepEntry("title", "chapters_tab", "none", True, False),
+       DepEntry("title", "title", "none", True, False),
+       DepEntry("title", "start_chapter", "none", True, False),
+       DepEntry("title", "end_chapter", "none", True, False),
+       DepEntry("vquality_type_bitrate", "VideoAvgBitrate", "TRUE", False, False),
+       DepEntry("vquality_type_target", "VideoTargetSize", "TRUE", False, False),
+       DepEntry("vquality_type_constant", "VideoQualitySlider", "TRUE", False, False),
+       DepEntry("vquality_type_constant", "constant_rate_factor", "TRUE", False, False),
+       DepEntry("vquality_type_constant", "VideoTwoPass", "TRUE", True, False),
+       DepEntry("vquality_type_constant", "VideoTurboTwoPass", "TRUE", True, False),
+       DepEntry("VideoTwoPass", "VideoTurboTwoPass", "TRUE", False, False),
+       DepEntry("FileFormat", "Mp4LargeFile", "mp4|m4v", False, True),
+       DepEntry("FileFormat", "Mp4HttpOptimize", "mp4|m4v", False, True),
+       DepEntry("FileFormat", "Mp4iPodCompatible", "mp4|m4v", False, True),
+       DepEntry("PictureDecomb", "PictureDeinterlace", "none", False, False),
+       DepEntry("PictureDecomb", "PictureDeinterlaceCustom", "none", False, True),
+       DepEntry("PictureDeinterlace", "PictureDeinterlaceCustom", "custom", False, True),
+       DepEntry("PictureDenoise", "PictureDenoiseCustom", "custom", False, True),
+       DepEntry("PictureDecomb", "PictureDecombCustom", "custom", False, True),
+       DepEntry("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True),
+       DepEntry("PictureAutoCrop", "PictureTopCrop", "FALSE", False, False),
+       DepEntry("PictureAutoCrop", "PictureBottomCrop", "FALSE", False, False),
+       DepEntry("PictureAutoCrop", "PictureLeftCrop", "FALSE", False, False),
+       DepEntry("PictureAutoCrop", "PictureRightCrop", "FALSE", False, False),
+       DepEntry("autoscale", "scale_width", "FALSE", False, False),
+       DepEntry("autoscale", "scale_height", "FALSE", False, False),
+       DepEntry("anamorphic", "PictureKeepRatio", "FALSE", False, False),
+       ## "CHECK" is a dummy value that forces scale_height deps to
+       ## be re-evaluated whenever anamorphic changes
+       DepEntry("anamorphic", "scale_height", "CHECK", True, False),
+       DepEntry("PictureKeepRatio", "scale_height", "FALSE", False, False),
+       DepEntry("VideoEncoder", "x264_tab", "x264", False, False),
+       DepEntry("VideoEncoder", "x264_tab_label", "x264", False, False),
+       DepEntry("VideoEncoder", "Mp4iPodCompatible", "x264", False, False),
+       DepEntry("AudioEncoder", "AudioBitrate", "ac3|dts", True, False),
+       DepEntry("AudioEncoder", "AudioSamplerate", "ac3|dts", True, False),
+       DepEntry("AudioEncoder", "AudioMixdown", "ac3|dts", True, False),
+       DepEntry("AudioEncoder", "AudioTrackDRCSlider", "ac3|dts", True, False),
+       DepEntry("x264_bframes", "x264_weighted_bframes", "0", True, False),
+       DepEntry("x264_bframes", "x264_bpyramid", "<2", True, False),
+       DepEntry("x264_bframes", "x264_direct", "0", True, False),
+       DepEntry("x264_bframes", "x264_b_adapt", "0", True, False),
+       DepEntry("x264_refs", "x264_mixed_refs", "<2", True, False),
+       DepEntry("x264_cabac", "x264_trellis", "TRUE", False, False),
+       DepEntry("x264_subme", "x264_psy_rd", "<6", True, False),
+       DepEntry("x264_subme", "x264_psy_trell", "<6", True, False),
+       DepEntry("x264_cabac", "x264_psy_trell", "TRUE", False, False),
+       DepEntry("x264_trellis", "x264_psy_trell", "0", True, False),
+       DepEntry("ChapterMarkers", "chapters_list", "TRUE", False, False),
+       DepEntry("use_source_name", "chapters_in_destination", "TRUE", False, False),
+       DepEntry("use_source_name", "title_no_in_destination", "TRUE", False, False),
+       )
+
+def main():
+
+       try:
+               depsfile = open("widget.deps", "w")
+       except Exception, err:
+               print >> sys.stderr, ( "Error: %s"  % str(err) )
+               sys.exit(1)
+
+       try:
+               revfile = open("widget_reverse.deps", "w")
+       except Exception, err:
+               print >> sys.stderr, ( "Error: %s"  % str(err))
+               sys.exit(1)
+
+       top = dict()
+       for ii in dep_map:
+               if ii.widget in top:
+                       continue
+               deps = list()
+               for jj in dep_map:
+                       if jj.widget == ii.widget:
+                               deps.append(jj.dep)
+               top[ii.widget] = deps
+       plistlib.writePlist(top, depsfile)
+
+       top = dict()
+       for ii in dep_map:
+               if ii.dep in top:
+                       continue
+               deps = list()
+               for jj in dep_map:
+                       if ii.dep == jj.dep:
+                               rec = list()
+                               rec.append(jj.widget)
+                               rec.append(jj.enable)
+                               rec.append(jj.die)
+                               rec.append(jj.hide)
+                               deps.append(rec)
+               top[ii.dep] = deps
+       plistlib.writePlist(top, revfile)
+       
+main()
+
index cb9b0e2..05d6fdd 100644 (file)
@@ -525,6 +525,11 @@ gval_write(FILE *file, GValue *gval)
                gint val = g_value_get_int64(gval);
                indent_fprintf(file, indent, "<integer>%d</integer>\n", val);
        }
+       else if (gtype == G_TYPE_INT)
+       {
+               gint val = g_value_get_int(gval);
+               indent_fprintf(file, indent, "<integer>%d</integer>\n", val);
+       }
        else if (gtype == G_TYPE_STRING)
        {
                const gchar *str = g_value_get_string(gval);
index d3fad53..990ea58 100644 (file)
@@ -210,7 +210,7 @@ static value_map_t subtitle_xlat[] =
 static value_map_t vcodec_xlat[] =
 {
        {"MPEG-4 (FFmpeg)", "ffmpeg"},
-       {"MPEG-4 (XviD)", "xvid"},
+       {"MPEG-4 (XviD)", "ffmpeg"},
        {"H.264 (x264)", "x264"},
        {"VP3 (Theora)", "theora"},
        {NULL,NULL}
index f7504d6..bac7bb8 100644 (file)
  * any later version.
  * 
  */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gstdio.h>
 #include <string.h>
 #include <gtk/gtk.h>
+#include "hb.h"
 #include "settings.h"
 #include "callbacks.h"
 #include "audiohandler.h"
+#include "subtitlehandler.h"
 #include "hb-backend.h"
 #include "plist.h"
 #include "resources.h"
@@ -37,10 +43,24 @@ enum
 static GValue *presetsPlist = NULL;
 static GValue *internalPlist = NULL;
 static GValue *prefsPlist = NULL;
+static gboolean prefs_modified = FALSE;
 
 static const GValue* preset_dict_get_value(GValue *dict, const gchar *key);
 static void store_plist(GValue *plist, const gchar *name);
 static void store_presets(void);
+static void store_prefs(void);
+
+gint
+preset_path_cmp(gint *indices1, gint len1, gint *indices2, gint len2)
+{
+       gint ii;
+       for (ii = 0; ii < len1 && ii < len2; ii++)
+       {
+               if (indices1[ii] != indices2[ii])
+                       return indices1[ii] - indices2[ii];
+       }
+       return len1 - len2;
+}
 
 // This only handle limited depth
 GtkTreePath*
@@ -139,37 +159,6 @@ ghb_preset_path_string(const GValue *path)
        return str;
 }
 
-static void
-debug_show_type(GType tp)
-{
-       const gchar *str = "unknown";
-       if (tp == G_TYPE_STRING)
-       {
-               str ="string";
-       }
-       else if (tp == G_TYPE_INT)
-       {
-               str ="int";
-       }
-       else if (tp == G_TYPE_INT64)
-       {
-               str ="int64";
-       }
-       else if (tp == G_TYPE_BOOLEAN)
-       {
-               str ="bool";
-       }
-       else if (tp == ghb_array_get_type())
-       {
-               str ="array";
-       }
-       else if (tp == ghb_dict_get_type())
-       {
-               str ="dict";
-       }
-       g_message("Type: %s", str);
-}
-
 void
 dump_preset_path(const gchar *msg, const GValue *path)
 {
@@ -284,6 +273,17 @@ preset_get_name(GValue *dict)
        return g_value_get_string(preset_dict_get_value(dict, "PresetName"));
 }
 
+static gboolean
+preset_folder_is_open(GValue *dict)
+{
+       const GValue *gval;
+
+       gval = preset_dict_get_value(dict, "FolderOpen");
+       if (gval != NULL)
+               return g_value_get_boolean(gval);
+       return FALSE;
+}
+
 gboolean
 ghb_preset_folder(GValue *dict)
 {
@@ -521,6 +521,37 @@ presets_clear_default(GValue *presets)
        }
 }
 
+static void
+presets_customize(GValue *presets)
+{
+       gint count, ii;
+
+       count = ghb_array_len(presets);
+       for (ii = 0; ii < count; ii++)
+       {
+               GValue *dict;
+               gboolean folder;
+               gint ptype;
+
+               dict = ghb_array_get_nth(presets, ii);
+
+               ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+               if (ptype != PRESETS_CUSTOM)
+               {
+                       ghb_dict_insert(dict, g_strdup("Type"), 
+                                               ghb_int64_value_new(PRESETS_CUSTOM));
+               }
+               folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+               if (folder)
+               {
+                       GValue *nested;
+
+                       nested = ghb_dict_lookup(dict, "ChildrenArray");
+                       presets_customize(nested);
+               }
+       }
+}
+
 static gint*
 presets_find_default2(GValue *presets, gint *len)
 {
@@ -555,7 +586,7 @@ presets_find_default2(GValue *presets, gint *len)
                {
                        if (preset_is_default(dict))
                        {
-                               indices = malloc(MAX_NESTED_PRESET * sizeof(gint));
+                               indices = g_malloc(MAX_NESTED_PRESET * sizeof(gint));
                                indices[*len] = ii;
                                (*len)++;
                                return indices;
@@ -675,6 +706,20 @@ presets_set_default(gint *indices, gint len)
        store_presets();
 }
 
+static void
+presets_set_folder_open(gboolean open, gint *indices, gint len)
+{
+       GValue *dict;
+       
+       g_debug("presets_set_folder_open ()");
+       dict = presets_get_dict(presetsPlist, indices, len);
+       if (dict)
+       {
+               ghb_dict_insert(dict, g_strdup("FolderOpen"), 
+                                               ghb_boolean_value_new(open));
+       }
+}
+
 // Used for sorting dictionaries.
 gint
 key_cmp(gconstpointer a, gconstpointer b)
@@ -862,18 +907,16 @@ preset_to_ui(signal_user_data_t *ud, GValue *dict)
        init_ui_from_dict(ud, internal, dict);
        init_ui_from_dict(ud, hidden, dict);
 
-       if (ghb_settings_get_boolean(ud->settings, "allow_tweaks"))
+       if (dict != NULL)
        {
-               const GValue *gval;
-               gval = preset_dict_get_value(dict, "PictureDeinterlace");
-               if (gval)
-               {
-                       ghb_ui_update(ud, "tweak_PictureDeinterlace", gval);
-               }
-               gval = preset_dict_get_value(dict, "PictureDenoise");
-               if (gval)
+               GValue *val;
+               gboolean dd;
+
+               val = ghb_dict_lookup(dict, "PictureDecombDeinterlace");
+               if (val != NULL)
                {
-                       ghb_ui_update(ud, "tweak_PictureDenoise", gval);
+                       dd = ghb_value_boolean(val);
+                       ghb_ui_update(ud, "PictureDeinterlaceDecomb", ghb_boolean_value(!dd));
                }
        }
 }
@@ -1039,7 +1082,7 @@ ghb_get_user_config_dir(gchar *subdir)
                gchar **split;
                gint ii;
 
-               split = g_strsplit(subdir, "/", -1);
+               split = g_strsplit(subdir, G_DIR_SEPARATOR_S, -1);
                for (ii = 0; split[ii] != NULL; ii++)
                {
                        gchar *tmp;
@@ -1086,6 +1129,28 @@ load_plist(const gchar *name)
        return plist;
 }
 
+gboolean
+ghb_lock_file(const gchar *name)
+{
+#if !defined(_WIN32)
+       gchar *config, *path;
+       int fd, lock = 0;
+
+       config = ghb_get_user_config_dir(NULL);
+       path = g_strdup_printf ("%s/%s", config, name);
+       fd = open(path, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
+       if (fd >= 0)
+               lock = lockf(fd, F_TLOCK, 0);
+       if (lock)
+               close(fd);
+       g_free(config);
+       g_free(path);
+       return !lock;
+#else
+       return 1;
+#endif
+}
+
 static void
 remove_plist(const gchar *name)
 {
@@ -1138,14 +1203,14 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
        // pointer will break strict-aliasing rules"
        while (g_hash_table_iter_next(
                        &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
-    {
+       {
                const GValue *value = NULL;
                if (dict)
                        value = ghb_dict_lookup(dict, key);
                if (value == NULL)
                        value = gval;
                ghb_settings_set_value(ud->settings, key, value);
-    }
+       }
        internal = plist_get_dict(internalPlist, "Preferences");
        ghb_dict_iter_init(&iter, internal);
        // middle (void*) cast prevents gcc warning "defreferencing type-punned
@@ -1177,12 +1242,14 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
        }
        gval = ghb_settings_get_value(ud->settings, "default_source");
        ghb_settings_set_value (ud->settings, "source", gval);
+
        str = ghb_settings_get_string(ud->settings, "destination_dir");
+       ghb_ui_update(ud, "dest_dir", ghb_string_value(str));
 
-       gchar *path = g_strdup_printf ("%s/new_video.mp4", str);
-       ghb_ui_update(ud, "destination", ghb_string_value(path));
+       gchar *file = g_strdup_printf ("new_video.mp4");
+       ghb_ui_update(ud, "dest_file", ghb_string_value(file));
        g_free(str);
-       g_free(path);
+       g_free(file);
 
        prefs_initializing = FALSE;
 }
@@ -1206,20 +1273,43 @@ ghb_prefs_save(GValue *settings)
        // pointer will break strict-aliasing rules"
        while (g_hash_table_iter_next(
                        &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
-    {
-           value = ghb_settings_get_value(settings, key);
-           if (value != NULL)
-           {
+       {
+               value = ghb_settings_get_value(settings, key);
+               if (value != NULL)
+               {
                        ghb_dict_insert(pref_dict, g_strdup(key), ghb_value_dup(value));
-           }
+               }
+       }
+       store_prefs();
+       prefs_modified = FALSE;
+}
+
+void
+ghb_pref_set(GValue *settings, const gchar *key)
+{
+       const GValue *value, *value2;
+       
+       if (prefs_initializing) return;
+       value = ghb_settings_get_value(settings, key);
+       if (value != NULL)
+       {
+               GValue *dict;
+               dict = plist_get_dict(prefsPlist, "Preferences");
+               if (dict == NULL) return;
+               value2 = ghb_dict_lookup(dict, key);
+               if (ghb_value_cmp(value, value2) != 0)
+               {
+                       ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
+                       store_prefs();
+                       prefs_modified = TRUE;
+               }
        }
-    store_plist(prefsPlist, "preferences");
 }
 
 void
 ghb_pref_save(GValue *settings, const gchar *key)
 {
-       const GValue *value;
+       const GValue *value, *value2;
        
        if (prefs_initializing) return;
        value = ghb_settings_get_value(settings, key);
@@ -1228,8 +1318,23 @@ ghb_pref_save(GValue *settings, const gchar *key)
                GValue *dict;
                dict = plist_get_dict(prefsPlist, "Preferences");
                if (dict == NULL) return;
-               ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
-               store_plist(prefsPlist, "preferences");
+               value2 = ghb_dict_lookup(dict, key);
+               if (ghb_value_cmp(value, value2) != 0)
+               {
+                       ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
+                       store_prefs();
+                       prefs_modified = FALSE;
+               }
+       }
+}
+
+void
+ghb_prefs_store(void)
+{
+       if (prefs_modified)
+       {
+               store_prefs();
+               prefs_modified = FALSE;
        }
 }
 
@@ -1294,6 +1399,34 @@ ghb_settings_close()
                ghb_value_free(prefsPlist);
 }
 
+#if defined(_WIN32)
+gchar*
+FindFirstCDROM(void)
+{
+       gint ii, drives;
+       gchar drive[5];
+
+       strcpy(drive, "A:" G_DIR_SEPARATOR_S);
+       drives = GetLogicalDrives();
+       for (ii = 0; ii < 26; ii++)
+       {
+               if (drives & 0x01)
+               {
+                       guint dtype;
+
+                       drive[0] = 'A' + ii;
+                       dtype = GetDriveType(drive);
+                       if (dtype == DRIVE_CDROM)
+                       {
+                               return g_strdup(drive);
+                       }
+               }
+               drives >>= 1;
+       }
+       return NULL;
+}
+#endif
+
 void
 ghb_prefs_load(signal_user_data_t *ud)
 {
@@ -1308,29 +1441,53 @@ ghb_prefs_load(signal_user_data_t *ud)
                prefsPlist = ghb_dict_value_new();
        dict = plist_get_dict(prefsPlist, "Preferences");
        internal = plist_get_dict(internalPlist, "Preferences");
-    if (dict == NULL && internal)
-    {
+       if (dict == NULL && internal)
+       {
                dict = ghb_dict_value_new();
                ghb_dict_insert(prefsPlist, g_strdup("Preferences"), dict);
 
-        // Get defaults from internal defaults 
+               // Get defaults from internal defaults 
                ghb_dict_iter_init(&iter, internal);
                // middle (void*) cast prevents gcc warning "defreferencing type-punned
                // pointer will break strict-aliasing rules"
                while (g_hash_table_iter_next(
                                &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
-        {
+               {
                        ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval));
-        }
-               const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
+               }
+
+               const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+               if (dir == NULL)
+               {
+                       dir = ".";
+               }
+               ghb_dict_insert(dict, 
+                       g_strdup("ExportDirectory"), ghb_value_dup(ghb_string_value(dir)));
+
+               dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
                if (dir == NULL)
                {
                        dir = ".";
                }
                ghb_dict_insert(dict, 
                        g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir)));
-               store_plist(prefsPlist, "preferences");
-    }
+
+               ghb_dict_insert(dict, 
+                       g_strdup("SrtDir"), ghb_value_dup(ghb_string_value(dir)));
+#if defined(_WIN32)
+               gchar *source;
+
+               source = FindFirstCDROM();
+               if (source == NULL)
+               {
+                       source = g_strdup("C:" G_DIR_SEPARATOR_S);
+               }
+               ghb_dict_insert(dict, g_strdup("default_source"), 
+                                               ghb_value_dup(ghb_string_value(source)));
+               g_free(source);
+#endif
+               store_prefs();
+       }
        // Read legacy default_preset preference and update accordingly
        path = ghb_dict_lookup(dict, "default_preset");
        if (path)
@@ -1355,7 +1512,7 @@ ghb_prefs_load(signal_user_data_t *ud)
                        g_free(indices);
                }
                ghb_dict_remove(dict, "default_preset");
-               store_plist(prefsPlist, "preferences");
+               store_prefs();
        }
 }
 
@@ -1447,6 +1604,7 @@ ghb_presets_list_init(
                                                        2, def ? 2 : 0,
                                                        3, color, 
                                                        4, description,
+                                                       5, type == PRESETS_BUILTIN ? 0 : 1,
                                                        -1);
                if (def && piter)
                {
@@ -1467,6 +1625,20 @@ ghb_presets_list_init(
                if (folder)
                {
                        ghb_presets_list_init(ud, more_indices, len+1);
+                       if (preset_folder_is_open(dict))
+                       {
+                               GtkTreePath *path;
+
+                               if (piter != NULL)
+                               {
+                                       path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), piter);
+                                       gtk_tree_view_expand_row(treeview, path, FALSE);
+                                       gtk_tree_path_free(path);
+                               }
+                               path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+                               gtk_tree_view_expand_row(treeview, path, FALSE);
+                               gtk_tree_path_free(path);
+                       }
                }
        }
        g_free(more_indices);
@@ -1476,7 +1648,8 @@ static void
 presets_list_update_item(
        signal_user_data_t *ud, 
        gint *indices,
-       gint len)
+       gint len,
+       gboolean recurse)
 {
        GtkTreeView *treeview;
        GtkTreeStore *store;
@@ -1510,8 +1683,9 @@ presets_list_update_item(
                                                2, def ? 2 : 0,
                                                3, color,
                                                4, description,
+                                               5, type == PRESETS_BUILTIN ? 0 : 1,
                                                -1);
-       if (folder)
+       if (recurse && folder)
        {
                ghb_presets_list_init(ud, indices, len);
        }
@@ -1574,6 +1748,7 @@ presets_list_insert(
                                                2, def ? 2 : 0,
                                                3, color,
                                                4, description,
+                                               5, type == PRESETS_BUILTIN ? 0 : 1,
                                                -1);
        if (folder)
        {
@@ -1655,7 +1830,7 @@ typedef struct
 static value_map_t vcodec_xlat[] =
 {
        {"MPEG-4 (FFmpeg)", "ffmpeg"},
-       {"MPEG-4 (XviD)", "xvid"},
+       {"MPEG-4 (XviD)", "ffmpeg"},
        {"H.264 (x264)", "x264"},
        {"VP3 (Theora)", "theora"},
        {NULL,NULL}
@@ -1664,6 +1839,7 @@ static value_map_t vcodec_xlat[] =
 static value_map_t acodec_xlat[] =
 {
        {"AAC (faac)", "faac"},
+       {"AAC (CoreAudio)", "faac"},
        {"AC3 Passthru", "ac3"},
        {"MP3 (lame)", "lame"},
        {"Vorbis (vorbis)", "vorbis"},
@@ -1673,10 +1849,10 @@ static value_map_t acodec_xlat[] =
 value_map_t container_xlat[] =
 {
        {"MP4 file", "mp4"},
-       {"M4V file", "m4v"},
+       {"M4V file", "mp4"},
        {"MKV file", "mkv"},
-       {"AVI file", "avi"},
-       {"OGM file", "ogm"},
+       {"AVI file", "mkv"},
+       {"OGM file", "mkv"},
        {NULL, NULL}
 };
 
@@ -1718,19 +1894,37 @@ value_map_t mix_xlat[] =
 
 value_map_t deint_xlat[] =
 {
-       {"0", "none"},
-       {"1", "fast"},
-       {"2", "slow"},
-       {"3", "slower"},
+       {"0", "off"},
+       {"1", "custom"},
+       {"2", "fast"},
+       {"3", "slow"},
+       {"4", "slower"},
        {NULL, NULL}
 };
 
 value_map_t denoise_xlat[] =
 {
-       {"0", "none"},
-       {"1", "weak"},
-       {"2", "medium"},
-       {"3", "strong"},
+       {"0", "off"},
+       {"1", "custom"},
+       {"2", "weak"},
+       {"3", "medium"},
+       {"4", "strong"},
+       {NULL, NULL}
+};
+
+value_map_t detel_xlat[] =
+{
+       {"0", "off"},
+       {"1", "custom"},
+       {"2", "default"},
+       {NULL, NULL}
+};
+
+value_map_t decomb_xlat[] =
+{
+       {"0", "off"},
+       {"1", "custom"},
+       {"2", "default"},
        {NULL, NULL}
 };
 
@@ -1750,7 +1944,14 @@ export_lang_xlat2(GValue *lin_val)
        {
                if (strcmp(str, ghb_language_table[ii].iso639_2) == 0)
                {
-                       gval = ghb_string_value_new(ghb_language_table[ii].eng_name);
+                       const gchar *lang;
+
+                       if (ghb_language_table[ii].native_name[0] != 0)
+                               lang = ghb_language_table[ii].native_name;
+                       else
+                               lang = ghb_language_table[ii].eng_name;
+
+                       gval = ghb_string_value_new(lang);
                        g_free(str);
                        return gval;
                }
@@ -1796,7 +1997,8 @@ import_lang_xlat2(GValue *mac_val)
        str = ghb_value_string(mac_val);
        for (ii = 0; ghb_language_table[ii].eng_name; ii++)
        {
-               if (strcmp(str, ghb_language_table[ii].eng_name) == 0)
+               if ((strcmp(str, ghb_language_table[ii].eng_name) == 0) ||
+                       (strcmp(str, ghb_language_table[ii].native_name) == 0))
                {
                        gval = ghb_string_value_new(ghb_language_table[ii].iso639_2);
                        g_free(str);
@@ -1931,29 +2133,45 @@ export_value_xlat(GValue *dict)
        gval = export_value_xlat2(framerate_xlat, lin_val, G_TYPE_STRING);
        if (gval)
                ghb_dict_insert(dict, g_strdup(key), gval);
+       key = "PictureDetelecine";
+       lin_val = ghb_dict_lookup(dict, key);
+       gval = export_value_xlat2(detel_xlat, lin_val, G_TYPE_INT);
+       if (gval)
+               ghb_dict_insert(dict, g_strdup(key), gval);
+       key = "PictureDecomb";
+       lin_val = ghb_dict_lookup(dict, key);
+       gval = export_value_xlat2(decomb_xlat, lin_val, G_TYPE_INT);
+       if (gval)
+               ghb_dict_insert(dict, g_strdup(key), gval);
        key = "PictureDeinterlace";
        lin_val = ghb_dict_lookup(dict, key);
        gval = export_value_xlat2(deint_xlat, lin_val, G_TYPE_INT);
        if (gval)
                ghb_dict_insert(dict, g_strdup(key), gval);
-       else
-               ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(lin_val));
        key = "PictureDenoise";
        lin_val = ghb_dict_lookup(dict, key);
        gval = export_value_xlat2(denoise_xlat, lin_val, G_TYPE_INT);
        if (gval)
                ghb_dict_insert(dict, g_strdup(key), gval);
-       else
-               ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(lin_val));
-       key = "Subtitles";
-       lin_val = ghb_dict_lookup(dict, key);
-       gval = export_subtitle_xlat2(lin_val);
-       if (gval)
-               ghb_dict_insert(dict, g_strdup(key), gval);
+
+       GValue *slist;
+       GValue *sdict;
+       gint count, ii;
+
+       slist = ghb_dict_lookup(dict, "SubtitleList");
+       count = ghb_array_len(slist);
+       for (ii = 0; ii < count; ii++)
+       {
+               sdict = ghb_array_get_nth(slist, ii);
+               key = "SubtitleLanguage";
+               lin_val = ghb_dict_lookup(sdict, key);
+               gval = export_subtitle_xlat2(lin_val);
+               if (gval)
+                       ghb_dict_insert(sdict, g_strdup(key), gval);
+       }
 
        GValue *alist;
        GValue *adict;
-       gint count, ii;
 
        alist = ghb_dict_lookup(dict, "AudioList");
        count = ghb_array_len(alist);
@@ -2020,13 +2238,34 @@ import_value_xlat2(
                                return gval;
                        }
                }
-               //g_warning("Can't map value: (%s)", str);
                g_free(str);
        }
        else
        {
-               g_warning("Bad key: (%s)", key);
-               return NULL;
+               gint ii;
+               gchar *str;
+               GValue *sval;
+
+               str = ghb_value_string(mac_val);
+               for (ii = 0; value_map[ii].mac_val; ii++)
+               {
+                       if (strcmp(str, value_map[ii].mac_val) == 0)
+                       {
+                               sval = ghb_string_value_new(value_map[ii].lin_val);
+                               g_free(str);
+                               gval = ghb_value_new(G_VALUE_TYPE(mac_val));
+                               if (!g_value_transform(sval, gval))
+                               {
+                                       g_warning("can't transform");
+                                       ghb_value_free(gval);
+                                       ghb_value_free(sval);
+                                       return NULL;
+                               }
+                               ghb_value_free(sval);
+                               return gval;
+                       }
+               }
+               g_free(str);
        }
        return NULL;
 }
@@ -2053,6 +2292,16 @@ import_value_xlat(GValue *dict)
        gval = import_value_xlat2(defaults, framerate_xlat, key, mac_val);
        if (gval)
                ghb_dict_insert(dict, g_strdup(key), gval);
+       key = "PictureDetelecine";
+       mac_val = ghb_dict_lookup(dict, key);
+       gval = import_value_xlat2(defaults, detel_xlat, key, mac_val);
+       if (gval)
+               ghb_dict_insert(dict, g_strdup(key), gval);
+       key = "PictureDecomb";
+       mac_val = ghb_dict_lookup(dict, key);
+       gval = import_value_xlat2(defaults, decomb_xlat, key, mac_val);
+       if (gval)
+               ghb_dict_insert(dict, g_strdup(key), gval);
        key = "PictureDeinterlace";
        mac_val = ghb_dict_lookup(dict, key);
        gval = import_value_xlat2(defaults, deint_xlat, key, mac_val);
@@ -2063,19 +2312,85 @@ import_value_xlat(GValue *dict)
        gval = import_value_xlat2(defaults, denoise_xlat, key, mac_val);
        if (gval)
                ghb_dict_insert(dict, g_strdup(key), gval);
-       key = "Subtitles";
-       mac_val = ghb_dict_lookup(dict, key);
-       gval = import_subtitle_xlat2(mac_val);
-       if (gval)
-               ghb_dict_insert(dict, g_strdup(key), gval);
+
+
+       GValue *sdeflist;
+       GValue *sdefaults;
+       GValue *slist;
+       GValue *sdict;
+       gint count, ii;
+
+       sdeflist = ghb_dict_lookup(defaults, "SubtitleList");
+       if (sdeflist)
+       {
+               slist = ghb_dict_lookup(dict, "SubtitleList");
+               if (slist)
+               {
+                       sdefaults = ghb_array_get_nth(sdeflist, 0);
+                       count = ghb_array_len(slist);
+                       for (ii = 0; ii < count; ii++)
+                       {
+                               sdict = ghb_array_get_nth(slist, ii);
+                               key = "SubtitleLanguage";
+                               mac_val = ghb_dict_lookup(sdict, key);
+                               gval = import_subtitle_xlat2(mac_val);
+                               if (gval)
+                                       ghb_dict_insert(sdict, g_strdup(key), gval);
+                       }
+               
+               }
+               else
+               {
+                       key = "Subtitles";
+                       mac_val = ghb_dict_lookup(dict, key);
+                       slist = ghb_array_value_new(8);
+                       ghb_dict_insert(dict, g_strdup("SubtitleList"), slist);
+                       if (mac_val)
+                       {
+                               gchar *lang;
+       
+                               gval = import_subtitle_xlat2(mac_val);
+                               lang = ghb_value_string(gval);
+                               if (lang && strcasecmp(lang, "none") != 0 && !slist)
+                               {
+                                       sdict = ghb_dict_value_new();
+                                       ghb_array_append(slist, sdict);
+                                       ghb_dict_insert(sdict, g_strdup("SubtitleLanguage"), gval);
+                                       gval = ghb_dict_lookup(dict, "SubtitlesForced");
+                                       if (gval != NULL)
+                                       {
+                                               ghb_dict_insert(sdict, g_strdup("SubtitleForced"), 
+                                                                               ghb_value_dup(gval));
+                                       }
+                                       else
+                                       {
+                                               ghb_dict_insert(sdict, g_strdup("SubtitleForced"), 
+                                                                               ghb_boolean_value_new(FALSE));
+                                       }
+                                       ghb_dict_insert(sdict, g_strdup("SubtitleBurned"),
+                                                                       ghb_boolean_value_new(TRUE));
+                                       ghb_dict_insert(sdict, g_strdup("SubtitleDefaultTrack"),
+                                                                       ghb_boolean_value_new(FALSE));
+                               }
+                               else
+                               {
+                                       ghb_value_free(gval);
+                               }
+                               if (lang)
+                                       g_free(lang);
+                       }
+               }
+       }
+       ghb_dict_remove(dict, "Subtitles");
+       ghb_dict_remove(dict, "SubtitlesForced");
+
 
        GValue *alist;
        GValue *adict;
        GValue *adefaults;
        GValue *adeflist;
-       gint count, ii;
 
-       adeflist = ghb_dict_lookup(dict, "AudioList");
+       adeflist = ghb_dict_lookup(defaults, "AudioList");
        if (adeflist)
        {
                adefaults = ghb_array_get_nth(adeflist, 0);
@@ -2104,6 +2419,18 @@ import_value_xlat(GValue *dict)
                        gval = import_value_xlat2(adefaults, mix_xlat, key, mac_val);
                        if (gval)
                                ghb_dict_insert(adict, g_strdup(key), gval);
+
+                       mac_val = ghb_dict_lookup(adict, "AudioTrackDRCSlider");
+                       if (mac_val != NULL)
+                       {
+                               gdouble drc;
+                               drc = ghb_value_double(mac_val);
+                               if (drc < 1.0 && drc > 0.0)
+                               {
+                                       ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), 
+                                                                       ghb_double_value_new(0.0));
+                               }
+                       }
                }
        }
 }
@@ -2133,32 +2460,26 @@ import_xlat_preset(GValue *dict)
        {
        case 0:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(FALSE));
-               if (ghb_dict_lookup(dict, "ModDimensions") == NULL)
-                       ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                                       ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureModulus") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureModulus"), 
+                                                       ghb_int_value_new(16));
        } break;
        case 1:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(FALSE));
+               ghb_dict_insert(dict, g_strdup("PictureModulus"), 
+                                               ghb_int_value_new(1));
        } break;
        case 2:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureModulus") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureModulus"), 
+                                                       ghb_int_value_new(16));
        } break;
        default:
        {
-               ghb_dict_insert(dict, g_strdup("anamorphic"), 
-                                               ghb_boolean_value_new(TRUE));
-               ghb_dict_insert(dict, g_strdup("ModDimensions"), 
-                                               ghb_boolean_value_new(TRUE));
+               if (ghb_dict_lookup(dict, "PictureModulus") == NULL)
+                       ghb_dict_insert(dict, g_strdup("PictureModulus"), 
+                                                       ghb_int_value_new(16));
        } break;
        }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
@@ -2202,9 +2523,45 @@ import_xlat_preset(GValue *dict)
        } break;
        }
        import_value_xlat(dict);
-}
 
-static void
+       gdouble vquality;
+       const GValue *gval;
+
+       vquality = ghb_value_double(preset_dict_get_value(dict, "VideoQualitySlider"));
+       if (vquality < 1.0)
+       {
+               gint vcodec;
+
+               gval = preset_dict_get_value(dict, "VideoEncoder");
+               vcodec = ghb_lookup_combo_int("VideoEncoder", gval);
+               switch (vcodec)
+               {
+                       case HB_VCODEC_X264:
+                       {
+                               vquality = 51. - vquality * 51.;
+                       } break;
+
+                       case HB_VCODEC_FFMPEG:
+                       {
+                               vquality = 31. - vquality * 30.;
+                       } break;
+
+                       case HB_VCODEC_THEORA:
+                       {
+                               vquality = vquality * 63.;
+                       } break;
+
+                       default:
+                       {
+                               vquality = 0.;
+                       } break;
+               }
+               ghb_dict_insert(dict, g_strdup("VideoQualitySlider"), 
+                                               ghb_double_value_new(vquality));
+       }
+}
+
+static void
 import_xlat_presets(GValue *presets)
 {
        gint count, ii;
@@ -2235,12 +2592,10 @@ import_xlat_presets(GValue *presets)
 static void
 export_xlat_preset(GValue *dict)
 {
-       gboolean ana, round, autoscale, target, br, constant;
+       gboolean autoscale, target, br, constant;
 
        g_debug("export_xlat_prest ()");
        autoscale = ghb_value_boolean(preset_dict_get_value(dict, "autoscale"));
-       ana = ghb_value_boolean(preset_dict_get_value(dict, "anamorphic"));
-       round = ghb_value_boolean(preset_dict_get_value(dict, "ModDimensions"));
        target = ghb_value_boolean(
                                preset_dict_get_value(dict, "vquality_type_target"));
        br = ghb_value_boolean(
@@ -2255,20 +2610,6 @@ export_xlat_preset(GValue *dict)
                ghb_dict_insert(dict, g_strdup("UsesPictureSettings"), 
                                                ghb_int_value_new(1));
 
-       if (ana)
-       {
-               if (round)
-                       ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(2));
-               else
-                       ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(1));
-       }
-       else
-       {
-               ghb_dict_insert(dict, g_strdup("PicturePAR"), 
-                                               ghb_int_value_new(0));
-       }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
        if (target)
        {
@@ -2285,8 +2626,28 @@ export_xlat_preset(GValue *dict)
                ghb_dict_insert(dict, g_strdup("VideoQualityType"), 
                                                ghb_int_value_new(2));
        }
+
+       GValue *alist, *adict;
+       gint count, ii;
+
+       alist = ghb_dict_lookup(dict, "AudioList");
+       count = ghb_array_len(alist);
+       for (ii = 0; ii < count; ii++)
+       {
+               gdouble drc;
+
+               adict = ghb_array_get_nth(alist, ii);
+               drc = ghb_value_double(
+                               preset_dict_get_value(adict, "AudioTrackDRCSlider"));
+               if (drc < 1.0 && drc > 0.0)
+               {
+                       ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), 
+                                                       ghb_double_value_new(0.0));
+               }
+       }
+
+       ghb_dict_remove(dict, "UsesMaxPictureSettings");
        ghb_dict_remove(dict, "autoscale");
-       ghb_dict_remove(dict, "anamorphic");
        ghb_dict_remove(dict, "vquality_type_target");
        ghb_dict_remove(dict, "vquality_type_bitrate");
        ghb_dict_remove(dict, "vquality_type_constant");
@@ -2320,6 +2681,16 @@ export_xlat_presets(GValue *presets)
        }
 }
 
+static guint prefs_timeout_id = 0;
+
+static gboolean
+delayed_store_prefs(gpointer data)
+{
+       store_plist(prefsPlist, "preferences");
+       prefs_timeout_id = 0;
+       return FALSE;
+}
+
 static void
 store_presets()
 {
@@ -2331,6 +2702,22 @@ store_presets()
        ghb_value_free(export);
 }
 
+static void
+store_prefs(void)
+{
+       if (prefs_timeout_id != 0)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, prefs_timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+       prefs_timeout_id = g_timeout_add_seconds(1, (GSourceFunc)delayed_store_prefs, NULL);
+}
+
 void
 ghb_presets_reload(signal_user_data_t *ud)
 {
@@ -2343,7 +2730,7 @@ ghb_presets_reload(signal_user_data_t *ud)
        if (std_presets == NULL) return;
 
        remove_std_presets(ud);
-    indices = presets_find_default(presetsPlist, &len);
+       indices = presets_find_default(presetsPlist, &len);
        if (indices)
        {
                presets_clear_default(std_presets);
@@ -2359,6 +2746,8 @@ ghb_presets_reload(signal_user_data_t *ud)
 
                std_dict = ghb_array_get_nth(std_presets, ii);
                copy_dict = ghb_value_dup(std_dict);
+               ghb_dict_insert(copy_dict, g_strdup("PresetBuildNumber"), 
+                                               ghb_int64_value_new(hb_get_build(NULL)));
                ghb_presets_insert(presetsPlist, copy_dict, &indices, 1);
                presets_list_insert(ud, &indices, 1);
        }
@@ -2385,8 +2774,102 @@ check_old_presets()
        return FALSE;
 }
 
+static void
+replace_standard_presets()
+{
+       GValue *std_presets;
+       int *indices, len;
+       gint count, ii;
+
+       count = ghb_array_len(presetsPlist);
+       for (ii = count-1; ii >= 0; ii--)
+       {
+               GValue *dict;
+               gint ptype;
+
+               dict = ghb_array_get_nth(presetsPlist, ii);
+               ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+               if (ptype == PRESETS_BUILTIN)
+               {
+                       gint indices = 0;
+                       ghb_presets_remove(presetsPlist, &indices, 1);
+               }
+       }
+
+       std_presets = ghb_resource_get("standard-presets");
+       if (std_presets == NULL) return;
+
+       indices = presets_find_default(presetsPlist, &len);
+       if (indices)
+       {
+               presets_clear_default(std_presets);
+               g_free(indices);
+       }
+       // Merge the keyfile contents into our presets
+       count = ghb_array_len(std_presets);
+       for (ii = count-1; ii >= 0; ii--)
+       {
+               GValue *std_dict;
+               GValue *copy_dict;
+               gint indices = 0;
+
+               std_dict = ghb_array_get_nth(std_presets, ii);
+               copy_dict = ghb_value_dup(std_dict);
+               ghb_dict_insert(copy_dict, g_strdup("PresetBuildNumber"), 
+                                               ghb_int64_value_new(hb_get_build(NULL)));
+               ghb_presets_insert(presetsPlist, copy_dict, &indices, 1);
+       }
+       import_xlat_presets(presetsPlist);
+       store_presets();
+}
+
+static void
+update_standard_presets(signal_user_data_t *ud)
+{
+       gint count, ii;
+
+       count = ghb_array_len(presetsPlist);
+       for (ii = count-1; ii >= 0; ii--)
+       {
+               GValue *dict;
+               const GValue *gval;
+               gint64 build;
+               gint type;
+
+               dict = ghb_array_get_nth(presetsPlist, ii);
+               gval = ghb_dict_lookup(dict, "Type");
+               if (gval == NULL)
+               {
+                       // Old preset that doesn't have a Type
+                       replace_standard_presets();
+                       return;
+               }
+                       
+               type = ghb_value_int(gval);
+               if (type == 0)
+               {
+                       gval = ghb_dict_lookup(dict, "PresetBuildNumber");
+                       if (gval == NULL)
+                       {
+                               // Old preset that doesn't have a build number
+                               replace_standard_presets();
+                               return;
+                       }
+
+                       build = ghb_value_int64(gval);
+                       if (build != hb_get_build(NULL))
+                       {
+                               // Build number does not match
+                               replace_standard_presets();
+                               return;
+                       }
+               }
+       }
+       return;
+}
+
 void
-ghb_presets_load()
+ghb_presets_load(signal_user_data_t *ud)
 {
        presetsPlist = load_plist("presets");
        if (presetsPlist == NULL)
@@ -2409,6 +2892,7 @@ ghb_presets_load()
                import_xlat_presets(presetsPlist);
                store_presets();
        }
+       update_standard_presets(ud);
        import_xlat_presets(presetsPlist);
 }
 
@@ -2421,6 +2905,7 @@ settings_save(signal_user_data_t *ud, const GValue *path)
        GValue *value;
        gboolean autoscale;
        gint *indices, len, count;
+       gint *def_indices, def_len;
        const gchar *name;
        gboolean replace = FALSE;
 
@@ -2461,24 +2946,9 @@ settings_save(signal_user_data_t *ud, const GValue *path)
                }
        }
        current_preset = dict;
-       if (ghb_settings_get_boolean(ud->settings, "allow_tweaks"))
-       {
-               gchar *str;
-               str = ghb_settings_get_string(ud->settings, "tweak_PictureDeinterlace");
-               if (str)
-               {
-                       ghb_settings_set_string(ud->settings, "PictureDeinterlace", str);
-                       g_free(str);
-               }
-               str = ghb_settings_get_string(ud->settings, "tweak_PictureDenoise");
-               if (str)
-               {
-                       ghb_settings_set_string(ud->settings, "PictureDenoise", str);
-                       g_free(str);
-               }
-       }
        autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
        ghb_settings_set_int64(ud->settings, "Type", PRESETS_CUSTOM);
+       ghb_settings_set_int64(ud->settings, "PresetBuildNumber", hb_get_build(NULL));
 
        internal = plist_get_dict(internalPlist, "Presets");
        ghb_dict_iter_init(&iter, internal);
@@ -2527,7 +2997,16 @@ settings_save(signal_user_data_t *ud, const GValue *path)
        }
        ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(name));
        if (replace)
-               presets_list_update_item(ud, indices, len);
+       {
+               def_indices = presets_find_default(presetsPlist, &def_len);
+               if (def_indices != NULL && 
+                       preset_path_cmp(indices, len, def_indices, def_len) != 0)
+               {
+                       ghb_dict_insert(dict, g_strdup("Default"), 
+                                                       ghb_boolean_value_new(FALSE));
+               }
+               presets_list_update_item(ud, indices, len, FALSE);
+       }
        else
        {
                ghb_dict_insert(dict, g_strdup("Default"), 
@@ -2572,7 +3051,9 @@ folder_save(signal_user_data_t *ud, const GValue *path)
                ghb_dict_insert(dict, g_strdup("PresetDescription"), 
                        ghb_value_dup(preset_dict_get_value(
                                ud->settings, "PresetDescription")));
+               presets_list_update_item(ud, indices, len, FALSE);
                g_free(indices);
+               store_presets();
                return;
        }
        else
@@ -2673,45 +3154,246 @@ update_audio_presets(signal_user_data_t *ud)
        ghb_settings_set_value(ud->settings, "AudioList", audio_list);
 }
 
-void
-enforce_preset_type(signal_user_data_t *ud, const GValue *path)
+static void
+update_subtitle_presets(signal_user_data_t *ud)
 {
-       gint *indices, len;
-       GtkWidget *normal, *folder;
-       gboolean fold;
+       g_debug("update_subtitle_presets");
+       const GValue *subtitle_list, *subtitle;
+       GValue *slist, *dict;
+       gint count, ii, source;
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       slist = ghb_array_value_new(8);
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               subtitle = ghb_array_get_nth(subtitle_list, ii);
+               source = ghb_settings_get_int(subtitle, "SubtitleSource");
+               if (source != SRTSUB)
+               {
+                       dict = ghb_value_dup(subtitle);
+                       ghb_array_append(slist, dict);
+               }
+       }
+       ghb_settings_take_value(ud->settings, "SubtitleList", slist);
+}
 
-       normal = GHB_WIDGET(ud->builder, "preset_type_normal");
-       folder = GHB_WIDGET(ud->builder, "preset_type_folder");
-       indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
-       if (indices)
+G_MODULE_EXPORT void
+presets_menu_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkMenu *menu;
+
+       menu = GTK_MENU(GHB_WIDGET(ud->builder, "presets_menu"));
+       gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 1, 
+                                       gtk_get_current_event_time());
+}
+
+G_MODULE_EXPORT void
+preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+       gchar *exportDir;
+       gchar *filename;
+       GtkFileFilter *filter;
+
+       g_debug("preset_import_clicked_cb ()");
+
+       dialog = gtk_file_chooser_dialog_new("Import Preset", NULL,
+                               GTK_FILE_CHOOSER_ACTION_OPEN,
+                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+                               NULL);
+
+       filter = gtk_file_filter_new();
+       gtk_file_filter_set_name(filter, "All (*)");
+       gtk_file_filter_add_pattern(filter, "*");
+       gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+
+       filter = gtk_file_filter_new();
+       gtk_file_filter_set_name(filter, "Presets (*.plist)");
+       gtk_file_filter_add_pattern(filter, "*.plist");
+       gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+       gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+
+       exportDir = ghb_settings_get_string(ud->settings, "ExportDirectory");
+       if (exportDir == NULL || exportDir[0] == '\0')
        {
-               fold = ghb_presets_get_folder(presetsPlist, indices, len);
-               if (fold)
-                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(folder), 
-                                                                       TRUE);
-               else
-                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(normal), 
-                                                                       TRUE);
-               gtk_widget_set_sensitive(folder,  fold);
-               gtk_widget_set_sensitive(normal,  !fold);
-               g_free(indices);
+               exportDir = g_strdup(".");
        }
-       else
+       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), exportDir);
+       g_free(exportDir);
+
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_hide(dialog);
+       if (response == GTK_RESPONSE_ACCEPT)
+       {
+               GValue *dict, *array;
+               gchar  *dir;
+               gint count, ii;
+
+               filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+               // import the preset
+               if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+               {
+                       gtk_widget_destroy(dialog);
+                       g_free(filename);
+                       return;
+               }
+               array = ghb_plist_parse_file(filename);
+               g_free(filename);
+
+               import_xlat_presets(array);
+               presets_clear_default(array);
+               presets_customize(array);
+
+               count = ghb_array_len(array);
+               for (ii = 0; ii < count; ii++)
+               {
+                       GValue *path, *name;
+                       gint *indices, len;
+                       gint index = 1;
+
+                       dict = ghb_array_get_nth(array, ii);
+                       path = ghb_array_value_new(1);
+                       name = ghb_value_dup(ghb_dict_lookup(dict, "PresetName"));
+                       ghb_array_append(path, name);
+                       indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
+                       // Modify the preset name till we make it unique
+                       while (indices != NULL)
+                       {
+                               gchar *str = ghb_value_string(name);
+
+                               ghb_value_free(path);
+                               g_free(indices);
+
+                               str = g_strdup_printf("%s %d", str, index);
+                               path = ghb_array_value_new(1);
+                               name = ghb_string_value_new(str);
+                               ghb_array_append(path, name);
+                               g_free(str);
+
+                               index++;
+                               indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
+                       }
+                       ghb_dict_insert(dict, g_strdup("PresetName"), ghb_value_dup(name));
+                       indices = presets_find_pos(path, PRESETS_CUSTOM, &len);
+                       ghb_presets_insert(presetsPlist, ghb_value_dup(dict), indices, len);
+                       presets_list_insert(ud, indices, len);
+                       ghb_value_free(path);
+               }
+               ghb_value_free(array);
+
+               exportDir = ghb_settings_get_string(ud->settings, "ExportDirectory");
+               dir = g_path_get_dirname(filename);
+               if (strcmp(dir, exportDir) != 0)
+               {
+                       ghb_settings_set_string(ud->settings, "ExportDirectory", dir);
+                       ghb_pref_save(ud->settings, "ExportDirectory");
+               }
+               g_free(exportDir);
+               g_free(dir);
+       }
+       gtk_widget_destroy(dialog);
+}
+
+G_MODULE_EXPORT void
+preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+       GValue *preset;
+       const gchar *name = "";
+       gint count, *indices, len;
+       gchar *exportDir;
+       gchar *filename;
+
+       g_debug("preset_export_clicked_cb ()");
+       preset = ghb_settings_get_value (ud->settings, "preset_selection");
+       if (preset == NULL)
+               return;
+
+       count = ghb_array_len(preset);
+       if (count <= 0)
+               return;
+
+       name = g_value_get_string(ghb_array_get_nth(preset, count-1));
+
+       dialog = gtk_file_chooser_dialog_new("Export Preset", NULL,
+                               GTK_FILE_CHOOSER_ACTION_SAVE,
+                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                               GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+                               NULL);
+
+       exportDir = ghb_settings_get_string(ud->settings, "ExportDirectory");
+       if (exportDir == NULL || exportDir[0] == '\0')
        {
-               gtk_widget_set_sensitive(folder, TRUE);
-               gtk_widget_set_sensitive(normal, TRUE);
+               exportDir = g_strdup(".");
        }
+       filename = g_strdup_printf("%s.plist", name);
+       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), exportDir);
+       gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
+       g_free(filename);
+       g_free(exportDir);
+
+       indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
+       if (indices == NULL)
+               return;
+
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_hide(dialog);
+       if (response == GTK_RESPONSE_ACCEPT)
+       {
+               GValue *export, *dict, *array;
+               FILE *file;
+               gchar  *dir;
+
+               filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+               // export the preset
+               dict = presets_get_dict(presetsPlist, indices, len);
+
+               export = ghb_value_dup(dict);
+               array = ghb_array_value_new(1);
+               ghb_array_append(array, export);
+               presets_clear_default(array);
+               presets_customize(array);
+               export_xlat_presets(array);
+
+               file = g_fopen(filename, "w");
+               if (file != NULL)
+               {
+                       ghb_plist_write(file, array);
+                       fclose(file);
+               }
+               ghb_value_free(array);
+
+               exportDir = ghb_settings_get_string(ud->settings, "ExportDirectory");
+               dir = g_path_get_dirname(filename);
+               if (strcmp(dir, exportDir) != 0)
+               {
+                       ghb_settings_set_string(ud->settings, "ExportDirectory", dir);
+                       ghb_pref_save(ud->settings, "ExportDirectory");
+               }
+               g_free(exportDir);
+               g_free(dir);
+               g_free(filename);
+       }
+       gtk_widget_destroy(dialog);
+       g_free(indices);
 }
 
-void
-presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+G_MODULE_EXPORT void
+presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkWidget *dialog;
        GtkEntry *entry;
        GtkTextView *desc;
        GtkResponseType response;
-       GValue *preset;
+       GValue *preset, *dict;
        const gchar *name = "";
+       const gchar *description = "";
        gint count, *indices, len;
 
        g_debug("presets_save_clicked_cb ()");
@@ -2722,12 +3404,20 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                name = g_value_get_string(ghb_array_get_nth(preset, count-1));
        else
                count = 1;
-       // Clear the description
+
+       indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
+       dict = presets_get_dict(presetsPlist, indices, len);
+       if (dict != NULL)
+       {
+               description = g_value_get_string(
+                                                       ghb_dict_lookup(dict, "PresetDescription"));
+               ghb_ui_update(ud, "PresetDescription", ghb_string_value(description));
+       }
+
        desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
        dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
        entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
        gtk_entry_set_text(entry, name);
-       enforce_preset_type(ud, preset);
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
        if (response == GTK_RESPONSE_OK)
@@ -2736,13 +3426,61 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                const gchar *name = gtk_entry_get_text(entry);
                GValue *dest;
 
-               if (ghb_settings_get_boolean(ud->settings, "preset_type_folder"))
+               if (count > MAX_NESTED_PRESET-1)
+                       count = MAX_NESTED_PRESET-1;
+
+               dest = ghb_array_value_new(MAX_NESTED_PRESET);
+               if (indices != NULL)
                {
-                       if (count > MAX_NESTED_PRESET-1)
+                       gint ptype;
+
+                       ptype = ghb_presets_get_type(presetsPlist, indices, len);
+                       if (ptype == PRESETS_CUSTOM)
                        {
-                               count = MAX_NESTED_PRESET-1;
+                               ghb_array_copy(dest, preset, count-1);
                        }
                }
+               ghb_array_append(dest, ghb_string_value_new(name));
+               ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
+               folder_save(ud, dest);
+               ghb_value_free(dest);
+       }
+       if (indices != NULL)
+               g_free(indices);
+}
+
+G_MODULE_EXPORT void
+presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *dialog;
+       GtkEntry *entry;
+       GtkTextView *desc;
+       GtkResponseType response;
+       GValue *preset;
+       const gchar *name = "";
+       gint count, *indices, len;
+
+       g_debug("presets_save_clicked_cb ()");
+       preset = ghb_settings_get_value (ud->settings, "preset_selection");
+
+       count = ghb_array_len(preset);
+       if (count > 0)
+               name = g_value_get_string(ghb_array_get_nth(preset, count-1));
+       else
+               count = 1;
+
+       desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
+       dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
+       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
+       gtk_entry_set_text(entry, name);
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_hide(dialog);
+       if (response == GTK_RESPONSE_OK)
+       {
+               // save the preset
+               const gchar *name = gtk_entry_get_text(entry);
+               GValue *dest;
+
                dest = ghb_array_value_new(MAX_NESTED_PRESET);
                indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
                if (indices)
@@ -2754,47 +3492,27 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        {
                                ghb_array_copy(dest, preset, count-1);
                        }
+                       g_free(indices);
                }
                ghb_array_append(dest, ghb_string_value_new(name));
 
                ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
-               if (ghb_settings_get_boolean(ud->settings, "preset_type_folder"))
-               {
-                       folder_save(ud, dest);
-               }
-               else
-               {
-                       // Construct the audio settings presets from the current audio list
-                       update_audio_presets(ud);
-                       settings_save(ud, dest);
-               }
+
+               // Construct the audio settings presets from the current audio list
+               update_audio_presets(ud);
+               update_subtitle_presets(ud);
+               settings_save(ud, dest);
                ghb_value_free(dest);
        }
 }
 
-void
+G_MODULE_EXPORT void
 preset_type_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        ghb_widget_to_setting(ud->settings, widget);
 }
 
-void
-preset_name_changed_cb(GtkWidget *entry, signal_user_data_t *ud)
-{
-       gchar *name;
-       GValue *preset, *dest;
-       gint count;
-
-       preset = ghb_settings_get_value (ud->settings, "preset_selection");
-       name = ghb_widget_string(entry);
-       dest = ghb_value_dup(preset);
-       count = ghb_array_len(dest);
-       ghb_array_replace(dest, count-1, ghb_string_value_new(name));
-       enforce_preset_type(ud, dest);
-       ghb_value_free(dest);
-}
-
-void
+G_MODULE_EXPORT void
 presets_restore_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GValue *preset;
@@ -2808,7 +3526,7 @@ presets_restore_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        ghb_select_preset(ud->builder, preset);
 }
 
-void
+G_MODULE_EXPORT void
 presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
@@ -2877,7 +3595,7 @@ presets_remove_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 }
 
 // controls where valid drop locations are
-gboolean
+G_MODULE_EXPORT gboolean
 presets_drag_motion_cb(
        GtkTreeView *tv,
        GdkDragContext *ctx,
@@ -2897,6 +3615,11 @@ presets_drag_motion_cb(
        gboolean src_folder, dst_folder;
        GValue *preset;
        gint tree_depth, ii;
+       GtkWidget *widget;
+
+       widget = gtk_drag_get_source_widget(ctx);
+       if (widget == NULL || widget != GTK_WIDGET(tv))
+               return TRUE;
 
        // Get the type of the object being dragged
        srctv = GTK_TREE_VIEW(gtk_drag_get_source_widget(ctx));
@@ -2968,7 +3691,7 @@ presets_drag_motion_cb(
        return TRUE;
 }
 
-void 
+G_MODULE_EXPORT void 
 presets_drag_cb(
        GtkTreeView *dstwidget, 
        GdkDragContext *dc, 
@@ -3108,7 +3831,7 @@ presets_drag_cb(
                        dstpath = gtk_tree_model_get_path (dstmodel, &iter);
                        dst_indices = gtk_tree_path_get_indices(dstpath);
                        dst_len = gtk_tree_path_get_depth(dstpath);
-                       presets_list_update_item(ud, dst_indices, dst_len);
+                       presets_list_update_item(ud, dst_indices, dst_len, TRUE);
                        gtk_tree_path_free(dstpath);
 
                        store_presets();
@@ -3117,6 +3840,62 @@ presets_drag_cb(
        }
 }
 
+void
+presets_row_expanded_cb(
+       GtkTreeView *treeview, 
+       GtkTreeIter *iter, 
+       GtkTreePath *path, 
+       signal_user_data_t *ud)
+{
+       gint *indices, len;
+       gboolean expanded, folder;
+       GValue *dict;
+
+       expanded = gtk_tree_view_row_expanded(treeview, path);
+       indices = gtk_tree_path_get_indices(path);
+       len = gtk_tree_path_get_depth(path);
+       dict = presets_get_dict(presetsPlist, indices, len);
+       if (preset_folder_is_open(dict))
+       {
+               if (expanded)
+                       return;
+       }
+       else if (!expanded)
+       {
+               return;
+       }
+       folder = ghb_presets_get_folder(presetsPlist, indices, len);
+       if (folder)
+       {
+               presets_set_folder_open(expanded, indices, len);
+       }
+
+       // Collapsing parent folder collapses all children
+       if (!expanded)
+       {
+               GValue *presets = NULL;
+               gint *more_indices, count, ii;
+
+               more_indices = g_malloc((len+1)*sizeof(gint));
+               memcpy(more_indices, indices, len*sizeof(gint));
+
+               presets = presets_get_folder(presetsPlist, indices, len);
+               count = ghb_array_len(presets);
+               for (ii = 0; ii < count; ii++)
+               {
+                       dict = ghb_array_get_nth(presets, ii);
+                       folder = ghb_preset_folder(dict);
+                       if (folder)
+                       {
+                               more_indices[len] = ii;
+                               presets_set_folder_open(expanded, more_indices, len+1);
+                       }
+               }
+               g_free(more_indices);
+       }
+       store_presets();
+}
+
 static void
 preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
 {
@@ -3125,10 +3904,11 @@ preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        ghb_ui_update(ud, "scale_width", 
                        ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
        // If anamorphic or keep_aspect, the hight will be automatically calculated
-       gboolean keep_aspect, anamorphic;
+       gboolean keep_aspect;
+       gint pic_par;
        keep_aspect = ghb_settings_get_boolean(ud->settings, "PictureKeepRatio");
-       anamorphic = ghb_settings_get_boolean(ud->settings, "anamorphic");
-       if (!(keep_aspect || anamorphic))
+       pic_par = ghb_settings_combo_int(ud->settings, "PicturePAR");
+       if (!(keep_aspect || pic_par) || pic_par == 3)
        {
                ghb_ui_update(ud, "scale_height", 
                        ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));
@@ -3156,7 +3936,7 @@ preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        }
 }
 
-void
+G_MODULE_EXPORT void
 presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
 {
        GtkTreeModel *store;
@@ -3199,20 +3979,25 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        gint titleindex;
                        titleindex = ghb_settings_combo_int(ud->settings, "title");
                        ghb_set_pref_audio(titleindex, ud);
+                       ghb_set_pref_subtitle(titleindex, ud);
                        ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
-                       ud->dont_clear_presets = FALSE;
                        if (ghb_get_title_info (&tinfo, titleindex))
                        {
                                preset_update_title_deps(ud, &tinfo);
                        }
-                       ghb_set_scale (ud, GHB_SCALE_KEEP_NONE);
+                       ghb_set_scale (ud, GHB_PIC_KEEP_PAR);
+                       ud->dont_clear_presets = FALSE;
 
                        gdouble vqmin, vqmax, step, page;
                        gint digits;
-                       ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits);
+                       gboolean inverted;
+
+                       ghb_vquality_range(ud, &vqmin, &vqmax, &step, 
+                                                               &page, &digits, &inverted);
                        gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax);
                        gtk_range_set_increments (GTK_RANGE(qp), step, page);
                        gtk_scale_set_digits(GTK_SCALE(qp), digits);
+                       gtk_range_set_inverted (GTK_RANGE(qp), inverted);
 
                        gchar *text;
                        gint crop[4];
@@ -3250,7 +4035,7 @@ ghb_clear_presets_selection(signal_user_data_t *ud)
        ghb_settings_set_boolean(ud->settings, "preset_modified", TRUE);
 }
 
-void
+G_MODULE_EXPORT void
 presets_frame_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
@@ -3270,7 +4055,7 @@ presets_frame_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, sig
        }
 }
 
-void
+G_MODULE_EXPORT void
 presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GValue *preset;
@@ -3291,3 +4076,50 @@ presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        }
 }
 
+G_MODULE_EXPORT void
+preset_edited_cb(
+       GtkCellRendererText *cell, 
+       gchar *path, 
+       gchar *text, 
+       signal_user_data_t *ud)
+{
+       GtkTreePath *treepath;
+       GtkTreeStore *store;
+       GtkTreeView *treeview;
+       GtkTreeIter iter;
+       gint *indices, len, count;
+       GValue *dict;
+       GValue *preset, *dest;
+       
+       g_debug("preset_edited_cb ()");
+       g_debug("path (%s)", path);
+       g_debug("text (%s)", text);
+
+       preset = ghb_settings_get_value (ud->settings, "preset_selection");
+       dest = ghb_array_value_new(MAX_NESTED_PRESET);
+       count = ghb_array_len(preset);
+       ghb_array_copy(dest, preset, count-1);
+       ghb_array_append(dest, ghb_string_value_new(text));
+       indices = ghb_preset_indices_from_path(presetsPlist, dest, &len);
+       ghb_value_free(dest);
+       if (indices != NULL)
+       {
+               // Already exists
+               g_free(indices);
+               return;
+       }
+
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list"));
+       store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
+       treepath = gtk_tree_path_new_from_string (path);
+       indices = gtk_tree_path_get_indices(treepath);
+       len = gtk_tree_path_get_depth(treepath);
+       gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath);
+       gtk_tree_store_set(store, &iter, 0, text, -1);
+
+       dict = presets_get_dict(presetsPlist, indices, len);
+       ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(text));
+       store_presets();
+       gtk_tree_path_free (treepath);
+}
+
index c5a870d..65b4e8c 100644 (file)
@@ -17,7 +17,7 @@
 #define _GHB_PRESETS_H_
 
 void ghb_settings_save(signal_user_data_t *ud, const gchar *name);
-void ghb_presets_load(void);
+void ghb_presets_load(signal_user_data_t *ud);
 void ghb_update_from_preset(signal_user_data_t *ud, const gchar *key);
 void ghb_prefs_load(signal_user_data_t *ud);
 void ghb_settings_init(signal_user_data_t *ud);
@@ -38,5 +38,8 @@ void ghb_presets_list_init(signal_user_data_t *ud, gint *indices, gint len);
 GValue* ghb_parse_preset_path(const gchar *path);
 gchar* ghb_preset_path_string(const GValue *path);
 gboolean ghb_preset_is_custom(void);
+void ghb_prefs_store(void);
+void ghb_pref_set(GValue *settings, const gchar *key);
+gboolean ghb_lock_file(const gchar *name);
 
 #endif // _GHB_PRESETS_H_
diff --git a/gtk/src/preview.c b/gtk/src/preview.c
new file mode 100644 (file)
index 0000000..e85130e
--- /dev/null
@@ -0,0 +1,1230 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * preview.c
+ * Copyright (C) John Stebbins 2008 <stebbins@stebbins>
+ * 
+ * preview.c is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ */
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#if !defined(_WIN32)
+#include <gdk/gdkx.h>
+#endif
+
+#if defined(_ENABLE_GST)
+#include <gst/gst.h>
+#include <gst/interfaces/xoverlay.h>
+#include <gst/video/video.h>
+#include <gst/pbutils/missing-plugins.h>
+#endif
+
+#include "settings.h"
+#include "presets.h"
+#include "callbacks.h"
+#include "hb-backend.h"
+#include "preview.h"
+#include "values.h"
+#include "hb.h"
+
+#define PREVIEW_STATE_IMAGE 0
+#define PREVIEW_STATE_LIVE 1
+
+struct preview_s
+{
+#if defined(_ENABLE_GST)
+       GstElement *play;
+       gulong xid;
+#endif
+       gint64 len;
+       gint64 pos;
+       gboolean seek_lock;
+       gboolean progress_lock;
+       gint width;
+       gint height;
+       GtkWidget *view;
+       GdkPixbuf *pix;
+       gint button_width;
+       gint button_height;
+       gint frame;
+       gint state;
+       gboolean pause;
+       gboolean encoded[10];
+       gint encode_frame;
+       gint live_id;
+       gchar *current;
+};
+
+#if defined(_ENABLE_GST)
+G_MODULE_EXPORT gboolean live_preview_cb(GstBus *bus, GstMessage *msg, gpointer data);
+static GstBusSyncReply create_window(GstBus *bus, GstMessage *msg, 
+                               gpointer data);
+#endif
+
+G_MODULE_EXPORT gboolean preview_expose_cb(GtkWidget *widget, GdkEventExpose *event, 
+                               signal_user_data_t *ud);
+
+void
+ghb_screen_par(signal_user_data_t *ud, gint *par_n, gint *par_d)
+{
+#if defined(_ENABLE_GST)
+       GValue disp_par = {0,};
+       GstElement *xover;
+       GObjectClass *klass;
+       GParamSpec *pspec;
+
+       g_value_init(&disp_par, GST_TYPE_FRACTION);
+       gst_value_set_fraction(&disp_par, 1, 1);
+       g_object_get(ud->preview->play, "video-sink", &xover, NULL);
+       if (xover == NULL)
+               goto fail;
+
+       klass = G_OBJECT_GET_CLASS(xover);
+       if (klass == NULL)
+               goto fail;
+
+       pspec = g_object_class_find_property(klass, "pixel-aspect_ratio");
+       if (pspec)
+       {
+               GValue par_prop = {0,};
+
+               g_value_init(&par_prop, pspec->value_type);
+               g_object_get_property(G_OBJECT(xover), "pixel-aspect-ratio",
+                                                               &par_prop);
+               if (!g_value_transform(&par_prop, &disp_par))
+               {
+                       g_warning("transform failed");
+                       gst_value_set_fraction(&disp_par, 1, 1);
+               }
+               g_value_unset(&par_prop);
+       }
+       *par_n = gst_value_get_fraction_numerator(&disp_par);
+       *par_d = gst_value_get_fraction_denominator(&disp_par);
+       g_value_unset(&disp_par);
+       return;
+
+fail:
+       *par_n = 1;
+       *par_d = 1;
+#else
+       *par_n = 1;
+       *par_d = 1;
+#endif
+}
+
+void
+ghb_par_scale(signal_user_data_t *ud, gint *width, gint *height, gint par_n, gint par_d)
+{
+       gint disp_par_n, disp_par_d;
+       gint64 num, den;
+
+       ghb_screen_par(ud, &disp_par_n, &disp_par_d);
+       if (disp_par_n < 1) disp_par_n = 1;
+       if (disp_par_d < 1) disp_par_d = 1;
+       num = par_n * disp_par_d;
+       den = par_d * disp_par_n;
+
+       if (par_n > par_d)
+               *width = *width * num / den;
+       else
+               *height = *height * den / num;
+}
+
+void
+ghb_preview_init(signal_user_data_t *ud)
+{
+       GtkWidget *widget;
+
+       ud->preview = g_malloc0(sizeof(preview_t));
+       ud->preview->view = GHB_WIDGET(ud->builder, "preview_image");
+       gtk_widget_realize(ud->preview->view);
+       g_signal_connect(G_OBJECT(ud->preview->view), "expose_event",
+                                       G_CALLBACK(preview_expose_cb), ud);
+
+       ud->preview->pause = TRUE;
+       ud->preview->encode_frame = -1;
+       ud->preview->live_id = -1;
+       widget = GHB_WIDGET (ud->builder, "preview_button_image");
+       gtk_widget_get_size_request(widget, &ud->preview->button_width, &ud->preview->button_height);
+       
+#if defined(_ENABLE_GST)
+       GstBus *bus;
+       GstElement *xover;
+
+#if !defined(_WIN32)
+       ud->preview->xid = GDK_DRAWABLE_XID(ud->preview->view->window);
+#else
+       ud->preview->xid = GDK_WINDOW_HWND(ud->preview->view->window);
+#endif
+       ud->preview->play = gst_element_factory_make("playbin", "play");
+       //xover = gst_element_factory_make("xvimagesink", "xover");
+       //xover = gst_element_factory_make("ximagesink", "xover");
+       xover = gst_element_factory_make("gconfvideosink", "xover");
+       if (xover == NULL)
+       {
+               GtkWidget *widget = GHB_WIDGET(ud->builder, "live_preview_box");
+               gtk_widget_hide (widget);
+               widget = GHB_WIDGET(ud->builder, "live_preview_duration_box");
+               gtk_widget_hide (widget);
+               return;
+       }
+
+       g_object_set(G_OBJECT(ud->preview->play), "video-sink", xover, NULL);
+       g_object_set(ud->preview->play, "subtitle-font-desc", 
+                               "sans bold 20", NULL);
+       //g_object_set(G_OBJECT(xover), "force-aspect-ratio", TRUE, NULL);
+
+       bus = gst_pipeline_get_bus(GST_PIPELINE(ud->preview->play));
+       gst_bus_add_watch(bus, live_preview_cb, ud);
+       gst_bus_set_sync_handler(bus, create_window, ud->preview);
+       gst_object_unref(bus);
+#else
+       GtkWidget *widget = GHB_WIDGET(ud->builder, "live_preview_box");
+       gtk_widget_hide (widget);
+       widget = GHB_WIDGET(ud->builder, "live_preview_duration_box");
+       gtk_widget_hide (widget);
+#endif
+}
+
+void
+ghb_preview_cleanup(signal_user_data_t *ud)
+{
+       if (ud->preview->current)
+       {
+               ud->preview->current = NULL;
+               g_free(ud->preview->current);
+       }
+}
+
+#if defined(_ENABLE_GST)
+static GstBusSyncReply
+create_window(GstBus *bus, GstMessage *msg, gpointer data)
+{
+       preview_t *preview = (preview_t*)data;
+
+       switch (GST_MESSAGE_TYPE(msg))
+       {
+       case GST_MESSAGE_ELEMENT:
+       {
+               if (!gst_structure_has_name(msg->structure, "prepare-xwindow-id"))
+                       return GST_BUS_PASS;
+#if !defined(_WIN32)
+               gst_x_overlay_set_xwindow_id(
+                       GST_X_OVERLAY(GST_MESSAGE_SRC(msg)), preview->xid);
+#else
+               gst_directdraw_sink_set_window_id(
+                       GST_X_OVERLAY(GST_MESSAGE_SRC(msg)), preview->xid);
+#endif
+               gst_message_unref(msg);
+               return GST_BUS_DROP;
+       } break;
+
+       default:
+       {
+       } break;
+       }
+       return GST_BUS_PASS;
+}
+
+static GList *
+get_stream_info_objects_for_type (GstElement *play, const gchar *typestr)
+{
+       GValueArray *info_arr = NULL;
+       GList *ret = NULL;
+       guint ii;
+
+       if (play == NULL)
+               return NULL;
+
+       g_object_get(play, "stream-info-value-array", &info_arr, NULL);
+       if (info_arr == NULL)
+               return NULL;
+
+       for (ii = 0; ii < info_arr->n_values; ++ii) 
+       {
+               GObject *info_obj;
+               GValue *val;
+
+               val = g_value_array_get_nth(info_arr, ii);
+               info_obj = g_value_get_object(val);
+               if (info_obj) 
+               {
+                       GParamSpec *pspec;
+                       GEnumValue *value;
+                       gint type = -1;
+
+                       g_object_get(info_obj, "type", &type, NULL);
+                       pspec = g_object_class_find_property(
+                                               G_OBJECT_GET_CLASS (info_obj), "type");
+                       value = g_enum_get_value(
+                                               G_PARAM_SPEC_ENUM (pspec)->enum_class, type);
+                       if (value) 
+                       {
+                               if (g_ascii_strcasecmp (value->value_nick, typestr) == 0 ||
+                                       g_ascii_strcasecmp (value->value_name, typestr) == 0) 
+                               {
+                                       ret = g_list_prepend (ret, g_object_ref (info_obj));
+                               }
+                       }
+               }
+       }
+       g_value_array_free (info_arr);
+       return g_list_reverse (ret);
+}
+
+static void
+caps_set(GstCaps *caps, signal_user_data_t *ud)
+{
+       GstStructure *ss;
+
+       ss = gst_caps_get_structure(caps, 0);
+       if (ss)
+       {
+               gint fps_n, fps_d, width, height;
+               guint num, den, par_n, par_d;
+               gint disp_par_n, disp_par_d;
+               const GValue *par;
+
+               gst_structure_get_fraction(ss, "framerate", &fps_n, &fps_d);
+               gst_structure_get_int(ss, "width", &width);
+               gst_structure_get_int(ss, "height", &height);
+               par = gst_structure_get_value(ss, "pixel-aspect-ratio");
+               par_n = gst_value_get_fraction_numerator(par);
+               par_d = gst_value_get_fraction_denominator(par);
+
+               ghb_screen_par(ud, &disp_par_n, &disp_par_d);
+               gst_video_calculate_display_ratio(
+                       &num, &den, width, height, par_n, par_d, disp_par_n, disp_par_d);
+
+               if (par_n > par_d)
+                       width = gst_util_uint64_scale_int(height, num, den);
+               else
+                       height = gst_util_uint64_scale_int(width, den, num);
+
+               if (ghb_settings_get_boolean(ud->settings, "reduce_hd_preview"))
+               {
+                       GdkScreen *ss;
+                       gint s_w, s_h;
+
+                       ss = gdk_screen_get_default();
+                       s_w = gdk_screen_get_width(ss);
+                       s_h = gdk_screen_get_height(ss);
+
+                       if (width > s_w * 80 / 100)
+                       {
+                               width = s_w * 80 / 100;
+                               height = gst_util_uint64_scale_int(width, den, num);
+                       }
+                       if (height > s_h * 80 / 100)
+                       {
+                               height = s_h * 80 / 100;
+                               width = gst_util_uint64_scale_int(height, num, den);
+                       }
+               }
+               
+               if (width != ud->preview->width || height != ud->preview->height)
+               {
+                       gtk_widget_set_size_request(ud->preview->view, width, height);
+                       ud->preview->width = width;
+                       ud->preview->height = height;
+               }
+       }
+}
+
+static void
+update_stream_info(signal_user_data_t *ud)
+{
+       GList *vstreams, *ll;
+       GstPad *vpad = NULL;
+
+       vstreams = get_stream_info_objects_for_type(ud->preview->play, "video");
+       if (vstreams)
+       {
+               for (ll = vstreams; vpad == NULL && ll != NULL; ll = ll->next)
+               {
+                       g_object_get(ll->data, "object", &vpad, NULL);
+               }
+       }
+       if (vpad)
+       {
+               GstCaps *caps;
+
+               caps = gst_pad_get_negotiated_caps(vpad);
+               if (caps)
+               {
+                       caps_set(caps, ud);
+                       gst_caps_unref(caps);
+               }
+               //g_signal_connect(vpad, "notify::caps", G_CALLBACK(caps_set_cb), preview);
+               gst_object_unref(vpad);
+       }
+       g_list_foreach(vstreams, (GFunc)g_object_unref, NULL);
+       g_list_free(vstreams);
+}
+
+G_MODULE_EXPORT gboolean
+live_preview_cb(GstBus *bus, GstMessage *msg, gpointer data)
+{
+       signal_user_data_t *ud = (signal_user_data_t*)data;
+
+       switch (GST_MESSAGE_TYPE(msg))
+       {
+       case GST_MESSAGE_ERROR:
+       {
+               GError *err;
+               gchar *debug;
+
+               gst_message_parse_error(msg, &err, &debug);
+               g_warning("Gstreamer Error: %s", err->message);
+               g_error_free(err);
+               g_free(debug);
+       } break;
+
+       case GST_MESSAGE_ELEMENT:
+       {
+               if (gst_is_missing_plugin_message(msg))
+               {
+                       gst_element_set_state(ud->preview->play, GST_STATE_PAUSED);
+                       gchar *message, *desc;
+                       desc = gst_missing_plugin_message_get_description(msg);
+                       message = g_strdup_printf(
+                                               "Missing GStreamer plugin\n"
+                                               "Audio or Video may not play as expected\n\n%s",
+                                               desc);
+                       ghb_message_dialog(GTK_MESSAGE_WARNING, message, "Ok", NULL);
+                       g_free(message);
+                       gst_element_set_state(ud->preview->play, GST_STATE_PLAYING);
+               }
+       } break;
+
+       case GST_MESSAGE_STATE_CHANGED:
+       {
+               GstState state, pending;
+               gst_element_get_state(ud->preview->play, &state, &pending, 0);
+               if (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING)
+               {
+                       update_stream_info(ud);
+               }
+       } break;
+
+       case GST_MESSAGE_EOS:
+       {
+               // Done
+               GtkImage *img;
+
+               img = GTK_IMAGE(GHB_WIDGET(ud->builder, "live_preview_play_image"));
+               gtk_image_set_from_stock(img, "gtk-media-play", GTK_ICON_SIZE_BUTTON);
+               gst_element_set_state(ud->preview->play, GST_STATE_PAUSED);
+               ud->preview->pause = TRUE;
+               gst_element_seek(ud->preview->play, 1.0,
+                       GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+                       GST_SEEK_TYPE_SET, 0,
+                       GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+       } break;
+
+       default:
+       {
+               // Ignore
+       }
+       }
+       return TRUE;
+}
+
+void
+live_preview_start(signal_user_data_t *ud)
+{
+       GtkImage *img;
+       gchar *uri;
+
+       img = GTK_IMAGE(GHB_WIDGET(ud->builder, "live_preview_play_image"));
+       if (!ud->preview->encoded[ud->preview->frame])
+       {
+               gtk_image_set_from_stock(img, "gtk-media-play", GTK_ICON_SIZE_BUTTON);
+               gst_element_set_state(ud->preview->play, GST_STATE_NULL);
+               ud->preview->pause = TRUE;
+               return;
+       }
+
+       uri = g_strdup_printf("file://%s", ud->preview->current);
+       gtk_image_set_from_stock(img, "gtk-media-pause", GTK_ICON_SIZE_BUTTON);
+       ud->preview->state = PREVIEW_STATE_LIVE;
+       g_object_set(G_OBJECT(ud->preview->play), "uri", uri, NULL);
+       gst_element_set_state(ud->preview->play, GST_STATE_PLAYING);
+       ud->preview->pause = FALSE;
+       g_free(uri);
+}
+
+void
+live_preview_pause(signal_user_data_t *ud)
+{
+       GtkImage *img;
+
+       img = GTK_IMAGE(GHB_WIDGET(ud->builder, "live_preview_play_image"));
+       gtk_image_set_from_stock(img, "gtk-media-play", GTK_ICON_SIZE_BUTTON);
+       gst_element_set_state(ud->preview->play, GST_STATE_PAUSED);
+       ud->preview->pause = TRUE;
+}
+#endif
+
+void
+live_preview_stop(signal_user_data_t *ud)
+{
+       GtkImage *img;
+       GtkRange *progress;
+
+       img = GTK_IMAGE(GHB_WIDGET(ud->builder, "live_preview_play_image"));
+       gtk_image_set_from_stock(img, "gtk-media-play", GTK_ICON_SIZE_BUTTON);
+#if defined(_ENABLE_GST)
+       gst_element_set_state(ud->preview->play, GST_STATE_NULL);
+#endif
+       ud->preview->pause = TRUE;
+       ud->preview->state = PREVIEW_STATE_IMAGE;
+
+       progress = GTK_RANGE(GHB_WIDGET(ud->builder, "live_preview_progress"));
+       gtk_range_set_value(progress, 0);
+}
+
+void
+ghb_live_reset(signal_user_data_t *ud)
+{
+       gboolean encoded;
+
+       if (ud->preview->live_id >= 0)
+       {
+               ghb_stop_live_encode();
+       }
+       ud->preview->live_id = -1;
+       ud->preview->encode_frame = -1;
+       if (!ud->preview->pause)
+               live_preview_stop(ud);
+       if (ud->preview->current)
+       {
+               g_free(ud->preview->current);
+               ud->preview->current = NULL;
+       }
+       encoded = ud->preview->encoded[ud->preview->frame];
+       memset(ud->preview->encoded, 0, sizeof(gboolean) * 10);
+       if (encoded)
+               ghb_set_preview_image(ud);
+}
+
+extern void hb_get_tempory_directory(hb_handle_t *h, char path[512]);
+
+G_MODULE_EXPORT void
+live_preview_start_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       gchar *tmp_dir;
+       gchar *name;
+       gint frame = ud->preview->frame;
+
+       tmp_dir = ghb_get_tmp_dir();
+       name = g_strdup_printf("%s/live%02d", tmp_dir, ud->preview->frame);
+       if (ud->preview->current)
+               g_free(ud->preview->current);
+       ud->preview->current = name;
+
+       if (ud->preview->encoded[frame] &&
+               g_file_test(name, G_FILE_TEST_IS_REGULAR))
+       {
+#if defined(_ENABLE_GST)
+               if (ud->preview->pause)
+                       live_preview_start(ud);
+               else
+                       live_preview_pause(ud);
+#endif
+       }
+       else
+       {
+               GValue *js;
+
+               ud->preview->encode_frame = frame;
+               js = ghb_value_dup(ud->settings);
+               ghb_settings_set_string(js, "destination", name);
+               ghb_settings_set_int(js, "start_frame", ud->preview->frame);
+               ud->preview->live_id = 0;
+               ghb_add_live_job(js, ud->preview->live_id);
+               ghb_start_live_encode();
+               ghb_value_free(js);
+       }
+}
+
+void
+ghb_live_encode_done(signal_user_data_t *ud, gboolean success)
+{
+       GtkWidget *widget;
+       GtkWidget *prog;
+
+       ud->preview->live_id = -1;
+       prog = GHB_WIDGET(ud->builder, "live_encode_progress");
+       if (success && 
+               ud->preview->encode_frame == ud->preview->frame)
+       {
+               gtk_progress_bar_set_text(GTK_PROGRESS_BAR(prog), "Done");
+               gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(prog), 1);
+               ud->preview->encoded[ud->preview->encode_frame] = TRUE;
+#if defined(_ENABLE_GST)
+               live_preview_start(ud);
+#endif
+               widget = GHB_WIDGET(ud->builder, "live_progress_box");
+               gtk_widget_hide (widget);
+               widget = GHB_WIDGET(ud->builder, "live_preview_progress");
+               gtk_widget_show (widget);
+       }
+       else
+       {
+               gtk_progress_bar_set_text(GTK_PROGRESS_BAR(prog), "");
+               gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(prog), 0);
+               ud->preview->encoded[ud->preview->encode_frame] = FALSE;
+       }
+}
+
+#if defined(_ENABLE_GST)
+G_MODULE_EXPORT gboolean
+unlock_progress_cb(signal_user_data_t *ud)
+{
+       ud->preview->progress_lock = FALSE;
+       // This function is initiated by g_idle_add.  Must return false
+       // so that it is not called again
+       return FALSE;
+}
+#endif
+
+void
+ghb_live_preview_progress(signal_user_data_t *ud)
+{
+#if defined(_ENABLE_GST)
+       GstFormat fmt = GST_FORMAT_TIME;
+       gint64 len = -1, pos = -1;
+
+       if (ud->preview->state != PREVIEW_STATE_LIVE || ud->preview->seek_lock)
+               return;
+
+       ud->preview->progress_lock = TRUE;
+       if (gst_element_query_duration(ud->preview->play, &fmt, &len))
+       {
+               if (len != -1 && fmt == GST_FORMAT_TIME)
+               {
+                       ud->preview->len = len / GST_MSECOND;
+               }
+       }
+       if (gst_element_query_position(ud->preview->play, &fmt, &pos))
+       {
+               if (pos != -1 && fmt == GST_FORMAT_TIME)
+               {
+                       ud->preview->pos = pos / GST_MSECOND;
+               }
+       }
+       if (ud->preview->len > 0)
+       {
+               GtkRange *progress;
+               gdouble percent;
+
+               percent = (gdouble)ud->preview->pos * 100 / ud->preview->len;
+               progress = GTK_RANGE(GHB_WIDGET(ud->builder, "live_preview_progress"));
+               gtk_range_set_value(progress, percent);
+       }
+       g_idle_add((GSourceFunc)unlock_progress_cb, ud);
+#endif
+}
+
+#if defined(_ENABLE_GST)
+G_MODULE_EXPORT gboolean
+unlock_seek_cb(signal_user_data_t *ud)
+{
+       ud->preview->seek_lock = FALSE;
+       // This function is initiated by g_idle_add.  Must return false
+       // so that it is not called again
+       return FALSE;
+}
+#endif
+
+G_MODULE_EXPORT void
+live_preview_seek_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+#if defined(_ENABLE_GST)
+       gdouble dval;
+       gint64 pos;
+
+       if (ud->preview->progress_lock)
+               return;
+
+       ud->preview->seek_lock = TRUE;
+       dval = gtk_range_get_value(GTK_RANGE(widget));
+       pos = ((ud->preview->len * dval) / 100) * GST_MSECOND;
+       gst_element_seek(ud->preview->play, 1.0,
+               GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+               GST_SEEK_TYPE_SET, pos,
+               GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+       g_idle_add((GSourceFunc)unlock_seek_cb, ud);
+#endif
+}
+
+void
+ghb_set_preview_image(signal_user_data_t *ud)
+{
+       GtkWidget *widget;
+       gint preview_width, preview_height, target_height, width, height;
+
+       g_debug("set_preview_button_image ()");
+       gint titleindex;
+
+       live_preview_stop(ud);
+
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0) return;
+       widget = GHB_WIDGET (ud->builder, "preview_frame");
+       ud->preview->frame = ghb_widget_int(widget) - 1;
+       if (ud->preview->encoded[ud->preview->frame])
+       {
+               widget = GHB_WIDGET(ud->builder, "live_progress_box");
+               gtk_widget_hide (widget);
+               widget = GHB_WIDGET(ud->builder, "live_preview_progress");
+               gtk_widget_show (widget);
+       }
+       else
+       {
+               widget = GHB_WIDGET(ud->builder, "live_preview_progress");
+               gtk_widget_hide (widget);
+               widget = GHB_WIDGET(ud->builder, "live_progress_box");
+               gtk_widget_show (widget);
+               widget = GHB_WIDGET(ud->builder, "live_encode_progress");
+               gtk_progress_bar_set_text(GTK_PROGRESS_BAR(widget), "");
+               gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(widget), 0);
+       }
+       if (ud->preview->pix != NULL)
+               g_object_unref(ud->preview->pix);
+
+       ud->preview->pix = 
+               ghb_get_preview_image(titleindex, ud->preview->frame, 
+                                                               ud, &width, &height);
+       if (ud->preview->pix == NULL) return;
+       preview_width = gdk_pixbuf_get_width(ud->preview->pix);
+       preview_height = gdk_pixbuf_get_height(ud->preview->pix);
+       widget = GHB_WIDGET (ud->builder, "preview_image");
+       if (preview_width != ud->preview->width || 
+               preview_height != ud->preview->height)
+       {
+               gtk_widget_set_size_request(widget, preview_width, preview_height);
+               ud->preview->width = preview_width;
+               ud->preview->height = preview_height;
+       }
+       gdk_draw_pixbuf(
+               widget->window, NULL, ud->preview->pix, 0, 0, 0, 0,
+               -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
+
+       gchar *text = g_strdup_printf("%d x %d", width, height);
+       widget = GHB_WIDGET (ud->builder, "preview_dims");
+       gtk_label_set_text(GTK_LABEL(widget), text);
+       g_free(text);
+       
+       g_debug("preview %d x %d", preview_width, preview_height);
+       target_height = MIN(ud->preview->button_height, 200);
+       height = target_height;
+       width = preview_width * height / preview_height;
+       if (width > 400)
+       {
+               width = 400;
+               height = preview_height * width / preview_width;
+       }
+
+       if ((height >= 16) && (width >= 16))
+       {
+               GdkPixbuf *scaled_preview;
+               scaled_preview = gdk_pixbuf_scale_simple (ud->preview->pix, width, 
+                                                                                               height, GDK_INTERP_NEAREST);
+               if (scaled_preview != NULL)
+               {
+                       widget = GHB_WIDGET (ud->builder, "preview_button_image");
+                       gtk_image_set_from_pixbuf(GTK_IMAGE(widget), scaled_preview);
+                       g_object_unref (scaled_preview);
+               }
+       }
+}
+
+#if defined(_ENABLE_GST)
+G_MODULE_EXPORT gboolean
+delayed_expose_cb(signal_user_data_t *ud)
+{
+       GstElement *vsink;
+       GstXOverlay *xover;
+
+       g_object_get(ud->preview->play, "video-sink", &vsink, NULL);
+       if (vsink == NULL)
+               return FALSE;
+
+       if (GST_IS_BIN(vsink))
+               xover = GST_X_OVERLAY(gst_bin_get_by_interface(
+                                                               GST_BIN(vsink), GST_TYPE_X_OVERLAY));
+       else
+               xover = GST_X_OVERLAY(vsink);
+       gst_x_overlay_expose(xover);
+       // This function is initiated by g_idle_add.  Must return false
+       // so that it is not called again
+       return FALSE;
+}
+#endif
+
+G_MODULE_EXPORT gboolean
+preview_expose_cb(
+       GtkWidget *widget, 
+       GdkEventExpose *event, 
+       signal_user_data_t *ud)
+{
+#if defined(_ENABLE_GST)
+       if (ud->preview->state == PREVIEW_STATE_LIVE)
+       {
+               if (GST_STATE(ud->preview->play) >= GST_STATE_PAUSED)
+               {
+                       GstElement *vsink;
+                       GstXOverlay *xover;
+
+                       g_object_get(ud->preview->play, "video-sink", &vsink, NULL);
+                       if (GST_IS_BIN(vsink))
+                               xover = GST_X_OVERLAY(gst_bin_get_by_interface(
+                                                                               GST_BIN(vsink), GST_TYPE_X_OVERLAY));
+                       else
+                               xover = GST_X_OVERLAY(vsink);
+                       gst_x_overlay_expose(xover);
+                       // For some reason, the exposed region doesn't always get
+                       // cleaned up here. But a delayed gst_x_overlay_expose()
+                       // takes care of it.
+                       g_idle_add((GSourceFunc)delayed_expose_cb, ud);
+                       return FALSE;
+               }
+               return TRUE;
+       }
+#endif
+
+       if (ud->preview->pix != NULL)
+       {
+               gdk_draw_pixbuf(
+                       widget->window, NULL, ud->preview->pix, 0, 0, 0, 0,
+                       -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
+       }
+       return TRUE;
+}
+
+G_MODULE_EXPORT void
+preview_button_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, signal_user_data_t *ud)
+{
+       g_debug("allocate %d x %d", allocation->width, allocation->height);
+       if (ud->preview->button_width == allocation->width &&
+               ud->preview->button_height == allocation->height)
+       {
+               // Nothing to do. Bug out.
+               g_debug("nothing to do");
+               return;
+       }
+       g_debug("prev allocate %d x %d", ud->preview->button_width, 
+                       ud->preview->button_height);
+       ud->preview->button_width = allocation->width;
+       ud->preview->button_height = allocation->height;
+       ghb_set_preview_image(ud);
+}
+
+static void
+set_visible(GtkWidget *widget, gboolean visible)
+{
+       if (visible)
+       {
+               gtk_widget_show_now(widget);
+       }
+       else
+       {
+               gtk_widget_hide(widget);
+       }
+}
+
+void
+ghb_preview_set_visible(signal_user_data_t *ud)
+{
+       gint titleindex;
+       GtkWidget *widget;
+       gboolean settings_active;
+
+       settings_active = ghb_settings_get_boolean(ud->settings, "show_picture");
+       widget = GHB_WIDGET (ud->builder, "preview_window");
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (settings_active && titleindex >= 0)
+       {
+               gint x, y;
+               x = ghb_settings_get_int(ud->settings, "preview_x");
+               y = ghb_settings_get_int(ud->settings, "preview_y");
+               if (x >= 0 && y >= 0)
+                       gtk_window_move(GTK_WINDOW(widget), x, y);
+               set_visible(widget, 
+                                       ghb_settings_get_boolean(ud->settings, "show_preview"));
+       }
+       else
+       {
+               set_visible(widget, FALSE);
+       }
+}
+
+G_MODULE_EXPORT void
+preview_button_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       g_debug("preview_button_clicked_cb()");
+       ghb_widget_to_setting (ud->settings, xwidget);
+       ghb_preview_set_visible(ud);
+       ghb_check_dependency(ud, xwidget, NULL);
+       const gchar *name = gtk_widget_get_name(xwidget);
+       ghb_pref_save(ud->settings, name);
+}
+
+G_MODULE_EXPORT void
+picture_settings_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *widget;
+       gboolean active, hide_settings;
+       gint x, y;
+
+       g_debug("picture_settings_clicked_cb()");
+       ghb_widget_to_setting (ud->settings, xwidget);
+
+       hide_settings = ghb_settings_get_boolean(ud->settings, "hide_settings");
+
+       active = ghb_settings_get_boolean(ud->settings, "show_picture");
+       widget = GHB_WIDGET (ud->builder, "settings_window");
+       x = ghb_settings_get_int(ud->settings, "settings_x");
+       y = ghb_settings_get_int(ud->settings, "settings_y");
+       if (x >= 0 && y >= 0)
+               gtk_window_move(GTK_WINDOW(widget), x, y);
+       set_visible(widget, active && !hide_settings);
+       ghb_preview_set_visible(ud);
+}
+
+G_MODULE_EXPORT void
+picture_settings_alt_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *toggle;
+       gboolean active;
+
+       g_debug("picture_settings_alt_clicked_cb()");
+       toggle = GHB_WIDGET (ud->builder, "show_picture");
+       active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toggle));
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(toggle), !active);
+}
+
+static gboolean
+go_full(signal_user_data_t *ud)
+{
+       GtkWindow *window;
+       window = GTK_WINDOW(GHB_WIDGET (ud->builder, "preview_window"));
+       gtk_window_fullscreen(window);
+       ghb_set_preview_image(ud);
+       return FALSE;
+}
+
+G_MODULE_EXPORT void
+fullscreen_clicked_cb(GtkWidget *toggle, signal_user_data_t *ud)
+{
+       gboolean active;
+       GtkWindow *window;
+
+       g_debug("fullscreen_clicked_cb()");
+       ghb_widget_to_setting (ud->settings, toggle);
+       ghb_check_dependency(ud, toggle, NULL);
+       const gchar *name = gtk_widget_get_name(toggle);
+       ghb_pref_save(ud->settings, name);
+
+       window = GTK_WINDOW(GHB_WIDGET (ud->builder, "preview_window"));
+       active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle));
+       if (active)
+       {
+               gtk_window_set_resizable(window, TRUE);
+               gtk_button_set_label(GTK_BUTTON(toggle), "Windowed");
+               // Changing resizable property doesn't take effect immediately
+               // need to delay fullscreen till after this callback returns
+               // to mainloop
+               g_idle_add((GSourceFunc)go_full, ud);
+       }
+       else
+       {
+               gtk_window_unfullscreen(window);
+               gtk_window_set_resizable(window, FALSE);
+               gtk_button_set_label(GTK_BUTTON(toggle), "Fullscreen");
+               ghb_set_preview_image(ud);
+       }
+}
+
+G_MODULE_EXPORT void
+picture_settings_alt2_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       GtkWidget *toggle;
+       gboolean active;
+       GtkWidget *window;
+
+       g_debug("picture_settings_alt2_clicked_cb()");
+       ghb_widget_to_setting (ud->settings, xwidget);
+       active = ghb_settings_get_boolean(ud->settings, "hide_settings");
+
+       toggle = GHB_WIDGET (ud->builder, "hide_settings");
+       window = GHB_WIDGET(ud->builder, "settings_window");
+       if (!active)
+       {
+               gtk_button_set_label(GTK_BUTTON(toggle), "Hide Settings");
+               gtk_widget_set_tooltip_text(toggle, 
+                       "Hide the picture settings window while "
+                       "leaving the preview visible.");
+               gtk_widget_show(window);
+       }
+       else
+       {
+               gtk_button_set_label(GTK_BUTTON(toggle), "Show Settings");
+               gtk_widget_set_tooltip_text(toggle, "Show picture settings.");
+               gtk_widget_hide(window);
+       }
+}
+
+G_MODULE_EXPORT void
+preview_frame_value_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       if (ud->preview->live_id >= 0)
+       {
+               ghb_stop_live_encode();
+               ud->preview->live_id = -1;
+               ud->preview->encode_frame = -1;
+       }
+       ghb_set_preview_image(ud);
+}
+
+G_MODULE_EXPORT gboolean
+preview_window_delete_cb(
+       GtkWidget *widget, 
+       GdkEvent *event, 
+       signal_user_data_t *ud)
+{
+       live_preview_stop(ud);
+       widget = GHB_WIDGET (ud->builder, "show_picture");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), FALSE);
+       return TRUE;
+}
+
+G_MODULE_EXPORT gboolean
+settings_window_delete_cb(
+       GtkWidget *widget, 
+       GdkEvent *event, 
+       signal_user_data_t *ud)
+{
+       live_preview_stop(ud);
+       widget = GHB_WIDGET (ud->builder, "show_picture");
+       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), FALSE);
+
+       return TRUE;
+}
+
+G_MODULE_EXPORT void
+preview_duration_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       g_debug("preview_duration_changed_cb ()");
+       ghb_live_reset(ud);
+       ghb_widget_to_setting (ud->settings, widget);
+       ghb_check_dependency(ud, widget, NULL);
+       const gchar *name = gtk_widget_get_name(widget);
+       ghb_pref_save(ud->settings, name);
+}
+
+static guint hud_timeout_id = 0;
+
+static gboolean
+hud_timeout(signal_user_data_t *ud)
+{
+       GtkWidget *widget;
+
+       g_debug("hud_timeout()");
+       widget = GHB_WIDGET(ud->builder, "preview_hud");
+       gtk_widget_hide(widget);
+       hud_timeout_id = 0;
+       return FALSE;
+}
+
+G_MODULE_EXPORT gboolean
+hud_enter_cb(
+       GtkWidget *widget,
+       GdkEventCrossing *event,
+       signal_user_data_t *ud)
+{
+       g_debug("hud_enter_cb()");
+       if (hud_timeout_id != 0)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, hud_timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+       widget = GHB_WIDGET(ud->builder, "preview_hud");
+       gtk_widget_show(widget);
+       hud_timeout_id = 0;
+       return FALSE;
+}
+
+G_MODULE_EXPORT gboolean
+preview_leave_cb(
+       GtkWidget *widget,
+       GdkEventCrossing *event,
+       signal_user_data_t *ud)
+{
+       g_debug("hud_leave_cb()");
+       if (hud_timeout_id != 0)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, hud_timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+       hud_timeout_id = g_timeout_add(300, (GSourceFunc)hud_timeout, ud);
+       return FALSE;
+}
+
+G_MODULE_EXPORT gboolean
+preview_motion_cb(
+       GtkWidget *widget,
+       GdkEventMotion *event,
+       signal_user_data_t *ud)
+{
+       //g_debug("hud_motion_cb %d", hud_timeout_id);
+       if (hud_timeout_id != 0)
+       {
+               GMainContext *mc;
+               GSource *source;
+
+               mc = g_main_context_default();
+               source = g_main_context_find_source_by_id(mc, hud_timeout_id);
+               if (source != NULL)
+                       g_source_destroy(source);
+       }
+       widget = GHB_WIDGET(ud->builder, "preview_hud");
+       if (!GTK_WIDGET_VISIBLE(widget))
+       {
+               gtk_widget_show(widget);
+       }
+       hud_timeout_id = g_timeout_add_seconds(4, (GSourceFunc)hud_timeout, ud);
+       return FALSE;
+}
+
+GdkDrawable*
+ghb_curved_rect_mask(gint width, gint height, gint radius)
+{
+       GdkDrawable *shape;
+       cairo_t *cr;
+       double w, h;
+
+       if (!width || !height)
+               return NULL;
+
+       shape = (GdkDrawable *)gdk_pixmap_new (NULL, width, height, 1);
+
+       cr = gdk_cairo_create (shape);
+
+       w = width;
+       h = height;
+       if (radius > width / 2)
+               radius = width / 2;
+       if (radius > height / 2)
+               radius = height / 2;
+
+       // fill shape with black
+       cairo_save(cr);
+       cairo_rectangle (cr, 0, 0, width, height);
+       cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+       cairo_fill (cr);
+       cairo_restore (cr);
+
+       cairo_move_to  (cr, 0, radius);
+       cairo_curve_to (cr, 0 , 0, 0 , 0, radius, 0);
+       cairo_line_to (cr, w - radius, 0);
+       cairo_curve_to (cr, w, 0, w, 0, w, radius);
+       cairo_line_to (cr, w , h - radius);
+       cairo_curve_to (cr, w, h, w, h, w - radius, h);
+       cairo_line_to (cr, 0 + radius, h);
+       cairo_curve_to (cr, 0, h, 0, h, 0, h - radius);
+
+       cairo_close_path(cr);
+
+       cairo_set_source_rgb(cr, 1, 1, 1);
+       cairo_fill(cr);
+
+       cairo_destroy(cr);
+
+       return shape;
+}
+
+G_MODULE_EXPORT void
+preview_hud_size_alloc_cb(
+       GtkWidget *widget,
+       GtkAllocation *allocation,
+       signal_user_data_t *ud)
+{
+       GdkDrawable *shape;
+
+       //g_message("preview_hud_size_alloc_cb()");
+       if (GTK_WIDGET_VISIBLE(widget) && allocation->height > 50)
+       {
+               shape = ghb_curved_rect_mask(allocation->width, 
+                                                                       allocation->height, allocation->height/4);
+               if (shape != NULL)
+               {
+                       gtk_widget_shape_combine_mask(widget, shape, 0, 0);
+                       gdk_pixmap_unref(shape);
+               }
+       }
+}
+
+G_MODULE_EXPORT gboolean
+preview_configure_cb(
+       GtkWidget *widget,
+       GdkEventConfigure *event,
+       signal_user_data_t *ud)
+{
+       gint x, y;
+
+       //g_message("preview_configure_cb()");
+       if (GTK_WIDGET_VISIBLE(widget))
+       {
+               gtk_window_get_position(GTK_WINDOW(widget), &x, &y);
+               ghb_settings_set_int(ud->settings, "preview_x", x);
+               ghb_settings_set_int(ud->settings, "preview_y", y);
+               ghb_pref_set(ud->settings, "preview_x");
+               ghb_pref_set(ud->settings, "preview_y");
+               ghb_prefs_store();
+       }
+       return FALSE;
+}
+
+G_MODULE_EXPORT gboolean
+settings_configure_cb(
+       GtkWidget *widget,
+       GdkEventConfigure *event,
+       signal_user_data_t *ud)
+{
+       gint x, y;
+
+       //g_message("settings_configure_cb()");
+       if (GTK_WIDGET_VISIBLE(widget))
+       {
+               gtk_window_get_position(GTK_WINDOW(widget), &x, &y);
+               ghb_settings_set_int(ud->settings, "settings_x", x);
+               ghb_settings_set_int(ud->settings, "settings_y", y);
+               ghb_pref_set(ud->settings, "settings_x");
+               ghb_pref_set(ud->settings, "settings_y");
+               ghb_prefs_store();
+       }
+       return FALSE;
+}
+
diff --git a/gtk/src/preview.h b/gtk/src/preview.h
new file mode 100644 (file)
index 0000000..f89e4f3
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+#if !defined(_GHB_PREVIEW_H_)
+#define _GHB_PREVIEW_H_
+
+#define MOD_ROUND(v,m) ((m==1)?v:(m * ((v + (m>>1) - 1) / m)))
+#define MOD_DOWN(v,m)  (m * (v / m))
+#define MOD_UP(v,m)    (m * ((v + m - 1) / m))
+
+void ghb_preview_init(signal_user_data_t *ud);
+void ghb_set_preview_image(signal_user_data_t *ud);
+void ghb_live_preview_progress(signal_user_data_t *ud);
+void ghb_live_encode_done(signal_user_data_t *ud, gboolean success);
+void ghb_preview_cleanup(signal_user_data_t *ud);
+void ghb_live_reset(signal_user_data_t *ud);
+void ghb_par_scale(signal_user_data_t *ud, gint *width, gint *height, gint par_n, gint par_d);
+void ghb_preview_set_visible(signal_user_data_t *ud);
+
+#endif // _GHB_PREVIEW_H_
index f8687b7..4ba0957 100644 (file)
@@ -23,7 +23,7 @@
 #include "presets.h"
 #include "ghb-dvd.h"
 
-void
+G_MODULE_EXPORT void
 queue_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
 {
        GtkTreeModel *store;
@@ -72,8 +72,10 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        gchar *fps, *vcodec_abbr;
        gint title, start_chapter, end_chapter, width, height;
        gint source_width, source_height;
-       gboolean pass2, anamorphic, round_dim, keep_aspect, vqtype, turbo;
+       gboolean pass2 = FALSE, keep_aspect, vqtype, turbo;
+       gint pic_par;
        gboolean tweaks;
+       gchar *escape;
        
        g_debug("update_queue_list ()");
        if (settings == NULL) return;
@@ -81,21 +83,27 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
                
        tweaks = ghb_settings_get_boolean(settings, "allow_tweaks");
-       title = ghb_settings_combo_int(settings, "title");
+       title = ghb_settings_get_int(settings, "titlenum");
        start_chapter = ghb_settings_get_int(settings, "start_chapter");
        end_chapter = ghb_settings_get_int(settings, "end_chapter");
-       pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass");
        vol_name = ghb_settings_get_string(settings, "volume_label");
        dest = ghb_settings_get_string(settings, "destination");
        basename = g_path_get_basename(dest);
+       escape = g_markup_escape_text(basename, -1);
+
+       vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
+       if (!vqtype)
+               pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass");
        info = g_strdup_printf 
        (
                "<big><b>%s</b></big> "
                "<small>(Title %d, Chapters %d through %d, %d Video %s)"
                " --> %s</small>",
-                vol_name, title+1, start_chapter, end_chapter, 
-                pass2 ? 2:1, pass2 ? "Passes":"Pass", basename
+                vol_name, title, start_chapter, end_chapter, 
+                pass2 ? 2:1, pass2 ? "Passes":"Pass", escape
        );
+       g_free(basename);
+       g_free(escape);
 
        if (piter)
                iter = *piter;
@@ -176,28 +184,19 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                        g_string_append_printf(str, "</small>\n");
                }
        }
+       escape = g_markup_escape_text(dest, -1);
        g_string_append_printf(str, 
-               "<b>Destination:</b> <small>%s</small>\n", dest);
+               "<b>Destination:</b> <small>%s</small>\n", escape);
 
        width = ghb_settings_get_int(settings, "scale_width");
        height = ghb_settings_get_int(settings, "scale_height");
-       anamorphic = ghb_settings_get_boolean(settings, "anamorphic");
-       round_dim = ghb_settings_get_boolean(settings, "ModDimensions");
+       pic_par = ghb_settings_combo_int(settings, "PicturePAR");
        keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio");
 
        gchar *aspect_desc;
-       if (anamorphic)
+       switch (pic_par)
        {
-               if (round_dim)
-               {
-                       aspect_desc = "(Anamorphic)";
-               }
-               else
-               {
-                       aspect_desc = "(Strict Anamorphic)";
-               }
-       }
-       else
+       case 0:
        {
                if (keep_aspect)
                {
@@ -207,6 +206,27 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                {
                        aspect_desc = "(Aspect Lost)";
                }
+       } break;
+
+       case 1:
+       {
+               aspect_desc = "(Strict Anamorphic)";
+       } break;
+
+       case 2:
+       {
+               aspect_desc = "(Loose Anamorphic)";
+       } break;
+
+       case 3:
+       {
+               aspect_desc = "(Custom Anamorphic)";
+       } break;
+
+       default:
+       {
+               aspect_desc = "(Unknown)";
+       } break;
        }
        vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
 
@@ -238,22 +258,14 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                // Constant quality
                vqvalue = ghb_settings_get_double(settings, "VideoQualitySlider");
                vq_desc = "Constant Quality:";
-               if (ghb_settings_get_boolean(settings, "directqp"))
-               {
-                       vqstr = g_strdup_printf("%d", (gint)vqvalue);
-                       vq_units = "(crf)";
-               }
-               else
-               {
-                       vqstr = g_strdup_printf("%.1f", 100*vqvalue);
-                       vq_units = "%";
-               }
+               vqstr = g_strdup_printf("%d", (gint)vqvalue);
+               vq_units = "(RF)";
        }
        fps = ghb_settings_get_string(settings, "VideoFramerate");
        if (strcmp("source", fps) == 0)
        {
                g_free(fps);
-               if (ghb_settings_get_boolean(settings, "PictureDetelecine"))
+               if (ghb_settings_combo_int(settings, "PictureDetelecine"))
                        fps = g_strdup("Same As Source (vfr detelecine)");
                else
                        fps = g_strdup("Same As Source (variable)");
@@ -273,40 +285,75 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                "<b>Picture:</b> Source: <small>%d x %d, Output %d x %d %s</small>\n",
                 source_width, source_height, width, height, aspect_desc);
 
-       gboolean decomb;
+       gint decomb, detel;
+       gboolean decomb_deint;
        gboolean filters = FALSE;
 
-       decomb = ghb_settings_get_boolean(settings, "PictureDecomb");
+       decomb_deint = ghb_settings_get_boolean(settings, "PictureDecombDeinterlace");
+       decomb = ghb_settings_combo_int(settings, "PictureDecomb");
        g_string_append_printf(str, "<b>Filters:</b><small>");
-       if (ghb_settings_get_boolean(settings, "PictureDetelecine"))
+       detel = ghb_settings_combo_int(settings, "PictureDetelecine");
+       if (detel)
        {
                g_string_append_printf(str, " - Detelecine");
+               if (detel == 1)
+               {
+                       gchar *cust;
+                       cust = ghb_settings_get_string(settings, "PictureDetelecineCustom");
+                       g_string_append_printf(str, ": %s", cust);
+                       g_free(cust);
+               }
                filters = TRUE;
        }
-       if (decomb)
+       if (decomb_deint && decomb)
        {
                g_string_append_printf(str, " - Decomb");
+               if (decomb == 1)
+               {
+                       gchar *cust;
+                       cust = ghb_settings_get_string(settings, "PictureDecombCustom");
+                       g_string_append_printf(str, ": %s", cust);
+                       g_free(cust);
+               }
                filters = TRUE;
        }
-       else
+       else if (!decomb_deint)
        {
-               gint deint = ghb_settings_combo_int(settings, 
-                                       tweaks ? "tweak_PictureDeinterlace":"PictureDeinterlace");
+               gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
                if (deint)
                {
-                       const gchar *opt = ghb_settings_combo_option(settings,
-                                       tweaks ? "tweak_PictureDeinterlace":"PictureDeinterlace");
-                       g_string_append_printf(str, " - Deinterlace: %s", opt);
+                       if (deint == 1)
+                       {
+                               gchar *cust = ghb_settings_get_string(settings,
+                                                                                               "PictureDeinterlaceCustom");
+                               g_string_append_printf(str, " - Deinterlace: %s", cust);
+                               g_free(cust);
+                       }
+                       else
+                       {
+                               const gchar *opt = ghb_settings_combo_option(settings,
+                                                                                                       "PictureDeinterlace");
+                               g_string_append_printf(str, " - Deinterlace: %s", opt);
+                       }
                        filters = TRUE;
                }
        }
-       gint denoise = ghb_settings_combo_int(settings, 
-                               tweaks ? "tweak_PictureDenoise":"PictureDenoise");
+       gint denoise = ghb_settings_combo_int(settings, "PictureDenoise");
        if (denoise)
        {
-               const gchar *opt = ghb_settings_combo_option(settings,
-                               tweaks ? "tweak_PictureDenoise":"PictureDenoise");
-               g_string_append_printf(str, " - Denoise: %s", opt);
+               if (denoise == 1)
+               {
+                       gchar *cust = ghb_settings_get_string(settings,
+                                                                                                       "PictureDenoiseCustom");
+                       g_string_append_printf(str, " - Denoise: %s", cust);
+                       g_free(cust);
+               }
+               else
+               {
+                       const gchar *opt = ghb_settings_combo_option(settings,
+                                                                                                       "PictureDenoise");
+                       g_string_append_printf(str, " - Denoise: %s", opt);
+               }
                filters = TRUE;
        }
        gint deblock = ghb_settings_get_int(settings, "PictureDeblock");
@@ -364,15 +411,79 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                }
                track = ghb_settings_get_string(asettings, "AudioTrackDescription");
                mix = ghb_settings_combo_option(asettings, "AudioMixdown");
+               if (count == 1)
+                       g_string_append_printf(str, "<b>Audio:</b>");
+               else if (ii == 0)
+                       g_string_append_printf(str, "<b>Audio:</b>\n");
+               if (count != 1)
+                       g_string_append_printf(str, "\t");
+
                g_string_append_printf(str,
-                       "<b>Audio:</b><small> %s, Encoder: %s, Mixdown: %s, SampleRate: %s, Bitrate: %s</small>",
+                       "<small> %s, Encoder: %s, Mixdown: %s, SampleRate: %s, Bitrate: %s</small>\n",
                         track, acodec, mix, samplerate, bitrate);
-               if (ii < count-1)
-                       g_string_append_printf(str, "\n");
                g_free(track);
                g_free(bitrate);
                g_free(samplerate);
        }
+
+       // Add the audios
+       const GValue *sub_list;
+
+       sub_list = ghb_settings_get_value(settings, "subtitle_list");
+       count = ghb_array_len(sub_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               GValue *settings;
+               gchar *track;
+               gboolean force, burn, def;
+               gint source;
+
+               settings = ghb_array_get_nth(sub_list, ii);
+               track = ghb_settings_get_string(settings, "SubtitleTrackDescription");
+               source = ghb_settings_get_int(settings, "SubtitleSource");
+               force = ghb_settings_get_boolean(settings, "SubtitleForced");
+               burn = ghb_settings_get_boolean(settings, "SubtitleBurned");
+               def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+               if (count == 1)
+                       g_string_append_printf(str, "<b>Subtitle:</b>");
+               else if (ii == 0)
+                       g_string_append_printf(str, "<b>Subtitles:</b>\n");
+               if (count != 1)
+                       g_string_append_printf(str, "\t");
+
+               if (source != SRTSUB)
+               {
+                       g_string_append_printf(str,
+                               "<small> %s%s%s%s</small>",
+                               track, 
+                               force ? " (Force)":"",
+                               burn  ? " (Burn)":"",
+                               def   ? " (Default)":""
+                       );
+               }
+               else
+               {
+                       gint offset;
+                       gchar *filename, *basename, *code;
+
+                       offset = ghb_settings_get_int(settings, "SrtOffset");
+                       filename = ghb_settings_get_string(settings, "SrtFile");
+                       basename = g_path_get_basename(filename);
+                       code = ghb_settings_get_string(settings, "SrtCodeset");
+                       g_string_append_printf(str,
+                               "<small> %s (%s), %s, Offset (ms) %d%s</small>",
+                               track, code, basename, offset,
+                               def   ? " (Default)":""
+                       );
+                       g_free(filename);
+                       g_free(basename);
+                       g_free(code);
+               }
+               if (ii < count-1)
+                       g_string_append_printf(str, "\n");
+               g_free(track);
+       }
+
        info = g_string_free(str, FALSE);
        gtk_tree_store_append(store, &citer, &iter);
        gtk_tree_store_set(store, &citer, 1, info, -1);
@@ -392,7 +503,7 @@ audio_list_refresh(signal_user_data_t *ud)
        GtkListStore *store;
        gboolean done;
        gint row = 0;
-       GValue *audio_list;
+       const GValue *audio_list;
 
        g_debug("ghb_audio_list_refresh ()");
        treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
@@ -403,6 +514,7 @@ audio_list_refresh(signal_user_data_t *ud)
                {
                        const gchar *track, *codec, *br, *sr, *mix;
                        gchar *drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+                       gint itrack, icodec;
                        gdouble s_drc;
                        GValue *asettings;
 
@@ -412,11 +524,12 @@ audio_list_refresh(signal_user_data_t *ud)
                        asettings = ghb_array_get_nth(audio_list, row);
 
                        track = ghb_settings_combo_option(asettings, "AudioTrack");
+                       itrack = ghb_settings_combo_int(asettings, "AudioTrack");
                        codec = ghb_settings_combo_option(asettings, "AudioEncoder");
+                       icodec = ghb_settings_combo_int(asettings, "AudioEncoder");
                        br = ghb_settings_combo_option(asettings, "AudioBitrate");
                        sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
                        mix = ghb_settings_combo_option(asettings, "AudioMixdown");
-                       drc = ghb_settings_get_string(asettings, "AudioTrackDRCSlider");
 
                        s_track = ghb_settings_get_string(asettings, "AudioTrack");
                        s_codec = ghb_settings_get_string(asettings, "AudioEncoder");
@@ -424,6 +537,13 @@ audio_list_refresh(signal_user_data_t *ud)
                        s_sr = ghb_settings_get_string(asettings, "AudioSamplerate");
                        s_mix = ghb_settings_get_string(asettings, "AudioMixdown");
                        s_drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
+                       if (s_drc < 1.0)
+                               drc = g_strdup("Off");
+                       else
+                               drc = g_strdup_printf("%.1f", s_drc);
+
+                       if (icodec == HB_ACODEC_MASK)
+                               codec = ghb_select_audio_codec_str(ud, itrack);
 
                        gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
                                // These are displayed in list
@@ -432,8 +552,8 @@ audio_list_refresh(signal_user_data_t *ud)
                                2, br,
                                3, sr,
                                4, mix,
-                               // These are used to set combo values when an item is selected
                                5, drc,
+                               // These are used to set combo values when an item is selected
                                6, s_track,
                                7, s_codec,
                                8, s_br,
@@ -505,6 +625,8 @@ validate_settings(signal_user_data_t *ud)
                g_free(destdir);
                return FALSE;
        }
+#if !defined(_WIN32)
+       // This doesn't work properly on windows
        if (g_access(destdir, R_OK|W_OK) != 0)
        {
                message = g_strdup_printf(
@@ -517,6 +639,7 @@ validate_settings(signal_user_data_t *ud)
                g_free(destdir);
                return FALSE;
        }
+#endif
        GFile *gfile;
        GFileInfo *info;
        guint64 size;
@@ -557,7 +680,7 @@ validate_settings(signal_user_data_t *ud)
        {
                message = g_strdup_printf(
                                        "Destination: %s\n\n"
-                                       "File already exhists.\n"
+                                       "File already exists.\n"
                                        "Do you want to overwrite?",
                                        dest);
                if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Overwrite"))
@@ -580,6 +703,11 @@ validate_settings(signal_user_data_t *ud)
        {
                return FALSE;
        }
+       // Validate audio settings
+       if (!ghb_validate_subtitles(ud))
+       {
+               return FALSE;
+       }
        // Validate video settings
        if (!ghb_validate_video(ud))
        {
@@ -607,6 +735,7 @@ queue_add(signal_user_data_t *ud)
        {
                return FALSE;
        }
+
        if (ud->queue == NULL)
                ud->queue = ghb_array_value_new(32);
        // Make a copy of current settings to be used for the new job
@@ -619,18 +748,19 @@ queue_add(signal_user_data_t *ud)
        ghb_array_append(ud->queue, settings);
        add_to_queue_list(ud, settings, NULL);
        ghb_save_queue(ud->queue);
+       ghb_update_pending(ud);
 
        return TRUE;
 }
 
-void
+G_MODULE_EXPORT void
 queue_add_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("queue_add_clicked_cb ()");
        queue_add(ud);
 }
 
-void
+G_MODULE_EXPORT void
 queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
@@ -664,7 +794,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
                if (status == GHB_QUEUE_RUNNING)
                {
                        // Ask if wants to stop encode.
-                       if (!ghb_cancel_encode(NULL))
+                       if (!ghb_cancel_encode2(ud, NULL))
                        {
                                return;
                        }
@@ -683,6 +813,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
        {       
                gtk_tree_path_free (treepath);
        }
+       ghb_update_pending(ud);
 }
 
 static gint
@@ -710,7 +841,7 @@ find_last_finished(GValue *queue)
 // handler from expanding rows if you hover over them while
 // dragging.
 // Also controls where valid drop locations are
-gboolean
+G_MODULE_EXPORT gboolean
 queue_drag_motion_cb(
        GtkTreeView *tv,
        GdkDragContext *ctx,
@@ -727,6 +858,11 @@ queue_drag_motion_cb(
        GtkTreeView *srctv;
        GtkTreeModel *model;
        GtkTreeSelection *select;
+       GtkWidget *widget;
+
+       widget = gtk_drag_get_source_widget(ctx);
+       if (widget == NULL || widget != GTK_WIDGET(tv))
+               return TRUE;
 
        // This bit checks to see if the source is allowed to be
        // moved.  Only pending and canceled items may be moved.
@@ -788,7 +924,7 @@ queue_drag_motion_cb(
        return TRUE;
 }
 
-void 
+G_MODULE_EXPORT void 
 queue_drag_cb(
        GtkTreeView *dstwidget, 
        GdkDragContext *dc, 
@@ -892,37 +1028,159 @@ queue_drag_cb(
 }
 
 void
-ghb_queue_buttons_grey(signal_user_data_t *ud, gboolean working)
+ghb_queue_buttons_grey(signal_user_data_t *ud)
 {
        GtkWidget *widget;
        GtkAction *action;
        gint queue_count;
        gint titleindex;
-       gboolean title_ok;
+       gint queue_state, scan_state;
+       gboolean show_start, show_stop, paused;
 
        queue_count = ghb_array_len(ud->queue);
        titleindex = ghb_settings_combo_int(ud->settings, "title");
-       title_ok = (titleindex >= 0);
+
+       queue_state = ghb_get_queue_state();
+       scan_state = ghb_get_scan_state();
+
+       show_stop = queue_state & 
+                               (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING);
+       show_start = !(scan_state & GHB_STATE_SCANNING) && 
+                                       (titleindex >= 0 || queue_count > 0);
+
+
+       paused = queue_state & GHB_STATE_PAUSED;
 
        widget = GHB_WIDGET (ud->builder, "queue_start1");
-       gtk_widget_set_sensitive (widget, !working && (title_ok || queue_count));
+       if (show_stop)
+       {
+               gtk_widget_set_sensitive (widget, TRUE);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding");
+       }
+       else
+       {
+               gtk_widget_set_sensitive (widget, show_start);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding");
+       }
        widget = GHB_WIDGET (ud->builder, "queue_start2");
-       gtk_widget_set_sensitive (widget, !working && (title_ok || queue_count));
-       action = GHB_ACTION (ud->builder, "queue_start_menu");
-       gtk_action_set_sensitive (action, !working && (title_ok || queue_count));
+       if (show_stop)
+       {
+               gtk_widget_set_sensitive (widget, TRUE);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Encoding");
+       }
+       else
+       {
+               gtk_widget_set_sensitive (widget, show_start);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Start Encoding");
+       }
        widget = GHB_WIDGET (ud->builder, "queue_pause1");
-       gtk_widget_set_sensitive (widget, working);
+       if (paused)
+       {
+               gtk_widget_set_sensitive (widget, show_stop);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding");
+       }
+       else
+       {
+               gtk_widget_set_sensitive (widget, show_stop);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding");
+       }
        widget = GHB_WIDGET (ud->builder, "queue_pause2");
-       gtk_widget_set_sensitive (widget, working);
+       if (paused)
+       {
+               gtk_widget_set_sensitive (widget, show_stop);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Resume Encoding");
+       }
+       else
+       {
+               gtk_widget_set_sensitive (widget, show_stop);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause");
+               gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Pause Encoding");
+       }
+
+       action = GHB_ACTION (ud->builder, "queue_start_menu");
+       if (show_stop)
+       {
+               gtk_action_set_sensitive (action, TRUE);
+#if GTK_CHECK_VERSION(2, 16, 0)
+               gtk_action_set_icon_name(action, "hb-stop");
+               gtk_action_set_label(action, "S_top Queue");
+               gtk_action_set_tooltip(action, "Stop Encoding");
+#else
+               g_object_set_property(G_OBJECT(action), "icon-name", 
+                                                                                       ghb_string_value("hb-stop"));
+               g_object_set_property(G_OBJECT(action), "label",
+                                                                                       ghb_string_value("S_top Queue"));
+               g_object_set_property(G_OBJECT(action), "tooltip",
+                                                                                       ghb_string_value("Stop Encoding"));
+#endif
+       }
+       else
+       {
+               gtk_action_set_sensitive (action, show_start);
+#if GTK_CHECK_VERSION(2, 16, 0)
+               gtk_action_set_icon_name(action, "hb-play");
+               gtk_action_set_label(action, "_Start Queue");
+               gtk_action_set_tooltip(action, "Start Encoding");
+#else
+               g_object_set_property(G_OBJECT(action), "icon-name", 
+                                                                                       ghb_string_value("hb-play"));
+               g_object_set_property(G_OBJECT(action), "label",
+                                                                                       ghb_string_value("_Start Queue"));
+               g_object_set_property(G_OBJECT(action), "tooltip",
+                                                                                       ghb_string_value("Start Encoding"));
+#endif
+       }
        action = GHB_ACTION (ud->builder, "queue_pause_menu");
-       gtk_action_set_sensitive (action, working);
-       widget = GHB_WIDGET (ud->builder, "queue_stop");
-       gtk_widget_set_sensitive (widget, working);
-       action = GHB_ACTION (ud->builder, "queue_stop_menu");
-       gtk_action_set_sensitive (action, working);
+       if (paused)
+       {
+               gtk_action_set_sensitive (action, show_start);
+#if GTK_CHECK_VERSION(2, 16, 0)
+               gtk_action_set_icon_name(action, "hb-play");
+               gtk_action_set_label(action, "_Resume Queue");
+               gtk_action_set_tooltip(action, "Resume Encoding");
+#else
+               g_object_set_property(G_OBJECT(action), "icon-name", 
+                                                                               ghb_string_value("hb-play"));
+               g_object_set_property(G_OBJECT(action), "label",
+                                                                               ghb_string_value("_Resume Queue"));
+               g_object_set_property(G_OBJECT(action), "tooltip",
+                                                                               ghb_string_value("Resume Encoding"));
+#endif
+       }
+       else
+       {
+               gtk_action_set_sensitive (action, show_stop);
+#if GTK_CHECK_VERSION(2, 16, 0)
+               gtk_action_set_icon_name(action, "hb-pause");
+               gtk_action_set_label(action, "_Pause Queue");
+               gtk_action_set_tooltip(action, "Pause Encoding");
+#else
+               g_object_set_property(G_OBJECT(action), "icon-name", 
+                                                                               ghb_string_value("hb-pause"));
+               g_object_set_property(G_OBJECT(action), "label",
+                                                                               ghb_string_value("_Pause Queue"));
+               g_object_set_property(G_OBJECT(action), "tooltip",
+                                                                               ghb_string_value("Pause Encoding"));
+#endif
+       }
 }
 
-void
+G_MODULE_EXPORT void
 queue_list_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, GtkCellRenderer *cell)
 {
        GtkTreeViewColumn *column;
@@ -937,7 +1195,7 @@ queue_list_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, GtkCel
                g_object_set(cell, "wrap-width", width-70, NULL);
 }
 
-void
+G_MODULE_EXPORT void
 queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GValue *js;
@@ -946,6 +1204,14 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        gint status;
        gint state;
 
+       state = ghb_get_queue_state();
+       if (state & (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING))
+       {
+               ghb_cancel_encode(ud, "You are currently encoding.  "
+                                                               "What would you like to do?");
+               return;
+       }
+
        count = ghb_array_len(ud->queue);
        for (ii = 0; ii < count; ii++)
        {
@@ -965,7 +1231,6 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                if (!queue_add(ud))
                        return;
        }
-       state = ghb_get_queue_state();
        if (state == GHB_STATE_IDLE)
        {
                // Add the first pending queue item and start
@@ -973,14 +1238,7 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        }
 }
 
-void
-queue_stop_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
-{
-       ud->cancel_encode = TRUE;
-       ghb_cancel_encode(NULL);
-}
-
-void
+G_MODULE_EXPORT void
 queue_pause_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        ghb_pause_queue();
@@ -997,6 +1255,7 @@ ghb_reload_queue(signal_user_data_t *ud)
        gchar *message;
 
        g_debug("ghb_reload_queue");
+
        queue = ghb_load_queue();
        // Look for unfinished entries
        count = ghb_array_len(queue);
@@ -1021,6 +1280,8 @@ ghb_reload_queue(signal_user_data_t *ud)
                {
                        GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_window");
                        gtk_widget_show (widget);
+                       widget = GHB_WIDGET (ud->builder, "show_queue");
+                       gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), TRUE);
 
                        ud->queue = queue;
                        // First get rid of any old items we don't want
@@ -1043,7 +1304,7 @@ ghb_reload_queue(signal_user_data_t *ud)
                                ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
                                add_to_queue_list(ud, settings, NULL);
                        }
-                       ghb_queue_buttons_grey(ud, FALSE);
+                       ghb_queue_buttons_grey(ud);
                }
                else
                {
@@ -1055,7 +1316,7 @@ ghb_reload_queue(signal_user_data_t *ud)
        return FALSE;
 }
 
-gboolean 
+G_MODULE_EXPORT gboolean 
 queue_key_press_cb(
        GtkWidget *widget, 
        GdkEventKey *event,
@@ -1097,7 +1358,7 @@ queue_key_press_cb(
                if (status == GHB_QUEUE_RUNNING)
                {
                        // Ask if wants to stop encode.
-                       if (!ghb_cancel_encode(NULL))
+                       if (!ghb_cancel_encode2(ud, NULL))
                        {
                                return TRUE;
                        }
@@ -1118,7 +1379,7 @@ queue_key_press_cb(
 
 GValue *ghb_queue_edit_settings = NULL;
 
-void
+G_MODULE_EXPORT void
 queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
 {
        GtkTreeView *treeview;
@@ -1157,9 +1418,13 @@ queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        // Remove the corresponding item from the queue list
                        ghb_array_remove(ud->queue, row);
                }
+               else
+               {
+                       ghb_queue_edit_settings = ghb_value_dup(ghb_queue_edit_settings);
+               }
                gchar *source;
                source = ghb_settings_get_string(ghb_queue_edit_settings, "source");
-               ghb_do_scan(ud, source, FALSE);
+               ghb_do_scan(ud, source, 0, FALSE);
                g_free(source);
        }
 }
index c817331..8ff454a 100644 (file)
@@ -28,6 +28,7 @@
 #include <gtk/gtk.h>
 #include "settings.h"
 
-void ghb_queue_buttons_grey(signal_user_data_t *ud, gboolean working);
+void ghb_queue_buttons_grey(signal_user_data_t *ud);
+gboolean ghb_reload_queue(signal_user_data_t *ud);
 
 #endif // _QUEUEHANDLER_H_
diff --git a/gtk/src/quotestring.py b/gtk/src/quotestring.py
new file mode 100644 (file)
index 0000000..ee6acb3
--- /dev/null
@@ -0,0 +1,63 @@
+#! /usr/bin/python
+
+import re
+import getopt
+import sys
+
+def usage():
+       print >> sys.stderr, (
+               "Usage: %s <input> [output]\n"
+               "Summary:\n"
+               "    Creates a quoted string suitable for inclusion in a C char*\n\n"
+               "Options:\n"
+               "    <input>   Input file to quote\n"
+               "    <output>  Output quoted string [stdout]\n"
+               % sys.argv[0]
+       )
+
+def main():
+       global inc_list
+
+       OPTS = ""
+       try:
+               opts, args = getopt.gnu_getopt(sys.argv[1:], OPTS)
+       except getopt.GetoptError, err:
+               print >> sys.stderr, str(err)
+               usage()
+               sys.exit(2)
+
+       for o, a in opts:
+               usage()
+               assert False, "unhandled option"
+
+       if len(args) > 2 or len(args) < 1:
+               usage()
+               sys.exit(2)
+
+       try:
+               infile = open(args[0])
+       except Exception, err:
+               print >> sys.stderr, ( "Error: %s"  % str(err) )
+               sys.exit(1)
+
+       if len(args) > 1:
+               try:
+                       outfile = open(args[1], "w")
+               except Exception, err:
+                       print >> sys.stderr, ( "Error: %s"  % str(err))
+                       sys.exit(1)
+       else:
+               outfile = sys.stdout
+
+       ss = infile.read()
+       ss = re.sub("\"", "\\\"", ss)
+       pattern = re.compile("$", re.M)
+       # the replacement string below seems a bit strange, but it seems to be
+       # the only way to get the litteral chars '\' 'n' inserted into the string
+       ss = re.sub(pattern, "\\\\n\"", ss)
+       pattern = re.compile("^", re.M)
+       ss = re.sub(pattern, "\"", ss)
+       outfile.write(ss)
+
+main()
+
index 4e11a0e..5a06877 100644 (file)
@@ -6,9 +6,12 @@
                <icon name="hb-complete" file="hb-complete.16.png" />
                <icon name="hb-drawer" file="hb-drawer.32.png" />
                <icon name="hb-icon" file="hb-icon.128.png" />
+               <icon name="hb-status" file="hb-status.32.png" />
+               <icon name="hb-status-empty" file="hb-status-empty.32.png" />
                <icon name="hb-pause" file="hb-pause.32.png" />
                <icon name="hb-play" file="hb-play.32.png" />
                <icon name="hb-pref" file="hb-pref.32.png" />
+               <icon name="hb-picture" file="hb-picture.32.png" />
                <icon name="hb-queue" file="hb-queue.32.png" />
                <icon name="hb-queue-delete" file="hb-queue-delete.16.png" />
                <icon name="hb-queue-job" file="hb-queue-job.16.png" />
@@ -28,7 +31,7 @@
        </section>
        <plist name="internal-defaults" file="internal_defaults.xml" />
        <plist name="standard-presets" file="standard_presets.xml" />
-       <plist name="widget-deps" file="widget_deps" />
-       <plist name="widget-reverse-deps" file="widget_reverse_deps" />
+       <plist name="widget-deps" file="widget.deps" />
+       <plist name="widget-reverse-deps" file="widget_reverse.deps" />
        <string name="ghb-ui" file="ghb.ui" />
 </resources>
index 0b5c902..4bafd9b 100644 (file)
@@ -98,7 +98,7 @@ ghb_settings_set_boolean(GValue *settings, const gchar *key, gboolean bval)
 }
 
 GValue*
-ghb_settings_get_value(GValue *settings, const gchar *key)
+ghb_settings_get_value(const GValue *settings, const gchar *key)
 {
        GValue *value;
        value = ghb_dict_lookup(settings, key);
@@ -108,7 +108,7 @@ ghb_settings_get_value(GValue *settings, const gchar *key)
 }
 
 gboolean
-ghb_settings_get_boolean(GValue *settings, const gchar *key)
+ghb_settings_get_boolean(const GValue *settings, const gchar *key)
 {
        const GValue* value;
        value = ghb_settings_get_value(settings, key);
@@ -117,7 +117,7 @@ ghb_settings_get_boolean(GValue *settings, const gchar *key)
 }
 
 gint64
-ghb_settings_get_int64(GValue *settings, const gchar *key)
+ghb_settings_get_int64(const GValue *settings, const gchar *key)
 {
        const GValue* value;
        value = ghb_settings_get_value(settings, key);
@@ -126,7 +126,7 @@ ghb_settings_get_int64(GValue *settings, const gchar *key)
 }
 
 gint
-ghb_settings_get_int(GValue *settings, const gchar *key)
+ghb_settings_get_int(const GValue *settings, const gchar *key)
 {
        const GValue* value;
        value = ghb_settings_get_value(settings, key);
@@ -135,7 +135,7 @@ ghb_settings_get_int(GValue *settings, const gchar *key)
 }
 
 gdouble
-ghb_settings_get_double(GValue *settings, const gchar *key)
+ghb_settings_get_double(const GValue *settings, const gchar *key)
 {
        const GValue* value;
        value = ghb_settings_get_value(settings, key);
@@ -144,7 +144,7 @@ ghb_settings_get_double(GValue *settings, const gchar *key)
 }
 
 gchar*
-ghb_settings_get_string(GValue *settings, const gchar *key)
+ghb_settings_get_string(const GValue *settings, const gchar *key)
 {
        const GValue* value;
        value = ghb_settings_get_value(settings, key);
@@ -153,17 +153,29 @@ ghb_settings_get_string(GValue *settings, const gchar *key)
 }
 
 gint
-ghb_settings_combo_int(GValue *settings, const gchar *key)
+ghb_settings_combo_int(const GValue *settings, const gchar *key)
 {
        return ghb_lookup_combo_int(key, ghb_settings_get_value(settings, key));
 }
 
+gdouble
+ghb_settings_combo_double(const GValue *settings, const gchar *key)
+{
+       return ghb_lookup_combo_double(key, ghb_settings_get_value(settings, key));
+}
+
 const gchar*
-ghb_settings_combo_option(GValue *settings, const gchar *key)
+ghb_settings_combo_option(const GValue *settings, const gchar *key)
 {
        return ghb_lookup_combo_option(key, ghb_settings_get_value(settings, key));
 }
 
+const gchar*
+ghb_settings_combo_string(const GValue *settings, const gchar *key)
+{
+       return ghb_lookup_combo_string(key, ghb_settings_get_value(settings, key));
+}
+
 // Map widget names to setting keys
 // Widgets that map to settings have names
 // of this format: s_<setting key>
@@ -226,6 +238,20 @@ ghb_widget_value(GtkWidget *widget)
                bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
                value = ghb_boolean_value_new(bval);
        }
+       else if (type == GTK_TYPE_TOGGLE_TOOL_BUTTON)
+       {
+               g_debug("\ttoggle_tool_button");
+               gboolean bval;
+               bval = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
+               value = ghb_boolean_value_new(bval);
+       }
+       else if (type == GTK_TYPE_TOGGLE_BUTTON)
+       {
+               g_debug("\ttoggle_button");
+               gboolean bval;
+               bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+               value = ghb_boolean_value_new(bval);
+       }
        else if (type == GTK_TYPE_TOGGLE_ACTION)
        {
                g_debug("\ttoggle action");
@@ -303,6 +329,13 @@ ghb_widget_value(GtkWidget *widget)
                        value = ghb_int_value_new(dval);
                }
        }
+       else if (type == GTK_TYPE_SCALE_BUTTON)
+       {
+               gdouble dval;
+
+               dval = gtk_scale_button_get_value(GTK_SCALE_BUTTON(widget));
+               value = ghb_double_value_new(dval);
+       }
        else if (type == GTK_TYPE_TEXT_VIEW)
        {
                GtkTextBuffer *buffer;
@@ -321,6 +354,16 @@ ghb_widget_value(GtkWidget *widget)
                str = gtk_label_get_text (GTK_LABEL(widget));
                value = ghb_string_value_new(str);
        }
+       else if (type == GTK_TYPE_FILE_CHOOSER_BUTTON)
+       {
+               gchar *str;
+               str = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(widget));
+               if (str == NULL)
+                       str = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget));
+               value = ghb_string_value_new(str);
+               if (str != NULL)
+                       g_free(str);
+       }
        else
        {
                g_debug("Attempt to set unknown widget type: %s\n", name);
@@ -444,6 +487,16 @@ update_widget(GtkWidget *widget, const GValue *value)
                g_debug("check button");
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), ival);
        }
+       else if (type == GTK_TYPE_TOGGLE_TOOL_BUTTON)
+       {
+               g_debug("toggle button");
+               gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), ival);
+       }
+       else if (type == GTK_TYPE_TOGGLE_BUTTON)
+       {
+               g_debug("toggle button");
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), ival);
+       }
        else if (type == GTK_TYPE_TOGGLE_ACTION)
        {
                g_debug("toggle action");
@@ -459,7 +512,7 @@ update_widget(GtkWidget *widget, const GValue *value)
                GtkTreeModel *store;
                GtkTreeIter iter;
                gchar *shortOpt;
-               gint ivalue;
+               gdouble ivalue;
                gboolean foundit = FALSE;
 
                g_debug("combo (%s)", str);
@@ -485,7 +538,7 @@ update_widget(GtkWidget *widget, const GValue *value)
                        do
                        {
                                gtk_tree_model_get(store, &iter, 3, &ivalue, -1);
-                               if (ivalue == ival)
+                               if ((gint)ivalue == ival || ivalue == dval)
                                {
                                        gtk_combo_box_set_active_iter (
                                                GTK_COMBO_BOX(widget), &iter);
@@ -504,7 +557,7 @@ update_widget(GtkWidget *widget, const GValue *value)
                GtkTreeModel *store;
                GtkTreeIter iter;
                gchar *shortOpt;
-               gint ivalue;
+               gdouble ivalue;
                gboolean foundit = FALSE;
 
                g_debug("GTK_COMBO_BOX_ENTRY");
@@ -530,7 +583,7 @@ update_widget(GtkWidget *widget, const GValue *value)
                        do
                        {
                                gtk_tree_model_get(store, &iter, 3, &ivalue, -1);
-                               if (ivalue == ival)
+                               if ((gint)ivalue == ival || ivalue == dval)
                                {
                                        gtk_combo_box_set_active_iter (
                                                GTK_COMBO_BOX(widget), &iter);
@@ -558,6 +611,11 @@ update_widget(GtkWidget *widget, const GValue *value)
                g_debug("hscale");
                gtk_range_set_value(GTK_RANGE(widget), dval);
        }
+       else if (type == GTK_TYPE_SCALE_BUTTON)
+       {
+               g_debug("scale_button");
+               gtk_scale_button_set_value(GTK_SCALE_BUTTON(widget), dval);
+       }
        else if (type == GTK_TYPE_TEXT_VIEW)
        {
                g_debug("textview (%s)", str);
@@ -567,7 +625,47 @@ update_widget(GtkWidget *widget, const GValue *value)
        }
        else if (type == GTK_TYPE_LABEL)
        {
-               gtk_label_set_text (GTK_LABEL(widget), str);
+               gtk_label_set_markup (GTK_LABEL(widget), str);
+       }
+       else if (type == GTK_TYPE_FILE_CHOOSER_BUTTON)
+       {
+               GtkFileChooserAction act;
+               act = gtk_file_chooser_get_action(GTK_FILE_CHOOSER(widget));
+               if (str[0] == 0)
+               {
+                       // Do nothing
+                       ;
+               }
+               else if (act == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+                       act == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+               {
+                       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget), str);
+               }
+               else if (act == GTK_FILE_CHOOSER_ACTION_SAVE)
+               {
+                       gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str);
+               }
+               else
+               {
+                       if (g_file_test(str, G_FILE_TEST_IS_DIR))
+                       {
+                               gtk_file_chooser_set_current_folder(
+                                       GTK_FILE_CHOOSER(widget), str);
+                       }
+                       else if (g_file_test(str, G_FILE_TEST_EXISTS))
+                       {
+                               gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(widget), str);
+                       }
+                       else
+                       {
+                               gchar *dirname;
+
+                               dirname = g_path_get_dirname(str);
+                               gtk_file_chooser_set_current_folder(
+                                       GTK_FILE_CHOOSER(widget), dirname);
+                               g_free(dirname);
+                       }
+               }
        }
        else
        {
index bc4adc6..c499da5 100644 (file)
@@ -36,20 +36,32 @@ enum
        GHB_STATE_MUXING        = 0x40,
 };
 
+enum
+{
+       GHB_CANCEL_NONE,
+       GHB_CANCEL_ALL,
+       GHB_CANCEL_CURRENT,
+       GHB_CANCEL_FINISH
+};
+
+typedef struct preview_s preview_t;
+
 typedef struct
 {
        gchar *current_dvd_device;
        gboolean debug;
        gboolean dont_clear_presets;
-       gboolean cancel_encode;
+       gint cancel_encode;
        GtkBuilder *builder;
        GValue *settings;
        GValue *queue;
        GValue *current_job;
        GIOChannel *activity_log;
        GIOChannel *job_activity_log;
+       preview_t *preview;
        gchar *appcast;
        gint appcast_len;
+       GdkVisibilityState hb_visibility;
 } signal_user_data_t;
 
 enum
@@ -74,14 +86,16 @@ void ghb_settings_set_boolean(
        GValue *settings, const gchar *key, gboolean bval);
 void ghb_settings_copy(
        GValue *settings, const gchar *key, const GValue *value);
-GValue* ghb_settings_get_value(GValue *settings, const gchar *key);
-gboolean ghb_settings_get_boolean(GValue *settings, const gchar *key);
-gint64 ghb_settings_get_int64(GValue *settings, const gchar *key);
-gint ghb_settings_get_int(GValue *settings, const gchar *key);
-gdouble ghb_settings_get_double(GValue *settings, const gchar *key);
-gchar* ghb_settings_get_string(GValue *settings, const gchar *key);
-gint ghb_settings_combo_int(GValue *settings, const gchar *key);
-const gchar* ghb_settings_combo_option(GValue *settings, const gchar *key);
+GValue* ghb_settings_get_value(const GValue *settings, const gchar *key);
+gboolean ghb_settings_get_boolean(const GValue *settings, const gchar *key);
+gint64 ghb_settings_get_int64(const GValue *settings, const gchar *key);
+gint ghb_settings_get_int(const GValue *settings, const gchar *key);
+gdouble ghb_settings_get_double(const GValue *settings, const gchar *key);
+gchar* ghb_settings_get_string(const GValue *settings, const gchar *key);
+gint ghb_settings_combo_int(const GValue *settings, const gchar *key);
+gdouble ghb_settings_combo_double(const GValue *settings, const gchar *key);
+const gchar* ghb_settings_combo_option(const GValue *settings, const gchar *key);
+const gchar* ghb_settings_combo_string(const GValue *settings, const gchar *key);
 
 GValue* ghb_widget_value(GtkWidget *widget);
 gchar* ghb_widget_string(GtkWidget *widget);
index 2e6019d..b5e36ef 100644 (file)
@@ -20,9 +20,7 @@
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                        <dict>
                                                <key>AudioBitrate</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>Folder</key>
-                               <false />
+                               <false/>
                                <key>Mp4LargeFile</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
@@ -78,7 +74,7 @@
                                <key>PictureWidth</key>
                                <integer>720</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s universally compatible, full resolution settings for all current Apple devices: iPod, iPhone, AppleTV, and Macs</string>
+                               <string>HandBrake's universally compatible, full resolution settings for all current Apple devices: iPod (6G and up), iPhone, AppleTV, and Macs</string>
                                <key>PresetName</key>
                                <string>Universal</string>
                                <key>Subtitles</key>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>2500</integer>
+                               <string>2500</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
-                               <real>0.5899999737739563</real>
+                               <real>20</real>
                                <key>VideoQualityType</key>
                                <integer>2</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1</string>
+                               <string>cabac=0:ref=2:me=umh:bframes=0:8x8dct=0:trellis=0:subme=6</string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>Mp4iPodCompatible</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
                                <key>PictureWidth</key>
                                <integer>320</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size.</string>
+                               <string>HandBrake's low resolution settings for the iPod (5G and up). Optimized for great playback on the iPod screen, with smaller file size.</string>
                                <key>PresetName</key>
                                <string>iPod</string>
                                <key>Subtitles</key>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <false />
+                               <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
                                <real>0.64709997177124023</real>
                                <key>VideoQualityType</key>
                                <integer>1</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1</string>
+                               <string>level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0</string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>Mp4iPodCompatible</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
                                <key>PictureWidth</key>
                                <integer>480</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for the iPhone and iPod Touch.</string>
+                               <string>HandBrake's settings for all iPhones and iPod Touches going back to the original iPhone 2G.</string>
                                <key>PresetName</key>
                                <string>iPhone &amp; iPod Touch</string>
                                <key>Subtitles</key>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <false />
+                               <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>960</integer>
+                               <string>960</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
-                               <real>0.5899999737739563</real>
+                               <real>20</real>
                                <key>VideoQualityType</key>
                                <integer>2</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1</string>
+                               <string>cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0</string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                        <dict>
                                                <key>AudioBitrate</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>Folder</key>
-                               <false />
+                               <false/>
                                <key>Mp4LargeFile</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
                                <key>PictureWidth</key>
                                <integer>960</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance.</string>
+                               <string>HandBrake's settings for the AppleTV and 2009's iPhone and iPod Touch lineup. Provides a good balance between quality and file size, and pushes the devices to their limits. Includes Dolby Digital 5.1 AC3 sound for the AppleTV.</string>
                                <key>PresetName</key>
                                <string>AppleTV</string>
                                <key>Subtitles</key>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>2500</integer>
+                               <string>2500</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
-                               <real>0.5899999737739563</real>
+                               <real>20</real>
                                <key>VideoQualityType</key>
                                <integer>2</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
-                               <key>x264Option</key>
-                               <string>level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all</string>
-                       </dict>
-                       <dict>
-                               <key>AudioList</key>
-                               <array>
-                                       <dict>
-                                               <key>AudioBitrate</key>
-                                               <string>160</string>
-                                               <key>AudioEncoder</key>
-                                               <string>AAC (faac)</string>
-                                               <key>AudioMixdown</key>
-                                               <string>Dolby Pro Logic II</string>
-                                               <key>AudioSamplerate</key>
-                                               <string>Auto</string>
-                                               <key>AudioTrack</key>
-                                               <integer>1</integer>
-                                               <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
-                                       </dict>
-                               </array>
-                               <key>ChapterMarkers</key>
-                               <true />
-                               <key>Default</key>
-                               <false />
-                               <key>FileFormat</key>
-                               <string>MP4 file</string>
-                               <key>PictureAutoCrop</key>
-                               <true />
-                               <key>PictureBottomCrop</key>
-                               <integer>0</integer>
-                               <key>PictureDeblock</key>
-                               <integer>0</integer>
-                               <key>PictureDeinterlace</key>
-                               <string>0</string>
-                               <key>PictureDenoise</key>
-                               <string>0</string>
-                               <key>PictureDetelecine</key>
-                               <false />
-                               <key>PictureHeight</key>
-                               <integer>0</integer>
-                               <key>PictureKeepRatio</key>
-                               <false />
-                               <key>PictureLeftCrop</key>
-                               <integer>0</integer>
-                               <key>PicturePAR</key>
-                               <integer>1</integer>
-                               <key>PictureRightCrop</key>
-                               <integer>0</integer>
-                               <key>PictureTopCrop</key>
-                               <integer>0</integer>
-                               <key>PictureWidth</key>
                                <integer>0</integer>
-                               <key>PresetDescription</key>
-                               <string>HandBrake&apos;s high profile settings for use with QuickTime. It can be slow, so use it when the Normal preset doesn&apos;t look good enough.</string>
-                               <key>PresetName</key>
-                               <string>QuickTime</string>
-                               <key>Subtitles</key>
-                               <string>None</string>
-                               <key>Type</key>
-                               <integer>0</integer>
-                               <key>UsesMaxPictureSettings</key>
-                               <true />
-                               <key>UsesPictureFilters</key>
-                               <true />
-                               <key>UsesPictureSettings</key>
-                               <integer>1</integer>
-                               <key>VideoAvgBitrate</key>
-                               <integer>1800</integer>
-                               <key>VideoEncoder</key>
-                               <string>H.264 (x264)</string>
-                               <key>VideoFramerate</key>
-                               <string>Same as source</string>
-                               <key>VideoGrayScale</key>
-                               <false />
-                               <key>VideoQualitySlider</key>
-                               <real>0.64709997177124023</real>
-                               <key>VideoQualityType</key>
-                               <integer>1</integer>
-                               <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTurboTwoPass</key>
-                               <true />
-                               <key>VideoTwoPass</key>
-                               <true />
                                <key>x264Option</key>
-                               <string>ref=3:mixed-refs:bframes=3:weightb:direct=auto:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip=1:psy-rd=1,1</string>
-                       </dict>
-                       <dict>
-                               <key>ChildrenArray</key>
-                               <array>
-                                       <dict>
-                                               <key>AudioList</key>
-                                               <array>
-                                                       <dict>
-                                                               <key>AudioBitrate</key>
-                                                               <string>160</string>
-                                                               <key>AudioEncoder</key>
-                                                               <string>AAC (faac)</string>
-                                                               <key>AudioMixdown</key>
-                                                               <string>Dolby Pro Logic II</string>
-                                                               <key>AudioSamplerate</key>
-                                                               <string>48</string>
-                                                               <key>AudioTrack</key>
-                                                               <integer>1</integer>
-                                                               <key>AudioTrackDRCSlider</key>
-                                                               <real>1</real>
-                                                               <key>AudioTrackDescription</key>
-                                                               <string></string>
-                                                       </dict>
-                                                       <dict>
-                                                               <key>AudioBitrate</key>
-                                                               <string>160</string>
-                                                               <key>AudioEncoder</key>
-                                                               <string>AC3 Passthru</string>
-                                                               <key>AudioMixdown</key>
-                                                               <string>AC3 Passthru</string>
-                                                               <key>AudioSamplerate</key>
-                                                               <string>Auto</string>
-                                                               <key>AudioTrack</key>
-                                                               <integer>1</integer>
-                                                               <key>AudioTrackDRCSlider</key>
-                                                               <real>1</real>
-                                                               <key>AudioTrackDescription</key>
-                                                               <string></string>
-                                                       </dict>
-                                               </array>
-                                               <key>ChapterMarkers</key>
-                                               <true />
-                                               <key>Default</key>
-                                               <false />
-                                               <key>FileFormat</key>
-                                               <string>MP4 file</string>
-                                               <key>Mp4LargeFile</key>
-                                               <true />
-                                               <key>PictureBottomCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeblock</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeinterlace</key>
-                                               <string>0</string>
-                                               <key>PictureDenoise</key>
-                                               <string>0</string>
-                                               <key>PictureDetelecine</key>
-                                               <false />
-                                               <key>PictureHeight</key>
-                                               <integer>0</integer>
-                                               <key>PictureKeepRatio</key>
-                                               <false />
-                                               <key>PictureLeftCrop</key>
-                                               <integer>0</integer>
-                                               <key>PicturePAR</key>
-                                               <integer>1</integer>
-                                               <key>PictureRightCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureTopCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureWidth</key>
-                                               <integer>0</integer>
-                                               <key>PresetDescription</key>
-                                               <string>HandBrake&apos;s deprecated settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance. This is the AppleTV preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported.</string>
-                                               <key>PresetName</key>
-                                               <string>AppleTV Legacy</string>
-                                               <key>Subtitles</key>
-                                               <string>None</string>
-                                               <key>Type</key>
-                                               <integer>0</integer>
-                                               <key>UsesMaxPictureSettings</key>
-                                               <true />
-                                               <key>UsesPictureFilters</key>
-                                               <true />
-                                               <key>UsesPictureSettings</key>
-                                               <integer>1</integer>
-                                               <key>VideoAvgBitrate</key>
-                                               <integer>2500</integer>
-                                               <key>VideoEncoder</key>
-                                               <string>H.264 (x264)</string>
-                                               <key>VideoFramerate</key>
-                                               <string>Same as source</string>
-                                               <key>VideoGrayScale</key>
-                                               <false />
-                                               <key>VideoQualitySlider</key>
-                                               <real>0.64709997177124023</real>
-                                               <key>VideoQualityType</key>
-                                               <integer>1</integer>
-                                               <key>VideoTargetSize</key>
-                                               <integer>700</integer>
-                                               <key>VideoTwoPass</key>
-                                               <false />
-                                               <key>x264Option</key>
-                                               <string>bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0</string>
-                                       </dict>
-                                       <dict>
-                                               <key>AudioList</key>
-                                               <array>
-                                                       <dict>
-                                                               <key>AudioBitrate</key>
-                                                               <string>128</string>
-                                                               <key>AudioEncoder</key>
-                                                               <string>AAC (faac)</string>
-                                                               <key>AudioMixdown</key>
-                                                               <string>Dolby Pro Logic II</string>
-                                                               <key>AudioSamplerate</key>
-                                                               <string>48</string>
-                                                               <key>AudioTrack</key>
-                                                               <integer>1</integer>
-                                                               <key>AudioTrackDRCSlider</key>
-                                                               <real>1</real>
-                                                               <key>AudioTrackDescription</key>
-                                                               <string></string>
-                                                       </dict>
-                                               </array>
-                                               <key>ChapterMarkers</key>
-                                               <true />
-                                               <key>Default</key>
-                                               <false />
-                                               <key>FileFormat</key>
-                                               <string>MP4 file</string>
-                                               <key>Mp4iPodCompatible</key>
-                                               <true />
-                                               <key>PictureAutoCrop</key>
-                                               <true />
-                                               <key>PictureBottomCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeblock</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeinterlace</key>
-                                               <string>0</string>
-                                               <key>PictureDenoise</key>
-                                               <string>0</string>
-                                               <key>PictureDetelecine</key>
-                                               <false />
-                                               <key>PictureHeight</key>
-                                               <integer>0</integer>
-                                               <key>PictureKeepRatio</key>
-                                               <true />
-                                               <key>PictureLeftCrop</key>
-                                               <integer>0</integer>
-                                               <key>PicturePAR</key>
-                                               <integer>0</integer>
-                                               <key>PictureRightCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureTopCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureWidth</key>
-                                               <integer>480</integer>
-                                               <key>PresetDescription</key>
-                                               <string>HandBrake&apos;s deprecated settings for the iPhone and iPod Touch. This is the iPhone preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported.</string>
-                                               <key>PresetName</key>
-                                               <string>iPhone Legacy</string>
-                                               <key>Subtitles</key>
-                                               <string>None</string>
-                                               <key>Type</key>
-                                               <integer>0</integer>
-                                               <key>UsesMaxPictureSettings</key>
-                                               <false />
-                                               <key>UsesPictureFilters</key>
-                                               <true />
-                                               <key>UsesPictureSettings</key>
-                                               <integer>1</integer>
-                                               <key>VideoAvgBitrate</key>
-                                               <integer>960</integer>
-                                               <key>VideoEncoder</key>
-                                               <string>H.264 (x264)</string>
-                                               <key>VideoFramerate</key>
-                                               <string>Same as source</string>
-                                               <key>VideoGrayScale</key>
-                                               <false />
-                                               <key>VideoQualitySlider</key>
-                                               <real>0.64709997177124023</real>
-                                               <key>VideoQualityType</key>
-                                               <integer>1</integer>
-                                               <key>VideoTargetSize</key>
-                                               <integer>700</integer>
-                                               <key>VideoTwoPass</key>
-                                               <false />
-                                               <key>x264Option</key>
-                                               <string>level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:trellis=1</string>
-                                       </dict>
-                                       <dict>
-                                               <key>AudioList</key>
-                                               <array>
-                                                       <dict>
-                                                               <key>AudioBitrate</key>
-                                                               <string>160</string>
-                                                               <key>AudioEncoder</key>
-                                                               <string>AAC (faac)</string>
-                                                               <key>AudioMixdown</key>
-                                                               <string>Dolby Pro Logic II</string>
-                                                               <key>AudioSamplerate</key>
-                                                               <string>48</string>
-                                                               <key>AudioTrack</key>
-                                                               <integer>1</integer>
-                                                               <key>AudioTrackDRCSlider</key>
-                                                               <real>1</real>
-                                                               <key>AudioTrackDescription</key>
-                                                               <string></string>
-                                                       </dict>
-                                               </array>
-                                               <key>ChapterMarkers</key>
-                                               <true />
-                                               <key>Default</key>
-                                               <false />
-                                               <key>FileFormat</key>
-                                               <string>MP4 file</string>
-                                               <key>Mp4iPodCompatible</key>
-                                               <true />
-                                               <key>PictureAutoCrop</key>
-                                               <true />
-                                               <key>PictureBottomCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeblock</key>
-                                               <integer>0</integer>
-                                               <key>PictureDeinterlace</key>
-                                               <string>0</string>
-                                               <key>PictureDenoise</key>
-                                               <string>0</string>
-                                               <key>PictureDetelecine</key>
-                                               <false />
-                                               <key>PictureHeight</key>
-                                               <integer>0</integer>
-                                               <key>PictureKeepRatio</key>
-                                               <true />
-                                               <key>PictureLeftCrop</key>
-                                               <integer>0</integer>
-                                               <key>PicturePAR</key>
-                                               <integer>0</integer>
-                                               <key>PictureRightCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureTopCrop</key>
-                                               <integer>0</integer>
-                                               <key>PictureWidth</key>
-                                               <integer>640</integer>
-                                               <key>PresetDescription</key>
-                                               <string>HandBrake&apos;s high resolution settings for older 5 and 5.5G iPods. Good video quality, great for viewing on a TV using your iPod. This is the iPod High-Rez preset from 0.9.2.</string>
-                                               <key>PresetName</key>
-                                               <string>iPod Legacy</string>
-                                               <key>Subtitles</key>
-                                               <string>None</string>
-                                               <key>Type</key>
-                                               <integer>0</integer>
-                                               <key>UsesMaxPictureSettings</key>
-                                               <false />
-                                               <key>UsesPictureFilters</key>
-                                               <true />
-                                               <key>UsesPictureSettings</key>
-                                               <integer>1</integer>
-                                               <key>VideoAvgBitrate</key>
-                                               <integer>1500</integer>
-                                               <key>VideoEncoder</key>
-                                               <string>H.264 (x264)</string>
-                                               <key>VideoFramerate</key>
-                                               <string>Same as source</string>
-                                               <key>VideoGrayScale</key>
-                                               <false />
-                                               <key>VideoQualitySlider</key>
-                                               <real>0.64709997177124023</real>
-                                               <key>VideoQualityType</key>
-                                               <integer>1</integer>
-                                               <key>VideoTargetSize</key>
-                                               <integer>700</integer>
-                                               <key>VideoTwoPass</key>
-                                               <false />
-                                               <key>x264Option</key>
-                                               <string>level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1</string>
-                                       </dict>
-                               </array>
-                               <key>Folder</key>
-                               <true />
-                               <key>PresetName</key>
-                               <string>Legacy</string>
-                               <key>Type</key>
-                               <integer>0</integer>
+                               <string>cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0</string>
                        </dict>
                </array>
+               <key>Default</key>
+               <integer>0</integer>
                <key>Folder</key>
-               <true />
+               <true/>
+               <key>PresetBuildNumber</key>
+               <integer>2009112101</integer>
                <key>PresetName</key>
                <string>Apple</string>
                <key>Type</key>
                                                <key>AudioMixdown</key>
                                                <string>Dolby Pro Logic II</string>
                                                <key>AudioSamplerate</key>
-                                               <string>Auto</string>
+                                               <string>48</string>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <true />
+                               <integer>1</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
                                <key>PictureWidth</key>
                                <integer>0</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s normal, default settings.</string>
+                               <string>HandBrake's normal, default settings.</string>
                                <key>PresetName</key>
                                <string>Normal</string>
                                <key>Subtitles</key>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>1500</integer>
+                               <string>1500</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
-                               <real>0.64709997177124023</real>
+                               <real>20</real>
                                <key>VideoQualityType</key>
-                               <integer>1</integer>
+                               <integer>2</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTurboTwoPass</key>
-                               <true />
+                               <integer>0</integer>
                                <key>VideoTwoPass</key>
-                               <true />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>ref=2:bframes=2:me=umh</string>
+                               <string>ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0</string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioMixdown</key>
                                                <string>Dolby Pro Logic II</string>
                                                <key>AudioSamplerate</key>
+                                               <string>48</string>
+                                               <key>AudioTrack</key>
+                                               <integer>1</integer>
+                                               <key>AudioTrackDRCSlider</key>
+                                               <real>0.0</real>
+                                       </dict>
+                                       <dict>
+                                               <key>AudioBitrate</key>
+                                               <string>160</string>
+                                               <key>AudioEncoder</key>
+                                               <string>AC3 Passthru</string>
+                                               <key>AudioMixdown</key>
+                                               <string>AC3 Passthru</string>
+                                               <key>AudioSamplerate</key>
                                                <string>Auto</string>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <false />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
+                               <key>PictureDecomb</key>
+                               <integer>2</integer>
+                               <key>PictureDecombDeinterlace</key>
+                               <integer>1</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>2</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <true />
+                               <integer>0</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
-                               <integer>0</integer>
+                               <integer>2</integer>
                                <key>PictureRightCrop</key>
                                <integer>0</integer>
                                <key>PictureTopCrop</key>
                                <key>PictureWidth</key>
                                <integer>0</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s traditional, faster, lower-quality settings.</string>
+                               <string>HandBrake's general-purpose preset for High Profile H.264 video, with all the bells and whistles.</string>
                                <key>PresetName</key>
-                               <string>Classic</string>
+                               <string>High Profile</string>
                                <key>Subtitles</key>
                                <string>None</string>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>1000</integer>
+                               <string>1800</string>
                                <key>VideoEncoder</key>
-                               <string>MPEG-4 (FFmpeg)</string>
+                               <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
-                               <real>0.64709997177124023</real>
+                               <real>20</real>
                                <key>VideoQualityType</key>
-                               <integer>1</integer>
+                               <integer>2</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
+                               <key>VideoTurboTwoPass</key>
+                               <integer>0</integer>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string></string>
+                               <string>b-adapt=2:rc-lookahead=50</string>
                        </dict>
                </array>
+               <key>Default</key>
+               <integer>0</integer>
                <key>Folder</key>
-               <true />
+               <true/>
+               <key>PresetBuildNumber</key>
+               <integer>2009112101</integer>
                <key>PresetName</key>
-               <string>Basic</string>
+               <string>Regular</string>
                <key>Type</key>
                <integer>0</integer>
        </dict>
                                                <key>AudioMixdown</key>
                                                <string>Dolby Pro Logic II</string>
                                                <key>AudioSamplerate</key>
-                                               <string>Auto</string>
+                                               <string>48</string>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
+                               <integer>0</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
-                               <string>MKV file</string>
+                               <string>MP4 file</string>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
-                               <key>PictureDecomb</key>
-                               <true />
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <true />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>1</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
-                               <integer>1</integer>
+                               <integer>0</integer>
                                <key>PictureRightCrop</key>
                                <integer>0</integer>
                                <key>PictureTopCrop</key>
                                <key>PictureWidth</key>
                                <integer>0</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for cartoons, anime, and CGI.</string>
+                               <string>HandBrake's traditional, faster, lower-quality settings.</string>
                                <key>PresetName</key>
-                               <string>Animation</string>
+                               <string>Classic</string>
                                <key>Subtitles</key>
                                <string>None</string>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>1000</integer>
+                               <string>1000</string>
                                <key>VideoEncoder</key>
-                               <string>H.264 (x264)</string>
+                               <string>MPEG-4 (FFmpeg)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
                                <real>0.64709997177124023</real>
                                <key>VideoQualityType</key>
                                <integer>1</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTurboTwoPass</key>
-                               <true />
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <true />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>ref=5:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2:psy-rd=1,1:subme=9</string>
+                               <string></string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioBitrate</key>
                                                <string>160</string>
                                                <key>AudioEncoder</key>
-                                               <string>AC3 Passthru</string>
+                                               <string>AAC (faac)</string>
                                                <key>AudioMixdown</key>
-                                               <string>AC3 Passthru</string>
+                                               <string>Dolby Pro Logic II</string>
                                                <key>AudioSamplerate</key>
-                                               <string>Auto</string>
+                                               <string>48</string>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
-                               </array>
-                               <key>ChapterMarkers</key>
-                               <true />
-                               <key>Default</key>
-                               <false />
-                               <key>FileFormat</key>
-                               <string>MKV file</string>
-                               <key>PictureAutoCrop</key>
-                               <true />
-                               <key>PictureBottomCrop</key>
-                               <integer>0</integer>
-                               <key>PictureDeblock</key>
-                               <integer>0</integer>
-                               <key>PictureDeinterlace</key>
-                               <string>0</string>
-                               <key>PictureDenoise</key>
-                               <string>0</string>
-                               <key>PictureDetelecine</key>
-                               <false />
-                               <key>PictureHeight</key>
-                               <integer>0</integer>
-                               <key>PictureKeepRatio</key>
-                               <false />
-                               <key>PictureLeftCrop</key>
-                               <integer>0</integer>
-                               <key>PicturePAR</key>
-                               <integer>1</integer>
-                               <key>PictureRightCrop</key>
-                               <integer>0</integer>
-                               <key>PictureTopCrop</key>
-                               <integer>0</integer>
-                               <key>PictureWidth</key>
-                               <integer>0</integer>
-                               <key>PresetDescription</key>
-                               <string>HandBrake&apos;s preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates.</string>
-                               <key>PresetName</key>
-                               <string>Constant Quality Rate</string>
-                               <key>Subtitles</key>
-                               <string>None</string>
-                               <key>Type</key>
-                               <integer>0</integer>
-                               <key>UsesMaxPictureSettings</key>
-                               <true />
-                               <key>UsesPictureFilters</key>
-                               <true />
-                               <key>UsesPictureSettings</key>
-                               <integer>1</integer>
-                               <key>VideoAvgBitrate</key>
-                               <integer>2000</integer>
-                               <key>VideoEncoder</key>
-                               <string>H.264 (x264)</string>
-                               <key>VideoFramerate</key>
-                               <string>Same as source</string>
-                               <key>VideoGrayScale</key>
-                               <false />
-                               <key>VideoQualitySlider</key>
-                               <real>0.60000002384185791</real>
-                               <key>VideoQualityType</key>
-                               <integer>2</integer>
-                               <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTurboTwoPass</key>
-                               <false />
-                               <key>VideoTwoPass</key>
-                               <false />
-                               <key>x264Option</key>
-                               <string>ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all:8x8dct:me=umh:subme=9:psy-rd=1,1</string>
-                       </dict>
-                       <dict>
-                               <key>AudioList</key>
-                               <array>
                                        <dict>
                                                <key>AudioBitrate</key>
                                                <string>160</string>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
-                               <key>Default</key>
-                               <false />
-                               <key>FileFormat</key>
-                               <string>MKV file</string>
-                               <key>PictureAutoCrop</key>
-                               <true />
-                               <key>PictureBottomCrop</key>
-                               <integer>0</integer>
-                               <key>PictureDeblock</key>
-                               <integer>0</integer>
-                               <key>PictureDeinterlace</key>
-                               <string>0</string>
-                               <key>PictureDenoise</key>
-                               <string>0</string>
-                               <key>PictureDetelecine</key>
-                               <false />
-                               <key>PictureHeight</key>
-                               <integer>0</integer>
-                               <key>PictureKeepRatio</key>
-                               <false />
-                               <key>PictureLeftCrop</key>
-                               <integer>0</integer>
-                               <key>PicturePAR</key>
                                <integer>1</integer>
-                               <key>PictureRightCrop</key>
-                               <integer>0</integer>
-                               <key>PictureTopCrop</key>
-                               <integer>0</integer>
-                               <key>PictureWidth</key>
-                               <integer>0</integer>
-                               <key>PresetDescription</key>
-                               <string>HandBrake&apos;s preset for feature films.</string>
-                               <key>PresetName</key>
-                               <string>Film</string>
-                               <key>Subtitles</key>
-                               <string>None</string>
-                               <key>Type</key>
-                               <integer>0</integer>
-                               <key>UsesMaxPictureSettings</key>
-                               <true />
-                               <key>UsesPictureFilters</key>
-                               <true />
-                               <key>UsesPictureSettings</key>
-                               <integer>1</integer>
-                               <key>VideoAvgBitrate</key>
-                               <integer>1800</integer>
-                               <key>VideoEncoder</key>
-                               <string>H.264 (x264)</string>
-                               <key>VideoFramerate</key>
-                               <string>Same as source</string>
-                               <key>VideoGrayScale</key>
-                               <false />
-                               <key>VideoQualitySlider</key>
-                               <real>0.64709997177124023</real>
-                               <key>VideoQualityType</key>
-                               <integer>1</integer>
-                               <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTurboTwoPass</key>
-                               <true />
-                               <key>VideoTwoPass</key>
-                               <true />
-                               <key>x264Option</key>
-                               <string>ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1</string>
-                       </dict>
-                       <dict>
-                               <key>AudioList</key>
-                               <array>
-                                       <dict>
-                                               <key>AudioBitrate</key>
-                                               <string>160</string>
-                                               <key>AudioEncoder</key>
-                                               <string>AAC (faac)</string>
-                                               <key>AudioMixdown</key>
-                                               <string>Dolby Pro Logic II</string>
-                                               <key>AudioSamplerate</key>
-                                               <string>Auto</string>
-                                               <key>AudioTrack</key>
-                                               <integer>1</integer>
-                                               <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
-                                       </dict>
-                               </array>
-                               <key>ChapterMarkers</key>
-                               <true />
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
-                               <string>MKV file</string>
+                               <string>MP4 file</string>
+                               <key>Mp4LargeFile</key>
+                               <integer>1</integer>
                                <key>PictureAutoCrop</key>
-                               <true />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
-                               <key>PictureDecomb</key>
-                               <true />
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <true />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
                                <key>PictureWidth</key>
                                <integer>0</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for video from television.</string>
+                               <string>HandBrake's deprecated settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance. This is the AppleTV preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported.</string>
                                <key>PresetName</key>
-                               <string>Television</string>
+                               <string>AppleTV Legacy</string>
                                <key>Subtitles</key>
                                <string>None</string>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>1300</integer>
+                               <string>2500</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
                                <real>0.64709997177124023</real>
                                <key>VideoQualityType</key>
                                <integer>1</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTurboTwoPass</key>
-                               <true />
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <true />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip=1:psy-rd=1,1</string>
+                               <string>ref=1:subme=5:me=umh:no-fast-pskip=1:cabac=0:weightb=0:8x8dct=0:trellis=0</string>
                        </dict>
-               </array>
-               <key>Folder</key>
-               <true />
-               <key>PresetName</key>
-               <string>High Profile</string>
-               <key>Type</key>
-               <integer>0</integer>
-       </dict>
-       <dict>
-               <key>ChildrenArray</key>
-               <array>
                        <dict>
                                <key>AudioList</key>
                                <array>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <true />
-                               <key>Default</key>
-                               <false />
-                               <key>FileFormat</key>
-                               <string>MP4 file</string>
-                               <key>PictureAutoCrop</key>
-                               <true />
-                               <key>PictureBottomCrop</key>
-                               <integer>0</integer>
-                               <key>PictureDeblock</key>
-                               <integer>0</integer>
-                               <key>PictureDeinterlace</key>
-                               <string>0</string>
-                               <key>PictureDenoise</key>
-                               <string>0</string>
-                               <key>PictureDetelecine</key>
-                               <false />
-                               <key>PictureHeight</key>
-                               <integer>208</integer>
-                               <key>PictureKeepRatio</key>
-                               <true />
-                               <key>PictureLeftCrop</key>
-                               <integer>0</integer>
-                               <key>PicturePAR</key>
-                               <integer>0</integer>
-                               <key>PictureRightCrop</key>
-                               <integer>0</integer>
-                               <key>PictureTopCrop</key>
-                               <integer>0</integer>
-                               <key>PictureWidth</key>
-                               <integer>368</integer>
-                               <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for the Sony PlayStation Portable.</string>
-                               <key>PresetName</key>
-                               <string>PSP</string>
-                               <key>Subtitles</key>
-                               <string>None</string>
-                               <key>Type</key>
-                               <integer>0</integer>
-                               <key>UsesMaxPictureSettings</key>
-                               <false />
-                               <key>UsesPictureFilters</key>
-                               <true />
-                               <key>UsesPictureSettings</key>
-                               <integer>1</integer>
-                               <key>VideoAvgBitrate</key>
-                               <integer>1024</integer>
-                               <key>VideoEncoder</key>
-                               <string>MPEG-4 (FFmpeg)</string>
-                               <key>VideoFramerate</key>
-                               <string>Same as source</string>
-                               <key>VideoGrayScale</key>
-                               <false />
-                               <key>VideoQualitySlider</key>
-                               <real>0.64709997177124023</real>
-                               <key>VideoQualityType</key>
                                <integer>1</integer>
-                               <key>VideoTargetSize</key>
-                               <integer>700</integer>
-                               <key>VideoTwoPass</key>
-                               <false />
-                               <key>x264Option</key>
-                               <string></string>
-                       </dict>
-                       <dict>
-                               <key>AudioList</key>
-                               <array>
-                                       <dict>
-                                               <key>AudioBitrate</key>
-                                               <string>160</string>
-                                               <key>AudioEncoder</key>
-                                               <string>AAC (faac)</string>
-                                               <key>AudioMixdown</key>
-                                               <string>Dolby Pro Logic II</string>
-                                               <key>AudioSamplerate</key>
-                                               <string>48</string>
-                                               <key>AudioTrack</key>
-                                               <integer>1</integer>
-                                               <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
-                                       </dict>
-                               </array>
-                               <key>ChapterMarkers</key>
-                               <false />
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
+                               <key>Mp4iPodCompatible</key>
+                               <integer>1</integer>
                                <key>PictureAutoCrop</key>
-                               <false />
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>1</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
-                               <integer>1</integer>
+                               <integer>0</integer>
                                <key>PictureRightCrop</key>
                                <integer>0</integer>
                                <key>PictureTopCrop</key>
                                <integer>0</integer>
                                <key>PictureWidth</key>
-                               <integer>0</integer>
+                               <integer>480</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for the Sony PlayStation 3.</string>
+                               <string>HandBrake's deprecated settings for the iPhone and iPod Touch. This is the iPhone preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported.</string>
                                <key>PresetName</key>
-                               <string>PS3</string>
+                               <string>iPhone Legacy</string>
                                <key>Subtitles</key>
                                <string>None</string>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>2500</integer>
+                               <string>960</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
                                <real>0.64709997177124023</real>
                                <key>VideoQualityType</key>
                                <integer>1</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>level=41:me=umh</string>
+                               <string>level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:subme=6:8x8dct=0:trellis=0</string>
                        </dict>
                        <dict>
                                <key>AudioList</key>
                                                <key>AudioTrack</key>
                                                <integer>1</integer>
                                                <key>AudioTrackDRCSlider</key>
-                                               <real>1</real>
-                                               <key>AudioTrackDescription</key>
-                                               <string></string>
+                                               <real>0.0</real>
                                        </dict>
                                </array>
                                <key>ChapterMarkers</key>
-                               <false />
+                               <integer>1</integer>
                                <key>Default</key>
-                               <false />
+                               <integer>0</integer>
                                <key>FileFormat</key>
                                <string>MP4 file</string>
+                               <key>Mp4iPodCompatible</key>
+                               <integer>1</integer>
+                               <key>PictureAutoCrop</key>
+                               <integer>1</integer>
                                <key>PictureBottomCrop</key>
                                <integer>0</integer>
                                <key>PictureDeblock</key>
                                <integer>0</integer>
                                <key>PictureDeinterlace</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDenoise</key>
-                               <string>0</string>
+                               <integer>0</integer>
                                <key>PictureDetelecine</key>
-                               <false />
+                               <integer>0</integer>
                                <key>PictureHeight</key>
                                <integer>0</integer>
                                <key>PictureKeepRatio</key>
-                               <false />
+                               <integer>1</integer>
                                <key>PictureLeftCrop</key>
                                <integer>0</integer>
                                <key>PicturePAR</key>
-                               <integer>1</integer>
+                               <integer>0</integer>
                                <key>PictureRightCrop</key>
                                <integer>0</integer>
                                <key>PictureTopCrop</key>
                                <integer>0</integer>
                                <key>PictureWidth</key>
-                               <integer>0</integer>
+                               <integer>640</integer>
                                <key>PresetDescription</key>
-                               <string>HandBrake&apos;s settings for the Microsoft Xbox 360.</string>
+                               <string>HandBrake's high resolution settings for older 5 and 5.5G iPods. Good video quality, great for viewing on a TV using your iPod. This is the iPod High-Rez preset from 0.9.2.</string>
                                <key>PresetName</key>
-                               <string>Xbox 360</string>
+                               <string>iPod Legacy</string>
                                <key>Subtitles</key>
                                <string>None</string>
                                <key>Type</key>
                                <integer>0</integer>
                                <key>UsesMaxPictureSettings</key>
-                               <true />
+                               <integer>0</integer>
                                <key>UsesPictureFilters</key>
-                               <true />
+                               <integer>1</integer>
                                <key>UsesPictureSettings</key>
                                <integer>1</integer>
+                               <key>VFR</key>
+                               <integer>0</integer>
                                <key>VideoAvgBitrate</key>
-                               <integer>2000</integer>
+                               <string>1500</string>
                                <key>VideoEncoder</key>
                                <string>H.264 (x264)</string>
                                <key>VideoFramerate</key>
                                <string>Same as source</string>
                                <key>VideoGrayScale</key>
-                               <false />
+                               <integer>0</integer>
                                <key>VideoQualitySlider</key>
                                <real>0.64709997177124023</real>
                                <key>VideoQualityType</key>
                                <integer>1</integer>
                                <key>VideoTargetSize</key>
-                               <integer>700</integer>
+                               <string>700</string>
                                <key>VideoTwoPass</key>
-                               <false />
+                               <integer>0</integer>
                                <key>x264Option</key>
-                               <string>level=40:ref=2:mixed-refs:bframes=3:weightb:subme=9:direct=auto:b-pyramid:me=umh:analyse=all:no-fast-pskip:filter=-2,-1</string>
+                               <string>level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:subme=6:8x8dct=0:trellis=0</string>
                        </dict>
                </array>
+               <key>Default</key>
+               <integer>0</integer>
                <key>Folder</key>
-               <true />
+               <true/>
+               <key>PresetBuildNumber</key>
+               <integer>2009112101</integer>
                <key>PresetName</key>
-               <string>Gaming Consoles</string>
+               <string>Legacy</string>
                <key>Type</key>
                <integer>0</integer>
        </dict>
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
new file mode 100644 (file)
index 0000000..5374408
--- /dev/null
@@ -0,0 +1,1327 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * subtitlehandler.c
+ * Copyright (C) John Stebbins 2008 <stebbins@stebbins>
+ * 
+ * subtitlehandler.c is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <gtk/gtk.h>
+#include "hb.h"
+#include "settings.h"
+#include "hb-backend.h"
+#include "values.h"
+#include "callbacks.h"
+#include "preview.h"
+#include "presets.h"
+#include "audiohandler.h"
+#include "subtitlehandler.h"
+
+static void add_to_subtitle_list(signal_user_data_t *ud, GValue *settings);
+static void add_to_srt_list(signal_user_data_t *ud, GValue *settings);
+
+static void
+free_subtitle_index_list(gpointer data)
+{
+       g_free(data);
+}
+
+static void
+free_subtitle_key(gpointer data)
+{
+       if (data != NULL)
+               g_free(data);
+}
+
+static gboolean
+mustBurn(signal_user_data_t *ud, GValue *settings)
+{
+       if (ghb_settings_combo_int(ud->settings, "FileFormat") == HB_MUX_MP4)
+       {
+               // MP4 can only handle burned vobsubs.  make sure there isn't
+               // already something burned in the list
+               if (ghb_settings_get_int(settings, "SubtitleSource") == VOBSUB)
+               {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+gboolean
+ghb_soft_in_subtitle_list(GValue *subtitle_list)
+{
+       gint count, ii;
+       GValue *settings;
+
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               settings = ghb_array_get_nth(subtitle_list, ii);
+               if (!ghb_settings_get_boolean(settings, "SubtitleBurned"))
+               {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+void
+ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint index)
+{
+       GValue *subtitle_list;
+       GValue *settings;
+       gint ii, count;
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       gboolean burned;
+
+       g_debug("ghb_subtitle_exclusive_burn");
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               settings = ghb_array_get_nth(subtitle_list, ii);
+               burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+
+               tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+               g_return_if_fail(tv != NULL);
+               tm = gtk_tree_view_get_model(tv);
+               gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+               if (burned && ii != index && !mustBurn(ud, settings))
+               {
+                       ghb_settings_set_boolean(settings, "SubtitleBurned", FALSE);
+                       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 2, FALSE, -1);
+               }
+       }
+}
+
+void
+ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint index)
+{
+       GValue *subtitle_list;
+       GValue *settings;
+       gint ii, count;
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       gboolean def;
+
+       g_debug("ghb_subtitle_exclusive_default");
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               settings = ghb_array_get_nth(subtitle_list, ii);
+               def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+               tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+               g_return_if_fail(tv != NULL);
+               tm = gtk_tree_view_get_model(tv);
+               gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+               if (def && ii != index)
+               {
+
+                       ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", FALSE);
+                       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 3, FALSE, -1);
+               }
+       }
+}
+
+void
+ghb_add_srt(signal_user_data_t *ud, GValue *settings)
+{
+       // Add the current subtitle settings to the list.
+       GValue *subtitle_list;
+       gint count;
+       const gchar *lang;
+       
+       g_debug("ghb_add_srt ()");
+
+       ghb_settings_set_boolean(settings, "SubtitleBurned", FALSE);
+       // Add the long track description so the queue can access it
+       // when a different title is selected.
+       lang = ghb_settings_combo_option(settings, "SrtLanguage");
+       ghb_settings_set_string(settings, "SubtitleTrackDescription", lang);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       if (subtitle_list == NULL)
+       {
+               subtitle_list = ghb_array_value_new(8);
+               ghb_settings_set_value(ud->settings, "subtitle_list", subtitle_list);
+       }
+       count = ghb_array_len(subtitle_list);
+
+       // Don't allow more than 99
+       // This is a had limit imposed by libhb/sync.c:GetFifoForId()
+       if (count >= 99)
+       {
+               ghb_value_free(settings);
+               return;
+       }
+
+       ghb_array_append(subtitle_list, settings);
+       add_to_srt_list(ud, settings);
+
+       if (count == 98)
+       {
+               GtkWidget *widget;
+               widget = GHB_WIDGET (ud->builder, "subtitle_add");
+               gtk_widget_set_sensitive(widget, FALSE);
+               widget = GHB_WIDGET (ud->builder, "srt_add");
+               gtk_widget_set_sensitive(widget, FALSE);
+       }
+       ghb_update_destination_extension(ud);
+       ghb_live_reset(ud);
+}
+
+void
+ghb_add_subtitle(signal_user_data_t *ud, GValue *settings)
+{
+       // Add the current subtitle settings to the list.
+       GValue *subtitle_list;
+       gint count;
+       gboolean burned;
+       const gchar *track;
+       const gchar *lang;
+       
+       g_debug("ghb_add_subtitle ()");
+
+       // Add the long track description so the queue can access it
+       // when a different title is selected.
+       track = ghb_settings_combo_option(settings, "SubtitleTrack");
+       ghb_settings_set_string(settings, "SubtitleTrackDescription", track);
+
+       lang = ghb_settings_combo_string(settings, "SubtitleTrack");
+       ghb_settings_set_string(settings, "SubtitleLanguage", lang);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       if (subtitle_list == NULL)
+       {
+               subtitle_list = ghb_array_value_new(8);
+               ghb_settings_set_value(ud->settings, "subtitle_list", subtitle_list);
+       }
+       count = ghb_array_len(subtitle_list);
+
+       // Don't allow more than 99
+       // This is a had limit imposed by libhb/sync.c:GetFifoForId()
+       if (count >= 99)
+       {
+               ghb_value_free(settings);
+               return;
+       }
+
+       ghb_array_append(subtitle_list, settings);
+       add_to_subtitle_list(ud, settings);
+
+       burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+       if (burned)
+               ghb_subtitle_exclusive_burn(ud, count);
+       if (count == 98)
+       {
+               GtkWidget *widget;
+               widget = GHB_WIDGET (ud->builder, "subtitle_add");
+               gtk_widget_set_sensitive(widget, FALSE);
+               widget = GHB_WIDGET (ud->builder, "srt_add");
+               gtk_widget_set_sensitive(widget, FALSE);
+       }
+       ghb_update_destination_extension(ud);
+       ghb_live_reset(ud);
+}
+
+static void
+add_all_pref_subtitles(signal_user_data_t *ud)
+{
+       const GValue *pref_subtitle;
+       GValue *subtitle;
+       gint count, ii, track;
+       char *lang;
+
+       pref_subtitle = ghb_settings_get_value(ud->settings, "SubtitleList");
+       count = ghb_array_len(pref_subtitle);
+       for (ii = 0; ii < count; ii++)
+       {
+               subtitle = ghb_value_dup(ghb_array_get_nth(pref_subtitle, ii));
+               lang = ghb_settings_get_string(subtitle, "SubtitleLanguage");
+               // If there are multiple subtitles using the same language, then
+               // select sequential tracks for each.  The hash keeps track 
+               // of the tracks used for each language.
+               track = ghb_find_pref_subtitle_track(lang);
+               g_free(lang);
+               if (track >= -1)
+               {
+                       int source;
+
+                       // Add to subtitle list
+                       ghb_settings_set_int(subtitle, "SubtitleTrack", track);
+                       source = ghb_subtitle_track_source(ud, track);
+                       ghb_settings_set_int(subtitle, "SubtitleSource", source);
+                       ghb_add_subtitle(ud, subtitle);
+               }
+       }
+}
+
+void
+ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud)
+{
+       gint track;
+       GHashTable *track_indices;
+       gchar *lang, *pref_lang = NULL;
+       gchar *audio_lang;
+       gint foreign_lang_index = -1;
+       gboolean found_cc = FALSE;
+
+       const GValue *pref_subtitle;
+       GValue *subtitle;
+       gint count, ii, jj;
+       
+       g_debug("ghb_set_pref_subtitle %d", titleindex);
+
+       // Check to see if we need to add a subtitle track for foreign audio
+       // language films. A subtitle track will be added if:
+       //
+       // The first (default) audio track language does NOT match the users
+       // chosen Preferred Language AND the Preferred Language is NOT Any (und).
+       //
+       audio_lang = ghb_get_user_audio_lang(ud, titleindex, 0);
+       pref_lang = ghb_settings_get_string(ud->settings, "PreferredLanguage");
+
+       if (audio_lang != NULL && pref_lang != NULL &&
+               (strcmp(audio_lang, pref_lang) == 0 || strcmp("und", pref_lang) == 0))
+       {
+               g_free(pref_lang);
+               pref_lang = NULL;
+       }
+
+       track_indices = g_hash_table_new_full(g_str_hash, g_str_equal, 
+                                                                                       free_subtitle_key, free_subtitle_index_list);
+
+       ghb_ui_update(ud, "SubtitleTrack", ghb_int_value(0));
+
+       // Clear the subtitle list
+       ghb_clear_subtitle_list(ud);
+       if (titleindex < 0)
+       {
+               add_all_pref_subtitles(ud);
+               return;
+       }
+
+       // Find "best" subtitle based on subtitle preferences
+       pref_subtitle = ghb_settings_get_value(ud->settings, "SubtitleList");
+
+       count = ghb_array_len(pref_subtitle);
+       jj = 0;
+       for (ii = 0; ii < count; ii++)
+       {
+               gint source;
+               gboolean force, burn;
+
+               subtitle = ghb_array_get_nth(pref_subtitle, ii);
+               lang = ghb_settings_get_string(subtitle, "SubtitleLanguage");
+               source = ghb_settings_get_int(subtitle, "SubtitleSource");
+               burn = ghb_settings_get_boolean(subtitle, "SubtitleBurned");
+               force = ghb_settings_get_boolean(subtitle, "SubtitleForced");
+               // If there are multiple subtitles using the same language, then
+               // select sequential tracks for each.  The hash keeps track 
+               // of the tracks used for each language.
+               track = ghb_find_subtitle_track(titleindex, lang, burn, 
+                                                                               force, source, track_indices);
+               g_free(lang);
+               if (track >= -1)
+               {
+                       GValue *dup = ghb_value_dup(subtitle);
+                       lang = ghb_subtitle_track_lang(ud, track);
+                       ghb_settings_set_int(dup, "SubtitleTrack", track);
+                       if (foreign_lang_index < 0 && pref_lang != NULL &&
+                               strcmp(lang, pref_lang) == 0)
+                       {
+                               foreign_lang_index = jj;
+                               ghb_settings_take_value(dup, "SubtitleForced", 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_settings_take_value(dup, "SubtitleDefaultTrack", 
+                                                               ghb_boolean_value_new(TRUE));
+                       }
+                       source = ghb_subtitle_track_source(ud, track);
+                       ghb_settings_set_int(dup, "SubtitleSource", source);
+                       if (source == CC608SUB || source == CC708SUB)
+                               found_cc = TRUE;
+                       ghb_add_subtitle(ud, dup);
+                       jj++;
+                       g_free(lang);
+               }
+       }
+       if (foreign_lang_index < 0 && pref_lang != NULL)
+       {
+               // Subtitle for foreign language audio not added yet
+               GValue *settings;
+               gboolean burn;
+
+               track = ghb_find_subtitle_track(titleindex, pref_lang, FALSE, FALSE, VOBSUB, track_indices);
+               if (track >= -1)
+               {
+                       int source;
+
+                       settings = ghb_dict_value_new();
+                       ghb_settings_set_int(settings, "SubtitleTrack", track);
+                       source = ghb_subtitle_track_source(ud, track);
+                       ghb_settings_set_int(settings, "SubtitleSource", source);
+                       burn = mustBurn(ud, settings);
+                       ghb_settings_take_value(settings, "SubtitleForced", 
+                                                       ghb_boolean_value_new(FALSE));
+                       ghb_settings_take_value(settings, "SubtitleBurned", 
+                                                       ghb_boolean_value_new(burn));
+                       ghb_settings_take_value(settings, "SubtitleDefaultTrack", 
+                                                       ghb_boolean_value_new(TRUE));
+
+                       ghb_add_subtitle(ud, settings);
+                       foreign_lang_index = jj;
+               }
+       }
+       if (foreign_lang_index >= 0)
+       {
+               GValue *subtitle_list;
+               gboolean burn, def;
+
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               subtitle = ghb_array_get_nth(subtitle_list, foreign_lang_index);
+
+               burn = ghb_settings_get_boolean(subtitle, "SubtitleBurned");
+               def = ghb_settings_get_boolean(subtitle, "SubtitleDefaultTrack");
+               if (burn)
+                       ghb_subtitle_exclusive_burn(ud, foreign_lang_index);
+               if (def)
+                       ghb_subtitle_exclusive_default(ud, foreign_lang_index);
+               ghb_log("adding subtitle for foreign language audio: %s", audio_lang);
+       }
+       if (ghb_settings_get_boolean(ud->settings, "AddCC") && !found_cc)
+       {
+               // Subtitle for foreign language audio not added yet
+               GValue *settings;
+
+               track = ghb_find_cc_track(titleindex);
+               if (track >= 0)
+               {
+                       int source;
+
+                       settings = ghb_dict_value_new();
+                       ghb_settings_set_int(settings, "SubtitleTrack", track);
+                       source = ghb_subtitle_track_source(ud, track);
+                       ghb_settings_set_int(settings, "SubtitleSource", source);
+                       ghb_settings_take_value(settings, "SubtitleForced", 
+                                                       ghb_boolean_value_new(FALSE));
+                       ghb_settings_take_value(settings, "SubtitleBurned", 
+                                                       ghb_boolean_value_new(FALSE));
+                       ghb_settings_take_value(settings, "SubtitleDefaultTrack", 
+                                                       ghb_boolean_value_new(FALSE));
+
+                       ghb_add_subtitle(ud, settings);
+                       ghb_log("adding Closed Captions: %s", audio_lang);
+               }
+       }
+       if (pref_lang != NULL)
+               g_free(pref_lang);
+       if (audio_lang != NULL)
+               g_free(audio_lang);
+       g_hash_table_destroy(track_indices);
+}
+
+gint
+ghb_selected_subtitle_row(signal_user_data_t *ud)
+{
+       GtkTreeView *treeview;
+       GtkTreePath *treepath;
+       GtkTreeSelection *selection;
+       GtkTreeModel *store;
+       GtkTreeIter iter;
+       gint *indices;
+       gint row = -1;
+       
+       g_debug("ghb_selected_subtitle_row ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       if (gtk_tree_selection_get_selected(selection, &store, &iter))
+       {
+               // Get the row number
+               treepath = gtk_tree_model_get_path (store, &iter);
+               indices = gtk_tree_path_get_indices (treepath);
+               row = indices[0];
+               gtk_tree_path_free(treepath);
+       }
+       return row;
+}
+
+GValue*
+ghb_selected_subtitle_settings(signal_user_data_t *ud)
+{
+       GtkTreeView *treeview;
+       GtkTreePath *treepath;
+       GtkTreeSelection *selection;
+       GtkTreeModel *store;
+       GtkTreeIter iter;
+       gint *indices;
+       gint row;
+       GValue *settings = NULL;
+       const GValue *subtitle_list;
+       
+       g_debug("get_selected_settings ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       if (gtk_tree_selection_get_selected(selection, &store, &iter))
+       {
+               // Get the row number
+               treepath = gtk_tree_model_get_path (store, &iter);
+               indices = gtk_tree_path_get_indices (treepath);
+               row = indices[0];
+               gtk_tree_path_free(treepath);
+               // find subtitle settings
+               if (row < 0) return NULL;
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               if (row >= ghb_array_len(subtitle_list))
+                       return NULL;
+               settings = ghb_array_get_nth(subtitle_list, row);
+       }
+       return settings;
+}
+
+G_MODULE_EXPORT void
+subtitle_forced_toggled_cb(
+       GtkCellRendererToggle *cell, 
+       gchar                 *path,
+       signal_user_data_t    *ud)
+{
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       gboolean      active;
+       gint          row;
+       GtkTreePath  *tp;
+       gint *indices;
+       GValue *subtitle_list, *settings;
+       gint source;
+
+       g_debug("forced toggled");
+       tp = gtk_tree_path_new_from_string (path);
+       tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       g_return_if_fail(tv != NULL);
+       tm = gtk_tree_view_get_model(tv);
+       g_return_if_fail(tm != NULL);
+       gtk_tree_model_get_iter(tm, &ti, tp);
+       gtk_tree_model_get(tm, &ti, 1, &active, -1);
+       active ^= 1;
+
+       // Get the row number
+       indices = gtk_tree_path_get_indices (tp);
+       row = indices[0];
+       gtk_tree_path_free(tp);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+
+       if (row < 0 || row >= ghb_array_len(subtitle_list))
+               return;
+
+       settings = ghb_array_get_nth(subtitle_list, row);
+
+       source = ghb_settings_get_int(settings, "SubtitleSource");
+       if (source != VOBSUB)
+               return;
+
+       ghb_settings_set_boolean(settings, "SubtitleForced", active);
+       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 1, active, -1);
+       ghb_live_reset(ud);
+}
+
+G_MODULE_EXPORT void
+subtitle_burned_toggled_cb(
+       GtkCellRendererToggle *cell, 
+       gchar                 *path,
+       signal_user_data_t    *ud)
+{
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       GtkTreePath  *tp;
+       gboolean      active;
+       gint          row;
+       gint *indices;
+       GValue *subtitle_list;
+       gint count;
+       GValue *settings;
+       gint source;
+
+       g_debug("burned toggled");
+       tp = gtk_tree_path_new_from_string (path);
+       tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       g_return_if_fail(tv != NULL);
+       tm = gtk_tree_view_get_model(tv);
+       g_return_if_fail(tm != NULL);
+       gtk_tree_model_get_iter(tm, &ti, tp);
+       gtk_tree_model_get(tm, &ti, 2, &active, -1);
+       active ^= 1;
+
+       // Get the row number
+       indices = gtk_tree_path_get_indices (tp);
+       row = indices[0];
+       gtk_tree_path_free(tp);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       if (row < 0 || row >= count)
+               return;
+
+       settings = ghb_array_get_nth(subtitle_list, row);
+       source = ghb_settings_get_int(settings, "SubtitleSource");
+       if (source != VOBSUB)
+               return;
+       if (!active && mustBurn(ud, settings))
+               return;
+
+       ghb_settings_set_boolean(settings, "SubtitleBurned", active);
+       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 2, active, -1);
+
+       if (active)
+       {
+               ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", !active);
+               gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 3, !active, -1);
+       }
+
+       // Unburn the rest
+       if (active)
+               ghb_subtitle_exclusive_burn(ud, row);
+       ghb_update_destination_extension(ud);
+       ghb_live_reset(ud);
+}
+
+G_MODULE_EXPORT void
+subtitle_default_toggled_cb(
+       GtkCellRendererToggle *cell, 
+       gchar                 *path,
+       signal_user_data_t    *ud)
+{
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       GtkTreePath  *tp;
+       gboolean      active;
+       gint          row;
+       gint *indices;
+       GValue *subtitle_list;
+       gint count;
+       GValue *settings;
+       gboolean burned;
+
+       g_debug("default toggled");
+       tp = gtk_tree_path_new_from_string (path);
+       tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       g_return_if_fail(tv != NULL);
+       tm = gtk_tree_view_get_model(tv);
+       g_return_if_fail(tm != NULL);
+       gtk_tree_model_get_iter(tm, &ti, tp);
+       gtk_tree_model_get(tm, &ti, 3, &active, -1);
+       active ^= 1;
+
+       // Get the row number
+       indices = gtk_tree_path_get_indices (tp);
+       row = indices[0];
+       gtk_tree_path_free(tp);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       if (row < 0 || row >= count)
+               return;
+
+       settings = ghb_array_get_nth(subtitle_list, row);
+       if (active && mustBurn(ud, settings))
+               return;
+
+       ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active);
+       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 3, active, -1);
+
+       if (active)
+       {
+               ghb_settings_set_boolean(settings, "SubtitleBurned", !active);
+               gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 2, !active, -1);
+       }
+       // allow only one default
+       ghb_subtitle_exclusive_default(ud, row);
+       ghb_live_reset(ud);
+}
+
+static const char*
+subtitle_source_name(gint source)
+{
+       const gchar * name;
+
+       switch (source)
+       {
+               case VOBSUB:
+                       name = "Bitmap";
+                       break;
+               case CC708SUB:
+               case CC608SUB:
+                       name = "Text";
+                       break;
+               case SRTSUB:
+                       name = "SRT";
+                       break;
+               default:
+                       name = "Unknown";
+                       break;
+       }
+       return name;
+}
+
+static void
+subtitle_list_refresh_selected(signal_user_data_t *ud)
+{
+       GtkTreeView *treeview;
+       GtkTreePath *treepath;
+       GtkTreeSelection *selection;
+       GtkTreeModel *store;
+       GtkTreeIter iter;
+       gint *indices;
+       gint row;
+       GValue *settings = NULL;
+       const GValue *subtitle_list;
+       
+       g_debug("subtitle_list_refresh_selected ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       if (gtk_tree_selection_get_selected(selection, &store, &iter))
+       {
+               gchar *track, *source;
+               gboolean forced, burned, def;
+               gchar *s_track;
+               gint offset = 0;
+       
+               // Get the row number
+               treepath = gtk_tree_model_get_path (store, &iter);
+               indices = gtk_tree_path_get_indices (treepath);
+               row = indices[0];
+               gtk_tree_path_free(treepath);
+               if (row < 0) return;
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               if (row >= ghb_array_len(subtitle_list))
+                       return;
+               settings = ghb_array_get_nth(subtitle_list, row);
+
+               def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+               gint i_source;
+               i_source = ghb_settings_get_int(settings, "SubtitleSource");
+               if (i_source != VOBSUB)
+               {
+                       // Force and burn only apply to VOBSUBS
+                       forced = FALSE;
+                       burned = FALSE;
+                       ghb_settings_set_boolean(settings, "SubtitleForced", forced);
+                       ghb_settings_set_boolean(settings, "SubtitleBurned", burned);
+               }
+
+               if (i_source == SRTSUB)
+               {
+                       const gchar *lang;
+                       gchar *code;
+
+                       lang = ghb_settings_combo_option(settings, "SrtLanguage");
+                       code = ghb_settings_get_string(settings, "SrtCodeset");
+                       track = g_strdup_printf("%s (%s)", lang, code);
+                       g_free(code);
+
+                       s_track = ghb_settings_get_string(settings, "SrtFile");
+                       if (g_file_test(s_track, G_FILE_TEST_IS_REGULAR))
+                       {
+                               gchar *basename;
+
+                               basename = g_path_get_basename(s_track);
+                               source = g_strdup_printf("SRT (%s)", basename);
+                               g_free(basename);
+                       }
+                       else
+                       {
+                               source = g_strdup_printf("SRT (none)");
+                       }
+                       offset = ghb_settings_get_int(settings, "SrtOffset");
+
+                       forced = FALSE;
+                       burned = FALSE;
+               }
+               else
+               {
+                       track = g_strdup(
+                               ghb_settings_combo_option(settings, "SubtitleTrack"));
+                       source = g_strdup(subtitle_source_name(i_source));
+                       s_track = ghb_settings_get_string(settings, "SubtitleTrack");
+
+                       forced = ghb_settings_get_boolean(settings, "SubtitleForced");
+                       burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+               }
+
+               gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
+                       // These are displayed in list
+                       0, track,
+                       1, forced,
+                       2, burned,
+                       3, def,
+                       4, source,
+                       5, offset,
+                       // These are used to set combo box values when a list item is selected
+                       6, s_track,
+                       7, i_source,
+                       -1);
+               g_free(track);
+               g_free(source);
+               g_free(s_track);
+               if (burned)
+                       ghb_subtitle_exclusive_burn(ud, row);
+       }
+}
+
+G_MODULE_EXPORT void
+subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       GValue *settings;
+
+       g_debug("subtitle_track_changed_cb ()");
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_widget_to_setting(ud->settings, widget);
+       settings = ghb_selected_subtitle_settings(ud);
+       if (settings != NULL)
+       {
+               const gchar *track, *lang;
+               gint tt, source;
+
+               ghb_widget_to_setting(settings, widget);
+               track = ghb_settings_combo_option(settings, "SubtitleTrack");
+               ghb_settings_set_string(settings, "SubtitleTrackDescription", track);
+               tt = ghb_settings_get_int(settings, "SubtitleTrack");
+               source = ghb_subtitle_track_source(ud, tt);
+               ghb_settings_set_int(settings, "SubtitleSource", source);
+               lang = ghb_settings_combo_string(settings, "SubtitleTrack");
+               ghb_settings_set_string(settings, "SubtitleLanguage", lang);
+               subtitle_list_refresh_selected(ud);
+               ghb_live_reset(ud);
+       }
+       ghb_live_reset(ud);
+}
+
+G_MODULE_EXPORT void
+srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       GValue *settings;
+
+       g_debug("srt_changed_cb ()");
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_widget_to_setting(ud->settings, widget);
+       settings = ghb_selected_subtitle_settings(ud);
+       if (settings != NULL)
+       {
+               ghb_widget_to_setting(settings, widget);
+               subtitle_list_refresh_selected(ud);
+
+               ghb_live_reset(ud);
+       }
+}
+
+G_MODULE_EXPORT void
+srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       GValue *settings;
+
+       g_debug("srt_file_changed_cb ()");
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_widget_to_setting(ud->settings, widget);
+       settings = ghb_selected_subtitle_settings(ud);
+       if (settings != NULL)
+       {
+               gchar *filename, *dirname;
+
+               ghb_widget_to_setting(settings, widget);
+               subtitle_list_refresh_selected(ud);
+
+               ghb_live_reset(ud);
+
+               filename = ghb_settings_get_string(settings, "SrtFile");
+               if (g_file_test(filename, G_FILE_TEST_IS_DIR))
+               {
+                       ghb_settings_set_string(ud->settings, "SrtDir", filename);
+               }
+               else
+               {
+                       dirname = g_path_get_dirname(filename);
+                       ghb_settings_set_string(ud->settings, "SrtDir", dirname);
+                       g_free(dirname);
+               }
+               ghb_pref_save(ud->settings, "SrtDir");
+               g_free(filename);
+       }
+}
+
+G_MODULE_EXPORT void
+srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       GValue *settings;
+
+       g_debug("srt_lang_changed_cb ()");
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_widget_to_setting(ud->settings, widget);
+       settings = ghb_selected_subtitle_settings(ud);
+       if (settings != NULL)
+       {
+               const gchar *lang;
+
+               ghb_widget_to_setting(settings, widget);
+               subtitle_list_refresh_selected(ud);
+
+               ghb_live_reset(ud);
+
+               lang = ghb_settings_combo_option(settings, "SrtLanguage");
+               ghb_settings_set_string(settings, "SubtitleTrackDescription", lang);
+       }
+}
+
+void
+ghb_clear_subtitle_list(signal_user_data_t *ud)
+{
+       GtkTreeView *treeview;
+       GtkListStore *store;
+       GValue *subtitle_list;
+       
+       g_debug("clear_subtitle_list ()");
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       if (subtitle_list == NULL)
+       {
+               subtitle_list = ghb_array_value_new(8);
+               ghb_settings_set_value(ud->settings, "subtitle_list", subtitle_list);
+       }
+       else
+               ghb_array_value_reset(subtitle_list, 8);
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+       gtk_list_store_clear (store);
+}
+
+static void
+add_to_subtitle_list(
+       signal_user_data_t *ud, 
+       GValue *settings)
+{
+       GtkTreeView *treeview;
+       GtkTreeIter iter;
+       GtkListStore *store;
+       GtkTreeSelection *selection;
+       const gchar *track, *source;
+       gboolean forced, burned, def;
+       gchar *s_track;
+       gint i_source;
+       
+       g_debug("add_to_subtitle_list ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+
+       track = ghb_settings_combo_option(settings, "SubtitleTrack");
+       forced = ghb_settings_get_boolean(settings, "SubtitleForced");
+       burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+       def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+       s_track = ghb_settings_get_string(settings, "SubtitleTrack");
+       i_source = ghb_settings_get_int(settings, "SubtitleSource");
+       source = subtitle_source_name(i_source);
+
+       gtk_list_store_append(store, &iter);
+       gtk_list_store_set(store, &iter, 
+               // These are displayed in list
+               0, track,
+               1, forced,
+               2, burned,
+               3, def,
+               4, source,
+               // These are used to set combo box values when a list item is selected
+               6, s_track,
+               7, i_source,
+               8, TRUE,
+               9, TRUE,
+               10, FALSE,
+               -1);
+       gtk_tree_selection_select_iter(selection, &iter);
+       g_free(s_track);
+}
+
+static void
+add_to_srt_list(
+       signal_user_data_t *ud, 
+       GValue *settings)
+{
+       GtkTreeView *treeview;
+       GtkTreeIter iter;
+       GtkListStore *store;
+       GtkTreeSelection *selection;
+       const gchar *lang;
+       gboolean forced, burned, def;
+       gchar *filename, *code, *track, *source;
+       gint i_source, offset;
+       
+       g_debug("add_to_srt_list ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
+
+       lang = ghb_settings_combo_option(settings, "SrtLanguage");
+       code = ghb_settings_get_string(settings, "SrtCodeset");
+       track = g_strdup_printf("%s (%s)", lang, code);
+       forced = FALSE;
+       burned = FALSE;
+       def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+       filename = ghb_settings_get_string(settings, "SrtFile");
+       if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+       {
+               gchar *basename;
+
+               basename = g_path_get_basename(filename);
+               source = g_strdup_printf("SRT (%s)", basename);
+               g_free(basename);
+       }
+       else
+       {
+               source = g_strdup_printf("SRT (none)");
+       }
+       i_source = SRTSUB;
+       offset = ghb_settings_get_int(settings, "SrtOffset");
+
+       gtk_list_store_append(store, &iter);
+       gtk_list_store_set(store, &iter, 
+               // These are displayed in list
+               0, track,
+               1, forced,
+               2, burned,
+               3, def,
+               4, source,
+               5, offset,
+               // These are used to set combo box values when a list item is selected
+               6, filename,
+               7, i_source,
+               8, FALSE,
+               9, FALSE,
+               10, TRUE,
+               -1);
+       gtk_tree_selection_select_iter(selection, &iter);
+       g_free(code);
+       g_free(track);
+       g_free(filename);
+       g_free(source);
+}
+
+G_MODULE_EXPORT void
+subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
+{
+       GtkTreeModel *store;
+       GtkTreeIter iter;
+       GtkWidget *widget;
+       
+       g_debug("subtitle_list_selection_changed_cb ()");
+       if (gtk_tree_selection_get_selected(selection, &store, &iter))
+       {
+               gint source;
+               GtkTreePath *treepath;
+               gint *indices, row;
+               GValue *subtitle_list, *settings;
+
+               treepath = gtk_tree_model_get_path (store, &iter);
+               indices = gtk_tree_path_get_indices (treepath);
+               row = indices[0];
+               gtk_tree_path_free(treepath);
+
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               if (row >= ghb_array_len(subtitle_list))
+                       return;
+
+               settings = ghb_array_get_nth(subtitle_list, row);
+
+               source = ghb_settings_get_int(settings, "SubtitleSource");
+               if (source == SRTSUB)
+               {
+                       gchar *str;
+                       gint offset;
+
+                       str = ghb_settings_get_string(settings, "SrtLanguage");
+                       ghb_ui_update(ud, "SrtLanguage", ghb_string_value(str));
+                       g_free(str);
+
+                       str = ghb_settings_get_string(settings, "SrtCodeset");
+                       ghb_ui_update(ud, "SrtCodeset", ghb_string_value(str));
+                       g_free(str);
+
+                       str = ghb_settings_get_string(settings, "SrtFile");
+                       ghb_ui_update(ud, "SrtFile", ghb_string_value(str));
+                       g_free(str);
+
+                       offset = ghb_settings_get_int(settings, "SrtOffset");
+                       ghb_ui_update(ud, "SrtOffset", ghb_int_value(offset));
+
+                       widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_lang_label");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_code_label");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_file_label");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_offset_label");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtLanguage");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtCodeset");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtFile");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtOffset");
+                       gtk_widget_show(widget);
+               }
+               else
+               {
+                       gchar *track;
+
+                       track = ghb_settings_get_string(settings, "SubtitleTrack");
+                       ghb_ui_update(ud, "SubtitleTrack", ghb_string_value(track));
+                       g_free(track);
+
+                       widget = GHB_WIDGET(ud->builder, "srt_lang_label");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_code_label");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_file_label");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "srt_offset_label");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtLanguage");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtCodeset");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtFile");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "SrtOffset");
+                       gtk_widget_hide(widget);
+                       widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+                       gtk_widget_show(widget);
+                       widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
+                       gtk_widget_show(widget);
+               }
+               widget = GHB_WIDGET (ud->builder, "subtitle_remove");
+               gtk_widget_set_sensitive(widget, TRUE);
+       }
+       else
+       {
+               widget = GHB_WIDGET(ud->builder, "srt_lang_label");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "srt_code_label");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "srt_file_label");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "srt_offset_label");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "SrtLanguage");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "SrtCodeset");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "SrtFile");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "SrtOffset");
+               gtk_widget_hide(widget);
+               widget = GHB_WIDGET(ud->builder, "subtitle_track_label");
+               gtk_widget_show(widget);
+               widget = GHB_WIDGET(ud->builder, "SubtitleTrack");
+               gtk_widget_show(widget);
+       }
+}
+
+G_MODULE_EXPORT void
+srt_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       // Add the current subtitle settings to the list.
+       GValue *settings;
+       gchar *dir, *filename;
+       
+       g_debug("subtitle_add_clicked_cb ()");
+
+       settings = ghb_dict_value_new();
+       ghb_settings_set_int(settings, "SubtitleSource", SRTSUB);
+       ghb_settings_set_string(settings, "SrtLanguage", "und");
+       ghb_settings_set_string(settings, "SrtCodeset", "UTF-8");
+
+       dir = ghb_settings_get_string(ud->settings, "SrtDir");
+       filename = g_strdup_printf("%s/none", dir);
+       ghb_settings_set_string(settings, "SrtFile", filename);
+       g_free(dir);
+       g_free(filename);
+
+       ghb_settings_set_int(settings, "SrtOffset", 0);
+       ghb_settings_take_value(settings, "SubtitleDefaultTrack", 
+                                                       ghb_boolean_value_new(FALSE));
+
+       ghb_add_srt(ud, settings);
+}
+
+G_MODULE_EXPORT void
+subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
+{
+       // Add the current subtitle settings to the list.
+       GValue *settings;
+       gboolean burned = FALSE;
+       gint track, source;
+       
+       g_debug("subtitle_add_clicked_cb ()");
+
+       track = ghb_settings_get_int(ud->settings, "SubtitleTrack");
+
+       settings = ghb_dict_value_new();
+       ghb_settings_set_int(settings, "SubtitleTrack", track);
+       source = ghb_subtitle_track_source(ud, track);
+       ghb_settings_set_int(settings, "SubtitleSource", source);
+       if (mustBurn(ud, settings))
+       {
+               burned = TRUE;
+       }
+       ghb_settings_take_value(settings, "SubtitleForced", 
+                                                       ghb_boolean_value_new(FALSE));
+       ghb_settings_take_value(settings, "SubtitleBurned", 
+                                                       ghb_boolean_value_new(burned));
+       ghb_settings_take_value(settings, "SubtitleDefaultTrack", 
+                                                       ghb_boolean_value_new(FALSE));
+
+       ghb_add_subtitle(ud, settings);
+}
+
+G_MODULE_EXPORT void
+subtitle_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       GtkTreeView *treeview;
+       GtkTreePath *treepath;
+       GtkTreeSelection *selection;
+       GtkTreeModel *store;
+       GtkTreeIter iter, nextIter;
+       gint *indices;
+       gint row;
+       GValue *subtitle_list;
+
+       g_debug("subtitle_remove_clicked_cb ()");
+       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       selection = gtk_tree_view_get_selection (treeview);
+       if (gtk_tree_selection_get_selected(selection, &store, &iter))
+       {
+               nextIter = iter;
+               if (!gtk_tree_model_iter_next(store, &nextIter))
+               {
+                       nextIter = iter;
+                       if (gtk_tree_model_get_iter_first(store, &nextIter))
+                       {
+                               gtk_tree_selection_select_iter (selection, &nextIter);
+                       }
+               }
+               else
+               {
+                       gtk_tree_selection_select_iter (selection, &nextIter);
+               }
+               // Get the row number
+               treepath = gtk_tree_model_get_path (store, &iter);
+               indices = gtk_tree_path_get_indices (treepath);
+               row = indices[0];
+               gtk_tree_path_free(treepath);
+               // Remove the selected item
+               gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
+               // remove from subtitle settings list
+               if (row < 0) return;
+               widget = GHB_WIDGET (ud->builder, "subtitle_add");
+               gtk_widget_set_sensitive(widget, TRUE);
+               widget = GHB_WIDGET (ud->builder, "srt_add");
+               gtk_widget_set_sensitive(widget, TRUE);
+               subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+               if (row >= ghb_array_len(subtitle_list))
+                       return;
+               GValue *old = ghb_array_get_nth(subtitle_list, row);
+               ghb_value_free(old);
+               ghb_array_remove(subtitle_list, row);
+               ghb_live_reset(ud);
+       }
+}
+
+void
+ghb_subtitle_prune(signal_user_data_t *ud)
+{
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       GValue *subtitle_list;
+       gint count, ii;
+       gint first_track = 0, one_burned = 0;
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       if (subtitle_list == NULL)
+               return;
+       count = ghb_array_len(subtitle_list);
+
+       tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       g_return_if_fail(tv != NULL);
+       tm = gtk_tree_view_get_model(tv);
+       for (ii = count-1; ii >= 0; ii--)
+       {
+               gboolean burned;
+               GValue *settings;
+
+               settings = ghb_array_get_nth(subtitle_list, ii);
+               burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+               if (!burned && mustBurn(ud, settings))
+               {
+                       gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+                       gtk_list_store_remove (GTK_LIST_STORE(tm), &ti);
+                       ghb_array_remove(subtitle_list, ii);
+               }
+               if (burned)
+               {
+                       first_track = ii;
+                       one_burned++;
+               }
+       }
+       if (one_burned)
+       {
+               ghb_subtitle_exclusive_burn(ud, first_track);
+       }
+}
+
+void
+ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings)
+{
+       GValue *slist;
+       GValue *subtitle;
+       gint count, ii;
+       gint titleindex;
+       
+       g_debug("ghb_reset_subtitles");
+       ghb_clear_subtitle_list(ud);
+       titleindex = ghb_settings_combo_int(ud->settings, "title");
+       if (titleindex < 0)
+               return;
+
+       slist = ghb_settings_get_value(settings, "subtitle_list");
+       count = ghb_array_len(slist);
+       for (ii = 0; ii < count; ii++)
+       {
+               int source;
+
+               subtitle = ghb_value_dup(ghb_array_get_nth(slist, ii));
+               source = ghb_settings_get_int(subtitle, "SubtitleSource");
+               if (source == SRTSUB)
+                       ghb_add_srt(ud, subtitle);
+               else
+                       ghb_add_subtitle(ud, subtitle);
+       }
+}
+
diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h
new file mode 100644 (file)
index 0000000..c0970d0
--- /dev/null
@@ -0,0 +1,41 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * subtitlehandler.h
+ * Copyright (C) John Stebbins 2008 <stebbins@stebbins>
+ * 
+ * audiohandler.h is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * callbacks.h is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with callbacks.h.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+
+#if !defined(_SUBTITLEHANDLER_H_)
+#define _SUBTITLEHANDLER_H_
+
+#include "settings.h"
+
+void ghb_set_pref_subtitle(gint titleindex, signal_user_data_t *ud);
+void ghb_clear_subtitle_list(signal_user_data_t *ud);
+void ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings);
+GValue* ghb_selected_subtitle_settings(signal_user_data_t *ud);
+gint ghb_selected_subtitle_row(signal_user_data_t *ud);
+void ghb_add_subtitle(
+       signal_user_data_t *ud, GValue *settings);
+void ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings);
+void ghb_subtitle_prune(signal_user_data_t *ud);
+gboolean ghb_soft_in_subtitle_list(GValue *subtitle_list);
+
+#endif // _SUBTITLEHANDLER_H_
index 94b417f..17319a5 100644 (file)
@@ -15,6 +15,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <string.h>
+#include <inttypes.h>
 #include "values.h"
 
 static void dict_delete_key(gpointer data);
@@ -77,7 +78,43 @@ debug_show_type(GType tp)
        {
                str ="dict";
        }
-       g_debug("%s", str);
+       g_debug("Type %s", str);
+}
+
+void
+debug_show_value(GValue *gval)
+{
+       GType tp;
+
+       tp = G_VALUE_TYPE(gval);
+       if (tp == G_TYPE_STRING)
+       {
+               g_message("Type %s value %s", "string", g_value_get_string(gval));
+       }
+       else if (tp == G_TYPE_INT)
+       {
+               g_message("Type %s value %d", "int", g_value_get_int(gval));
+       }
+       else if (tp == G_TYPE_INT64)
+       {
+               g_message("Type %s value %" PRId64, "int64", g_value_get_int64(gval));
+       }
+       else if (tp == G_TYPE_DOUBLE)
+       {
+               g_message("Type %s value %f", "double", g_value_get_double(gval));
+       }
+       else if (tp == G_TYPE_BOOLEAN)
+       {
+               g_message("Type %s value %d", "boolean", g_value_get_boolean(gval));
+       }
+       else if (tp == ghb_array_get_type())
+       {
+               g_message("Type %s", "boolean");
+       }
+       else if (tp == ghb_dict_get_type())
+       {
+               g_message("Type %s", "dict");
+       }
 }
 
 gint
@@ -216,6 +253,10 @@ ghb_value_cmp(const GValue *vala, const GValue *valb)
        GType typa;
        GType typb;
 
+       if ((vala == NULL && valb != NULL) || (vala != NULL && valb == NULL))
+       {
+               return 1;
+       }
        typa = G_VALUE_TYPE(vala);
        typb = G_VALUE_TYPE(valb);
        if (typa != typb)
@@ -533,7 +574,7 @@ ghb_dict_iter_init(GHashTableIter *iter, GValue *gval)
 }
 
 GValue*
-ghb_dict_lookup(GValue *gval, const gchar *key)
+ghb_dict_lookup(const GValue *gval, const gchar *key)
 {
        GHashTable *dict = g_value_get_boxed(gval);
        return g_hash_table_lookup(dict, key);
index 4000ad6..d28727f 100644 (file)
@@ -67,9 +67,11 @@ GValue* ghb_rawdata_value_new(ghb_rawdata_t *data);
 
 void ghb_dict_insert(GValue *gval, gchar *key, GValue *val);
 void ghb_dict_iter_init(GHashTableIter *iter, GValue *gval);
-GValue* ghb_dict_lookup(GValue *gval, const gchar *key);
+GValue* ghb_dict_lookup(const GValue *gval, const gchar *key);
 gboolean ghb_dict_remove(GValue *gval, const gchar *key);
 void ghb_register_transforms(void);
 
+void debug_show_value(GValue *gval);
+void debug_show_type(GType tp);
 
 #endif // _GHB_VALUES_H_
diff --git a/gtk/src/widgetdeps.c b/gtk/src/widgetdeps.c
new file mode 100644 (file)
index 0000000..17502eb
--- /dev/null
@@ -0,0 +1,142 @@
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gstdio.h>
+#include <string.h>
+#include "values.h"
+#include "plist.h"
+
+typedef struct
+{
+       const gchar *widget_name;
+       const gchar *dep_name;
+       const gchar *enable_value;
+       const gboolean disable_if_equal;
+       const gboolean hide;
+} dependency_t;
+
+static dependency_t dep_map[] =
+{
+       {"title", "queue_add", "none", TRUE, FALSE},
+       {"title", "queue_add_menu", "none", TRUE, FALSE},
+       {"title", "preview_frame", "none", TRUE, FALSE},
+       {"title", "picture_label", "none", TRUE, FALSE},
+       {"title", "picture_tab", "none", TRUE, FALSE},
+       {"title", "chapters_label", "none", TRUE, FALSE},
+       {"title", "chapters_tab", "none", TRUE, FALSE},
+       {"title", "start_chapter", "none", TRUE, FALSE},
+       {"title", "end_chapter", "none", TRUE, FALSE},
+       {"title", "angle", "none", TRUE, FALSE},
+       {"use_dvdnav", "angle", "FALSE", TRUE, TRUE},
+       {"use_dvdnav", "angle_label", "FALSE", TRUE, TRUE},
+       {"vquality_type_bitrate", "VideoAvgBitrate", "TRUE", FALSE, FALSE},
+       {"vquality_type_target", "VideoTargetSize", "TRUE", FALSE, FALSE},
+       {"vquality_type_constant", "VideoQualitySlider", "TRUE", FALSE, FALSE},
+       {"vquality_type_constant", "VideoTwoPass", "TRUE", TRUE, FALSE},
+       {"vquality_type_constant", "VideoTurboTwoPass", "TRUE", TRUE, FALSE},
+       {"VideoTwoPass", "VideoTurboTwoPass", "TRUE", FALSE, FALSE},
+       {"FileFormat", "Mp4LargeFile", "mp4", FALSE, TRUE},
+       {"FileFormat", "Mp4HttpOptimize", "mp4", FALSE, TRUE},
+       {"FileFormat", "Mp4iPodCompatible", "mp4", FALSE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDeinterlace", "TRUE", TRUE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDeinterlaceCustom", "TRUE", TRUE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDeinterlaceLabel", "TRUE", TRUE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDecomb", "FALSE", TRUE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDecombCustom", "FALSE", TRUE, TRUE},
+       {"PictureDecombDeinterlace", "PictureDecombLabel", "FALSE", TRUE, TRUE},
+       {"PictureDeinterlace", "PictureDeinterlaceCustom", "custom", FALSE, TRUE},
+       {"PictureDenoise", "PictureDenoiseCustom", "custom", FALSE, TRUE},
+       {"PictureDecomb", "PictureDecombCustom", "custom", FALSE, TRUE},
+       {"PictureDetelecine", "PictureDetelecineCustom", "custom", FALSE, TRUE},
+       {"PictureAutoCrop", "PictureTopCrop", "FALSE", FALSE, FALSE},
+       {"PictureAutoCrop", "PictureBottomCrop", "FALSE", FALSE, FALSE},
+       {"PictureAutoCrop", "PictureLeftCrop", "FALSE", FALSE, FALSE},
+       {"PictureAutoCrop", "PictureRightCrop", "FALSE", FALSE, FALSE},
+       {"VideoEncoder", "x264_tab", "x264", FALSE, FALSE},
+       {"VideoEncoder", "x264_tab_label", "x264", FALSE, FALSE},
+       {"VideoEncoder", "Mp4iPodCompatible", "x264", FALSE, FALSE},
+       {"AudioEncoder", "AudioBitrate", "ac3|dts|auto", TRUE, FALSE},
+       {"AudioEncoder", "AudioSamplerate", "ac3|dts|auto", TRUE, FALSE},
+       {"AudioEncoder", "AudioMixdown", "ac3|dts|auto", TRUE, FALSE},
+       {"AudioEncoder", "AudioTrackDRCSlider", "ac3|dts|auto", TRUE, FALSE},
+       {"AudioEncoder", "drc_label", "ac3|dts|auto", TRUE, FALSE},
+       {"x264_bframes", "x264_weighted_bframes", "0", TRUE, FALSE},
+       {"x264_bframes", "x264_bpyramid", "<2", TRUE, FALSE},
+       {"x264_bframes", "x264_direct", "0", TRUE, FALSE},
+       {"x264_bframes", "x264_b_adapt", "0", TRUE, FALSE},
+       {"x264_refs", "x264_mixed_refs", "<2", TRUE, FALSE},
+       {"x264_cabac", "x264_trellis", "TRUE", FALSE, FALSE},
+       {"x264_subme", "x264_psy_rd", "<6", TRUE, FALSE},
+       {"x264_subme", "x264_psy_trell", "<6", TRUE, FALSE},
+       {"x264_cabac", "x264_psy_trell", "TRUE", FALSE, FALSE},
+       {"x264_trellis", "x264_psy_trell", "0", TRUE, FALSE},
+       {"x264_mbtree", "x264_bpyramid", "TRUE", TRUE, FALSE},
+       {"ChapterMarkers", "chapters_list", "TRUE", FALSE, FALSE},
+       {"use_source_name", "chapters_in_destination", "TRUE", FALSE, FALSE},
+       {"use_source_name", "title_no_in_destination", "TRUE", FALSE, FALSE},
+};
+
+int
+main(gint argc, gchar *argv[])
+{
+       gint ii, jj;
+       GValue *top;
+       gint count = sizeof(dep_map) / sizeof(dependency_t);
+
+       g_type_init();
+
+       top = ghb_dict_value_new();
+       for (ii = 0; ii < count; ii++)
+       {
+               const gchar *name;
+               GValue *array;
+
+               name = dep_map[ii].widget_name;
+               if (ghb_dict_lookup(top, name))
+                       continue;
+               array = ghb_array_value_new(8);
+               for (jj = 0; jj < count; jj++)
+               {
+                       if (strcmp(name, dep_map[jj].widget_name) == 0)
+                       {
+                               ghb_array_append(array,
+                                       ghb_value_dup(ghb_string_value(dep_map[jj].dep_name)));
+                       }
+               }
+               ghb_dict_insert(top, g_strdup(name), array);
+       }
+       ghb_plist_write_file("widget.deps", top);
+
+       // reverse map
+       top = ghb_dict_value_new();
+       for (ii = 0; ii < count; ii++)
+       {
+               const gchar *name;
+               GValue *array;
+
+               name = dep_map[ii].dep_name;
+               if (ghb_dict_lookup(top, name))
+                       continue;
+               array = ghb_array_value_new(8);
+               for (jj = 0; jj < count; jj++)
+               {
+                       if (strcmp(name, dep_map[jj].dep_name) == 0)
+                       {
+                               GValue *data;
+                               data = ghb_array_value_new(3);
+                               ghb_array_append(data, ghb_value_dup(
+                                       ghb_string_value(dep_map[jj].widget_name)));
+                               ghb_array_append(data, ghb_value_dup(
+                                       ghb_string_value(dep_map[jj].enable_value)));
+                               ghb_array_append(data, ghb_value_dup(
+                                       ghb_boolean_value(dep_map[jj].disable_if_equal)));
+                               ghb_array_append(data, ghb_value_dup(
+                                       ghb_boolean_value(dep_map[jj].hide)));
+                               ghb_array_append(array, data);
+                       }
+               }
+               ghb_dict_insert(top, g_strdup(name), array);
+       }
+       ghb_plist_write_file("widget_reverse.deps", top);
+       return 0;
+}
+
index 154defb..a466412 100644 (file)
 #include "values.h"
 #include "callbacks.h"
 #include "presets.h"
+#include "hb-backend.h"
 #include "x264handler.h"
 
+gint ghb_lookup_bframes(const gchar *options);
 static void x264_opt_update(signal_user_data_t *ud, GtkWidget *widget);
 static gchar* sanitize_x264opts(signal_user_data_t *ud, const gchar *options);
 
 // Flag needed to prevent x264 options processing from chasing its tail
 static gboolean ignore_options_update = FALSE;
 
-void
+G_MODULE_EXPORT void
 x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        ghb_widget_to_setting(ud->settings, widget);
@@ -35,11 +37,39 @@ x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
                x264_opt_update(ud, widget);
                ignore_options_update = FALSE;
        }
-       ghb_check_dependency(ud, widget);
+       ghb_check_dependency(ud, widget, NULL);
        ghb_clear_presets_selection(ud);
 }
 
-void
+G_MODULE_EXPORT void
+x264_me_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       gint me;
+
+       ghb_widget_to_setting(ud->settings, widget);
+       if (!ignore_options_update)
+       {
+               ignore_options_update = TRUE;
+               x264_opt_update(ud, widget);
+               ignore_options_update = FALSE;
+       }
+       ghb_check_dependency(ud, widget, NULL);
+       ghb_clear_presets_selection(ud);
+       widget = GHB_WIDGET(ud->builder, "x264_merange");
+       me = ghb_settings_combo_int(ud->settings, "x264_me");
+       if (me < 2)
+       {       // me < umh
+               // me_range 4 - 16
+               gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 16);
+       }
+       else
+       {
+               // me_range 4 - 64
+               gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 64);
+       }
+}
+
+G_MODULE_EXPORT void
 x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
        g_debug("x264_entry_changed_cb ()");
@@ -67,7 +97,7 @@ x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        }
 }
 
-gboolean
+G_MODULE_EXPORT gboolean
 x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, 
        signal_user_data_t *ud)
 {
@@ -77,7 +107,7 @@ x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
        options = ghb_settings_get_string(ud->settings, "x264Option");
        sopts = sanitize_x264opts(ud, options);
        ignore_options_update = TRUE;
-       if (sopts != NULL)
+       if (sopts != NULL && strcmp(sopts, options) != 0)
        {
                ghb_ui_update(ud, "x264Option", ghb_string_value(sopts));
                ghb_x264_parse_options(ud, sopts);
@@ -90,7 +120,11 @@ x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
 
 enum
 {
+       X264_OPT_NONE,
+       X264_OPT_BOOL_NONE,
+       X264_OPT_INT_NONE,
        X264_OPT_DEBLOCK,
+       X264_OPT_PSY,
        X264_OPT_INT,
        X264_OPT_COMBO,
        X264_OPT_BOOL,
@@ -108,6 +142,7 @@ struct x264_opt_map_s
 static gchar *x264_ref_syns[] = {"ref", "frameref", NULL};
 static gchar *x264_mixed_syns[] = {"mixed-refs", "mixed_refs", NULL};
 static gchar *x264_bframes_syns[] = {"bframes", NULL};
+static gchar *x264_badapt_syns[] = {"b-adapt", "b_adapt", NULL};
 static gchar *x264_direct_syns[] = 
        {"direct", "direct-pred", "direct_pred", NULL};
 static gchar *x264_weightb_syns[] = {"weightb", "weight-b", "weight_b", NULL};
@@ -115,11 +150,14 @@ static gchar *x264_bpyramid_syns[] = {"b-pyramid", "b_pyramid", NULL};
 static gchar *x264_me_syns[] = {"me", NULL};
 static gchar *x264_merange_syns[] = {"merange", "me-range", "me_range", NULL};
 static gchar *x264_subme_syns[] = {"subme", "subq", NULL};
+static gchar *x264_aqmode_syns[] = {"aq-mode", NULL};
 static gchar *x264_analyse_syns[] = {"analyse", "partitions", NULL};
 static gchar *x264_8x8dct_syns[] = {"8x8dct", NULL};
 static gchar *x264_deblock_syns[] = {"deblock", "filter", NULL};
 static gchar *x264_trellis_syns[] = {"trellis", NULL};
 static gchar *x264_pskip_syns[] = {"no-fast-pskip", "no_fast_pskip", NULL};
+static gchar *x264_psy_syns[] = {"psy-rd", "psy_rd", NULL};
+static gchar *x264_mbtree_syns[] = {"mbtree", NULL};
 static gchar *x264_decimate_syns[] = 
        {"no-dct-decimate", "no_dct_decimate", NULL};
 static gchar *x264_cabac_syns[] = {"cabac", NULL};
@@ -138,23 +176,28 @@ find_syn_match(const gchar *opt, gchar **syns)
 
 struct x264_opt_map_s x264_opt_map[] =
 {
-       {x264_ref_syns, "x264_refs", "1", X264_OPT_INT},
-       {x264_mixed_syns, "x264_mixed_refs", "0", X264_OPT_BOOL},
-       {x264_bframes_syns, "x264_bframes", "0", X264_OPT_INT},
+       {x264_ref_syns, "x264_refs", "3", X264_OPT_INT},
+       {x264_mixed_syns, "x264_mixed_refs", "1", X264_OPT_BOOL},
+       {x264_bframes_syns, "x264_bframes", "3", X264_OPT_INT},
        {x264_direct_syns, "x264_direct", "spatial", X264_OPT_COMBO},
-       {x264_weightb_syns, "x264_weighted_bframes", "0", X264_OPT_BOOL},
+       {x264_badapt_syns, "x264_b_adapt", "1", X264_OPT_COMBO},
+       {x264_weightb_syns, "x264_weighted_bframes", "1", X264_OPT_BOOL},
        {x264_bpyramid_syns, "x264_bpyramid", "0", X264_OPT_BOOL},
        {x264_me_syns, "x264_me", "hex", X264_OPT_COMBO},
        {x264_merange_syns, "x264_merange", "16", X264_OPT_INT},
-       {x264_subme_syns, "x264_subme", "6", X264_OPT_COMBO},
+       {x264_subme_syns, "x264_subme", "7", X264_OPT_COMBO},
+       {x264_aqmode_syns, "x264_aqmode", "1", X264_OPT_INT_NONE},
        {x264_analyse_syns, "x264_analyse", "some", X264_OPT_COMBO},
-       {x264_8x8dct_syns, "x264_8x8dct", "0", X264_OPT_BOOL},
+       {x264_8x8dct_syns, "x264_8x8dct", "1", X264_OPT_BOOL},
        {x264_deblock_syns, "x264_deblock_alpha", "0,0", X264_OPT_DEBLOCK},
        {x264_deblock_syns, "x264_deblock_beta", "0,0", X264_OPT_DEBLOCK},
-       {x264_trellis_syns, "x264_trellis", "0", X264_OPT_COMBO},
+       {x264_trellis_syns, "x264_trellis", "1", X264_OPT_COMBO},
        {x264_pskip_syns, "x264_no_fast_pskip", "0", X264_OPT_BOOL},
        {x264_decimate_syns, "x264_no_dct_decimate", "0", X264_OPT_BOOL},
        {x264_cabac_syns, "x264_cabac", "1", X264_OPT_BOOL},
+       {x264_psy_syns, "x264_psy_rd", "1,0", X264_OPT_PSY},
+       {x264_psy_syns, "x264_psy_trell", "1,0", X264_OPT_PSY},
+       {x264_mbtree_syns, "x264_mbtree", "1", X264_OPT_BOOL_NONE},
 };
 #define X264_OPT_MAP_SIZE (sizeof(x264_opt_map)/sizeof(struct x264_opt_map_s))
 
@@ -182,6 +225,17 @@ x264_update_int(signal_user_data_t *ud, const gchar *name, const gchar *val)
        ghb_ui_update(ud, name, ghb_int64_value(ival));
 }
 
+static void
+x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar *val)
+{
+       gint ival;
+
+       if (val == NULL) return;
+       ival = g_strtod (val, NULL);
+       ghb_settings_set_value(ud->settings, name, ghb_int64_value(ival));
+       ghb_check_dependency(ud, NULL, name);
+}
+
 static gchar *true_str[] =
 {
        "true",
@@ -212,12 +266,23 @@ x264_update_bool(signal_user_data_t *ud, const gchar *name, const gchar *val)
 }
 
 static void
+x264_update_bool_setting(signal_user_data_t *ud, const gchar *name, const gchar *val)
+{
+       if (val == NULL)
+               ghb_settings_set_value(ud->settings, name, ghb_boolean_value(1));
+       else
+               ghb_settings_set_value(ud->settings, name, ghb_boolean_value(str_is_true(val)));
+
+       ghb_check_dependency(ud, NULL, name);
+}
+
+static void
 x264_update_combo(signal_user_data_t *ud, const gchar *name, const gchar *val)
 {
        GtkTreeModel *store;
        GtkTreeIter iter;
        gchar *shortOpt;
-       gint ivalue;
+       gdouble ivalue;
        gboolean foundit = FALSE;
        GtkWidget *widget;
 
@@ -298,6 +363,42 @@ x264_update_deblock(signal_user_data_t *ud, const gchar *xval)
        ghb_ui_update(ud, "x264_deblock_beta", ghb_int64_value(bvalue));
 }
 
+static void
+x264_parse_psy(const gchar *psy, gdouble *psy_rd, gdouble *psy_trell)
+{
+       gchar *val;
+       gchar *trell_val = NULL;
+       gchar *end;
+
+       *psy_rd = 0.;
+       *psy_trell = 0.;
+       if (psy == NULL) return;
+       val = g_strdup(psy);
+       gchar *pos = strchr(val, ',');
+       if (pos != NULL)
+       {
+               trell_val = pos + 1;
+               *pos = 0;
+       }
+       *psy_rd = g_strtod (val, &end);
+       if (trell_val != NULL)
+       {
+               *psy_trell = g_strtod (trell_val, &end);
+       }
+       g_free(val);
+}
+
+static void
+x264_update_psy(signal_user_data_t *ud, const gchar *xval)
+{
+       gdouble rd_value, trell_value;
+
+       if (xval == NULL) return;
+       x264_parse_psy(xval, &rd_value, &trell_value);
+       ghb_ui_update(ud, "x264_psy_rd", ghb_double_value(rd_value));
+       ghb_ui_update(ud, "x264_psy_trell", ghb_double_value(trell_value));
+}
+
 void
 ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options)
 {
@@ -340,6 +441,17 @@ ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options)
                                        x264_opt_map[jj+1].found = TRUE;
                                        x264_update_deblock(ud, val);
                                        break;
+                               case X264_OPT_PSY:
+                                       // dirty little hack.  mark psy_trell found as well
+                                       x264_opt_map[jj+1].found = TRUE;
+                                       x264_update_psy(ud, val);
+                                       break;
+                               case X264_OPT_BOOL_NONE:
+                                       x264_update_bool_setting(ud, x264_opt_map[jj].name, val);
+                                       break;
+                               case X264_OPT_INT_NONE:
+                                       x264_update_int_setting(ud, x264_opt_map[jj].name, val);
+                                       break;
                                }
                                break;
                        }
@@ -366,6 +478,15 @@ ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options)
                        case X264_OPT_DEBLOCK:
                                x264_update_deblock(ud, val);
                                break;
+                       case X264_OPT_PSY:
+                               x264_update_psy(ud, val);
+                               break;
+                       case X264_OPT_BOOL_NONE:
+                               x264_update_bool_setting(ud, x264_opt_map[jj].name, val);
+                               break;
+                       case X264_OPT_INT_NONE:
+                               x264_update_int_setting(ud, x264_opt_map[jj].name, val);
+                               break;
                        }
                        x264_opt_map[jj].found = TRUE;
                        g_free(val);
@@ -387,6 +508,17 @@ get_deblock_val(signal_user_data_t *ud)
        return result;
 }
 
+gchar*
+get_psy_val(signal_user_data_t *ud)
+{
+       gdouble rd, trell;
+       gchar *result;
+       rd = ghb_settings_get_double(ud->settings, "x264_psy_rd");
+       trell = ghb_settings_get_double(ud->settings, "x264_psy_trell");
+       result = g_strdup_printf("%g,%g", rd, trell);
+       return result;
+}
+
 static void
 x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
 {
@@ -438,6 +570,8 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
                                foundit = TRUE;
                                if (type == X264_OPT_DEBLOCK)
                                        val = get_deblock_val(ud);
+                               else if (type == X264_OPT_PSY)
+                                       val = get_psy_val(ud);
                                else
                                {
                                        GValue *gval;
@@ -473,6 +607,8 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
                        gchar *val;
                        if (type == X264_OPT_DEBLOCK)
                                val = get_deblock_val(ud);
+                       else if (type == X264_OPT_PSY)
+                               val = get_psy_val(ud);
                        else
                        {
                                GValue *gval;
@@ -512,6 +648,29 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
        }
 }
 
+static gint
+x264_find_opt(gchar **opts, gchar **opt_syns)
+{
+       gint ii;
+       for (ii = 0; opts[ii] != NULL; ii++)
+       {
+               gchar *opt;
+               opt = g_strdup(opts[ii]);
+               gchar *pos = strchr(opt, '=');
+               if (pos != NULL)
+               {
+                       *pos = 0;
+               }
+               if (find_syn_match(opt, opt_syns) >= 0)
+               {
+                       g_free(opt);
+                       return ii;
+               }
+               g_free(opt);
+       }
+       return -1;
+}
+
 static void
 x264_remove_opt(gchar **opts, gchar **opt_syns)
 {
@@ -534,6 +693,122 @@ x264_remove_opt(gchar **opts, gchar **opt_syns)
        }
 }
 
+static gchar*
+x264_lookup_value(gchar **opts, gchar **opt_syns)
+{
+       gchar *ret = NULL;
+       gint pos;
+
+       const gchar *def_val = x264_opt_get_default(opt_syns[0]);
+
+       pos = x264_find_opt(opts, opt_syns);
+       if (pos >= 0)
+       {
+               gchar *cpos = strchr(opts[pos], '=');
+               if (cpos != NULL)
+               {
+                       ret = g_strdup(cpos+1);
+               }
+               else
+               {
+                       ret = g_strdup("");
+               }
+       }
+       else if (def_val != NULL)
+       {
+               ret = g_strdup(def_val);
+       }
+       return ret;
+}
+
+gint
+ghb_lookup_badapt(const gchar *options)
+{
+       gint ret = 0;
+       gchar *result;
+       gchar **split;
+       
+       if (options == NULL)
+               options = "";
+
+       split = g_strsplit(options, ":", -1);
+
+       result = x264_lookup_value(split, x264_badapt_syns);
+       g_strfreev(split);
+       if (result != NULL)
+       {
+               ret = g_strtod(result, NULL);
+               g_free(result);
+       }
+       return ret;
+}
+
+gint
+ghb_lookup_aqmode(const gchar *options)
+{
+       gint ret = 0;
+       gchar *result;
+       gchar **split;
+       
+       if (options == NULL)
+               options = "";
+
+       split = g_strsplit(options, ":", -1);
+
+       result = x264_lookup_value(split, x264_aqmode_syns);
+       g_strfreev(split);
+       if (result != NULL)
+       {
+               ret = g_strtod(result, NULL);
+               g_free(result);
+       }
+       return ret;
+}
+
+gint
+ghb_lookup_bframes(const gchar *options)
+{
+       gint ret = 0;
+       gchar *result;
+       gchar **split;
+       
+       if (options == NULL)
+               options = "";
+
+       split = g_strsplit(options, ":", -1);
+
+       result = x264_lookup_value(split, x264_bframes_syns);
+       g_strfreev(split);
+       if (result != NULL)
+       {
+               ret = g_strtod(result, NULL);
+               g_free(result);
+       }
+       return ret;
+}
+
+gint
+ghb_lookup_mbtree(const gchar *options)
+{
+       gint ret = ghb_lookup_bframes(options) != 0;
+       gchar *result;
+       gchar **split;
+       
+       if (options == NULL)
+               options = "";
+
+       split = g_strsplit(options, ":", -1);
+
+       result = x264_lookup_value(split, x264_mbtree_syns);
+       g_strfreev(split);
+       if (result != NULL)
+       {
+               ret = g_strtod(result, NULL);
+               g_free(result);
+       }
+       return ret;
+}
+
 // Construct the x264 options string
 // The result is allocated, so someone must free it at some point.
 static gchar*
@@ -541,30 +816,46 @@ sanitize_x264opts(signal_user_data_t *ud, const gchar *options)
 {
        GString *x264opts = g_string_new("");
        gchar **split = g_strsplit(options, ":", -1);
-
-       // Remove entries that match the defaults
        gint ii;
-       for (ii = 0; split[ii] != NULL; ii++)
+
+       // Fix up option dependencies
+       gboolean mbtree = ghb_lookup_mbtree(options);
+       if (mbtree)
        {
-               gchar *val = NULL;
-               gchar *opt = g_strdup(split[ii]);
-               gchar *pos = strchr(opt, '=');
-               if (pos != NULL)
-               {
-                       val = pos + 1;
-                       *pos = 0;
-               }
-               else
+               x264_remove_opt(split, x264_bpyramid_syns);
+       }
+       gint subme = ghb_settings_combo_int(ud->settings, "x264_subme");
+       if (subme < 6)
+       {
+               x264_remove_opt(split, x264_psy_syns);
+       }
+       gint trell = ghb_settings_combo_int(ud->settings, "x264_trellis");
+       if (subme == 10)
+       {
+               gint aqmode = ghb_lookup_aqmode(options);
+               if (trell != 2 || aqmode == 0)
                {
-                       val = "1";
+                       gint pos = x264_find_opt(split, x264_subme_syns);
+                       g_free(split[pos]);
+                       split[pos] = g_strdup_printf("subme=9");
                }
-               const gchar *def_val = x264_opt_get_default(opt);
-               if (strcmp(val, def_val) == 0)
+       }
+       if (trell < 1)
+       {
+               gint psy;
+               gdouble psy_rd = 0., psy_trell;
+
+               psy = x264_find_opt(split, x264_psy_syns);
+               if (psy >= 0)
                {
-                       // Matches the default, so remove it
-                       split[ii][0] = 0;
+                       gchar *pos = strchr(split[psy], '=');
+                       if (pos != NULL)
+                       {
+                               x264_parse_psy(pos+1, &psy_rd, &psy_trell);
+                       }
+                       g_free(split[psy]);
+                       split[psy] = g_strdup_printf("psy-rd=%g,0", psy_rd);
                }
-               g_free(opt);
        }
        gint refs = ghb_settings_get_int(ud->settings, "x264_refs");
        if (refs <= 1)
@@ -576,21 +867,47 @@ sanitize_x264opts(signal_user_data_t *ud, const gchar *options)
        {
                x264_remove_opt(split, x264_weightb_syns);
                x264_remove_opt(split, x264_direct_syns);
+               x264_remove_opt(split, x264_badapt_syns);
        }
        if (bframes <= 1)
        {
                x264_remove_opt(split, x264_bpyramid_syns);
        }
-       gchar *me = ghb_settings_get_string(ud->settings, "x264_me");
-       if (!(strcmp(me, "umh") == 0 || strcmp(me, "esa") == 0))
-       {
-               x264_remove_opt(split, x264_merange_syns);
-       }
-       g_free(me);
        if (!ghb_settings_get_boolean(ud->settings, "x264_cabac"))
        {
                x264_remove_opt(split, x264_trellis_syns);
        }
+       // Remove entries that match the defaults
+       for (ii = 0; split[ii] != NULL; ii++)
+       {
+               gchar *val = NULL;
+               gchar *opt = g_strdup(split[ii]);
+               gchar *pos = strchr(opt, '=');
+               if (pos != NULL)
+               {
+                       val = pos + 1;
+                       *pos = 0;
+               }
+               else
+               {
+                       val = "1";
+               }
+               const gchar *def_val;
+               if (find_syn_match(opt, x264_mbtree_syns) >= 0 && bframes == 0)
+               {
+                       def_val = "0";
+               }
+               else
+               {
+                       def_val = x264_opt_get_default(opt);
+               }
+               if (strcmp(val, def_val) == 0)
+               {
+                       // Matches the default, so remove it
+                       split[ii][0] = 0;
+               }
+               g_free(opt);
+       }
        for (ii = 0; split[ii] != NULL; ii++)
        {
                if (split[ii][0] != 0)
index 89e906a..945a385 100644 (file)
@@ -28,5 +28,6 @@
 #include "settings.h"
 
 void ghb_x264_parse_options(signal_user_data_t *ud, const gchar *options);
+gint ghb_lookup_badapt(const gchar *options);
 
 #endif // _X264HANDLER_H_
index 7d26905..52ea27f 100644 (file)
@@ -9,6 +9,8 @@
 #include <sys/time.h>
 
 #include "common.h"
+#include "lang.h"
+#include "hb.h"
 
 /**********************************************************************
  * Global variables
@@ -31,7 +33,8 @@ hb_rate_t hb_audio_bitrates[] =
 { {  "32",  32 }, {  "40",  40 }, {  "48",  48 }, {  "56",  56 },
   {  "64",  64 }, {  "80",  80 }, {  "96",  96 }, { "112", 112 },
   { "128", 128 }, { "160", 160 }, { "192", 192 }, { "224", 224 },
-  { "256", 256 }, { "320", 320 }, { "384", 384 } };
+  { "256", 256 }, { "320", 320 }, { "384", 384 }, { "448", 448 },
+  { "768", 768 } };
 int hb_audio_bitrates_count = sizeof( hb_audio_bitrates ) /
                               sizeof( hb_rate_t );
 int hb_audio_bitrates_default = 8; /* 128 kbps */
@@ -121,8 +124,8 @@ void hb_fix_aspect( hb_job_t * job, int keep )
     if ( title->height == 0 || title->width == 0 || title->aspect == 0 )
     {
         hb_log( "hb_fix_aspect: incomplete info for title %d: "
-                "height = %d, width = %d, aspect = %d",
-                title->height, title->width, title->aspect );
+                "height = %d, width = %d, aspect = %.3f",
+                title->index, title->height, title->width, title->aspect );
         return;
     }
 
@@ -214,9 +217,21 @@ int hb_calc_bitrate( hb_job_t * job, int size )
     length += 135000;
     length /= 90000;
 
+    if( size == -1 )
+    {
+        hb_interjob_t * interjob = hb_interjob_get( job->h );
+        avail = job->vbitrate * 125 * length;
+        avail += length * interjob->vrate * overhead / interjob->vrate_base;
+    }
+
     /* Video overhead */
     avail -= length * job->vrate * overhead / job->vrate_base;
 
+    if( size == -1 )
+    {
+        goto ret;
+    }
+
     for( i = 0; i < hb_list_count(job->list_audio); i++ )
     {
         /* Audio data */
@@ -227,6 +242,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
         switch( audio->config.out.codec )
         {
             case HB_ACODEC_FAAC:
+            case HB_ACODEC_CA_AAC:
             case HB_ACODEC_VORBIS:
                 samples_per_frame = 1024;
                 break;
@@ -234,6 +250,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
                 samples_per_frame = 1152;
                 break;
             case HB_ACODEC_AC3:
+            case HB_ACODEC_DCA:
                 samples_per_frame = 1536;
                 break;
             default:
@@ -263,6 +280,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
         avail -= length * audio->config.out.samplerate * overhead / samples_per_frame;
     }
 
+ret:
     if( avail < 0 )
     {
         return 0;
@@ -674,6 +692,15 @@ void hb_title_close( hb_title_t ** _t )
     }
     hb_list_close( &t->list_subtitle );
 
+    if( t->metadata )
+    {
+        if( t->metadata->coverart )
+        {
+            free( t->metadata->coverart );
+        }
+        free( t->metadata );
+    }
+
     free( t );
     *_t = NULL;
 }
@@ -804,3 +831,72 @@ hb_audio_config_t * hb_list_audio_config_item(hb_list_t * list, int i)
 
     return NULL;
 }
+
+/**********************************************************************
+ * hb_subtitle_copy
+ **********************************************************************
+ *
+ *********************************************************************/
+hb_subtitle_t *hb_subtitle_copy(const hb_subtitle_t *src)
+{
+    hb_subtitle_t *subtitle = NULL;
+
+    if( src )
+    {
+        subtitle = calloc(1, sizeof(*subtitle));
+        memcpy(subtitle, src, sizeof(*subtitle));
+    }
+    return subtitle;
+}
+
+/**********************************************************************
+ * hb_subtitle_add
+ **********************************************************************
+ *
+ *********************************************************************/
+int hb_subtitle_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, int track)
+{
+    hb_title_t *title = job->title;
+    hb_subtitle_t *subtitle;
+
+    subtitle = hb_subtitle_copy( hb_list_item( title->list_subtitle, track ) );
+    if( subtitle == NULL )
+    {
+        /* We fail! */
+        return 0;
+    }
+    subtitle->config = *subtitlecfg;
+    hb_list_add(job->list_subtitle, subtitle);
+    return 1;
+}
+
+int hb_srt_add( const hb_job_t * job, 
+                const hb_subtitle_config_t * subtitlecfg, 
+                const char *lang )
+{
+    hb_subtitle_t *subtitle;
+    iso639_lang_t *language = NULL;
+    int retval = 0;
+
+    subtitle = calloc( 1, sizeof( *subtitle ) );
+    
+    subtitle->id = (hb_list_count(job->list_subtitle) << 8) | 0xFF;
+    subtitle->format = TEXTSUB;
+    subtitle->source = SRTSUB;
+
+    language = lang_for_code2( lang );
+
+    if( language )
+    {
+
+        strcpy( subtitle->lang, language->eng_name );
+        strncpy( subtitle->iso639_2, lang, 4 );
+        
+        subtitle->config = *subtitlecfg;
+        subtitle->config.dest = PASSTHRUSUB;
+
+        hb_list_add(job->list_subtitle, subtitle);
+        retval = 1;
+    }
+    return retval;
+}
index 44706af..b6c5e57 100644 (file)
 #include <sys/stat.h>
 #include <dirent.h>
 
+#if defined( __GNUC__ ) && !(defined( _WIN32 ) || defined( __MINGW32__ ))
+#   define HB_WPRINTF(s,v) __attribute__((format(printf,s,v)))
+#else
+#   define HB_WPRINTF(s,v)
+#endif
+
+#if defined( SYS_MINGW )
+#   define fseek fseeko64
+#   define ftell ftello64
+#   undef  fseeko
+#   define fseeko fseeko64
+#   undef  ftello
+#   define ftello ftello64
+#   define flockfile(...)
+#   define funlockfile(...)
+#   define getc_unlocked getc
+#   undef  off_t
+#   define off_t off64_t
+#endif
+
 #ifndef MIN
 #define MIN( a, b ) ( (a) > (b) ? (b) : (a) )
 #endif
@@ -27,7 +47,7 @@
 
 #define EVEN( a )        ( (a) + ( (a) & 1 ) )
 #define MULTIPLE_16( a ) ( 16 * ( ( (a) + 8 ) / 16 ) )
-#define MULTIPLE_MOD( a, b ) ( b * ( ( (a) + (b / 2) - 1) / b ) )
+#define MULTIPLE_MOD( a, b ) ((b==1)?a:( b * ( ( (a) + (b / 2) - 1) / b ) ))
 
 #define HB_DVD_READ_BUFFER_SIZE 2048
 
@@ -41,6 +61,8 @@ typedef struct hb_chapter_s hb_chapter_t;
 typedef struct hb_audio_s hb_audio_t;
 typedef struct hb_audio_config_s hb_audio_config_t;
 typedef struct hb_subtitle_s hb_subtitle_t;
+typedef struct hb_subtitle_config_s hb_subtitle_config_t;
+typedef struct hb_metadata_s hb_metadata_t;
 typedef struct hb_state_s hb_state_t;
 typedef union  hb_esconfig_u     hb_esconfig_t;
 typedef struct hb_work_private_s hb_work_private_t;
@@ -79,6 +101,11 @@ void hb_audio_config_init(hb_audio_config_t * audiocfg);
 int hb_audio_add(const hb_job_t * job, const hb_audio_config_t * audiocfg);
 hb_audio_config_t * hb_list_audio_config_item(hb_list_t * list, int i);
 
+int hb_subtitle_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, int track);
+int hb_srt_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, 
+               const char *lang);
+
+
 struct hb_rate_s
 {
     char * string;
@@ -93,6 +120,16 @@ struct hb_mixdown_s
     int    amixdown;
 };
 
+struct hb_subtitle_config_s
+{
+    enum subdest { RENDERSUB, PASSTHRUSUB } dest;
+    int  force;
+    int  default_track; 
+    char src_filename[128];
+    char src_codeset[40];
+    int64_t offset;
+};
+
 #define HB_VIDEO_RATE_BASE   27000000
 
 extern hb_rate_t    hb_video_rates[];
@@ -146,10 +183,19 @@ struct hb_job_s
     int             height;
     int             keep_ratio;
     int             grayscale;
-    int             pixel_ratio;
-    int             pixel_aspect_width;
-    int             pixel_aspect_height;
-    int             modulus;
+
+    struct
+    {
+        int             mode;
+        int             modulus;
+        int             itu_par;
+        int             par_width;
+        int             par_height;
+        int             dar_width;
+        int             dar_height;
+        int             keep_display_aspect;
+    } anamorphic;
+    
     int             maxWidth;
     int             maxHeight;
 
@@ -160,19 +206,15 @@ struct hb_job_s
                             except with x264, to use its real QP/RF scale
          vbitrate:          output bitrate (kbps)
          vrate, vrate_base: output framerate is vrate / vrate_base
-         vfr:               boolean for variable frame rate detelecine
-         cfr:               boolean to use constant frame rates instead of
-                            passing through the source's frame durations.
+         cfr:               0 (vfr), 1 (cfr), 2 (pfr) [see render.c]
          pass:              0, 1 or 2 (or -1 for scan)
          h264_level:        vestigial boolean to decide if we're encoding for iPod
-         crf:               boolean for whether to use constant rate factor with x264
          x264opts:          string of extra x264 options
          areBframes:        boolean to note if b-frames are included in x264opts */
 #define HB_VCODEC_MASK   0x0000FF
 #define HB_VCODEC_FFMPEG 0x000001
-#define HB_VCODEC_XVID   0x000002
-#define HB_VCODEC_X264   0x000004
-#define HB_VCODEC_THEORA 0x000008
+#define HB_VCODEC_X264   0x000002
+#define HB_VCODEC_THEORA 0x000004
 
     int             vcodec;
     float           vquality;
@@ -184,7 +226,6 @@ struct hb_job_s
     int             pass;
     int             h264_13;
     int             h264_level;
-    int             crf;
     char            *x264opts;
     int             areBframes;
     int             color_matrix;
@@ -192,11 +233,9 @@ struct hb_job_s
     /* List of audio settings. */
     hb_list_t     * list_audio;
 
-    /* Subtitle settings:
-         subtitle: index in hb_title_t's subtitles list, starting
-         from 0. -1 means no subtitle */
-    int             subtitle;
-    int             subtitleSmartAdjust;
+    /* Subtitles
+     */
+    hb_list_t     * list_subtitle;
 
     /* Muxer settings
          mux:  output file format
@@ -217,15 +256,16 @@ struct hb_job_s
     int             mp4_optimize;
     int             ipod_atom;
 
-    int indepth_scan;
-    hb_subtitle_t ** select_subtitle;
-    int subtitle_force;
-    char * native_language;
+    int                     indepth_scan;
+    hb_subtitle_config_t    select_subtitle_config;
 
+    int             angle;              // dvd angle to encode
+    int             frame_to_stop;       // declare eof when we hit this frame
     int64_t         pts_to_stop;        // declare eof when we pass this pts in
                                         //  the time-linearized input stream
     int             start_at_preview;   // if non-zero, encoding will start
-                                        //  at the position of preview n (1-10)
+                                        //  at the position of preview n
+    int             seek_points;        //  out of N previews
     uint32_t        frames_to_skip;     // decode but discard this many frames
                                         //  initially (for frame accurate positioning
                                         //  to non-I frames).
@@ -237,6 +277,9 @@ struct hb_job_s
     volatile int  * die;
     volatile int    done;
 
+    uint64_t        st_pause_date;
+    uint64_t        st_paused;
+
     hb_fifo_t     * fifo_mpeg2;   /* MPEG-2 video ES */
     hb_fifo_t     * fifo_raw;     /* Raw pictures */
     hb_fifo_t     * fifo_sync;    /* Raw pictures, framerate corrected */
@@ -265,6 +308,7 @@ struct hb_job_s
 #define HB_ACODEC_LPCM   0x002000
 #define HB_ACODEC_DCA    0x004000
 #define HB_ACODEC_FFMPEG 0x008000
+#define HB_ACODEC_CA_AAC 0x010000
 
 /* Audio Mixdown */
 /* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
@@ -396,6 +440,8 @@ struct hb_audio_s
 struct hb_chapter_s
 {
     int      index;
+    int      pgcn;
+    int      pgn;
     int      cell_start;
     int      cell_end;
     int      block_start;
@@ -417,6 +463,12 @@ struct hb_chapter_s
 struct hb_subtitle_s
 {
     int  id;
+    int  track;
+
+    hb_subtitle_config_t config;
+
+    enum subtype { PICTURESUB, TEXTSUB } format;
+    enum subsource { VOBSUB, SRTSUB, CC608SUB, CC708SUB } source;
     char lang[1024];
     char iso639_2[4];
     uint8_t type; /* Closed Caption, Childrens, Directors etc */
@@ -427,10 +479,26 @@ struct hb_subtitle_s
 #ifdef __LIBHB__
     /* Internal data */
     hb_fifo_t * fifo_in;  /* SPU ES */
-    hb_fifo_t * fifo_raw; /* Decodec SPU */
+    hb_fifo_t * fifo_raw; /* Decoded SPU */
+    hb_fifo_t * fifo_sync;/* Synced */
+    hb_fifo_t * fifo_out; /* Correct Timestamps, ready to be muxed */
+    hb_mux_data_t * mux_data;
 #endif
 };
 
+struct hb_metadata_s 
+{
+    char  name[255];
+    char  artist[255];
+    char  composer[255];
+    char  release_date[255];
+    char  comment[1024];
+    char  album[255];
+    char  genre[255];
+    uint32_t coverart_size;
+    uint8_t *coverart;
+};
+
 struct hb_title_s
 {
     char        dvd[1024];
@@ -443,6 +511,7 @@ struct hb_title_s
     int         block_start;
     int         block_end;
     int         block_count;
+    int         angle_count;
 
     /* Visual-friendly duration */
     int         hours;
@@ -461,13 +530,11 @@ struct hb_title_s
     int         rate;
     int         rate_base;
     int         crop[4];
-    enum { HB_MPEG2_DEMUXER = 0, HB_NULL_DEMUXER } demuxer;
+    enum { HB_MPEG2_PS_DEMUXER = 0, HB_MPEG2_TS_DEMUXER, HB_NULL_DEMUXER } demuxer;
     int         detected_interlacing;
     int         video_id;               /* demuxer stream id for video */
     int         video_codec;            /* worker object id of video codec */
     int         video_codec_param;      /* codec specific config */
-    int         flaky_clock;            /* can lose reference clock */
-                                        /* (for over-the-air transport streams) */
     const char  *video_codec_name;
     int         video_bitrate;
     const char  *container_name;
@@ -475,12 +542,18 @@ struct hb_title_s
 
     uint32_t    palette[16];
 
+    hb_metadata_t *metadata;
+
     hb_list_t * list_chapter;
     hb_list_t * list_audio;
     hb_list_t * list_subtitle;
 
     /* Job template for this title */
     hb_job_t  * job;
+
+    uint32_t    flags;
+                // set if video stream doesn't have IDR frames
+#define         HBTF_NO_IDR (1 << 0)
 };
 
 
@@ -588,7 +661,10 @@ struct hb_work_object_s
     hb_esconfig_t     * config;
 
     /* Pointer hb_audio_t so we have access to the info in the audio worker threads. */
-    hb_audio_t *audio;
+    hb_audio_t        * audio;
+
+    /* Pointer hb_subtitle_t so we have access to the info in the subtitle worker threads. */
+    hb_subtitle_t     * subtitle;
 
     hb_work_private_t * private_data;
 
@@ -596,18 +672,21 @@ struct hb_work_object_s
     volatile int      * done;
     int                 status;
     int                 codec_param;
+    hb_title_t        * title;
 
     hb_work_object_t  * next;
-       int                               thread_sleep_interval;
+    int                 thread_sleep_interval;
 #endif
 };
 
 extern hb_work_object_t hb_sync;
 extern hb_work_object_t hb_decmpeg2;
-extern hb_work_object_t hb_decsub;
+extern hb_work_object_t hb_decvobsub;
+extern hb_work_object_t hb_encvobsub;
+extern hb_work_object_t hb_deccc608;
+extern hb_work_object_t hb_decsrtsub;
 extern hb_work_object_t hb_render;
 extern hb_work_object_t hb_encavcodec;
-extern hb_work_object_t hb_encxvid;
 extern hb_work_object_t hb_encx264;
 extern hb_work_object_t hb_enctheora;
 extern hb_work_object_t hb_deca52;
@@ -620,6 +699,7 @@ extern hb_work_object_t hb_declpcm;
 extern hb_work_object_t hb_encfaac;
 extern hb_work_object_t hb_enclame;
 extern hb_work_object_t hb_encvorbis;
+extern hb_work_object_t hb_encca_aac;
 
 #define FILTER_OK      0
 #define FILTER_DELAY   1
index f549fbb..261b0b3 100644 (file)
@@ -17,7 +17,7 @@
 */
 
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
 
 #define PP7_QP_DEFAULT    5
index 5559024..db3b56f 100644 (file)
@@ -7,6 +7,7 @@
 #include "hb.h"
 
 #include "a52dec/a52.h"
+#include "libavutil/crc.h"
 
 struct hb_work_private_s
 {
@@ -19,23 +20,18 @@ struct hb_work_private_s
     int           flags_out;
     int           rate;
     int           bitrate;
+    int           out_discrete_channels;
+    int           error;
+    int           frames;                   // number of good frames decoded
+    int           crc_errors;               // number of frames with crc errors
+    int           bytes_dropped;            // total bytes dropped while resyncing
     float         level;
     float         dynamic_range_compression;
-
-    int           error;
-    int           sync;
-    int           size;
-
-    int64_t       next_expected_pts;
-
-    int64_t       sequence;
-
+    double        next_expected_pts;
+    int64_t       last_buf_pts;
+    hb_list_t    *list;
+    const AVCRC  *crc_table;
     uint8_t       frame[3840];
-
-    hb_list_t   * list;
-
-       int           out_discrete_channels;
-
 };
 
 static int  deca52Init( hb_work_object_t *, hb_job_t * );
@@ -97,6 +93,7 @@ static int deca52Init( hb_work_object_t * w, hb_job_t * job )
 
     pv->job   = job;
 
+    pv->crc_table = av_crc_get_table( AV_CRC_16_ANSI );
     pv->list      = hb_list_init();
     pv->state     = a52_init( 0 );
 
@@ -112,9 +109,6 @@ static int deca52Init( hb_work_object_t * w, hb_job_t * job )
     pv->level     = 32768.0;
     pv->dynamic_range_compression = audio->config.out.dynamic_range_compression;
 
-    pv->next_expected_pts = 0;
-    pv->sequence = 0;
-
     return 0;
 }
 
@@ -126,6 +120,12 @@ static int deca52Init( hb_work_object_t * w, hb_job_t * job )
 static void deca52Close( hb_work_object_t * w )
 {
     hb_work_private_t * pv = w->private_data;
+
+    if ( pv->crc_errors )
+    {
+        hb_log( "deca52: %d frames decoded, %d crc errors, %d bytes dropped",
+                pv->frames, pv->crc_errors, pv->bytes_dropped );
+    }
     a52_free( pv->state );
     hb_list_empty( &pv->list );
     free( pv );
@@ -152,7 +152,12 @@ static int deca52Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
         return HB_WORK_DONE;
     }
 
-    pv->sequence = (*buf_in)->sequence;
+    if ( (*buf_in)->start < -1 && pv->next_expected_pts == 0 )
+    {
+        // discard buffers that start before video time 0
+        *buf_out = NULL;
+        return HB_WORK_OK;
+    }
 
     hb_list_add( pv->list, *buf_in );
     *buf_in = NULL;
@@ -161,7 +166,6 @@ static int deca52Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
     *buf_out = buf = Decode( w );
     while( buf )
     {
-        buf->sequence = pv->sequence;
         buf->next = Decode( w );
         buf       = buf->next;
     }
@@ -180,86 +184,113 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
     hb_buffer_t * buf;
     hb_audio_t  * audio = w->audio;
     int           i, j, k;
-    uint64_t      pts, pos;
+    int           size = 0;
 
-    /* Get a frame header if don't have one yet */
-    if( !pv->sync )
+    // check that we're at the start of a valid frame and align to the
+    // start of a valid frame if we're not.
+    // we have to check the header & crc so we need at least
+    // 7 (the header size) + 128 (the minimum frame size) bytes
+    while( hb_list_bytes( pv->list ) >= 7+128 )
     {
-        while( hb_list_bytes( pv->list ) >= 7 )
+        /* check if this is a valid header */
+        hb_list_seebytes( pv->list, pv->frame, 7 );
+        size = a52_syncinfo( pv->frame, &pv->flags_in, &pv->rate, &pv->bitrate );
+        if ( size > 0 )
         {
-            /* We have 7 bytes, check if this is a correct header */
-            hb_list_seebytes( pv->list, pv->frame, 7 );
-            pv->size = a52_syncinfo( pv->frame, &pv->flags_in, &pv->rate,
-                                    &pv->bitrate );
-            if( pv->size )
+            // header looks valid - check the crc1
+            if( size > hb_list_bytes( pv->list ) )
+            {
+                // don't have all the frame's data yet
+                return NULL;
+            }
+            int crc1size = (size >> 1) + (size >> 3);
+            hb_list_seebytes( pv->list, pv->frame, crc1size );
+            if ( av_crc( pv->crc_table, 0, pv->frame + 2, crc1size - 2 ) == 0 )
             {
-                /* It is. W00t. */
+                // crc1 is ok - say we have valid frame sync
                 if( pv->error )
                 {
-                    hb_log( "a52_syncinfo ok" );
+                    hb_log( "output track %d: ac3 in sync after skipping %d bytes",
+                            audio->config.out.track, pv->error );
+                    pv->bytes_dropped += pv->error;
+                    pv->error = 0;
                 }
-                pv->error = 0;
-                pv->sync  = 1;
                 break;
             }
-
-            /* It is not */
-            if( !pv->error )
-            {
-                hb_log( "a52_syncinfo failed" );
-                pv->error = 1;
-            }
-
-            /* Try one byte later */
-            hb_list_getbytes( pv->list, pv->frame, 1, NULL, NULL );
         }
+        // no sync - discard one byte then try again
+        hb_list_getbytes( pv->list, pv->frame, 1, NULL, NULL );
+        ++pv->error;
     }
 
-    if( !pv->sync ||
-        hb_list_bytes( pv->list ) < pv->size )
+    // we exit the above loop either in error state (we didn't find sync
+    // or don't have enough data yet to validate sync) or in sync. If we're
+    // not in sync we need more data so just return.
+    if( pv->error || size <= 0 || hb_list_bytes( pv->list ) < size )
     {
         /* Need more data */
         return NULL;
     }
 
-    /* Get the whole frame */
-    hb_list_getbytes( pv->list, pv->frame, pv->size, &pts, &pos );
-    if (pts == -1)
+    // Get the whole frame and check its CRC. If the CRC is wrong
+    // discard the frame - we'll resync on the next call.
+
+    uint64_t ipts;
+    hb_list_getbytes( pv->list, pv->frame, size, &ipts, NULL );
+    if ( av_crc( pv->crc_table, 0, pv->frame + 2, size - 2 ) != 0 )
+    {
+        ++pv->crc_errors;
+        return NULL;
+    }
+    ++pv->frames;
+    if ( ipts != pv->last_buf_pts )
+    {
+        pv->last_buf_pts = ipts;
+    }
+    else
     {
-        pts = pv->next_expected_pts;
+        // spec says that the PTS is the start time of the first frame
+        // that starts in the PES frame so we only use the PTS once then
+        // get the following frames' PTS from the frame length.
+        ipts = -1;
     }
 
+    double pts = ( ipts != -1 ) ? ipts : pv->next_expected_pts;
+    double frame_dur = (6. * 256. * 90000.) / pv->rate;
+
     /* AC3 passthrough: don't decode the AC3 frame */
     if( audio->config.out.codec == HB_ACODEC_AC3 )
     {
-        buf = hb_buffer_init( pv->size );
-        memcpy( buf->data, pv->frame, pv->size );
-        buf->start = pts + ( pos / pv->size ) * 6 * 256 * 90000 / pv->rate;
-        buf->stop  = buf->start + 6 * 256 * 90000 / pv->rate;
-        pv->next_expected_pts = buf->stop;
-        pv->sync = 0;
+        buf = hb_buffer_init( size );
+        memcpy( buf->data, pv->frame, size );
+        buf->start = pts;
+        pts += frame_dur;
+        buf->stop  = pts;
+        pv->next_expected_pts = pts;
         return buf;
     }
 
     /* Feed liba52 */
     a52_frame( pv->state, pv->frame, &pv->flags_out, &pv->level, 0 );
 
-    if ( pv->dynamic_range_compression > 1.0 )
+    /* If a user specifies strong dynamic range compression (>1), adjust it.
+       If a user specifies default dynamic range compression (1), leave it alone.
+       If a user specifies no dynamic range compression (0), call a null function. */
+    if( pv->dynamic_range_compression > 1.0 )
     {
-        a52_dynrng( pv->state, dynrng_call, &pv->dynamic_range_compression);
+        a52_dynrng( pv->state, dynrng_call, &pv->dynamic_range_compression );
+    }
+    else if( !pv->dynamic_range_compression )
+    {
+        a52_dynrng( pv->state, NULL, NULL );
     }
 
     /* 6 blocks per frame, 256 samples per block, channelsused channels */
     buf        = hb_buffer_init( 6 * 256 * pv->out_discrete_channels * sizeof( float ) );
-    buf->start = pts + ( pos / pv->size ) * 6 * 256 * 90000 / pv->rate;
-    buf->stop  = buf->start + 6 * 256 * 90000 / pv->rate;
-
-    /*
-       * To track AC3 PTS add this back in again.
-        *hb_log("AC3: pts is %lld, buf->start %lld buf->stop %lld", pts, buf->start, buf->stop);
-        */
-
-    pv->next_expected_pts = buf->stop;
+    buf->start = pts;
+    pts += frame_dur;
+    buf->stop  = pts;
+    pv->next_expected_pts = pts;
 
     for( i = 0; i < 6; i++ )
     {
@@ -280,56 +311,100 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
         }
 
     }
-
-    pv->sync = 0;
     return buf;
 }
 
-static int deca52BSInfo( hb_work_object_t *w, const hb_buffer_t *b,
-                         hb_work_info_t *info )
+static int find_sync( const uint8_t *buf, int len )
 {
     int i;
-    int rate = 0, bitrate = 0, flags = 0;
-    int old_rate = 0, old_bitrate = 0;
-    uint8_t raw;
 
+    // since AC3 frames don't line up with MPEG ES frames scan the
+    // frame for an AC3 sync pattern.
+    for ( i = 0; i < len - 16; ++i )
+    {
+        int rate, bitrate, flags;
+        int size = a52_syncinfo( (uint8_t *)buf + i, &flags, &rate, &bitrate );
+        if( size > 0 )
+        {
+            // we have a plausible sync header - see if crc1 checks
+            int crc1size = (size >> 1) + (size >> 3); 
+            if ( i + crc1size > len )
+            {
+                // don't have enough data to check crc1
+                break;
+            }
+            if ( av_crc( av_crc_get_table( AV_CRC_16_ANSI ), 0,
+                         buf + i + 2, crc1size - 2 ) == 0 )
+            {
+                // crc checks - we've got sync
+                return i;
+            }
+        }
+    }
+    return -1;
+}
+
+static int deca52BSInfo( hb_work_object_t *w, const hb_buffer_t *b,
+                         hb_work_info_t *info )
+{
     memset( info, 0, sizeof(*info) );
 
-    /* since AC3 frames don't line up with MPEG ES frames scan the
-     * entire frame for an AC3 sync pattern.  */
-    for ( i = 0; i < b->size - 7; ++i )
+    // We don't know if the way that AC3 frames are fragmented into whatever
+    // packetization the container uses will give us enough bytes per fragment
+    // to check the CRC (we need at least 5/8 of the the frame). So we
+    // copy the fragment we got into an accumulation buffer in the audio object
+    // then look for sync over all the frags we've accumulated so far.
+    uint8_t *buf = w->audio->priv.config.a52.buf;
+    int len = w->audio->priv.config.a52.len, blen = b->size;
+    if ( len + blen > sizeof(w->audio->priv.config.a52.buf) )
     {
-        if( a52_syncinfo( &b->data[i], &flags, &rate, &bitrate ) != 0 )
+        // we don't have enough empty space in the accumulation buffer to
+        // hold the new frag - make room for it by discarding the oldest data.
+        if ( blen >= sizeof(w->audio->priv.config.a52.buf) )
         {
-            /*
-             * Got sync apparently, save these values and check that they
-             * also match when we get sync again.
-             */
-            if( old_rate ) 
-            {
-                if( rate == old_rate && bitrate == old_bitrate )
-                {
-                    break;
-                } 
-            } 
-            
-            old_rate = rate;
-            old_bitrate = bitrate;
-            raw = b->data[i+5];
+            // the frag is bigger than our accumulation buffer - copy all
+            // that will fit (the excess doesn't matter since the buffer
+            // is many times the size of a max length ac3 frame).
+            blen = sizeof(w->audio->priv.config.a52.buf);
+            len = 0;
+        }
+        else
+        {
+            // discard enough bytes from the front of the buffer to make
+            // room for the new stuff
+            int newlen = sizeof(w->audio->priv.config.a52.buf) - blen;
+            memcpy( buf, buf + len - newlen, newlen );
+            len = newlen;
         }
     }
-    if ( rate == 0 || bitrate == 0 )
+    // add the new frag to the buffer
+    memcpy( buf+len, b->data, blen );
+    len += blen;
+
+    int i;
+    if ( ( i = find_sync( buf, len ) ) < 0 )
     {
-        /* didn't find AC3 sync */
+        // didn't find sync - wait for more data
+        w->audio->priv.config.a52.len = len;
         return 0;
     }
 
-    /*
-     * bsid | bsmod | acmod | cmixlev | surmixlev | dsurmod | lfeon | dialnorm | compre
-     *    5       3       3         2           2         2       1          5        1
-     * [    byte1  ][         byte2                    ][   byte3                     ]
-     */
+    // got sync - extract and canoncalize the bitstream parameters
+    int rate = 0, bitrate = 0, flags = 0;
+    uint8_t raw = buf[i + 5];
+    a52_syncinfo( buf + i, &flags, &rate, &bitrate );
+
+    if ( rate == 0 || bitrate == 0 )
+    {
+        // invalid AC-3 parameters - toss what we have so we'll start over
+        // with the next buf otherwise we'll keep syncing on this junk.
+        w->audio->priv.config.a52.len = 0;
+        return 0;
+    }
 
+    // bsid | bsmod | acmod | cmixlv | surmixlv | dsurmod | lfeon | dialnorm | compre
+    //   5       3      3        2         2         2        1          5        1
+    //      byte1   |          byte2                 |    byte3  
 
     info->name = "AC-3";
     info->rate = rate;
index 81ea499..9d1474b 100644 (file)
  */
 
 #include "hb.h"
-
-#include "libavcodec/avcodec.h"
-#include "libavformat/avformat.h"
-#include "libswscale/swscale.h"
+#include "hbffmpeg.h"
+#include "libavcodec/audioconvert.h"
 
 static int  decavcodecInit( hb_work_object_t *, hb_job_t * );
 static int  decavcodecWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
@@ -190,11 +188,12 @@ static int decavcodecInit( hb_work_object_t * w, hb_job_t * job )
     /*XXX*/
     if ( codec_id == 0 )
         codec_id = CODEC_ID_MP2;
+
     codec = avcodec_find_decoder( codec_id );
     pv->parser = av_parser_init( codec_id );
 
     pv->context = avcodec_alloc_context();
-    avcodec_open( pv->context, codec );
+    hb_avcodec_open( pv->context, codec );
 
     return 0;
 }
@@ -226,7 +225,7 @@ static void decavcodecClose( hb_work_object_t * w )
         }
         if ( pv->context && pv->context->codec )
         {
-            avcodec_close( pv->context );
+            hb_avcodec_close( pv->context );
         }
         if ( pv->list )
         {
@@ -234,7 +233,7 @@ static void decavcodecClose( hb_work_object_t * w )
         }
         if ( pv->buffer )
         {
-            free( pv->buffer );
+            av_free( pv->buffer );
             pv->buffer = NULL;
         }
         free( pv );
@@ -253,7 +252,7 @@ static int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * in = *buf_in, * buf, * last = NULL;
     int   pos, len, out_size, i, uncompressed_len;
-    short buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE];
+    short* bufaligned;
     uint64_t cur;
     unsigned char *parser_output_buffer;
     int parser_output_buffer_len;
@@ -268,23 +267,32 @@ static int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     *buf_out = NULL;
 
+    if ( in->start < -1 && pv->pts_next <= 0 )
+    {
+        // discard buffers that start before video time 0
+        return HB_WORK_OK;
+    }
+
     cur = ( in->start < 0 )? pv->pts_next : in->start;
 
+    bufaligned = av_malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
     pos = 0;
     while( pos < in->size )
     {
-        len = av_parser_parse( pv->parser, pv->context,
-                               &parser_output_buffer, &parser_output_buffer_len,
-                               in->data + pos, in->size - pos, cur, cur );
+        len = av_parser_parse2( pv->parser, pv->context,
+                                &parser_output_buffer, &parser_output_buffer_len,
+                                in->data + pos, in->size - pos, cur, cur, AV_NOPTS_VALUE );
         out_size = 0;
         uncompressed_len = 0;
         if (parser_output_buffer_len)
         {
-            out_size = sizeof(buffer);
-            uncompressed_len = avcodec_decode_audio2( pv->context, buffer,
-                                                      &out_size,
-                                                      parser_output_buffer,
-                                                      parser_output_buffer_len );
+            AVPacket avp;
+            av_init_packet( &avp );
+            avp.data = parser_output_buffer;
+            avp.size = parser_output_buffer_len;
+
+            out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+            uncompressed_len = avcodec_decode_audio3( pv->context, bufaligned, &out_size, &avp );
         }
         if( out_size )
         {
@@ -311,7 +319,7 @@ static int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                          pv->context->sample_rate;
             cur = buf->stop;
 
-            s16  = buffer;
+            s16  = bufaligned;
             fl32 = (float *) buf->data;
             for( i = 0; i < out_size / 2; i++ )
             {
@@ -333,6 +341,7 @@ static int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     pv->pts_next = cur;
 
+    av_free( bufaligned );
     return HB_WORK_OK;
 }
 
@@ -355,10 +364,23 @@ static int decavcodecInfo( hb_work_object_t *w, hb_work_info_t *info )
     return 0;
 }
 
+static const int chan2layout[] = {
+    HB_INPUT_CH_LAYOUT_MONO,  // We should allow no audio really.
+    HB_INPUT_CH_LAYOUT_MONO,   
+    HB_INPUT_CH_LAYOUT_STEREO,
+    HB_INPUT_CH_LAYOUT_2F1R,   
+    HB_INPUT_CH_LAYOUT_2F2R,
+    HB_INPUT_CH_LAYOUT_3F2R,   
+    HB_INPUT_CH_LAYOUT_4F2R,
+    HB_INPUT_CH_LAYOUT_STEREO, 
+    HB_INPUT_CH_LAYOUT_STEREO,
+};
+
 static int decavcodecBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
                              hb_work_info_t *info )
 {
     hb_work_private_t *pv = w->private_data;
+    int ret = 0;
 
     memset( info, 0, sizeof(*info) );
 
@@ -371,18 +393,52 @@ static int decavcodecBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
     // now we just return dummy values if there's a codec that will handle it.
     AVCodec *codec = avcodec_find_decoder( w->codec_param? w->codec_param :
                                                            CODEC_ID_MP2 );
-    if ( codec )
+    if ( codec )
     {
-        static char codec_name[64];
+        // there's no ffmpeg codec for this audio type - give up
+        return -1;
+    }
 
-        info->name =  strncpy( codec_name, codec->name, sizeof(codec_name)-1 );
-        info->bitrate = 384000;
-        info->rate = 48000;
-        info->rate_base = 1;
-        info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
-        return 1;
+    static char codec_name[64];
+    info->name =  strncpy( codec_name, codec->name, sizeof(codec_name)-1 );
+
+    AVCodecParserContext *parser = av_parser_init( codec->id );
+    AVCodecContext *context = avcodec_alloc_context();
+    hb_avcodec_open( context, codec );
+    uint8_t *buffer = av_malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
+    int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+    unsigned char *pbuffer;
+    int pos = 0, pbuffer_size;
+
+    while ( pos < buf->size )
+    {
+        int len = av_parser_parse2( parser, context, &pbuffer, &pbuffer_size,
+                                    buf->data + pos, buf->size - pos,
+                                    buf->start, buf->start, AV_NOPTS_VALUE );
+        pos += len;
+        if ( pbuffer_size > 0 )
+        {
+            AVPacket avp;
+            av_init_packet( &avp );
+            avp.data = pbuffer;
+            avp.size = pbuffer_size;
+
+            len = avcodec_decode_audio3( context, (int16_t*)buffer, &out_size, &avp );
+            if ( len > 0 && context->sample_rate > 0 )
+            {
+                info->bitrate = context->bit_rate;
+                info->rate = context->sample_rate;
+                info->rate_base = 1;
+                info->channel_layout = chan2layout[context->channels & 7];
+                ret = 1;
+                break;
+            }
+        }
     }
-    return -1;
+    av_free( buffer );
+    av_parser_close( parser );
+    hb_avcodec_close( context );
+    return ret;
 }
 
 /* -------------------------------------------------------------
@@ -469,12 +525,12 @@ static void log_chapter( hb_work_private_t *pv, int chap_num, int64_t pts )
     hb_chapter_t *c = hb_list_item( pv->job->title->list_chapter, chap_num - 1 );
     if ( c && c->title )
     {
-        hb_log( "%s: \"%s\" (%d) at frame %u time %lld",
+        hb_log( "%s: \"%s\" (%d) at frame %u time %"PRId64,
                 pv->context->codec->name, c->title, chap_num, pv->nframes, pts );
     }
     else
     {
-        hb_log( "%s: Chapter %d at frame %u time %lld",
+        hb_log( "%s: Chapter %d at frame %u time %"PRId64,
                 pv->context->codec->name, chap_num, pv->nframes, pts );
     }
 }
@@ -496,13 +552,27 @@ static void flushDelayQueue( hb_work_private_t *pv )
 
 static int decodeFrame( hb_work_private_t *pv, uint8_t *data, int size )
 {
-    int got_picture;
+    int got_picture, oldlevel = 0;
     AVFrame frame;
+    AVPacket avp;
+
+    if ( global_verbosity_level <= 1 )
+    {
+        oldlevel = av_log_get_level();
+        av_log_set_level( AV_LOG_QUIET );
+    }
 
-    if ( avcodec_decode_video( pv->context, &frame, &got_picture, data, size ) < 0 )
+    av_init_packet( &avp );
+    avp.data = data;
+    avp.size = size;
+    if ( avcodec_decode_video2( pv->context, &frame, &got_picture, &avp ) < 0 )
     {
         ++pv->decode_errors;     
     }
+    if ( global_verbosity_level <= 1 )
+    {
+        av_log_set_level( oldlevel );
+    }
     if( got_picture )
     {
         // ffmpeg makes it hard to attach a pts to a frame. if the MPEG ES
@@ -528,6 +598,14 @@ static int decodeFrame( hb_work_private_t *pv, uint8_t *data, int size )
         {
             frame_dur += frame.repeat_pict * frame_dur * 0.5;
         }
+        // XXX Unlike every other video decoder, the Raw decoder doesn't
+        //     use the standard buffer allocation routines so we never
+        //     get to put a PTS in the frame. Do it now.
+        if ( pv->context->codec_id == CODEC_ID_RAWVIDEO )
+        {
+            frame.pts = pv->pts;
+            pv->pts = -1;
+        }
         // If there was no pts for this frame, assume constant frame rate
         // video & estimate the next frame time from the last & duration.
         double pts = frame.pts;
@@ -614,8 +692,8 @@ static void decodeVideo( hb_work_private_t *pv, uint8_t *data, int size,
     do {
         uint8_t *pout;
         int pout_len;
-        int len = av_parser_parse( pv->parser, pv->context, &pout, &pout_len,
-                                   data + pos, size - pos, pts, dts );
+        int len = av_parser_parse2( pv->parser, pv->context, &pout, &pout_len,
+                                    data + pos, size - pos, pts, dts, AV_NOPTS_VALUE );
         pos += len;
 
         if ( pout_len > 0 )
@@ -672,17 +750,91 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
     pv->context->opaque = pv;
     pv->context->get_buffer = get_frame_buf;
 
-    AVCodec *codec = avcodec_find_decoder( codec_id );
+    return 0;
+}
+
+static int next_hdr( hb_buffer_t *in, int offset )
+{
+    uint8_t *dat = in->data;
+    uint16_t last2 = 0xffff;
+    for ( ; in->size - offset > 1; ++offset )
+    {
+        if ( last2 == 0 && dat[offset] == 0x01 )
+            // found an mpeg start code
+            return offset - 2;
+
+        last2 = ( last2 << 8 ) | dat[offset];
+    }
+
+    return -1;
+}
+
+static int find_hdr( hb_buffer_t *in, int offset, uint8_t hdr_type )
+{
+    if ( in->size - offset < 4 )
+        // not enough room for an mpeg start code
+        return -1;
+
+    for ( ; ( offset = next_hdr( in, offset ) ) >= 0; ++offset )
+    {
+        if ( in->data[offset+3] == hdr_type )
+            // found it
+            break;
+    }
+    return offset;
+}
+
+static int setup_extradata( hb_work_object_t *w, hb_buffer_t *in )
+{
+    hb_work_private_t *pv = w->private_data;
 
     // we can't call the avstream funcs but the read_header func in the
     // AVInputFormat may set up some state in the AVContext. In particular 
     // vc1t_read_header allocates 'extradata' to deal with header issues
     // related to Microsoft's bizarre engineering notions. We alloc a chunk
     // of space to make vc1 work then associate the codec with the context.
-    pv->context->extradata_size = 32;
-    pv->context->extradata = av_malloc(pv->context->extradata_size);
-    avcodec_open( pv->context, codec );
+    if ( w->codec_param != CODEC_ID_VC1 )
+    {
+        // we haven't been inflicted with M$ - allocate a little space as
+        // a marker and return success.
+        pv->context->extradata_size = 16;
+        pv->context->extradata = av_malloc(pv->context->extradata_size);
+        return 0;
+    }
 
+    // find the start and and of the sequence header
+    int shdr, shdr_end;
+    if ( ( shdr = find_hdr( in, 0, 0x0f ) ) < 0 )
+    {
+        // didn't find start of seq hdr
+        return 1;
+    }
+    if ( ( shdr_end = next_hdr( in, shdr + 4 ) ) < 0 )
+    {
+        shdr_end = in->size;
+    }
+    shdr_end -= shdr;
+
+    // find the start and and of the entry point header
+    int ehdr, ehdr_end;
+    if ( ( ehdr = find_hdr( in, 0, 0x0e ) ) < 0 )
+    {
+        // didn't find start of entry point hdr
+        return 1;
+    }
+    if ( ( ehdr_end = next_hdr( in, ehdr + 4 ) ) < 0 )
+    {
+        ehdr_end = in->size;
+    }
+    ehdr_end -= ehdr;
+
+    // found both headers - allocate an extradata big enough to hold both
+    // then copy them into it.
+    pv->context->extradata_size = shdr_end + ehdr_end;
+    pv->context->extradata = av_malloc(pv->context->extradata_size + 8);
+    memcpy( pv->context->extradata, in->data + shdr, shdr_end );
+    memcpy( pv->context->extradata + shdr_end, in->data + ehdr, ehdr_end );
+    memset( pv->context->extradata + shdr_end + ehdr_end, 0, 8);
     return 0;
 }
 
@@ -705,6 +857,27 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         return HB_WORK_DONE;
     }
 
+    // if this is the first frame open the codec (we have to wait for the
+    // first frame because of M$ VC1 braindamage).
+    if ( pv->context->extradata_size == 0 )
+    {
+        if ( setup_extradata( w, in ) )
+        {
+            // we didn't find the headers needed to set up extradata.
+            // the codec will abort if we open it so just free the buf
+            // and hope we eventually get the info we need.
+            hb_buffer_close( &in );
+            return HB_WORK_OK;
+        }
+        AVCodec *codec = avcodec_find_decoder( w->codec_param );
+        // There's a mis-feature in ffmpeg that causes the context to be 
+        // incorrectly initialized the 1st time avcodec_open is called.
+        // If you close it and open a 2nd time, it finishes the job.
+        hb_avcodec_open( pv->context, codec );
+        hb_avcodec_close( pv->context );
+        hb_avcodec_open( pv->context, codec );
+    }
+
     if( in->start >= 0 )
     {
         pts = in->start;
@@ -739,14 +912,29 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
         info->rate = 27000000;
         info->rate_base = (int64_t)context->time_base.num * 27000000LL /
                           context->time_base.den;
+        if ( context->ticks_per_frame > 1 )
+        {
+            // for ffmpeg 0.5 & later, the H.264 & MPEG-2 time base is
+            // field rate rather than frame rate so convert back to frames.
+            info->rate_base *= context->ticks_per_frame;
+        }
         
-        /* Sometimes there's no pixel aspect set in the source. In that case,
-           assume a 1:1 PAR. Otherwise, preserve the source PAR.             */
-        info->pixel_aspect_width = context->sample_aspect_ratio.num ?
-                                        context->sample_aspect_ratio.num : 1;
-        info->pixel_aspect_height = context->sample_aspect_ratio.den ?
-                                        context->sample_aspect_ratio.den : 1;
-
+        info->pixel_aspect_width = context->sample_aspect_ratio.num;
+        info->pixel_aspect_height = context->sample_aspect_ratio.den;
+
+        /* Sometimes there's no pixel aspect set in the source ffmpeg context
+         * which appears to come from the video stream. In that case,
+         * try the pixel aspect in AVStream (which appears to come from
+         * the container). Else assume a 1:1 PAR. */
+        if ( info->pixel_aspect_width == 0 ||
+             info->pixel_aspect_height == 0 )
+        {
+            AVStream *st = hb_ffmpeg_avstream( w->codec_param );
+            info->pixel_aspect_width = st->sample_aspect_ratio.num ?
+                                        st->sample_aspect_ratio.num : 1;
+            info->pixel_aspect_height = st->sample_aspect_ratio.den ?
+                                        st->sample_aspect_ratio.den : 1;
+        }
         /* ffmpeg returns the Pixel Aspect Ratio (PAR). Handbrake wants the
          * Display Aspect Ratio so we convert by scaling by the Storage
          * Aspect Ratio (w/h). We do the calc in floating point to get the
@@ -804,7 +992,7 @@ static void init_ffmpeg_context( hb_work_object_t *w )
     if ( ! pv->context->codec )
     {
         AVCodec *codec = avcodec_find_decoder( pv->context->codec_id );
-        avcodec_open( pv->context, codec );
+        hb_avcodec_open( pv->context, codec );
     }
     // set up our best guess at the frame duration.
     // the frame rate in the codec is usually bogus but it's sometimes
@@ -962,19 +1150,17 @@ static void decodeAudio( hb_work_private_t *pv, uint8_t *data, int size )
         int16_t *buffer = pv->buffer;
         if ( buffer == NULL )
         {
-            // XXX ffmpeg bug workaround
-            // malloc a buffer for the audio decode. On an x86, ffmpeg
-            // uses mmx/sse instructions on this buffer without checking
-            // that it's 16 byte aligned and this will cause an abort if
-            // the buffer is allocated on our stack. Rather than doing
-            // complicated, machine dependent alignment here we use the
-            // fact that malloc returns an aligned pointer on most architectures.
-            pv->buffer = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
+            pv->buffer = av_malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
             buffer = pv->buffer;
         }
+
+        AVPacket avp;
+        av_init_packet( &avp );
+        avp.data = data + pos;
+        avp.size = size - pos;
+
         int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-        int len = avcodec_decode_audio2( context, buffer, &out_size,
-                                         data + pos, size - pos );
+        int len = avcodec_decode_audio3( context, buffer, &out_size, &avp );
         if ( len <= 0 )
         {
             return;
@@ -982,6 +1168,35 @@ static void decodeAudio( hb_work_private_t *pv, uint8_t *data, int size )
         pos += len;
         if( out_size > 0 )
         {
+            // We require signed 16-bit ints for the output format. If
+            // we got something different convert it.
+            if ( context->sample_fmt != SAMPLE_FMT_S16 )
+            {
+                // Note: av_audio_convert seems to be a work-in-progress but
+                //       looks like it will eventually handle general audio
+                //       mixdowns which would allow us much more flexibility
+                //       in handling multichannel audio in HB. If we were doing
+                //       anything more complicated than a one-for-one format
+                //       conversion we'd probably want to cache the converter
+                //       context in the pv.
+                int isamp = av_get_bits_per_sample_format( context->sample_fmt ) / 8;
+                AVAudioConvert *ctx = av_audio_convert_alloc( SAMPLE_FMT_S16, 1,
+                                                              context->sample_fmt, 1,
+                                                              NULL, 0 );
+                // get output buffer size (in 2-byte samples) then malloc a buffer
+                out_size = ( out_size * 2 ) / isamp;
+                buffer = av_malloc( out_size );
+
+                // we're doing straight sample format conversion which behaves as if
+                // there were only one channel.
+                const void * const ibuf[6] = { pv->buffer };
+                void * const obuf[6] = { buffer };
+                const int istride[6] = { isamp };
+                const int ostride[6] = { 2 };
+
+                av_audio_convert( ctx, obuf, ostride, ibuf, istride, out_size >> 1 );
+                av_audio_convert_free( ctx );
+            }
             hb_buffer_t *buf = hb_buffer_init( 2 * out_size );
 
             // convert from bytes to total samples
@@ -1000,6 +1215,12 @@ static void decodeAudio( hb_work_private_t *pv, uint8_t *data, int size )
                 fl32[i] = buffer[i];
             }
             hb_list_add( pv->list, buf );
+
+            // if we allocated a buffer for sample format conversion, free it
+            if ( buffer != pv->buffer )
+            {
+                av_free( buffer );
+            }
         }
     }
 }
@@ -1016,6 +1237,14 @@ static int decavcodecaiWork( hb_work_object_t *w, hb_buffer_t **buf_in,
     }
 
     hb_work_private_t *pv = w->private_data;
+
+    if ( (*buf_in)->start < -1 && pv->pts_next <= 0 )
+    {
+        // discard buffers that start before video time 0
+        *buf_out = NULL;
+        return HB_WORK_OK;
+    }
+
     if ( ! pv->context )
     {
         init_ffmpeg_context( w );
diff --git a/libhb/deccc608sub.c b/libhb/deccc608sub.c
new file mode 100644 (file)
index 0000000..2f13749
--- /dev/null
@@ -0,0 +1,2537 @@
+/*
+ * From ccextractor, leave this file as intact and close to the original as possible so that 
+ * it is easy to patch in fixes - even though this file contains code that we don't need.
+ *
+ * Note that the SRT sub generation from CC could be useful for mkv subs.
+ */
+#include "hb.h"
+#include "deccc608sub.h"
+
+/*
+ * ccextractor static configuration variables.
+ */
+static int debug_608 = 0;
+static int trim_subs = 1;
+static int nofontcolor = 0;
+static enum encoding_type encoding = ENC_UTF_8;
+static int cc_channel = 1;
+static enum output_format write_format = OF_SRT;
+static int sentence_cap = 0;
+static int subs_delay = 0;
+static LLONG screens_to_process = -1;
+static int processed_enough = 0;
+static int gui_mode_reports = 0;
+static int norollup = 1;
+static int direct_rollup = 0;
+
+/*
+ * Get the time of the last buffer that we have received.
+ */
+static LLONG get_fts(struct s_write *wb)
+{
+    return wb->last_pts;
+}
+
+#define fatal(N, ...) // N
+#define XMLRPC_APPEND(N, ...) // N
+
+int     rowdata[] = {11,-1,1,2,3,4,12,13,14,15,5,6,7,8,9,10};
+// Relationship between the first PAC byte and the row number
+
+// The following enc_buffer is not used at the moment, if it does get used
+// we need to bring it into the swrite struct. Same for "str".
+#define INITIAL_ENC_BUFFER_CAPACITY            2048
+
+unsigned char str[2048]; // Another generic general purpose buffer
+
+#define GUARANTEE(wb, length) if (length>wb->enc_buffer_capacity)            \
+{wb->enc_buffer_capacity*=2; wb->enc_buffer=(unsigned char*) realloc (wb->enc_buffer, wb->enc_buffer_capacity); \
+    if (wb->enc_buffer==NULL) { fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory, bailing out\n"); } \
+}
+
+const unsigned char pac2_attribs[][3]= // Color, font, ident
+{
+    {COL_WHITE,     FONT_REGULAR,               0},  // 0x40 || 0x60 
+    {COL_WHITE,     FONT_UNDERLINED,            0},  // 0x41 || 0x61
+    {COL_GREEN,     FONT_REGULAR,               0},  // 0x42 || 0x62
+    {COL_GREEN,     FONT_UNDERLINED,            0},  // 0x43 || 0x63
+    {COL_BLUE,      FONT_REGULAR,               0},  // 0x44 || 0x64
+    {COL_BLUE,      FONT_UNDERLINED,            0},  // 0x45 || 0x65
+    {COL_CYAN,      FONT_REGULAR,               0},  // 0x46 || 0x66
+    {COL_CYAN,      FONT_UNDERLINED,            0},  // 0x47 || 0x67
+    {COL_RED,       FONT_REGULAR,               0},  // 0x48 || 0x68
+    {COL_RED,       FONT_UNDERLINED,            0},  // 0x49 || 0x69
+    {COL_YELLOW,    FONT_REGULAR,               0},  // 0x4a || 0x6a
+    {COL_YELLOW,    FONT_UNDERLINED,            0},  // 0x4b || 0x6b
+    {COL_MAGENTA,   FONT_REGULAR,               0},  // 0x4c || 0x6c
+    {COL_MAGENTA,   FONT_UNDERLINED,            0},  // 0x4d || 0x6d
+    {COL_WHITE,     FONT_ITALICS,               0},  // 0x4e || 0x6e
+    {COL_WHITE,     FONT_UNDERLINED_ITALICS,    0},  // 0x4f || 0x6f
+    {COL_WHITE,     FONT_REGULAR,               0},  // 0x50 || 0x70
+    {COL_WHITE,     FONT_UNDERLINED,            0},  // 0x51 || 0x71
+    {COL_WHITE,     FONT_REGULAR,               4},  // 0x52 || 0x72
+    {COL_WHITE,     FONT_UNDERLINED,            4},  // 0x53 || 0x73
+    {COL_WHITE,     FONT_REGULAR,               8},  // 0x54 || 0x74
+    {COL_WHITE,     FONT_UNDERLINED,            8},  // 0x55 || 0x75
+    {COL_WHITE,     FONT_REGULAR,               12}, // 0x56 || 0x76
+    {COL_WHITE,     FONT_UNDERLINED,            12}, // 0x57 || 0x77
+    {COL_WHITE,     FONT_REGULAR,               16}, // 0x58 || 0x78
+    {COL_WHITE,     FONT_UNDERLINED,            16}, // 0x59 || 0x79
+    {COL_WHITE,     FONT_REGULAR,               20}, // 0x5a || 0x7a
+    {COL_WHITE,     FONT_UNDERLINED,            20}, // 0x5b || 0x7b
+    {COL_WHITE,     FONT_REGULAR,               24}, // 0x5c || 0x7c
+    {COL_WHITE,     FONT_UNDERLINED,            24}, // 0x5d || 0x7d
+    {COL_WHITE,     FONT_REGULAR,               28}, // 0x5e || 0x7e
+    {COL_WHITE,     FONT_UNDERLINED,            28}  // 0x5f || 0x7f
+};
+
+// Preencoded strings
+unsigned char encoded_crlf[16]; 
+unsigned int encoded_crlf_length;
+unsigned char encoded_br[16];
+unsigned int encoded_br_length;
+
+// Default color
+unsigned char usercolor_rgb[8]="";
+enum color_code default_color=COL_WHITE;
+
+const char *sami_header= // TODO: Revise the <!-- comments
+"<SAMI>\n\
+<HEAD>\n\
+<STYLE TYPE=\"text/css\">\n\
+<!--\n\
+P {margin-left: 16pt; margin-right: 16pt; margin-bottom: 16pt; margin-top: 16pt;\n\
+text-align: center; font-size: 18pt; font-family: arial; font-weight: bold; color: #f0f0f0;}\n\
+.UNKNOWNCC {Name:Unknown; lang:en-US; SAMIType:CC;}\n\
+-->\n\
+</STYLE>\n\
+</HEAD>\n\n\
+<BODY>\n";
+
+const char *command_type[] =
+{
+    "Unknown",
+    "EDM - EraseDisplayedMemory",
+    "RCL - ResumeCaptionLoading",
+    "EOC - End Of Caption",
+    "TO1 - Tab Offset, 1 column",
+    "TO2 - Tab Offset, 2 column",
+    "TO3 - Tab Offset, 3 column",
+    "RU2 - Roll up 2 rows",
+    "RU3 - Roll up 3 rows",
+    "RU4 - Roll up 4 rows",
+    "CR  - Carriage Return",
+    "ENM - Erase non-displayed memory",
+    "BS  - Backspace",
+    "RTD - Resume Text Display"
+};
+
+const char *font_text[]=
+{
+    "regular",
+    "italics",
+    "underlined",
+    "underlined italics"
+};
+
+const char *cc_modes_text[]=
+{
+    "Pop-Up captions"
+};
+
+const char *color_text[][2]=
+{
+    {"white",""},
+    {"green","<font color=\"#00ff00\">"},
+    {"blue","<font color=\"#0000ff\">"},
+    {"cyan","<font color=\"#00ffff\">"},
+    {"red","<font color=\"#ff0000\">"},
+    {"yellow","<font color=\"#ffff00\">"},
+    {"magenta","<font color=\"#ff00ff\">"},
+    {"userdefined","<font color=\""}
+};
+
+int general_608_init (struct s_write *wb)
+{
+    if( !wb->enc_buffer )
+    {
+        wb->enc_buffer=(unsigned char *) malloc (INITIAL_ENC_BUFFER_CAPACITY); 
+        if (wb->enc_buffer==NULL)
+            return -1;
+        wb->enc_buffer_capacity=INITIAL_ENC_BUFFER_CAPACITY;
+    }
+
+    if( !wb->subline) {
+        wb->subline = malloc(2048);
+    
+        if (!wb->subline)
+        {
+            return -1;
+        }
+    }
+
+    wb->new_sentence = 1;
+    wb->new_channel = 1;
+    wb->in_xds_mode = 0;
+
+    wb->hb_buffer = NULL;
+    wb->hb_last_buffer = NULL;
+    wb->last_pts = 0;
+    return 0;
+}
+
+/*
+ * Free up CC memory - don't call this from HB just yet since it will cause
+ * parallel encodes to fail - to be honest they will be stuffed anyway since
+ * the CC's may be overwriting the buffers.
+ */
+void general_608_close (struct s_write *wb)
+{
+    if( wb->enc_buffer ) {
+        free(wb->enc_buffer);
+        wb->enc_buffer_capacity = 0;
+        wb->enc_buffer_used = 0;
+    }
+    if( wb->subline ) {
+        free(wb->subline);
+    }
+
+    if( wb->hb_buffer ) {
+        hb_buffer_close( &wb->hb_buffer );
+    }
+}
+
+
+#include <ctype.h>
+
+void get_char_in_latin_1 (unsigned char *buffer, unsigned char c)
+{
+    unsigned char c1='?';
+    if (c<0x80) 
+    {  
+        // Regular line-21 character set, mostly ASCII except these exceptions
+        switch (c)
+        {
+            case 0x2a: // lowercase a, acute accent
+                c1=0xe1;
+                break;
+            case 0x5c: // lowercase e, acute accent
+                c1=0xe9;
+                break;
+            case 0x5e: // lowercase i, acute accent
+                c1=0xed;
+                break;                 
+            case 0x5f: // lowercase o, acute accent
+                c1=0xf3;
+                break;
+            case 0x60: // lowercase u, acute accent
+                c1=0xfa;
+                break;
+            case 0x7b: // lowercase c with cedilla
+                c1=0xe7;
+                break;
+            case 0x7c: // division symbol
+                c1=0xf7;
+                break;
+            case 0x7d: // uppercase N tilde
+                c1=0xd1;
+                break;
+            case 0x7e: // lowercase n tilde
+                c1=0xf1;
+                break;
+            default:
+                c1=c;
+                break;
+        }
+        *buffer=c1;
+        return;
+    }
+    switch (c)
+    {
+        // THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F           
+        case 0x80: // Registered symbol (R)
+            c1=0xae;
+            break;                     
+        case 0x81: // degree sign
+            c1=0xb0;
+            break;
+        case 0x82: // 1/2 symbol                       
+            c1=0xbd;
+            break;
+        case 0x83: // Inverted (open) question mark                    
+            c1=0xbf;
+            break;
+        case 0x84: // Trademark symbol (TM) - Does not exist in Latin 1
+            break;                     
+        case 0x85: // Cents symbol                     
+            c1=0xa2;
+            break;
+        case 0x86: // Pounds sterling                  
+            c1=0xa3;
+            break;
+        case 0x87: // Music note - Not in latin 1, so we use 'pilcrow'
+            c1=0xb6;
+            break;
+        case 0x88: // lowercase a, grave accent
+            c1=0xe0;
+            break;
+        case 0x89: // transparent space, we make it regular
+            c1=0x20;                   
+            break;
+        case 0x8a: // lowercase e, grave accent
+            c1=0xe8;
+            break;
+        case 0x8b: // lowercase a, circumflex accent
+            c1=0xe2;
+            break;
+        case 0x8c: // lowercase e, circumflex accent
+            c1=0xea;                   
+            break;
+        case 0x8d: // lowercase i, circumflex accent
+            c1=0xee;
+            break;
+        case 0x8e: // lowercase o, circumflex accent
+            c1=0xf4;
+            break;
+        case 0x8f: // lowercase u, circumflex accent
+            c1=0xfb;
+            break;
+        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F
+        case 0x90: // capital letter A with acute
+            c1=0xc1;
+            break;
+        case 0x91: // capital letter E with acute
+            c1=0xc9;
+            break;
+        case 0x92: // capital letter O with acute
+            c1=0xd3;
+            break;
+        case 0x93: // capital letter U with acute
+            c1=0xda;
+            break;
+        case 0x94: // capital letter U with diaresis
+            c1=0xdc;
+            break;
+        case 0x95: // lowercase letter U with diaeresis
+            c1=0xfc;
+            break;
+        case 0x96: // apostrophe
+            c1=0x27;                   
+            break;
+        case 0x97: // inverted exclamation mark                        
+            c1=0xa1;
+            break;
+        case 0x98: // asterisk
+            c1=0x2a;                   
+            break;
+        case 0x99: // apostrophe (yes, duped). See CCADI source code.
+            c1=0x27;                   
+            break;
+        case 0x9a: // hyphen-minus
+            c1=0x2d;                   
+            break;
+        case 0x9b: // copyright sign
+            c1=0xa9;
+            break;
+        case 0x9c: // Service Mark - not available in latin 1
+            break;
+        case 0x9d: // Full stop (.)
+            c1=0x2e;
+            break;
+        case 0x9e: // Quoatation mark
+            c1=0x22;                   
+            break;
+        case 0x9f: // Quoatation mark
+            c1=0x22;                   
+            break;
+        case 0xa0: // uppercase A, grave accent
+            c1=0xc0;
+            break;
+        case 0xa1: // uppercase A, circumflex
+            c1=0xc2;
+            break;                     
+        case 0xa2: // uppercase C with cedilla
+            c1=0xc7;
+            break;
+        case 0xa3: // uppercase E, grave accent
+            c1=0xc8;
+            break;
+        case 0xa4: // uppercase E, circumflex
+            c1=0xca;
+            break;
+        case 0xa5: // capital letter E with diaresis
+            c1=0xcb;
+            break;
+        case 0xa6: // lowercase letter e with diaresis
+            c1=0xeb;
+            break;
+        case 0xa7: // uppercase I, circumflex
+            c1=0xce;
+            break;
+        case 0xa8: // uppercase I, with diaresis
+            c1=0xcf;
+            break;
+        case 0xa9: // lowercase i, with diaresis
+            c1=0xef;
+            break;
+        case 0xaa: // uppercase O, circumflex
+            c1=0xd4;
+            break;
+        case 0xab: // uppercase U, grave accent
+            c1=0xd9;
+            break;
+        case 0xac: // lowercase u, grave accent
+            c1=0xf9;
+            break;
+        case 0xad: // uppercase U, circumflex
+            c1=0xdb;
+            break;
+        case 0xae: // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+            c1=0xab;
+            break;
+        case 0xaf: // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+            c1=0xbb;
+            break;
+        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F
+        case 0xb0: // Uppercase A, tilde
+            c1=0xc3;
+            break;
+        case 0xb1: // Lowercase a, tilde
+            c1=0xe3;
+            break;
+        case 0xb2: // Uppercase I, acute accent
+            c1=0xcd;
+            break;
+        case 0xb3: // Uppercase I, grave accent
+            c1=0xcc;
+            break;
+        case 0xb4: // Lowercase i, grave accent
+            c1=0xec;
+            break;
+        case 0xb5: // Uppercase O, grave accent
+            c1=0xd2;
+            break;
+        case 0xb6: // Lowercase o, grave accent
+            c1=0xf2;
+            break;
+        case 0xb7: // Uppercase O, tilde
+            c1=0xd5;
+            break;
+        case 0xb8: // Lowercase o, tilde
+            c1=0xf5;
+            break;
+        case 0xb9: // Open curly brace
+            c1=0x7b;
+            break;
+        case 0xba: // Closing curly brace
+            c1=0x7d;            
+            break;
+        case 0xbb: // Backslash
+            c1=0x5c;
+            break;
+        case 0xbc: // Caret
+            c1=0x5e;
+            break;
+        case 0xbd: // Underscore
+            c1=0x5f;
+            break;
+        case 0xbe: // Pipe (broken bar)            
+            c1=0xa6;
+            break;
+        case 0xbf: // Tilde
+            c1=0x7e; 
+            break;
+        case 0xc0: // Uppercase A, umlaut            
+            c1=0xc4;
+            break;
+        case 0xc1: // Lowercase A, umlaut
+            c1=0xe3; 
+            break;
+        case 0xc2: // Uppercase O, umlaut
+            c1=0xd6;
+            break;
+        case 0xc3: // Lowercase o, umlaut
+            c1=0xf6;
+            break;
+        case 0xc4: // Esszett (sharp S)
+            c1=0xdf;
+            break;
+        case 0xc5: // Yen symbol
+            c1=0xa5;
+            break;
+        case 0xc6: // Currency symbol
+            c1=0xa4;
+            break;            
+        case 0xc7: // Vertical bar
+            c1=0x7c;
+            break;            
+        case 0xc8: // Uppercase A, ring
+            c1=0xc5;
+            break;
+        case 0xc9: // Lowercase A, ring
+            c1=0xe5;
+            break;
+        case 0xca: // Uppercase O, slash
+            c1=0xd8;
+            break;
+        case 0xcb: // Lowercase o, slash
+            c1=0xf8;
+            break;
+        case 0xcc: // Upper left corner
+        case 0xcd: // Upper right corner
+        case 0xce: // Lower left corner
+        case 0xcf: // Lower right corner
+        default: // For those that don't have representation
+            *buffer='?'; // I'll do it eventually, I promise
+            break; // This are weird chars anyway
+    }
+    *buffer=c1;        
+}
+
+void get_char_in_unicode (unsigned char *buffer, unsigned char c)
+{
+    unsigned char c1,c2;
+    switch (c)
+    {
+        case 0x84: // Trademark symbol (TM) 
+            c2=0x21;
+            c1=0x22;
+            break;
+        case 0x87: // Music note
+            c2=0x26;
+            c1=0x6a;
+            break;
+        case 0x9c: // Service Mark
+            c2=0x21;
+            c1=0x20;
+            break;
+        case 0xcc: // Upper left corner
+            c2=0x23;
+            c1=0x1c;
+            break;                     
+        case 0xcd: // Upper right corner
+            c2=0x23;
+            c1=0x1d;
+            break;
+        case 0xce: // Lower left corner
+            c2=0x23;
+            c1=0x1e;
+            break;
+        case 0xcf: // Lower right corner
+            c2=0x23;
+            c1=0x1f;
+            break;
+        default: // Everything else, same as latin-1 followed by 00                    
+            get_char_in_latin_1 (&c1,c);
+            c2=0;
+            break;
+    }
+    *buffer=c1;
+    *(buffer+1)=c2;
+}
+
+int get_char_in_utf_8 (unsigned char *buffer, unsigned char c) // Returns number of bytes used
+{
+    if (c==0x00)
+        return 0;
+    if (c<0x80) // Regular line-21 character set, mostly ASCII except these exceptions
+    {
+        switch (c)
+        {
+        case 0x2a: // lowercase a, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0xa1;
+            return 2;
+        case 0x5c: // lowercase e, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0xa9;
+            return 2;
+        case 0x5e: // lowercase i, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0xad;
+            return 2;
+        case 0x5f: // lowercase o, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0xb3;
+            return 2;
+        case 0x60: // lowercase u, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0xba;
+            return 2;
+        case 0x7b: // lowercase c with cedilla
+            *buffer=0xc3;
+            *(buffer+1)=0xa7;
+            return 2;
+        case 0x7c: // division symbol
+            *buffer=0xc3;
+            *(buffer+1)=0xb7;
+            return 2;
+        case 0x7d: // uppercase N tilde
+            *buffer=0xc3;
+            *(buffer+1)=0x91;
+            return 2;
+        case 0x7e: // lowercase n tilde
+            *buffer=0xc3;
+            *(buffer+1)=0xb1;
+            return 2;
+        default:
+            *buffer=c;
+            return 1;
+        }
+    }
+    switch (c)
+    {
+        // THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F           
+        case 0x80: // Registered symbol (R)
+            *buffer=0xc2;
+            *(buffer+1)=0xae;                  
+            return 2;
+        case 0x81: // degree sign
+            *buffer=0xc2;
+            *(buffer+1)=0xb0;
+            return 2;
+        case 0x82: // 1/2 symbol
+            *buffer=0xc2;
+            *(buffer+1)=0xbd;
+            return 2;
+        case 0x83: // Inverted (open) question mark
+            *buffer=0xc2;
+            *(buffer+1)=0xbf;
+            return 2;
+        case 0x84: // Trademark symbol (TM)
+            *buffer=0xe2;
+            *(buffer+1)=0x84;
+            *(buffer+2)=0xa2;
+            return 3;
+        case 0x85: // Cents symbol
+            *buffer=0xc2;
+            *(buffer+1)=0xa2;
+            return 2;
+        case 0x86: // Pounds sterling
+            *buffer=0xc2;
+            *(buffer+1)=0xa3;
+            return 2;
+        case 0x87: // Music note                       
+            *buffer=0xe2;
+            *(buffer+1)=0x99;
+            *(buffer+2)=0xaa;
+            return 3;
+        case 0x88: // lowercase a, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0xa0;
+            return 2;
+        case 0x89: // transparent space, we make it regular
+            *buffer=0x20;                      
+            return 1;
+        case 0x8a: // lowercase e, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0xa8;
+            return 2;
+        case 0x8b: // lowercase a, circumflex accent
+            *buffer=0xc3;
+            *(buffer+1)=0xa2;
+            return 2;
+        case 0x8c: // lowercase e, circumflex accent
+            *buffer=0xc3;
+            *(buffer+1)=0xaa;
+            return 2;
+        case 0x8d: // lowercase i, circumflex accent
+            *buffer=0xc3;
+            *(buffer+1)=0xae;
+            return 2;
+        case 0x8e: // lowercase o, circumflex accent
+            *buffer=0xc3;
+            *(buffer+1)=0xb4;
+            return 2;
+        case 0x8f: // lowercase u, circumflex accent
+            *buffer=0xc3;
+            *(buffer+1)=0xbb;
+            return 2;
+        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F
+        case 0x90: // capital letter A with acute
+            *buffer=0xc3;
+            *(buffer+1)=0x81;
+            return 2;
+        case 0x91: // capital letter E with acute
+            *buffer=0xc3;
+            *(buffer+1)=0x89;
+            return 2;
+        case 0x92: // capital letter O with acute
+            *buffer=0xc3;
+            *(buffer+1)=0x93;
+            return 2;
+        case 0x93: // capital letter U with acute
+            *buffer=0xc3;
+            *(buffer+1)=0x9a;
+            return 2;
+        case 0x94: // capital letter U with diaresis
+            *buffer=0xc3;
+            *(buffer+1)=0x9c;
+            return 2;
+        case 0x95: // lowercase letter U with diaeresis
+            *buffer=0xc3;
+            *(buffer+1)=0xbc;
+            return 2;
+        case 0x96: // apostrophe
+            *buffer=0x27;                      
+            return 1;
+        case 0x97: // inverted exclamation mark
+            *buffer=0xc2;
+            *(buffer+1)=0xa1;
+            return 2;
+        case 0x98: // asterisk
+            *buffer=0x2a;                      
+            return 1;
+        case 0x99: // apostrophe (yes, duped). See CCADI source code.
+            *buffer=0x27;                      
+            return 1;
+        case 0x9a: // hyphen-minus
+            *buffer=0x2d;                      
+            return 1;
+        case 0x9b: // copyright sign
+            *buffer=0xc2;
+            *(buffer+1)=0xa9;
+            return 2;
+        case 0x9c: // Service mark 
+            *buffer=0xe2;                      
+            *(buffer+1)=0x84;
+            *(buffer+2)=0xa0;
+            return 3;
+        case 0x9d: // Full stop (.)
+            *buffer=0x2e;                      
+            return 1;
+        case 0x9e: // Quoatation mark
+            *buffer=0x22;                      
+            return 1;
+        case 0x9f: // Quoatation mark
+            *buffer=0x22;                      
+            return 1;
+        case 0xa0: // uppercase A, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0x80;
+            return 2;
+        case 0xa1: // uppercase A, circumflex
+            *buffer=0xc3;
+            *(buffer+1)=0x82;
+            return 2;
+        case 0xa2: // uppercase C with cedilla
+            *buffer=0xc3;
+            *(buffer+1)=0x87;
+            return 2;
+        case 0xa3: // uppercase E, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0x88;
+            return 2;
+        case 0xa4: // uppercase E, circumflex
+            *buffer=0xc3;
+            *(buffer+1)=0x8a;
+            return 2;
+        case 0xa5: // capital letter E with diaresis
+            *buffer=0xc3;
+            *(buffer+1)=0x8b;
+            return 2;
+        case 0xa6: // lowercase letter e with diaresis
+            *buffer=0xc3;
+            *(buffer+1)=0xab;
+            return 2;
+        case 0xa7: // uppercase I, circumflex
+            *buffer=0xc3;
+            *(buffer+1)=0x8e;
+            return 2;
+        case 0xa8: // uppercase I, with diaresis
+            *buffer=0xc3;
+            *(buffer+1)=0x8f;
+            return 2;
+        case 0xa9: // lowercase i, with diaresis
+            *buffer=0xc3;
+            *(buffer+1)=0xaf;
+            return 2;
+        case 0xaa: // uppercase O, circumflex
+            *buffer=0xc3;
+            *(buffer+1)=0x94;
+            return 2;
+        case 0xab: // uppercase U, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0x99;
+            return 2;
+        case 0xac: // lowercase u, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0xb9;
+            return 2;
+        case 0xad: // uppercase U, circumflex
+            *buffer=0xc3;
+            *(buffer+1)=0x9b;
+            return 2;
+        case 0xae: // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+            *buffer=0xc2;
+            *(buffer+1)=0xab;
+            return 2;
+        case 0xaf: // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+            *buffer=0xc2;
+            *(buffer+1)=0xbb;
+            return 2;
+        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS
+        // THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F
+        case 0xb0: // Uppercase A, tilde
+            *buffer=0xc3;
+            *(buffer+1)=0x83;
+            return 2;
+        case 0xb1: // Lowercase a, tilde
+            *buffer=0xc3;
+            *(buffer+1)=0xa3;
+            return 2;
+        case 0xb2: // Uppercase I, acute accent
+            *buffer=0xc3;
+            *(buffer+1)=0x8d;
+            return 2;
+        case 0xb3: // Uppercase I, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0x8c;
+            return 2;
+        case 0xb4: // Lowercase i, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0xac;
+            return 2;
+        case 0xb5: // Uppercase O, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0x92;
+            return 2;
+        case 0xb6: // Lowercase o, grave accent
+            *buffer=0xc3;
+            *(buffer+1)=0xb2;
+            return 2;
+        case 0xb7: // Uppercase O, tilde
+            *buffer=0xc3;
+            *(buffer+1)=0x95;
+            return 2;
+        case 0xb8: // Lowercase o, tilde
+            *buffer=0xc3;
+            *(buffer+1)=0xb5;
+            return 2;
+        case 0xb9: // Open curly brace
+            *buffer=0x7b;
+            return 1;
+        case 0xba: // Closing curly brace
+            *buffer=0x7d;            
+            return 1;
+        case 0xbb: // Backslash
+            *buffer=0x5c;
+            return 1;
+        case 0xbc: // Caret
+            *buffer=0x5e;
+            return 1;
+        case 0xbd: // Underscore
+            *buffer=0x5f;
+            return 1;
+        case 0xbe: // Pipe (broken bar)
+            *buffer=0xc2; 
+            *(buffer+1)=0xa6;
+            return 1;
+        case 0xbf: // Tilde
+            *buffer=0x7e; // Not sure
+            return 1;
+        case 0xc0: // Uppercase A, umlaut
+            *buffer=0xc3; 
+            *(buffer+1)=0x84;
+            return 2;
+        case 0xc1: // Lowercase A, umlaut
+            *buffer=0xc3; 
+            *(buffer+1)=0xa4;
+            return 2;
+        case 0xc2: // Uppercase O, umlaut
+            *buffer=0xc3; 
+            *(buffer+1)=0x96;
+            return 2;
+        case 0xc3: // Lowercase o, umlaut
+            *buffer=0xc3; 
+            *(buffer+1)=0xb6;
+            return 2;
+        case 0xc4: // Esszett (sharp S)
+            *buffer=0xc3;
+            *(buffer+1)=0x9f;
+            return 2;
+        case 0xc5: // Yen symbol
+            *buffer=0xc2;
+            *(buffer+1)=0xa5;
+            return 2;
+        case 0xc6: // Currency symbol
+            *buffer=0xc2;
+            *(buffer+1)=0xa4;
+            return 2;
+        case 0xc7: // Vertical bar
+            *buffer=0x7c; 
+            return 1;
+        case 0xc8: // Uppercase A, ring
+            *buffer=0xc3;
+            *(buffer+1)=0x85;
+            return 2;
+        case 0xc9: // Lowercase A, ring
+            *buffer=0xc3;
+            *(buffer+1)=0xa5;
+            return 2;
+        case 0xca: // Uppercase O, slash
+            *buffer=0xc3;
+            *(buffer+1)=0x98;
+            return 2;
+        case 0xcb: // Lowercase o, slash
+            *buffer=0xc3;
+            *(buffer+1)=0xb8;
+            return 2;
+        case 0xcc: // Upper left corner
+            *buffer=0xe2;
+            *(buffer+1)=0x8c;
+            *(buffer+2)=0x9c;
+            return 3;
+        case 0xcd: // Upper right corner
+            *buffer=0xe2;
+            *(buffer+1)=0x8c;
+            *(buffer+2)=0x9d;
+            return 3;
+        case 0xce: // Lower left corner
+            *buffer=0xe2;
+            *(buffer+1)=0x8c;
+            *(buffer+2)=0x9e;
+            return 3;
+        case 0xcf: // Lower right corner
+            *buffer=0xe2;
+            *(buffer+1)=0x8c;
+            *(buffer+2)=0x9f;
+            return 3;
+        default: // 
+            *buffer='?'; // I'll do it eventually, I promise
+            return 1; // This are weird chars anyway
+    }
+}
+
+unsigned char cctolower (unsigned char c)
+{
+    if (c>='A' && c<='Z')
+        return tolower(c);
+    switch (c)
+    {
+        case 0x7d: // uppercase N tilde
+            return 0x7e;
+        case 0x90: // capital letter A with acute
+            return 0x2a;
+        case 0x91: // capital letter E with acute
+            return 0x5c; 
+        case 0x92: // capital letter O with acute
+            return 0x5f; 
+        case 0x93: // capital letter U with acute
+            return 0x60; 
+        case 0xa2: // uppercase C with cedilla
+            return 0x7b; 
+        case 0xa0: // uppercase A, grave accent
+            return 0x88; 
+        case 0xa3: // uppercase E, grave accent
+            return 0x8a; 
+        case 0xa1: // uppercase A, circumflex
+            return 0x8b; 
+        case 0xa4: // uppercase E, circumflex
+            return 0x8c; 
+        case 0xa7: // uppercase I, circumflex
+            return 0x8d; 
+        case 0xaa: // uppercase O, circumflex
+            return 0x8e; 
+        case 0xad: // uppercase U, circumflex
+            return 0x8f; 
+        case 0x94: // capital letter U with diaresis
+            return 0x95; 
+        case 0xa5: // capital letter E with diaresis
+            return 0xa6; 
+        case 0xa8: // uppercase I, with diaresis
+            return 0xa9; 
+        case 0xab: // uppercase U, grave accent
+            return 0xac; 
+        case 0xb0: // Uppercase A, tilde
+            return 0xb1;
+        case 0xb2: // Uppercase I, acute accent
+            return 0x5e;
+        case 0xb3: // Uppercase I, grave accent
+            return 0xb4;
+        case 0xb5: // Uppercase O, grave accent
+            return 0xb6;
+        case 0xb7: // Uppercase O, tilde
+            return 0xb8;
+        case 0xc0: // Uppercase A, umlaut
+            return 0xc1;
+        case 0xc2: // Uppercase O, umlaut
+            return 0xc3;
+        case 0xc8: // Uppercase A, ring
+            return 0xc9;
+        case 0xca: // Uppercase O, slash
+            return 0xcb;
+    }
+    return c;
+}
+
+unsigned char cctoupper (unsigned char c)
+{
+    if (c>='a' && c<='z')
+        return toupper(c);
+    switch (c)
+    {
+        case 0x7e: // lowercase n tilde
+            return 0x7d;
+        case 0x2a: // lowercase a, acute accent
+            return 0x90;
+        case 0x5c: // lowercase e, acute accent
+            return 0x91;
+        case 0x5e: // lowercase i, acute accent
+            return 0xb2;
+        case 0x5f: // lowercase o, acute accent
+            return 0x92;
+        case 0x60: // lowercase u, acute accent
+            return 0x93;
+        case 0x7b: // lowercase c with cedilla
+            return 0xa2;
+        case 0x88: // lowercase a, grave accent
+            return 0xa0;
+        case 0x8a: // lowercase e, grave accent
+            return 0xa3;
+        case 0x8b: // lowercase a, circumflex accent
+            return 0xa1;
+        case 0x8c: // lowercase e, circumflex accent
+            return 0xa4;
+        case 0x8d: // lowercase i, circumflex accent
+            return 0xa7;
+        case 0x8e: // lowercase o, circumflex accent
+            return 0xaa;
+        case 0x8f: // lowercase u, circumflex accent
+            return 0xad;
+        case 0x95: // lowercase letter U with diaeresis
+            return 0x94;
+        case 0xa6: // lowercase letter e with diaresis
+            return 0xa5;
+        case 0xa9: // lowercase i, with diaresis
+            return 0xa8;
+        case 0xac: // lowercase u, grave accent
+            return 0xab;
+        case 0xb1: // Lowercase a, tilde
+            return 0xb0; 
+        case 0xb4: // Lowercase i, grave accent
+            return 0xb3;
+        case 0xb6: // Lowercase o, grave accent
+            return 0xb5; 
+        case 0xb8: // Lowercase o, tilde       
+            return 0xb7;
+        case 0xc1: // Lowercase A, umlaut      
+            return 0xc0; 
+        case 0xc3: // Lowercase o, umlaut
+            return 0xc2;
+        case 0xc9: // Lowercase A, ring
+            return 0xc8; 
+        case 0xcb: // Lowercase o, slash
+            return 0xca; 
+    }
+    return c;
+}
+
+
+// Encodes a generic string. Note that since we use the encoders for closed caption
+// data, text would have to be encoded as CCs... so using special characters here
+// it's a bad idea. 
+unsigned encode_line (unsigned char *buffer, unsigned char *text)
+{ 
+    unsigned bytes=0;
+    while (*text)
+    {          
+        switch (encoding)
+        {
+            case ENC_UTF_8:
+            case ENC_LATIN_1:
+                *buffer=*text;
+                bytes++;
+                buffer++;
+                break;
+        case ENC_UNICODE:                              
+            *buffer=*text;                             
+            *(buffer+1)=0;
+            bytes+=2;                          
+            buffer+=2;
+            break;
+        }              
+        text++;
+    }
+    return bytes;
+}
+
+#define ISSEPARATOR(c) (c==' ' || c==0x89 || ispunct(c) \
+    || c==0x99) // This is the apostrofe. We get it here in CC encoding, not ASCII
+
+
+void correct_case (int line_num, struct eia608_screen *data)
+{
+/*     int i=0; */
+/*     while (i<spell_words) */
+/*     { */
+/*         char *c=(char *) data->characters[line_num]; */
+/*         size_t len=strlen (spell_correct[i]); */
+/*         while ((c=strstr (c,spell_lower[i]))!=NULL) */
+/*         { */
+/*             // Make sure it's a whole word (start of line or */
+/*             // preceded by space, and end of line or followed by */
+/*             // space) */
+/*             unsigned char prev; */
+/*             if (c==(char *) data->characters[line_num]) // Beginning of line... */
+/*                 prev=' '; // ...Pretend we had a blank before */
+/*             else */
+/*                 prev=*(c-1);              */
+/*             unsigned char next; */
+/*             if (c-(char *) data->characters[line_num]+len==CC608_SCREEN_WIDTH) // End of line... */
+/*                 next=' '; // ... pretend we have a blank later */
+/*             else */
+/*                 next=*(c+len);                       */
+/*             if ( ISSEPARATOR(prev) && ISSEPARATOR(next)) */
+/*             { */
+/*                 memcpy (c,spell_correct[i],len); */
+/*             } */
+/*             c++; */
+/*         } */
+/*         i++; */
+/*     } */
+}
+
+void capitalize (int line_num, struct eia608_screen *data, int *new_sentence)
+{
+    int i;
+
+    for (i=0;i<CC608_SCREEN_WIDTH;i++)
+    {
+        switch (data->characters[line_num][i])
+        {
+            case ' ': 
+            case 0x89: // This is a transparent space
+            case '-':
+                break; 
+            case '.': // Fallthrough
+            case '?': // Fallthrough
+            case '!':
+            case ':':
+                *new_sentence=1;
+                break;
+            default:
+                if (*new_sentence)                     
+                    data->characters[line_num][i]=cctoupper (data->characters[line_num][i]);
+                else
+                    data->characters[line_num][i]=cctolower (data->characters[line_num][i]);
+                *new_sentence=0;
+                break;
+        }
+    }
+}
+
+void find_limit_characters (unsigned char *line, int *first_non_blank, int *last_non_blank)
+{
+    int i;
+
+    *last_non_blank=-1;
+    *first_non_blank=-1;
+    for (i=0;i<CC608_SCREEN_WIDTH;i++)
+    {
+        unsigned char c=line[i];
+        if (c!=' ' && c!=0x89)
+        {
+            if (*first_non_blank==-1)
+                *first_non_blank=i;
+            *last_non_blank=i;
+        }
+    }
+}
+
+unsigned get_decoder_line_basic (unsigned char *buffer, int line_num, struct eia608_screen *data)
+{
+    unsigned char *line = data->characters[line_num];
+    int last_non_blank=-1;
+    int first_non_blank=-1;
+    unsigned char *orig=buffer; // Keep for debugging
+    int i;
+    find_limit_characters (line, &first_non_blank, &last_non_blank);
+
+    if (first_non_blank==-1)
+    {
+        *buffer=0;
+        return 0;
+    }
+
+    int bytes=0;
+    for (i=first_non_blank;i<=last_non_blank;i++)
+    {
+        char c=line[i];
+        switch (encoding)
+        {
+            case ENC_UTF_8:
+                bytes=get_char_in_utf_8 (buffer,c);
+                break;
+            case ENC_LATIN_1:
+                get_char_in_latin_1 (buffer,c);
+                bytes=1;
+                break;
+            case ENC_UNICODE:
+                get_char_in_unicode (buffer,c);
+                bytes=2;                               
+                break;
+        }
+        buffer+=bytes;
+    }
+    *buffer=0;
+    return (unsigned) (buffer-orig); // Return length
+}
+
+unsigned get_decoder_line_encoded_for_gui (unsigned char *buffer, int line_num, struct eia608_screen *data)
+{
+    unsigned char *line = data->characters[line_num];  
+    unsigned char *orig=buffer; // Keep for debugging
+    int first=0, last=31;
+    int i;
+
+    find_limit_characters(line,&first,&last);
+    for (i=first;i<=last;i++)
+    {  
+        get_char_in_latin_1 (buffer,line[i]);
+        buffer++;
+    }
+    *buffer=0;
+    return (unsigned) (buffer-orig); // Return length
+
+}
+
+unsigned get_decoder_line_encoded (unsigned char *buffer, int line_num, struct eia608_screen *data)
+{
+    int col = COL_WHITE;
+    int underlined = 0;
+    int italics = 0;   
+    int i;
+
+    unsigned char *line = data->characters[line_num];  
+    unsigned char *orig=buffer; // Keep for debugging
+    int first=0, last=31;
+    if (trim_subs)
+        find_limit_characters(line,&first,&last);
+    for (i=first;i<=last;i++)
+    {  
+        // Handle color
+        int its_col = data->colors[line_num][i];
+        if (its_col != col  && !nofontcolor)
+        {
+            if (col!=COL_WHITE) // We need to close the previous font tag
+            {
+                buffer+= encode_line (buffer,(unsigned char *) "</font>");
+            }
+            // Add new font tag
+            buffer+=encode_line (buffer, (unsigned char*) color_text[its_col][1]);
+            if (its_col==COL_USERDEFINED)
+            {
+                // The previous sentence doesn't copy the whole 
+                // <font> tag, just up to the quote before the color
+                buffer+=encode_line (buffer, (unsigned char*) usercolor_rgb);
+                buffer+=encode_line (buffer, (unsigned char*) "\">");
+            }                  
+
+            col = its_col;
+        }
+        // Handle underlined
+        int is_underlined = data->fonts[line_num][i] & FONT_UNDERLINED;
+        if (is_underlined && underlined==0) // Open underline
+        {
+            buffer+=encode_line (buffer, (unsigned char *) "<u>");
+        }
+        if (is_underlined==0 && underlined) // Close underline
+        {
+            buffer+=encode_line (buffer, (unsigned char *) "</u>");
+        } 
+        underlined=is_underlined;
+        // Handle italics
+        int has_ita = data->fonts[line_num][i] & FONT_ITALICS;         
+        if (has_ita && italics==0) // Open italics
+        {
+            buffer+=encode_line (buffer, (unsigned char *) "<i>");
+        }
+        if (has_ita==0 && italics) // Close italics
+        {
+            buffer+=encode_line (buffer, (unsigned char *) "</i>");
+        } 
+        italics=has_ita;
+        int bytes=0;
+        switch (encoding)
+        {
+            case ENC_UTF_8:
+                bytes=get_char_in_utf_8 (buffer,line[i]);
+                break;
+            case ENC_LATIN_1:
+                get_char_in_latin_1 (buffer,line[i]);
+                bytes=1;
+                break;
+            case ENC_UNICODE:
+                get_char_in_unicode (buffer,line[i]);
+                bytes=2;                               
+                break;
+        }
+        buffer+=bytes;        
+    }
+    if (italics)
+    {
+        buffer+=encode_line (buffer, (unsigned char *) "</i>");
+    }
+    if (underlined)
+    {
+        buffer+=encode_line (buffer, (unsigned char *) "</u>");
+    }
+    if (col != COL_WHITE && !nofontcolor)
+    {
+        buffer+=encode_line (buffer, (unsigned char *) "</font>");
+    }
+    *buffer=0;
+    return (unsigned) (buffer-orig); // Return length
+}
+
+
+void delete_all_lines_but_current (struct eia608_screen *data, int row)
+{
+    int i;
+    for (i=0;i<15;i++)
+    {
+        if (i!=row)
+        {
+            memset(data->characters[i],' ',CC608_SCREEN_WIDTH);
+            data->characters[i][CC608_SCREEN_WIDTH]=0;         
+            memset (data->colors[i],default_color,CC608_SCREEN_WIDTH+1); 
+            memset (data->fonts[i],FONT_REGULAR,CC608_SCREEN_WIDTH+1); 
+            data->row_used[i]=0;        
+        }
+    }
+}
+
+void clear_eia608_cc_buffer (struct eia608_screen *data)
+{
+    int i;
+
+    for (i=0;i<15;i++)
+    {
+        memset(data->characters[i],' ',CC608_SCREEN_WIDTH);
+        data->characters[i][CC608_SCREEN_WIDTH]=0;             
+        memset (data->colors[i],default_color,CC608_SCREEN_WIDTH+1); 
+        memset (data->fonts[i],FONT_REGULAR,CC608_SCREEN_WIDTH+1); 
+        data->row_used[i]=0;        
+    }
+    data->empty=1;
+}
+
+void init_eia608 (struct eia608 *data)
+{
+    data->cursor_column=0;
+    data->cursor_row=0;
+    clear_eia608_cc_buffer (&data->buffer1);
+    clear_eia608_cc_buffer (&data->buffer2);
+    data->visible_buffer=1;
+    data->last_c1=0;
+    data->last_c2=0;
+    data->mode=MODE_POPUP;
+    // data->current_visible_start_cc=0;
+    data->current_visible_start_ms=0;
+    data->srt_counter=0;
+    data->screenfuls_counter=0;
+    data->channel=1;   
+    data->color=default_color;
+    data->font=FONT_REGULAR;
+    data->rollup_base_row=14;
+}
+
+struct eia608_screen *get_writing_buffer (struct s_write *wb)
+{
+    struct eia608_screen *use_buffer=NULL;
+    switch (wb->data608->mode)
+    {
+        case MODE_POPUP: // Write on the non-visible buffer
+            if (wb->data608->visible_buffer==1)
+                use_buffer = &wb->data608->buffer2;
+            else
+                use_buffer = &wb->data608->buffer1;
+            break;
+        case MODE_ROLLUP_2: // Write directly to screen
+        case MODE_ROLLUP_3:
+        case MODE_ROLLUP_4:
+            if (wb->data608->visible_buffer==1)
+                use_buffer = &wb->data608->buffer1;
+            else
+                use_buffer = &wb->data608->buffer2;
+            break;
+        default:
+            fatal (EXIT_BUG_BUG, "Caption mode has an illegal value at get_writing_buffer(), this is a bug.\n");            
+    }
+    return use_buffer;
+}
+
+void write_char (const unsigned char c, struct s_write *wb)
+{
+    if (wb->data608->mode!=MODE_TEXT)
+    {
+        struct eia608_screen * use_buffer=get_writing_buffer(wb);
+        /* hb_log ("\rWriting char [%c] at %s:%d:%d\n",c,
+        use_buffer == &wb->data608->buffer1?"B1":"B2",
+        wb->data608->cursor_row,wb->data608->cursor_column); */
+        use_buffer->characters[wb->data608->cursor_row][wb->data608->cursor_column]=c;
+        use_buffer->colors[wb->data608->cursor_row][wb->data608->cursor_column]=wb->data608->color;
+        use_buffer->fonts[wb->data608->cursor_row][wb->data608->cursor_column]=wb->data608->font;      
+        use_buffer->row_used[wb->data608->cursor_row]=1;
+        use_buffer->empty=0;
+        if (wb->data608->cursor_column<31)
+            wb->data608->cursor_column++;
+    }
+
+}
+
+/* Handle MID-ROW CODES. */
+void handle_text_attr (const unsigned char c1, const unsigned char c2, struct s_write *wb)
+{
+    // Handle channel change
+    wb->data608->channel=wb->new_channel;
+    if (wb->data608->channel!=cc_channel)
+        return;
+    if (debug_608)
+        hb_log ("\r608: text_attr: %02X %02X",c1,c2);
+    if ( ((c1!=0x11 && c1!=0x19) ||
+        (c2<0x20 || c2>0x2f)) && debug_608)
+    {
+        hb_log ("\rThis is not a text attribute!\n");
+    }
+    else
+    {
+        int i = c2-0x20;
+        wb->data608->color=pac2_attribs[i][0];
+        wb->data608->font=pac2_attribs[i][1];
+        if (debug_608)
+            hb_log ("  --  Color: %s,  font: %s\n",
+            color_text[wb->data608->color][0],
+            font_text[wb->data608->font]);
+        if (wb->data608->cursor_column<31)
+            wb->data608->cursor_column++;
+    }
+}
+
+void mstotime (LLONG milli, unsigned *hours, unsigned *minutes,
+               unsigned *seconds, unsigned *ms)
+{
+    // LLONG milli = (LLONG) ((ccblock*1000)/29.97);
+    *ms=(unsigned) (milli%1000); // milliseconds
+    milli=(milli-*ms)/1000;  // Remainder, in seconds
+    *seconds = (int) (milli%60);
+    milli=(milli-*seconds)/60; // Remainder, in minutes
+    *minutes = (int) (milli%60);
+    milli=(milli-*minutes)/60; // Remainder, in hours
+    *hours=(int) milli;
+}
+
+void write_subtitle_file_footer (struct s_write *wb)
+{
+    switch (write_format)
+    {
+        case OF_SAMI:
+            sprintf ((char *) str,"</BODY></SAMI>\n");
+            if (debug_608 && encoding!=ENC_UNICODE)
+            {
+                hb_log ("\r%s\n", str);
+            }
+            wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) str);
+            //fwrite (enc_buffer,enc_buffer_used,1,wb->fh);
+            XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+            break;
+        default: // Nothing to do. Only SAMI has a footer
+            break;
+    }
+}
+
+void fhb_log_encoded (FILE *fh, const char *string)
+{
+    //GUARANTEE(wb, strlen (string)*3);
+    //wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) string);
+    //fwrite (wb->enc_buffer,wb->enc_buffer_used,1,fh);
+}
+
+void write_subtitle_file_header (struct s_write *wb)
+{
+    switch (write_format)
+    {
+        case OF_SRT: // Subrip subtitles have no header
+            break; 
+        case OF_SAMI: // This header brought to you by McPoodle's CCASDI  
+            //fhb_log_encoded (wb->fh, sami_header);
+            GUARANTEE(wb, strlen (sami_header)*3);
+            wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) sami_header);
+            //fwrite (enc_buffer,enc_buffer_used,1,wb->fh);
+            XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+            break;
+        case OF_RCWT: // Write header
+            //fwrite (rcwt_header, sizeof(rcwt_header),1,wb->fh);
+            break;
+        case OF_TRANSCRIPT: // No header. Fall thru
+        default:
+            break;
+    }
+}
+
+void write_cc_line_as_transcript (struct eia608_screen *data, struct s_write *wb, int line_number)
+{
+    hb_buffer_t *buffer;
+
+    if (sentence_cap)
+    {
+        capitalize(line_number,data, &wb->new_sentence);
+        correct_case(line_number,data);
+    }
+    int length = get_decoder_line_basic (wb->subline, line_number, data);
+    if (debug_608 && encoding!=ENC_UNICODE)
+    {
+        hb_log ("\r");
+        hb_log ("%s\n",wb->subline);
+    }
+    if (length>0)
+    {
+        //fwrite (wb->subline, 1, length, wb->fh);
+        /*
+         * Put this subtitle in a hb_buffer_t and shove it into the subtitle fifo
+         */
+        buffer = hb_buffer_init( length + 1 );
+        buffer->start = wb->data608->current_visible_start_ms;
+        buffer->stop = get_fts(wb);
+        memcpy( buffer->data, wb->subline, length + 1 );
+        //hb_log("CC %lld: %s", buffer->stop, wb->subline);
+
+        if (wb->hb_last_buffer) {
+            wb->hb_last_buffer->next = buffer;
+        } else {
+            wb->hb_buffer = buffer;
+        }
+        wb->hb_last_buffer = buffer;
+
+        XMLRPC_APPEND(wb->subline,length);
+        //fwrite (encoded_crlf, 1, encoded_crlf_length,wb->fh);
+        XMLRPC_APPEND(encoded_crlf,encoded_crlf_length);    
+    }
+    // fhb_log (wb->fh,encoded_crlf);
+}
+
+int write_cc_buffer_as_transcript (struct eia608_screen *data, struct s_write *wb)
+{
+    int i;
+
+    int wrote_something = 0;
+    if (debug_608)
+    {
+        hb_log ("\n- - - TRANSCRIPT caption - - -\n");        
+    }
+    for (i=0;i<15;i++)
+    {
+        if (data->row_used[i])
+        {              
+            write_cc_line_as_transcript (data,wb, i);
+        }
+        wrote_something=1;
+    }
+    if (debug_608)
+    {
+        hb_log ("- - - - - - - - - - - -\r\n");
+    }
+    return wrote_something;
+}
+
+void write_cc_buffer_to_gui (struct eia608_screen *data, struct s_write *wb)
+{
+    unsigned h1,m1,s1,ms1;
+    unsigned h2,m2,s2,ms2;    
+    int i;
+
+    LLONG ms_start= wb->data608->current_visible_start_ms;
+
+    ms_start+=subs_delay;
+    if (ms_start<0) // Drop screens that because of subs_delay start too early
+        return;
+    int time_reported=0;    
+    for (i=0;i<15;i++)
+    {
+        if (data->row_used[i])
+        {
+            hb_log ("###SUBTITLE#");            
+            if (!time_reported)
+            {
+                LLONG ms_end = get_fts(wb)+subs_delay;         
+                mstotime (ms_start,&h1,&m1,&s1,&ms1);
+                mstotime (ms_end-1,&h2,&m2,&s2,&ms2); // -1 To prevent overlapping with next line.
+                // Note, only MM:SS here as we need to save space in the preview window
+                hb_log ("%02u:%02u#%02u:%02u#",
+                        h1*60+m1,s1, h2*60+m2,s2);
+                time_reported=1;
+            }
+            else
+                hb_log ("##");
+            
+            // We don't capitalize here because whatever function that was used
+            // before to write to file already took care of it.
+            int length = get_decoder_line_encoded_for_gui (wb->subline, i, data);
+            fwrite (wb->subline, 1, length, stderr);
+            fwrite ("\n",1,1,stderr);
+        }
+    }
+    fflush (stderr);
+}
+
+int write_cc_buffer_as_srt (struct eia608_screen *data, struct s_write *wb)
+{
+    unsigned h1,m1,s1,ms1;
+    unsigned h2,m2,s2,ms2;
+    int wrote_something = 0;
+    LLONG ms_start= wb->data608->current_visible_start_ms;
+    int i;
+
+    ms_start+=subs_delay;
+    if (ms_start<0) // Drop screens that because of subs_delay start too early
+        return 0;
+
+    LLONG ms_end = get_fts(wb)+subs_delay;             
+    mstotime (ms_start,&h1,&m1,&s1,&ms1);
+    mstotime (ms_end-1,&h2,&m2,&s2,&ms2); // -1 To prevent overlapping with next line.
+    char timeline[128];   
+    wb->data608->srt_counter++;
+    sprintf (timeline,"%u\r\n",wb->data608->srt_counter);
+    //wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) timeline);
+    //fwrite (wb->enc_buffer,wb->enc_buffer_used,1,wb->fh);
+    XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+    //sprintf (timeline, "%02u:%02u:%02u,%03u --> %02u:%02u:%02u,%03u\r\n",
+    //      h1,m1,s1,ms1, h2,m2,s2,ms2);
+    //wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) timeline);
+    if (debug_608)
+    {
+        hb_log ("\n- - - SRT caption - - -\n");
+        hb_log (timeline);
+    }
+    //fwrite (enc_buffer,enc_buffer_used,1,wb->fh);            
+    XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+    
+    /*
+     * Write all the lines into enc_buffer, and then write that out at the end
+     * ensure that we only have two lines, insert a newline after the first one,
+     * and have a big bottom line (strip spaces from any joined lines).
+     */
+    int line = 1;
+    for (i=0;i<15;i++)
+    {
+        if (data->row_used[i])
+        {              
+            if (sentence_cap)
+            {
+                capitalize(i,data, &wb->new_sentence);
+                correct_case(i,data);
+            }
+            /*
+             * The intention was to use a newline but QT doesn't like it, old code still
+             * here just in case..
+             */
+            if (line == 1) {
+                wb->enc_buffer_used = get_decoder_line_encoded (wb->enc_buffer, i, data);
+                line = 2;
+            } else {
+                if (line == 2) {
+                    wb->enc_buffer_used += encode_line (wb->enc_buffer+wb->enc_buffer_used,
+                                                        (unsigned char *) "\n");
+                    line = 3;
+                } else {
+                    wb->enc_buffer_used += encode_line (wb->enc_buffer+wb->enc_buffer_used,
+                                                        (unsigned char *) " "); 
+                }
+                wb->enc_buffer_used += get_decoder_line_encoded (wb->enc_buffer+wb->enc_buffer_used, i, data);
+            }
+        }
+    }
+    if (wb->enc_buffer_used)
+    {
+        hb_buffer_t *buffer = hb_buffer_init( wb->enc_buffer_used + 1 );
+        buffer->start = ms_start;
+        buffer->stop = ms_end;
+        memcpy( buffer->data, wb->enc_buffer, wb->enc_buffer_used + 1 );
+        if (wb->hb_last_buffer) {
+            wb->hb_last_buffer->next = buffer;
+        } else {
+            wb->hb_buffer = buffer;
+        }
+        wb->hb_last_buffer = buffer;
+        
+        wrote_something=1;
+    }
+    if (debug_608)
+    {
+        hb_log ("- - - - - - - - - - - -\r\n");
+    }
+    // fhb_log (wb->fh, encoded_crlf);
+    //fwrite (encoded_crlf, 1, encoded_crlf_length,wb->fh);
+    XMLRPC_APPEND(encoded_crlf,encoded_crlf_length);
+    return wrote_something;
+}
+
+int write_cc_buffer_as_sami (struct eia608_screen *data, struct s_write *wb)
+{
+    int wrote_something=0;
+    LLONG startms = wb->data608->current_visible_start_ms;
+    int i;
+
+    startms+=subs_delay;
+    if (startms<0) // Drop screens that because of subs_delay start too early
+        return 0; 
+
+    LLONG endms   = get_fts(wb)+subs_delay;
+    endms--; // To prevent overlapping with next line.
+    sprintf ((char *) str,"<SYNC start=\"%llu\"><P class=\"UNKNOWNCC\">\r\n",startms);
+    if (debug_608 && encoding!=ENC_UNICODE)
+    {
+        hb_log ("\r%s\n", str);
+    }
+    wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) str);
+    fwrite (wb->enc_buffer,wb->enc_buffer_used,1,wb->fh);              
+    XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+    for (i=0;i<15;i++)
+    {
+        if (data->row_used[i])
+        {                              
+            int length = get_decoder_line_encoded (wb->subline, i, data);
+            if (debug_608 && encoding!=ENC_UNICODE)
+            {
+                hb_log ("\r");
+                hb_log ("%s\n",wb->subline);
+            }
+            fwrite (wb->subline, 1, length, wb->fh);
+            XMLRPC_APPEND(wb->subline,length);
+            wrote_something=1;
+            if (i!=14)
+            {
+                fwrite (encoded_br, 1, encoded_br_length,wb->fh);                      
+                XMLRPC_APPEND(encoded_br, encoded_br_length);
+            }
+            fwrite (encoded_crlf, 1, encoded_crlf_length,wb->fh);
+            XMLRPC_APPEND(encoded_crlf, encoded_crlf_length);
+        }
+    }
+    sprintf ((char *) str,"</P></SYNC>\r\n");
+    if (debug_608 && encoding!=ENC_UNICODE)
+    {
+        hb_log ("\r%s\n", str);
+    }
+    wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) str);
+    fwrite (wb->enc_buffer,wb->enc_buffer_used,1,wb->fh);
+    XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+    sprintf ((char *) str,"<SYNC start=\"%llu\"><P class=\"UNKNOWNCC\">&nbsp;</P></SYNC>\r\n\r\n",endms);
+    if (debug_608 && encoding!=ENC_UNICODE)
+    {
+        hb_log ("\r%s\n", str);
+    }
+    wb->enc_buffer_used=encode_line (wb->enc_buffer,(unsigned char *) str);
+    fwrite (wb->enc_buffer,wb->enc_buffer_used,1,wb->fh);
+    XMLRPC_APPEND(wb->enc_buffer,wb->enc_buffer_used);
+    return wrote_something;
+}
+
+struct eia608_screen *get_current_visible_buffer (struct s_write *wb)
+{
+    struct eia608_screen *data;
+    if (wb->data608->visible_buffer==1)
+        data = &wb->data608->buffer1;
+    else
+        data = &wb->data608->buffer2;
+    return data;
+}
+
+
+int write_cc_buffer (struct s_write *wb)
+{
+    struct eia608_screen *data;
+    int wrote_something=0;
+    if (screens_to_process!=-1 && wb->data608->screenfuls_counter>=screens_to_process)
+    {
+        // We are done. 
+        processed_enough=1;
+        return 0;
+    }
+    if (wb->data608->visible_buffer==1)
+        data = &wb->data608->buffer1;
+    else
+        data = &wb->data608->buffer2;
+
+    if (!data->empty)
+    {
+        wb->new_sentence=1;
+        switch (write_format)
+        {
+            case OF_SRT:
+                wrote_something = write_cc_buffer_as_srt (data, wb);
+                break;
+            case OF_SAMI:
+                wrote_something = write_cc_buffer_as_sami (data,wb);
+                break;
+            case OF_TRANSCRIPT:
+                wrote_something = write_cc_buffer_as_transcript (data,wb);
+                break;
+        default: 
+                break;
+        }
+        if (wrote_something && gui_mode_reports)
+            write_cc_buffer_to_gui (data,wb);
+    }
+    return wrote_something;
+}
+
+void roll_up(struct s_write *wb)
+{
+    struct eia608_screen *use_buffer;
+    int i, j;
+
+    if (wb->data608->visible_buffer==1)
+        use_buffer = &wb->data608->buffer1;
+    else
+        use_buffer = &wb->data608->buffer2;
+    int keep_lines;
+    switch (wb->data608->mode)
+    {
+        case MODE_ROLLUP_2:
+            keep_lines=2;
+            break;
+        case MODE_ROLLUP_3:
+            keep_lines=3;
+            break;
+        case MODE_ROLLUP_4:
+            keep_lines=4;
+            break;
+        default: // Shouldn't happen
+            keep_lines=0;
+            break;
+    }
+    int firstrow=-1, lastrow=-1;
+    // Look for the last line used
+    int rows_now=0; // Number of rows in use right now
+    for (i=0;i<15;i++)
+    {
+        if (use_buffer->row_used[i])
+        {
+            rows_now++;
+            if (firstrow==-1)
+                firstrow=i;
+            lastrow=i;
+        }
+    }
+    
+    if (debug_608)
+        hb_log ("\rIn roll-up: %d lines used, first: %d, last: %d\n", rows_now, firstrow, lastrow);
+
+    if (lastrow==-1) // Empty screen, nothing to rollup
+        return;
+
+    for (j=lastrow-keep_lines+1;j<lastrow; j++)
+    {
+        if (j>=0)
+        {
+            memcpy (use_buffer->characters[j],use_buffer->characters[j+1],CC608_SCREEN_WIDTH+1);
+            memcpy (use_buffer->colors[j],use_buffer->colors[j+1],CC608_SCREEN_WIDTH+1);
+            memcpy (use_buffer->fonts[j],use_buffer->fonts[j+1],CC608_SCREEN_WIDTH+1);
+            use_buffer->row_used[j]=use_buffer->row_used[j+1];
+        }
+    }
+    for (j=0;j<(1+wb->data608->cursor_row-keep_lines);j++)
+    {
+        memset(use_buffer->characters[j],' ',CC608_SCREEN_WIDTH);                      
+        memset(use_buffer->colors[j],COL_WHITE,CC608_SCREEN_WIDTH);
+        memset(use_buffer->fonts[j],FONT_REGULAR,CC608_SCREEN_WIDTH);
+        use_buffer->characters[j][CC608_SCREEN_WIDTH]=0;
+        use_buffer->row_used[j]=0;
+    }
+    memset(use_buffer->characters[lastrow],' ',CC608_SCREEN_WIDTH);
+    memset(use_buffer->colors[lastrow],COL_WHITE,CC608_SCREEN_WIDTH);
+    memset(use_buffer->fonts[lastrow],FONT_REGULAR,CC608_SCREEN_WIDTH);
+
+    use_buffer->characters[lastrow][CC608_SCREEN_WIDTH]=0;
+    use_buffer->row_used[lastrow]=0;
+    
+    // Sanity check
+    rows_now=0;
+    for (i=0;i<15;i++)
+        if (use_buffer->row_used[i])
+            rows_now++;
+    if (rows_now>keep_lines)
+        hb_log ("Bug in roll_up, should have %d lines but I have %d.\n",
+            keep_lines, rows_now);
+}
+
+void erase_memory (struct s_write *wb, int displayed)
+{
+    struct eia608_screen *buf;
+    if (displayed)
+    {
+        if (wb->data608->visible_buffer==1)
+            buf=&wb->data608->buffer1;
+        else
+            buf=&wb->data608->buffer2;
+    }
+    else
+    {
+        if (wb->data608->visible_buffer==1)
+            buf=&wb->data608->buffer2;
+        else
+            buf=&wb->data608->buffer1;
+    }
+    clear_eia608_cc_buffer (buf);
+}
+
+int is_current_row_empty (struct s_write *wb)
+{
+    struct eia608_screen *use_buffer;
+    int i;
+
+    if (wb->data608->visible_buffer==1)
+        use_buffer = &wb->data608->buffer1;
+    else
+        use_buffer = &wb->data608->buffer2;
+    for (i=0;i<CC608_SCREEN_WIDTH;i++)
+    {
+        if (use_buffer->characters[wb->data608->rollup_base_row][i]!=' ')
+            return 0;
+    }
+    return 1;
+}
+
+/* Process GLOBAL CODES */
+void handle_command (/*const */ unsigned char c1, const unsigned char c2, struct s_write *wb)
+{
+    // Handle channel change
+    wb->data608->channel=wb->new_channel;
+    if (wb->data608->channel!=cc_channel)
+        return;
+
+    enum command_code command = COM_UNKNOWN;
+    if (c1==0x15)
+        c1=0x14;
+    if ((c1==0x14 || c1==0x1C) && c2==0x2C)
+        command = COM_ERASEDISPLAYEDMEMORY;
+    if ((c1==0x14 || c1==0x1C) && c2==0x20)
+        command = COM_RESUMECAPTIONLOADING;
+    if ((c1==0x14 || c1==0x1C) && c2==0x2F)
+        command = COM_ENDOFCAPTION;
+    if ((c1==0x17 || c1==0x1F) && c2==0x21)
+        command = COM_TABOFFSET1;
+    if ((c1==0x17 || c1==0x1F) && c2==0x22)
+        command = COM_TABOFFSET2;
+    if ((c1==0x17 || c1==0x1F) && c2==0x23)
+        command = COM_TABOFFSET3;
+    if ((c1==0x14 || c1==0x1C) && c2==0x25)
+        command = COM_ROLLUP2;
+    if ((c1==0x14 || c1==0x1C) && c2==0x26)
+        command = COM_ROLLUP3;
+    if ((c1==0x14 || c1==0x1C) && c2==0x27)
+        command = COM_ROLLUP4;
+    if ((c1==0x14 || c1==0x1C) && c2==0x2D)
+        command = COM_CARRIAGERETURN;
+    if ((c1==0x14 || c1==0x1C) && c2==0x2E)
+        command = COM_ERASENONDISPLAYEDMEMORY;
+    if ((c1==0x14 || c1==0x1C) && c2==0x21)
+        command = COM_BACKSPACE;
+    if ((c1==0x14 || c1==0x1C) && c2==0x2b)
+        command = COM_RESUMETEXTDISPLAY;
+    if (debug_608)
+    {
+        hb_log ("\rCommand: %02X %02X (%s)\n",c1,c2,command_type[command]);
+    }
+    switch (command)
+    {
+        case COM_BACKSPACE:
+            if (wb->data608->cursor_column>0)
+            {
+                wb->data608->cursor_column--;
+                get_writing_buffer(wb)->characters[wb->data608->cursor_row][wb->data608->cursor_column]=' ';
+            }
+            break;
+        case COM_TABOFFSET1:
+            if (wb->data608->cursor_column<31)
+                wb->data608->cursor_column++;
+            break;
+        case COM_TABOFFSET2:
+            wb->data608->cursor_column+=2;
+            if (wb->data608->cursor_column>31)
+                wb->data608->cursor_column=31;
+            break;
+        case COM_TABOFFSET3:
+            wb->data608->cursor_column+=3;
+            if (wb->data608->cursor_column>31)
+                wb->data608->cursor_column=31;
+            break;
+        case COM_RESUMECAPTIONLOADING:
+            wb->data608->mode=MODE_POPUP;
+            break;
+        case COM_RESUMETEXTDISPLAY:
+            wb->data608->mode=MODE_TEXT;
+            break;
+        case COM_ROLLUP2:            
+            if (wb->data608->mode==MODE_POPUP)
+            {
+                if (write_cc_buffer (wb))
+                    wb->data608->screenfuls_counter++;
+                erase_memory (wb, 1);                  
+            }
+            if (wb->data608->mode==MODE_ROLLUP_2 && !is_current_row_empty(wb))
+            {
+                if (debug_608)
+                    hb_log ("Two RU2, current line not empty. Simulating a CR\n");
+                handle_command(0x14, 0x2D, wb);
+            }   
+            wb->data608->mode=MODE_ROLLUP_2;
+            erase_memory (wb, 0);
+            wb->data608->cursor_column=0;
+            wb->data608->cursor_row=wb->data608->rollup_base_row;
+            break;
+        case COM_ROLLUP3:
+            if (wb->data608->mode==MODE_POPUP)
+            {
+                if (write_cc_buffer (wb))
+                    wb->data608->screenfuls_counter++;
+                erase_memory (wb, 1);
+            }
+            if (wb->data608->mode==MODE_ROLLUP_3 && !is_current_row_empty(wb))
+            {
+                if (debug_608)
+                    hb_log ("Two RU3, current line not empty. Simulating a CR\n");
+                handle_command(0x14, 0x2D, wb);
+            }
+            wb->data608->mode=MODE_ROLLUP_3;
+            erase_memory (wb, 0);
+            wb->data608->cursor_column=0;
+            wb->data608->cursor_row=wb->data608->rollup_base_row;
+            break;
+        case COM_ROLLUP4:
+            if (wb->data608->mode==MODE_POPUP)
+            {
+                if (write_cc_buffer (wb))
+                    wb->data608->screenfuls_counter++;
+                erase_memory (wb, 1);                  
+            }
+            if (wb->data608->mode==MODE_ROLLUP_4 && !is_current_row_empty(wb))
+            {
+                if (debug_608)
+                    hb_log ("Two RU4, current line not empty. Simulating a CR\n");
+                handle_command(0x14, 0x2D, wb);
+            }
+            
+            wb->data608->mode=MODE_ROLLUP_4;
+            wb->data608->cursor_column=0;
+            wb->data608->cursor_row=wb->data608->rollup_base_row;
+            erase_memory (wb, 0);
+            break;
+        case COM_CARRIAGERETURN:
+            // In transcript mode, CR doesn't write the whole screen, to avoid
+            // repeated lines.
+            if (write_format==OF_TRANSCRIPT)
+            {
+                write_cc_line_as_transcript(get_current_visible_buffer (wb), wb, wb->data608->cursor_row);
+            }
+            else
+            {
+                if (norollup)
+                    delete_all_lines_but_current (get_current_visible_buffer (wb), wb->data608->cursor_row);
+                if (write_cc_buffer(wb))
+                    wb->data608->screenfuls_counter++;
+            }
+            roll_up(wb);               
+            wb->data608->current_visible_start_ms=get_fts(wb);
+            wb->data608->cursor_column=0;
+            break;
+        case COM_ERASENONDISPLAYEDMEMORY:
+            erase_memory (wb,0);
+            break;
+        case COM_ERASEDISPLAYEDMEMORY:
+            // Write it to disk before doing this, and make a note of the new
+            // time it became clear.
+            if (write_format==OF_TRANSCRIPT && 
+                (wb->data608->mode==MODE_ROLLUP_2 || wb->data608->mode==MODE_ROLLUP_3 ||
+                wb->data608->mode==MODE_ROLLUP_4))
+            {
+                // In transcript mode we just write the cursor line. The previous lines
+                // should have been written already, so writing everything produces
+                // duplicate lines.                
+                write_cc_line_as_transcript(get_current_visible_buffer (wb), wb, wb->data608->cursor_row);
+            }
+            else
+            {
+                if (write_cc_buffer (wb))
+                    wb->data608->screenfuls_counter++;
+            }
+            erase_memory (wb,1);
+            wb->data608->current_visible_start_ms=get_fts(wb);
+            break;
+        case COM_ENDOFCAPTION: // Switch buffers
+            // The currently *visible* buffer is leaving, so now we know it's ending
+            // time. Time to actually write it to file.
+            if (write_cc_buffer (wb))
+                wb->data608->screenfuls_counter++;
+            wb->data608->visible_buffer = (wb->data608->visible_buffer==1) ? 2 : 1;
+            wb->data608->current_visible_start_ms=get_fts(wb);
+            wb->data608->cursor_column=0;
+            wb->data608->cursor_row=0;
+            wb->data608->color=default_color;
+            wb->data608->font=FONT_REGULAR;
+            break;
+        default:
+            if (debug_608)
+            {
+                hb_log ("\rNot yet implemented.\n");
+            }
+            break;
+    }
+}
+
+void handle_end_of_data (struct s_write *wb)
+{ 
+    // We issue a EraseDisplayedMemory here so if there's any captions pending
+    // they get written to file. 
+    handle_command (0x14, 0x2c, wb); // EDM
+}
+
+void handle_double (const unsigned char c1, const unsigned char c2, struct s_write *wb)
+{
+    unsigned char c;
+    if (wb->data608->channel!=cc_channel)
+        return;
+    if (c2>=0x30 && c2<=0x3f)
+    {
+        c=c2 + 0x50; // So if c>=0x80 && c<=0x8f, it comes from here
+        if (debug_608)
+            hb_log ("\rDouble: %02X %02X  -->  %c\n",c1,c2,c);
+        write_char(c,wb);
+    }
+}
+
+/* Process EXTENDED CHARACTERS */
+unsigned char handle_extended (unsigned char hi, unsigned char lo, struct s_write *wb)
+{
+    // Handle channel change
+    if (wb->new_channel > 2) 
+    {
+        wb->new_channel -= 2;
+        if (debug_608)
+            hb_log ("\nChannel correction, now %d\n", wb->new_channel);
+    }
+    wb->data608->channel=wb->new_channel;
+    if (wb->data608->channel!=cc_channel)
+        return 0;
+
+    // For lo values between 0x20-0x3f
+    unsigned char c=0;
+
+    if (debug_608)
+        hb_log ("\rExtended: %02X %02X\n",hi,lo);
+    if (lo>=0x20 && lo<=0x3f && (hi==0x12 || hi==0x13))
+    {
+        switch (hi)
+        {
+            case 0x12:
+                c=lo+0x70; // So if c>=0x90 && c<=0xaf it comes from here
+                break;
+            case 0x13:
+                c=lo+0x90; // So if c>=0xb0 && c<=0xcf it comes from here
+                break;
+        }
+        // This column change is because extended characters replace 
+        // the previous character (which is sent for basic decoders
+        // to show something similar to the real char)
+        if (wb->data608->cursor_column>0)        
+            wb->data608->cursor_column--;        
+
+        write_char (c,wb);
+    }
+    return 1;
+}
+
+/* Process PREAMBLE ACCESS CODES (PAC) */
+void handle_pac (unsigned char c1, unsigned char c2, struct s_write *wb)
+{
+    // Handle channel change
+    if (wb->new_channel > 2) 
+    {
+        wb->new_channel -= 2;
+        if (debug_608)
+            hb_log ("\nChannel correction, now %d\n", wb->new_channel);
+    }
+    wb->data608->channel=wb->new_channel;
+    if (wb->data608->channel!=cc_channel)
+        return;
+
+    int row=rowdata[((c1<<1)&14)|((c2>>5)&1)];
+
+    if (debug_608)
+        hb_log ("\rPAC: %02X %02X",c1,c2);
+
+    if (c2>=0x40 && c2<=0x5f)
+    {
+        c2=c2-0x40;
+    }
+    else
+    {
+        if (c2>=0x60 && c2<=0x7f)
+        {
+            c2=c2-0x60;
+        }
+        else
+        {
+            if (debug_608)
+                hb_log ("\rThis is not a PAC!!!!!\n");
+            return;
+        }
+    }
+    int color=pac2_attribs[c2][0];
+    int font=pac2_attribs[c2][1];
+    int indent=pac2_attribs[c2][2];
+    if (debug_608)
+        hb_log ("  --  Position: %d:%d, color: %s,  font: %s\n",row,
+        indent,color_text[color][0],font_text[font]);
+    if (wb->data608->mode!=MODE_TEXT)
+    {
+        // According to Robson, row info is discarded in text mode
+        // but column is accepted
+        wb->data608->cursor_row=row-1 ; // Since the array is 0 based
+    }
+    wb->data608->rollup_base_row=row-1;
+    wb->data608->cursor_column=indent; 
+}
+
+
+void handle_single (const unsigned char c1, struct s_write *wb)
+{      
+    if (c1<0x20 || wb->data608->channel!=cc_channel)
+        return; // We don't allow special stuff here
+    if (debug_608)
+        hb_log ("%c",c1);
+
+    /*if (debug_608)
+    hb_log ("Character: %02X (%c) -> %02X (%c)\n",c1,c1,c,c); */
+    write_char (c1,wb);
+}
+
+int check_channel (unsigned char c1, struct s_write *wb)
+{
+    if (c1==0x14) 
+    {
+        if (debug_608 && wb->data608->channel!=1)
+            hb_log ("\nChannel change, now 1\n");
+        return 1;
+    }
+    if (c1==0x1c) 
+    {
+        if (debug_608 && wb->data608->channel!=2)
+            hb_log ("\nChannel change, now 2\n");
+        return 2;
+    }
+    if (c1==0x15) 
+    {
+        if (debug_608 && wb->data608->channel!=3)
+            hb_log ("\nChannel change, now 3\n");
+        return 3;
+    }
+    if (c1==0x1d) 
+    {
+        if (debug_608 && wb->data608->channel!=4)
+            hb_log ("\nChannel change, now 4\n");
+        return 4;
+    }
+
+    // Otherwise keep the current channel
+    return wb->data608->channel;
+}
+
+/* Handle Command, special char or attribute and also check for
+* channel changes.
+* Returns 1 if something was written to screen, 0 otherwise */
+int disCommand (unsigned char hi, unsigned char lo, struct s_write *wb)
+{
+    int wrote_to_screen=0;
+
+    /* Full channel changes are only allowed for "GLOBAL CODES",
+    * "OTHER POSITIONING CODES", "BACKGROUND COLOR CODES",
+    * "MID-ROW CODES".
+    * "PREAMBLE ACCESS CODES", "BACKGROUND COLOR CODES" and
+    * SPECIAL/SPECIAL CHARACTERS allow only switching
+    * between 1&3 or 2&4. */
+    wb->new_channel = check_channel (hi,wb);
+    //if (wb->data608->channel!=cc_channel)
+    //    continue;
+
+    if (hi>=0x18 && hi<=0x1f)
+        hi=hi-8;
+
+    switch (hi)
+    {
+        case 0x10:
+            if (lo>=0x40 && lo<=0x5f)
+                handle_pac (hi,lo,wb);
+            break;
+        case 0x11:
+            if (lo>=0x20 && lo<=0x2f)
+                handle_text_attr (hi,lo,wb);
+            if (lo>=0x30 && lo<=0x3f)
+            {
+                wrote_to_screen=1;
+                handle_double (hi,lo,wb);
+            }
+            if (lo>=0x40 && lo<=0x7f)
+                handle_pac (hi,lo,wb);
+            break;
+        case 0x12:
+        case 0x13:
+            if (lo>=0x20 && lo<=0x3f)
+            {
+                wrote_to_screen=handle_extended (hi,lo,wb);
+            }
+            if (lo>=0x40 && lo<=0x7f)
+                handle_pac (hi,lo,wb);
+            break;
+        case 0x14:
+        case 0x15:
+            if (lo>=0x20 && lo<=0x2f)
+                handle_command (hi,lo,wb);
+            if (lo>=0x40 && lo<=0x7f)
+                handle_pac (hi,lo,wb);
+            break;
+        case 0x16:
+            if (lo>=0x40 && lo<=0x7f)
+                handle_pac (hi,lo,wb);
+            break;
+        case 0x17:
+            if (lo>=0x21 && lo<=0x22)
+                handle_command (hi,lo,wb);
+            if (lo>=0x2e && lo<=0x2f)
+                handle_text_attr (hi,lo,wb);
+            if (lo>=0x40 && lo<=0x7f)
+                handle_pac (hi,lo,wb);
+            break;
+    }
+    return wrote_to_screen;
+}
+
+void process608 (const unsigned char *data, int length, struct s_write *wb)
+{
+    static int textprinted = 0;
+    int i;
+
+    if (data!=NULL)
+    {
+        for (i=0;i<length;i=i+2)
+        {
+            unsigned char hi, lo;
+            int wrote_to_screen=0; 
+            hi = data[i] & 0x7F; // Get rid of parity bit
+            lo = data[i+1] & 0x7F; // Get rid of parity bit
+
+            if (hi==0 && lo==0) // Just padding
+                continue;
+            // hb_log ("\r[%02X:%02X]\n",hi,lo);
+
+            if (hi>=0x01 && hi<=0x0E)
+            {
+                // XDS crap - mode. Would be nice to support it eventually
+                // wb->data608->last_c1=0;
+                // wb->data608->last_c2=0;
+                wb->data608->channel=3; // Always channel 3
+                wb->in_xds_mode=1;
+            }
+            if (hi==0x0F) // End of XDS block
+            {
+                wb->in_xds_mode=0;
+                continue;
+            }
+            if (hi>=0x10 && hi<0x1F) // Non-character code or special/extended char
+                // http://www.geocities.com/mcpoodle43/SCC_TOOLS/DOCS/CC_CODES.HTML
+                // http://www.geocities.com/mcpoodle43/SCC_TOOLS/DOCS/CC_CHARS.HTML
+            {
+                // We were writing characters before, start a new line for
+                // diagnostic output from disCommand()
+                if (debug_608 && textprinted == 1 )
+                {
+                    hb_log("\n");
+                    textprinted = 0;
+                }
+
+                wb->in_xds_mode=0; // Back to normal
+                if (wb->data608->last_c1==hi && wb->data608->last_c2==lo)
+                {
+                    // Duplicate dual code, discard
+                    continue;
+                }
+                wb->data608->last_c1=hi;
+                wb->data608->last_c2=lo;
+                wrote_to_screen=disCommand (hi,lo,wb);
+            }
+            if (hi>=0x20) // Standard characters (always in pairs)
+            {
+                // Only print if the channel is active
+                if (wb->data608->channel!=cc_channel)
+                    continue;
+
+                if (debug_608)
+                {
+                    if( textprinted == 0 )
+                    {
+                        hb_log("\n");
+                        textprinted = 1;
+                    }
+                }
+
+                handle_single(hi,wb);
+                handle_single(lo,wb);
+                wrote_to_screen=1;
+                wb->data608->last_c1=0;
+                wb->data608->last_c2=0;
+            }
+
+            if ( debug_608 && !textprinted && wb->data608->channel==cc_channel )
+            {   // Current FTS information after the characters are shown
+                //hb_log("Current FTS: %s\n", print_mstime(get_fts()));
+            }
+
+            if (wrote_to_screen && direct_rollup && // If direct_rollup is enabled and
+                (wb->data608->mode==MODE_ROLLUP_2 || // we are in rollup mode, write now.
+                wb->data608->mode==MODE_ROLLUP_3 ||
+                wb->data608->mode==MODE_ROLLUP_4))
+            {
+                // We don't increase screenfuls_counter here.
+                write_cc_buffer (wb);
+                wb->data608->current_visible_start_ms=get_fts(wb);
+            }
+        }
+    }
+}
+
+
+/* Return a pointer to a string that holds the printable characters
+ * of the caption data block. FOR DEBUG PURPOSES ONLY! */
+unsigned char *debug_608toASC (unsigned char *cc_data, int channel)
+{
+    static unsigned char output[3];
+
+    unsigned char cc_valid = (cc_data[0] & 4) >>2;
+    unsigned char cc_type = cc_data[0] & 3;
+    unsigned char hi, lo;
+
+    output[0]=' ';
+    output[1]=' ';
+    output[2]='\x00';
+
+    if (cc_valid && cc_type==channel)
+    {
+        hi = cc_data[1] & 0x7F; // Get rid of parity bit
+        lo = cc_data[2] & 0x7F; // Get rid of parity bit
+        if (hi>=0x20)
+        {
+            output[0]=hi;
+            output[1]=(lo>=20 ? lo : '.');
+            output[2]='\x00';
+        }
+        else
+        {
+            output[0]='<';
+            output[1]='>';
+            output[2]='\x00';
+        }
+    }
+    return output;
+}
+
+
+struct hb_work_private_s
+{
+    hb_job_t           * job;
+    struct s_write     * cc608;
+};
+
+int decccInit( hb_work_object_t * w, hb_job_t * job )
+{
+    int retval = 1;
+    hb_work_private_t * pv;
+
+    pv = calloc( 1, sizeof( hb_work_private_t ) );
+    if( pv )
+    {
+        w->private_data = pv;
+
+        pv->job = job;
+
+        pv->cc608 = calloc(1, sizeof(struct s_write));
+
+        if( pv->cc608 )
+        {
+            retval = general_608_init(pv->cc608);
+            if( !retval )
+            {
+                pv->cc608->data608 = calloc(1, sizeof(struct eia608));
+                if( !pv->cc608->data608 )
+                {
+                    retval = 1;
+                }
+            }
+        }
+    }
+    return retval;
+}
+
+int decccWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+               hb_buffer_t ** buf_out )
+{
+    hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
+
+    if ( in->size <= 0 )
+    {
+        /* EOF on input stream - send it downstream & say that we're done */
+        handle_end_of_data(pv->cc608);
+        /*
+         * Grab any pending buffer and output them with the EOF on the end
+         */
+        if (pv->cc608->hb_last_buffer) {
+            pv->cc608->hb_last_buffer->next = in;
+            *buf_out = pv->cc608->hb_buffer;
+            *buf_in = NULL;
+            pv->cc608->hb_buffer = NULL;
+            pv->cc608->hb_last_buffer = NULL;
+        } else {
+            *buf_out = in;
+            *buf_in = NULL;
+        }
+        return HB_WORK_DONE;
+    }
+
+    pv->cc608->last_pts = in->start;
+
+    process608(in->data, in->size, pv->cc608);
+
+    /*
+     * If there is one waiting then pass it on
+     */
+    *buf_out = pv->cc608->hb_buffer;
+    pv->cc608->hb_buffer = NULL;
+    pv->cc608->hb_last_buffer = NULL;
+
+    return HB_WORK_OK; 
+}
+
+void decccClose( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+    general_608_close( pv->cc608 );
+    free( pv->cc608->data608 );
+    free( pv->cc608 );
+    free( w->private_data );
+}
+
+hb_work_object_t hb_deccc608 =
+{
+    WORK_DECCC608,
+    "Closed Caption (608) decoder",
+    decccInit,
+    decccWork,
+    decccClose
+};
diff --git a/libhb/deccc608sub.h b/libhb/deccc608sub.h
new file mode 100644 (file)
index 0000000..1b7b940
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * From ccextractor, leave this file as intact and close to the original as possible so that 
+ * it is easy to patch in fixes - even though this file contains code that we don't need.
+ *
+ * Note that the SRT sub generation from CC could be useful for mkv subs.
+ */
+#ifndef __deccc608sub_H__
+#define __deccc608sub_H__
+
+#include "common.h"
+
+struct s_write;
+
+void handle_end_of_data (struct s_write *wb);
+void process608 (const unsigned char *data, int length, struct s_write *wb);
+void get_char_in_latin_1 (unsigned char *buffer, unsigned char c);
+void get_char_in_unicode (unsigned char *buffer, unsigned char c);
+int get_char_in_utf_8 (unsigned char *buffer, unsigned char c);
+unsigned char cctolower (unsigned char c);
+unsigned char cctoupper (unsigned char c);
+int general_608_init (struct s_write *wb);
+void general_608_close (struct s_write *wb);
+
+#define CC608_SCREEN_WIDTH  32
+
+enum cc_modes
+{
+    MODE_POPUP = 0,
+    MODE_ROLLUP_2 = 1,
+    MODE_ROLLUP_3 = 2,
+    MODE_ROLLUP_4 = 3,
+       MODE_TEXT = 4
+};
+
+enum color_code
+{
+    COL_WHITE = 0,
+    COL_GREEN = 1,
+    COL_BLUE = 2,
+    COL_CYAN = 3,
+    COL_RED = 4,
+    COL_YELLOW = 5,
+    COL_MAGENTA = 6,
+       COL_USERDEFINED = 7
+};
+
+
+enum font_bits
+{
+    FONT_REGULAR = 0,
+    FONT_ITALICS = 1,
+    FONT_UNDERLINED = 2,
+    FONT_UNDERLINED_ITALICS = 3
+};
+
+
+struct eia608_screen // A CC buffer
+{
+    unsigned char characters[15][33]; 
+    unsigned char colors[15][33];
+    unsigned char fonts[15][33]; // Extra char at the end for a 0
+    int row_used[15]; // Any data in row?
+    int empty; // Buffer completely empty?     
+};
+
+#define LLONG long long
+
+struct eia608
+{
+    struct eia608_screen buffer1;
+    struct eia608_screen buffer2;  
+    int cursor_row, cursor_column;
+    int visible_buffer;
+    int srt_counter; // Number of subs currently written
+    int screenfuls_counter; // Number of meaningful screenfuls written
+    LLONG current_visible_start_ms; // At what time did the current visible buffer became so?
+    // unsigned current_visible_start_cc; // At what time did the current visible buffer became so?
+    enum cc_modes mode;
+    unsigned char last_c1, last_c2;
+    int channel; // Currently selected channel
+    unsigned char color; // Color we are currently using to write
+    unsigned char font; // Font we are currently using to write
+    int rollup_base_row;
+};
+
+struct s_write {
+    struct eia608 *data608;
+    FILE *fh;
+    unsigned char *subline; 
+    int new_sentence;
+    int new_channel;
+    int in_xds_mode;
+    hb_buffer_t *hb_buffer;
+    hb_buffer_t *hb_last_buffer;
+    uint64_t last_pts;
+    unsigned char *enc_buffer; // Generic general purpose buffer
+    unsigned enc_buffer_used;
+    unsigned enc_buffer_capacity;
+};
+
+enum command_code
+{
+    COM_UNKNOWN = 0,
+    COM_ERASEDISPLAYEDMEMORY = 1,
+    COM_RESUMECAPTIONLOADING = 2,
+    COM_ENDOFCAPTION = 3,
+    COM_TABOFFSET1 = 4,
+    COM_TABOFFSET2 = 5,
+    COM_TABOFFSET3 = 6,
+    COM_ROLLUP2 = 7,
+    COM_ROLLUP3 = 8,
+    COM_ROLLUP4 = 9,
+    COM_CARRIAGERETURN = 10,
+    COM_ERASENONDISPLAYEDMEMORY = 11,
+    COM_BACKSPACE = 12,
+       COM_RESUMETEXTDISPLAY = 13
+};
+
+enum encoding_type
+{
+    ENC_UNICODE = 0,
+    ENC_LATIN_1 = 1,
+    ENC_UTF_8 = 2
+};
+
+enum output_format
+{
+    OF_RAW     = 0,
+    OF_SRT     = 1,
+    OF_SAMI = 2,
+    OF_TRANSCRIPT = 3,
+    OF_RCWT = 4
+};
+
+#endif
index b58a9ef..4fe0661 100644 (file)
@@ -15,6 +15,7 @@ struct hb_work_private_s
     dca_state_t * state;
 
     double        next_pts;
+    int64_t       last_buf_pts;
     int           flags_in;
     int           flags_out;
     int           rate;
@@ -122,6 +123,13 @@ static int decdcaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         return HB_WORK_DONE;
     }
 
+    if ( (*buf_in)->start < -1 && pv->next_pts == 0 )
+    {
+        // discard buffers that start before video time 0
+        *buf_out = NULL;
+        return HB_WORK_OK;
+    }
+
     hb_list_add( pv->list, *buf_in );
     *buf_in = NULL;
 
@@ -145,8 +153,10 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
 {
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * buf;
+    hb_audio_t  * audio = w->audio;
     int           i, j, k;
     int64_t       pts, pos;
+    uint64_t      upts, upos;
     int           num_blocks;
 
     /* Get a frame header if don't have one yet */
@@ -189,17 +199,21 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
     }
 
     /* Get the whole frame */
-    hb_list_getbytes( pv->list, pv->frame, pv->size, &pts, &pos );
-
-    /* Feed libdca */
-    dca_frame( pv->state, pv->frame, &pv->flags_out, &pv->level, 0 );
-
-    /* find out how many blocks are in this frame */
-    num_blocks = dca_blocks_num( pv->state );
+    hb_list_getbytes( pv->list, pv->frame, pv->size, &upts, &upos );
+    pts = (int64_t)upts;
+    pos = (int64_t)upos;
 
-    /* num_blocks blocks per frame, 256 samples per block, channelsused channels */
-    int nsamp = num_blocks * 256;
-    buf = hb_buffer_init( nsamp * pv->out_discrete_channels * sizeof( float ) );
+    if ( pts != pv->last_buf_pts )
+    {
+        pv->last_buf_pts = pts;
+    }
+    else
+    {
+        // spec says that the PTS is the start time of the first frame
+        // that starts in the PES frame so we only use the PTS once then
+        // get the following frames' PTS from the frame length.
+        pts = -1;
+    }
 
     // mkv files typically use a 1ms timebase which results in a lot of
     // truncation error in their timestamps. Also, TSMuxer or something
@@ -207,12 +221,37 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
     // about time - timestamps seem to randomly offset by ~40ms for a few
     // seconds then recover. So, if the pts we got is within 50ms of the
     // pts computed from the data stream, use the data stream pts.
-    if ( pts < 0 || fabs( (double)pts - pv->next_pts ) < 50.*90. )
+    if ( pts == -1 || ( pv->next_pts && fabs( pts - pv->next_pts ) < 50.*90. ) )
     {
         pts = pv->next_pts;
     }
+
+    double frame_dur = (double)(pv->frame_length & ~0xFF) / (double)pv->rate * 90000.;
+
+    /* DCA passthrough: don't decode the DCA frame */
+    if( audio->config.out.codec == HB_ACODEC_DCA )
+    {
+        buf = hb_buffer_init( pv->size );
+        memcpy( buf->data, pv->frame, pv->size );
+        buf->start = pts;
+        pv->next_pts = pts + frame_dur;
+        buf->stop  = pv->next_pts;
+        pv->sync = 0;
+        return buf;
+    }
+
+    /* Feed libdca */
+    dca_frame( pv->state, pv->frame, &pv->flags_out, &pv->level, 0 );
+
+    /* find out how many blocks are in this frame */
+    num_blocks = dca_blocks_num( pv->state );
+
+    /* num_blocks blocks per frame, 256 samples per block, channelsused channels */
+    int nsamp = num_blocks * 256;
+    buf = hb_buffer_init( nsamp * pv->out_discrete_channels * sizeof( float ) );
+
     buf->start = pts;
-    pv->next_pts += (double)nsamp / (double)pv->rate * 90000.;
+    pv->next_pts = pts + (double)nsamp / (double)pv->rate * 90000.;
     buf->stop  = pv->next_pts;
 
     for( i = 0; i < num_blocks; i++ )
diff --git a/libhb/decmetadata.c b/libhb/decmetadata.c
new file mode 100644 (file)
index 0000000..e377f8c
--- /dev/null
@@ -0,0 +1,134 @@
+/* decmetadata.c - Extract and decode metadata from the source
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include <mp4v2/mp4v2.h>
+
+#include "common.h"
+
+static void decmp4metadata( hb_title_t *title )
+{
+    MP4FileHandle input_file;
+    hb_deep_log( 2, "Got an MP4 input, read the metadata");
+
+    input_file = MP4Read( title->dvd, 0 );
+
+    if( input_file != MP4_INVALID_FILE_HANDLE )
+    { 
+        /*
+         * Store iTunes MetaData
+         */
+        const MP4Tags* tags;
+
+        /* alloc,fetch tags */
+        tags = MP4TagsAlloc();
+        MP4TagsFetch( tags, input_file );
+
+        if( tags->name ) {
+            hb_deep_log( 2, "Metadata Name in input file is '%s'", tags->name );
+            strncpy( title->metadata->name, tags->name, sizeof(title->metadata->name) );
+        }
+
+        if( tags->artist )
+            strncpy( title->metadata->artist, tags->artist, sizeof(title->metadata->artist) );
+
+        if( tags->composer )
+            strncpy( title->metadata->composer, tags->composer, sizeof(title->metadata->composer) );
+
+        if( tags->comments )
+            strncpy( title->metadata->comment, tags->comments, sizeof(title->metadata->comment) );
+
+        if( tags->releaseDate )
+            strncpy( title->metadata->release_date, tags->releaseDate, sizeof(title->metadata->release_date) );
+
+        if( tags->album )
+            strncpy( title->metadata->album, tags->album, sizeof(title->metadata->album) );
+
+        if( tags->genre )
+            strncpy( title->metadata->genre, tags->genre, sizeof(title->metadata->genre) );
+
+        if( tags->artworkCount > 0 ) {
+            const MP4TagArtwork* art = tags->artwork + 0; // first element
+            title->metadata->coverart = (uint8_t*)malloc( art->size );
+            title->metadata->coverart_size = art->size;
+            memcpy( title->metadata->coverart, art->data, art->size );
+            hb_deep_log( 2, "Got some cover art of type %d, size %d", 
+                         art->type,
+                         title->metadata->coverart_size );
+        }
+
+        /* store,free tags */
+        MP4TagsStore( tags, input_file );
+        MP4TagsFree( tags );
+        
+        /*
+         * Handle the chapters. 
+         */
+        MP4Chapter_t *chapter_list = NULL;
+        uint32_t      chapter_count;
+        
+        MP4GetChapters( input_file, &chapter_list, &chapter_count, 
+                        MP4ChapterTypeQt );
+
+        if( chapter_list && ( hb_list_count( title->list_chapter ) == 0 ) ) {
+            uint32_t i = 1;
+            while( i <= chapter_count )
+            {
+                hb_chapter_t * chapter;
+                chapter = calloc( sizeof( hb_chapter_t ), 1 );
+                chapter->index = i;
+                chapter->duration = chapter_list[i-1].duration * 90;
+                chapter->hours    = chapter->duration / 90000 / 3600;
+                chapter->minutes  = ( ( chapter->duration / 90000 ) % 3600 ) / 60;
+                chapter->seconds  = ( chapter->duration / 90000 ) % 60;
+                strcpy( chapter->title, chapter_list[i-1].title );
+                hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRId64", (%02i:%02i:%02i)", chapter->index, chapter->title, 
+                       chapter->duration, chapter->hours, 
+                       chapter->minutes, chapter->seconds);
+                hb_list_add( title->list_chapter, chapter );
+                i++;
+            }
+        }
+
+        MP4Close( input_file );
+    }
+}
+
+/*
+ * decmetadata()
+ *
+ * Look at the title and extract whatever metadata we can from that title.
+ */
+void decmetadata( hb_title_t *title )
+{
+    if( !title ) 
+    {
+        return;
+    }
+    
+    if( title->metadata )
+    {
+        free( title->metadata );
+        title->metadata = NULL;
+    }
+
+    title->metadata = calloc( sizeof(hb_metadata_t), 1);
+
+    if( !title->metadata )
+    {
+        return;
+    }
+
+    /*
+     * Hacky way of figuring out if this is an MP4, in which case read the data using libmp4v2
+     */
+    if( title->container_name && strcmp(title->container_name, "mov,mp4,m4a,3gp,3g2,mj2") == 0 ) 
+    {
+        decmp4metadata( title );
+    } else {
+        free( title->metadata );
+        title->metadata = NULL;
+    }
+}
index eae0091..385a1ae 100644 (file)
@@ -5,10 +5,8 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
-#include "libavcodec/avcodec.h"
-#include "libswscale/swscale.h"
 
 /* Cadence tracking */
 #ifndef PIC_FLAG_REPEAT_FIRST_FIELD
@@ -27,8 +25,8 @@
 #define BTB_PROG 64
 #define TB_PROG 128
 #define TBT_PROG 256
-static int cadence[12];
-static int flag = 0;
+
+#define NTAGS 8
 
 /**********************************************************************
  * hb_libmpeg2_t
@@ -38,6 +36,7 @@ typedef struct hb_libmpeg2_s
     mpeg2dec_t         * libmpeg2;
     const mpeg2_info_t * info;
     hb_job_t           * job;
+    hb_title_t         * title;
     int                  width;
     int                  height;
     int                  rate;
@@ -45,8 +44,18 @@ typedef struct hb_libmpeg2_s
     int                  got_iframe;        /* set when we get our first iframe */
     int                  look_for_iframe;   /* need an iframe to add chap break */
     int                  look_for_break;    /* need gop start to add chap break */
+    int                  cur_tag;           /* index of current tag */
     uint32_t             nframes;           /* number of frames we've decoded */
     int64_t              last_pts;
+    int64_t              first_pts;
+    int cadence[12];
+    int flag;
+    hb_list_t          * list_subtitle;
+    hb_buffer_t        * last_cc1_buf;
+    struct {
+        int64_t          start;             // start time of this frame
+        hb_buffer_t    * cc_buf;            // captions for this frame
+    } tags[NTAGS];
 } hb_libmpeg2_t;
 
 /**********************************************************************
@@ -61,10 +70,191 @@ static hb_libmpeg2_t * hb_libmpeg2_init()
     m->libmpeg2 = mpeg2_init();
     m->info     = mpeg2_info( m->libmpeg2 );
     m->last_pts = -1;
+    m->first_pts = -1;
+
+    int i;
+    for ( i = 0; i < NTAGS; ++i )
+    {
+        m->tags[i].start = -1;
+    }
 
     return m;
 }
 
+// send cc_buf to the CC decoder(s)
+static void cc_send_to_decoder( hb_libmpeg2_t *m, hb_buffer_t *cc_buf )
+{
+    hb_subtitle_t *subtitle;
+
+    // if there's more than one decoder for the captions send a copy
+    // of the buffer to all but the last. Then send the buffer to
+    // the last one (usually there's just one decoder so the 'while' is skipped).
+    int i = 0, n = hb_list_count( m->list_subtitle );
+    while ( --n > 0 )
+    {
+        // make a copy of the buf then forward it to the decoder
+        hb_buffer_t *cpy = hb_buffer_init( cc_buf->size );
+        hb_buffer_copy_settings( cpy, cc_buf );
+        memcpy( cpy->data, cc_buf->data, cc_buf->size );
+
+        subtitle = hb_list_item( m->list_subtitle, i++ );
+        hb_fifo_push( subtitle->fifo_in, cpy );
+    }
+    subtitle = hb_list_item( m->list_subtitle, i );
+    hb_fifo_push( subtitle->fifo_in, cc_buf );
+}
+
+static void hb_mpeg2_cc( hb_libmpeg2_t *m, const uint8_t *cc_block )
+{
+    uint8_t cc_hdr = *cc_block;
+    
+    if ( ( cc_hdr & 0x4 ) == 0 )
+        // not valid - ignore
+        return;
+
+    switch (cc_hdr & 3)
+    {
+        case 0:
+            // CC1 stream
+            if ( ( cc_block[1] & 0x7f ) == 0 && ( cc_block[2] & 0x7f ) == 0 )
+                // just padding - ignore
+                return;
+
+            if ( m->last_cc1_buf )
+            {
+                // new data from the same time as last call - add to buffer
+                int len = m->last_cc1_buf->size;
+                hb_buffer_realloc( m->last_cc1_buf, len + 2 );
+                memcpy( m->last_cc1_buf->data + len, cc_block+1, 2 );
+                m->last_cc1_buf->size = len + 2;
+                return;
+            }
+
+            // allocate a new buffer and copy the caption data into it.
+            // (we don't send it yet because we don't know what timestamp to use).
+            hb_buffer_t *cc_buf = hb_buffer_init( 2 );
+            if( !cc_buf )
+                return;
+
+            memcpy( cc_buf->data, cc_block+1, 2 );
+            m->last_cc1_buf = cc_buf;
+            break;
+#ifdef notyet
+        case 1:
+            // CC2 stream
+            //process608( cc_block+1, 2, &m->cc608 );
+            break;
+        case 2: //EIA-708
+            // DTVCC packet data
+            // Fall through
+        case 3: //EIA-708
+            {
+                uint8_t temp[4];
+                temp[0]=cc_valid;
+                temp[1]=cc_type;
+                temp[2]=cc_block[1];
+                temp[3]=cc_block[2];
+                do_708 ((const unsigned char *) temp, 4);
+            }
+            break;
+#endif
+        default:
+            break;
+    } 
+} 
+
+static inline int have_captions( const uint8_t *user_data, uint32_t len )
+{
+    return len >= 6 && 
+           ( ( user_data[0] == 0x43 && user_data[1] == 0x43 ) ||
+             ( user_data[0] == 0x47 && user_data[1] == 0x41 &&
+               user_data[2] == 0x39 && user_data[3] == 0x34 &&
+               user_data[4] == 3 && (user_data[5] & 0x40) ) );
+}
+
+static void do_one_dvd_cc( hb_libmpeg2_t *m, const uint8_t *header, int field1 )
+{
+    uint8_t data[3];
+
+    data[0] = ( header[0] == 0xff && 0 == field1 )? 0x04 : 0x05;
+    data[1] = header[1];
+    data[2] = header[2];
+    hb_mpeg2_cc( m, data );
+
+    data[0] = ( header[3] == 0xff && 1 == field1 )? 0x04 : 0x05;
+    data[1] = header[4];
+    data[2] = header[5];
+    hb_mpeg2_cc( m, data );
+}
+
+// extract all the captions in the current frame and send them downstream
+// to the decoder.
+//
+// (this routine should only be called if there are captions in the current
+// frame. I.e., only if a call to 'have_captions' returns true.)
+static void extract_mpeg2_captions( hb_libmpeg2_t *m )
+{
+    const uint8_t *user_data = m->info->user_data;
+    int dvd_captions = user_data[0] == 0x43;
+    int capcount, field1packet = 0;
+    const uint8_t *header = &user_data[4];
+    if ( !dvd_captions )
+    {
+        // ATSC encapsulated captions - header starts one byte later
+        // and has an extra unused byte following it.
+        capcount = header[1] & 0x1f;
+        header += 3;
+    }
+    else
+    {
+        // DVD captions
+        if ( ( header[0] & 0x80 ) == 0x00 ) 
+            field1packet=1; /* expect Field 1 second */
+        capcount=(header[0] & 0x1e) / 2;
+        header++;
+    }
+
+    int i;
+    for( i=0; i<capcount; i++ )
+    {
+        if ( !dvd_captions )
+        {
+            hb_mpeg2_cc( m, header );
+            header += 3;
+        }
+        else
+        {
+            do_one_dvd_cc( m, header, field1packet );
+            header += 6;
+        }
+    }
+    if ( dvd_captions )
+    {
+        // Deal with extra closed captions some DVDs have.
+        while( header[0]==0xfe || header[0]==0xff )
+        {
+            do_one_dvd_cc( m, header, field1packet );
+            header += 6;
+        }   
+    }   
+}
+
+static void next_tag( hb_libmpeg2_t *m, hb_buffer_t *buf_es )
+{
+    m->cur_tag = ( m->cur_tag + 1 ) & (NTAGS-1);
+    if ( m->tags[m->cur_tag].start >= 0 || m->tags[m->cur_tag].cc_buf )
+    {
+        if ( m->tags[m->cur_tag].start < 0 ||
+             ( m->got_iframe && m->tags[m->cur_tag].start >= m->first_pts ) )
+            hb_log("mpeg2 tag botch: pts %lld, tag pts %lld buf 0x%p",
+                   buf_es->start, m->tags[m->cur_tag].start, m->tags[m->cur_tag].cc_buf);
+        if ( m->tags[m->cur_tag].cc_buf )
+            hb_buffer_close( &m->tags[m->cur_tag].cc_buf );
+    }
+    m->tags[m->cur_tag].start = buf_es->start;
+    mpeg2_tag_picture( m->libmpeg2, m->cur_tag, 0 );
+}
+
 static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
                                    uint8_t* y, uint8_t *u, uint8_t *v )
 {
@@ -76,6 +266,7 @@ static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
     }
     int dst_wh = dst_w * dst_h;
     hb_buffer_t *buf  = hb_video_buffer_init( dst_w, dst_h );
+    buf->start = -1;
 
     if ( dst_w != width || dst_h != height )
     {
@@ -96,7 +287,7 @@ static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
         sws_scale( context, in.data, in.linesize, 0, height, out.data, out.linesize );
         sws_freeContext( context );
 
-        u_int8_t *data = buf->data;
+        uint8_t *data = buf->data;
         memcpy( data, out.data[0], dst_wh );
         data += dst_wh;
         // U & V planes are 1/4 the size of Y plane.
@@ -112,7 +303,7 @@ static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
     {
         // we're scanning or the frame dimensions match the title's dimensions
         // so we can do a straight copy.
-        u_int8_t *data = buf->data;
+        uint8_t *data = buf->data;
         memcpy( data, y, dst_wh );
         data += dst_wh;
         // U & V planes are 1/4 the size of Y plane.
@@ -130,7 +321,7 @@ static hb_buffer_t *hb_copy_frame( hb_job_t *job, int width, int height,
  *
  *********************************************************************/
 static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
-                        hb_list_t * list_raw )
+                               hb_list_t * list_raw )
 {
     mpeg2_state_t   state;
     hb_buffer_t   * buf;
@@ -138,13 +329,11 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
     if ( buf_es->size )
     {
         /* Feed libmpeg2 */
-        if( buf_es->start > -1 )
+        if( buf_es->start >= 0 )
         {
-            mpeg2_tag_picture( m->libmpeg2, buf_es->start >> 32,
-                               buf_es->start & 0xFFFFFFFF );
+            next_tag( m, buf_es );
         }
-        mpeg2_buffer( m->libmpeg2, buf_es->data,
-                      buf_es->data + buf_es->size );
+        mpeg2_buffer( m->libmpeg2, buf_es->data, buf_es->data + buf_es->size );
     }
 
     for( ;; )
@@ -155,7 +344,32 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
             /* Require some more data */
             break;
         }
-        else if( state == STATE_SEQUENCE )
+
+        // if the user requested captions, process
+        // any captions found in the current frame.
+        if ( m->list_subtitle && m->last_pts >= 0 &&
+             have_captions( m->info->user_data, m->info->user_data_len ) )
+        {
+            extract_mpeg2_captions( m );
+            // if we don't have a tag for the captions, make one
+            if ( m->last_cc1_buf && m->tags[m->cur_tag].cc_buf != m->last_cc1_buf )
+            {
+                if (m->tags[m->cur_tag].cc_buf)
+                {
+                    hb_log("mpeg2 tag botch2: pts %lld, tag pts %lld buf 0x%p",
+                           buf_es->start, m->tags[m->cur_tag].start, m->tags[m->cur_tag].cc_buf);
+                    hb_buffer_close( &m->tags[m->cur_tag].cc_buf );
+                }
+                // see if we already made a tag for the timestamp. If so we
+                // can just use it, otherwise make a new tag.
+                if (m->tags[m->cur_tag].start < 0)
+                {
+                    next_tag( m, buf_es );
+                }
+                m->tags[m->cur_tag].cc_buf = m->last_cc1_buf;
+            }
+        }
+        if( state == STATE_SEQUENCE )
         {
             if( !( m->width && m->height && m->rate ) )
             {
@@ -186,7 +400,9 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
         else if( ( state == STATE_SLICE || state == STATE_END ) &&
                  m->info->display_fbuf )
         {
-            if( ( m->info->display_picture->flags &
+            m->last_cc1_buf = NULL;
+
+            if( !m->got_iframe && ( m->info->display_picture->flags &
                   PIC_MASK_CODING_TYPE ) == PIC_FLAG_CODING_TYPE_I )
             {
                 // we got an iframe so we can start decoding video now
@@ -202,13 +418,16 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                                       m->info->display_fbuf->buf[2] );
                 buf->sequence = buf_es->sequence;
 
+                hb_buffer_t *cc_buf = NULL;
                 if( m->info->display_picture->flags & PIC_FLAG_TAGS )
                 {
-                    buf->start =
-                        ( (uint64_t) m->info->display_picture->tag << 32 ) |
-                        ( (uint64_t) m->info->display_picture->tag2 );
+                    int t = m->info->display_picture->tag;
+                    buf->start = m->tags[t].start;
+                    cc_buf = m->tags[t].cc_buf;
+                    m->tags[t].start = -1;
+                    m->tags[t].cc_buf = NULL;
                 }
-                else if( m->last_pts > -1 )
+                if( buf->start < 0 && m->last_pts >= 0 )
                 {
                     /* For some reason nb_fields is sometimes 1 while it
                        should be 2 */
@@ -216,11 +435,18 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                         MAX( 2, m->info->display_picture->nb_fields ) *
                         m->info->sequence->frame_period / 600;
                 }
-                else
+                if ( buf->start >= 0 )
+                {
+                    m->last_pts = buf->start;
+                }
+
+                // if we were accumulating captions we now know the timestamp
+                // so ship them to the decoder.
+                if ( cc_buf )
                 {
-                    buf->start = -1;
+                    cc_buf->start = m->last_pts;
+                    cc_send_to_decoder( m, cc_buf );
                 }
-                m->last_pts = buf->start;
 
                 if( m->look_for_iframe && ( m->info->display_picture->flags &
                       PIC_MASK_CODING_TYPE ) == PIC_FLAG_CODING_TYPE_I )
@@ -238,36 +464,41 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                                                          buf->new_chap - 1 );
                         chap_name = c->title;
                     }
-                    hb_log( "mpeg2: \"%s\" (%d) at frame %u time %lld",
+                    hb_log( "mpeg2: \"%s\" (%d) at frame %u time %"PRId64,
                             chap_name, buf->new_chap, m->nframes, buf->start );
-                } else if ( m->nframes == 0 && m->job &&
-                            hb_list_item( m->job->title->list_chapter,
-                                          m->job->chapter_start - 1 ) )
+                }
+                else if ( m->nframes == 0 )
                 {
-                    hb_chapter_t * c = hb_list_item( m->job->title->list_chapter,
-                                                     m->job->chapter_start - 1 );
-                    hb_log( "mpeg2: \"%s\" (%d) at frame %u time %lld", c->title,
-                            m->job->chapter_start, m->nframes, buf->start );
+                    // this is the first frame returned by the decoder
+                    m->first_pts = buf->start;
+                    if ( m->job && hb_list_item( m->job->title->list_chapter,
+                                                 m->job->chapter_start - 1 ) )
+                    {
+                        hb_chapter_t * c = hb_list_item( m->job->title->list_chapter,
+                                                         m->job->chapter_start - 1 );
+                        hb_log( "mpeg2: \"%s\" (%d) at frame %u time %"PRId64,
+                                c->title, m->job->chapter_start, m->nframes, buf->start );
+                    }
                 }
                 ++m->nframes;
 
-                flag = m->info->display_picture->flags;
+                m->flag = m->info->display_picture->flags;
 
 /*  Uncomment this block to see frame-by-frame picture flags, as the video encodes.
                hb_log("***** MPEG 2 Picture Info for PTS %lld *****", buf->start);
-                if( flag & TOP_FIRST )
+                if( m->flag & TOP_FIRST )
                     hb_log("MPEG2 Flag: Top field first");
-                if( flag & PROGRESSIVE )
+                if( m->flag & PROGRESSIVE )
                     hb_log("MPEG2 Flag: Progressive");
-                if( flag & COMPOSITE )
+                if( m->flag & COMPOSITE )
                     hb_log("MPEG2 Flag: Composite");
-                if( flag & SKIP )
+                if( m->flag & SKIP )
                     hb_log("MPEG2 Flag: Skip!");
-                if( flag & TAGS )
+                if( m->flag & TAGS )
                     hb_log("MPEG2 Flag: TAGS");
-                if(flag & REPEAT_FIRST )
+                if(fm->lag & REPEAT_FIRST )
                     hb_log("MPEG2 Flag: Repeat first field");
-                if( flag & COMPOSITE_MASK )
+                if( m->flag & COMPOSITE_MASK )
                     hb_log("MPEG2 Flag: Composite mask");
                 hb_log("fields: %d", m->info->display_picture->nb_fields);
 */
@@ -275,66 +506,66 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                 int i = 0;
                 for(i=11; i > 0; i--)
                 {
-                    cadence[i] = cadence[i-1];
+                    m->cadence[i] = m->cadence[i-1];
                 }
 
-                if ( !(flag & PROGRESSIVE) && !(flag & TOP_FIRST) )
+                if ( !(m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) )
                 {
                     /* Not progressive, not top first...
                        That means it's probably bottom
                        first, 2 fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Bottom field first, 2 fields displayed.");
-                    cadence[0] = BT;
+                    m->cadence[0] = BT;
                 }
-                else if ( !(flag & PROGRESSIVE) && (flag & TOP_FIRST) )
+                else if ( !(m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) )
                 {
                     /* Not progressive, top is first,
                        Two fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Top field first, 2 fields displayed.");
-                    cadence[0] = TB;
+                    m->cadence[0] = TB;
                 }
-                else if ( (flag & PROGRESSIVE) && !(flag & TOP_FIRST) && !( flag & REPEAT_FIRST )  )
+                else if ( (m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) && !( m->flag & REPEAT_FIRST )  )
                 {
                     /* Progressive, but noting else.
                        That means Bottom first,
                        2 fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Progressive. Bottom field first, 2 fields displayed.");
-                    cadence[0] = BT_PROG;
+                    m->cadence[0] = BT_PROG;
                 }
-                else if ( (flag & PROGRESSIVE) && !(flag & TOP_FIRST) && ( flag & REPEAT_FIRST )  )
+                else if ( (m->flag & PROGRESSIVE) && !(m->flag & TOP_FIRST) && ( m->flag & REPEAT_FIRST )  )
                 {
                     /* Progressive, and repeat. .
                        That means Bottom first,
                        3 fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Progressive repeat. Bottom field first, 3 fields displayed.");
-                    cadence[0] = BTB_PROG;
+                    m->cadence[0] = BTB_PROG;
                 }
-                else if ( (flag & PROGRESSIVE) && (flag & TOP_FIRST) && !( flag & REPEAT_FIRST )  )
+                else if ( (m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) && !( m->flag & REPEAT_FIRST )  )
                 {
                     /* Progressive, top first.
                        That means top first,
                        2 fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Progressive. Top field first, 2 fields displayed.");
-                    cadence[0] = TB_PROG;
+                    m->cadence[0] = TB_PROG;
                 }
-                else if ( (flag & PROGRESSIVE) && (flag & TOP_FIRST) && ( flag & REPEAT_FIRST )  )
+                else if ( (m->flag & PROGRESSIVE) && (m->flag & TOP_FIRST) && ( m->flag & REPEAT_FIRST )  )
                 {
                     /* Progressive, top, repeat.
                        That means top first,
                        3 fields displayed.
                     */
                     //hb_log("MPEG2 Flag: Progressive repeat. Top field first, 3 fields displayed.");
-                    cadence[0] = TBT_PROG;
+                    m->cadence[0] = TBT_PROG;
                 }
 
-                if ( (cadence[2] <= TB) && (cadence[1] <= TB) && (cadence[0] > TB) && (cadence[11]) )
+                if ( (m->cadence[2] <= TB) && (m->cadence[1] <= TB) && (m->cadence[0] > TB) && (m->cadence[11]) )
                     hb_log("%fs: Video -> Film", (float)buf->start / 90000);
-                if ( (cadence[2] > TB) && (cadence[1] <= TB) && (cadence[0] <= TB) && (cadence[11]) )
+                if ( (m->cadence[2] > TB) && (m->cadence[1] <= TB) && (m->cadence[0] <= TB) && (m->cadence[11]) )
                     hb_log("%fs: Film -> Video", (float)buf->start / 90000);
 
                 /* Store picture flags for later use by filters */
@@ -347,6 +578,60 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
         {
             mpeg2_reset( m->libmpeg2, 0 );
         }
+
+        /*
+         * Add closed captions to the title if we are scanning (no job).
+         *
+         * Just because we don't add this doesn't mean that there aren't any when 
+         * we scan, just that noone said anything. So you should be able to add
+         * closed captions some other way (See decmpeg2Init() for alternative
+         * approach of assuming that there are always CC, which is probably
+         * safer - however I want to leave the autodetect in here for now to
+         * see how it goes).
+         */
+        if( !m->job && m->title &&
+            have_captions( m->info->user_data, m->info->user_data_len ) )
+        {
+            hb_subtitle_t *subtitle;
+            int i = 0;
+            
+            while ( ( subtitle = hb_list_item( m->title->list_subtitle, i++ ) ) )
+            {
+                /*
+                 * Let's call them 608 subs for now even if they aren't,
+                 * since they are the only types we grok.
+                 */
+                if( subtitle->source == CC608SUB ) 
+                {
+                    break;
+                }
+            }
+            
+            if( ! subtitle )
+            {
+                subtitle = calloc( sizeof( hb_subtitle_t ), 1 );
+                subtitle->track = 0;
+                subtitle->id = 0;
+                subtitle->format = TEXTSUB;
+                subtitle->source = CC608SUB;
+                subtitle->config.dest = PASSTHRUSUB;
+                subtitle->type = 5; 
+                snprintf( subtitle->lang, sizeof( subtitle->lang ), "Closed Captions");
+                /*
+                 * The language of the subtitles will be the same as the first audio
+                 * track, i.e. the same as the video.
+                 */
+                hb_audio_t *audio = hb_list_item( m->title->list_audio, 0 );
+                if( audio )
+                {
+                    snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), 
+                              audio->config.lang.iso639_2);
+                } else {
+                    snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "und");
+                }
+                hb_list_add( m->title->list_subtitle, subtitle );
+            }
+        }
     }
     return 1;
 }
@@ -362,6 +647,13 @@ static void hb_libmpeg2_close( hb_libmpeg2_t ** _m )
 
     mpeg2_close( m->libmpeg2 );
 
+    int i;
+    for ( i = 0; i < NTAGS; ++i )
+    {
+        if ( m->tags[i].cc_buf )
+            hb_buffer_close( &m->tags[i].cc_buf );
+    }
+
     free( m );
     *_m = NULL;
 }
@@ -394,6 +686,33 @@ static int decmpeg2Init( hb_work_object_t * w, hb_job_t * job )
 
     pv->libmpeg2->job = job;
 
+    if( job && job->title ) {
+        pv->libmpeg2->title = job->title;
+    }
+
+    /*
+     * If not scanning, then are we supposed to extract Closed Captions
+     * and send them to the decoder? 
+     */
+    if( job && hb_list_count( job->list_subtitle ) > 0 )
+    {
+        hb_subtitle_t *subtitle;
+        int i = 0;
+        
+        for( i = 0; i < hb_list_count( job->list_subtitle ); i++ )
+        while ( ( subtitle = hb_list_item( job->list_subtitle, i++ ) ) != NULL )
+        {
+            if( subtitle->source == CC608SUB ) 
+            {
+                if ( ! pv->libmpeg2->list_subtitle )
+                {
+                    pv->libmpeg2->list_subtitle = hb_list_init();
+                }
+                hb_list_add(pv->libmpeg2->list_subtitle, subtitle);
+            }
+        }
+    }
+
     return 0;
 }
 
@@ -403,17 +722,25 @@ static int decmpeg2Init( hb_work_object_t * w, hb_job_t * job )
  *
  *********************************************************************/
 static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
-                   hb_buffer_t ** buf_out )
+                         hb_buffer_t ** buf_out )
 {
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * buf, * last = NULL;
     int status = HB_WORK_OK;
 
-    // The reader found a chapter break, consume it completely, and remove it from the
-    // stream. We need to shift it.
+    if( w->title && pv && pv->libmpeg2 && !pv->libmpeg2->title ) {
+        pv->libmpeg2->title = w->title;
+    }
+
+    // The reader found a chapter break. Remove it from the input 
+    // stream. If we're reading (as opposed to scanning) start looking
+    // for the next GOP start since that's where the chapter begins.
     if( (*buf_in)->new_chap )
     {
-        pv->libmpeg2->look_for_break = (*buf_in)->new_chap;
+        if ( pv->libmpeg2->job )
+        {
+            pv->libmpeg2->look_for_break = (*buf_in)->new_chap;
+        }
         (*buf_in)->new_chap = 0;
     }
 
@@ -425,6 +752,20 @@ static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
         hb_list_add( pv->list, *buf_in );
         *buf_in = NULL;
         status = HB_WORK_DONE;
+
+        /*
+         * Purge any pending caption buffer then let the Closed Captions decoder
+         * know that it is the end of the data.
+         */
+        if ( pv->libmpeg2->list_subtitle )
+        {
+            if ( pv->libmpeg2->last_cc1_buf )
+            {
+                cc_send_to_decoder( pv->libmpeg2, pv->libmpeg2->last_cc1_buf );
+                pv->libmpeg2->last_cc1_buf = NULL;
+            }
+            cc_send_to_decoder( pv->libmpeg2, hb_buffer_init( 0 ) );
+        }
     }
 
     *buf_out = NULL;
@@ -460,7 +801,15 @@ static void decmpeg2Close( hb_work_object_t * w )
     {
         hb_log( "mpeg2 done: %d frames", pv->libmpeg2->nframes );
     }
+    if ( pv->libmpeg2->last_cc1_buf )
+    {
+        hb_buffer_close( &pv->libmpeg2->last_cc1_buf );
+    }
     hb_list_close( &pv->list );
+    if ( pv->libmpeg2->list_subtitle )
+    {
+        hb_list_close( &pv->libmpeg2->list_subtitle );
+    }
     hb_libmpeg2_close( &pv->libmpeg2 );
     free( pv );
 }
index 2194f56..584a340 100644 (file)
@@ -4,14 +4,74 @@
    Homepage: <http://handbrake.fr/>.
    It may be used under the terms of the GNU General Public License. 
    
-   The yadif algorithm was created by Michael Niedermayer. */
+   The yadif algorithm was created by Michael Niedermayer.
+   Tritical's work inspired much of the comb detection code:
+   http://web.missouri.edu/~kes25c/
+*/
+
+/*****
+Parameters:
+    Mode : Spatial metric : Motion thresh : Spatial thresh : Block thresh :
+    Block width : Block height
+
+Appended for EEDI2:
+    Magnitude thresh : Variance thresh : Laplacian thresh : Dilation thresh :
+    Erosion thresh : Noise thresh : Max search distance : Post-processing
+
+Plus:
+    Parity
+    
+Defaults:
+    7:2:6:9:80:16:16:10:20:20:4:2:50:24:1:-1
+*****/
+
+#define MODE_YADIF       1 // Use yadif
+#define MODE_BLEND       2 // Use blending interpolation
+#define MODE_CUBIC       4 // Use cubic interpolation
+#define MODE_EEDI2       8 // Use EEDI2 interpolation
+#define MODE_MCDEINT    16 // Post-process with mcdeint
+#define MODE_MASK       32 // Output combing masks instead of pictures
+
+/***** 
+These modes can be layered. For example, Yadif (1) + EEDI2 (8) = 9,
+which will feed EEDI2 interpolations to yadif.
+
+** Working combos:
+ 1: Just yadif
+ 2: Just blend
+ 3: Switch between yadif and blend
+ 4: Just cubic interpolate
+ 5: Cubic->yadif
+ 6: Switch between cubic and blend
+ 7: Switch between cubic->yadif and blend
+ 8: Just EEDI2 interpolate
+ 9: EEDI2->yadif
+10: Switch between EEDI2 and blend
+11: Switch between EEDI2->yadif and blend
+17: Yadif->mcdeint
+18: Blend->mcdeint
+19: Switch between blending and yadif -> mcdeint
+20: Cubic->mdeint
+21: Cubic->yadif->mcdeint
+22: Cubic or blend -> mcdeint
+23: Cubic->yadif or blend -> mcdeint
+24: EEDI2->mcdeint
+25: EEDI2->yadif->mcdeint
+...okay I'm getting bored now listing all these different modes
+32: Passes through the combing mask for every combed frame (white for combed pixels, otherwise black)
+33+: Overlay the combing mask for every combed frame on top of the filtered output (white for combed pixels)
+
+12-15: EEDI2 will override cubic interpolation
+16: DOES NOT WORK BY ITSELF-- mcdeint needs to be fed by another deinterlacer
+*****/
+
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
+#include "eedi2.h"
 
 #define SUPPRESS_AV_LOG
 
-#define MODE_DEFAULT     1
 #define PARITY_DEFAULT   -1
 
 #define MCDEINT_MODE_DEFAULT   -1
 #define MIN3(a,b,c) MIN(MIN(a,b),c)
 #define MAX3(a,b,c) MAX(MAX(a,b),c)
 
-typedef struct yadif_arguments_s {
+// Some names to correspond to the pv->eedi_half array's contents
+#define SRCPF 0
+#define MSKPF 1
+#define TMPPF 2
+#define DSTPF 3
+// Some names to correspond to the pv->eedi_full array's contents
+#define DST2PF 0
+#define TMP2PF2 1
+#define MSK2PF 2
+#define TMP2PF 3
+#define DST2MPF 4
+
+struct yadif_arguments_s {
     uint8_t **dst;
     int parity;
     int tff;
     int stop;
     int is_combed;
-} yadif_arguments_t;
+};
+
+struct decomb_arguments_s {
+    int stop;
+};
 
-typedef struct decomb_arguments_s {
+struct eedi2_arguments_s {
     int stop;
-} decomb_arguments_t;
+};
+
+typedef struct yadif_arguments_s yadif_arguments_t;
+typedef struct decomb_arguments_s decomb_arguments_t;
+typedef struct eedi2_arguments_s eedi2_arguments_t;
+
+typedef struct eedi2_thread_arg_s {
+    hb_filter_private_t *pv;
+    int plane;
+} eedi2_thread_arg_t;
+
+typedef struct decomb_thread_arg_s {
+    hb_filter_private_t *pv;
+    int segment;
+} decomb_thread_arg_t;
+
+typedef struct yadif_thread_arg_s {
+    hb_filter_private_t *pv;
+    int segment;
+} yadif_thread_arg_t;
 
 struct hb_filter_private_s
 {
@@ -39,6 +134,7 @@ struct hb_filter_private_s
     int              width[3];
     int              height[3];
 
+    // Decomb parameters
     int              mode;
     int              spatial_metric;
     int              motion_threshold;
@@ -46,8 +142,19 @@ struct hb_filter_private_s
     int              block_threshold;
     int              block_width;
     int              block_height;
+    
+    // EEDI2 parameters
+    int              magnitude_threshold;
+    int              variance_threshold;
+    int              laplacian_threshold;
+    int              dilation_threshold;
+    int              erosion_threshold;
+    int              noise_threshold;
+    int              maximum_search_distance;
+    int              post_processing;
 
     int              parity;
+    int              tff;
     
     int              yadif_ready;
 
@@ -60,8 +167,8 @@ struct hb_filter_private_s
     AVFrame        * mcdeint_frame;
     AVFrame        * mcdeint_frame_dec;
 
-    int              yadif_deinterlaced_frames;
-    int              blend_deinterlaced_frames;
+    int              deinterlaced_frames;
+    int              blended_frames;
     int              unfiltered_frames;
 
     uint8_t        * ref[4][3];
@@ -70,6 +177,13 @@ struct hb_filter_private_s
     /* Make a buffer to store a comb mask. */
     uint8_t        * mask[3];
 
+    uint8_t        * eedi_half[4][3];
+    uint8_t        * eedi_full[5][3];
+    int            * cx2;
+    int            * cy2;
+    int            * cxy;
+    int            * tmpc;
+    
     AVPicture        pic_in;
     AVPicture        pic_out;
     hb_buffer_t *    buf_out[2];
@@ -86,7 +200,13 @@ struct hb_filter_private_s
     hb_lock_t      ** decomb_begin_lock;     // Thread has work
     hb_lock_t      ** decomb_complete_lock;  // Thread has completed work
     decomb_arguments_t *decomb_arguments;    // Arguments to thread for work
-    
+
+    hb_thread_t    ** eedi2_threads;        // Threads for eedi2 - one per plane
+    hb_lock_t      ** eedi2_begin_lock;     // Thread has work
+    hb_lock_t      ** eedi2_complete_lock;  // Thread has completed work
+    eedi2_arguments_t *eedi2_arguments;    // Arguments to thread for work
+
+//    int              alternator;           // for bobbing parity when framedoubling
 };
 
 hb_filter_private_t * hb_decomb_init( int pix_fmt,
@@ -106,14 +226,14 @@ void hb_decomb_close( hb_filter_private_t * pv );
 hb_filter_object_t hb_filter_decomb =
 {
     FILTER_DECOMB,
-    "Deinterlaces selectively with yadif/mcdeint and lowpass5 blending",
+    "Decomb",
     NULL,
     hb_decomb_init,
     hb_decomb_work,
     hb_decomb_close,
 };
 
-int cubic_interpolate( int y0, int y1, int y2, int y3 )
+int cubic_interpolate_pixel( int y0, int y1, int y2, int y3 )
 {
     /* From http://www.neuron2.net/library/cubicinterp.html */
     int result = ( y0 * -3 ) + ( y1 * 23 ) + ( y2 * 23 ) + ( y3 * -3 );
@@ -131,6 +251,111 @@ int cubic_interpolate( int y0, int y1, int y2, int y3 )
     return result;
 }
 
+static void cubic_interpolate_line( uint8_t *dst,
+                               uint8_t *cur,
+                               int plane,
+                               int y,
+                               hb_filter_private_t * pv )
+{
+    int w = pv->width[plane];
+    int refs = pv->ref_stride[plane];
+    int x;
+
+    for( x = 0; x < w; x++)
+    {
+        int a, b, c, d;
+        a = b = c = d = 0;
+        
+        if( y >= 3 )
+        {
+            /* Normal top*/
+            a = cur[-3*refs];
+            b = cur[-refs];
+        }
+        else if( y == 2 || y == 1 )
+        {
+            /* There's only one sample above this pixel, use it twice. */
+            a = cur[-refs];
+            b = cur[-refs];
+        }
+        else if( y == 0 )
+        {
+            /* No samples above, triple up on the one below. */
+            a = cur[+refs];
+            b = cur[+refs];
+        }
+        
+        if( y <= ( pv->height[plane] - 4 ) )
+        {
+            /* Normal bottom*/
+            c = cur[+refs];
+            d = cur[3*refs];            
+        }
+        else if( y == ( pv->height[plane] - 3 ) || y == ( pv->height[plane] - 2 ) )
+        {
+            /* There's only one sample below, use it twice. */
+            c = cur[+refs];
+            d = cur[+refs];
+        }
+        else if( y == pv->height[plane] - 1)
+        {
+            /* No samples below, triple up on the one above. */
+            c = cur[-refs];
+            d = cur[-refs];
+        }
+        
+        dst[0] = cubic_interpolate_pixel( a, b, c, d );
+        
+        dst++;
+        cur++;
+    }
+}
+
+void apply_mask_line( uint8_t * srcp,
+                      uint8_t * mskp,
+                      int width )
+{
+    int x;
+    
+    for( x = 0; x < width; x++ )
+    {
+        if( mskp[x] == 255 )
+        {
+            srcp[x] = 255;
+        }
+    }
+}
+
+void apply_mask( hb_filter_private_t * pv )
+{
+    int plane, height;
+    
+    for( plane = 0; plane < 3; plane++ )
+    {
+        uint8_t * srcp = ( pv->mode & MODE_MCDEINT ) ? pv->pic_in.data[plane] : pv->pic_out.data[plane];
+        uint8_t * mskp = pv->mask[plane];
+        
+        for( height = 0; height < pv->height[plane]; height++ )
+        {
+            if( pv->mode == MODE_MASK && plane == 0 )
+            {
+                memcpy( srcp, mskp, pv->width[plane] );
+            }
+            else if( pv->mode == MODE_MASK )
+            {
+                memset( srcp, 128, pv->width[plane] );
+            }
+            else if( plane == 0 )
+            {
+                apply_mask_line( srcp, mskp, pv->width[plane] );
+            }
+
+            srcp += pv->pic_out.linesize[plane];
+            mskp += pv->ref_stride[plane];
+        }
+    }
+}
+
 static void store_ref( const uint8_t ** pic,
                              hb_filter_private_t * pv )
 {
@@ -153,7 +378,7 @@ static void store_ref( const uint8_t ** pic,
         int ref_stride = pv->ref_stride[i];
 
         int y;
-        for( y = 0; y < pv->height[i]; y++ )
+        for( y = 0; y < h; y++ )
         {
             memcpy(ref, src, w);
             src = (uint8_t*)src + w;
@@ -162,6 +387,8 @@ static void store_ref( const uint8_t ** pic,
     }
 }
 
+/* This function may be useful in the future, if we want to output
+   a reference to an AVPicture, since they have different strides.
 static void get_ref( uint8_t ** pic, hb_filter_private_t * pv, int frm )
 {
     int i;
@@ -181,6 +408,7 @@ static void get_ref( uint8_t ** pic, hb_filter_private_t * pv, int frm )
         }
     }
 }
+*/
 
 int blend_filter_pixel( int up2, int up1, int current, int down1, int down2 )
 {
@@ -316,7 +544,7 @@ int check_combing_mask( hb_filter_private_t * pv )
                 if( block_score >= ( threshold / 2 ) )
                 {
 #if 0
-                    hb_log("decomb: frame %i | score %i | type %s", pv->yadif_deinterlaced_frames + pv->blend_deinterlaced_frames +  pv->unfiltered_frames + 1, block_score, pv->buf_settings->flags & 16 ? "Film" : "Video");
+                    hb_log("decomb: frame %i | score %i | type %s", pv->deinterlaced_frames + pv->blended_frames +  pv->unfiltered_frames + 1, block_score, pv->buf_settings->flags & 16 ? "Film" : "Video");
 #endif
                     if ( block_score <= threshold && !( pv->buf_settings->flags & 16) )
                     {
@@ -353,7 +581,7 @@ int check_combing_mask( hb_filter_private_t * pv )
     }
 }
 
-int detect_combed_segment( hb_filter_private_t * pv, int segment_start, int segment_stop )
+void detect_combed_segment( hb_filter_private_t * pv, int segment_start, int segment_stop )
 {
     /* A mish-mash of various comb detection tricks
        picked up from neuron2's Decomb plugin for
@@ -449,7 +677,7 @@ int detect_combed_segment( hb_filter_private_t * pv, int segment_start, int segm
                         motion = 1;
                     }
                            
-                    if( motion || ( pv->yadif_deinterlaced_frames==0 && pv->blend_deinterlaced_frames==0 && pv->unfiltered_frames==0) )
+                    if( motion || ( pv->deinterlaced_frames==0 && pv->blended_frames==0 && pv->unfiltered_frames==0) )
                     {
                            /* That means it's time for the spatial check.
                               We've got several options here.             */
@@ -510,10 +738,171 @@ int detect_combed_segment( hb_filter_private_t * pv, int segment_start, int segm
     }
 }
 
-typedef struct decomb_thread_arg_s {
-    hb_filter_private_t *pv;
-    int segment;
-} decomb_thread_arg_t;
+// This function calls all the eedi2 filters in sequence for a given plane.
+// It outputs the final interpolated image to pv->eedi_full[DST2PF].
+void eedi2_interpolate_plane( hb_filter_private_t * pv, int k )
+{
+    /* We need all these pointers. No, seriously.
+       I swear. It's not a joke. They're used.
+       All nine of them.                         */
+    uint8_t * mskp = pv->eedi_half[MSKPF][k];
+    uint8_t * srcp = pv->eedi_half[SRCPF][k];
+    uint8_t * tmpp = pv->eedi_half[TMPPF][k];
+    uint8_t * dstp = pv->eedi_half[DSTPF][k];
+    uint8_t * dst2p = pv->eedi_full[DST2PF][k];
+    uint8_t * tmp2p2 = pv->eedi_full[TMP2PF2][k];
+    uint8_t * msk2p = pv->eedi_full[MSK2PF][k];
+    uint8_t * tmp2p = pv->eedi_full[TMP2PF][k];
+    uint8_t * dst2mp = pv->eedi_full[DST2MPF][k];
+    int * cx2 = pv->cx2;
+    int * cy2 = pv->cy2;
+    int * cxy = pv->cxy;
+    int * tmpc = pv->tmpc;
+
+    int pitch = pv->ref_stride[k];
+    int height = pv->height[k]; int width = pv->width[k];
+    int half_height = height / 2;
+
+    // edge mask
+    eedi2_build_edge_mask( mskp, pitch, srcp, pitch,
+                     pv->magnitude_threshold, pv->variance_threshold, pv->laplacian_threshold, 
+                     half_height, width );
+    eedi2_erode_edge_mask( mskp, pitch, tmpp, pitch, pv->erosion_threshold, half_height, width );
+    eedi2_dilate_edge_mask( tmpp, pitch, mskp, pitch, pv->dilation_threshold, half_height, width );
+    eedi2_erode_edge_mask( mskp, pitch, tmpp, pitch, pv->erosion_threshold, half_height, width );
+    eedi2_remove_small_gaps( tmpp, pitch, mskp, pitch, half_height, width );
+
+    // direction mask
+    eedi2_calc_directions( k, mskp, pitch, srcp, pitch, tmpp, pitch,
+                     pv->maximum_search_distance, pv->noise_threshold,
+                     half_height, width );
+    eedi2_filter_dir_map( mskp, pitch, tmpp, pitch, dstp, pitch, half_height, width );
+    eedi2_expand_dir_map( mskp, pitch, dstp, pitch, tmpp, pitch, half_height, width );
+    eedi2_filter_map( mskp, pitch, tmpp, pitch, dstp, pitch, half_height, width );
+
+    // upscale 2x vertically
+    eedi2_upscale_by_2( srcp, dst2p, half_height, pitch );
+    eedi2_upscale_by_2( dstp, tmp2p2, half_height, pitch );
+    eedi2_upscale_by_2( mskp, msk2p, half_height, pitch );
+
+    // upscale the direction mask
+    eedi2_mark_directions_2x( msk2p, pitch, tmp2p2, pitch, tmp2p, pitch, pv->tff, height, width );
+    eedi2_filter_dir_map_2x( msk2p, pitch, tmp2p, pitch,  dst2mp, pitch, pv->tff, height, width );
+    eedi2_expand_dir_map_2x( msk2p, pitch, dst2mp, pitch, tmp2p, pitch, pv->tff, height, width );
+    eedi2_fill_gaps_2x( msk2p, pitch, tmp2p, pitch, dst2mp, pitch, pv->tff, height, width );
+    eedi2_fill_gaps_2x( msk2p, pitch, dst2mp, pitch, tmp2p, pitch, pv->tff, height, width );
+
+    // interpolate a full-size plane
+    eedi2_interpolate_lattice( k, tmp2p, pitch, dst2p, pitch, tmp2p2, pitch, pv->tff,
+                         pv->noise_threshold, height, width );
+
+    if( pv->post_processing == 1 || pv->post_processing == 3 )
+    {
+        // make sure the edge directions are consistent
+        eedi2_bit_blit( tmp2p2, pitch, tmp2p, pitch, pv->width[k], pv->height[k] );
+        eedi2_filter_dir_map_2x( msk2p, pitch, tmp2p, pitch, dst2mp, pitch, pv->tff, height, width );
+        eedi2_expand_dir_map_2x( msk2p, pitch, dst2mp, pitch, tmp2p, pitch, pv->tff, height, width );
+        eedi2_post_process( tmp2p, pitch, tmp2p2, pitch, dst2p, pitch, pv->tff, height, width );
+    }
+    if( pv->post_processing == 2 || pv->post_processing == 3 )
+    {
+        // filter junctions and corners
+        eedi2_gaussian_blur1( srcp, pitch, tmpp, pitch, srcp, pitch, half_height, width );
+        eedi2_calc_derivatives( srcp, pitch, half_height, width, cx2, cy2, cxy );
+        eedi2_gaussian_blur_sqrt2( cx2, tmpc, cx2, pitch, half_height, width);
+        eedi2_gaussian_blur_sqrt2( cy2, tmpc, cy2, pitch, half_height, width);
+        eedi2_gaussian_blur_sqrt2( cxy, tmpc, cxy, pitch, half_height, width);
+        eedi2_post_process_corner( cx2, cy2, cxy, pitch, tmp2p2, pitch, dst2p, pitch, height, width, pv->tff );
+    }
+}
+
+/*
+ *  eedi2 interpolate this plane in a single thread.
+ */
+void eedi2_filter_thread( void *thread_args_v )
+{
+    eedi2_arguments_t *eedi2_work = NULL;
+    hb_filter_private_t * pv;
+    int run = 1;
+    int plane;
+    eedi2_thread_arg_t *thread_args = thread_args_v;
+
+    pv = thread_args->pv;
+    plane = thread_args->plane;
+
+    hb_log("eedi2 thread started for plane %d", plane);
+
+    while( run )
+    {
+        /*
+         * Wait here until there is work to do. hb_lock() blocks until
+         * render releases it to say that there is more work to do.
+         */
+        hb_lock( pv->eedi2_begin_lock[plane] );
+
+        eedi2_work = &pv->eedi2_arguments[plane];
+
+        if( eedi2_work->stop )
+        {
+            /*
+             * No more work to do, exit this thread.
+             */
+            run = 0;
+            continue;
+        } 
+
+        /*
+         * Process plane
+         */
+            eedi2_interpolate_plane( pv, plane );
+        
+        /*
+         * Finished this segment, let everyone know.
+         */
+        hb_unlock( pv->eedi2_complete_lock[plane] );
+    }
+    free( thread_args_v );
+}
+
+// Sets up the input field planes for EEDI2 in pv->eedi_half[SRCPF]
+// and then runs eedi2_filter_thread for each plane.
+void eedi2_planer( hb_filter_private_t * pv )
+{
+    /* Copy the first field from the source to a half-height frame. */
+    int i;
+    for( i = 0;  i < 3; i++ )
+    {
+        int pitch = pv->ref_stride[i];
+        int start_line = !pv->tff;
+        eedi2_fill_half_height_buffer_plane( &pv->ref[1][i][pitch*start_line], pv->eedi_half[SRCPF][i], pitch, pv->height[i] );
+    }
+    
+    int plane;
+    for( plane = 0; plane < 3; plane++ )
+    {  
+        /*
+         * Let the thread for this plane know that we've setup work 
+         * for it by releasing the begin lock (ensuring that the
+         * complete lock is already locked so that we block when
+         * we try to lock it again below).
+         */
+        hb_lock( pv->eedi2_complete_lock[plane] );
+        hb_unlock( pv->eedi2_begin_lock[plane] );
+    }
+
+    /*
+     * Wait until all three threads have completed by trying to get
+     * the complete lock that we locked earlier for each thread, which
+     * will block until that thread has completed the work on that
+     * plane.
+     */
+    for( plane = 0; plane < 3; plane++ )
+    {
+        hb_lock( pv->eedi2_complete_lock[plane] );
+        hb_unlock( pv->eedi2_complete_lock[plane] );
+    }
+}
+
 
 /*
  * comb detect this segment of all three planes in a single thread.
@@ -556,9 +945,7 @@ void decomb_filter_thread( void *thread_args_v )
         for( plane = 0; plane < 1; plane++)
         {
 
-            int w = pv->width[plane];
             int h = pv->height[plane];
-            int ref_stride = pv->ref_stride[plane];
             segment_start = ( h / pv->cpu_count ) * segment;
             if( segment == pv->cpu_count - 1 )
             {
@@ -626,16 +1013,21 @@ static void yadif_filter_line( uint8_t *dst,
        to the other field in the current frame--the one not being filtered.  */
     uint8_t *prev2 = parity ? prev : cur ;
     uint8_t *next2 = parity ? cur  : next;
+    
     int w = pv->width[plane];
     int refs = pv->ref_stride[plane];
     int x;
+    int eedi2_mode = ( pv->mode & MODE_EEDI2 );
     
+    /* We can replace spatial_pred with this interpolation*/
+    uint8_t * eedi2_guess = &pv->eedi_full[DST2PF][plane][y*refs];
+
     /* Decomb's cubic interpolation can only function when there are
        three samples above and below, so regress to yadif's traditional
        two-tap interpolation when filtering at the top and bottom edges. */
-    int edge = 0;
+    int vertical_edge = 0;
     if( ( y < 3 ) || ( y > ( pv->height[plane] - 4 ) )  )
-        edge = 1;
+        vertical_edge = 1;
 
     for( x = 0; x < w; x++)
     {
@@ -654,60 +1046,83 @@ static void yadif_filter_line( uint8_t *dst,
         int temporal_diff2 = ( ABS(next[-refs] - cur[-refs]) + ABS(next[+refs] - cur[+refs]) ) >> 1;
         /* For the actual difference, use the largest of the previous average diffs. */
         int diff           = MAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2);
-        
-        /* SAD of how the pixel-1, the pixel, and the pixel+1 change from the line above to below. */ 
-        int spatial_score  = ABS(cur[-refs-1] - cur[+refs-1]) + ABS(cur[-refs]-cur[+refs]) +
-                                     ABS(cur[-refs+1] - cur[+refs+1]) - 1;         
+
         int spatial_pred;
-         
-        /* Spatial pred is either a bilinear or cubic vertical interpolation. */
-        if( pv->mode > 0 && !edge)
+        
+        if( eedi2_mode )
         {
-            spatial_pred = cubic_interpolate( cur[-3*refs], cur[-refs], cur[+refs], cur[3*refs] );
+            /* Who needs yadif's spatial predictions when we can have EEDI2's? */
+            spatial_pred = eedi2_guess[0];
+            eedi2_guess++;
         }
-        else
+        else // Yadif spatial interpolation
         {
-            spatial_pred = (c+e)>>1;
+            /* SAD of how the pixel-1, the pixel, and the pixel+1 change from the line above to below. */ 
+            int spatial_score  = ABS(cur[-refs-1] - cur[+refs-1]) + ABS(cur[-refs]-cur[+refs]) +
+                                         ABS(cur[-refs+1] - cur[+refs+1]) - 1;         
+            
+            /* Spatial pred is either a bilinear or cubic vertical interpolation. */
+            if( ( pv->mode & MODE_CUBIC ) && !vertical_edge)
+            {
+                spatial_pred = cubic_interpolate_pixel( cur[-3*refs], cur[-refs], cur[+refs], cur[3*refs] );
+            }
+            else
+            {
+                spatial_pred = (c+e)>>1;
+            }
+
+        /* EDDI: Edge Directed Deinterlacing Interpolation
+           Checks 4 different slopes to see if there is more similarity along a diagonal
+           than there was vertically. If a diagonal is more similar, then it indicates
+           an edge, so interpolate along that instead of a vertical line, using either
+           linear or cubic interpolation depending on mode. */
+        #define YADIF_CHECK(j)\
+                {   int score = ABS(cur[-refs-1+j] - cur[+refs-1-j])\
+                              + ABS(cur[-refs  +j] - cur[+refs  -j])\
+                              + ABS(cur[-refs+1+j] - cur[+refs+1-j]);\
+                    if( score < spatial_score ){\
+                        spatial_score = score;\
+                        if( ( pv->mode & MODE_CUBIC ) && !vertical_edge )\
+                        {\
+                            switch(j)\
+                            {\
+                                case -1:\
+                                    spatial_pred = cubic_interpolate_pixel(cur[-3 * refs - 3], cur[-refs -1], cur[+refs + 1], cur[3* refs + 3] );\
+                                break;\
+                                case -2:\
+                                    spatial_pred = cubic_interpolate_pixel( ( ( cur[-3*refs - 4] + cur[-refs - 4] ) / 2 ) , cur[-refs -2], cur[+refs + 2], ( ( cur[3*refs + 4] + cur[refs + 4] ) / 2 ) );\
+                                break;\
+                                case 1:\
+                                    spatial_pred = cubic_interpolate_pixel(cur[-3 * refs +3], cur[-refs +1], cur[+refs - 1], cur[3* refs -3] );\
+                                break;\
+                                case 2:\
+                                    spatial_pred = cubic_interpolate_pixel(( ( cur[-3*refs + 4] + cur[-refs + 4] ) / 2 ), cur[-refs +2], cur[+refs - 2], ( ( cur[3*refs - 4] + cur[refs - 4] ) / 2 ) );\
+                                break;\
+                            }\
+                        }\
+                        else\
+                        {\
+                            spatial_pred = ( cur[-refs +j] + cur[+refs -j] ) >>1;\
+                        }\
+
+                        if( x >= 2 && x <= w - 3 )
+                        {
+                            YADIF_CHECK(-1)
+                            if( x >= 3 && x <= w - 4 )
+                            {
+                                YADIF_CHECK(-2) }} }}
+                            }
+                        }
+                        if( x >= 2 && x <= w - 3 )
+                        {
+                            YADIF_CHECK(1)
+                            if( x >= 3 && x <= w - 4 )
+                            {
+                                YADIF_CHECK(2) }} }}
+                            }
+                        }
         }
 
-/* EDDI: Edge Directed Deinterlacing Interpolation
-   Uses the Martinez-Lim Line Shift Parametric Modeling algorithm...I think.
-   Checks 4 different slopes to see if there is more similarity along a diagonal
-   than there was vertically. If a diagonal is more similar, then it indicates
-   an edge, so interpolate along that instead of a vertical line, using either
-   linear or cubic interpolation depending on mode. */
-#define YADIF_CHECK(j)\
-        {   int score = ABS(cur[-refs-1+j] - cur[+refs-1-j])\
-                      + ABS(cur[-refs  +j] - cur[+refs  -j])\
-                      + ABS(cur[-refs+1+j] - cur[+refs+1-j]);\
-            if( score < spatial_score ){\
-                spatial_score = score;\
-                if( pv->mode > 0 && !edge )\
-                {\
-                    switch(j)\
-                    {\
-                        case -1:\
-                            spatial_pred = cubic_interpolate(cur[-3 * refs - 3], cur[-refs -1], cur[+refs + 1], cur[3* refs + 3] );\
-                        break;\
-                        case -2:\
-                            spatial_pred = cubic_interpolate( ( ( cur[-3*refs - 4] + cur[-refs - 4] ) / 2 ) , cur[-refs -2], cur[+refs + 2], ( ( cur[3*refs + 4] + cur[refs + 4] ) / 2 ) );\
-                        break;\
-                        case 1:\
-                            spatial_pred = cubic_interpolate(cur[-3 * refs +3], cur[-refs +1], cur[+refs - 1], cur[3* refs -3] );\
-                        break;\
-                        case 2:\
-                            spatial_pred = cubic_interpolate(( ( cur[-3*refs + 4] + cur[-refs + 4] ) / 2 ), cur[-refs +2], cur[+refs - 2], ( ( cur[3*refs - 4] + cur[refs - 4] ) / 2 ) );\
-                        break;\
-                    }\
-                }\
-                else\
-                {\
-                    spatial_pred = ( cur[-refs +j] + cur[+refs -j] ) >>1;\
-                }\
-                
-                YADIF_CHECK(-1) YADIF_CHECK(-2) }} }}
-                YADIF_CHECK( 1) YADIF_CHECK( 2) }} }}
-                                
         /* Temporally adjust the spatial prediction by
            comparing against lines in the adjacent fields. */
         int b = (prev2[-2*refs] + next2[-2*refs])>>1;
@@ -738,11 +1153,6 @@ static void yadif_filter_line( uint8_t *dst,
     }
 }
 
-typedef struct yadif_thread_arg_s {
-    hb_filter_private_t *pv;
-    int segment;
-} yadif_thread_arg_t;
-
 /*
  * deinterlace this segment of all three planes in a single thread.
  */
@@ -817,17 +1227,26 @@ void yadif_decomb_filter_thread( void *thread_args_v )
 
             for( y = segment_start; y < segment_stop; y++ )
             {
-                if( ( pv->mode == 4 && is_combed ) || is_combed == 2 )
+                if( is_combed == 2 )
                 {
                     /* This line gets blend filtered, not yadif filtered. */
-                    uint8_t *prev = &pv->ref[0][plane][y*ref_stride];
                     uint8_t *cur  = &pv->ref[1][plane][y*ref_stride];
-                    uint8_t *next = &pv->ref[2][plane][y*ref_stride];
                     uint8_t *dst2 = &dst[plane][y*w];
+                    /* These will be useful if we ever do temporal blending. */
+                    // uint8_t *prev = &pv->ref[0][plane][y*ref_stride];
+                    // uint8_t *next = &pv->ref[2][plane][y*ref_stride];
 
                     blend_filter_line( dst2, cur, plane, y, pv );
                 }
-                else if( ( ( y ^ parity ) &  1 )  && ( is_combed == 1 ) )
+                else if( pv->mode == MODE_CUBIC && is_combed && ( ( y ^ parity ) & 1 ) )
+                {
+                    /* Just apply vertical cubic interpolation */
+                    uint8_t *cur  = &pv->ref[1][plane][y*ref_stride];
+                    uint8_t *dst2 = &dst[plane][y*w];
+                    
+                    cubic_interpolate_line( dst2, cur, plane, y, pv );
+                }
+                else if( pv->mode & MODE_YADIF && ( ( y ^ parity ) &  1 )  && ( is_combed == 1 ) )
                 {
                     /* This line gets yadif filtered. It is the bottom field
                        when TFF and vice-versa. It's the field that gets
@@ -902,65 +1321,129 @@ static void yadif_filter( uint8_t ** dst,
                           int tff,
                           hb_filter_private_t * pv )
 {
+    /* If we're running comb detection, do it now, otherwise default to true. */
+    int is_combed = pv->spatial_metric >= 0 ? comb_segmenter( pv ) : 1;
     
-    int is_combed = comb_segmenter( pv );
+    /* The comb detector suggests three different values:
+       0: Don't comb this frame.
+       1: Deinterlace this frame.
+       2: Blend this frame.
+       Since that might conflict with the filter's mode,
+       it may be necesary to adjust this value.          */
+    if( is_combed == 1 && (pv->mode == MODE_BLEND) )
+    {
+        /* All combed frames are getting blended */
+        is_combed = 2;
+    }
+    else if( is_combed == 2 && !( pv->mode & MODE_BLEND ) )
+    {
+        /* Blending is disabled, so force interpolation of these frames. */
+        is_combed = 1;
+    }
+    if( is_combed == 1 &&
+        ( pv->mode & MODE_BLEND ) &&
+        !( pv->mode & ( MODE_YADIF | MODE_EEDI2 | MODE_CUBIC ) ) )
+    {
+        /* Deinterlacers are disabled, blending isn't, so blend these frames. */
+        is_combed = 2;
+    }
+    else if( is_combed &&
+             !( pv->mode & ( MODE_BLEND | MODE_YADIF | MODE_EEDI2 | MODE_CUBIC | MODE_MASK ) ) )
+    {
+        /* No deinterlacer or mask chosen, pass the frame through. */
+        is_combed = 0;
+    }
     
     if( is_combed == 1 )
     {
-        pv->yadif_deinterlaced_frames++;
+        pv->deinterlaced_frames++;
     }
     else if( is_combed == 2 )
     {
-        pv->blend_deinterlaced_frames++;
+        pv->blended_frames++;
     }
     else
     {
         pv->unfiltered_frames++;
     }
     
+    if( is_combed == 1 && ( pv->mode & MODE_EEDI2 ) )
+    {
+        /* Generate an EEDI2 interpolation */
+        eedi2_planer( pv );
+    }
+    
     if( is_combed )
     {
-        int segment;
+        if( ( pv->mode & MODE_EEDI2 ) && !( pv->mode & MODE_YADIF ) && is_combed == 1 )
+        {
+            // Just pass through the EEDI2 interpolation
+            int i;
+            for( i = 0; i < 3; i++ )
+            {
+                uint8_t * ref = pv->eedi_full[DST2PF][i];
+                uint8_t * dest = dst[i];
+
+                int w = pv->width[i];
+                int ref_stride = pv->ref_stride[i];
+
+                int y;
+                for( y = 0; y < pv->height[i]; y++ )
+                {
+                    memcpy(dest, ref, w);
+                    dest += w;
+                    ref += ref_stride;
+                }
+            }
+        }
+        else
+        {
+            int segment;
+
+            for( segment = 0; segment < pv->cpu_count; segment++ )
+            {  
+                /*
+                 * Setup the work for this plane.
+                 */
+                pv->yadif_arguments[segment].parity = parity;
+                pv->yadif_arguments[segment].tff = tff;
+                pv->yadif_arguments[segment].dst = dst;
+                pv->yadif_arguments[segment].is_combed = is_combed;
+
+                /*
+                 * Let the thread for this plane know that we've setup work 
+                 * for it by releasing the begin lock (ensuring that the
+                 * complete lock is already locked so that we block when
+                 * we try to lock it again below).
+                 */
+                hb_lock( pv->yadif_complete_lock[segment] );
+                hb_unlock( pv->yadif_begin_lock[segment] );
+            }
 
-        for( segment = 0; segment < pv->cpu_count; segment++ )
-        {  
             /*
-             * Setup the work for this plane.
+             * Wait until all three threads have completed by trying to get
+             * the complete lock that we locked earlier for each thread, which
+             * will block until that thread has completed the work on that
+             * plane.
              */
-            pv->yadif_arguments[segment].parity = parity;
-            pv->yadif_arguments[segment].tff = tff;
-            pv->yadif_arguments[segment].dst = dst;
-            pv->yadif_arguments[segment].is_combed = is_combed;
+            for( segment = 0; segment < pv->cpu_count; segment++ )
+            {
+                hb_lock( pv->yadif_complete_lock[segment] );
+                hb_unlock( pv->yadif_complete_lock[segment] );
+            }
 
             /*
-             * Let the thread for this plane know that we've setup work 
-             * for it by releasing the begin lock (ensuring that the
-             * complete lock is already locked so that we block when
-             * we try to lock it again below).
+             * Entire frame is now deinterlaced.
              */
-            hb_lock( pv->yadif_complete_lock[segment] );
-            hb_unlock( pv->yadif_begin_lock[segment] );
-        }
-
-        /*
-         * Wait until all three threads have completed by trying to get
-         * the complete lock that we locked earlier for each thread, which
-         * will block until that thread has completed the work on that
-         * plane.
-         */
-        for( segment = 0; segment < pv->cpu_count; segment++ )
-        {
-            hb_lock( pv->yadif_complete_lock[segment] );
-            hb_unlock( pv->yadif_complete_lock[segment] );
         }
-
-        /*
-         * Entire frame is now deinterlaced.
-         */
     }
     else
     {
         /*  Just passing through... */
+        
+        /* For mcdeint's benefit... */
+        pv->yadif_arguments[0].is_combed = is_combed; // 0
+        
         int i;
         for( i = 0; i < 3; i++ )
         {
@@ -979,6 +1462,12 @@ static void yadif_filter( uint8_t ** dst,
             }
         }
     }
+    
+    if( pv->mode & MODE_MASK && pv->spatial_metric >= 0 )
+    {
+        if( pv->mode == MODE_MASK || is_combed )
+        apply_mask( pv );
+    }
 }
 
 static void mcdeint_filter( uint8_t ** dst,
@@ -1024,7 +1513,7 @@ static void mcdeint_filter( uint8_t ** dst,
             {
                 for( x = 0; x < w; x++ )
                 {
-                    if( (x-2)+(y-1)*w >= 0 && (x+2)+(y+1)*w < w*h )
+                    if( (x-1)+(y-1)*w >= 0 && (x+1)+(y+1)*w < w*h )
                     {
                         uint8_t * filp =
                             &pv->mcdeint_frame_dec->data[i][x + y*fils];
@@ -1032,11 +1521,12 @@ static void mcdeint_filter( uint8_t ** dst,
 
                         int diff0 = filp[-fils] - srcp[-srcs];
                         int diff1 = filp[+fils] - srcp[+srcs];
-
-                        int spatial_score =
-                              ABS(srcp[-srcs-1] - srcp[+srcs-1])
-                            + ABS(srcp[-srcs  ] - srcp[+srcs  ])
-                            + ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 1;
+                        int spatial_score;
+                        
+                        spatial_score =
+                            ABS(srcp[-srcs-1] - srcp[+srcs-1]) +
+                            ABS(srcp[-srcs  ] - srcp[+srcs  ]) +
+                            ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 1;
 
                         int temp = filp[0];
 
@@ -1049,8 +1539,22 @@ static void mcdeint_filter( uint8_t ** dst,
                                 diff0 = filp[-fils+j] - srcp[-srcs+j];\
                                 diff1 = filp[+fils-j] - srcp[+srcs-j];
 
-                        MCDEINT_CHECK(-1) MCDEINT_CHECK(-2) }} }}
-                        MCDEINT_CHECK( 1) MCDEINT_CHECK( 2) }} }}
+                        if( x >= 2 && x <= w - 3 )
+                        {
+                            MCDEINT_CHECK(-1)
+                            if( x >= 3 && x <= w - 4 )
+                            {
+                                MCDEINT_CHECK(-2) }} }}
+                            }
+                        }
+                        if( x >= 2 && x <= w - 3 )
+                        {
+                            MCDEINT_CHECK(1)
+                            if( x >= 3 && x <= w - 4 )
+                            {
+                                MCDEINT_CHECK(2) }} }}
+                            }
+                        }
 
                         if(diff0 + diff1 > 0)
                         {
@@ -1073,11 +1577,7 @@ static void mcdeint_filter( uint8_t ** dst,
                     }
                 }
             }
-        }
-
-        for( y = 0; y < h; y++ )
-        {
-            if( !((y ^ parity) & 1) )
+            else
             {
                 for( x = 0; x < w; x++ )
                 {
@@ -1117,13 +1617,13 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
     pv->buf_out[1] = hb_video_buffer_init( width, height );
     pv->buf_settings = hb_buffer_init( 0 );
 
-    pv->yadif_deinterlaced_frames = 0;
-    pv->blend_deinterlaced_frames = 0;
+    pv->deinterlaced_frames = 0;
+    pv->blended_frames = 0;
     pv->unfiltered_frames = 0;
 
     pv->yadif_ready    = 0;
 
-    pv->mode     = MODE_DEFAULT;
+    pv->mode     = MODE_YADIF | MODE_BLEND | MODE_CUBIC;
     pv->spatial_metric = 2;
     pv->motion_threshold = 6;
     pv->spatial_threshold = 9;
@@ -1131,6 +1631,15 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
     pv->block_width = 16;
     pv->block_height = 16;
     
+    pv->magnitude_threshold = 10;
+    pv->variance_threshold = 20;
+    pv->laplacian_threshold = 20;
+    pv->dilation_threshold = 4;
+    pv->erosion_threshold = 2;
+    pv->noise_threshold = 50;
+    pv->maximum_search_distance = 24;
+    pv->post_processing = 1;
+
     pv->parity   = PARITY_DEFAULT;
 
     pv->mcdeint_mode   = MCDEINT_MODE_DEFAULT;
@@ -1138,22 +1647,31 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
 
     if( settings )
     {
-        sscanf( settings, "%d:%d:%d:%d:%d:%d:%d",
+        sscanf( settings, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
                 &pv->mode,
                 &pv->spatial_metric,
                 &pv->motion_threshold,
                 &pv->spatial_threshold,
                 &pv->block_threshold,
                 &pv->block_width,
-                &pv->block_height );
+                &pv->block_height,
+                &pv->magnitude_threshold,
+                &pv->variance_threshold,
+                &pv->laplacian_threshold,
+                &pv->dilation_threshold,
+                &pv->erosion_threshold,
+                &pv->noise_threshold,
+                &pv->maximum_search_distance,
+                &pv->post_processing,
+                &pv->parity );
     }
     
     pv->cpu_count = hb_get_cpu_count();
     
 
-    if( pv->mode == 2 || pv->mode == 3 )
+    if( pv->mode & MODE_MCDEINT )
     {
-        pv->mcdeint_mode = 0;
+        pv->mcdeint_mode = 2;
     }
     
     /* Allocate yadif specific buffers */
@@ -1168,7 +1686,7 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
 
         for( j = 0; j < 3; j++ )
         {
-            pv->ref[j][i] = malloc( w*h*sizeof(uint8_t) ) + 3*w;
+            pv->ref[j][i] = calloc( 1, w*h*sizeof(uint8_t) ) + 3*w;
         }
     }
 
@@ -1181,7 +1699,38 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
 
         pv->mask[i] = calloc( 1, w*h*sizeof(uint8_t) ) + 3*w;
     }
+    
+    if( pv->mode & MODE_EEDI2 )
+    {
+        /* Allocate half-height eedi2 buffers */
+        height = pv->height[0] / 2;
+        for( i = 0; i < 3; i++ )
+        {
+            int is_chroma = !!i;
+            int w = ((width   + 31) & (~31))>>is_chroma;
+            int h = ((height+6+ 31) & (~31))>>is_chroma;
 
+            for( j = 0; j < 4; j++ )
+            {
+                pv->eedi_half[j][i] = calloc( 1, w*h*sizeof(uint8_t) ) + 3*w;
+            }
+        }
+
+        /* Allocate full-height eedi2 buffers */
+        height = pv->height[0];
+        for( i = 0; i < 3; i++ )
+        {
+            int is_chroma = !!i;
+            int w = ((width   + 31) & (~31))>>is_chroma;
+            int h = ((height+6+ 31) & (~31))>>is_chroma;
+
+            for( j = 0; j < 5; j++ )
+            {
+                pv->eedi_full[j][i] = calloc( 1, w*h*sizeof(uint8_t) ) + 3*w;
+            }
+        }
+    }
+    
      /*
       * Create yadif threads and locks.
       */
@@ -1264,7 +1813,62 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
             hb_error( "decomb could not create threads" );
         }
     }
+    
+    if( pv->mode & MODE_EEDI2 )
+    {
+        /*
+         * Create eedi2 threads and locks.
+         */
+        pv->eedi2_threads = malloc( sizeof( hb_thread_t* ) * 3 );
+        pv->eedi2_begin_lock = malloc( sizeof( hb_lock_t * ) * 3 );
+        pv->eedi2_complete_lock = malloc( sizeof( hb_lock_t * ) * 3 );
+        pv->eedi2_arguments = malloc( sizeof( eedi2_arguments_t ) * 3 );
 
+        if( pv->post_processing > 1 )
+        {
+            pv->cx2 = (int*)eedi2_aligned_malloc(pv->height[0]*pv->ref_stride[0]*sizeof(int), 16);
+            pv->cy2 = (int*)eedi2_aligned_malloc(pv->height[0]*pv->ref_stride[0]*sizeof(int), 16);
+            pv->cxy = (int*)eedi2_aligned_malloc(pv->height[0]*pv->ref_stride[0]*sizeof(int), 16);
+            pv->tmpc = (int*)eedi2_aligned_malloc(pv->height[0]*pv->ref_stride[0]*sizeof(int), 16);
+            if( !pv->cx2 || !pv->cy2 || !pv->cxy || !pv->tmpc )
+                hb_log("EEDI2: failed to malloc derivative arrays");
+            else
+                hb_log("EEDI2: successfully mallloced derivative arrays");
+        }
+
+        for( i = 0; i < 3; i++ )
+        {
+            eedi2_thread_arg_t *eedi2_thread_args;
+
+            eedi2_thread_args = malloc( sizeof( eedi2_thread_arg_t ) );
+
+            if( eedi2_thread_args )
+            {
+                eedi2_thread_args->pv = pv;
+                eedi2_thread_args->plane = i;
+
+                pv->eedi2_begin_lock[i] = hb_lock_init();
+                pv->eedi2_complete_lock[i] = hb_lock_init();
+
+                /*
+                 * Important to start off with the threads locked waiting
+                 * on input.
+                 */
+                hb_lock( pv->eedi2_begin_lock[i] );
+
+                pv->eedi2_arguments[i].stop = 0;
+
+                pv->eedi2_threads[i] = hb_thread_init( "eedi2_filter_segment",
+                                                       eedi2_filter_thread,
+                                                       eedi2_thread_args,
+                                                       HB_NORMAL_PRIORITY );
+            }
+            else
+            {
+                hb_error( "eedi2 could not create threads" );
+            }
+        }
+    }
     
     
     /* Allocate mcdeint specific buffers */
@@ -1272,9 +1876,7 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
     {
         avcodec_init();
         avcodec_register_all();
-
         AVCodec * enc = avcodec_find_encoder( CODEC_ID_SNOW );
-
         int i;
         for (i = 0; i < 3; i++ )
         {
@@ -1301,7 +1903,7 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
                 case 3:
                     avctx_enc->refs = 3;
                 case 2:
-                    avctx_enc->me_method = ME_UMH;
+                    avctx_enc->me_method = ME_ITER;
                 case 1:
                     avctx_enc->flags |= CODEC_FLAG_4MV;
                     avctx_enc->dia_size =2;
@@ -1309,7 +1911,7 @@ hb_filter_private_t * hb_decomb_init( int pix_fmt,
                     avctx_enc->flags |= CODEC_FLAG_QPEL;
             }
 
-            avcodec_open(avctx_enc, enc);
+            hb_avcodec_open(avctx_enc, enc);
         }
 
         pv->mcdeint_frame       = avcodec_alloc_frame();
@@ -1327,7 +1929,7 @@ void hb_decomb_close( hb_filter_private_t * pv )
         return;
     }
     
-    hb_log("decomb: yadif deinterlaced %i | blend deinterlaced %i | unfiltered %i | total %i", pv->yadif_deinterlaced_frames, pv->blend_deinterlaced_frames, pv->unfiltered_frames, pv->yadif_deinterlaced_frames + pv->blend_deinterlaced_frames + pv->unfiltered_frames);
+    hb_log("decomb: deinterlaced %i | blended %i | unfiltered %i | total %i", pv->deinterlaced_frames, pv->blended_frames, pv->unfiltered_frames, pv->deinterlaced_frames + pv->blended_frames + pv->unfiltered_frames);
 
     /* Cleanup frame buffers */
     if( pv->buf_out[0] )
@@ -1366,6 +1968,46 @@ void hb_decomb_close( hb_filter_private_t * pv )
         }
     }
     
+    if( pv->mode & MODE_EEDI2 )
+    {
+        /* Cleanup eedi-half  buffers */
+        int j;
+        for( i = 0; i<3; i++ )
+        {
+            for( j = 0; j < 4; j++ )
+            {
+                uint8_t **p = &pv->eedi_half[j][i];
+                if (*p)
+                {
+                    free( *p - 3*pv->ref_stride[i] );
+                    *p = NULL;
+                }            
+            }
+        }
+
+        /* Cleanup eedi-full  buffers */
+        for( i = 0; i<3; i++ )
+        {
+            for( j = 0; j < 5; j++ )
+            {
+                uint8_t **p = &pv->eedi_full[j][i];
+                if (*p)
+                {
+                    free( *p - 3*pv->ref_stride[i] );
+                    *p = NULL;
+                }            
+            }
+        }
+    }
+    
+    if( pv->post_processing > 1  && ( pv->mode & MODE_EEDI2 ) )
+    {
+        if (pv->cx2) eedi2_aligned_free(pv->cx2);
+        if (pv->cy2) eedi2_aligned_free(pv->cy2);
+        if (pv->cxy) eedi2_aligned_free(pv->cxy);
+        if (pv->tmpc) eedi2_aligned_free(pv->tmpc);
+    }
+    
     for( i = 0; i < pv->cpu_count; i++)
     {
         /*
@@ -1408,12 +2050,36 @@ void hb_decomb_close( hb_filter_private_t * pv )
     free( pv->decomb_complete_lock );
     free( pv->decomb_arguments );
     
+    if( pv->mode & MODE_EEDI2 )
+    {
+        for( i = 0; i < 3; i++)
+        {
+            /*
+             * Tell each eedi2 thread to stop, and then cleanup.
+             */
+            pv->eedi2_arguments[i].stop = 1;
+            hb_unlock(  pv->eedi2_begin_lock[i] );
+
+            hb_thread_close( &pv->eedi2_threads[i] );
+            hb_lock_close( &pv->eedi2_begin_lock[i] );
+            hb_lock_close( &pv->eedi2_complete_lock[i] );
+        }
+
+        /*
+         * free memory for eedi2 structs
+         */
+        free( pv->eedi2_threads );
+        free( pv->eedi2_begin_lock );
+        free( pv->eedi2_complete_lock );
+        free( pv->eedi2_arguments );
+    }
+    
     /* Cleanup mcdeint specific buffers */
     if( pv->mcdeint_mode >= 0 )
     {
         if( pv->mcdeint_avctx_enc )
         {
-            avcodec_close( pv->mcdeint_avctx_enc );
+            hb_avcodec_close( pv->mcdeint_avctx_enc );
             av_freep( &pv->mcdeint_avctx_enc );
         }
         if( pv->mcdeint_outbuf )
@@ -1476,16 +2142,48 @@ int hb_decomb_work( const hb_buffer_t * cbuf_in,
 
     /* Perform yadif filtering */        
     int frame;
-    for( frame = 0; frame <= ( ( pv->mode == 2 || pv->mode == 3 )? 1 : 0 ) ; frame++ )
+    for( frame = 0; frame <= ( ( pv->mode & MODE_MCDEINT ) ? 1 : 0 ) ; frame++ )
+// This would be what to use for bobbing: for( frame = 0; frame <= 0 ; frame++ )
     {
+
+#if 0        
+        /* Perhaps skip the second run if the frame is uncombed? */
+        if( frame && !pv->yadif_arguments[0].is_combed )
+        {
+            break;
+        }
+#endif        
         int parity = frame ^ tff ^ 1;
 
+// This will be for bobbing
+#if 0
+        if( pv->alternator )
+        {
+            parity = !parity;
+            pv->alternator = 0;
+        }
+        else
+        {
+            pv->alternator = 1;
+        }
+#endif
+        pv->tff = !parity;
+
         avpicture_fill( &pv->pic_out, pv->buf_out[!(frame^1)]->data,
                         pix_fmt, width, height );
 
+        /* XXX
+            Should check here and only bother filtering field 2 when
+           field 1 was detected as combed.
+           And when it's not, it's a progressive frame,
+           so mcdeint should be skipped...
+        */
         yadif_filter( pv->pic_out.data, parity, tff, pv );
 
-        if( pv->mcdeint_mode >= 0 )
+        /* Commented out code in the line below would skip mcdeint
+           on uncombed frames. Possibly a bad idea, since mcdeint
+           maintains the same snow context for the entire video... */
+        if( pv->mcdeint_mode >= 0 /* && pv->yadif_arguments[0].is_combed */)
         {
             /* Perform mcdeint filtering */
             avpicture_fill( &pv->pic_in,  pv->buf_out[(frame^1)]->data,
diff --git a/libhb/decsrtsub.c b/libhb/decsrtsub.c
new file mode 100644 (file)
index 0000000..7f1602b
--- /dev/null
@@ -0,0 +1,568 @@
+/* 
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <iconv.h>
+#include <errno.h>
+#include "hb.h"
+
+struct start_and_end {
+    unsigned long start, end;
+};
+
+enum
+{
+    k_state_inEntry,
+    k_state_inEntry_or_new,
+    k_state_potential_new_entry,
+    k_state_timecode,
+};
+
+typedef struct srt_entry_s {
+    long offset, duration;
+    long start, stop;
+    char text[1024];
+    int  pos;
+} srt_entry_t;
+
+/*
+ * Store all context in the work private struct,
+ */
+struct hb_work_private_s
+{
+    hb_job_t * job;
+    FILE     * file;
+    char       buf[1024];
+    int        pos;
+    int        end;
+    char       utf8_buf[2048];
+    int        utf8_pos;
+    int        utf8_end;
+    unsigned long current_time;
+    unsigned long number_of_entries;
+    unsigned long last_entry_number;
+    unsigned long current_state;
+    srt_entry_t current_entry;
+    iconv_t *iconv_context;
+    hb_subtitle_t *subtitle;
+    uint64_t start_time;              // In HB time
+    uint64_t stop_time;               // In HB time
+};
+
+static int 
+read_time_from_string( const char* timeString, struct start_and_end *result )
+{
+    // for ex. 00:00:15,248 --> 00:00:16,545
+    
+    long houres1, minutes1, seconds1, milliseconds1,
+         houres2, minutes2, seconds2, milliseconds2;
+    int scanned;
+    
+    scanned = sscanf(timeString, "%ld:%ld:%ld,%ld --> %ld:%ld:%ld,%ld\n",
+                    &houres1, &minutes1, &seconds1, &milliseconds1,
+                    &houres2, &minutes2, &seconds2, &milliseconds2);
+    if (scanned != 8)
+    {
+        return 0;
+    }
+    result->start =
+        milliseconds1 + seconds1*1000 + minutes1*60*1000 + houres1*60*60*1000;
+    result->end =
+        milliseconds2 + seconds2*1000 + minutes2*60*1000 + houres2*60*60*1000;
+    return 1;
+}
+
+static int utf8_fill( hb_work_private_t * pv )
+{
+    int bytes, conversion = 0;
+    size_t out_size;
+
+    /* Align utf8 data to beginning of the buffer so that we can
+     * fill the buffer to its maximum */
+    memmove( pv->utf8_buf, pv->utf8_buf + pv->utf8_pos, pv->utf8_end - pv->utf8_pos );
+    pv->utf8_end -= pv->utf8_pos;
+    pv->utf8_pos = 0;
+    out_size = 2048 - pv->utf8_end;
+    while( out_size )
+    {
+        char *p, *q;
+        size_t in_size, retval;
+
+        if( pv->end == pv->pos )
+        {
+            bytes = fread( pv->buf, 1, 1024, pv->file );
+            pv->pos = 0;
+            pv->end = bytes;
+            if( bytes == 0 )
+            {
+                if( conversion )
+                    return 1;
+                else
+                    return 0;
+            }
+        }
+
+        p = pv->buf + pv->pos;
+        q = pv->utf8_buf + pv->utf8_end;
+        in_size = pv->end - pv->pos;
+
+        retval = iconv( pv->iconv_context, &p, &in_size, &q, &out_size);
+        if( q != pv->utf8_buf + pv->utf8_pos )
+            conversion = 1;
+
+        pv->utf8_end = q - pv->utf8_buf;
+        pv->pos = p - pv->buf;
+
+        if( ( retval == -1 ) && ( errno == EINVAL ) )
+        {
+            /* Incomplete multibyte sequence, read more data */
+            memmove( pv->buf, p, pv->end - pv->pos );
+            pv->end -= pv->pos;
+            pv->pos = 0;
+            bytes = fread( pv->buf + pv->end, 1, 1024 - pv->end, pv->file );
+            if( bytes == 0 )
+            {
+                if( !conversion )
+                    return 0;
+                else
+                    return 1;
+            }
+            pv->end += bytes;
+        } else if ( ( retval == -1 ) && ( errno == EILSEQ ) )
+        {
+            hb_error( "Invalid byte for codeset in input, discard byte" );
+            /* Try the next byte of the input */
+            pv->pos++;
+        } else if ( ( retval == -1 ) && ( errno == E2BIG ) )
+        {
+            /* buffer full */
+            return conversion;
+        }
+    }
+    return 1;
+}
+
+static int get_line( hb_work_private_t * pv, char *buf, int size )
+{
+    int i;
+    char c;
+
+    /* Find newline in converted UTF-8 buffer */
+    for( i = 0; i < size - 1; i++ )
+    {
+        if( pv->utf8_pos >= pv->utf8_end )
+        {
+            if( !utf8_fill( pv ) )
+            {
+                if( i )
+                    return 1;
+                else
+                    return 0;
+            }
+        }
+        c = pv->utf8_buf[pv->utf8_pos++];
+        if( c == '\n' )
+        {
+            buf[i] = '\n';
+            buf[i+1] = '\0';
+            return 1;
+        }
+        buf[i] = c;
+    }
+    buf[0] = '\0';
+    return 1;
+}
+
+/*
+ * Read the SRT file and put the entries into the subtitle fifo for all to read
+ */
+static hb_buffer_t *srt_read( hb_work_private_t *pv )
+{
+    char line_buffer[1024];
+    int reprocess = 0, resync = 0;
+
+    if( !pv->file )
+    {
+        return NULL;
+    }
+    
+    while( reprocess || get_line( pv, line_buffer, sizeof( line_buffer ) ) ) 
+    {
+        reprocess = 0;
+        switch (pv->current_state)
+        {
+        case k_state_timecode:
+        {
+            struct start_and_end timing;
+            int result;
+
+            result = read_time_from_string( line_buffer, &timing );
+            if (!result)
+            {
+                resync = 1;
+                pv->current_state = k_state_potential_new_entry;
+                continue;
+            }
+            pv->current_entry.duration = timing.end - timing.start;
+            pv->current_entry.offset = timing.start - pv->current_time;
+            
+            pv->current_time = timing.end;
+
+            pv->current_entry.start = timing.start;
+            pv->current_entry.stop = timing.end;
+
+            pv->current_state = k_state_inEntry;
+            continue;
+        }
+
+        case k_state_inEntry_or_new:
+        {
+            char *endpoint;
+            long entry_number;
+            /*
+             * Is this really new next entry begin?
+             */
+            entry_number = strtol(line_buffer, &endpoint, 10);
+            if (endpoint == line_buffer ||
+                (endpoint && *endpoint != '\n' && *endpoint != '\r'))
+            {
+                /*
+                 * Doesn't resemble an entry number
+                 * must still be in an entry
+                 */
+                if (!resync)
+                {
+                    reprocess = 1;
+                    pv->current_state = k_state_inEntry;
+                }
+                continue;
+            }
+            reprocess = 1;
+            pv->current_state = k_state_potential_new_entry;
+            break;
+        }
+
+        case k_state_inEntry:
+        {
+            char *q;
+            int  size, len;
+
+            // If the current line is empty, we assume this is the
+            // seperation betwene two entries. In case we are wrong,
+            // the mistake is corrected in the next state.
+            if (strcmp(line_buffer, "\n") == 0 || strcmp(line_buffer, "\r\n") == 0) {
+                pv->current_state = k_state_potential_new_entry;
+                continue;
+            }
+            
+            q = pv->current_entry.text + pv->current_entry.pos;
+            len = strlen( line_buffer );
+            size = MIN(1024 - pv->current_entry.pos - 1, len );
+            memcpy(q, line_buffer, size);
+            pv->current_entry.pos += size;
+            pv->current_entry.text[pv->current_entry.pos] = '\0';
+            break;
+        }
+
+        case k_state_potential_new_entry:
+        {
+            char *endpoint;
+            long entry_number;
+            hb_buffer_t *buffer = NULL;
+            /*
+             * Is this really new next entry begin?
+             */
+            entry_number = strtol(line_buffer, &endpoint, 10);
+            if (!resync && (*line_buffer == '\n' || *line_buffer == '\r'))
+            {
+                /*
+                 * Well.. looks like we are in the wrong mode.. lets add the
+                 * newline we misinterpreted...
+                 */
+                strncat(pv->current_entry.text, " ", 1024);
+                pv->current_state = k_state_inEntry_or_new;
+                continue;
+            }
+            if (endpoint == line_buffer ||
+                (endpoint && *endpoint != '\n' && *endpoint != '\r'))
+            {
+                /*
+                 * Well.. looks like we are in the wrong mode.. lets add the
+                 * line we misinterpreted...
+                 */
+                if (!resync)
+                {
+                    reprocess = 1;
+                    pv->current_state = k_state_inEntry;
+                }
+                continue;
+            }
+            /*
+             * We found the next entry - or a really rare error condition
+             */
+            pv->last_entry_number = entry_number;
+            resync = 0;
+            if( *pv->current_entry.text )
+            {
+                long length;
+                char *p, *q;
+                int  line = 1;
+                uint64_t start_time = ( pv->current_entry.start + 
+                                        pv->subtitle->config.offset ) * 90;
+                uint64_t stop_time = ( pv->current_entry.stop + 
+                                       pv->subtitle->config.offset ) * 90;
+
+                if( !( start_time > pv->start_time && stop_time < pv->stop_time ) )
+                {
+                    hb_deep_log( 3, "Discarding SRT at time start %"PRId64", stop %"PRId64, start_time, stop_time);
+                    memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+                    ++(pv->number_of_entries);
+                    pv->current_state = k_state_timecode;
+                    continue;
+                }
+
+                length = strlen( pv->current_entry.text );
+
+                for( q = p = pv->current_entry.text; *p; p++)
+                {
+                    if( *p == '\n' )
+                    {
+                        if ( line == 1 )
+                        {
+                            *q = *p;
+                            line = 2;
+                        }
+                        else
+                        {
+                            *q = ' ';
+                        }
+                        q++;
+                    }
+                    else if( *p != '\r' )
+                    {
+                        *q = *p;
+                        q++;
+                    }
+                    else
+                    {
+                        length--;
+                    }
+                }
+                *q = '\0';
+
+                buffer = hb_buffer_init( length + 1 );
+
+                if( buffer )
+                {
+                    buffer->start = start_time - pv->start_time;
+                    buffer->stop = stop_time - pv->start_time;
+
+                    memcpy( buffer->data, pv->current_entry.text, length + 1 );
+                }
+            }
+            memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+            ++(pv->number_of_entries);
+            pv->current_state = k_state_timecode;
+            if( buffer )
+            {
+                return buffer;
+            }
+            continue;
+        } 
+        }
+    }
+
+    hb_buffer_t *buffer = NULL;
+    if( *pv->current_entry.text )
+    {
+        long length;
+        char *p, *q;
+        int  line = 1;
+        uint64_t start_time = ( pv->current_entry.start + 
+                                pv->subtitle->config.offset ) * 90;
+        uint64_t stop_time = ( pv->current_entry.stop + 
+                               pv->subtitle->config.offset ) * 90;
+
+        if( !( start_time > pv->start_time && stop_time < pv->stop_time ) )
+        {
+            hb_deep_log( 3, "Discarding SRT at time start %"PRId64", stop %"PRId64, start_time, stop_time);
+            memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+            return NULL;
+        }
+
+        length = strlen( pv->current_entry.text );
+
+        for( q = p = pv->current_entry.text; *p; p++)
+        {
+            if( *p == '\n' )
+            {
+                if ( line == 1 )
+                {
+                    *q = *p;
+                    line = 2;
+                }
+                else
+                {
+                    *q = ' ';
+                }
+                q++;
+            }
+            else if( *p != '\r' )
+            {
+                *q = *p;
+                q++;
+            }
+            else
+            {
+                length--;
+            }
+        }
+        *q = '\0';
+
+        buffer = hb_buffer_init( length + 1 );
+
+        if( buffer )
+        {
+            buffer->start = start_time - pv->start_time;
+            buffer->stop = stop_time - pv->start_time;
+
+            memcpy( buffer->data, pv->current_entry.text, length + 1 );
+        }
+    }
+    memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+    if( buffer )
+    {
+        return buffer;
+    }
+    
+    return NULL;
+}
+
+static int decsrtInit( hb_work_object_t * w, hb_job_t * job )
+{
+    int retval = 1;
+    hb_work_private_t * pv;
+    hb_buffer_t *buffer;
+    int i;
+    hb_chapter_t * chapter;
+    hb_title_t *title = job->title;
+
+    pv = calloc( 1, sizeof( hb_work_private_t ) );
+    if( pv )
+    {
+        w->private_data = pv;
+
+        pv->job = job;
+
+        buffer = hb_buffer_init( 0 );
+        hb_fifo_push( w->fifo_in, buffer);
+        
+        pv->file = fopen( w->subtitle->config.src_filename, "r" );
+        
+        pv->current_state = k_state_potential_new_entry;
+        pv->number_of_entries = 0;
+        pv->last_entry_number = 0;
+        pv->current_time = 0;
+        pv->subtitle = w->subtitle;
+
+        /*
+         * Figure out the start and stop times from teh chapters being
+         * encoded - drop subtitle not in this range.
+         */
+        pv->start_time = 0;
+        for( i = 1; i < job->chapter_start; ++i )
+        {
+            chapter = hb_list_item( title->list_chapter, i - 1 );
+            if( chapter )
+            {
+                pv->start_time += chapter->duration;
+            } else {
+                hb_error( "Could not locate chapter %d for SRT start time", i );
+                retval = 0;
+            }
+        }
+        pv->stop_time = pv->start_time;
+        for( i = job->chapter_start; i <= job->chapter_end; ++i )
+        {
+            chapter = hb_list_item( title->list_chapter, i - 1 );
+            if( chapter )
+            {
+                pv->stop_time += chapter->duration;
+            } else {
+                hb_error( "Could not locate chapter %d for SRT start time", i );
+                retval = 0;
+            }
+        }
+
+        hb_deep_log( 3, "SRT Start time %"PRId64", stop time %"PRId64, pv->start_time, pv->stop_time);
+
+        pv->iconv_context = iconv_open( "utf-8", pv->subtitle->config.src_codeset );
+
+
+        if( pv->iconv_context == (iconv_t) -1 )
+        {
+            hb_error("Could not open the iconv library with those file formats\n");
+
+        } else {
+            memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+            
+            pv->file = fopen( w->subtitle->config.src_filename, "r" );
+            
+            if( !pv->file )
+            {
+                hb_error("Could not open the SRT subtitle file '%s'\n", 
+                         w->subtitle->config.src_filename);
+            } else {
+                retval = 0;
+            }
+        }
+    } 
+
+    return retval;
+}
+
+static int decsrtWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+                       hb_buffer_t ** buf_out )
+{
+    hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
+    hb_buffer_t * out = NULL;
+
+    out = srt_read( pv );
+
+    if( out )
+    {
+        /*
+         * Keep a buffer in our input fifo so that we get run.
+         */
+        hb_fifo_push( w->fifo_in, in);
+        *buf_in = NULL;
+        *buf_out = out;
+    } else {
+        *buf_out = NULL;
+        return HB_WORK_OK;
+    }
+
+    return HB_WORK_OK;  
+}
+
+static void decsrtClose( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+    fclose( pv->file );
+    iconv_close(pv->iconv_context);
+    free( w->private_data );
+}
+
+hb_work_object_t hb_decsrtsub =
+{
+    WORK_DECSRTSUB,
+    "SRT Subtitle Decoder",
+    decsrtInit,
+    decsrtWork,
+    decsrtClose
+};
diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c
new file mode 100644 (file)
index 0000000..c4474f9
--- /dev/null
@@ -0,0 +1,583 @@
+/* $Id: decsub.c,v 1.12 2005/04/14 17:37:54 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include "hb.h"
+
+struct hb_work_private_s
+{
+    hb_job_t    * job;
+
+    hb_buffer_t * buf;
+    int           size_sub;
+    int           size_got;
+    int           size_rle;
+    int64_t       pts;
+    int64_t       pts_start;
+    int64_t       pts_stop;
+    int           pts_forced;
+    int           x;
+    int           y;
+    int           width;
+    int           height;
+    int           stream_id;
+
+    int           offsets[2];
+    uint8_t       lum[4];
+    uint8_t       chromaU[4];
+    uint8_t       chromaV[4];
+    uint8_t       alpha[4];
+};
+
+static hb_buffer_t * Decode( hb_work_object_t * );
+
+int decsubInit( hb_work_object_t * w, hb_job_t * job )
+{
+    hb_work_private_t * pv;
+
+    pv              = calloc( 1, sizeof( hb_work_private_t ) );
+    w->private_data = pv;
+
+    pv->job = job;
+    pv->pts = -1;
+
+    return 0;
+}
+
+int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+                hb_buffer_t ** buf_out )
+{
+    hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
+    int size_sub, size_rle;
+
+    if ( in->size <= 0 )
+    {
+        /* EOF on input stream - send it downstream & say that we're done */
+        *buf_out = in;
+        *buf_in = NULL;
+        return HB_WORK_DONE;
+    }
+
+    pv->stream_id = in->id;
+
+    size_sub = ( in->data[0] << 8 ) | in->data[1];
+    size_rle = ( in->data[2] << 8 ) | in->data[3];
+
+    if( !pv->size_sub )
+    {
+        /* We are looking for the start of a new subtitle */
+        if( size_sub && size_rle && size_sub > size_rle &&
+            in->size <= size_sub )
+        {
+            /* Looks all right so far */
+            pv->size_sub = size_sub;
+            pv->size_rle = size_rle;
+
+            pv->buf      = hb_buffer_init( 0xFFFF );
+            memcpy( pv->buf->data, in->data, in->size );
+            pv->buf->id = in->id;
+            pv->buf->sequence = in->sequence;
+            pv->size_got = in->size;
+            pv->pts      = in->start;
+        }
+    }
+    else
+    {
+        /* We are waiting for the end of the current subtitle */
+        if( in->size <= pv->size_sub - pv->size_got )
+        {
+            memcpy( pv->buf->data + pv->size_got, in->data, in->size );
+            pv->buf->id = in->id;
+            pv->buf->sequence = in->sequence;
+            pv->size_got += in->size;
+            if( in->start >= 0 )
+            {
+                pv->pts = in->start;
+            }
+        }
+        else
+        {
+            // bad size, must have lost sync
+            // force re-sync
+            if ( pv->buf != NULL )
+                hb_buffer_close( &pv->buf );
+            pv->size_sub = 0;
+        }
+
+    }
+
+    *buf_out = NULL;
+
+    if( pv->size_sub && pv->size_sub == pv->size_got )
+    {
+        pv->buf->size = pv->size_sub;
+
+        /* We got a complete subtitle, decode it */
+        *buf_out = Decode( w );
+
+        if( buf_out && *buf_out )
+        {
+            (*buf_out)->id = in->id;
+            (*buf_out)->sequence = in->sequence;
+        }
+
+        /* Wait for the next one */
+        pv->size_sub = 0;
+        pv->size_got = 0;
+        pv->size_rle = 0;
+        pv->pts      = -1;
+    }
+
+    return HB_WORK_OK;
+}
+
+void decsubClose( hb_work_object_t * w )
+{
+    free( w->private_data );
+}
+
+hb_work_object_t hb_decvobsub =
+{
+    WORK_DECVOBSUB,
+    "VOBSUB decoder",
+    decsubInit,
+    decsubWork,
+    decsubClose
+};
+
+
+/***********************************************************************
+ * ParseControls
+ ***********************************************************************
+ * Get the start and end dates (relative to the PTS from the PES
+ * header), the width and height of the subpicture and the colors and
+ * alphas used in it
+ **********************************************************************/
+static void ParseControls( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+    hb_job_t * job = pv->job;
+    hb_title_t * title = job->title;
+    hb_subtitle_t * subtitle;
+    uint8_t * buf = pv->buf->data;
+
+    int i, n;
+    int command;
+    int date, next;
+
+    pv->pts_start = 0;
+    pv->pts_stop  = 0;
+    pv->pts_forced  = 0;
+
+    pv->alpha[3] = 0;
+    pv->alpha[2] = 0;
+    pv->alpha[1] = 0;
+    pv->alpha[0] = 0;
+
+    for( i = pv->size_rle; ; )
+    {
+        date = ( buf[i] << 8 ) | buf[i+1]; i += 2;
+        next = ( buf[i] << 8 ) | buf[i+1]; i += 2;
+
+        for( ;; )
+        {
+            command = buf[i++];
+
+            /*
+             * There are eight commands available for
+             * Sub-Pictures. The first SP_DCSQ should contain, as a
+             * minimum, SET_COLOR, SET_CONTR, SET_DAREA, and
+             * SET_DSPXA
+             */
+
+            if( command == 0xFF ) // 0xFF - CMD_END - ends one SP_DCSQ
+            {
+                break;
+            }
+
+            switch( command )
+            {
+                case 0x00: // 0x00 - FSTA_DSP - Forced Start Display, no arguments
+                    pv->pts_start = pv->pts + date * 900;
+                    pv->pts_forced = 1;
+
+                    /*
+                     * If we are doing a subtitle scan then note down
+                     */
+                    if( job->indepth_scan )
+                    {
+                        for( n=0; n < hb_list_count(title->list_subtitle); n++ )
+                        {
+                            subtitle = hb_list_item( title->list_subtitle, n);
+                            if( pv->stream_id == subtitle->id ) {
+                                /*
+                                 * A hit, count it.
+                                 */
+                                subtitle->forced_hits++;
+                            }
+                        }
+                    }
+                    break;
+
+                case 0x01: // 0x01 - STA_DSP - Start Display, no arguments
+                    pv->pts_start = pv->pts + date * 900;
+                    pv->pts_forced  = 0;
+                    break;
+
+                case 0x02: // 0x02 - STP_DSP - Stop Display, no arguments
+                    if(!pv->pts_stop)
+                        pv->pts_stop = pv->pts + date * 900;
+                    break;
+
+                case 0x03: // 0x03 - SET_COLOR - Set Colour indices
+                {
+                    /*
+                     * SET_COLOR - provides four indices into the CLUT
+                     * for the current PGC to associate with the four
+                     * pixel values
+                     */
+                    int colors[4];
+                    int j;
+
+                    colors[0] = (buf[i+0]>>4)&0x0f;
+                    colors[1] = (buf[i+0])&0x0f;
+                    colors[2] = (buf[i+1]>>4)&0x0f;
+                    colors[3] = (buf[i+1])&0x0f;
+
+                    for( j = 0; j < 4; j++ )
+                    {
+                        /*
+                         * Not sure what is happening here, in theory
+                         * the palette is in YCbCr. And we want YUV.
+                         *
+                         * However it looks more like YCrCb (according
+                         * to pgcedit). And the scalers for YCrCb don't
+                         * work, but I get the right colours by doing
+                         * no conversion.
+                         */
+                        uint32_t color = title->palette[colors[j]];
+                        uint8_t Cr, Cb, y;
+                        y = (color>>16) & 0xff;
+                        Cr = (color>>8) & 0xff;
+                        Cb = (color) & 0xff;
+                        pv->lum[3-j] = y;
+                        pv->chromaU[3-j] = Cb;
+                        pv->chromaV[3-j] = Cr;
+                        /* hb_log("color[%d] y = %d, u = %d, v = %d",
+                               3-j,
+                               pv->lum[3-j],
+                               pv->chromaU[3-j],
+                               pv->chromaV[3-j]);
+                        */
+                    }
+                    i += 2;
+                    break;
+                }
+                case 0x04: // 0x04 - SET_CONTR - Set Contrast
+                {
+                    /*
+                     * SET_CONTR - directly provides the four contrast
+                     * (alpha blend) values to associate with the four
+                     * pixel values
+                     */
+                    uint8_t    alpha[4];
+
+                    alpha[3] = (buf[i+0]>>4)&0x0f;
+                    alpha[2] = (buf[i+0])&0x0f;
+                    alpha[1] = (buf[i+1]>>4)&0x0f;
+                    alpha[0] = (buf[i+1])&0x0f;
+
+
+                    int lastAlpha = pv->alpha[3] + pv->alpha[2] + pv->alpha[1] + pv->alpha[0];
+                    int currAlpha = alpha[3] + alpha[2] + alpha[1] + alpha[0];
+
+                    // fading-in, save the highest alpha value
+                    if( currAlpha > lastAlpha )
+                    {
+                        pv->alpha[3] = alpha[3];
+                        pv->alpha[2] = alpha[2];
+                        pv->alpha[1] = alpha[1];
+                        pv->alpha[0] = alpha[0];
+                    }
+
+                    // fading-out
+                    if( currAlpha < lastAlpha && !pv->pts_stop )
+                    {
+                        pv->pts_stop = pv->pts + date * 900;
+                    }
+
+                    i += 2;
+                    break;
+                }
+                case 0x05: // 0x05 - SET_DAREA - defines the display area
+                {
+                    pv->x     = (buf[i+0]<<4) | ((buf[i+1]>>4)&0x0f);
+                    pv->width = (((buf[i+1]&0x0f)<<8)| buf[i+2]) - pv->x + 1;
+                    pv->y     = (buf[i+3]<<4)| ((buf[i+4]>>4)&0x0f);
+                    pv->height = (((buf[i+4]&0x0f)<<8)| buf[i+5]) - pv->y + 1;
+                    i += 6;
+                    break;
+                }
+                case 0x06: // 0x06 - SET_DSPXA - defines the pixel data addresses
+                {
+                    pv->offsets[0] = ( buf[i] << 8 ) | buf[i+1]; i += 2;
+                    pv->offsets[1] = ( buf[i] << 8 ) | buf[i+1]; i += 2;
+                    break;
+                }
+            }
+        }
+
+
+
+        if( i > next )
+        {
+            break;
+        }
+        i = next;
+    }
+
+    if( !pv->pts_stop )
+    {
+        /* Show it for 3 seconds */
+        pv->pts_stop = pv->pts_start + 3 * 90000;
+    }
+}
+
+/***********************************************************************
+ * CropSubtitle
+ ***********************************************************************
+ * Given a raw decoded subtitle, detects transparent borders and
+ * returns a cropped subtitle in a hb_buffer_t ready to be used by
+ * the renderer, or NULL if the subtitle was completely transparent
+ **********************************************************************/
+static int LineIsTransparent( hb_work_object_t * w, uint8_t * p )
+{
+    hb_work_private_t * pv = w->private_data;
+    int i;
+    for( i = 0; i < pv->width; i++ )
+    {
+        if( p[i] )
+        {
+            return 0;
+        }
+    }
+    return 1;
+}
+static int ColumnIsTransparent( hb_work_object_t * w, uint8_t * p )
+{
+    hb_work_private_t * pv = w->private_data;
+    int i;
+    for( i = 0; i < pv->height; i++ )
+    {
+        if( p[i*pv->width] )
+        {
+            return 0;
+        }
+    }
+    return 1;
+}
+static hb_buffer_t * CropSubtitle( hb_work_object_t * w, uint8_t * raw )
+{
+    hb_work_private_t * pv = w->private_data;
+    int i;
+    int crop[4] = { -1,-1,-1,-1 };
+    uint8_t * alpha;
+    int realwidth, realheight;
+    hb_buffer_t * buf;
+    uint8_t * lum_in, * lum_out, * alpha_in, * alpha_out;
+    uint8_t * u_in, * u_out, * v_in, * v_out;
+
+    alpha = raw + pv->width * pv->height;
+
+    /* Top */
+    for( i = 0; i < pv->height; i++ )
+    {
+        if( !LineIsTransparent( w, &alpha[i*pv->width] ) )
+        {
+            crop[0] = i;
+            break;
+        }
+    }
+
+    if( crop[0] < 0 )
+    {
+        /* Empty subtitle */
+        return NULL;
+    }
+
+    /* Bottom */
+    for( i = pv->height - 1; i >= 0; i-- )
+    {
+        if( !LineIsTransparent( w, &alpha[i*pv->width] ) )
+        {
+            crop[1] = i;
+            break;
+        }
+    }
+
+    /* Left */
+    for( i = 0; i < pv->width; i++ )
+    {
+        if( !ColumnIsTransparent( w, &alpha[i] ) )
+        {
+            crop[2] = i;
+            break;
+        }
+    }
+
+    /* Right */
+    for( i = pv->width - 1; i >= 0; i-- )
+    {
+        if( !ColumnIsTransparent( w, &alpha[i] ) )
+        {
+            crop[3] = i;
+            break;
+        }
+    }
+
+    realwidth  = crop[3] - crop[2] + 1;
+    realheight = crop[1] - crop[0] + 1;
+
+    buf         = hb_buffer_init( realwidth * realheight * 4 );
+    buf->start  = pv->pts_start;
+    buf->stop   = pv->pts_stop;
+    buf->x      = pv->x + crop[2];
+    buf->y      = pv->y + crop[0];
+    buf->width  = realwidth;
+    buf->height = realheight;
+
+    lum_in    = raw + crop[0] * pv->width + crop[2];
+    alpha_in  = lum_in + pv->width * pv->height;
+    u_in      = alpha_in + pv->width * pv->height;
+    v_in      = u_in + pv->width * pv->height;
+
+    lum_out   = buf->data;
+    alpha_out = lum_out + realwidth * realheight;
+    u_out     = alpha_out + realwidth * realheight;
+    v_out     = u_out + realwidth * realheight;
+
+    for( i = 0; i < realheight; i++ )
+    {
+        memcpy( lum_out, lum_in, realwidth );
+        memcpy( alpha_out, alpha_in, realwidth );
+        memcpy( u_out, u_in, realwidth );
+        memcpy( v_out, v_in, realwidth );
+
+        lum_in    += pv->width;
+        alpha_in  += pv->width;
+        u_in      += pv->width;
+        v_in      += pv->width;
+
+        lum_out   += realwidth;
+        alpha_out += realwidth;
+        u_out     += realwidth;
+        v_out     += realwidth;
+    }
+
+    return buf;
+}
+
+static hb_buffer_t * Decode( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+    int code, line, col;
+    int offsets[2];
+    int * offset;
+    hb_buffer_t * buf;
+    uint8_t * buf_raw = NULL;
+    hb_job_t * job = pv->job;
+
+    /* Get infos about the subtitle */
+    ParseControls( w );
+
+    if( job->indepth_scan || ( w->subtitle->config.force && pv->pts_forced == 0 ) )
+    {
+        /*
+         * Don't encode subtitles when doing a scan.
+         *
+         * When forcing subtitles, ignore all those that don't
+         * have the forced flag set.
+         */
+        return NULL;
+    }
+
+    if (w->subtitle->config.dest == PASSTHRUSUB)
+    {
+        pv->buf->start  = pv->pts_start;
+        pv->buf->stop   = pv->pts_stop;
+        return pv->buf;
+    }
+
+    /* Do the actual decoding now */
+    buf_raw = malloc( ( pv->width * pv->height ) * 4 );
+
+#define GET_NEXT_NIBBLE code = ( code << 4 ) | ( ( ( *offset & 1 ) ? \
+( pv->buf->data[((*offset)>>1)] & 0xF ) : ( pv->buf->data[((*offset)>>1)] >> 4 ) ) ); \
+(*offset)++
+
+    offsets[0] = pv->offsets[0] * 2;
+    offsets[1] = pv->offsets[1] * 2;
+
+    for( line = 0; line < pv->height; line++ )
+    {
+        /* Select even or odd field */
+        offset = ( line & 1 ) ? &offsets[1] : &offsets[0];
+
+        for( col = 0; col < pv->width; col += code >> 2 )
+        {
+            uint8_t * lum, * alpha,  * chromaU, * chromaV;
+
+            code = 0;
+            GET_NEXT_NIBBLE;
+            if( code < 0x4 )
+            {
+                GET_NEXT_NIBBLE;
+                if( code < 0x10 )
+                {
+                    GET_NEXT_NIBBLE;
+                    if( code < 0x40 )
+                    {
+                        GET_NEXT_NIBBLE;
+                        if( code < 0x100 )
+                        {
+                            /* End of line */
+                            code |= ( pv->width - col ) << 2;
+                        }
+                    }
+                }
+            }
+
+            lum   = buf_raw;
+            alpha = lum + pv->width * pv->height;
+            chromaU = alpha + pv->width * pv->height;
+            chromaV = chromaU + pv->width * pv->height;
+
+            memset( lum + line * pv->width + col,
+                    pv->lum[code & 3], code >> 2 );
+            memset( alpha + line * pv->width + col,
+                    pv->alpha[code & 3], code >> 2 );
+            memset( chromaU + line * pv->width + col,
+                    pv->chromaU[code & 3], code >> 2 );
+            memset( chromaV + line * pv->width + col,
+                    pv->chromaV[code & 3], code >> 2 );
+        }
+
+        /* Byte-align */
+        if( *offset & 1 )
+        {
+            (*offset)++;
+        }
+    }
+
+    hb_buffer_close( &pv->buf );
+
+    /* Crop subtitle (remove transparent borders) */
+    buf = CropSubtitle( w, buf_raw );
+
+    free( buf_raw );
+
+    return buf;
+}
index b6b10fe..78856dd 100644 (file)
@@ -17,7 +17,7 @@
 */
 
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
 
 #define SUPPRESS_AV_LOG
@@ -653,7 +653,7 @@ hb_filter_private_t * hb_deinterlace_init( int pix_fmt,
                     avctx_enc->flags |= CODEC_FLAG_QPEL;
             }
 
-            avcodec_open(avctx_enc, enc);
+            hb_avcodec_open(avctx_enc, enc);
         }
 
         pv->mcdeint_frame       = avcodec_alloc_frame();
@@ -726,7 +726,7 @@ void hb_deinterlace_close( hb_filter_private_t * pv )
     {
         if( pv->mcdeint_avctx_enc )
         {
-            avcodec_close( pv->mcdeint_avctx_enc );
+            hb_avcodec_close( pv->mcdeint_avctx_enc );
             av_freep( &pv->mcdeint_avctx_enc );
         }
         if( pv->mcdeint_outbuf )
index b92a8de..afeda30 100644 (file)
@@ -6,6 +6,44 @@
 
 #include "hb.h"
 
+static inline void check_mpeg_scr( hb_psdemux_t *state, int64_t scr, int tol )
+{
+    /*
+     * This section of code implements the timing model of
+     * the "Standard Target Decoder" (STD) of the MPEG2 standard
+     * (specified in ISO 13818-1 sections 2.4.2, 2.5.2 & Annex D).
+     * The STD removes and corrects for clock discontinuities so
+     * that the time stamps on the video, audio & other media
+     * streams can be used for cross-media synchronization. To do
+     * this the STD has its own timestamp value, the System Clock
+     * Reference or SCR, in the PACK header. Clock discontinuities
+     * are detected using the SCR & and the adjustment needed
+     * to correct post-discontinuity timestamps to be contiguous
+     * with pre-discontinuity timestamps is computed from pre- and
+     * post-discontinuity values of the SCR. Then this adjustment
+     * is applied to every media timestamp (PTS).
+     *
+     * ISO 13818-1 says there must be an SCR at least every 700ms
+     * (100ms for Transport Streams) so if the difference between
+     * this SCR & the previous is >700ms it's a discontinuity.
+     * If the difference is negative it's non-physical (time doesn't
+     * go backward) and must also be a discontinuity. When we find a
+     * discontinuity we adjust the scr_offset so that the SCR of the
+     * new packet lines up with that of the previous packet.
+     */
+
+    // we declare a discontinuity if there's a gap of more than
+    // 'tol'ms between the last scr & this or if this scr goes back
+    // by more than half a frame time.
+    int64_t scr_delta = scr - state->last_scr;
+    if ( scr_delta > 90*tol || scr_delta < -90*10 )
+    {
+        ++state->scr_changes;
+        state->last_pts = -1;
+    }
+    state->last_scr = scr;
+}
+
 /* Basic MPEG demuxer */
 
 int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state )
@@ -27,29 +65,6 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
 
     if ( state )
     {
-        /*
-         * This section of code implements the timing model of
-         * the "Standard Target Decoder" (STD) of the MPEG2 standard
-         * (specified in ISO 13818-1 sections 2.4.2, 2.5.2 & Annex D).
-         * The STD removes and corrects for clock discontinuities so
-         * that the time stamps on the video, audio & other media
-         * streams can be used for cross-media synchronization. To do
-         * this the STD has its own timestamp value, the System Clock
-         * Reference or SCR, in the PACK header. Clock discontinuities
-         * are detected using the SCR & and the adjustment needed
-         * to correct post-discontinuity timestamps to be contiguous
-         * with pre-discontinuity timestamps is computed from pre- and
-         * post-discontinuity values of the SCR. Then this adjustment
-         * is applied to every media timestamp (PTS).
-         *
-         * ISO 13818-1 says there must be an SCR at least every 700ms
-         * (100ms for Transport Streams) so if the difference between
-         * this SCR & the previous is >700ms it's a discontinuity.
-         * If the difference is negative it's non-physical (time doesn't
-         * go backward) and must also be a discontinuity. When we find a
-         * discontinuity we adjust the scr_offset so that the SCR of the
-         * new packet lines up with that of the previous packet.
-         */
         /* extract the system clock reference (scr) */
         int64_t scr = ((uint64_t)(d[pos] & 0x38) << 27) |
                       ((uint64_t)(d[pos] & 0x03) << 28) |
@@ -58,15 +73,7 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
                       ((uint64_t)(d[pos+2] & 3) << 13) |
                       ((uint64_t)(d[pos+3]) << 5) |
                       (d[pos+4] >> 3);
-        // we declare a discontinuity if there's a gap of more than
-        // 100ms between the last scr & this or if this scr goes back
-        // by more than half a frame time.
-        int64_t scr_delta = scr - state->last_scr;
-        if ( scr_delta > 90*100 || scr_delta < -90*10 )
-        {
-            ++state->scr_changes;
-        }
-        state->last_scr = scr;
+        check_mpeg_scr( state, scr, 300 );
     }
 
     pos += 9;                    /* pack_header */
@@ -137,26 +144,6 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
             {
                 dts = pts;
             }
-            if ( state && state->flaky_clock )
-            {
-                // Program streams have an SCR in every PACK header so they
-                // can't lose their clock reference. But the PCR in Transport
-                // streams is typically on <.1% of the packets. If a PCR
-                // packet gets lost and it marks a clock discontinuity then
-                // the data following it will be referenced to the wrong
-                // clock & introduce huge gaps or throw our A/V sync off.
-                // We try to protect against that here by sanity checking
-                // timestamps against the current reference clock and discarding
-                // packets where the DTS is "too far" from its clock.
-                int64_t fdelta = dts - state->last_scr;
-                if ( fdelta < -300 * 90000LL || fdelta > 300 * 90000LL )
-                {
-                    // packet too far behind or ahead of its clock reference
-                    ++state->dts_drops;
-                    pos = pes_packet_end;
-                    continue;
-                }
-            }
         }
 
         pos = pes_header_end;
@@ -206,6 +193,64 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
     return 1;
 }
 
+// mpeg transport stream demuxer. the elementary stream headers have been
+// stripped off and buf_ps has all the info gleaned from them: id is set,
+// start contains the pts (if any), renderOffset contains the dts (if any)
+// and stop contains the pcr (if it changed).
+int hb_demux_ts( hb_buffer_t *buf_ps, hb_list_t *list_es, hb_psdemux_t *state )
+{
+    if ( state )
+    {
+        // we're keeping track of timing (i.e., not in scan)
+        // check if there's a new pcr in this packet
+        if ( buf_ps->stop >= 0 )
+        {
+            // we have a new pcr
+            check_mpeg_scr( state, buf_ps->stop, 300 );
+            buf_ps->stop = -1;
+        }
+        if ( buf_ps->start >= 0 )
+        {
+            // Program streams have an SCR in every PACK header so they
+            // can't lose their clock reference. But the PCR in Transport
+            // streams is typically on <.1% of the packets. If a PCR
+            // packet gets lost and it marks a clock discontinuity then
+            // the data following it will be referenced to the wrong
+            // clock & introduce huge gaps or throw our A/V sync off.
+            // We try to protect against that here by sanity checking
+            // timestamps against the current reference clock and discarding
+            // packets where the DTS is "too far" from its clock.
+            int64_t fdelta = buf_ps->start - state->last_scr;
+            if ( fdelta < -300 * 90000LL || fdelta > 300 * 90000LL )
+            {
+                // packet too far behind or ahead of its clock reference
+                ++state->dts_drops;
+                return 1;
+            }
+            if ( state->last_pts >= 0 )
+            {
+                fdelta = buf_ps->start - state->last_pts;
+                if ( fdelta < -5 * 90000LL || fdelta > 5 * 90000LL )
+                {
+                    // Packet too far from last. This may be a NZ TV broadcast
+                    // as they like to change the PCR without sending a PCR
+                    // update. Since it may be a while until they actually tell
+                    // us the new PCR use the PTS as the PCR.
+                    ++state->scr_changes;
+                    state->last_scr = buf_ps->start;
+                }
+            }
+            state->last_pts = buf_ps->start;
+        }
+    }
+
+    hb_buffer_t *buf = hb_buffer_init( buf_ps->alloc );
+    hb_buffer_swap_copy( buf_ps, buf );
+    hb_list_add( list_es, buf );
+
+    return 1;
+}
+
 // "null" demuxer (makes a copy of input buf & returns it in list)
 // used when the reader for some format includes its own demuxer.
 // for example, ffmpeg.
@@ -219,17 +264,11 @@ int hb_demux_null( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* stat
         state->last_scr = buf_ps->start >= 0 ? buf_ps->start : buf_ps->renderOffset;
     }
 
-    hb_buffer_t *buf = hb_buffer_init( buf_ps->size );
-
-    // copy everything from the old to the new except the data ptr & alloc
-    uint8_t *data = buf->data;
-    int alloc = buf->alloc;
-    *buf = *buf_ps;
-    buf->data = data;
-    buf->alloc = alloc;
-
-    // now copy the data
-    memcpy( buf->data, buf_ps->data, buf_ps->size );
+    hb_buffer_t *buf = hb_buffer_init( buf_ps->alloc );
+    hb_buffer_swap_copy( buf_ps, buf );
     hb_list_add( list_es, buf );
+
     return 1;
 }
+
+const hb_muxer_t hb_demux[] = { hb_demux_ps, hb_demux_ts, hb_demux_null };
index 3913912..26e2535 100644 (file)
@@ -17,7 +17,7 @@
 */
 
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
 
 #define HQDN3D_SPATIAL_LUMA_DEFAULT    4.0f
index 92d279d..2021038 100644 (file)
@@ -1,5 +1,5 @@
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 #include "mpeg2dec/mpeg2.h"
 
 /*
@@ -60,6 +60,7 @@ struct pullup_context
     int metric_plane;
     int strict_breaks;
     int strict_pairs;
+    int parity;
     /* Internal data */
     struct pullup_field *first, *last, *head;
     struct pullup_buffer *buffers;
@@ -838,16 +839,18 @@ hb_filter_private_t * hb_detelecine_init( int pix_fmt,
     ctx->junk_top  = ctx->junk_bottom = 4;
     ctx->strict_breaks = -1;
     ctx->metric_plane  = 0;
-
+    ctx->parity = -1;
+    
     if( settings )
     {
-        sscanf( settings, "%d:%d:%d:%d:%d:%d",
+        sscanf( settings, "%d:%d:%d:%d:%d:%d:%d",
                 &ctx->junk_left,
                 &ctx->junk_right,
                 &ctx->junk_top,
                 &ctx->junk_bottom,
                 &ctx->strict_breaks,
-                &ctx->metric_plane );
+                &ctx->metric_plane,
+                &ctx->parity );
     }
 
     ctx->format = PULLUP_FMT_Y;
@@ -947,12 +950,25 @@ int hb_detelecine_work( const hb_buffer_t * buf_in,
     memcpy( buf->planes[2], pv->pic_in.data[2],
             pv->width[2] * pv->height[2] * sizeof(uint8_t) );
 
-    /* Submit buffer fields based on buffer flags */
+    /* Submit buffer fields based on buffer flags.
+       Detelecine assumes BFF when the TFF flag isn't present. */
     int parity = 1;
     if( buf_in->flags & PIC_FLAG_TOP_FIELD_FIRST )
     {
+        /* Source signals TFF */
         parity = 0;
     }
+    else if( ctx->parity == 0 )
+    {
+        /* Many non-MPEG-2 sources lack parity flags even though
+           they are TFF, so this allow users to override. */
+        parity = 0;
+    }
+    if( ctx->parity == 1 )
+    {
+        /* Override autodetected parity with BFF */
+        parity = 1;
+    }
     pullup_submit_field( ctx, buf, parity );
     pullup_submit_field( ctx, buf, parity^1 );
     if( buf_in->flags & PIC_FLAG_REPEAT_FIRST_FIELD )
index 85fe47e..fa5373e 100644 (file)
@@ -6,47 +6,56 @@
 
 #include "hb.h"
 #include "lang.h"
+#include "dvd.h"
 
 #include "dvdread/ifo_read.h"
+#include "dvdread/ifo_print.h"
 #include "dvdread/nav_read.h"
 
-struct hb_dvd_s
+static hb_dvd_t    * hb_dvdread_init( char * path );
+static void          hb_dvdread_close( hb_dvd_t ** _d );
+static char        * hb_dvdread_name( char * path );
+static int           hb_dvdread_title_count( hb_dvd_t * d );
+static hb_title_t  * hb_dvdread_title_scan( hb_dvd_t * d, int t );
+static int           hb_dvdread_start( hb_dvd_t * d, hb_title_t *title, int chapter );
+static void          hb_dvdread_stop( hb_dvd_t * d );
+static int           hb_dvdread_seek( hb_dvd_t * d, float f );
+static int           hb_dvdread_read( hb_dvd_t * d, hb_buffer_t * b );
+static int           hb_dvdread_chapter( hb_dvd_t * d );
+static int           hb_dvdread_angle_count( hb_dvd_t * d );
+static void          hb_dvdread_set_angle( hb_dvd_t * d, int angle );
+
+hb_dvd_func_t hb_dvdread_func =
 {
-    char         * path;
-
-    dvd_reader_t * reader;
-    ifo_handle_t * vmg;
-
-    int            vts;
-    int            ttn;
-    ifo_handle_t * ifo;
-    dvd_file_t   * file;
-
-    pgc_t        * pgc;
-    int            cell_start;
-    int            cell_end;
-    int            title_start;
-    int            title_end;
-    int            title_block_count;
-    int            cell_cur;
-    int            cell_next;
-    int            cell_overlap;
-    int            block;
-    int            pack_len;
-    int            next_vobu;
-    int            in_cell;
-    int            in_sync;
-    uint16_t       cur_vob_id;
-    uint8_t        cur_cell_id;
+    hb_dvdread_init,
+    hb_dvdread_close,
+    hb_dvdread_name,
+    hb_dvdread_title_count,
+    hb_dvdread_title_scan,
+    hb_dvdread_start,
+    hb_dvdread_stop,
+    hb_dvdread_seek,
+    hb_dvdread_read,
+    hb_dvdread_chapter,
+    hb_dvdread_angle_count,
+    hb_dvdread_set_angle
 };
 
+static hb_dvd_func_t *dvd_methods = &hb_dvdread_func;
+
 /***********************************************************************
  * Local prototypes
  **********************************************************************/
-static void FindNextCell( hb_dvd_t * );
+static void FindNextCell( hb_dvdread_t * );
 static int  dvdtime2msec( dvd_time_t * );
+static int hb_dvdread_is_break( hb_dvdread_t * d );
 
-char * hb_dvd_name( char * path )
+hb_dvd_func_t * hb_dvdread_methods( void )
+{
+    return &hb_dvdread_func;
+}
+
+static char * hb_dvdread_name( char * path )
 {
     static char name[1024];
     unsigned char unused[1024];
@@ -70,15 +79,28 @@ char * hb_dvd_name( char * path )
 }
 
 /***********************************************************************
- * hb_dvd_init
+ * hb_dvdread_init
  ***********************************************************************
  *
  **********************************************************************/
-hb_dvd_t * hb_dvd_init( char * path )
+hb_dvd_t * hb_dvdread_init( char * path )
 {
-    hb_dvd_t * d;
+    hb_dvd_t * e;
+    hb_dvdread_t * d;
+    int region_mask;
 
-    d = calloc( sizeof( hb_dvd_t ), 1 );
+    e = calloc( sizeof( hb_dvd_t ), 1 );
+    d = &(e->dvdread);
+
+       /* Log DVD drive region code */
+    if ( hb_dvd_region( path, &region_mask ) == 0 )
+    {
+        hb_log( "dvd: Region mask 0x%02x", region_mask );
+        if ( region_mask == 0xFF )
+        {
+            hb_log( "dvd: Warning, DVD device has no region set" );
+        }
+    }
 
     /* Open device */
     if( !( d->reader = DVDOpen( path ) ) )
@@ -99,7 +121,7 @@ hb_dvd_t * hb_dvd_init( char * path )
 
     d->path = strdup( path );
 
-    return d;
+    return e;
 
 fail:
     if( d->vmg )    ifoClose( d->vmg );
@@ -109,19 +131,21 @@ fail:
 }
 
 /***********************************************************************
- * hb_dvd_title_count
+ * hb_dvdread_title_count
  **********************************************************************/
-int hb_dvd_title_count( hb_dvd_t * d )
+static int hb_dvdread_title_count( hb_dvd_t * e )
 {
+    hb_dvdread_t *d = &(e->dvdread);
     return d->vmg->tt_srpt->nr_of_srpts;
 }
 
 /***********************************************************************
- * hb_dvd_title_scan
+ * hb_dvdread_title_scan
  **********************************************************************/
-hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
+static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t )
 {
 
+    hb_dvdread_t *d = &(e->dvdread);
     hb_title_t   * title;
     ifo_handle_t * vts = NULL;
     int            pgc_id, pgn, i;
@@ -165,20 +189,61 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
         goto fail;
     }
 
+    /* ignore titles with bogus cell addresses so we don't abort later
+     * in libdvdread. */
+    for ( i = 0; i < vts->vts_c_adt->nr_of_vobs; ++i)
+    {
+        if( (vts->vts_c_adt->cell_adr_table[i].start_sector & 0xffffff ) ==
+            0xffffff )
+        {
+            hb_error( "scan: cell_adr_table[%d].start_sector invalid (0x%x) "
+                      "- skipping title", i,
+                      vts->vts_c_adt->cell_adr_table[i].start_sector );
+            goto fail;
+        }
+        if( (vts->vts_c_adt->cell_adr_table[i].last_sector & 0xffffff ) ==
+            0xffffff )
+        {
+            hb_error( "scan: cell_adr_table[%d].last_sector invalid (0x%x) "
+                      "- skipping title", i,
+                      vts->vts_c_adt->cell_adr_table[i].last_sector );
+            goto fail;
+        }
+        if( vts->vts_c_adt->cell_adr_table[i].start_sector >=
+            vts->vts_c_adt->cell_adr_table[i].last_sector )
+        {
+            hb_error( "scan: cell_adr_table[%d].start_sector (0x%x) "
+                      "is not before last_sector (0x%x) - skipping title", i,
+                      vts->vts_c_adt->cell_adr_table[i].start_sector,
+                      vts->vts_c_adt->cell_adr_table[i].last_sector );
+            goto fail;
+        }
+    }
+
     if( global_verbosity_level == 3 )
     {
-        ifoPrint( d->reader, title->vts );
+        ifo_print( d->reader, title->vts );
     }
 
     /* Position of the title in the VTS */
     title->ttn = d->vmg->tt_srpt->title[t-1].vts_ttn;
+    if ( title->ttn < 1 || title->ttn > vts->vts_ptt_srpt->nr_of_srpts )
+    {
+        hb_error( "invalid VTS PTT offset %d for title %d, skipping", title->ttn, t );
+        goto fail;
+    }
 
     /* Get pgc */
     pgc_id = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgcn;
+    if ( pgc_id < 1 || pgc_id > vts->vts_pgcit->nr_of_pgci_srp )
+    {
+        hb_error( "invalid PGC ID %d for title %d, skipping", pgc_id, t );
+        goto fail;
+    }
     pgn    = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgn;
     d->pgc = vts->vts_pgcit->pgci_srp[pgc_id-1].pgc;
 
-    hb_log("pgc_id: %d, pgn: %d: pgc: 0x%x", pgc_id, pgn, d->pgc);
+    hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgc_id, pgn, d->pgc);
 
     if( !d->pgc )
     {
@@ -222,7 +287,7 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
     title->hours    = title->duration / 90000 / 3600;
     title->minutes  = ( ( title->duration / 90000 ) % 3600 ) / 60;
     title->seconds  = ( title->duration / 90000 ) % 60;
-    hb_log( "scan: duration is %02d:%02d:%02d (%lld ms)",
+    hb_log( "scan: duration is %02d:%02d:%02d (%"PRId64" ms)",
             title->hours, title->minutes, title->seconds,
             title->duration / 90 );
 
@@ -356,12 +421,6 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
         hb_list_add( title->list_audio, audio );
     }
 
-    if( !hb_list_count( title->list_audio ) )
-    {
-        hb_log( "scan: ignoring title (no audio track)" );
-        goto fail;
-    }
-
     memcpy( title->palette,
             vts->vts_pgcit->pgci_srp[pgc_id-1].pgc->palette,
             16 * sizeof( uint32_t ) );
@@ -410,11 +469,15 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
         lang = lang_for_code( vts->vtsi_mat->vts_subp_attr[i].lang_code );
 
         subtitle = calloc( sizeof( hb_subtitle_t ), 1 );
+        subtitle->track = i+1;
         subtitle->id = ( ( 0x20 + position ) << 8 ) | 0xbd;
         snprintf( subtitle->lang, sizeof( subtitle->lang ), "%s",
              strlen(lang->native_name) ? lang->native_name : lang->eng_name);
         snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "%s",
                   lang->iso639_2);
+        subtitle->format = PICTURESUB;
+        subtitle->source = VOBSUB;
+        subtitle->config.dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
 
         subtitle->type = lang_extension;
 
@@ -476,9 +539,6 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
     for( i = 0, c = 1;
          i < vts->vts_ptt_srpt->title[title->ttn-1].nr_of_ptts; i++ )
     {
-        int pgc_id_next, pgn_next;
-        pgc_t * pgc_next;
-
         chapter = calloc( sizeof( hb_chapter_t ), 1 );
         /* remember the on-disc chapter number */
         chapter->index = i + 1;
@@ -492,34 +552,20 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
         chapter->block_start =
             d->pgc->cell_playback[chapter->cell_start].first_sector;
 
-        /* End cell */
-        if( i != vts->vts_ptt_srpt->title[title->ttn-1].nr_of_ptts - 1 )
+        // if there are no more programs in this pgc, the end cell is the
+        // last cell. Otherwise it's the cell before the start cell of the
+        // next program.
+        if ( pgn == d->pgc->nr_of_programs )
         {
-            /* The cell before the starting cell of the next chapter,
-               or... */
-            pgc_id_next = vts->vts_ptt_srpt->title[title->ttn-1].ptt[i+1].pgcn;
-            pgn_next    = vts->vts_ptt_srpt->title[title->ttn-1].ptt[i+1].pgn;
-            pgc_next    = vts->vts_pgcit->pgci_srp[pgc_id_next-1].pgc;
-            chapter->cell_end = pgc_next->program_map[pgn_next-1] - 2;
-            if( chapter->cell_end < 0 )
-            {
-                /* Huh? */
-                free( chapter );
-                continue;
-            }
+            chapter->cell_end = d->pgc->nr_of_cells - 1;
         }
         else
         {
-            /* ... the last cell of the title */
-            chapter->cell_end = title->cell_end;
+            chapter->cell_end = d->pgc->program_map[pgn] - 2;;
         }
-        chapter->block_end =
-            d->pgc->cell_playback[chapter->cell_end].last_sector;
+        chapter->block_end = d->pgc->cell_playback[chapter->cell_end].last_sector;
 
         /* Block count, duration */
-        pgc_id = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgcn;
-        pgn    = vts->vts_ptt_srpt->title[title->ttn-1].ptt[0].pgn;
-        d->pgc = vts->vts_pgcit->pgci_srp[pgc_id-1].pgc;
         chapter->block_count = 0;
         chapter->duration = 0;
 
@@ -556,7 +602,7 @@ hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
         chapter->minutes   = ( seconds % 3600 ) / 60;
         chapter->seconds   = seconds % 60;
 
-        hb_log( "scan: chap %d c=%d->%d, b=%d->%d (%d), %lld ms",
+        hb_log( "scan: chap %d c=%d->%d, b=%d->%d (%d), %"PRId64" ms",
                 chapter->index, chapter->cell_start, chapter->cell_end,
                 chapter->block_start, chapter->block_end,
                 chapter->block_count, chapter->duration / 90 );
@@ -594,18 +640,20 @@ cleanup:
 }
 
 /***********************************************************************
- * hb_dvd_start
+ * hb_dvdread_start
  ***********************************************************************
  * Title and chapter start at 1
  **********************************************************************/
-int hb_dvd_start( hb_dvd_t * d, int title, int chapter )
+static int hb_dvdread_start( hb_dvd_t * e, hb_title_t *title, int chapter )
 {
+    hb_dvdread_t *d = &(e->dvdread);
     int pgc_id, pgn;
     int i;
+    int t = title->index;
 
     /* Open the IFO and the VOBs for this title */
-    d->vts = d->vmg->tt_srpt->title[title-1].title_set_nr;
-    d->ttn = d->vmg->tt_srpt->title[title-1].vts_ttn;
+    d->vts = d->vmg->tt_srpt->title[t-1].title_set_nr;
+    d->ttn = d->vmg->tt_srpt->title[t-1].vts_ttn;
     if( !( d->ifo = ifoOpen( d->reader, d->vts ) ) )
     {
         hb_error( "dvd: ifoOpen failed for VTS %d", d->vts );
@@ -655,12 +703,13 @@ int hb_dvd_start( hb_dvd_t * d, int title, int chapter )
 }
 
 /***********************************************************************
- * hb_dvd_stop
+ * hb_dvdread_stop
  ***********************************************************************
  *
  **********************************************************************/
-void hb_dvd_stop( hb_dvd_t * d )
+static void hb_dvdread_stop( hb_dvd_t * e )
 {
+    hb_dvdread_t *d = &(e->dvdread);
     if( d->ifo )
     {
         ifoClose( d->ifo );
@@ -674,12 +723,13 @@ void hb_dvd_stop( hb_dvd_t * d )
 }
 
 /***********************************************************************
- * hb_dvd_seek
+ * hb_dvdread_seek
  ***********************************************************************
  *
  **********************************************************************/
-int hb_dvd_seek( hb_dvd_t * d, float f )
+static int hb_dvdread_seek( hb_dvd_t * e, float f )
 {
+    hb_dvdread_t *d = &(e->dvdread);
     int count, sizeCell;
     int i;
 
@@ -696,7 +746,7 @@ int hb_dvd_seek( hb_dvd_t * d, float f )
             d->cur_cell_id = 0;
             FindNextCell( d );
 
-            /* Now let hb_dvd_read find the next VOBU */
+            /* Now let hb_dvdread_read find the next VOBU */
             d->next_vobu = d->pgc->cell_playback[i].first_sector + count;
             d->pack_len  = 0;
             break;
@@ -764,12 +814,13 @@ int is_nav_pack( unsigned char *buf )
 
 
 /***********************************************************************
- * hb_dvd_read
+ * hb_dvdread_read
  ***********************************************************************
  *
  **********************************************************************/
-int hb_dvd_read( hb_dvd_t * d, hb_buffer_t * b )
+static int hb_dvdread_read( hb_dvd_t * e, hb_buffer_t * b )
 {
+    hb_dvdread_t *d = &(e->dvdread);
  top:
     if( !d->pack_len )
     {
@@ -971,7 +1022,7 @@ int hb_dvd_read( hb_dvd_t * d, hb_buffer_t * b )
 
                 if( d->cell_overlap )
                 {
-                    b->new_chap = hb_dvd_is_break( d );
+                    b->new_chap = hb_dvdread_is_break( d );
                     d->cell_overlap = 0;
                 }
             }
@@ -1015,13 +1066,14 @@ int hb_dvd_read( hb_dvd_t * d, hb_buffer_t * b )
 }
 
 /***********************************************************************
- * hb_dvd_chapter
+ * hb_dvdread_chapter
  ***********************************************************************
  * Returns in which chapter the next block to be read is.
  * Chapter numbers start at 1.
  **********************************************************************/
-int hb_dvd_chapter( hb_dvd_t * d )
+static int hb_dvdread_chapter( hb_dvd_t * e )
 {
+    hb_dvdread_t *d = &(e->dvdread);
     int     i;
     int     pgc_id, pgn;
     int     nr_of_ptts = d->ifo->vts_ptt_srpt->title[d->ttn-1].nr_of_ptts;
@@ -1049,15 +1101,15 @@ int hb_dvd_chapter( hb_dvd_t * d )
 }
 
 /***********************************************************************
- * hb_dvd_is_break
+ * hb_dvdread_is_break
  ***********************************************************************
  * Returns chapter number if the current block is a new chapter start
  **********************************************************************/
-int hb_dvd_is_break( hb_dvd_t * d )
+static int hb_dvdread_is_break( hb_dvdread_t * d )
 {
     int     i;
     int     pgc_id, pgn;
-       int     nr_of_ptts = d->ifo->vts_ptt_srpt->title[d->ttn-1].nr_of_ptts;
+    int     nr_of_ptts = d->ifo->vts_ptt_srpt->title[d->ttn-1].nr_of_ptts;
     pgc_t * pgc;
     int     cell;
 
@@ -1085,13 +1137,13 @@ int hb_dvd_is_break( hb_dvd_t * d )
 }
 
 /***********************************************************************
- * hb_dvd_close
+ * hb_dvdread_close
  ***********************************************************************
  * Closes and frees everything
  **********************************************************************/
-void hb_dvd_close( hb_dvd_t ** _d )
+static void hb_dvdread_close( hb_dvd_t ** _d )
 {
-    hb_dvd_t * d = *_d;
+    hb_dvdread_t * d = &((*_d)->dvdread);
 
     if( d->vmg )
     {
@@ -1107,12 +1159,32 @@ void hb_dvd_close( hb_dvd_t ** _d )
 }
 
 /***********************************************************************
+ * hb_dvdread_angle_count
+ ***********************************************************************
+ * Returns the number of angles supported.  We do not support angles
+ * with dvdread
+ **********************************************************************/
+static int hb_dvdread_angle_count( hb_dvd_t * d )
+{
+    return 1;
+}
+
+/***********************************************************************
+ * hb_dvdread_set_angle
+ ***********************************************************************
+ * Sets the angle to read.  Not supported with dvdread
+ **********************************************************************/
+static void hb_dvdread_set_angle( hb_dvd_t * d, int angle )
+{
+}
+
+/***********************************************************************
  * FindNextCell
  ***********************************************************************
  * Assumes pgc and cell_cur are correctly set, and sets cell_next to the
  * cell to be read when we will be done with cell_cur.
  **********************************************************************/
-static void FindNextCell( hb_dvd_t * d )
+static void FindNextCell( hb_dvdread_t * d )
 {
     int i = 0;
 
@@ -1158,3 +1230,74 @@ static int dvdtime2msec(dvd_time_t * dt)
 
     return ms;
 }
+
+char * hb_dvd_name( char * path )
+{
+    return dvd_methods->name(path);
+}
+
+hb_dvd_t * hb_dvd_init( char * path )
+{
+    return dvd_methods->init(path);
+}
+
+int hb_dvd_title_count( hb_dvd_t * d )
+{
+    return dvd_methods->title_count(d);
+}
+
+hb_title_t * hb_dvd_title_scan( hb_dvd_t * d, int t )
+{
+    return dvd_methods->title_scan(d, t);
+}
+
+int hb_dvd_start( hb_dvd_t * d, hb_title_t *title, int chapter )
+{
+    return dvd_methods->start(d, title, chapter);
+}
+
+void hb_dvd_stop( hb_dvd_t * d )
+{
+    dvd_methods->stop(d);
+}
+
+int hb_dvd_seek( hb_dvd_t * d, float f )
+{
+    return dvd_methods->seek(d, f);
+}
+
+int hb_dvd_read( hb_dvd_t * d, hb_buffer_t * b )
+{
+    return dvd_methods->read(d, b);
+}
+
+int hb_dvd_chapter( hb_dvd_t * d )
+{
+    return dvd_methods->chapter(d);
+}
+
+void hb_dvd_close( hb_dvd_t ** _d )
+{
+    dvd_methods->close(_d);
+}
+
+int hb_dvd_angle_count( hb_dvd_t * d )
+{
+    return dvd_methods->angle_count(d);
+}
+
+void hb_dvd_set_angle( hb_dvd_t * d, int angle )
+{
+    dvd_methods->set_angle(d, angle);
+}
+
+// hb_dvd_set_dvdnav must only be called when no dvd source is open
+// it rips the rug out from under things so be careful
+void hb_dvd_set_dvdnav( int enable )
+{
+    if (enable)
+        dvd_methods = hb_dvdnav_methods();
+    else
+        dvd_methods = hb_dvdread_methods();
+}
+
diff --git a/libhb/dvd.h b/libhb/dvd.h
new file mode 100644 (file)
index 0000000..bcba78e
--- /dev/null
@@ -0,0 +1,90 @@
+/* $Id: dvd.h,v 1.1 2004/08/02 07:19:05 stebbins Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#ifndef HB_DVD_H
+#define HB_DVD_H
+
+#include "dvdnav/dvdnav.h"
+#include "dvdread/ifo_read.h"
+#include "dvdread/nav_read.h"
+
+struct hb_dvdread_s
+{
+    char         * path;
+
+    dvd_reader_t * reader;
+    ifo_handle_t * vmg;
+
+    int            vts;
+    int            ttn;
+    ifo_handle_t * ifo;
+    dvd_file_t   * file;
+
+    pgc_t        * pgc;
+    int            cell_start;
+    int            cell_end;
+    int            title_start;
+    int            title_end;
+    int            title_block_count;
+    int            cell_cur;
+    int            cell_next;
+    int            cell_overlap;
+    int            block;
+    int            pack_len;
+    int            next_vobu;
+    int            in_cell;
+    int            in_sync;
+    uint16_t       cur_vob_id;
+    uint8_t        cur_cell_id;
+};
+
+struct hb_dvdnav_s
+{
+    char         * path;
+
+    dvdnav_t     * dvdnav;
+    dvd_reader_t * reader;
+    ifo_handle_t * vmg;
+    int            title;
+    int            title_block_count;
+    int            chapter;
+    hb_list_t    * list_chapter;
+    int            stopped;
+};
+
+typedef struct hb_dvdnav_s hb_dvdnav_t;
+typedef struct hb_dvdread_s hb_dvdread_t;
+
+union hb_dvd_s
+{
+    hb_dvdread_t dvdread;
+    hb_dvdnav_t  dvdnav;
+};
+
+
+struct hb_dvd_func_s
+{
+    hb_dvd_t *    (* init)        ( char * );
+    void          (* close)       ( hb_dvd_t ** );
+    char        * (* name)        ( char * );
+    int           (* title_count) ( hb_dvd_t * );
+    hb_title_t  * (* title_scan)  ( hb_dvd_t *, int );
+    int           (* start)       ( hb_dvd_t *, hb_title_t *, int );
+    void          (* stop)        ( hb_dvd_t * );
+    int           (* seek)        ( hb_dvd_t *, float );
+    int           (* read)        ( hb_dvd_t *, hb_buffer_t * );
+    int           (* chapter)     ( hb_dvd_t * );
+    int           (* angle_count) ( hb_dvd_t * );
+    void          (* set_angle)   ( hb_dvd_t *, int );
+};
+typedef struct hb_dvd_func_s hb_dvd_func_t;
+
+hb_dvd_func_t * hb_dvdnav_methods( void );
+hb_dvd_func_t * hb_dvdread_methods( void );
+
+#endif // HB_DVD_H
+
+
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
new file mode 100644 (file)
index 0000000..d525b96
--- /dev/null
@@ -0,0 +1,1339 @@
+/* $Id: dvd.c,v 1.12 2005/11/25 15:05:25 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include "hb.h"
+#include "lang.h"
+#include "dvd.h"
+
+#include "dvdnav/dvdnav.h"
+#include "dvdread/ifo_read.h"
+#include "dvdread/ifo_print.h"
+#include "dvdread/nav_read.h"
+
+#define DVD_READ_CACHE 1
+
+static char        * hb_dvdnav_name( char * path );
+static hb_dvd_t    * hb_dvdnav_init( char * path );
+static int           hb_dvdnav_title_count( hb_dvd_t * d );
+static hb_title_t  * hb_dvdnav_title_scan( hb_dvd_t * d, int t );
+static int           hb_dvdnav_start( hb_dvd_t * d, hb_title_t *title, int chapter );
+static void          hb_dvdnav_stop( hb_dvd_t * d );
+static int           hb_dvdnav_seek( hb_dvd_t * d, float f );
+static int           hb_dvdnav_read( hb_dvd_t * d, hb_buffer_t * b );
+static int           hb_dvdnav_chapter( hb_dvd_t * d );
+static void          hb_dvdnav_close( hb_dvd_t ** _d );
+static int           hb_dvdnav_angle_count( hb_dvd_t * d );
+static void          hb_dvdnav_set_angle( hb_dvd_t * e, int angle );
+
+hb_dvd_func_t hb_dvdnav_func =
+{
+    hb_dvdnav_init,
+    hb_dvdnav_close,
+    hb_dvdnav_name,
+    hb_dvdnav_title_count,
+    hb_dvdnav_title_scan,
+    hb_dvdnav_start,
+    hb_dvdnav_stop,
+    hb_dvdnav_seek,
+    hb_dvdnav_read,
+    hb_dvdnav_chapter,
+    hb_dvdnav_angle_count,
+    hb_dvdnav_set_angle
+};
+
+// there can be at most 999 PGCs per title. round that up to the nearest
+// power of two.
+#define MAX_PGCN 1024
+
+/***********************************************************************
+ * Local prototypes
+ **********************************************************************/
+static void PgcWalkInit( uint32_t pgcn_map[MAX_PGCN/32] );
+static int FindChapterIndex( hb_list_t * list, int pgcn, int pgn );
+static int NextPgcn( ifo_handle_t *ifo, int pgcn, uint32_t pgcn_map[MAX_PGCN/32] );
+static int FindNextCell( pgc_t *pgc, int cell_cur );
+static int dvdtime2msec( dvd_time_t * );
+
+hb_dvd_func_t * hb_dvdnav_methods( void )
+{
+    return &hb_dvdnav_func;
+}
+
+static char * hb_dvdnav_name( char * path )
+{
+    static char name[1024];
+    unsigned char unused[1024];
+    dvd_reader_t * reader;
+
+    reader = DVDOpen( path );
+    if( !reader )
+    {
+        return NULL;
+    }
+
+    if( DVDUDFVolumeInfo( reader, name, sizeof( name ),
+                          unused, sizeof( unused ) ) )
+    {
+        DVDClose( reader );
+        return NULL;
+    }
+
+    DVDClose( reader );
+    return name;
+}
+
+/***********************************************************************
+ * hb_dvdnav_reset
+ ***********************************************************************
+ * Once dvdnav has entered the 'stopped' state, it can not be revived
+ * dvdnav_reset doesn't work because it doesn't remember the path
+ * So this function re-opens dvdnav
+ **********************************************************************/
+static int hb_dvdnav_reset( hb_dvdnav_t * d )
+{
+    if ( d->dvdnav ) 
+        dvdnav_close( d->dvdnav );
+
+    /* Open device */
+    if( dvdnav_open(&d->dvdnav, d->path) != DVDNAV_STATUS_OK )
+    {
+        /*
+         * Not an error, may be a stream - which we'll try in a moment.
+         */
+        hb_log( "dvd: not a dvd - trying as a stream/file instead" );
+        goto fail;
+    }
+
+    if (dvdnav_set_readahead_flag(d->dvdnav, DVD_READ_CACHE) !=
+        DVDNAV_STATUS_OK)
+    {
+        hb_error("Error: dvdnav_set_readahead_flag: %s\n",
+                 dvdnav_err_to_string(d->dvdnav));
+        goto fail;
+    }
+
+    /*
+     ** set the PGC positioning flag to have position information
+     ** relatively to the whole feature instead of just relatively to the
+     ** current chapter 
+     **/
+    if (dvdnav_set_PGC_positioning_flag(d->dvdnav, 1) != DVDNAV_STATUS_OK)
+    {
+        hb_error("Error: dvdnav_set_PGC_positioning_flag: %s\n",
+                 dvdnav_err_to_string(d->dvdnav));
+        goto fail;
+    }
+    return 1;
+
+fail:
+    if( d->dvdnav ) dvdnav_close( d->dvdnav );
+    return 0;
+}
+
+/***********************************************************************
+ * hb_dvdnav_init
+ ***********************************************************************
+ *
+ **********************************************************************/
+static hb_dvd_t * hb_dvdnav_init( char * path )
+{
+    hb_dvd_t * e;
+    hb_dvdnav_t * d;
+    int region_mask;
+
+    e = calloc( sizeof( hb_dvd_t ), 1 );
+    d = &(e->dvdnav);
+
+       /* Log DVD drive region code */
+    if ( hb_dvd_region( path, &region_mask ) == 0 )
+    {
+        hb_log( "dvd: Region mask 0x%02x", region_mask );
+        if ( region_mask == 0xFF )
+        {
+            hb_log( "dvd: Warning, DVD device has no region set" );
+        }
+    }
+
+    /* Open device */
+    if( dvdnav_open(&d->dvdnav, path) != DVDNAV_STATUS_OK )
+    {
+        /*
+         * Not an error, may be a stream - which we'll try in a moment.
+         */
+        hb_log( "dvd: not a dvd - trying as a stream/file instead" );
+        goto fail;
+    }
+
+    if (dvdnav_set_readahead_flag(d->dvdnav, DVD_READ_CACHE) !=
+        DVDNAV_STATUS_OK)
+    {
+        hb_error("Error: dvdnav_set_readahead_flag: %s\n",
+                 dvdnav_err_to_string(d->dvdnav));
+        goto fail;
+    }
+
+    /*
+     ** set the PGC positioning flag to have position information
+     ** relatively to the whole feature instead of just relatively to the
+     ** current chapter 
+     **/
+    if (dvdnav_set_PGC_positioning_flag(d->dvdnav, 1) != DVDNAV_STATUS_OK)
+    {
+        hb_error("Error: dvdnav_set_PGC_positioning_flag: %s\n",
+                 dvdnav_err_to_string(d->dvdnav));
+        goto fail;
+    }
+
+    /* Open device */
+    if( !( d->reader = DVDOpen( path ) ) )
+    {
+        /*
+         * Not an error, may be a stream - which we'll try in a moment.
+         */
+        hb_log( "dvd: not a dvd - trying as a stream/file instead" );
+        goto fail;
+    }
+
+    /* Open main IFO */
+    if( !( d->vmg = ifoOpen( d->reader, 0 ) ) )
+    {
+        hb_error( "dvd: ifoOpen failed" );
+        goto fail;
+    }
+
+    d->path = strdup( path );
+
+    return e;
+
+fail:
+    if( d->dvdnav ) dvdnav_close( d->dvdnav );
+    if( d->vmg )    ifoClose( d->vmg );
+    if( d->reader ) DVDClose( d->reader );
+    free( e );
+    return NULL;
+}
+
+/***********************************************************************
+ * hb_dvdnav_title_count
+ **********************************************************************/
+static int hb_dvdnav_title_count( hb_dvd_t * e )
+{
+    int titles = 0;
+    hb_dvdnav_t * d = &(e->dvdnav);
+
+    dvdnav_get_number_of_titles(d->dvdnav, &titles);
+    return titles;
+}
+
+static uint64_t
+PttDuration(ifo_handle_t *ifo, int ttn, int pttn, int *blocks, int *last_pgcn)
+{
+    int            pgcn, pgn;
+    pgc_t        * pgc;
+    uint64_t       duration = 0;
+    int            cell_start, cell_end;
+    int            i;
+
+    // Initialize map of visited pgc's to prevent loops
+    uint32_t pgcn_map[MAX_PGCN/32];
+    PgcWalkInit( pgcn_map );
+    pgcn   = ifo->vts_ptt_srpt->title[ttn-1].ptt[pttn-1].pgcn;
+    pgn   = ifo->vts_ptt_srpt->title[ttn-1].ptt[pttn-1].pgn;
+    if ( pgcn < 1 || pgcn > ifo->vts_pgcit->nr_of_pgci_srp || pgcn >= MAX_PGCN)
+    {
+        hb_error( "invalid PGC ID %d, skipping", pgcn );
+        return 0;
+    }
+
+    if( pgn <= 0 || pgn > 99 )
+    {
+        hb_error( "scan: pgn %d not valid, skipping", pgn );
+        return 0;
+    }
+
+    *blocks = 0;
+    do
+    {
+        pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
+        if (!pgc)
+        {
+            hb_error( "scan: pgc not valid, skipping" );
+            break;
+        }
+        if (pgn > pgc->nr_of_programs)
+        {
+            pgn = 1;
+            continue;
+        }
+
+        duration += 90LL * dvdtime2msec( &pgc->playback_time );
+
+        cell_start = pgc->program_map[pgn-1] - 1;
+        cell_end = pgc->nr_of_cells - 1;
+        for(i = cell_start; i <= cell_end; i = FindNextCell(pgc, i))
+        {
+            *blocks += pgc->cell_playback[i].last_sector + 1 -
+                pgc->cell_playback[i].first_sector;
+        }
+        *last_pgcn = pgcn;
+        pgn = 1;
+    } while((pgcn = NextPgcn(ifo, pgcn, pgcn_map)) != 0);
+    return duration;
+}
+
+/***********************************************************************
+ * hb_dvdnav_title_scan
+ **********************************************************************/
+static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
+{
+
+    hb_dvdnav_t * d = &(e->dvdnav);
+    hb_title_t   * title;
+    ifo_handle_t * ifo = NULL;
+    int            pgcn, pgn, pgcn_end, i, c;
+    int            title_pgcn;
+    pgc_t        * pgc;
+    int            cell_cur;
+    hb_chapter_t * chapter;
+    int            count;
+    uint64_t       duration, longest;
+    int            longest_pgcn, longest_pgn, longest_pgcn_end;
+    float          duration_correction;
+    const char   * name;
+
+    hb_log( "scan: scanning title %d", t );
+
+    title = hb_title_init( d->path, t );
+    if (dvdnav_get_title_string(d->dvdnav, &name) == DVDNAV_STATUS_OK)
+    {
+        strncpy( title->name, name, sizeof( title->name ) );
+    }
+    else
+    {
+        char * p_cur, * p_last = d->path;
+        for( p_cur = d->path; *p_cur; p_cur++ )
+        {
+            if( p_cur[0] == '/' && p_cur[1] )
+            {
+                p_last = &p_cur[1];
+            }
+        }
+        snprintf( title->name, sizeof( title->name ), "%s", p_last );
+    }
+
+    /* VTS which our title is in */
+    title->vts = d->vmg->tt_srpt->title[t-1].title_set_nr;
+
+    if ( !title->vts )
+    {
+        /* A VTS of 0 means the title wasn't found in the title set */
+        hb_error("Invalid VTS (title set) number: %i", title->vts);
+        goto fail;
+    }
+
+    hb_log( "scan: opening IFO for VTS %d", title->vts );
+    if( !( ifo = ifoOpen( d->reader, title->vts ) ) )
+    {
+        hb_error( "scan: ifoOpen failed" );
+        goto fail;
+    }
+
+    /* ignore titles with bogus cell addresses so we don't abort later
+     ** in libdvdread. */
+    for ( i = 0; i < ifo->vts_c_adt->nr_of_vobs; ++i)
+    {
+        if( (ifo->vts_c_adt->cell_adr_table[i].start_sector & 0xffffff ) ==
+            0xffffff )
+        {
+            hb_error( "scan: cell_adr_table[%d].start_sector invalid (0x%x) "
+                      "- skipping title", i,
+                      ifo->vts_c_adt->cell_adr_table[i].start_sector );
+            goto fail;
+        }
+        if( (ifo->vts_c_adt->cell_adr_table[i].last_sector & 0xffffff ) ==
+            0xffffff )
+        {
+            hb_error( "scan: cell_adr_table[%d].last_sector invalid (0x%x) "
+                      "- skipping title", i,
+                      ifo->vts_c_adt->cell_adr_table[i].last_sector );
+            goto fail;
+        }
+        if( ifo->vts_c_adt->cell_adr_table[i].start_sector >=
+            ifo->vts_c_adt->cell_adr_table[i].last_sector )
+        {
+            hb_error( "scan: cell_adr_table[%d].start_sector (0x%x) "
+                      "is not before last_sector (0x%x) - skipping title", i,
+                      ifo->vts_c_adt->cell_adr_table[i].start_sector,
+                      ifo->vts_c_adt->cell_adr_table[i].last_sector );
+            goto fail;
+        }
+    }
+
+    if( global_verbosity_level == 3 )
+    {
+        ifo_print( d->reader, title->vts );
+    }
+
+    /* Position of the title in the VTS */
+    title->ttn = d->vmg->tt_srpt->title[t-1].vts_ttn;
+    if ( title->ttn < 1 || title->ttn > ifo->vts_ptt_srpt->nr_of_srpts )
+    {
+        hb_error( "invalid VTS PTT offset %d for title %d, skipping", title->ttn, t );
+        goto fail;
+    }
+
+    longest = 0LL;
+    longest_pgcn = -1;
+    longest_pgn = 1;
+    longest_pgcn_end = -1;
+    pgcn_end = -1;
+    for( i = 0; i < ifo->vts_ptt_srpt->title[title->ttn-1].nr_of_ptts; i++ )
+    {
+        int blocks = 0;
+
+        duration = PttDuration(ifo, title->ttn, i+1, &blocks, &pgcn_end);
+        pgcn  = ifo->vts_ptt_srpt->title[title->ttn-1].ptt[i].pgcn;
+        pgn   = ifo->vts_ptt_srpt->title[title->ttn-1].ptt[i].pgn;
+        if( duration > longest )
+        {
+            longest_pgcn  = pgcn;
+            longest_pgn   = pgn;
+            longest_pgcn_end   = pgcn_end;
+            longest = duration;
+            title->block_count = blocks;
+        }
+        else if (pgcn == longest_pgcn && pgn < longest_pgn)
+        {
+            longest_pgn   = pgn;
+            title->block_count = blocks;
+        }
+    }
+
+    /* ignore titles under 10 seconds because they're often stills or
+     * clips with no audio & our preview code doesn't currently handle
+     * either of these. */
+    if( longest < 900000LL )
+    {
+        hb_log( "scan: ignoring title (too short)" );
+        goto fail;
+    }
+
+    pgcn       = longest_pgcn;
+    pgcn_end   = longest_pgcn_end;
+    pgn        = longest_pgn;;
+    title_pgcn = pgcn;
+
+
+    /* Get pgc */
+    if ( pgcn < 1 || pgcn > ifo->vts_pgcit->nr_of_pgci_srp || pgcn >= MAX_PGCN)
+    {
+        hb_error( "invalid PGC ID %d for title %d, skipping", pgcn, t );
+        goto fail;
+    }
+
+    pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
+
+    hb_log("pgc_id: %d, pgn: %d: pgc: %p", pgcn, pgn, pgc);
+    if (pgn > pgc->nr_of_programs)
+    {
+        hb_error( "invalid PGN %d for title %d, skipping", pgn, t );
+        goto fail;
+    }
+
+    /* Title start */
+    title->cell_start = pgc->program_map[pgn-1] - 1;
+    title->block_start = pgc->cell_playback[title->cell_start].first_sector;
+
+    pgc = ifo->vts_pgcit->pgci_srp[pgcn_end-1].pgc;
+
+    /* Title end */
+    title->cell_end = pgc->nr_of_cells - 1;
+    title->block_end = pgc->cell_playback[title->cell_end].last_sector;
+
+    hb_log( "scan: vts=%d, ttn=%d, cells=%d->%d, blocks=%d->%d, "
+            "%d blocks", title->vts, title->ttn, title->cell_start,
+            title->cell_end, title->block_start, title->block_end,
+            title->block_count );
+
+    /* Get duration */
+    title->duration = longest;
+    title->hours    = title->duration / 90000 / 3600;
+    title->minutes  = ( ( title->duration / 90000 ) % 3600 ) / 60;
+    title->seconds  = ( title->duration / 90000 ) % 60;
+    hb_log( "scan: duration is %02d:%02d:%02d (%"PRId64" ms)",
+            title->hours, title->minutes, title->seconds,
+            title->duration / 90 );
+
+    /* Detect languages */
+    for( i = 0; i < ifo->vtsi_mat->nr_of_vts_audio_streams; i++ )
+    {
+        hb_audio_t * audio, * audio_tmp;
+        int          audio_format, lang_code, audio_control,
+                     position, j;
+        iso639_lang_t * lang;
+        int lang_extension = 0;
+
+        hb_log( "scan: checking audio %d", i + 1 );
+
+        audio = calloc( sizeof( hb_audio_t ), 1 );
+
+        audio_format  = ifo->vtsi_mat->vts_audio_attr[i].audio_format;
+        lang_code     = ifo->vtsi_mat->vts_audio_attr[i].lang_code;
+        lang_extension = ifo->vtsi_mat->vts_audio_attr[i].code_extension;
+        audio_control =
+            ifo->vts_pgcit->pgci_srp[title_pgcn-1].pgc->audio_control[i];
+
+        if( !( audio_control & 0x8000 ) )
+        {
+            hb_log( "scan: audio channel is not active" );
+            free( audio );
+            continue;
+        }
+
+        position = ( audio_control & 0x7F00 ) >> 8;
+
+        switch( audio_format )
+        {
+            case 0x00:
+                audio->id    = ( ( 0x80 + position ) << 8 ) | 0xbd;
+                audio->config.in.codec = HB_ACODEC_AC3;
+                break;
+
+            case 0x02:
+            case 0x03:
+                audio->id    = 0xc0 + position;
+                audio->config.in.codec = HB_ACODEC_MPGA;
+                break;
+
+            case 0x04:
+                audio->id    = ( ( 0xa0 + position ) << 8 ) | 0xbd;
+                audio->config.in.codec = HB_ACODEC_LPCM;
+                break;
+
+            case 0x06:
+                audio->id    = ( ( 0x88 + position ) << 8 ) | 0xbd;
+                audio->config.in.codec = HB_ACODEC_DCA;
+                break;
+
+            default:
+                audio->id    = 0;
+                audio->config.in.codec = 0;
+                hb_log( "scan: unknown audio codec (%x)",
+                        audio_format );
+                break;
+        }
+        if( !audio->id )
+        {
+            continue;
+        }
+
+        /* Check for duplicate tracks */
+        audio_tmp = NULL;
+        for( j = 0; j < hb_list_count( title->list_audio ); j++ )
+        {
+            audio_tmp = hb_list_item( title->list_audio, j );
+            if( audio->id == audio_tmp->id )
+            {
+                break;
+            }
+            audio_tmp = NULL;
+        }
+        if( audio_tmp )
+        {
+            hb_log( "scan: duplicate audio track" );
+            free( audio );
+            continue;
+        }
+
+        audio->config.lang.type = lang_extension;
+
+        lang = lang_for_code( ifo->vtsi_mat->vts_audio_attr[i].lang_code );
+
+        snprintf( audio->config.lang.description, sizeof( audio->config.lang.description ), "%s (%s)",
+            strlen(lang->native_name) ? lang->native_name : lang->eng_name,
+            audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : ( audio->config.in.codec ==
+                HB_ACODEC_DCA ? "DTS" : ( audio->config.in.codec ==
+                HB_ACODEC_MPGA ? "MPEG" : "LPCM" ) ) );
+        snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s",
+                  strlen(lang->native_name) ? lang->native_name : lang->eng_name );
+        snprintf( audio->config.lang.iso639_2, sizeof( audio->config.lang.iso639_2 ), "%s",
+                  lang->iso639_2);
+
+        switch( lang_extension )
+        {
+        case 0:
+        case 1:
+            break;
+        case 2:
+            strcat( audio->config.lang.description, " (Visually Impaired)" );
+            break;
+        case 3:
+            strcat( audio->config.lang.description, " (Director's Commentary 1)" );
+            break;
+        case 4:
+            strcat( audio->config.lang.description, " (Director's Commentary 2)" );
+            break;
+        default:
+            break;
+        }
+
+        hb_log( "scan: id=%x, lang=%s, 3cc=%s ext=%i", audio->id,
+                audio->config.lang.description, audio->config.lang.iso639_2,
+                lang_extension );
+
+        audio->config.in.track = i;
+        hb_list_add( title->list_audio, audio );
+    }
+
+    memcpy( title->palette,
+            ifo->vts_pgcit->pgci_srp[title_pgcn-1].pgc->palette,
+            16 * sizeof( uint32_t ) );
+
+    /* Check for subtitles */
+    for( i = 0; i < ifo->vtsi_mat->nr_of_vts_subp_streams; i++ )
+    {
+        hb_subtitle_t * subtitle;
+        int spu_control;
+        int position;
+        iso639_lang_t * lang;
+        int lang_extension = 0;
+
+        hb_log( "scan: checking subtitle %d", i + 1 );
+
+        spu_control =
+            ifo->vts_pgcit->pgci_srp[title_pgcn-1].pgc->subp_control[i];
+
+        if( !( spu_control & 0x80000000 ) )
+        {
+            hb_log( "scan: subtitle channel is not active" );
+            continue;
+        }
+
+        if( ifo->vtsi_mat->vts_video_attr.display_aspect_ratio )
+        {
+            switch( ifo->vtsi_mat->vts_video_attr.permitted_df )
+            {
+                case 1:
+                    position = spu_control & 0xFF;
+                    break;
+                case 2:
+                    position = ( spu_control >> 8 ) & 0xFF;
+                    break;
+                default:
+                    position = ( spu_control >> 16 ) & 0xFF;
+            }
+        }
+        else
+        {
+            position = ( spu_control >> 24 ) & 0x7F;
+        }
+
+        lang_extension = ifo->vtsi_mat->vts_subp_attr[i].code_extension;
+
+        lang = lang_for_code( ifo->vtsi_mat->vts_subp_attr[i].lang_code );
+
+        subtitle = calloc( sizeof( hb_subtitle_t ), 1 );
+        subtitle->track = i+1;
+        subtitle->id = ( ( 0x20 + position ) << 8 ) | 0xbd;
+        snprintf( subtitle->lang, sizeof( subtitle->lang ), "%s",
+             strlen(lang->native_name) ? lang->native_name : lang->eng_name);
+        snprintf( subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "%s",
+                  lang->iso639_2);
+        subtitle->format = PICTURESUB;
+        subtitle->source = VOBSUB;
+        subtitle->config.dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
+
+        subtitle->type = lang_extension;
+
+        switch( lang_extension )
+        {  
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            strcat( subtitle->lang, " (Caption with bigger size character)");
+            break;
+        case 3: 
+            strcat( subtitle->lang, " (Caption for Children)");
+            break;
+        case 4:
+            break;
+        case 5:
+            strcat( subtitle->lang, " (Closed Caption)");
+            break;
+        case 6:
+            strcat( subtitle->lang, " (Closed Caption with bigger size character)");
+            break;
+        case 7:
+            strcat( subtitle->lang, " (Closed Caption for Children)");
+            break;
+        case 8:
+            break;
+        case 9:
+            strcat( subtitle->lang, " (Forced Caption)");
+            break;
+        case 10:
+            break;
+        case 11:
+            break;
+        case 12:
+            break;
+        case 13:
+            strcat( subtitle->lang, " (Director's Commentary)");
+            break;
+        case 14:
+            strcat( subtitle->lang, " (Director's Commentary with bigger size character)");
+            break;
+        case 15:
+            strcat( subtitle->lang, " (Director's Commentary for Children)");
+        default:
+            break;
+        }
+
+        hb_log( "scan: id=%x, lang=%s, 3cc=%s", subtitle->id,
+                subtitle->lang, subtitle->iso639_2 );
+
+        hb_list_add( title->list_subtitle, subtitle );
+    }
+
+    /* Chapters */
+    uint32_t pgcn_map[MAX_PGCN/32];
+    PgcWalkInit( pgcn_map );
+    c = 0;
+    do
+    {
+        pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
+
+        for (i = pgn; i <= pgc->nr_of_programs; i++)
+        {
+            chapter = calloc( sizeof( hb_chapter_t ), 1 );
+
+            chapter->index = c + 1;
+            chapter->pgcn = pgcn;
+            chapter->pgn = i;
+            hb_list_add( title->list_chapter, chapter );
+            c++;
+        }
+
+        pgn = 1;
+    } while ((pgcn = NextPgcn(ifo, pgcn, pgcn_map)) != 0);
+
+    hb_log( "scan: title %d has %d chapters", t, c );
+
+    duration = 0;
+    count = hb_list_count( title->list_chapter );
+    for (i = 0; i < count; i++)
+    {
+        chapter = hb_list_item( title->list_chapter, i );
+
+        pgcn = chapter->pgcn;
+        pgn = chapter->pgn;
+        pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
+
+        /* Start cell */
+        chapter->cell_start  = pgc->program_map[pgn-1] - 1;
+        chapter->block_start = pgc->cell_playback[chapter->cell_start].first_sector;
+        // if there are no more programs in this pgc, the end cell is the
+        // last cell. Otherwise it's the cell before the start cell of the
+        // next program.
+        if ( pgn == pgc->nr_of_programs )
+        {
+            chapter->cell_end = pgc->nr_of_cells - 1;
+        }
+        else
+        {
+            chapter->cell_end = pgc->program_map[pgn] - 2;;
+        }
+        chapter->block_end = pgc->cell_playback[chapter->cell_end].last_sector;
+
+        /* Block count, duration */
+        chapter->block_count = 0;
+        chapter->duration = 0;
+
+        cell_cur = chapter->cell_start;
+        while( cell_cur <= chapter->cell_end )
+        {
+#define cp pgc->cell_playback[cell_cur]
+            chapter->block_count += cp.last_sector + 1 - cp.first_sector;
+            chapter->duration += 90LL * dvdtime2msec( &cp.playback_time );
+#undef cp
+            cell_cur = FindNextCell( pgc, cell_cur );
+        }
+        duration += chapter->duration;
+    }
+
+    /* The durations we get for chapters aren't precise. Scale them so
+       the total matches the title duration */
+    duration_correction = (float) title->duration / (float) duration;
+    for( i = 0; i < hb_list_count( title->list_chapter ); i++ )
+    {
+        int seconds;
+        chapter            = hb_list_item( title->list_chapter, i );
+        chapter->duration  = duration_correction * chapter->duration;
+        seconds            = ( chapter->duration + 45000 ) / 90000;
+        chapter->hours     = seconds / 3600;
+        chapter->minutes   = ( seconds % 3600 ) / 60;
+        chapter->seconds   = seconds % 60;
+
+        hb_log( "scan: chap %d c=%d->%d, b=%d->%d (%d), %"PRId64" ms",
+                chapter->index, chapter->cell_start, chapter->cell_end,
+                chapter->block_start, chapter->block_end,
+                chapter->block_count, chapter->duration / 90 );
+    }
+
+    /* Get aspect. We don't get width/height/rate infos here as
+       they tend to be wrong */
+    switch( ifo->vtsi_mat->vts_video_attr.display_aspect_ratio )
+    {
+        case 0:
+            title->container_aspect = 4. / 3.;
+            break;
+        case 3:
+            title->container_aspect = 16. / 9.;
+            break;
+        default:
+            hb_log( "scan: unknown aspect" );
+            goto fail;
+    }
+
+    hb_log( "scan: aspect = %g", title->aspect );
+
+    /* This title is ok so far */
+    goto cleanup;
+
+fail:
+    hb_list_close( &title->list_audio );
+    free( title );
+    title = NULL;
+
+cleanup:
+    if( ifo ) ifoClose( ifo );
+
+    return title;
+}
+
+/***********************************************************************
+ * hb_dvdnav_start
+ ***********************************************************************
+ * Title and chapter start at 1
+ **********************************************************************/
+static int hb_dvdnav_start( hb_dvd_t * e, hb_title_t *title, int c )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+    int t = title->index;
+    hb_chapter_t *chapter;
+    dvdnav_status_t result;
+
+    d->title_block_count = title->block_count;
+    d->list_chapter = title->list_chapter;
+
+    if ( d->stopped && !hb_dvdnav_reset(d) )
+    {
+        return 0;
+    }
+    chapter = hb_list_item( title->list_chapter, c - 1);
+    if (chapter != NULL)
+        result = dvdnav_program_play(d->dvdnav, t, chapter->pgcn, chapter->pgn);
+    else
+        result = dvdnav_part_play(d->dvdnav, t, 1);
+    if (result != DVDNAV_STATUS_OK)
+    {
+        hb_error( "dvd: dvdnav_*_play failed - %s", 
+                  dvdnav_err_to_string(d->dvdnav) );
+        return 0;
+    }
+    d->title = t;
+    d->stopped = 0;
+    d->chapter = 0;
+    return 1;
+}
+
+/***********************************************************************
+ * hb_dvdnav_stop
+ ***********************************************************************
+ *
+ **********************************************************************/
+static void hb_dvdnav_stop( hb_dvd_t * e )
+{
+}
+
+/***********************************************************************
+ * hb_dvdnav_seek
+ ***********************************************************************
+ *
+ **********************************************************************/
+static int hb_dvdnav_seek( hb_dvd_t * e, float f )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+    uint64_t sector = f * d->title_block_count;
+    int result, event, len;
+    uint8_t buf[HB_DVD_READ_BUFFER_SIZE];
+    int done = 0, ii;
+
+    if (d->stopped)
+    {
+        return 0;
+    }
+
+    // XXX the current version of libdvdnav can't seek outside the current
+    // PGC. Check if the place we're seeking to is in a different
+    // PGC. Position there & adjust the offset if so.
+    hb_chapter_t *pgc_change = hb_list_item(d->list_chapter, 0 );
+    for ( ii = 0; ii < hb_list_count( d->list_chapter ); ++ii )
+    {
+        hb_chapter_t *chapter = hb_list_item( d->list_chapter, ii );
+
+        if ( chapter->pgcn != pgc_change->pgcn )
+        {
+            // this chapter's in a different pgc from the previous - note the
+            // change so we can make sector offset's be pgc relative.
+            pgc_change = chapter;
+        }
+        if ( chapter->block_start <= sector && sector <= chapter->block_end )
+        {
+            // this chapter contains the sector we want - see if it's in a
+            // different pgc than the one we're currently in.
+            int32_t title, pgcn, pgn;
+            if (dvdnav_current_title_program( d->dvdnav, &title, &pgcn, &pgn ) != DVDNAV_STATUS_OK)
+                hb_log("dvdnav cur pgcn err: %s", dvdnav_err_to_string(d->dvdnav));
+            if ( d->title != title || chapter->pgcn != pgcn )
+            {
+                // this chapter is in a different pgc - switch to it.
+                if (dvdnav_program_play(d->dvdnav, d->title, chapter->pgcn, chapter->pgn) != DVDNAV_STATUS_OK)
+                    hb_log("dvdnav prog play err: %s", dvdnav_err_to_string(d->dvdnav));
+            }
+            // seek sectors are pgc-relative so remove the pgc start sector.
+            sector -= pgc_change->block_start;
+            break;
+        }
+    }
+
+    // dvdnav will not let you seek or poll current position
+    // till it reaches a certain point in parsing.  so we
+    // have to get blocks until we reach a cell
+    // Put an arbitrary limit of 100 blocks on how long we search
+    for (ii = 0; ii < 100 && !done; ii++)
+    {
+        result = dvdnav_get_next_block( d->dvdnav, buf, &event, &len );
+        if ( result == DVDNAV_STATUS_ERR )
+        {
+            hb_log("dvdnav: Read Error, %s", dvdnav_err_to_string(d->dvdnav));
+            return 0;
+        }
+        switch ( event )
+        {
+        case DVDNAV_BLOCK_OK:
+        case DVDNAV_CELL_CHANGE:
+            done = 1;
+            break;
+
+        case DVDNAV_STILL_FRAME:
+            dvdnav_still_skip( d->dvdnav );
+            break;
+
+        case DVDNAV_WAIT:
+            dvdnav_wait_skip( d->dvdnav );
+            break;
+
+        case DVDNAV_STOP:
+            hb_log("dvdnav: stop encountered during seek");
+            d->stopped = 1;
+            return 0;
+
+        case DVDNAV_HOP_CHANNEL:
+        case DVDNAV_NAV_PACKET:
+        case DVDNAV_VTS_CHANGE:
+        case DVDNAV_HIGHLIGHT:
+        case DVDNAV_AUDIO_STREAM_CHANGE:
+        case DVDNAV_SPU_STREAM_CHANGE:
+        case DVDNAV_SPU_CLUT_CHANGE:
+        case DVDNAV_NOP:
+        default:
+            break;
+        }
+    }
+
+    if (dvdnav_sector_search(d->dvdnav, sector, SEEK_SET) != DVDNAV_STATUS_OK)
+    {
+        hb_error( "dvd: dvdnav_sector_search failed - %s", 
+                  dvdnav_err_to_string(d->dvdnav) );
+        return 0;
+    }
+    return 1;
+}
+
+/***********************************************************************
+ * hb_dvdnav_read
+ ***********************************************************************
+ *
+ **********************************************************************/
+static int hb_dvdnav_read( hb_dvd_t * e, hb_buffer_t * b )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+    int result, event, len;
+    int chapter = 0;
+    int error_count = 0;
+
+    while ( 1 )
+    {
+        if (d->stopped)
+        {
+            return 0;
+        }
+        result = dvdnav_get_next_block( d->dvdnav, b->data, &event, &len );
+        if ( result == DVDNAV_STATUS_ERR )
+        {
+            hb_log("dvdnav: Read Error, %s", dvdnav_err_to_string(d->dvdnav));
+            if (dvdnav_sector_search(d->dvdnav, 1, SEEK_CUR) != DVDNAV_STATUS_OK)
+            {
+                hb_error( "dvd: dvdnav_sector_search failed - %s",
+                        dvdnav_err_to_string(d->dvdnav) );
+                return 0;
+            }
+            error_count++;
+            if (error_count > 10)
+            {
+                hb_log("dvdnav: Error, too many consecutive read errors");
+                return 0;
+            }
+            continue;
+        }
+        error_count = 0;
+        switch ( event )
+        {
+        case DVDNAV_BLOCK_OK:
+            // We have received a regular block of the currently playing
+            // MPEG stream.
+
+            // The muxers expect to only get chapter 2 and above
+            // They write chapter 1 when chapter 2 is detected.
+            if (chapter > 1)
+                b->new_chap = chapter;
+            chapter = 0;
+            return 1;
+
+        case DVDNAV_NOP:
+            /*
+            * Nothing to do here. 
+            */
+            break;
+
+        case DVDNAV_STILL_FRAME:
+            /*
+            * We have reached a still frame. A real player application
+            * would wait the amount of time specified by the still's
+            * length while still handling user input to make menus and
+            * other interactive stills work. A length of 0xff means an
+            * indefinite still which has to be skipped indirectly by some 
+            * user interaction. 
+            */
+            dvdnav_still_skip( d->dvdnav );
+            break;
+
+        case DVDNAV_WAIT:
+            /*
+            * We have reached a point in DVD playback, where timing is
+            * critical. Player application with internal fifos can
+            * introduce state inconsistencies, because libdvdnav is
+            * always the fifo's length ahead in the stream compared to
+            * what the application sees. Such applications should wait
+            * until their fifos are empty when they receive this type of
+            * event. 
+            */
+            dvdnav_wait_skip( d->dvdnav );
+            break;
+
+        case DVDNAV_SPU_CLUT_CHANGE:
+            /*
+            * Player applications should pass the new colour lookup table 
+            * to their SPU decoder 
+            */
+            break;
+
+        case DVDNAV_SPU_STREAM_CHANGE:
+            /*
+            * Player applications should inform their SPU decoder to
+            * switch channels 
+            */
+            break;
+
+        case DVDNAV_AUDIO_STREAM_CHANGE:
+            /*
+            * Player applications should inform their audio decoder to
+            * switch channels 
+            */
+            break;
+
+        case DVDNAV_HIGHLIGHT:
+            /*
+            * Player applications should inform their overlay engine to
+            * highlight the given button 
+            */
+            break;
+
+        case DVDNAV_VTS_CHANGE:
+            /*
+            * Some status information like video aspect and video scale
+            * permissions do not change inside a VTS. Therefore this
+            * event can be used to query such information only when
+            * necessary and update the decoding/displaying accordingly. 
+            */
+            break;
+
+        case DVDNAV_CELL_CHANGE:
+            /*
+            * Some status information like the current Title and Part
+            * numbers do not change inside a cell. Therefore this event
+            * can be used to query such information only when necessary
+            * and update the decoding/displaying accordingly. 
+            */
+            {
+                int tt = 0, pgcn = 0, pgn = 0, c;
+
+                dvdnav_current_title_program(d->dvdnav, &tt, &pgcn, &pgn);
+                if (tt != d->title)
+                {
+                    // Transition to another title signals that we are done.
+                    return 0;
+                }
+                c = FindChapterIndex(d->list_chapter, pgcn, pgn);
+                if (c != d->chapter)
+                {
+                    if (c < d->chapter)
+                    {
+                        // Some titles end with a 'link' back to the beginning so
+                        // a transition to an earlier chapter means we're done.
+                        return 0;
+                    }
+                    chapter = d->chapter = c;
+                }
+            }
+            break;
+
+        case DVDNAV_NAV_PACKET:
+            /*
+            * A NAV packet provides PTS discontinuity information, angle
+            * linking information and button definitions for DVD menus.
+            * Angles are handled completely inside libdvdnav. For the
+            * menus to work, the NAV packet information has to be passed
+            * to the overlay engine of the player so that it knows the
+            * dimensions of the button areas. 
+            */
+
+            // mpegdemux expects to get these.  I don't think it does
+            // anything useful with them however.
+
+            // The muxers expect to only get chapter 2 and above
+            // They write chapter 1 when chapter 2 is detected.
+            if (chapter > 1)
+                b->new_chap = chapter;
+            chapter = 0;
+            return 1;
+
+            break;
+
+        case DVDNAV_HOP_CHANNEL:
+            /*
+            * This event is issued whenever a non-seamless operation has
+            * been executed. Applications with fifos should drop the
+            * fifos content to speed up responsiveness. 
+            */
+            break;
+
+        case DVDNAV_STOP:
+            /*
+            * Playback should end here. 
+            */
+            d->stopped = 1;
+            return 0;
+
+        default:
+            break;
+        }
+    }
+    return 0;
+}
+
+/***********************************************************************
+ * hb_dvdnav_chapter
+ ***********************************************************************
+ * Returns in which chapter the next block to be read is.
+ * Chapter numbers start at 1.
+ **********************************************************************/
+static int hb_dvdnav_chapter( hb_dvd_t * e )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+    int32_t t, pgcn, pgn;
+    int32_t c;
+
+    if (dvdnav_current_title_program(d->dvdnav, &t, &pgcn, &pgn) != DVDNAV_STATUS_OK)
+    {
+        return -1;
+    }
+    c = FindChapterIndex( d->list_chapter, pgcn, pgn );
+    return c;
+}
+
+/***********************************************************************
+ * hb_dvdnav_close
+ ***********************************************************************
+ * Closes and frees everything
+ **********************************************************************/
+static void hb_dvdnav_close( hb_dvd_t ** _d )
+{
+    hb_dvdnav_t * d = &((*_d)->dvdnav);
+
+    if( d->dvdnav ) dvdnav_close( d->dvdnav );
+    if( d->vmg ) ifoClose( d->vmg );
+    if( d->reader ) DVDClose( d->reader );
+
+    free( d );
+    *_d = NULL;
+}
+
+/***********************************************************************
+ * hb_dvdnav_angle_count
+ ***********************************************************************
+ * Returns the number of angles supported.
+ **********************************************************************/
+static int hb_dvdnav_angle_count( hb_dvd_t * e )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+    int current, angle_count;
+
+    if (dvdnav_get_angle_info( d->dvdnav, &current, &angle_count) != DVDNAV_STATUS_OK)
+    {
+        hb_log("dvdnav_get_angle_info %s", dvdnav_err_to_string(d->dvdnav));
+        angle_count = 1;
+    }
+    return angle_count;
+}
+
+/***********************************************************************
+ * hb_dvdnav_set_angle
+ ***********************************************************************
+ * Sets the angle to read
+ **********************************************************************/
+static void hb_dvdnav_set_angle( hb_dvd_t * e, int angle )
+{
+    hb_dvdnav_t * d = &(e->dvdnav);
+
+    if (dvdnav_angle_change( d->dvdnav, angle) != DVDNAV_STATUS_OK)
+    {
+        hb_log("dvdnav_angle_change %s", dvdnav_err_to_string(d->dvdnav));
+    }
+}
+
+/***********************************************************************
+ * FindChapterIndex
+ ***********************************************************************
+ * Assumes pgc and cell_cur are correctly set, and sets cell_next to the
+ * cell to be read when we will be done with cell_cur.
+ **********************************************************************/
+static int FindChapterIndex( hb_list_t * list, int pgcn, int pgn )
+{
+    int count, ii;
+    hb_chapter_t *chapter;
+
+    count = hb_list_count( list );
+    for (ii = 0; ii < count; ii++)
+    {
+        chapter = hb_list_item( list, ii );
+        if (chapter->pgcn == pgcn && chapter->pgn == pgn)
+            return chapter->index;
+    }
+    return 0;
+}
+
+/***********************************************************************
+ * FindNextCell
+ ***********************************************************************
+ * Assumes pgc and cell_cur are correctly set, and sets cell_next to the
+ * cell to be read when we will be done with cell_cur.
+ **********************************************************************/
+static int FindNextCell( pgc_t *pgc, int cell_cur )
+{
+    int i = 0;
+    int cell_next;
+
+    if( pgc->cell_playback[cell_cur].block_type ==
+            BLOCK_TYPE_ANGLE_BLOCK )
+    {
+
+        while( pgc->cell_playback[cell_cur+i].block_mode !=
+                   BLOCK_MODE_LAST_CELL )
+        {
+             i++;
+        }
+        cell_next = cell_cur + i + 1;
+        hb_log( "dvd: Skipping multi-angle cells %d-%d",
+                cell_cur,
+                cell_next - 1 );
+    }
+    else
+    {
+        cell_next = cell_cur + 1;
+    }
+    return cell_next;
+}
+
+/***********************************************************************
+ * NextPgcn
+ ***********************************************************************
+ * Assumes pgc and cell_cur are correctly set, and sets cell_next to the
+ * cell to be read when we will be done with cell_cur.
+ * Since pg chains can be circularly linked (either from a read error or
+ * deliberately) pgcn_map tracks program chains we've already seen.
+ **********************************************************************/
+static int NextPgcn( ifo_handle_t *ifo, int pgcn, uint32_t pgcn_map[MAX_PGCN/32] )
+{
+    int next_pgcn;
+    pgc_t *pgc;
+
+    pgcn_map[pgcn >> 5] |= (1 << (pgcn & 31));
+
+    pgc = ifo->vts_pgcit->pgci_srp[pgcn-1].pgc;
+    next_pgcn = pgc->next_pgc_nr;
+    if ( next_pgcn < 1 || next_pgcn >= MAX_PGCN || next_pgcn > ifo->vts_pgcit->nr_of_pgci_srp )
+        return 0;
+
+    return pgcn_map[next_pgcn >> 5] & (1 << (next_pgcn & 31))? 0 : next_pgcn;
+}
+
+/***********************************************************************
+ * PgcWalkInit
+ ***********************************************************************
+ * Pgc links can loop. I track which have been visited in a bit vector
+ * Initialize the bit vector to empty.
+ **********************************************************************/
+static void PgcWalkInit( uint32_t pgcn_map[MAX_PGCN/32] )
+{
+    memset(pgcn_map, 0, sizeof(pgcn_map) );
+}
+
+/***********************************************************************
+ * dvdtime2msec
+ ***********************************************************************
+ * From lsdvd
+ **********************************************************************/
+static int dvdtime2msec(dvd_time_t * dt)
+{
+    double frames_per_s[4] = {-1.0, 25.00, -1.0, 29.97};
+    double fps = frames_per_s[(dt->frame_u & 0xc0) >> 6];
+    long   ms;
+    ms  = (((dt->hour &   0xf0) >> 3) * 5 + (dt->hour   & 0x0f)) * 3600000;
+    ms += (((dt->minute & 0xf0) >> 3) * 5 + (dt->minute & 0x0f)) * 60000;
+    ms += (((dt->second & 0xf0) >> 3) * 5 + (dt->second & 0x0f)) * 1000;
+
+    if( fps > 0 )
+    {
+        ms += ((dt->frame_u & 0x30) >> 3) * 5 +
+              (dt->frame_u & 0x0f) * 1000.0 / fps;
+    }
+
+    return ms;
+}
diff --git a/libhb/eedi2.c b/libhb/eedi2.c
new file mode 100644 (file)
index 0000000..2aa906e
--- /dev/null
@@ -0,0 +1,1870 @@
+/* $Id: eedi2.c,v 1.0 2009/03/06 5:00:00 jbrjake Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License.
+   
+   The EEDI2 interpolator was created by tritical:
+   http://web.missouri.edu/~kes25c/
+*/
+
+#include "hb.h"
+#include "eedi2.h"
+
+/**
+ * EEDI2 directional limit lookup table
+ *
+ * These values are used to limit the range of edge direction searches and filtering.
+ */
+const int eedi2_limlut[33] __attribute__ ((aligned (16))) = { 
+                         6, 6, 7, 7, 8, 8, 9, 9, 9, 10,
+                         10, 11, 11, 12, 12, 12, 12, 12, 12, 12,
+                         12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+                         12, -1, -1 };
+
+/**
+ * Analog of _aligned_malloc
+ * @param size Size of memory being pointed to
+ * @param align_size Size of memory chunks to align to (must be power of 2)
+ */
+void *eedi2_aligned_malloc( size_t size, size_t align_size )
+{
+  char * ptr, * ptr2, * aligned_ptr;
+  int align_mask = align_size - 1;
+
+  ptr = (char *)malloc( size + align_size + sizeof( int ) );
+  if( ptr==NULL ) return( NULL );
+
+  ptr2 = ptr + sizeof( int );
+  aligned_ptr = ptr2 + ( align_size - ( (size_t)ptr2 & align_mask ) );
+
+
+  ptr2 = aligned_ptr - sizeof( int );
+  *( (int *)ptr2 ) = (int)( aligned_ptr - ptr );
+
+  return( aligned_ptr );
+}
+
+/**
+ * Analog of _aligned_free
+ * @param ptr The aligned pointer, created with eedi2_aligned_malloc, to be freed
+ */
+void eedi2_aligned_free( void *ptr )
+{
+  int * ptr2 = (int *)ptr - 1;
+  ptr -= * ptr2;
+  free(ptr);
+}
+
+/**
+ * Sorts metrics for median filtering
+ * @param order Pointer to the table of values to sort
+ * @param length Length of the order array
+ */
+void eedi2_sort_metrics( int *order, const int length )
+{
+    int i;
+    for( i = 1; i < length; ++i ) 
+    {
+        int j = i;
+        const int temp = order[j];
+        while( j > 0 && order[j-1] > temp ) 
+        {
+            order[j] = order[j-1];
+            --j;
+        }
+        order[j] = temp;
+    }
+}
+
+/**
+ * Bitblits an image plane (overwrites one bitmap with another) 
+ * @param dtsp Pointer to destination bitmap
+ * @param dst_pitch Stride of destination bitmap
+ * @param srcp Pointer to source bitmap
+ * @param src_pitch Stride of destination bitmap
+ * @param row_size Width of the bitmap being copied
+ * @param height Height of the source bitmap
+ *
+ * When row_size, dst_pitch, and src_pitch are equal, eedi2_bit_blit can work more quickly by copying the whole plane at once instead of individual lines.
+ */
+void eedi2_bit_blit( uint8_t * dstp, int dst_pitch, 
+                     const uint8_t * srcp, int src_pitch,
+                     int row_size, int height )
+{
+    if( ( !height ) || ( !row_size ) ) 
+        return;
+
+    if( height == 1 || ( dst_pitch == src_pitch && src_pitch == row_size ) )
+    {
+        memcpy( dstp, srcp, row_size * height );
+    }
+    else
+    {
+        int y;
+        for( y = height; y > 0; --y )
+        {
+            memcpy( dstp, srcp, row_size );
+            dstp += dst_pitch;
+            srcp += src_pitch;
+        }
+    }
+}
+
+/**
+ * A specialized variant of bit_blit, just for setting up the initial, field-sized bitmap planes that EEDI2 interpolates from.
+ * @param src Pointer to source bitmap plane being copied from
+ * @param dst Pointer to the destination bitmap plane being copied to
+ * @param pitch Stride of both bitmaps
+ * @param height Height of the original, full-size src plane being copied from
+ */
+void eedi2_fill_half_height_buffer_plane( uint8_t * src, uint8_t * dst, int pitch, int height )
+{
+    /* When TFF, we want to copy alternating
+       lines starting at 0, the top field.
+       When BFF, we want to start at line 1. */
+    int y;
+    for( y = height; y > 0; y = y - 2 )
+    {
+      memcpy( dst, src, pitch );
+      dst += pitch;
+      src += pitch * 2;
+    }
+}
+
+/**
+ * A specialized variant of bit_blit, just for resizing the field-height maps EEDI2 generates to frame-height...a simple line doubler
+ * @param srcp Pointer to source bitmap plane being copied from
+ * @param dstp Pointer to the destination bitmap plane being copied to
+ * @param height Height of the input, half-size src plane being copied from
+ * @param pitch Stride of both bitmaps
+ */
+void eedi2_upscale_by_2( uint8_t * srcp, uint8_t * dstp, int height, int pitch )
+{
+    int y;
+    for( y = height; y > 0; y-- )
+    {
+      memcpy( dstp, srcp, pitch );
+      dstp += pitch;
+      memcpy( dstp, srcp, pitch );
+      srcp += pitch;
+      dstp += pitch;
+    }    
+}
+
+/**
+ * Finds places where verticaly adjacent pixels abruptly change in intensity, i.e., sharp edges.
+ * @param dstp Pointer to the destination bitmap
+ * @param dst_pitch Stride of dstp
+ * @param srcp Pointer to the source bitmap
+ * @param src_pitch Stride of srcp
+ * @param mtresh Magnitude threshold, ensures it doesn't mark edges on pixels that are too similar (10 is a good default value)
+ * @param vthresh Variance threshold, ensures it doesn't look for edges in highly random pixel blocks (20 is a good default value)
+ * @param lthresh Laplacian threshold, ensures edges are still prominent in the 2nd spatial derivative of the srcp plane (20 is a good default value)
+ * @param height Height of half-height single-field frame
+ * @param width Width of srcp bitmap rows, as opposed to the padded stride in src_pitch
+ */
+void eedi2_build_edge_mask( uint8_t * dstp, int dst_pitch, uint8_t *srcp, int src_pitch,
+                            int mthresh, int lthresh, int vthresh, int height, int width )
+{
+    int x, y;
+    
+    mthresh = mthresh * 10;
+    vthresh = vthresh * 81;
+    
+    memset( dstp, 0, ( height / 2 ) * dst_pitch );
+    
+    srcp += src_pitch;
+    dstp += dst_pitch;
+    unsigned char *srcpp = srcp-src_pitch;
+    unsigned char *srcpn = srcp+src_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width-1; ++x )
+        {
+            if( ( abs( srcpp[x]  -   srcp[x] ) < 10 &&
+                  abs(  srcp[x]  -  srcpn[x] ) < 10 &&
+                  abs( srcpp[x]  -  srcpn[x] ) < 10 )
+              ||
+                ( abs( srcpp[x-1] -  srcp[x-1] ) < 10 &&
+                  abs(  srcp[x-1] - srcpn[x-1] ) < 10 &&
+                  abs( srcpp[x-1] - srcpn[x-1] ) < 10 &&
+                  abs( srcpp[x+1] -  srcp[x+1] ) < 10 &&
+                  abs(  srcp[x+1] - srcpn[x+1] ) < 10 &&
+                  abs( srcpp[x+1] - srcpn[x+1] ) < 10) )
+                continue;
+            
+            const int sum = srcpp[x-1] + srcpp[x] + srcpp[x+1] +
+                             srcp[x-1] +  srcp[x]+   srcp[x+1] +
+                            srcpn[x-1] + srcpn[x] + srcpn[x+1];
+            
+            const int sumsq = srcpp[x-1] * srcpp[x-1] +
+                              srcpp[x]   * srcpp[x]   +
+                              srcpp[x+1] * srcpp[x+1] +
+                               srcp[x-1] *  srcp[x-1] +
+                               srcp[x]   *  srcp[x]   +
+                               srcp[x+1] *  srcp[x+1] +
+                              srcpn[x-1] * srcpn[x-1] +
+                              srcpn[x]   * srcpn[x]   +
+                              srcpn[x+1] * srcpn[x+1];
+
+            if( 9 * sumsq-sum * sum < vthresh )
+                continue;
+            
+            const int Ix = srcp[x+1] - srcp[x-1];
+            const int Iy = MAX( MAX( abs( srcpp[x] - srcpn[x] ),
+                                     abs( srcpp[x] -  srcp[x] ) ),
+                                abs( srcp[x] - srcpn[x] ) );
+            if( Ix * Ix + Iy * Iy >= mthresh )
+            {
+                dstp[x] = 255;
+                continue;
+            }
+
+            const int Ixx =  srcp[x-1] - 2 * srcp[x] +  srcp[x+1];
+            const int Iyy = srcpp[x]   - 2 * srcp[x] + srcpn[x];
+            if( abs( Ixx ) + abs( Iyy ) >= lthresh )
+                dstp[x] = 255;
+        }
+        dstp += dst_pitch;
+        srcpp += src_pitch;
+        srcp += src_pitch;
+        srcpn += src_pitch;
+    }
+}
+
+/**
+ * Expands and smooths out the edge mask
+ * @param mskp Pointer to the source edge mask being read from
+ * @param msk_pitch Stride of mskp
+ * @param dstp Pointer to the destination to store the dilated edge mask
+ * @param dst_pitch Stride of dstp
+ * @param dstr Dilation threshold, ensures a pixel is only retained as an edge in dstp if this number of adjacent pixels or greater are also edges in mskp (4 is a good default value)
+ * @param height Height of half-height field-sized frame
+ * @param width Width of mskp bitmap rows, as opposed to the pdded stride in msk_pitch
+ */
+void eedi2_dilate_edge_mask( uint8_t *mskp, int msk_pitch, uint8_t *dstp, int dst_pitch,
+                             int dstr, int height, int width )
+{
+    int x, y;
+    
+    eedi2_bit_blit( dstp, dst_pitch, mskp, msk_pitch, width, height );
+    
+    mskp += msk_pitch;
+    unsigned char *mskpp = mskp - msk_pitch;
+    unsigned char *mskpn = mskp + msk_pitch;
+    dstp += dst_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0 )
+                continue;
+
+            int count = 0;
+            if( mskpp[x-1] == 0xFF ) ++count;
+            if( mskpp[x]   == 0xFF ) ++count;
+            if( mskpp[x+1] == 0xFF ) ++count;
+            if(  mskp[x-1] == 0xFF ) ++count;
+            if(  mskp[x+1] == 0xFF ) ++count;
+            if( mskpn[x-1] == 0xFF ) ++count;
+            if( mskpn[x]   == 0xFF ) ++count;
+            if( mskpn[x+1] == 0xFF ) ++count;
+                
+            if( count >= dstr )
+                dstp[x] = 0xFF;
+        }
+        mskpp += msk_pitch;
+        mskp += msk_pitch;
+        mskpn += msk_pitch;
+        dstp += dst_pitch;
+    }
+}
+
+/**
+ * Contracts the edge mask
+ * @param mskp Pointer to the source edge mask being read from
+ * @param msk_pitch Stride of mskp
+ * @param dstp Pointer to the destination to store the eroded edge mask
+ * @param dst_pitch Stride of dstp
+ * @param estr Erosion threshold, ensures a pixel isn't retained as an edge in dstp if fewer than this number of adjacent pixels are also edges in mskp (2 is a good default value)
+ * @param height Height of half-height field-sized frame
+ * @param width Width of mskp bitmap rows, as opposed to the pdded stride in msk_pitch
+ */
+void eedi2_erode_edge_mask( uint8_t *mskp, int msk_pitch, uint8_t *dstp, int dst_pitch,
+                            int estr, int height, int width )
+{
+    int x, y;
+    
+    eedi2_bit_blit( dstp, dst_pitch, mskp, msk_pitch, width, height );
+    
+    mskp += msk_pitch;
+    unsigned char *mskpp = mskp - msk_pitch;
+    unsigned char *mskpn = mskp + msk_pitch;
+    dstp += dst_pitch;
+    for ( y = 1; y < height - 1; ++y )
+    {
+        for ( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0xFF ) continue;
+            
+            int count = 0;
+            if  ( mskpp[x-1] == 0xFF ) ++count;
+            if  ( mskpp[x]   == 0xFF ) ++count;
+            if  ( mskpp[x+1] == 0xFF ) ++count;
+            if  (  mskp[x-1] == 0xFF ) ++count;
+            if  (  mskp[x+1] == 0xFF ) ++count;
+            if  ( mskpn[x-1] == 0xFF ) ++count;
+            if  ( mskpn[x]   == 0xFF ) ++count;
+            if  ( mskpn[x+1] == 0xFF ) ++count;
+
+            if  ( count < estr) dstp[x] = 0;
+        }
+        mskpp += msk_pitch;
+        mskp += msk_pitch;
+        mskpn += msk_pitch;
+        dstp += dst_pitch;
+    }
+}
+
+/**
+ * Smooths out horizontally aligned holes in the mask
+ *
+ * If none of the 6 horizontally adjacent pixels are edges, mark the current pixel as not edged.
+ * If at least 1 of the 3 on either side are edges, mark the current pixel as an edge.
+ *
+ * @param mskp Pointer to the source edge mask being read from
+ * @param msk_pitch Stride of mskp
+ * @param dstp Pointer to the destination to store the smoothed edge mask
+ * @param dst_pitch Stride of dstp
+ * @param height Height of half-height field-sized frame
+ * @param width Width of mskp bitmap rows, as opposed to the pdded stride in msk_pitch
+ */
+void eedi2_remove_small_gaps( uint8_t * mskp, int msk_pitch, uint8_t * dstp, int dst_pitch, 
+                              int height, int width )
+{
+    int x, y;
+    
+    eedi2_bit_blit( dstp, dst_pitch, mskp, msk_pitch, width, height );
+    
+    mskp += msk_pitch;
+    dstp += dst_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 3; x < width - 3; ++x )
+        {
+            if( mskp[x] )
+            {
+                if( mskp[x-3] ) continue;
+                if( mskp[x-2] ) continue;
+                if( mskp[x-1] ) continue;
+                if( mskp[x+1] ) continue;
+                if( mskp[x+2] ) continue;
+                if( mskp[x+3] ) continue;
+                dstp[x] = 0;
+            }
+            else
+            {
+                if ( ( mskp[x+1] && ( mskp[x-1] || mskp[x-2] || mskp[x-3] ) ) ||
+                     ( mskp[x+2] && ( mskp[x-1] || mskp[x-2] ) ) ||
+                     ( mskp[x+3] && mskp[x-1] ) )
+                    dstp[x] = 0xFF;
+            }
+        }
+        mskp += msk_pitch;
+        dstp += dst_pitch;
+    }
+}
+
+/**
+ * Calculates spatial direction vectors for the edges. This is EEDI2's timesink, and can be thought of as YADIF_CHECK on steroids, as both try to discern which angle a given edge follows
+ * @param plane The plane of the image being processed, to know to reduce maxd for chroma planes (HandBrake only works with YUV420 video so it is assumed they are half-height)
+ * @param mskp Pointer to the source edge mask being read from
+ * @param msk_pitch Stride of mskp
+ * @param srcp Pointer to the source image being filtered
+ * @param src_pitch Stride of srcp
+ * @param dstp Pointer to the destination to store the dilated edge mask
+ * @param dst_pitch Stride of dstp
+ * @param maxd Maximum pixel distance to search (24 is a good default value)
+ * @param nt Noise threshold (50 is a good default value)
+ * @param height Height of half-height field-sized frame
+ * @param width Width of srcp bitmap rows, as opposed to the pdded stride in src_pitch
+ */
+void eedi2_calc_directions( const int plane, uint8_t * mskp, int msk_pitch, uint8_t * srcp, int src_pitch,
+                            uint8_t * dstp, int dst_pitch, int maxd, int nt, int height, int width  )
+{
+    int x, y, u, i;
+    
+    memset( dstp, 255, dst_pitch * height );
+    mskp += msk_pitch;
+    dstp += dst_pitch;
+    srcp += src_pitch;
+    unsigned char *src2p = srcp - src_pitch * 2;
+    unsigned char *srcpp = srcp - src_pitch;
+    unsigned char *srcpn = srcp + src_pitch;
+    unsigned char *src2n = srcp + src_pitch * 2;
+    unsigned char *mskpp = mskp - msk_pitch;
+    unsigned char *mskpn = mskp + msk_pitch;
+    const int maxdt = plane == 0 ? maxd : ( maxd >> 1 );
+
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0xFF || ( mskp[x-1] != 0xFF && mskp[x+1] != 0xFF ) )
+                continue;
+            const int startu = MAX( -x + 1, -maxdt );
+            const int stopu = MIN( width - 2 - x, maxdt );
+            int minb = MIN( 13 * nt,
+                            ( abs( srcp[x] - srcpn[x] ) +
+                              abs( srcp[x] - srcpp[x] ) ) * 6 );
+            int mina = MIN( 19 * nt,
+                            ( abs( srcp[x] - srcpn[x] ) +
+                              abs( srcp[x] - srcpp[x] ) ) * 9 );
+            int minc = mina;
+            int mind = minb;
+            int mine = minb;
+            int dira = -5000, dirb = -5000, dirc = -5000, dird = -5000, dire = -5000;
+            for( u = startu; u <= stopu; ++u )
+            {
+                if( y == 1 ||
+                      mskpp[x-1+u] == 0xFF || mskpp[x+u] == 0xFF || mskpp[x+1+u] == 0xFF )
+                {
+                    if( y == height - 2 ||
+                        mskpn[x-1-u] == 0xFF || mskpn[x-u] == 0xFF || mskpn[x+1-u] == 0xFF )
+                    {
+                        const int diffsn = abs(  srcp[x-1] - srcpn[x-1-u] ) +
+                                           abs(  srcp[x]   - srcpn[x-u] )   +
+                                           abs(  srcp[x+1] - srcpn[x+1-u] );
+
+                        const int diffsp = abs(  srcp[x-1] - srcpp[x-1+u] ) +
+                                           abs(  srcp[x]   - srcpp[x+u] )   +
+                                           abs(  srcp[x+1] - srcpp[x+1+u] );
+
+                        const int diffps = abs( srcpp[x-1] -  srcp[x-1-u] ) +
+                                           abs( srcpp[x]   -  srcp[x-u] )   +
+                                           abs( srcpp[x+1] -  srcp[x+1-u] );
+
+                        const int diffns = abs( srcpn[x-1] -  srcp[x-1+u] ) +
+                                           abs( srcpn[x]   -  srcp[x+u] )   +
+                                           abs( srcpn[x+1] -  srcp[x+1+u] );
+
+                        const int diff = diffsn + diffsp + diffps + diffns;
+                        int diffd = diffsp + diffns;
+                        int diffe = diffsn + diffps;
+                        if( diff < minb )
+                        {
+                            dirb = u;
+                            minb = diff;
+                        }
+                        if( __builtin_expect( y > 1, 1) )
+                        {
+                            const int diff2pp = abs( src2p[x-1] - srcpp[x-1-u] ) +
+                                            abs( src2p[x]   - srcpp[x-u] )   +
+                                            abs( src2p[x+1] - srcpp[x+1-u] );
+                            const int diffp2p = abs( srcpp[x-1] - src2p[x-1+u] ) + 
+                                            abs( srcpp[x]   - src2p[x+u] )   + 
+                                            abs( srcpp[x+1] - src2p[x+1+u] );
+                            const int diffa = diff + diff2pp + diffp2p;
+                            diffd += diffp2p;
+                            diffe += diff2pp;
+                            if( diffa < mina )
+                            {
+                                dira = u;
+                                mina = diffa;
+                            }
+                        }
+                        if( __builtin_expect( y < height-2, 1) )
+                        {
+                            const int diff2nn = abs( src2n[x-1] - srcpn[x-1+u] ) +
+                                                abs( src2n[x]   - srcpn[x+u] )   +
+                                                abs( src2n[x+1] - srcpn[x+1+u] );
+                            const int diffn2n = abs( srcpn[x-1] - src2n[x-1-u] ) +
+                                                abs( srcpn[x]   - src2n[x-u] )   +
+                                                abs( srcpn[x+1] - src2n[x+1-u] );
+                            const int diffc = diff + diff2nn + diffn2n;
+                            diffd += diff2nn;
+                            diffe += diffn2n;
+                            if( diffc < minc )
+                            {
+                                dirc = u;
+                                minc = diffc;
+                            }
+                        }
+                        if( diffd < mind )
+                        {
+                            dird = u;
+                            mind = diffd;
+                        }
+                        if( diffe < mine )
+                        {
+                            dire = u;
+                            mine = diffe;
+                        }
+                    }
+                }
+            }
+            int order[5], k=0;
+            if( dira != -5000 ) order[k++] = dira;
+            if( dirb != -5000 ) order[k++] = dirb;
+            if( dirc != -5000 ) order[k++] = dirc;
+            if( dird != -5000 ) order[k++] = dird;
+            if( dire != -5000 ) order[k++] = dire;
+            if( k > 1 )
+            {
+                eedi2_sort_metrics( order, k );
+                const int mid = ( k & 1 ) ? 
+                                    order[k>>1] :
+                                    ( order[(k-1)>>1] + order[k>>1] + 1 ) >> 1;
+                const int tlim = MAX( eedi2_limlut[abs(mid)] >> 2, 2 );
+                int sum = 0, count = 0;
+                for( i = 0; i < k; ++i )
+                {
+                    if( abs( order[i] - mid ) <= tlim )
+                    {
+                        ++count;
+                        sum += order[i];
+                    }
+                }
+                if( count > 1 ) 
+                    dstp[x] = 128 + ( (int)( (float)sum / (float)count ) * 4 );
+                else
+                    dstp[x] = 128;
+            }
+            else dstp[x] = 128;
+        }
+        mskpp += msk_pitch;
+        mskp += msk_pitch;
+        mskpn += msk_pitch;
+        src2p += src_pitch;
+        srcpp += src_pitch;
+        srcp += src_pitch;
+        srcpn += src_pitch;
+        src2n += src_pitch;
+        dstp += dst_pitch;
+    }
+}
+
+/**
+ * Filters the edge mask
+ * @param mskp Pointer to the source edge mask being read from
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the filtered edge mask
+ * @param dst_pitch Stride of dstp
+ * @param height Height of half-height field-sized frame
+ * @param width Width of mskp bitmap rows, as opposed to the pdded stride in msk_pitch
+ */
+void eedi2_filter_map( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                       uint8_t * dstp, int dst_pitch, int height, int width )
+{
+    int x, y, j;
+
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+    
+    mskp += msk_pitch;
+    dmskp += dmsk_pitch;
+    dstp += dst_pitch;
+    unsigned char *dmskpp = dmskp - dmsk_pitch;
+    unsigned char *dmskpn = dmskp + dmsk_pitch;
+
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( dmskp[x] == 0xFF || mskp[x] != 0xFF )
+                continue;
+            const int dir = ( dmskp[x] - 128 ) >> 2;
+            const int lim = MAX( abs( dir ) * 2, 12 );
+            int ict = 0, icb = 0;
+            if( dir < 0 )
+            {
+                const int dirt = MAX( -x, dir );
+                for( j = dirt; j <= 0; ++j )
+                {
+                    if( ( abs( dmskpp[x+j] - dmskp[x] ) > lim && dmskpp[x+j] != 0xFF ) ||
+                        ( dmskp[x+j] == 0xFF && dmskpp[x+j] == 0xFF ) ||
+                        ( abs(  dmskp[x+j] - dmskp[x] ) > lim &&  dmskp[x+j] != 0xFF ) )
+                    {
+                        ict = 1;
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                const int dirt = MIN( width - x - 1, dir );
+                for( j = 0; j <= dirt; ++j )
+                {
+                    if( ( abs( dmskpp[x+j] - dmskp[x] ) > lim && dmskpp[x+j] != 0xFF ) ||
+                        ( dmskp[x+j] == 0xFF && dmskpp[x+j] == 0xFF ) ||
+                        ( abs(  dmskp[x+j] - dmskp[x] ) > lim &&  dmskp[x+j] != 0xFF ) )
+                    {
+                        ict = 1;
+                        break;
+                    }
+                }
+            }
+            if( ict )
+            {
+                if( dir < 0 )
+                {
+                    const int dirt = MIN( width - x - 1, abs( dir ) );
+                    for( j = 0; j <= dirt; ++j )
+                    {
+                        if( ( abs( dmskpn[x+j] - dmskp[x] ) > lim && dmskpn[x+j] != 0xFF ) ||
+                            ( dmskpn[x+j] == 0xFF && dmskp[x+j] == 0xFF ) ||
+                            ( abs(  dmskp[x+j] - dmskp[x] ) > lim &&  dmskp[x+j] != 0xFF ) )
+                        {
+                            icb = 1;
+                            break;
+                        }
+                    }
+                }
+                else
+                {
+                    const int dirt = MAX( -x, -dir );
+                    for( j = dirt; j <= 0; ++j )
+                    {
+                        if( ( abs( dmskpn[x+j] - dmskp[x] ) > lim && dmskpn[x+j] != 0xFF ) ||
+                            ( dmskpn[x+j] == 0xFF && dmskp[x+j] == 0xFF ) ||
+                            ( abs(  dmskp[x+j] - dmskp[x] ) > lim &&  dmskp[x+j] != 0xFF ) )
+                        {
+                            icb = 1;
+                            break;
+                        }
+                    }
+                }
+                if( icb )
+                    dstp[x] = 255;
+            }
+        }
+        mskp += msk_pitch;
+        dmskpp += dmsk_pitch;
+        dmskp += dmsk_pitch;
+        dmskpn += dmsk_pitch;
+        dstp += dst_pitch;
+    }
+}
+
+
+/**
+ * Filters the edge direction mask
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the filtered edge direction mask
+ * @param dst_pitch Stride of dstp
+ * @param height Height of half_height field-sized frame
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_filter_dir_map( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                           uint8_t * dstp, int dst_pitch, int height, int width )
+{
+    int x, y, i;
+    
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+    
+    dmskp += dmsk_pitch;
+    unsigned char *dmskpp = dmskp - dmsk_pitch;
+    unsigned char *dmskpn = dmskp + dmsk_pitch;
+    dstp += dst_pitch;
+    mskp += msk_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0xFF ) continue;
+            int u = 0, order[9];
+            if( dmskpp[x-1] != 0xFF ) order[u++] = dmskpp[x-1];
+            if( dmskpp[x]   != 0xFF ) order[u++] = dmskpp[x];
+            if( dmskpp[x+1] != 0xFF ) order[u++] = dmskpp[x+1];
+            if(  dmskp[x-1] != 0xFF ) order[u++] =  dmskp[x-1];
+            if(  dmskp[x]   != 0xFF ) order[u++] =  dmskp[x];
+            if(  dmskp[x+1] != 0xFF ) order[u++] =  dmskp[x+1];
+            if( dmskpn[x-1] != 0xFF ) order[u++] = dmskpn[x-1];
+            if( dmskpn[x]   != 0xFF ) order[u++] = dmskpn[x];
+            if( dmskpn[x+1] != 0xFF ) order[u++] = dmskpn[x+1];
+            if( u < 4 )
+            {
+                dstp[x] = 255;
+                continue;
+            }
+            eedi2_sort_metrics( order, u );
+            const int mid = ( u & 1 ) ?
+                order[u>>1] : ( order[(u-1)>>1] + order[u>>1] + 1 ) >> 1;
+            int sum = 0, count = 0;
+            const int lim = eedi2_limlut[abs(mid-128)>>2];
+            for( i = 0; i < u; ++i )
+            {
+                if( abs( order[i] - mid ) <= lim )
+                {
+                    ++count;
+                    sum += order[i];
+                }
+            }
+            if( count < 4 || ( count < 5 && dmskp[x] == 0xFF ) )
+            {
+                dstp[x] = 255;
+                continue;
+            }
+            dstp[x] = (int)( ( (float)( sum + mid ) / (float)( count + 1 ) ) + 0.5f );
+        }
+        dmskpp += dmsk_pitch;
+        dmskp += dmsk_pitch;
+        dmskpn += dmsk_pitch;
+        dstp += dst_pitch;
+        mskp += msk_pitch;
+    }
+}
+
+/**
+ * Smoothes out the edge direction map
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the expanded edge direction mask
+ * @param dst_pitch Stride of dstp
+ * @param height Height of half-height field-sized frame
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_expand_dir_map( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                           uint8_t * dstp, int dst_pitch, int height, int width )
+{
+    int x, y, i;
+
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+    
+    dmskp += dmsk_pitch;
+    unsigned char *dmskpp = dmskp - dmsk_pitch;
+    unsigned char *dmskpn = dmskp + dmsk_pitch;
+    dstp += dst_pitch;
+    mskp += msk_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( dmskp[x] != 0xFF || mskp[x] != 0xFF ) continue;
+            int u = 0, order[9];
+            if( dmskpp[x-1] != 0xFF ) order[u++] = dmskpp[x-1];
+            if( dmskpp[x]   != 0xFF ) order[u++] = dmskpp[x];
+            if( dmskpp[x+1] != 0xFF ) order[u++] = dmskpp[x+1];
+            if(  dmskp[x-1] != 0xFF ) order[u++] =  dmskp[x-1];
+            if(  dmskp[x+1] != 0xFF ) order[u++] =  dmskp[x+1];
+            if( dmskpn[x-1] != 0xFF ) order[u++] = dmskpn[x-1];
+            if( dmskpn[x]   != 0xFF ) order[u++] = dmskpn[x];
+            if( dmskpn[x+1] != 0xFF ) order[u++] = dmskpn[x+1];
+            if( u < 5 ) continue;
+            eedi2_sort_metrics( order, u );
+            const int mid = ( u & 1 ) ?
+                order[u>>1] : ( order[(u-1)>>1] + order[u>>1] + 1 ) >> 1;
+            int sum = 0, count = 0;
+            const int lim = eedi2_limlut[abs(mid-128)>>2];
+            for( i = 0; i < u; ++i )
+            {
+                if( abs( order[i] - mid ) <= lim )
+                {
+                    ++count;
+                    sum += order[i];
+                }
+            }
+            if( count < 5 ) continue;
+            dstp[x] = (int)( ( (float)( sum + mid ) / (float)( count + 1 ) ) + 0.5f );
+        }
+        dmskpp += dmsk_pitch;
+        dmskp += dmsk_pitch;
+        dmskpn += dmsk_pitch;
+        dstp += dst_pitch;
+        mskp += msk_pitch;
+    }
+}
+
+/**
+ * Re-draws a clearer, less blocky frame-height edge direction mask
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the redrawn direction mask
+ * @param dst_pitch Stride of dstp
+ * @param tff Whether or not the frame parity is Top Field First
+ * @param height Height of the full-frame output
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_mark_directions_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                               uint8_t * dstp, int dst_pitch, int tff, int height, int width )
+{
+    int x, y, i;
+    memset( dstp, 255, dst_pitch * height );
+    dstp  += dst_pitch  * ( 2 - tff );
+    dmskp += dmsk_pitch * ( 1 - tff );
+    mskp  += msk_pitch  * ( 1 - tff );
+    unsigned char *dmskpn = dmskp + dmsk_pitch * 2;
+    unsigned char *mskpn = mskp + msk_pitch * 2;
+    for( y = 2 - tff; y < height - 1; y += 2 )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0xFF && mskpn[x] != 0xFF ) continue;
+            int v = 0, order[6];
+            if(  dmskp[x-1] != 0xFF ) order[v++] = dmskp[x-1];
+            if(  dmskp[x]   != 0xFF ) order[v++] = dmskp[x];
+            if(  dmskp[x+1] != 0xFF ) order[v++] = dmskp[x+1];
+            if( dmskpn[x-1] != 0xFF ) order[v++] = dmskpn[x-1];
+            if( dmskpn[x]   != 0xFF ) order[v++] = dmskpn[x];
+            if( dmskpn[x+1] != 0xFF ) order[v++] = dmskpn[x+1];
+            if( v < 3 ) continue;
+            else
+            {
+                eedi2_sort_metrics( order, v );
+                const int mid = ( v & 1 ) ? order[v>>1] : ( order[(v-1)>>1] + order[v>>1]+1) >> 1;
+                const int lim = eedi2_limlut[abs(mid-128)>>2];
+                int u = 0;
+                if( abs( dmskp[x-1] - dmskpn[x-1] ) <= lim ||
+                    dmskp[x-1] == 0xFF || dmskpn[x-1] == 0xFF )
+                        ++u;
+                if( abs( dmskp[x]   - dmskpn[x] )   <= lim ||
+                    dmskp[x]   == 0xFF || dmskpn[x]   == 0xFF )
+                        ++u;
+                if( abs( dmskp[x+1] - dmskpn[x-1] ) <= lim ||
+                    dmskp[x+1] == 0xFF || dmskpn[x+1] == 0xFF)
+                        ++u;
+                if( u < 2 ) continue;
+                int count = 0, sum = 0;
+                for( i = 0; i < v; ++i )
+                {
+                    if( abs( order[i] - mid ) <= lim )
+                    {
+                        ++count;
+                        sum += order[i];
+                    }
+                }
+                if( count < v - 2 || count < 2 ) continue;
+                dstp[x] = (int)( ( (float)( sum + mid ) / (float)( count + 1 ) ) + 0.5f );
+            }
+        }
+        mskp += msk_pitch * 2;
+        mskpn += msk_pitch * 2;
+        dstp += dst_pitch * 2;
+        dmskp += dmsk_pitch * 2;
+        dmskpn += dmsk_pitch * 2;
+    }
+}
+
+/**
+ * Filters the frane-height edge direction mask
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the filtered direction mask
+ * @param dst_pitch Stride of dstp
+ * @param field Field to filter
+ * @param height Height of the full-frame output
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_filter_dir_map_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                              uint8_t * dstp, int dst_pitch, int field, int height, int width )
+{
+    int x, y, i;
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+    dmskp += dmsk_pitch * ( 2 - field );
+    unsigned char *dmskpp = dmskp - dmsk_pitch * 2;
+    unsigned char *dmskpn = dmskp + dmsk_pitch * 2;
+    mskp += msk_pitch * ( 1 - field );
+    unsigned char *mskpn = mskp + msk_pitch * 2;
+    dstp += dst_pitch * ( 2 - field );
+    for( y = 2 - field; y < height - 1; y += 2 )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( mskp[x] != 0xFF && mskpn[x] != 0xFF ) continue;
+            int u = 0, order[9];
+            if( y > 1 )
+            {
+                if( dmskpp[x-1] != 0xFF ) order[u++] = dmskpp[x-1];
+                if( dmskpp[x]   != 0xFF ) order[u++] = dmskpp[x];
+                if( dmskpp[x+1] != 0xFF ) order[u++] = dmskpp[x+1];
+            }
+            if( dmskp[x-1] != 0xFF ) order[u++] = dmskp[x-1];
+            if( dmskp[x]   != 0xFF ) order[u++] = dmskp[x];
+            if( dmskp[x+1] != 0xFF ) order[u++] = dmskp[x+1];
+            if( y < height - 2 )
+            {
+                if( dmskpn[x-1] != 0xFF ) order[u++] = dmskpn[x-1];
+                if( dmskpn[x]   != 0xFF ) order[u++] = dmskpn[x];
+                if( dmskpn[x+1] != 0xFF ) order[u++] = dmskpn[x+1];
+            }
+            if( u < 4 )
+            {
+                dstp[x] = 255;
+                continue;
+            }
+            eedi2_sort_metrics( order, u );
+            const int mid = ( u & 1 ) ? order[u>>1] : (order[(u-1)>>1] + order[u>>1] + 1 ) >> 1;
+            int sum = 0, count = 0;
+            const int lim = eedi2_limlut[abs(mid-128)>>2];
+            for( i = 0; i < u; ++i )
+            {
+                if( abs( order[i] - mid ) <= lim )
+                {
+                    ++count;
+                    sum += order[i];
+                }
+            }
+            if( count < 4 || ( count < 5 && dmskp[x] == 0xFF ) )
+            {
+                dstp[x] = 255;
+                continue;
+            }
+            dstp[x] = (int)( ( (float)( sum + mid ) / (float)( count + 1 ) ) + 0.5f );
+        }
+        mskp += msk_pitch * 2;
+        mskpn += msk_pitch * 2;
+        dmskpp += dmsk_pitch * 2;
+        dmskp += dmsk_pitch * 2;
+        dmskpn += dmsk_pitch * 2;
+        dstp += dst_pitch * 2;
+    }
+}
+
+/**
+ * Smoothes out the frame-height edge direction mask
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the expanded direction mask
+ * @param dst_pitch Stride of dstp
+ * @param field Field to filter
+ * @param height Height of the full-frame output
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_expand_dir_map_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                              uint8_t * dstp, int dst_pitch, int field, int height, int width )
+{
+    int x, y, i;
+
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+
+    dmskp += dmsk_pitch * ( 2 - field );
+    unsigned char *dmskpp = dmskp - dmsk_pitch * 2;
+    unsigned char *dmskpn = dmskp + dmsk_pitch * 2;
+    mskp += msk_pitch * ( 1 - field );
+    unsigned char *mskpn = mskp + msk_pitch * 2;
+    dstp += dst_pitch * ( 2 - field );
+    for( y = 2 - field; y < height - 1; y += 2)
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( dmskp[x] != 0xFF || ( mskp[x] != 0xFF && mskpn[x] != 0xFF ) ) continue;
+            int u = 0, order[9];
+            if( y > 1 )
+            {
+                if( dmskpp[x-1] != 0xFF ) order[u++] = dmskpp[x-1];
+                if( dmskpp[x]   != 0xFF ) order[u++] = dmskpp[x];
+                if( dmskpp[x+1] != 0xFF ) order[u++] = dmskpp[x+1];
+            }
+            if( dmskp[x-1] != 0xFF ) order[u++] = dmskp[x-1];
+            if( dmskp[x+1] != 0xFF ) order[u++] = dmskp[x+1];
+            if( y < height - 2 )
+            {
+                if( dmskpn[x-1] != 0xFF) order[u++] = dmskpn[x-1];
+                if( dmskpn[x]   != 0xFF) order[u++] = dmskpn[x];
+                if( dmskpn[x+1] != 0xFF) order[u++] = dmskpn[x+1];
+            }
+            if( u < 5 ) continue;
+            eedi2_sort_metrics( order, u );
+            const int mid = ( u & 1 ) ? order[u>>1] : ( order[(u-1)>>1] + order[u>>1] + 1 ) >> 1;
+            int sum = 0, count = 0;
+            const int lim = eedi2_limlut[abs(mid-128)>>2];
+            for( i = 0; i < u; ++i )
+            {
+                if( abs( order[i] - mid ) <= lim )
+                {
+                    ++count;
+                    sum += order[i];
+                }
+            }
+            if( count < 5 ) continue;
+            dstp[x] = (int)( ( (float)( sum + mid ) / (float)( count + 1 ) ) + 0.5f );
+        }
+        mskp += msk_pitch * 2;
+        mskpn += msk_pitch * 2;
+        dmskpp += dmsk_pitch * 2;
+        dmskp += dmsk_pitch * 2;
+        dmskpn += dmsk_pitch * 2;
+        dstp += dst_pitch * 2;
+    }
+}
+
+/**
+ * Like the name suggests, this function fills in gaps in the frame-height edge direction mask
+ * @param mskp Pointer to the edge mask
+ * @param msk_pitch Stride of mskp
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the destination to store the filled-in direction mask
+ * @param dst_pitch Stride of dstp
+ * @param field Field to filter
+ * @param height Height of the full-frame output
+ * @param width Width of dmskp bitmap rows, as opposed to the pdded stride in dmsk_pitch
+ */
+void eedi2_fill_gaps_2x( uint8_t *mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch,
+                         uint8_t * dstp, int dst_pitch, int field, int height, int width )
+{
+    int x, y, j;
+
+    eedi2_bit_blit( dstp, dst_pitch, dmskp, dmsk_pitch, width, height );
+
+    dmskp += dmsk_pitch * ( 2 - field );
+    unsigned char *dmskpp = dmskp - dmsk_pitch * 2;
+    unsigned char *dmskpn = dmskp + dmsk_pitch * 2;
+    mskp += msk_pitch * ( 1 - field );
+    unsigned char *mskpp = mskp - msk_pitch * 2;
+    unsigned char *mskpn = mskp + msk_pitch * 2;
+    unsigned char *mskpnn = mskpn + msk_pitch * 2;
+    dstp += dst_pitch * ( 2 - field );
+    for( y = 2 - field; y < height - 1; y += 2 )
+    {
+        for( x = 1; x < width - 1; ++x )
+        {
+            if( dmskp[x] != 0xFF || 
+                ( mskp[x] != 0xFF && mskpn[x] != 0xFF ) ) continue;
+            int u = x - 1, back = 500, forward = -500;
+            while( u )
+            {
+                if( dmskp[u] != 0xFF ) 
+                { 
+                    back = dmskp[u]; 
+                    break; 
+                }
+                if( mskp[u] != 0xFF && mskpn[u] != 0xFF ) break;
+                --u;
+            }
+            int v = x + 1;
+            while( v < width )
+            {
+                if( dmskp[v] != 0xFF )
+                {
+                    forward = dmskp[v];
+                    break;
+                }
+                if( mskp[v] != 0xFF && mskpn[v] != 0xFF ) break;
+                ++v;
+            }
+            int tc = 1, bc = 1;
+            int mint = 500, maxt = -20;
+            int minb = 500, maxb = -20;
+            for( j = u; j <= v; ++j )
+            {
+                if( tc )
+                {
+                    if( y <= 2 || dmskpp[j] == 0xFF || ( mskpp[j] != 0xFF && mskp[j] != 0xFF ) )
+                    {
+                        tc = 0;
+                        mint = maxt = 20;
+                    }
+                    else
+                    {
+                        if( dmskpp[j] < mint ) mint = dmskpp[j];
+                        if( dmskpp[j] > maxt ) maxt = dmskpp[j];
+                    }
+                }
+                if( bc )
+                {
+                    if( y >= height - 3 || dmskpn[j] == 0xFF || ( mskpn[j] != 0xFF && mskpnn[j] != 0xFF ) )
+                    {
+                        bc = 0;
+                        minb = maxb = 20;
+                    }
+                    else
+                    {
+                        if( dmskpn[j] < minb ) minb = dmskpn[j];
+                        if( dmskpn[j] > maxb ) maxb = dmskpn[j];
+                    }
+                }
+            }
+            if( maxt == -20 ) maxt = mint = 20;
+            if( maxb == -20 ) maxb = minb = 20;
+            int thresh = MAX(
+                            MAX( MAX( abs( forward - 128 ), abs( back - 128 ) ) >> 2, 8 ),
+                            MAX( abs( mint - maxt ), abs( minb - maxb ) ) );
+            const int flim = MIN(
+                                MAX( abs( forward - 128 ), abs( back - 128 ) ) >> 2,
+                                6 );
+            if( abs( forward - back ) <= thresh && ( v - u - 1 <= flim || tc || bc ) )
+            {
+                double step = (double)( forward - back ) / (double)( v - u );
+                for( j = 0; j < v - u - 1; ++j )
+                    dstp[u+j+1] = back + (int)( j * step + 0.5 );
+            }
+        }
+        mskpp += msk_pitch * 2;
+        mskp += msk_pitch * 2;
+        mskpn += msk_pitch * 2;
+        mskpnn += msk_pitch * 2;
+        dmskpp += dmsk_pitch * 2;
+        dmskp += dmsk_pitch * 2;
+        dmskpn += dmsk_pitch * 2;
+        dstp += dst_pitch * 2;
+    }
+}
+
+/**
+ * Actually renders the output frame, based on the edge and edge direction masks
+ * @param plane The plane of the image being processed, to know to reduce a search distance for chroma planes (HandBrake only works with YUV420 video so it is assumed they are half-height)
+ * @param dmskp Pointer to the edge direction mask being read from
+ * @param dmsk_pitch Stride of dmskp
+ * @param dstp Pointer to the line-doubled source field used being filtered in place
+ * @param dst_pitch Stride of dstp
+ * @param omskp Pointer to the destination to store the output edge mask used for post-processing
+ * @param osmk_pitch Stride of omskp
+ * @param field Field to filter
+ * @nt Noise threshold, (50 is a good default value)
+ * @param height Height of the full-frame output
+ * @param width Width of dstp bitmap rows, as opposed to the pdded stride in dst_pitch
+ */
+void eedi2_interpolate_lattice( const int plane, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                                int dst_pitch, uint8_t * omskp, int omsk_pitch, int field, int nt,
+                                int height, int width )
+{
+    int x, y, u;
+    
+    if( field == 1 )
+    {
+        eedi2_bit_blit( dstp + ( height - 1 ) * dst_pitch,
+                  dst_pitch,
+                  dstp + ( height - 2 ) * dst_pitch,
+                  dst_pitch,
+                  width,
+                  1 );
+    }
+    else
+    {
+        eedi2_bit_blit( dstp,
+                  dst_pitch,
+                  dstp + dst_pitch,
+                  dst_pitch,
+                  width,
+                  1 );
+    }
+
+    dstp += dst_pitch * ( 1 - field );
+    omskp += omsk_pitch * ( 1 - field );
+    unsigned char *dstpn = dstp + dst_pitch;
+    unsigned char *dstpnn = dstp + dst_pitch * 2;
+    unsigned char *omskn = omskp + omsk_pitch * 2;
+    dmskp += dmsk_pitch * ( 2 - field );
+    for( y = 2 - field; y < height - 1; y += 2 )
+    {
+        for( x = 0; x < width; ++x )
+        {
+            int dir = dmskp[x];
+            const int lim = eedi2_limlut[abs(dir-128)>>2];
+            if( dir == 255 ||
+                ( abs( dmskp[x] - dmskp[x-1] ) > lim &&
+                  abs( dmskp[x] - dmskp[x+1] ) > lim ) )
+            {
+                dstpn[x] = ( dstp[x] + dstpnn[x] + 1 ) >> 1;
+                if( dir != 255 ) dmskp[x] = 128;
+                continue;
+            }
+            if( lim < 9 )
+            {
+                const int sum =   dstp[x-1] +   dstp[x] +   dstp[x+1] +
+                                dstpnn[x-1] + dstpnn[x] + dstpnn[x+1];
+                const int sumsq = dstp[x-1] *   dstp[x-1] + 
+                                  dstp[x]   *   dstp[x]   +
+                                  dstp[x+1] *   dstp[x+1] +
+                                dstpnn[x-1] * dstpnn[x-1] +
+                                dstpnn[x]   * dstpnn[x]   +
+                                dstpnn[x+1] * dstpnn[x+1];
+                if( 6 * sumsq - sum * sum < 576 )
+                {
+                    dstpn[x] = ( dstp[x] + dstpnn[x] + 1 ) >> 1;
+                    dmskp[x] = 255;
+                    continue;
+                }
+            }
+            if( x > 1 && x < width - 2 && 
+                (     dstp[x] < MAX(   dstp[x-2],   dstp[x-1] ) - 3 &&
+                      dstp[x] < MAX(   dstp[x+2],   dstp[x+1] ) - 3 &&
+                    dstpnn[x] < MAX( dstpnn[x-2], dstpnn[x-1] ) - 3 &&
+                    dstpnn[x] < MAX( dstpnn[x+2], dstpnn[x+1] ) - 3 )
+                ||
+                (     dstp[x] > MIN(   dstp[x-2],   dstp[x-1] ) + 3 &&
+                      dstp[x] > MIN(   dstp[x+2],   dstp[x+1] ) + 3 &&
+                    dstpnn[x] > MIN( dstpnn[x-2], dstpnn[x-1] ) + 3 &&
+                    dstpnn[x] > MIN( dstpnn[x+2], dstpnn[x+1] ) + 3 ) )
+            {
+                dstpn[x] = ( dstp[x] + dstpnn[x] + 1 ) >> 1;
+                dmskp[x] = 128;
+                continue;
+            }
+            dir = ( dir - 128 + 2 ) >> 2;
+            int val = ( dstp[x] + dstpnn[x] + 1 ) >> 1;
+            const int startu = ( dir - 2 < 0 ) ?
+                        MAX( -x + 1, MAX( dir - 2, -width + 2 + x ) )
+                        :
+                        MIN(  x - 1, MIN( dir - 2,  width - 2 - x ) );
+            const int stopu =  ( dir + 2 < 0 ) ?
+                        MAX( -x + 1, MAX( dir + 2, -width + 2 + x ) )
+                        :
+                        MIN(  x - 1, MIN( dir + 2,  width - 2 - x ) );
+            int min = 8 * nt;
+            for( u = startu; u <= stopu; ++u )
+            {
+                const int diff =
+                    abs(   dstp[x-1] - dstpnn[x-u-1] ) +
+                    abs(   dstp[x]   - dstpnn[x-u] )   +
+                    abs(   dstp[x+1] - dstpnn[x-u+1] ) + 
+                    abs( dstpnn[x-1] -   dstp[x+u-1] ) + 
+                    abs( dstpnn[x]   -   dstp[x+u] )   +
+                    abs( dstpnn[x+1] -   dstp[x+u+1] );
+                if( diff < min && 
+                    ( ( omskp[x-1+u] != 0xFF && abs( omskp[x-1+u] - dmskp[x] ) <= lim ) ||
+                     (  omskp[x+u]   != 0xFF && abs( omskp[x+u]   - dmskp[x]) <= lim )  ||
+                     (  omskp[x+1+u] != 0xFF && abs( omskp[x+1+u] - dmskp[x]) <= lim ) ) &&
+                    ( ( omskn[x-1-u] != 0xFF && abs( omskn[x-1-u] - dmskp[x]) <= lim ) ||
+                     (  omskn[x-u]   != 0xFF && abs( omskn[x-u]   - dmskp[x]) <= lim ) ||
+                     (  omskn[x+1-u] != 0xFF && abs( omskn[x+1-u] - dmskp[x]) <= lim ) ) )
+                {
+                    const int diff2 = 
+                        abs( dstp[x+(u>>1)-1] - dstpnn[x-(u>>1)-1] ) +
+                        abs( dstp[x+(u>>1)]   - dstpnn[x-(u>>1)]   ) +
+                        abs( dstp[x+(u>>1)+1] - dstpnn[x-(u>>1)+1] );
+                    if( diff2 < 4 * nt &&
+                        ( ( ( abs( omskp[x+(u>>1)] - omskn[x-(u>>1)]     ) <= lim ||
+                              abs( omskp[x+(u>>1)] - omskn[x-((u+1)>>1)] ) <= lim ) && 
+                            omskp[x+(u>>1)] != 0xFF )
+                          || 
+                          ( ( abs( omskp[x+((u+1)>>1)] - omskn[x-(u>>1)] )     <= lim ||
+                              abs( omskp[x+((u+1)>>1)] - omskn[x-((u+1)>>1)] ) <= lim ) && 
+                            omskp[x+((u+1)>>1)] != 0xFF ) ) ) 
+                    {
+                        if( ( abs( dmskp[x] - omskp[x+(u>>1)] )     <= lim ||
+                              abs( dmskp[x] - omskp[x+((u+1)>>1)] ) <= lim ) &&
+                            ( abs( dmskp[x] - omskn[x-(u>>1)] )     <= lim ||
+                              abs( dmskp[x] - omskn[x-((u+1)>>1)] ) <= lim ) )
+                        {
+                            val = (   dstp[x+(u>>1)] +   dstp[x+((u+1)>>1)] +
+                                    dstpnn[x-(u>>1)] + dstpnn[x-((u+1)>>1)] + 2 ) >> 2;
+                            min = diff;
+                            dir = u;
+                        }
+                    }
+                }
+            }
+            if( min != 8 * nt )
+            {
+                dstpn[x] = val;
+                dmskp[x] = 128 + dir * 4;
+            }
+            else 
+            {
+                const int minm = MIN( dstp[x], dstpnn[x] );
+                const int maxm = MAX( dstp[x], dstpnn[x] );
+                const int d = plane == 0 ? 4 : 2;
+                const int startu = MAX( -x + 1, -d );
+                const int stopu = MIN( width - 2 - x, d );
+                min = 7 * nt;
+                for( u = startu; u <= stopu; ++u )
+                {
+                    const int p1 =   dstp[x+(u>>1)] +   dstp[x+((u+1)>>1)];
+                    const int p2 = dstpnn[x-(u>>1)] + dstpnn[x-((u+1)>>1)];
+                    const int diff =
+                        abs(   dstp[x-1] - dstpnn[x-u-1] ) + 
+                        abs(   dstp[x]   - dstpnn[x-u] )   +
+                        abs(   dstp[x+1] - dstpnn[x-u+1] ) +
+                        abs( dstpnn[x-1] - dstp[x+u-1] )   + 
+                        abs( dstpnn[x]   - dstp[x+u] )     + 
+                        abs( dstpnn[x+1] - dstp[x+u+1] )   +
+                        abs( p1 - p2 );
+                    if( diff < min )
+                    {
+                        const int valt = ( p1 + p2 + 2 ) >> 2;
+                        if( valt >= minm && valt <= maxm )
+                        {
+                            val = valt;
+                            min = diff;
+                            dir = u;
+                        }
+                    }
+                }
+                dstpn[x] = val;
+                if( min == 7*nt ) dmskp[x] = 128;
+                else dmskp[x] = 128 + dir * 4;
+            }
+        }
+        dstp += dst_pitch * 2;
+        dstpn += dst_pitch * 2;
+        dstpnn += dst_pitch * 2;
+        dmskp += dmsk_pitch * 2;
+        omskp += omsk_pitch * 2;
+        omskn += omsk_pitch * 2;
+    }
+}
+
+/**
+ * Applies some extra filtering to smooth the edge direction mask
+ * @param nmskp Pointer to the newly-filtered edge direction mask being read from
+ * @param nmsk_pitch Stride of nmskp
+ * @param omskp Pointer to the old unfiltered edge direction mask being read from
+ * @param omsk_pitch Stride of osmkp
+ * @param dstp Pointer to the output image being filtered in place
+ * @param src_pitch Stride of dstp ....not sure why it's named this
+ * @param field Field to filter
+ * @param height Height of the full-frame output
+ * @param width Width of dstp bitmap rows, as opposed to the pdded stride in src_pitch
+ */
+void eedi2_post_process( uint8_t * nmskp, int nmsk_pitch, uint8_t * omskp, int omsk_pitch,
+                         uint8_t * dstp, int src_pitch, int field, int height, int width )
+{
+    int x, y;
+    
+    nmskp += ( 2 - field ) * nmsk_pitch;
+    omskp += ( 2 - field ) * omsk_pitch;
+    dstp += ( 2 - field ) * src_pitch;
+    unsigned char *srcpp = dstp - src_pitch;
+    unsigned char *srcpn = dstp + src_pitch;
+    for( y = 2 - field; y < height - 1; y += 2 )
+    {
+        for( x = 0; x < width; ++x )
+        {
+            const int lim = eedi2_limlut[abs(nmskp[x]-128)>>2];
+            if( abs( nmskp[x] - omskp[x] ) > lim && omskp[x] != 255 && omskp[x] != 128 )
+                dstp[x] = ( srcpp[x] + srcpn[x] + 1 ) >> 1;
+        }
+        nmskp += nmsk_pitch * 2;
+        omskp += omsk_pitch * 2;
+        srcpp += src_pitch * 2;
+        dstp += src_pitch * 2;
+        srcpn += src_pitch * 2;
+    }
+}
+
+/**
+ * Blurs the source field plane
+ * @param src Pointer to the half-height source field plane
+ * @param src_pitch Stride of src
+ * @param tmp Pointer to a temporary buffer for juggling bitmaps
+ * @param tmp_pitch Stride of tmp
+ * @param dst Pointer to the destination to store the blurred field plane
+ * @param dst_pitch Stride of dst
+ * @param height Height of the hakf-height field-sized frame
+ * @param width Width of dstp bitmap rows, as opposed to the padded stride in dst_pitch
+ */
+void eedi2_gaussian_blur1( uint8_t * src, int src_pitch, uint8_t * tmp, int tmp_pitch, uint8_t * dst, int dst_pitch, int height, int width )
+{
+    uint8_t * srcp = src;
+    uint8_t * dstp = tmp;
+    int x, y;
+
+    for( y = 0; y < height; ++y )
+    {
+        dstp[0] = ( srcp[3] * 582 + srcp[2] * 7078 + srcp[1] * 31724 + 
+                    srcp[0] * 26152 + 32768 ) >> 16;
+        dstp[1] = ( srcp[4] * 582 + srcp[3] * 7078 +
+                    ( srcp[0] + srcp[2] ) * 15862 +
+                    srcp[1] * 26152 + 32768 ) >> 16;
+        dstp[2] = ( srcp[5] * 582 + ( srcp[0] + srcp[4] ) * 3539 +
+                    ( srcp[1] + srcp[3] ) * 15862 + 
+                    srcp[2]*26152 + 32768 ) >> 16;
+        for( x = 3; x < width - 3; ++x )
+        {
+            dstp[x] = ( ( srcp[x-3] + srcp[x+3] ) * 291 +
+                        ( srcp[x-2] + srcp[x+2] ) * 3539 +
+                        ( srcp[x-1] + srcp[x+1] ) * 15862 +
+                        srcp[x] * 26152 + 32768 ) >> 16;
+        }
+        dstp[x] = ( srcp[x-3] * 582 + ( srcp[x-2] + srcp[x+2] ) * 3539 +
+                    ( srcp[x-1] + srcp[x+1] ) * 15862 +
+                    srcp[x]   * 26152 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x-3] * 582 + srcp[x-2] * 7078 +
+                    ( srcp[x-1] + srcp[x+1] ) * 15862 +
+                    srcp[x] * 26152 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x-3] * 582 + srcp[x-2] * 7078 +
+                    srcp[x-1] * 31724 + srcp[x] * 26152 + 32768 ) >> 16;
+        srcp += src_pitch;
+        dstp += tmp_pitch;
+    }
+    srcp = tmp;
+    dstp = dst;
+    unsigned char *src3p = srcp - tmp_pitch * 3;
+    unsigned char *src2p = srcp - tmp_pitch * 2;
+    unsigned char *srcpp = srcp - tmp_pitch;
+    unsigned char *srcpn = srcp + tmp_pitch;
+    unsigned char *src2n = srcp + tmp_pitch * 2;
+    unsigned char *src3n = srcp + tmp_pitch * 3;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3n[x] * 582 + src2n[x] * 7078 + srcpn[x] * 31724 + 
+                     srcp[x] * 26152 + 32768 ) >> 16;
+    }
+    src3p += tmp_pitch;
+    src2p += tmp_pitch;
+    srcpp += tmp_pitch;
+    srcp += tmp_pitch;
+    srcpn += tmp_pitch;
+    src2n += tmp_pitch;
+    src3n += tmp_pitch;
+    dstp += dst_pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3n[x] * 582 + src2n[x] * 7078 +
+                    ( srcpp[x] + srcpn[x] ) * 15862 +
+                    srcp[x] * 26152 + 32768 ) >> 16;
+    }
+    src3p += tmp_pitch;
+    src2p += tmp_pitch;
+    srcpp += tmp_pitch;
+    srcp += tmp_pitch;
+    srcpn += tmp_pitch;
+    src2n += tmp_pitch;
+    src3n += tmp_pitch;
+    dstp += dst_pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3n[x] * 582 + ( src2p[x] + src2n[x] ) * 3539 + 
+                    ( srcpp[x] + srcpn[x] ) * 15862 +
+                    srcp[x] * 26152 + 32768 ) >> 16;
+    }
+    src3p += src_pitch;
+    src2p += src_pitch;
+    srcpp += src_pitch;
+    srcp += src_pitch;
+    srcpn += src_pitch;
+    src2n += src_pitch;
+    src3n += src_pitch;
+    dstp += dst_pitch;
+    for( y = 3; y < height - 3; ++y )
+    {
+        for( x = 0; x < width; ++x )
+        {
+            dstp[x] = ( ( src3p[x] + src3n[x] ) * 291 +
+                        ( src2p[x] + src2n[x] ) * 3539 +
+                        ( srcpp[x] + srcpn[x] ) * 15862 +
+                        srcp[x] * 26152 + 32768 ) >> 16;
+        }
+        src3p += tmp_pitch;
+        src2p += tmp_pitch;
+        srcpp += tmp_pitch;
+        srcp += tmp_pitch;
+        srcpn += tmp_pitch;
+        src2n += tmp_pitch;
+        src3n += tmp_pitch;
+        dstp += dst_pitch;
+    }
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3p[x] * 582 + ( src2p[x] + src2n[x] ) *3539 +
+                    ( srcpp[x] + srcpn[x] ) * 15862 +
+                    srcp[x] * 26152 + 32768 ) >> 16;
+    }
+    src3p += tmp_pitch;
+    src2p += tmp_pitch;
+    srcpp += tmp_pitch;
+    srcp += tmp_pitch;
+    srcpn += tmp_pitch;
+    src2n += tmp_pitch;
+    src3n += tmp_pitch;
+    dstp += dst_pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3p[x] * 582 + src2p[x] * 7078 +
+                    ( srcpp[x] + srcpn[x] ) * 15862 +
+                     srcp[x] * 26152 + 32768 ) >> 16;
+    }
+    src3p += tmp_pitch;
+    src2p += tmp_pitch;
+    srcpp += tmp_pitch;
+    srcp += tmp_pitch;
+    srcpn += tmp_pitch;
+    src2n += tmp_pitch;
+    src3n += tmp_pitch;
+    dstp += dst_pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src3p[x] * 582   + src2p[x] * 7078 +
+                    srcpp[x] * 31724 +  srcp[x] * 26152 + 32768 ) >> 16;
+    }
+}
+
+
+/**
+ * Blurs the spatial derivatives of the source field plane
+ * @param src Pointer to the derivative array to filter
+ * @param tmp Pointer to a temporary storage for the derivative array while it's being filtered
+ * @param dst Pointer to the destination to store the filtered output derivative array
+ * @param pitch Stride of the bitmap from which the src array is derived
+ * @param height Height of the half-height field-sized frame from which the src array derivs were taken
+ * @param width Width of the bitmap from which the src array is derived, as opposed to the padded stride in pitch
+ */
+void eedi2_gaussian_blur_sqrt2( int *src, int *tmp, int *dst, const int pitch, int height, const int width )
+{
+    int * srcp = src;
+    int * dstp = tmp;
+    int x, y;
+    
+    for( y = 0; y < height; ++y )
+    {
+        x = 0;
+        dstp[x] = ( srcp[x+4] * 678   + srcp[x+3] * 3902  + srcp[x+2] * 13618 +
+                    srcp[x+1] * 28830 + srcp[x]   * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x+4] * 678   + srcp[x+3] * 3902 + srcp[x+2] * 13618 + 
+                    ( srcp[x-1] + srcp[x+1] ) *14415 +
+                    srcp[x]   * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x+4] * 678   + srcp[x+3] * 3902 + 
+                    ( srcp[x-2] + srcp[x+2] ) * 6809 +
+                    ( srcp[x-1] + srcp[x+1] ) * 14415 + 
+                    srcp[x]   * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x+4] * 678   + ( srcp[x-3] + srcp[x+3] ) * 1951 + 
+                    ( srcp[x-2] + srcp[x+2] ) * 6809 +
+                    ( srcp[x-1] + srcp[x+1] ) * 14415 + 
+                    srcp[x]   * 18508 + 32768 ) >> 16;
+
+        for( x = 4; x < width - 4; ++x )
+        {
+            dstp[x] = ( ( srcp[x-4] + srcp[x+4] ) * 339 + 
+                        ( srcp[x-3] + srcp[x+3] ) * 1951 + 
+                        ( srcp[x-2] + srcp[x+2] ) * 6809 +
+                        ( srcp[x-1] + srcp[x+1] ) * 14415 + 
+                        srcp[x] * 18508 + 32768 ) >> 16;
+        }
+
+        dstp[x] = ( srcp[x-4] * 678 + ( srcp[x-3] + srcp[x+3] ) * 1951 + 
+                    ( srcp[x-2] + srcp[x+2] ) * 6809  +
+                    ( srcp[x-1] + srcp[x+1] ) * 14415 + 
+                    srcp[x] * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x-4] * 678 + srcp[x-3] * 3902 + 
+                    ( srcp[x-2] + srcp[x+2] ) * 6809 +
+                    ( srcp[x-1] + srcp[x+1] ) * 14415 + 
+                    srcp[x] * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x-4] * 678 + srcp[x+3] * 3902 + srcp[x-2] * 13618 + 
+                    ( srcp[x-1] + srcp[x+1] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 16;
+        ++x;
+        dstp[x] = ( srcp[x-4] * 678 + srcp[x-3] * 3902 + srcp[x-2] * 13618 + 
+                    srcp[x-1] * 28830 +
+                    srcp[x] * 18508 + 32768 ) >> 16;
+        srcp += pitch;
+        dstp += pitch;
+    }
+    dstp = dst;
+    srcp = tmp;
+    int * src4p = srcp - pitch * 4;
+    int * src3p = srcp - pitch * 3;
+    int * src2p = srcp - pitch * 2;
+    int * srcpp = srcp - pitch;
+    int * srcpn = srcp + pitch;
+    int * src2n = srcp + pitch * 2;
+    int * src3n = srcp + pitch * 3;
+    int * src4n = srcp + pitch * 4;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4n[x] * 678   + src3n[x] * 3902  + 
+                    src2n[x] * 13618 + srcpn[x] * 28830 +
+                     srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4n[x] * 678 + src3n[x] * 3902 + src2n[x] * 13618 + 
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4n[x] * 678 + src3n[x] * 3902 + 
+                    ( src2p[x] + src2n[x] ) * 6809 + 
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4n[x] * 678 + ( src3p[x] + src3n[x] ) * 1951 +
+                    ( src2p[x] + src2n[x] ) * 6809 +
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( y = 4; y < height - 4; ++y )
+    {
+        for( x = 0; x < width; ++x )
+        {
+            dstp[x] = ( ( src4p[x] + src4n[x] ) * 339 +
+                        ( src3p[x] + src3n[x] ) * 1951 +
+                        ( src2p[x] + src2n[x] ) * 6809 +
+                        ( srcpp[x] + srcpn[x] ) * 14415 +
+                        srcp[x] * 18508 + 32768 ) >> 18;
+        }
+        src4p += pitch;
+        src3p += pitch;
+        src2p += pitch;
+        srcpp += pitch;
+        srcp += pitch;
+        srcpn += pitch;
+        src2n += pitch;
+        src3n += pitch;
+        src4n += pitch;
+        dstp += pitch;
+    }
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4p[x] * 678 +
+                    ( src3p[x] + src3n[x] ) * 1951 +
+                    ( src2p[x] + src2n[x] ) * 6809 +
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4p[x] * 678 + src3p[x] * 3902 +
+                    ( src2p[x] + src2n[x] ) * 6809 +
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4p[x] * 678 + src3p[x] * 3902 + src2p[x] * 13618 +
+                    ( srcpp[x] + srcpn[x] ) * 14415 +
+                    srcp[x] * 18508 + 32768 ) >> 18;
+    }
+    src4p += pitch;
+    src3p += pitch;
+    src2p += pitch;
+    srcpp += pitch;
+    srcp += pitch;
+    srcpn += pitch;
+    src2n += pitch;
+    src3n += pitch;
+    src4n += pitch;
+    dstp += pitch;
+    for( x = 0; x < width; ++x )
+    {
+        dstp[x] = ( src4p[x] * 678   + src3p[x] * 3902 +
+                    src2p[x] * 13618 + srcpp[x] * 28830 +
+                    srcp[x]  * 18508 + 32768 ) >> 18;
+    }
+}
+
+/**
+ * Finds spatial derivatives for a a source field plane
+ * @param srcp Pointer to the plane to derive
+ * @param src_pitch Stride of srcp
+ * @param height Height of the half-height field-sized frame
+ * @param width Width of srcp bitmap rows, as opposed to the padded stride in src_pitch
+ * @param x2 Pointed to the array to store the x/x derivatives
+ * @param y2 Pointer to the array to store the y/y derivatives
+ * @param xy Pointer to the array to store the x/y derivatives
+ */
+void eedi2_calc_derivatives( uint8_t *srcp, int src_pitch, int height, int width, int *x2, int *y2, int *xy)
+{
+    
+    unsigned char * srcpp = srcp - src_pitch;
+    unsigned char * srcpn = srcp + src_pitch;
+    int x, y;
+    {
+        const int Ix = srcp[1] -  srcp[0];
+        const int Iy = srcp[0] - srcpn[0];
+        x2[0] = ( Ix * Ix ) >> 1;
+        y2[0] = ( Iy * Iy ) >> 1;
+        xy[0] = ( Ix * Iy ) >> 1;
+    }
+    for( x = 1; x < width - 1; ++x )
+    {
+        const int Ix = srcp[x+1] -  srcp[x-1];
+        const int Iy = srcp[x]   - srcpn[x];
+        x2[x] = ( Ix * Ix ) >> 1;
+        y2[x] = ( Iy * Iy ) >> 1;
+        xy[x] = ( Ix * Iy ) >> 1;
+    }
+    {
+        const int Ix = srcp[x] -  srcp[x-1];
+        const int Iy = srcp[x] - srcpn[x];
+        x2[x] = ( Ix * Ix ) >> 1;
+        y2[x] = ( Iy * Iy ) >> 1;
+        xy[x] = ( Ix * Iy ) >> 1;
+    }
+    srcpp += src_pitch;
+    srcp += src_pitch;
+    srcpn += src_pitch;
+    x2 += src_pitch;
+    y2 += src_pitch;
+    xy += src_pitch;
+    for( y = 1; y < height - 1; ++y )
+    {
+        {
+            const int Ix =  srcp[1] -  srcp[0];
+            const int Iy = srcpp[0] - srcpn[0];
+            x2[0] = ( Ix * Ix ) >> 1;
+            y2[0] = ( Iy * Iy ) >> 1;
+            xy[0] = ( Ix * Iy ) >> 1;
+        }
+        for ( x = 1; x < width - 1; ++x )
+        {
+            const int Ix =  srcp[x+1] -  srcp[x-1];
+            const int Iy = srcpp[x]   - srcpn[x];
+            x2[x] = ( Ix * Ix ) >> 1;
+            y2[x] = ( Iy * Iy ) >> 1;
+            xy[x] = ( Ix * Iy ) >> 1;
+        }
+        {
+            const int Ix =  srcp[x] -  srcp[x-1];
+            const int Iy = srcpp[x] - srcpn[x];
+            x2[x] = ( Ix *Ix ) >> 1;
+            y2[x] = ( Iy *Iy ) >> 1;
+            xy[x] = ( Ix *Iy ) >> 1;
+        }
+        srcpp += src_pitch;
+        srcp += src_pitch;
+        srcpn += src_pitch;
+        x2 += src_pitch;
+        y2 += src_pitch;
+        xy += src_pitch;
+    }
+    {
+        const int Ix =  srcp[1] - srcp[0];
+        const int Iy = srcpp[0] - srcp[0];
+        x2[0] = ( Ix * Ix ) >> 1;
+        y2[0] = ( Iy * Iy ) >> 1;
+        xy[0] = ( Ix * Iy ) >> 1;
+    }
+    for( x = 1; x < width - 1; ++x )
+    {
+        const int Ix =  srcp[x+1] - srcp[x-1];
+        const int Iy = srcpp[x]   - srcp[x];
+        x2[x] = ( Ix * Ix ) >> 1;
+        y2[x] = ( Iy * Iy ) >> 1;
+        xy[x] = ( Ix * Iy ) >> 1;
+    }
+    {
+        const int Ix =  srcp[x] - srcp[x-1];
+        const int Iy = srcpp[x] - srcp[x];
+        x2[x] = ( Ix * Ix ) >> 1;
+        y2[x] = ( Iy * Iy ) >> 1;
+        xy[x] = ( Ix * Iy ) >> 1;
+    }
+}
+
+/**
+ * Filters junctions and corners for the output image
+ * @param x2 Pointer to the x/x derivatives
+ * @param y2 Pointer to the y/y derivatives
+ * @param xy Pointer to the x/y derivatives
+ * @param pitch Stride of the source field plane from which the derivatives were calculated
+ * @param mskp Pointer to the edge direction mask
+ * @param msk_pitch Stride of mskp
+ * @param dstp Pointer to the output image being filtered in place
+ * @param dst_pitch Stride of dstp
+ * @param height Height of the full-frame output plane
+ * @param width Width of dstp bitmap rows, as opposed to the padded stride in dst_pitch
+ * @param field Field to filter
+ */
+void eedi2_post_process_corner( int *x2, int *y2, int *xy, const int pitch, uint8_t * mskp, int msk_pitch, uint8_t * dstp, int dst_pitch, int height, int width, int field )
+{
+    mskp += ( 8 - field ) * msk_pitch;
+    dstp += ( 8 - field ) * dst_pitch;
+    unsigned char * dstpp = dstp - dst_pitch;
+    unsigned char * dstpn = dstp + dst_pitch;
+    x2 += pitch * 3;
+    y2 += pitch * 3;
+    xy += pitch * 3;
+    int *x2n = x2 + pitch;
+    int *y2n = y2 + pitch;
+    int *xyn = xy + pitch;
+    int x, y;
+    
+    for( y = 8 - field; y < height - 7; y += 2 )
+    {
+        for( x = 4; x < width - 4; ++x )
+        {
+            if( mskp[x] == 255 || mskp[x] == 128 ) continue;
+            const int c1 = (int)( x2[x]  *  y2[x] -  xy[x] * xy[x] - 0.09 *
+                                  ( x2[x]  + y2[x] )  * ( x2[x]  + y2[x] ) );
+            const int c2 = (int)( x2n[x] * y2n[x] - xyn[x]* xyn[x] - 0.09 * 
+                                  ( x2n[x] + y2n[x] ) * ( x2n[x] + y2n[x] ) );
+            if (c1 > 775 || c2 > 775)
+                dstp[x] = ( dstpp[x] + dstpn[x] + 1 ) >> 1;
+        }
+        mskp += msk_pitch * 2;
+        dstpp += dst_pitch * 2;
+        dstp += dst_pitch * 2;
+        dstpn += dst_pitch * 2;
+        x2 += pitch;
+        x2n += pitch;
+        y2 += pitch;
+        y2n += pitch;
+        xy += pitch;
+        xyn += pitch;
+    }
+}
diff --git a/libhb/eedi2.h b/libhb/eedi2.h
new file mode 100644 (file)
index 0000000..1df7b11
--- /dev/null
@@ -0,0 +1,84 @@
+// Used to order a sequeunce of metrics for median filtering
+void eedi2_sort_metrics( int *order, const int length );
+
+// Aping some Windows API funcctions AviSynth seems to like
+// Taken from here: http://www.gidforums.com/t-8543.html
+void *eedi2_aligned_malloc(size_t size, size_t align_size);
+void eedi2_aligned_free(void *ptr);
+
+// Copies bitmaps
+void eedi2_bit_blit( uint8_t * dstp, int dst_pitch, const uint8_t * srcp, int src_pitch,
+                     int row_size, int height );
+
+// Sets up the initial field-sized bitmap EEDI2 interpolates from
+void eedi2_fill_half_height_buffer_plane( uint8_t * src, uint8_t * dst, int pitch, int height );
+
+// Simple line doubler
+void eedi2_upscale_by_2( uint8_t * srcp, uint8_t * dstp, int height, int pitch );
+
+// Finds places where vertically adjacent pixels abruptly change intensity
+void eedi2_build_edge_mask( uint8_t * dstp, int dst_pitch, uint8_t *srcp, int src_pitch,
+                            int mthresh, int lthresh, int vthresh, int height, int width );
+
+// Expands and smooths out the edge mask by considering a pixel
+// to be masked if >= dilation threshold adjacent pixels are masked.
+void eedi2_dilate_edge_mask( uint8_t *mskp, int msk_pitch, uint8_t *dstp, int dst_pitch,
+                             int dstr, int height, int width );
+
+// Contracts the edge mask by considering a pixel to be masked
+// only if > erosion threshold adjacent pixels are masked
+void eedi2_erode_edge_mask( uint8_t *mskp, int msk_pitch, uint8_t *dstp, int dst_pitch,
+                            int estr, int height, int width );
+
+// Smooths out horizontally aligned holes in the mask
+// If none of the 6 horizontally adjacent pixels are masked,
+// don't consider the current pixel masked. If there are any
+// masked on both sides, consider the current pixel masked.
+void eedi2_remove_small_gaps( uint8_t * mskp, int msk_pitch, uint8_t * dstp, int dst_pitch, 
+                              int height, int width );
+
+// Spatial vectors. Looks at maximum_search_distance surrounding pixels
+// to guess which angle edges follow. This is EEDI2's timesink, and can be
+// thought of as YADIF_CHECK on steroids. Both find edge directions.
+void eedi2_calc_directions( const int plane, uint8_t * mskp, int msk_pitch, uint8_t * srcp, int src_pitch,
+                            uint8_t * dstp, int dst_pitch, int maxd, int nt, int height, int width  );
+
+void eedi2_filter_map( uint8_t *mskp, int msk_pitch, uint8_t *dmskp, int dmsk_pitch,
+                       uint8_t * dstp, int dst_pitch, int height, int width );
+
+void eedi2_filter_dir_map( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                           int dst_pitch, int height, int width );
+
+void eedi2_expand_dir_map( uint8_t * mskp, int msk_pitch, uint8_t  *dmskp, int dmsk_pitch, uint8_t * dstp,
+                           int dst_pitch, int height, int width );
+
+void eedi2_mark_directions_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                               int dst_pitch, int tff, int height, int width );
+
+void eedi2_filter_dir_map_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                              int dst_pitch, int field, int height, int width );
+
+void eedi2_expand_dir_map_2x( uint8_t * mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                              int dst_pitch, int field, int height, int width );
+
+void eedi2_fill_gaps_2x( uint8_t *mskp, int msk_pitch, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                         int dst_pitch, int field, int height, int width );
+
+void eedi2_interpolate_lattice( const int plane, uint8_t * dmskp, int dmsk_pitch, uint8_t * dstp,
+                                int dst_pitch, uint8_t * omskp, int omsk_pitch, int field, int nt,
+                                int height, int width );
+
+void eedi2_post_process( uint8_t * nmskp, int nmsk_pitch, uint8_t * omskp, int omsk_pitch, uint8_t * dstp,
+                         int src_pitch, int field, int height, int width );
+
+void eedi2_gaussian_blur1( uint8_t * src, int src_pitch, uint8_t * tmp, int tmp_pitch, uint8_t * dst,
+                           int dst_pitch, int height, int width );
+                           
+void eedi2_gaussian_blur_sqrt2( int *src, int *tmp, int *dst, const int pitch,
+                                const int height, const int width );
+                                
+void eedi2_calc_derivatives( uint8_t *srcp, int src_pitch, int height, int width,
+                             int *x2, int *y2, int *xy);
+
+void eedi2_post_process_corner( int *x2, int *y2, int *xy, const int pitch, uint8_t * mskp, int msk_pitch,
+                                uint8_t * dstp, int dst_pitch, int height, int width, int field );
index d22d30d..22eb286 100644 (file)
@@ -5,8 +5,7 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 
 struct hb_work_private_s
 {
@@ -107,13 +106,13 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
     context->gop_size  = 10 * job->vrate / job->vrate_base;
     context->pix_fmt   = PIX_FMT_YUV420P;
 
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
-        context->sample_aspect_ratio.num = job->pixel_aspect_width;
-        context->sample_aspect_ratio.den = job->pixel_aspect_height;
+        context->sample_aspect_ratio.num = job->anamorphic.par_width;
+        context->sample_aspect_ratio.den = job->anamorphic.par_height;
 
         hb_log( "encavcodec: encoding with stored aspect %d/%d",
-                job->pixel_aspect_width, job->pixel_aspect_height );
+                job->anamorphic.par_width, job->anamorphic.par_height );
     }
 
     if( job->mux & ( HB_MUX_MP4 | HB_MUX_PSP ) )
@@ -159,7 +158,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
         }
     }
 
-    if( avcodec_open( context, codec ) )
+    if( hb_avcodec_open( context, codec ) )
     {
         hb_log( "hb_work_encavcodec_init: avcodec_open failed" );
     }
@@ -194,7 +193,7 @@ void encavcodecClose( hb_work_object_t * w )
     {
         hb_deep_log( 2, "encavcodec: closing libavcodec" );
         avcodec_flush_buffers( pv->context );
-        avcodec_close( pv->context );
+        hb_avcodec_close( pv->context );
     }
     if( pv->file )
     {
index 8f4defc..027aa3a 100644 (file)
@@ -28,6 +28,7 @@ struct hb_work_private_s
     /* LAME handle */
     lame_global_flags * lame;
 
+    int             done;
     unsigned long   input_samples;
     unsigned long   output_bytes;
     uint8_t       * buf;
@@ -138,14 +139,33 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                  hb_buffer_t ** buf_out )
 {
     hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
     hb_buffer_t * buf;
 
     if ( (*buf_in)->size <= 0 )
     {
         /* EOF on input - send it downstream & say we're done */
-        *buf_out = *buf_in;
-        *buf_in = NULL;
-       return HB_WORK_DONE;
+        if ( pv->done )
+        {
+            *buf_out = *buf_in;
+            *buf_in = NULL;
+            return HB_WORK_DONE;
+        }
+        else
+        {
+            pv->done = 1;
+            hb_fifo_push( w->fifo_in, in);
+            *buf_in = NULL;
+
+            buf = hb_buffer_init( pv->output_bytes );
+            buf->size = lame_encode_flush( pv->lame, buf->data, LAME_MAXMP3BUFFER );
+            if( buf->size <= 0 )
+            {
+                hb_buffer_close( &buf );
+            }
+            *buf_out = buf;
+            return HB_WORK_OK;
+        }
     }
 
     hb_list_add( pv->list, *buf_in );
index bcc27eb..042262c 100644 (file)
@@ -3,7 +3,8 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-#include "theora/theora.h"
+#include "theora/codec.h"
+#include "theora/theoraenc.h"
 
 int  enctheoraInit( hb_work_object_t *, hb_job_t * );
 int  enctheoraWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
@@ -20,78 +21,188 @@ hb_work_object_t hb_enctheora =
 
 struct hb_work_private_s
 {
-    hb_job_t * job;
+    hb_job_t    * job;
 
-    theora_state theora;
+    th_enc_ctx    * ctx;
+
+    FILE          * file;
+    unsigned char   stat_buf[80];
+    int             stat_read;
+    int             stat_fill;
 };
 
 int enctheoraInit( hb_work_object_t * w, hb_job_t * job )
 {
+    int keyframe_frequency, log_keyframe, ret;
     hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
     w->private_data = pv;
 
     pv->job = job;
 
-    theora_info ti;
-    theora_comment tc;
+    if( job->pass != 0 && job->pass != -1 )
+    {
+        char filename[1024];
+        memset( filename, 0, 1024 );
+        hb_get_tempory_filename( job->h, filename, "theroa.log" );
+        if ( job->pass == 1 )
+        {
+            pv->file = fopen( filename, "wb" );
+        }
+        else
+        {
+            pv->file = fopen( filename, "rb" );
+        }
+    }
+
+    th_info ti;
+    th_comment tc;
     ogg_packet op;
-    theora_info_init( &ti );
+    th_info_init( &ti );
+
+    /* Frame width and height need to be multiples of 16 */
+    ti.pic_width = job->width;
+    ti.pic_height = job->height;
+    ti.frame_width = (job->width + 0xf) & ~0xf;
+    ti.frame_height = (job->height + 0xf) & ~0xf;
+    ti.pic_x = ti.pic_y = 0;
 
-    ti.width = ti.frame_width = job->width;
-    ti.height = ti.frame_height = job->height;
-    ti.offset_x = ti.offset_y = 0;
     ti.fps_numerator = job->vrate;
     ti.fps_denominator = job->vrate_base;
-    if (job->pixel_ratio)
+    if( job->anamorphic.mode )
     {
-        ti.aspect_numerator = job->pixel_aspect_width;
-        ti.aspect_denominator = job->pixel_aspect_height;
+        ti.aspect_numerator = job->anamorphic.par_width;
+        ti.aspect_denominator = job->anamorphic.par_height;
     }
     else
     {
         ti.aspect_numerator = ti.aspect_denominator = 1;
     }
-    ti.colorspace = OC_CS_UNSPECIFIED;
-    ti.pixelformat = OC_PF_420;
-    ti.keyframe_auto_p = 1;
-    ti.keyframe_frequency = (job->vrate / job->vrate_base) + 1;
-    ti.keyframe_frequency_force = (10 * job->vrate / job->vrate_base) + 1;
-    /* From encoder_example.c */
-    ti.quick_p = 1;
-    ti.dropframes_p = 0;
-    ti.keyframe_auto_threshold = 80;
-    ti.keyframe_mindistance = 8;
-    ti.noise_sensitivity = 1;
-    ti.sharpness = 0;
-    if (job->vquality < 0.0 || job->vquality > 1.0)
+    ti.colorspace = TH_CS_UNSPECIFIED;
+    ti.pixel_fmt = TH_PF_420;
+    if (job->vquality < 0.0)
     {
         ti.target_bitrate = job->vbitrate * 1000;
-        ti.keyframe_data_target_bitrate = job->vbitrate * 1000 * 1.5;
         ti.quality = 0;
     }
     else
     {
         ti.target_bitrate = 0;
-        ti.quality = 63 * job->vquality;
+        
+        if( job->vquality > 0 && job->vquality < 1 )
+        {
+            ti.quality = 63 * job->vquality;            
+        }
+        else
+        {
+            ti.quality = job->vquality;
+        }
+    }
+
+    if ( job->pass == 2 && !job->cfr )
+    {
+        /* Even though the framerate might be different due to VFR,
+           we still want the same keyframe intervals as the 1st pass,
+           so the 1st pass stats won't conflict on frame decisions.    */
+        hb_interjob_t * interjob = hb_interjob_get( job->h );
+        keyframe_frequency = ( 10 * interjob->vrate / interjob->vrate_base ) + 1;
+    }
+    else
+    {
+        int fps = job->vrate / job->vrate_base;
+
+        /* adjust +1 when fps has remainder to bump
+           { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
+        if (job->vrate % job->vrate_base)
+            fps += 1;
+
+        keyframe_frequency = fps * 10;
     }
+    int tmp = keyframe_frequency - 1;
+    for (log_keyframe = 0; tmp; log_keyframe++)
+        tmp >>= 1;
+        
+    hb_log("theora: keyint: %i", keyframe_frequency);
+
+    ti.keyframe_granule_shift = log_keyframe;
 
-    theora_encode_init( &pv->theora, &ti );
-    theora_info_clear( &ti );
+    pv->ctx = th_encode_alloc( &ti );
+    th_info_clear( &ti );
+
+    ret = th_encode_ctl(pv->ctx, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
+                        &keyframe_frequency, sizeof(keyframe_frequency));
+    if( ret < 0 )
+    {
+        hb_log("theora: Could not set keyframe interval to %d", keyframe_frequency);
+    }
+
+    /* Set "soft target" rate control which improves quality at the
+     * expense of solid bitrate caps */
+    int arg = TH_RATECTL_CAP_UNDERFLOW;
+    ret = th_encode_ctl(pv->ctx, TH_ENCCTL_SET_RATE_FLAGS, &arg, sizeof(arg));
+    if( ret < 0 )
+    {
+        hb_log("theora: Could not set soft ratecontrol");
+    }
+    if( job->pass != 0 && job->pass != -1 )
+    {
+        arg = keyframe_frequency * 7 >> 1;
+        ret = th_encode_ctl(pv->ctx, TH_ENCCTL_SET_RATE_BUFFER, &arg, sizeof(arg));
+        if( ret < 0 )
+        {
+            hb_log("theora: Could not set rate control buffer");
+        }
+    }
 
-    theora_encode_header( &pv->theora, &op );
+    if( job->pass == 1 )
+    {
+        unsigned char *buffer;
+        int bytes;
+        bytes = th_encode_ctl(pv->ctx, TH_ENCCTL_2PASS_OUT, &buffer, sizeof(buffer));
+        if( bytes < 0 )
+        {
+            hb_error("Could not set up the first pass of two-pass mode.\n");
+            hb_error("Did you remember to specify an estimated bitrate?\n");
+            return 1;
+        }
+        if( fwrite( buffer, 1, bytes, pv->file ) < bytes )
+        {
+            hb_error("Unable to write to two-pass data file.\n");
+            return 1;
+        }
+        fflush( pv->file );
+    }
+    if( job->pass == 2 )
+    {
+        /* Enable the second pass here.
+         * We make this call just to set the encoder into 2-pass mode, because
+         * by default enabling two-pass sets the buffer delay to the whole file
+         * (because there's no way to explicitly request that behavior).
+         * If we waited until we were actually encoding, it would overwite our
+         * settings.*/
+        hb_log("enctheora: init 2nd pass");
+        if( th_encode_ctl( pv->ctx, TH_ENCCTL_2PASS_IN, NULL, 0) < 0)
+        {
+            hb_log("theora: Could not set up the second pass of two-pass mode.");
+            return 1;
+        }
+    }
+
+    th_comment_init( &tc );
+
+    th_encode_flushheader( pv->ctx, &tc, &op );
     memcpy(w->config->theora.headers[0], &op, sizeof(op));
     memcpy(w->config->theora.headers[0] + sizeof(op), op.packet, op.bytes );
 
-    theora_comment_init(&tc);
-    theora_encode_comment(&tc,&op);
+    th_encode_flushheader( pv->ctx, &tc, &op );
     memcpy(w->config->theora.headers[1], &op, sizeof(op));
     memcpy(w->config->theora.headers[1] + sizeof(op), op.packet, op.bytes );
-    free(op.packet);
 
-    theora_encode_tables(&pv->theora, &op);
+    th_encode_flushheader( pv->ctx, &tc, &op );
     memcpy(w->config->theora.headers[2], &op, sizeof(op));
     memcpy(w->config->theora.headers[2] + sizeof(op), op.packet, op.bytes );
 
+    th_comment_clear( &tc );
+
     return 0;
 }
 
@@ -103,8 +214,13 @@ int enctheoraInit( hb_work_object_t * w, hb_job_t * job )
 void enctheoraClose( hb_work_object_t * w )
 {
     hb_work_private_t * pv = w->private_data;
-    /* TODO: Free alloc'd */
 
+    th_encode_free( pv->ctx );
+
+    if( pv->file )
+    {
+        fclose( pv->file );
+    }
     free( pv );
     w->private_data = NULL;
 }
@@ -120,44 +236,145 @@ int enctheoraWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_job_t * job = pv->job;
     hb_buffer_t * in = *buf_in, * buf;
-    yuv_buffer yuv;
+    th_ycbcr_buffer ycbcr;
     ogg_packet op;
 
+    int frame_width, frame_height;
+
     if ( in->size <= 0 )
     {
         // EOF on input - send it downstream & say we're done.
         // XXX may need to flush packets via a call to
-        //  theora_encode_packetout(&pv->theora, 1, &op);
+        //  th_encode_packetout( pv->ctx, 1, &op );
         // but we don't have a timestamp to put on those packets so we
         // drop them for now.
         *buf_out = in;
         *buf_in = NULL;
-       return HB_WORK_DONE;
+        th_encode_packetout( pv->ctx, 1, &op );
+        if( job->pass == 1 )
+        {
+            unsigned char *buffer;
+            int bytes;
+
+            bytes = th_encode_ctl(pv->ctx, TH_ENCCTL_2PASS_OUT, 
+                                  &buffer, sizeof(buffer));
+            if( bytes < 0 )
+            {
+                fprintf(stderr,"Could not read two-pass data from encoder.\n");
+                return HB_WORK_DONE;
+            }
+            fseek( pv->file, 0, SEEK_SET );
+            if( fwrite( buffer, 1, bytes, pv->file ) < bytes)
+            {
+                fprintf(stderr,"Unable to write to two-pass data file.\n");
+                return HB_WORK_DONE;
+            }
+            fflush( pv->file );
+        }
+        return HB_WORK_DONE;
     }
 
+    if( job->pass == 2 )
+    {
+        for(;;)
+        {
+            int bytes, size, ret;
+            /*Ask the encoder how many bytes it would like.*/
+            bytes = th_encode_ctl( pv->ctx, TH_ENCCTL_2PASS_IN, NULL, 0 );
+            if( bytes < 0 )
+            {
+                hb_error("Error requesting stats size in second pass.");
+                *job->die = 1;
+                return HB_WORK_DONE;
+            }
+
+            /*If it's got enough, stop.*/
+            if( bytes == 0 ) break;
+
+            /*Read in some more bytes, if necessary.*/
+            if( bytes > pv->stat_fill - pv->stat_read )
+                size = bytes - (pv->stat_fill - pv->stat_read);
+            else
+                size = 0;
+            if( size > 80 - pv->stat_fill )
+                size = 80 - pv->stat_fill;
+            if( size > 0 &&
+                fread( pv->stat_buf+pv->stat_fill, 1, size, pv->file ) < size )
+            {
+                hb_error("Could not read frame data from two-pass data file!");
+                *job->die = 1;
+                return HB_WORK_DONE;
+            }
+            pv->stat_fill += size;
+
+            /*And pass them off.*/
+            if( bytes > pv->stat_fill - pv->stat_read )
+                bytes = pv->stat_fill - pv->stat_read;
+            ret = th_encode_ctl( pv->ctx, TH_ENCCTL_2PASS_IN, 
+                                 pv->stat_buf+pv->stat_read, bytes);
+            if( ret < 0 )
+            {
+                hb_error("Error submitting pass data in second pass.");
+                *job->die = 1;
+                return HB_WORK_DONE;
+            }
+            /*If the encoder consumed the whole buffer, reset it.*/
+            if( ret >= pv->stat_fill - pv->stat_read )
+                pv->stat_read = pv->stat_fill = 0;
+            /*Otherwise remember how much it used.*/
+            else 
+                pv->stat_read += ret;
+        }
+    }
     memset(&op, 0, sizeof(op));
-    memset(&yuv, 0, sizeof(yuv));
+    memset(&ycbcr, 0, sizeof(ycbcr));
+
+    frame_width = (job->width + 0xf) & ~0xf;
+    frame_height = (job->height + 0xf) & ~0xf;
 
-    yuv.y_width = job->width;
-    yuv.y_height = job->height;
-    yuv.y_stride = job->width;
+    // Y
+    ycbcr[0].width = frame_width;
+    ycbcr[0].height = frame_height;
+    ycbcr[0].stride = job->width;
 
-    yuv.uv_width = (job->width + 1) / 2;
-    yuv.uv_height = (job->height + 1) / 2;
-    yuv.uv_stride = yuv.uv_width;
+    // CbCr decimated by factor of 2 in both width and height
+    ycbcr[1].width  = ycbcr[2].width  = (frame_width + 1) / 2;
+    ycbcr[1].height = ycbcr[2].height = (frame_height + 1) / 2;
+    ycbcr[1].stride = ycbcr[2].stride = (job->width + 1) / 2;
 
-    yuv.y = in->data;
-    yuv.u = in->data + job->width * job->height;
-    yuv.v = in->data + ( job->width * job->height ) + ( yuv.uv_width * yuv.uv_height );
+    ycbcr[0].data = in->data;
+    ycbcr[1].data = ycbcr[0].data + (ycbcr[0].stride * job->height);
+    ycbcr[2].data = ycbcr[1].data + (ycbcr[1].stride * ((job->height+1)/2));
 
-    theora_encode_YUVin(&pv->theora, &yuv);
+    th_encode_ycbcr_in( pv->ctx, ycbcr );
 
-    theora_encode_packetout(&pv->theora, 0, &op);
+    if( job->pass == 1 )
+    {
+        unsigned char *buffer;
+        int bytes;
+
+        bytes = th_encode_ctl(pv->ctx, TH_ENCCTL_2PASS_OUT, 
+                              &buffer, sizeof(buffer));
+        if( bytes < 0 )
+        {
+            fprintf(stderr,"Could not read two-pass data from encoder.\n");
+            *job->die = 1;
+            return HB_WORK_DONE;
+        }
+        if( fwrite( buffer, 1, bytes, pv->file ) < bytes)
+        {
+            fprintf(stderr,"Unable to write to two-pass data file.\n");
+            *job->die = 1;
+            return HB_WORK_DONE;
+        }
+        fflush( pv->file );
+    }
+    th_encode_packetout( pv->ctx, 0, &op );
 
     buf = hb_buffer_init( op.bytes + sizeof(op) );
     memcpy(buf->data, &op, sizeof(op));
     memcpy(buf->data + sizeof(op), op.packet, op.bytes);
-    buf->frametype = ( theora_packet_iskeyframe(&op) ) ? HB_FRAME_KEY : HB_FRAME_REF;
+    buf->frametype = ( th_packet_iskeyframe(&op) ) ? HB_FRAME_KEY : HB_FRAME_REF;
     buf->start = in->start;
     buf->stop  = in->stop;
 
diff --git a/libhb/encvobsub.c b/libhb/encvobsub.c
new file mode 100644 (file)
index 0000000..20a9879
--- /dev/null
@@ -0,0 +1,71 @@
+/* $Id: envvobsub.c
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include "hb.h"
+
+struct hb_work_private_s
+{
+    hb_job_t * job;
+};
+
+int encsubInit( hb_work_object_t * w, hb_job_t * job )
+{
+    hb_work_private_t * pv;
+
+    pv              = calloc( 1, sizeof( hb_work_private_t ) );
+    w->private_data = pv;
+
+    pv->job = job;
+
+    return 0;
+}
+
+int encsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+                hb_buffer_t ** buf_out )
+{
+    hb_buffer_t * in = *buf_in;
+
+    if (w->subtitle->source != VOBSUB)
+    {
+        // Invalid source, send EOF, this shouldn't ever happen
+        hb_log("encvobsub: invalid subtitle source");
+        hb_buffer_close( buf_in );
+        *buf_out = hb_buffer_init(0);
+    }
+    if ( in->size <= 0 )
+    {
+        /* EOF on input stream - send it downstream & say that we're done */
+        *buf_out = in;
+        *buf_in = NULL;
+        return HB_WORK_DONE;
+    }
+
+    /*
+     * Not much to do, just pass the buffer on.
+     * Some day, we may re-encode bd subtitles here ;)
+     */
+    if (buf_out)
+    {
+        *buf_out = in;
+        *buf_in = NULL;
+    }
+
+    return HB_WORK_OK; 
+}
+
+void encsubClose( hb_work_object_t * w )
+{
+    free( w->private_data );
+}
+
+hb_work_object_t hb_encvobsub =
+{
+    WORK_ENCVOBSUB,
+    "VOBSUB encoder",
+    encsubInit,
+    encsubWork,
+    encsubClose
+};
index 47a6077..ce27ea0 100644 (file)
@@ -123,12 +123,25 @@ int encvorbisInit( hb_work_object_t * w, hb_job_t * job )
             pv->channel_map[0] = 0;
             break;
         case 6:
-            pv->channel_map[0] = 0;
-            pv->channel_map[1] = 2;
-            pv->channel_map[2] = 1;
-            pv->channel_map[3] = 4;
-            pv->channel_map[4] = 5;
-            pv->channel_map[5] = 3;
+            // Vorbis use the following channels map = L C R Ls Rs Lfe
+            if( audio->config.in.codec == HB_ACODEC_AC3 )
+            {
+                pv->channel_map[0] = 1;
+                pv->channel_map[1] = 2;
+                pv->channel_map[2] = 3;
+                pv->channel_map[3] = 4;
+                pv->channel_map[4] = 5;
+                pv->channel_map[5] = 0;
+            }
+            else
+            {
+                pv->channel_map[0] = 1;
+                pv->channel_map[1] = 0;
+                pv->channel_map[2] = 2;
+                pv->channel_map[3] = 3;
+                pv->channel_map[4] = 4;
+                pv->channel_map[5] = 5;
+            }
             break;
         default:
             hb_log("encvorbis.c: Unable to correctly proccess %d channels, assuming stereo.", pv->out_discrete_channels);
index 97de03e..bd41839 100644 (file)
@@ -50,6 +50,9 @@ struct hb_work_private_s
     x264_picture_t   pic_in;
     uint8_t         *x264_allocated_pic;
 
+    uint32_t       frames_in;
+    uint32_t       frames_out;
+    uint32_t       frames_split; // number of frames we had to split
     int            chap_mark;   // saved chap mark when we're propagating it
     int64_t        last_stop;   // Debugging - stop time of previous input frame
     int64_t        init_delay;
@@ -72,7 +75,6 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     x264_param_t       param;
     x264_nal_t       * nal;
     int                nal_count;
-    int                nal_size;
 
     hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
     w->private_data = pv;
@@ -83,19 +85,91 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     hb_get_tempory_filename( job->h, pv->filename, "x264.log" );
 
     x264_param_default( &param );
-
+    
+    /* Default weightp to off for baseline,
+       overridable through x264 option strings. */
+    if( job->x264opts != NULL && *job->x264opts != '\0' )
+    {
+        char *x264opts, *x264opts_start;
+    
+        x264opts = x264opts_start = strdup(job->x264opts);
+    
+        while( x264opts_start && *x264opts )
+        {
+            char *name = x264opts;
+            char *value;
+    
+            x264opts += strcspn( x264opts, ":" );
+            if( *x264opts )
+            {
+                *x264opts = 0;
+                x264opts++;
+            }
+    
+            value = strchr( name, '=' );
+            if( value )
+            {
+                *value = 0;
+                value++;
+            }
+    
+            /*
+               When B-frames are enabled, the max frame count increments
+               by 1 (regardless of the number of B-frames). If you don't
+               change the duration of the video track when you mux, libmp4
+               barfs.  So, check if the x264opts aren't using B-frames, and
+               when they aren't, set the boolean job->areBframes as false.
+             */
+            if( !( strcmp( name, "bframes" ) ) )
+            {
+                if( atoi( value ) == 0 )
+                {
+                    param.analyse.i_weighted_pred = X264_WEIGHTP_NONE;
+                }
+            }
+        }
+    }
+    
+    /* Enable metrics */
+    param.analyse.b_psnr = 1;
+    param.analyse.b_ssim = 1;
+    
     param.i_threads    = ( hb_get_cpu_count() * 3 / 2 );
     param.i_width      = job->width;
     param.i_height     = job->height;
     param.i_fps_num    = job->vrate;
     param.i_fps_den    = job->vrate_base;
 
+    /* Disable annexb. Inserts size into nal header instead of start code */
+    param.b_annexb     = 0;
+
+    /* Set min:max key intervals ratio to 1:10 of fps.
+     * This section is skipped if fps=25 (default).
+     */
     if (job->vrate_base != 1080000)
     {
-        /* If the fps isn't 25, adjust the key intervals. Add 1 because
-           we want 24, not 23 with a truncated remainder.               */
-        param.i_keyint_min     = (job->vrate / job->vrate_base) + 1;
-        param.i_keyint_max = (10 * job->vrate / job->vrate_base) + 1;
+        if (job->pass == 2 && !job->cfr )
+        {
+            /* Even though the framerate might be different due to VFR,
+               we still want the same keyframe intervals as the 1st pass,
+               so the 1st pass stats won't conflict on frame decisions.    */
+            hb_interjob_t * interjob = hb_interjob_get( job->h );
+            param.i_keyint_min     = ( interjob->vrate / interjob->vrate_base ) + 1;
+            param.i_keyint_max = ( 10 * interjob->vrate / interjob->vrate_base ) + 1;
+        }
+        else
+        {
+            int fps = job->vrate / job->vrate_base;
+
+            /* adjust +1 when fps has remainder to bump
+               { 23.976, 29.976, 59.94 } to { 24, 30, 60 } */
+            if (job->vrate % job->vrate_base)
+                fps += 1;
+
+            param.i_keyint_min = fps;
+            param.i_keyint_max = fps * 10;
+        }
+        
         hb_log("encx264: keyint-min: %i, keyint-max: %i", param.i_keyint_min, param.i_keyint_max);
     }
 
@@ -108,6 +182,9 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
                 param.i_level_idc );
     }
 
+    /* B-frames are on by default.*/
+    job->areBframes = 1;
+    
     /*
                This section passes the string x264opts to libx264 for parsing into
         parameter names and values.
@@ -153,15 +230,14 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
                When B-frames are enabled, the max frame count increments
                by 1 (regardless of the number of B-frames). If you don't
                change the duration of the video track when you mux, libmp4
-               barfs.  So, check if the x264opts are using B-frames, and
-               when they are, set the boolean job->areBframes as true.
+               barfs.  So, check if the x264opts aren't using B-frames, and
+               when they aren't, set the boolean job->areBframes as false.
              */
-
             if( !( strcmp( name, "bframes" ) ) )
             {
-                if( atoi( value ) > 0 )
+                if( atoi( value ) == 0 )
                 {
-                    job->areBframes = 1;
+                    job->areBframes = 0;
                 }
             }
 
@@ -179,6 +255,14 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
                 {
                     job->areBframes = 2;
                 }
+                if( value == NULL || !strcmp( value, "1" ) )
+                {
+                    value = "normal";
+                }
+                else if( !strcmp( value, "0" ) )
+                {
+                    value = "none";
+                }
             }
 
             /* Here's where the strings are passed to libx264 for parsing. */
@@ -224,10 +308,10 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
         param.vui.i_colmatrix = 6;
     }
 
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
-        param.vui.i_sar_width = job->pixel_aspect_width;
-        param.vui.i_sar_height = job->pixel_aspect_height;
+        param.vui.i_sar_width  = job->anamorphic.par_width;
+        param.vui.i_sar_height = job->anamorphic.par_height;
 
         hb_log( "encx264: encoding with stored aspect %d/%d",
                 param.vui.i_sar_width, param.vui.i_sar_height );
@@ -236,47 +320,19 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
 
     if( job->vquality > 0.0 && job->vquality < 1.0 )
     {
-        switch( job->crf )
-        {
-            case 1:
-                /*Constant RF*/
-                param.rc.i_rc_method = X264_RC_CRF;
-                param.rc.f_rf_constant = 51 - job->vquality * 51;
-                hb_log( "encx264: Encoding at constant RF %f",
-                        param.rc.f_rf_constant );
-                break;
-
-            case 0:
-                /*Constant QP*/
-                param.rc.i_rc_method = X264_RC_CQP;
-                param.rc.i_qp_constant = 51 - job->vquality * 51;
-                hb_log( "encx264: encoding at constant QP %d",
-                        param.rc.i_qp_constant );
-                break;
-        }
+        /*Constant RF*/
+        param.rc.i_rc_method = X264_RC_CRF;
+        param.rc.f_rf_constant = 51 - job->vquality * 51;
+        hb_log( "encx264: Encoding at constant RF %f", param.rc.f_rf_constant );
     }
     else if( job->vquality == 0 || job->vquality >= 1.0 )
     {
         /* Use the vquality as a raw RF or QP
           instead of treating it like a percentage. */
-        switch( job->crf )
-        {
-            case 1:
-                /*Constant RF*/
-                param.rc.i_rc_method = X264_RC_CRF;
-                param.rc.f_rf_constant = job->vquality;
-                hb_log( "encx264: Encoding at constant RF %f",
-                        param.rc.f_rf_constant );
-                break;
-
-            case 0:
-                /*Constant QP*/
-                param.rc.i_rc_method = X264_RC_CQP;
-                param.rc.i_qp_constant = job->vquality;
-                hb_log( "encx264: encoding at constant QP %d",
-                        param.rc.i_qp_constant );
-                break;
-        }        
+        /*Constant RF*/
+        param.rc.i_rc_method = X264_RC_CRF;
+        param.rc.f_rf_constant = job->vquality;
+        hb_log( "encx264: Encoding at constant RF %f", param.rc.f_rf_constant );
     }
     else
     {
@@ -302,12 +358,12 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
     x264_encoder_headers( pv->x264, &nal, &nal_count );
 
     /* Sequence Parameter Set */
-    x264_nal_encode( w->config->h264.sps, &nal_size, 0, &nal[1] );
-    w->config->h264.sps_length = nal_size;
+    memcpy(w->config->h264.sps, nal[1].p_payload + 4, nal[1].i_payload - 4);
+    w->config->h264.sps_length = nal[1].i_payload - 4;
 
     /* Picture Parameter Set */
-    x264_nal_encode( w->config->h264.pps, &nal_size, 0, &nal[2] );
-    w->config->h264.pps_length = nal_size;
+    memcpy(w->config->h264.pps, nal[2].p_payload + 4, nal[2].i_payload - 4);
+    w->config->h264.pps_length = nal[2].i_payload - 4;
 
     x264_picture_alloc( &pv->pic_in, X264_CSP_I420,
                         job->width, job->height );
@@ -338,10 +394,14 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
         pv->init_delay += 2;
 
         /* For VFR, libhb sees the FPS as 29.97, but the longest frames
-           will use the duration of frames running at 23.976fps instead.. */
-        if (job->vfr)
+           will use the duration of frames running at 23.976fps instead.
+           Since detelecine occasionally makes mistakes and since we have
+           to deal with some really horrible timing jitter from mkvs and
+           mp4s encoded with low resolution clocks, make the delay very
+           conservative if we're not doing CFR. */
+        if ( job->cfr != 1 )
         {
-            pv->init_delay = 7506;
+            pv->init_delay *= 2;
         }
 
         /* The delay is 1 frames for regular b-frames, 2 for b-pyramid. */
@@ -355,6 +415,12 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job )
 void encx264Close( hb_work_object_t * w )
 {
     hb_work_private_t * pv = w->private_data;
+
+    if ( pv->frames_split )
+    {
+        hb_log( "encx264: %u frames had to be split (%u in, %u out)",
+                pv->frames_split, pv->frames_in, pv->frames_out );
+    }
     /*
      * Patch the x264 allocated data back in so that x264 can free it
      * we have been using our own buffers during the encode to avoid copying.
@@ -409,8 +475,8 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
     int i;
     for( i = 0; i < i_nal; i++ )
     {
-        int data = buf->alloc - buf->size;
-        int size = x264_nal_encode( buf->data + buf->size, &data, 1, &nal[i] );
+        int size = nal[i].i_payload;
+        memcpy(buf->data + buf->size, nal[i].p_payload, size);
         if( size < 1 )
         {
             continue;
@@ -427,19 +493,21 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
         }
 
         /* H.264 in .mp4 or .mkv */
-        int naltype = buf->data[buf->size+4] & 0x1f;
-        if ( naltype == 0x7 || naltype == 0x8 )
+        switch( nal[i].i_type )
         {
-            // Sequence Parameter Set & Program Parameter Set go in the
-            // mp4 header so skip them here
-            continue;
-        }
+            /* Sequence Parameter Set & Program Parameter Set go in the
+             * mp4 header so skip them here
+             */
+            case NAL_SPS:
+            case NAL_PPS:
+                continue;
 
-        /* H.264 in mp4 (stolen from mp4creator) */
-        buf->data[buf->size+0] = ( ( size - 4 ) >> 24 ) & 0xFF;
-        buf->data[buf->size+1] = ( ( size - 4 ) >> 16 ) & 0xFF;
-        buf->data[buf->size+2] = ( ( size - 4 ) >>  8 ) & 0xFF;
-        buf->data[buf->size+3] = ( ( size - 4 ) >>  0 ) & 0xFF;
+            case NAL_SLICE:
+            case NAL_SLICE_IDR:
+            case NAL_SEI:
+            default:
+                break;
+        }
 
         /* Decide what type of frame we have. */
         switch( pic_out->i_type )
@@ -487,6 +555,12 @@ static hb_buffer_t *nal_encode( hb_work_object_t *w, x264_picture_t *pic_out,
             (nal[i].i_ref_idc != NAL_PRIORITY_DISPOSABLE) )
             buf->frametype = HB_FRAME_BREF;
 
+        /* Expose disposable bit to muxer. */
+        if( nal[i].i_ref_idc == NAL_PRIORITY_DISPOSABLE )
+            buf->flags &= ~HB_FRAME_REF;
+        else
+            buf->flags |= HB_FRAME_REF;
+
         buf->size += size;
     }
     // make sure we found at least one video frame
@@ -548,7 +622,7 @@ static hb_buffer_t *x264_encode( hb_work_object_t *w, hb_buffer_t *in )
      */
     if( pv->last_stop != in->start )
     {
-        hb_log("encx264 input continuity err: last stop %lld  start %lld",
+        hb_log("encx264 input continuity err: last stop %"PRId64"  start %"PRId64,
                 pv->last_stop, in->start);
     }
     pv->last_stop = in->stop;
@@ -598,6 +672,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
             hb_buffer_t *buf = nal_encode( w, &pic_out, i_nal, nal );
             if ( buf )
             {
+                ++pv->frames_out;
                 if ( last_buf == NULL )
                     *buf_out = buf;
                 else
@@ -616,6 +691,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
     }
 
     // Not EOF - encode the packet & wrap it in a NAL
+    ++pv->frames_in;
 
     // if we're re-ordering frames, check if this frame is too large to reorder
     if ( pv->init_delay && in->stop - in->start > pv->init_delay )
@@ -631,6 +707,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
         // error. We take advantage of the fact that x264 buffers frame
         // data internally to feed the same image into the encoder multiple
         // times, just changing its start & stop times each time.
+        ++pv->frames_split;
         int64_t orig_stop = in->stop;
         int64_t new_stop = in->start;
         hb_buffer_t *last_buf = NULL;
@@ -657,6 +734,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
             hb_buffer_t *buf = x264_encode( w, in );
             if ( buf )
             {
+                ++pv->frames_out;
                 if ( last_buf == NULL )
                     *buf_out = buf;
                 else
@@ -668,6 +746,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
     }
     else
     {
+        ++pv->frames_out;
         *buf_out = x264_encode( w, in );
     }
     return HB_WORK_OK;
index 9441f71..48f6459 100644 (file)
@@ -90,8 +90,8 @@ void hb_buffer_pool_free( void )
         }
     }
 
-    hb_deep_log( 2, "Allocated %lld bytes of buffers on this pass and Freed %lld bytes, "
-           "%lld bytes leaked", buffers.allocated, freed, buffers.allocated - freed);
+    hb_deep_log( 2, "Allocated %"PRId64" bytes of buffers on this pass and Freed %"PRId64" bytes, "
+           "%"PRId64" bytes leaked", buffers.allocated, freed, buffers.allocated - freed);
     buffers.allocated = 0;
     hb_unlock(buffers.lock);
 }
@@ -147,7 +147,7 @@ hb_buffer_t * hb_buffer_init( int size )
 
     if (size)
     {
-#if defined( SYS_DARWIN ) || defined( SYS_FREEBSD )
+#if defined( SYS_DARWIN ) || defined( SYS_FREEBSD ) || defined( SYS_MINGW )
         b->data  = malloc( b->alloc );
 #elif defined( SYS_CYGWIN )
         /* FIXME */
@@ -191,6 +191,7 @@ void hb_buffer_close( hb_buffer_t ** _b )
     if( buffer_pool && b->data && !hb_fifo_is_full( buffer_pool ) )
     {
         hb_fifo_push_head( buffer_pool, b );
+        *_b = NULL;
         return;
     }
     /* either the pool is full or this size doesn't use a pool - free the buf */
index 713c825..34fe53b 100644 (file)
@@ -1,14 +1,11 @@
 #include "hb.h"
-
-#include "libavcodec/avcodec.h"
-#include "libavformat/avformat.h"
-#include "libswscale/swscale.h"
+#include "hbffmpeg.h"
 
 struct hb_handle_s
 {
     /* The "Check for update" thread */
     int            build;
-    char           version[16];
+    char           version[32];
     hb_thread_t  * update_thread;
 
     /* This thread's only purpose is to check other threads'
@@ -41,13 +38,43 @@ struct hb_handle_s
     /* For MacGui active queue
        increments each time the scan thread completes*/
     int            scanCount;
+    
+    /* Stash of persistent data between jobs, for stuff
+       like correcting frame count and framerate estimates
+       on multi-pass encodes where frames get dropped.     */
+    hb_interjob_t * interjob;
 
 };
 
+hb_lock_t *hb_avcodec_lock;
 hb_work_object_t * hb_objects = NULL;
 
 static void thread_func( void * );
 
+void hb_avcodec_init()
+{
+    hb_avcodec_lock  = hb_lock_init();
+    av_register_all();
+}
+
+int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec)
+{
+    int ret;
+    hb_lock( hb_avcodec_lock );
+    ret = avcodec_open(avctx, codec);
+    hb_unlock( hb_avcodec_lock );
+    return ret;
+}
+
+int hb_avcodec_close(AVCodecContext *avctx)
+{
+    int ret;
+    hb_lock( hb_avcodec_lock );
+    ret = avcodec_close(avctx);
+    hb_unlock( hb_avcodec_lock );
+    return ret;
+}
+
 /**
  * Registers work objects, by adding the work object to a liked list.
  * @param w Handle to hb_work_object_t to register.
@@ -64,7 +91,7 @@ void hb_register( hb_work_object_t * w )
  * @param update_check signals libhb to check for updated version from HandBrake website.
  * @return Handle to hb_handle_t for use on all subsequent calls to libhb.
  */
-hb_handle_t * hb_init_real( int verbose, int update_check )
+hb_handle_t * hb_init( int verbose, int update_check )
 {
     hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 );
     uint64_t      date;
@@ -120,19 +147,41 @@ hb_handle_t * hb_init_real( int verbose, int update_check )
 
     h->pause_lock = hb_lock_init();
 
+    h->interjob = calloc( sizeof( hb_interjob_t ), 1 );
+
     /* libavcodec */
-    av_register_all();
+    hb_avcodec_init();
 
     /* Start library thread */
     hb_log( "hb_init: starting libhb thread" );
     h->die         = 0;
     h->main_thread = hb_thread_init( "libhb", thread_func, h,
                                      HB_NORMAL_PRIORITY );
+    hb_register( &hb_sync );
+       hb_register( &hb_decmpeg2 );
+       hb_register( &hb_decvobsub );
+    hb_register( &hb_encvobsub );
+    hb_register( &hb_deccc608 );
+    hb_register( &hb_decsrtsub );
+       hb_register( &hb_render );
+       hb_register( &hb_encavcodec );
+       hb_register( &hb_encx264 );
+    hb_register( &hb_enctheora );
+       hb_register( &hb_deca52 );
+       hb_register( &hb_decdca );
+       hb_register( &hb_decavcodec );
+       hb_register( &hb_decavcodecv );
+       hb_register( &hb_decavcodecvi );
+       hb_register( &hb_decavcodecai );
+       hb_register( &hb_declpcm );
+       hb_register( &hb_encfaac );
+       hb_register( &hb_enclame );
+       hb_register( &hb_encvorbis );
+#ifdef __APPLE__
+       hb_register( &hb_encca_aac );
+#endif
 
     return h;
-
-       /* Set the scan count to start at 0 */
-       //scan_count = 0;
 }
 
 /**
@@ -207,10 +256,12 @@ hb_handle_t * hb_init_dl( int verbose, int update_check )
 
     hb_register( &hb_sync );
        hb_register( &hb_decmpeg2 );
-       hb_register( &hb_decsub );
+       hb_register( &hb_decvobsub );
+    hb_register( &hb_encvobsub );
+    hb_register( &hb_deccc608 );
+    hb_register( &hb_decsrtsub );
        hb_register( &hb_render );
        hb_register( &hb_encavcodec );
-       hb_register( &hb_encxvid );
        hb_register( &hb_encx264 );
     hb_register( &hb_enctheora );
        hb_register( &hb_deca52 );
@@ -223,6 +274,9 @@ hb_handle_t * hb_init_dl( int verbose, int update_check )
        hb_register( &hb_encfaac );
        hb_register( &hb_enclame );
        hb_register( &hb_encvorbis );
+#ifdef __APPLE__
+       hb_register( &hb_encca_aac );
+#endif
 
        return h;
 }
@@ -235,7 +289,7 @@ hb_handle_t * hb_init_dl( int verbose, int update_check )
  */
 char * hb_get_version( hb_handle_t * h )
 {
-    return HB_VERSION;
+    return HB_PROJECT_VERSION;
 }
 
 /**
@@ -245,7 +299,7 @@ char * hb_get_version( hb_handle_t * h )
  */
 int hb_get_build( hb_handle_t * h )
 {
-    return HB_BUILD;
+    return HB_PROJECT_BUILD;
 }
 
 /**
@@ -273,16 +327,60 @@ void hb_set_cpu_count( hb_handle_t * h, int cpu_count )
 }
 
 /**
+ * Deletes current previews associated with titles
+ * @param h Handle to hb_handle_t
+ */
+void hb_remove_previews( hb_handle_t * h )
+{
+    char            filename[1024];
+    char            dirname[1024];
+    hb_title_t    * title;
+    int             i, count, len;
+    DIR           * dir;
+    struct dirent * entry;
+
+    memset( dirname, 0, 1024 );
+    hb_get_tempory_directory( h, dirname );
+    dir = opendir( dirname );
+    if (dir == NULL) return;
+
+    count = hb_list_count( h->list_title );
+    while( ( entry = readdir( dir ) ) )
+    {
+        if( entry->d_name[0] == '.' )
+        {
+            continue;
+        }
+        for( i = 0; i < count; i++ )
+        {
+            title = hb_list_item( h->list_title, i );
+            len = snprintf( filename, 1024, "%" PRIxPTR, (intptr_t) title );
+            if (strncmp(entry->d_name, filename, len) == 0)
+            {
+                snprintf( filename, 1024, "%s/%s", dirname, entry->d_name );
+                unlink( filename );
+                break;
+            }
+        }
+    }
+    closedir( dir );
+}
+
+/**
  * Initializes a scan of the by calling hb_scan_init
  * @param h Handle to hb_handle_t
  * @param path location of VIDEO_TS folder.
  * @param title_index Desired title to scan.  0 for all titles.
+ * @param preview_count Number of preview images to generate.
+ * @param store_previews Whether or not to write previews to disk.
  */
-void hb_scan( hb_handle_t * h, const char * path, int title_index )
+void hb_scan( hb_handle_t * h, const char * path, int title_index,
+              int preview_count, int store_previews )
 {
     hb_title_t * title;
 
     /* Clean up from previous scan */
+    hb_remove_previews( h );
     while( ( title = hb_list_item( h->list_title, 0 ) ) )
     {
         hb_list_rem( h->list_title, title );
@@ -290,7 +388,8 @@ void hb_scan( hb_handle_t * h, const char * path, int title_index )
     }
 
     hb_log( "hb_scan: path=%s, title_index=%d", path, title_index );
-    h->scan_thread = hb_scan_init( h, path, title_index, h->list_title );
+    h->scan_thread = hb_scan_init( h, path, title_index, h->list_title,
+                                   preview_count, store_previews );
 }
 
 /**
@@ -317,39 +416,36 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
     char                 filename[1024];
     FILE               * file;
     uint8_t            * buf1, * buf2, * buf3, * buf4, * pen;
-    uint32_t           * p32, swsflags;
+    uint32_t             swsflags;
     AVPicture            pic_in, pic_preview, pic_deint, pic_crop, pic_scale;
     struct SwsContext  * context;
     int                  i;
     int                  rgb_width = ((job->width + 7) >> 3) << 3;
     int                  preview_size;
 
-    swsflags = SWS_LANCZOS;
-#ifndef __x86_64__
-    swsflags |= SWS_ACCURATE_RND;
-#endif  /* __x86_64__ */
+    swsflags = SWS_LANCZOS | SWS_ACCURATE_RND;
 
     buf1 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, title->width, title->height ) );
     buf2 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, title->width, title->height ) );
-    buf3 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, job->width, job->height ) );
-    buf4 = av_malloc( avpicture_get_size( PIX_FMT_RGBA32, rgb_width, job->height ) );
+    buf3 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, rgb_width, job->height ) );
+    buf4 = av_malloc( avpicture_get_size( PIX_FMT_RGB32, rgb_width, job->height ) );
     avpicture_fill( &pic_in, buf1, PIX_FMT_YUV420P,
                     title->width, title->height );
     avpicture_fill( &pic_deint, buf2, PIX_FMT_YUV420P,
                     title->width, title->height );
     avpicture_fill( &pic_scale, buf3, PIX_FMT_YUV420P,
-                    job->width, job->height );
-    avpicture_fill( &pic_preview, buf4, PIX_FMT_RGBA32,
+                    rgb_width, job->height );
+    avpicture_fill( &pic_preview, buf4, PIX_FMT_RGB32,
                     rgb_width, job->height );
 
     // Allocate the AVPicture frames and fill in
 
     memset( filename, 0, 1024 );
 
-    hb_get_tempory_filename( h, filename, "%x%d",
+    hb_get_tempory_filename( h, filename, "%" PRIxPTR "%d",
                              (intptr_t) title, picture );
 
-    file = fopen( filename, "r" );
+    file = fopen( filename, "rb" );
     if( !file )
     {
         hb_log( "hb_get_preview: fopen failed" );
@@ -389,7 +485,7 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
 
     // Get preview context
     context = sws_getContext(rgb_width, job->height, PIX_FMT_YUV420P,
-                              rgb_width, job->height, PIX_FMT_RGBA32,
+                              rgb_width, job->height, PIX_FMT_RGB32,
                               swsflags, NULL, NULL, NULL);
 
     // Create preview
@@ -401,31 +497,13 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
     // Free context
     sws_freeContext( context );
 
-    /* Gray background */
-    p32 = (uint32_t *) buffer;
-    for( i = 0; i < ( title->width + 2 ) * ( title->height + 2 ); i++ )
-    {
-        p32[i] = 0xFF808080;
-    }
-
-    /* Draw the picture, centered, and draw the cropping zone */
     preview_size = pic_preview.linesize[0];
-    pen = buffer + ( title->height - job->height ) *
-        ( title->width + 2 ) * 2 + ( title->width - job->width ) * 2;
-    memset( pen, 0xFF, 4 * ( job->width + 2 ) );
-    pen += 4 * ( title->width + 2 );
+    pen = buffer;
     for( i = 0; i < job->height; i++ )
     {
-        uint8_t * nextLine;
-        nextLine = pen + 4 * ( title->width + 2 );
-        memset( pen, 0xFF, 4 );
-        pen += 4;
         memcpy( pen, buf4 + preview_size * i, 4 * job->width );
         pen += 4 * job->width;
-        memset( pen, 0xFF, 4 );
-        pen = nextLine;
     }
-    memset( pen, 0xFF, 4 * ( job->width + 2 ) );
 
     // Clean up
     avpicture_free( &pic_preview );
@@ -453,7 +531,8 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
  */
 int hb_detect_comb( hb_buffer_t * buf, int width, int height, int color_equal, int color_diff, int threshold, int prog_equal, int prog_diff, int prog_threshold )
 {
-    int j, k, n, off, cc_1, cc_2, cc[3], flag[3] ;
+    int j, k, n, off, cc_1, cc_2, cc[3];
+       // int flag[3] ; // debugging flag
     uint16_t s1, s2, s3, s4;
     cc_1 = 0; cc_2 = 0;
 
@@ -557,60 +636,20 @@ void hb_set_anamorphic_size( hb_job_t * job,
         int *output_width, int *output_height,
         int *output_par_width, int *output_par_height )
 {
-    /* "Loose" anamorphic.
-        - Uses mod16-compliant dimensions,
-        - Allows users to set the width
-        - Handles ITU pixel aspects
-    */
-
     /* Set up some variables to make the math easier to follow. */
     hb_title_t * title = job->title;
     int cropped_width = title->width - job->crop[2] - job->crop[3] ;
     int cropped_height = title->height - job->crop[0] - job->crop[1] ;
     double storage_aspect = (double)cropped_width / (double)cropped_height;
-    int width = job->width;
-    int height; // Gets set later, ignore user job->height value
-    int mod = job->modulus;
+    int mod = job->anamorphic.modulus ? job->anamorphic.modulus : 16;
     double aspect = title->aspect;
-
-    /* Gotta handle bounding dimensions differently
-       than for non-anamorphic encodes:
-       If the width is too big, just reset it with no rescaling.
-       Instead of using the aspect-scaled job height,
-       we need to see if the job width divided by the storage aspect
-       is bigger than the max. If so, set it to the max (this is sloppy).
-       If not, set job height to job width divided by storage aspect.
-    */
-
-    if ( job->maxWidth && (job->maxWidth < job->width) )
-        width = job->maxWidth;
-
-    height = (double)width / storage_aspect;
-    if ( job->maxHeight && (job->maxHeight < height) )
-        height = job->maxHeight;
-
-    /* In case the user specified a modulus, use it */
-    if (job->modulus)
-        mod = job->modulus;
-    else
-        mod = 16;
-
-    /* Time to get picture dimensions that divide cleanly.*/
-    width  = MULTIPLE_MOD( width, mod);
-    height = MULTIPLE_MOD( height, mod);
-
-    /* Verify these new dimensions don't violate max height and width settings */
-    if ( job->maxWidth && (job->maxWidth < job->width) )
-        width = job->maxWidth;
-    if ( job->maxHeight && (job->maxHeight < height) )
-        height = job->maxHeight;
-    
-    int pixel_aspect_width = job->pixel_aspect_width;
-    int pixel_aspect_height = job->pixel_aspect_height;
     
-    /* If a source was really 704*480 and hard matted with cropping
-       to 720*480, replace the PAR values with the ITU broadcast ones. */
-    if (title->width == 720 && cropped_width <= 706)
+    int pixel_aspect_width  = job->anamorphic.par_width;
+    int pixel_aspect_height = job->anamorphic.par_height;
+
+    /* If a source was really NTSC or PAL and the user specified ITU PAR
+       values, replace the standard PAR values with the ITU broadcast ones. */
+    if( title->width == 720 && job->anamorphic.itu_par )
     {
         // convert aspect to a scaled integer so we can test for 16:9 & 4:3
         // aspect ratios ignoring insignificant differences in the LSBs of
@@ -652,20 +691,139 @@ void hb_set_anamorphic_size( hb_job_t * job,
         }
     }
 
-    /* Figure out what dimensions the source would display at. */
+    /* Figure out what width the source would display at. */
     int source_display_width = cropped_width * (double)pixel_aspect_width /
                                (double)pixel_aspect_height ;
 
-    /* The film AR is the source's display width / cropped source height.
-       The output display width is the output height * film AR.
-       The output PAR is the output display width / output storage width. */
-    pixel_aspect_width = height * source_display_width / cropped_height;
-    pixel_aspect_height = width;
-
-    /* Pass the results back to the caller */
-    *output_width = width;
-    *output_height = height;
-
+    /*
+       3 different ways of deciding output dimensions:
+        - 1: Strict anamorphic, preserve source dimensions
+        - 2: Loose anamorphic, round to mod16 and preserve storage aspect ratio
+        - 3: Power user anamorphic, specify everything
+    */
+    int width, height;
+    switch( job->anamorphic.mode )
+    {
+        case 1:
+            /* Strict anamorphic */
+            *output_width = cropped_width;
+            *output_height = cropped_height;
+            *output_par_width = title->pixel_aspect_width;
+            *output_par_height = title->pixel_aspect_height;
+        break;
+
+        case 2:
+            /* "Loose" anamorphic.
+                - Uses mod16-compliant dimensions,
+                - Allows users to set the width
+            */
+            width = job->width;
+            // height: Gets set later, ignore user job->height value
+
+            /* Gotta handle bounding dimensions.
+               If the width is too big, just reset it with no rescaling.
+               Instead of using the aspect-scaled job height,
+               we need to see if the job width divided by the storage aspect
+               is bigger than the max. If so, set it to the max (this is sloppy).
+               If not, set job height to job width divided by storage aspect.
+            */
+
+            if ( job->maxWidth && (job->maxWidth < job->width) )
+                width = job->maxWidth;
+
+            /* Time to get picture width that divide cleanly.*/
+            width  = MULTIPLE_MOD( width, mod);
+
+            /* Verify these new dimensions don't violate max height and width settings */
+            if ( job->maxWidth && (job->maxWidth < job->width) )
+                width = job->maxWidth;
+
+            height = ((double)width / storage_aspect) + 0.5;
+            
+            if ( job->maxHeight && (job->maxHeight < height) )
+                height = job->maxHeight;
+
+            /* Time to get picture height that divide cleanly.*/
+            height = MULTIPLE_MOD( height, mod);
+
+            /* Verify these new dimensions don't violate max height and width settings */
+            if ( job->maxHeight && (job->maxHeight < height) )
+                height = job->maxHeight;
+
+            /* The film AR is the source's display width / cropped source height.
+               The output display width is the output height * film AR.
+               The output PAR is the output display width / output storage width. */
+            pixel_aspect_width = height * source_display_width / cropped_height;
+            pixel_aspect_height = width;
+
+            /* Pass the results back to the caller */
+            *output_width = width;
+            *output_height = height;
+        break;
+            
+        case 3:
+            /* Anamorphic 3: Power User Jamboree
+               - Set everything based on specified values */
+            
+            /* Use specified storage dimensions */
+            width = job->width;
+            height = job->height;
+            
+            /* Bind to max dimensions */
+            if( job->maxWidth && width > job->maxWidth )
+                width = job->maxWidth;
+            if( job->maxHeight && height > job->maxHeight )
+                height = job->maxHeight;
+            
+            /* Time to get picture dimensions that divide cleanly.*/
+            width  = MULTIPLE_MOD( width, mod);
+            height = MULTIPLE_MOD( height, mod);
+            
+            /* Verify we're still within max dimensions */
+            if( job->maxWidth && width > job->maxWidth )
+                width = job->maxWidth - (mod/2);
+            if( job->maxHeight && height > job->maxHeight )
+                height = job->maxHeight - (mod/2);
+                
+            /* Re-ensure we have picture dimensions that divide cleanly. */
+            width  = MULTIPLE_MOD( width, mod );
+            height = MULTIPLE_MOD( height, mod );
+            
+            /* That finishes the storage dimensions. On to display. */            
+            if( job->anamorphic.dar_width && job->anamorphic.dar_height )
+            {
+                /* We need to adjust the PAR to produce this aspect. */
+                pixel_aspect_width = height * job->anamorphic.dar_width / job->anamorphic.dar_height;
+                pixel_aspect_height = width;
+            }
+            else
+            {
+                /* If we're doing ana 3 and not specifying a DAR, care needs to be taken.
+                   This indicates a PAR is potentially being set by the interface. But
+                   this is an output PAR, to correct a source, and it should not be assumed
+                   that it properly creates a display aspect ratio when applied to the source,
+                   which could easily be stored in a different resolution. */
+                if( job->anamorphic.keep_display_aspect )
+                {
+                    /* We can ignore the possibility of a PAR change */
+                    pixel_aspect_width = height * ( (double)source_display_width / (double)cropped_height );
+                    pixel_aspect_height = width;
+                }
+                else
+                {
+                    int output_display_width = width * (double)pixel_aspect_width /
+                        (double)pixel_aspect_height;
+                    pixel_aspect_width = output_display_width;
+                    pixel_aspect_height = width;
+                }
+            }
+            
+            /* Back to caller */
+            *output_width = width;
+            *output_height = height;
+        break;
+    }
+    
     /* While x264 is smart enough to reduce fractions on its own, libavcodec
        needs some help with the math, so lose superfluous factors.            */
     hb_reduce( output_par_width, output_par_height,
@@ -816,6 +974,34 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
         hb_list_add( title_copy->list_chapter, chapter_copy );
     }
 
+    /*
+     * Copy the metadata
+     */
+    if( title->metadata )
+    {
+        title_copy->metadata = malloc( sizeof( hb_metadata_t ) );
+        
+        if( title_copy->metadata ) 
+        {
+            memcpy( title_copy->metadata, title->metadata, sizeof( hb_metadata_t ) );
+
+            /*
+             * Need to copy the artwork seperatly (TODO).
+             */
+            if( title->metadata->coverart )
+            {
+                title_copy->metadata->coverart = malloc( title->metadata->coverart_size );
+                if( title_copy->metadata->coverart )
+                {
+                    memcpy( title_copy->metadata->coverart, title->metadata->coverart,
+                            title->metadata->coverart_size );
+                } else {
+                    title_copy->metadata->coverart_size = 0; 
+                }
+            }
+        }
+    }
+
     /* Copy the audio track(s) we want */
     title_copy->list_audio = hb_list_init();
 
@@ -830,7 +1016,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
     title_copy->list_subtitle = hb_list_init();
 
     /*
-     * The following code is confusing, there are three ways in which
+     * The following code is confusing, there are two ways in which
      * we select subtitles and it depends on whether this is single or
      * two pass mode.
      *
@@ -838,17 +1024,13 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
      * scans all subtitles of that language. The second pass does not
      * select any because they are set at the end of the first pass.
      *
-     * native_language may have a preferred language, in which case we
-     * may be switching the language we want for the subtitles in the
-     * first pass of a single pass, or the second pass of a two pass.
-     *
      * We may have manually selected a subtitle, in which case that is
      * selected in the first pass of a single pass, or the second of a
      * two pass.
      */
     memset( audio_lang, 0, sizeof( audio_lang ) );
 
-    if ( job->indepth_scan || job->native_language ) {
+    if ( job->indepth_scan ) {
 
         /*
          * Find the first audio language that is being encoded
@@ -861,35 +1043,6 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
                 break;
             }
         }
-
-        /*
-         * In all cases switch the language if we need to to our native
-         * language.
-         */
-        if( job->native_language )
-        {
-            if( strncasecmp( job->native_language, audio_lang,
-                             sizeof( audio_lang ) ) != 0 )
-            {
-
-                if( job->pass != 2 )
-                {
-                    hb_log( "Enabled subtitles in native language '%s', audio is in '%s'",
-                            job->native_language, audio_lang);
-                }
-                /*
-                 * The main audio track is not in our native language, so switch
-                 * the subtitles to use our native language instead.
-                 */
-                strncpy( audio_lang, job->native_language, sizeof( audio_lang ) );
-            } else {
-                /*
-                 * native language is irrelevent, free it.
-                 */
-                free( job->native_language );
-                job->native_language = NULL;
-            }
-        }
     }
 
     /*
@@ -901,7 +1054,8 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
         for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
         {
             subtitle = hb_list_item( title->list_subtitle, i );
-            if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+            if( strcmp( subtitle->iso639_2, audio_lang ) == 0 &&
+                subtitle->source == VOBSUB )
             {
                 /*
                  * Matched subtitle language with audio language, so
@@ -913,14 +1067,6 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
                 subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
                 memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
                 hb_list_add( title_copy->list_subtitle, subtitle_copy );
-                if ( job->native_language ) {
-                    /*
-                     * With native language just select the
-                     * first match in our langiage, not all of
-                     * them. Subsequent ones are likely to be commentary
-                     */
-                    break;
-                }
             }
         }
     } else {
@@ -928,52 +1074,17 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
          * Not doing a subtitle scan in this pass, but maybe we are in the
          * first pass?
          */
-        if( job->select_subtitle )
+        if( job->pass != 1 )
         {
             /*
-             * Don't add subtitles here, we'll add them via select_subtitle
-             * at the end of the subtitle_scan.
+             * Copy all of them from the input job, to the title_copy/job_copy.
              */
-        } else {
-            /*
-             * Definitely not doing a subtitle scan.
-             */
-            if( job->pass != 1 && job->native_language )
-            {
-                /*
-                 * We are not doing a subtitle scan but do want the
-                 * native langauge subtitle selected, so select it
-                 * for pass 0 or pass 2 of a two pass.
-                 */
-                for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
-                {
-                    subtitle = hb_list_item( title->list_subtitle, i );
-                    if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
-                    {
-                        /*
-                         * Matched subtitle language with audio language, so
-                         * add this to our list to scan.
-                         */
-                        subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
-                        memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
-                        hb_list_add( title_copy->list_subtitle, subtitle_copy );
-                        break;
-                    }
-                }
-            } else {
-                /*
-                 * Manually selected subtitle, in which case only
-                 * bother adding them for pass 0 or pass 2 of a two
-                 * pass.
-                 */
-                if( job->pass != 1 )
+            for(  i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
+                if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
                 {
-                    if( ( subtitle = hb_list_item( title->list_subtitle, job->subtitle ) ) )
-                    {
-                        subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
-                        memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
-                        hb_list_add( title_copy->list_subtitle, subtitle_copy );
-                    }
+                    subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
+                    memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
+                    hb_list_add( title_copy->list_subtitle, subtitle_copy );
                 }
             }
         }
@@ -985,6 +1096,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
     title_copy->job = job_copy;
     job_copy->title = title_copy;
     job_copy->list_audio = title_copy->list_audio;
+    job_copy->list_subtitle = title_copy->list_subtitle;   // sharing list between title and job
     job_copy->file  = strdup( job->file );
     job_copy->h     = h;
     job_copy->pause = h->pause_lock;
@@ -1083,6 +1195,8 @@ void hb_pause( hb_handle_t * h )
         hb_lock( h->pause_lock );
         h->paused = 1;
 
+        hb_current_job( h )->st_pause_date = hb_get_date();
+
         hb_lock( h->state_lock );
         h->state.state = HB_STATE_PAUSED;
         hb_unlock( h->state_lock );
@@ -1097,6 +1211,13 @@ void hb_resume( hb_handle_t * h )
 {
     if( h->paused )
     {
+#define job hb_current_job( h )
+        if( job->st_pause_date != -1 )
+        {
+           job->st_paused += hb_get_date() - job->st_pause_date;
+        }
+#undef job
+
         hb_unlock( h->pause_lock );
         h->paused = 0;
     }
@@ -1151,7 +1272,7 @@ int hb_get_scancount( hb_handle_t * h)
  }
 
 /**
- * Closes access to libhb by freeing the hb_handle_t handle ontained in hb_init_real.
+ * Closes access to libhb by freeing the hb_handle_t handle ontained in hb_init.
  * @param _h Pointer to handle to hb_handle_t.
  */
 void hb_close( hb_handle_t ** _h )
@@ -1314,3 +1435,9 @@ void hb_set_state( hb_handle_t * h, hb_state_t * s )
     hb_unlock( h->state_lock );
     hb_unlock( h->pause_lock );
 }
+
+/* Passes a pointer to persistent data */
+hb_interjob_t * hb_interjob_get( hb_handle_t * h )
+{
+    return h->interjob;
+}
index 8bfd9a1..234d4b5 100644 (file)
@@ -5,7 +5,7 @@
 extern "C" {
 #endif
 
-#include "hbversion.h"
+#include "project.h"
 #include "common.h"
 
 /* hb_init()
@@ -14,47 +14,9 @@ extern "C" {
 #define HB_DEBUG_NONE 0
 #define HB_DEBUG_ALL  1
 void          hb_register( hb_work_object_t * );
-hb_handle_t * hb_init_real( int verbose, int update_check );
+hb_handle_t * hb_init( int verbose, int update_check );
 hb_handle_t * hb_init_dl ( int verbose, int update_check ); // hb_init for use with dylib
 
-#define hb_init(v,u) \
-hb_init_real( v, u ); \
-hb_register( &hb_sync ); \
-hb_register( &hb_decmpeg2 ); \
-hb_register( &hb_decsub ); \
-hb_register( &hb_render ); \
-hb_register( &hb_encavcodec ); \
-hb_register( &hb_encxvid ); \
-hb_register( &hb_encx264 ); \
-hb_register( &hb_enctheora ); \
-hb_register( &hb_deca52 ); \
-hb_register( &hb_decdca ); \
-hb_register( &hb_decavcodec ); \
-hb_register( &hb_decavcodecv ); \
-hb_register( &hb_decavcodecvi ); \
-hb_register( &hb_decavcodecai ); \
-hb_register( &hb_declpcm ); \
-hb_register( &hb_encfaac ); \
-hb_register( &hb_enclame ); \
-hb_register( &hb_encvorbis ); \
-
-#define hb_init_express(v,u) \
-hb_init_real( v, u ); \
-hb_register( &hb_sync ); \
-hb_register( &hb_decmpeg2 ); \
-hb_register( &hb_decsub ); \
-hb_register( &hb_render ); \
-hb_register( &hb_encavcodec ); \
-hb_register( &hb_encx264 ); \
-hb_register( &hb_deca52 ); \
-hb_register( &hb_decdca ); \
-hb_register( &hb_decavcodec ); \
-hb_register( &hb_decavcodecv ); \
-hb_register( &hb_decavcodecvi ); \
-hb_register( &hb_decavcodecai ); \
-hb_register( &hb_declpcm ); \
-hb_register( &hb_encfaac ); \
-
 /* hb_get_version() */
 char        * hb_get_version( hb_handle_t * );
 int           hb_get_build( hb_handle_t * );
@@ -72,12 +34,14 @@ int           hb_check_update( hb_handle_t * h, char ** version );
 void          hb_set_cpu_count( hb_handle_t *, int );
 
 char *        hb_dvd_name( char * path );
+void          hb_dvd_set_dvdnav( int enable );
 
 /* hb_scan()
    Scan the specified path. Can be a DVD device, a VIDEO_TS folder or
    a VOB file. If title_index is 0, scan all titles. */
 void          hb_scan( hb_handle_t *, const char * path,
-                       int title_index );
+                       int title_index, int preview_count,
+                       int store_previews );
 
 /* hb_get_titles()
    Returns the list of valid titles detected by the latest scan. */
@@ -106,6 +70,21 @@ void          hb_pause( hb_handle_t * );
 void          hb_resume( hb_handle_t * );
 void          hb_stop( hb_handle_t * );
 
+/* Persistent data between jobs. */
+typedef struct hb_interjob_s
+{
+    int last_job;          /* job->sequence_id & 0xFFFFFF */
+    int frame_count;       /* number of frames counted by sync */
+    uint64_t total_time;   /* real length in 90khz (i.e. / 90000 */
+    int render_dropped;    /* frames droped by telecine */
+    int vrate;             /* initial assigned vrate */
+    int vrate_base;        /* initial assigned vrate_base */
+
+    hb_subtitle_t *select_subtitle; /* foreign language scan subtitle */
+} hb_interjob_t;
+
+hb_interjob_t * hb_interjob_get( hb_handle_t * ); 
+
 /* hb_get_state()
    Should be regularly called by the UI (like 5 or 10 times a second).
    Look at test/test.c to see how to use it. */
diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h
new file mode 100644 (file)
index 0000000..e0a7634
--- /dev/null
@@ -0,0 +1,11 @@
+/* This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#include "libavcodec/avcodec.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+
+void hb_avcodec_init(void);
+int hb_avcodec_open( AVCodecContext *, struct AVCodec * );
+int hb_avcodec_close( AVCodecContext * );
index 3ae1dad..9a03074 100644 (file)
@@ -7,7 +7,7 @@
 /***********************************************************************
  * common.c
  **********************************************************************/
-void hb_log( char * log, ... );
+void hb_log( char * log, ... ) HB_WPRINTF(1,2);
 extern int global_verbosity_level; // Global variable for hb_deep_log
 typedef enum hb_debug_level_s
 {
@@ -15,8 +15,8 @@ typedef enum hb_debug_level_s
     HB_HOUSEKEEPING_LOG = 2, // stuff we hate scrolling through  
     HB_GRANULAR_LOG     = 3  // sample-by-sample
 } hb_debug_level_t;
-void hb_deep_log( hb_debug_level_t level, char * log, ... );
-void hb_error( char * fmt, ...);
+void hb_deep_log( hb_debug_level_t level, char * log, ... ) HB_WPRINTF(2,3);
+void hb_error( char * fmt, ...) HB_WPRINTF(1,2);
 
 int  hb_list_bytes( hb_list_t * );
 void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size );
@@ -111,12 +111,29 @@ static inline hb_buffer_t * hb_video_buffer_init( int width, int height )
                            ( ( height+1 ) >> 1 ) * 2 );
 }
 
+// this routine 'moves' data from src to dst by interchanging 'data',
+// 'size' & 'alloc' between them and copying the rest of the fields
+// from src to dst.
+static inline void hb_buffer_swap_copy( hb_buffer_t *src, hb_buffer_t *dst )
+{
+    uint8_t *data  = dst->data;
+    int      size  = dst->size;
+    int      alloc = dst->alloc;
+
+    *dst = *src;
+
+    src->data  = data;
+    src->size  = size;
+    src->alloc = alloc;
+}
+
 /***********************************************************************
  * Threads: update.c, scan.c, work.c, reader.c, muxcommon.c
  **********************************************************************/
 hb_thread_t * hb_update_init( int * build, char * version );
 hb_thread_t * hb_scan_init( hb_handle_t *, const char * path,
-                            int title_index, hb_list_t * list_title );
+                            int title_index, hb_list_t * list_title,
+                            int preview_count, int store_previews );
 hb_thread_t * hb_work_init( hb_list_t * jobs, int cpu_count,
                             volatile int * die, int * error, hb_job_t ** job );
 hb_thread_t  * hb_reader_init( hb_job_t * );
@@ -130,36 +147,51 @@ hb_work_object_t * hb_codec_encoder( int );
  **********************************************************************/
 typedef struct {
     int64_t last_scr;       /* unadjusted SCR from most recent pack */
+    int64_t last_pts;       /* last pts we saw */
     int     scr_changes;    /* number of SCR discontinuities */
-    int     flaky_clock;    /* try to compensate for PCR drops */
     int     dts_drops;      /* number of drops because DTS too far from SCR */
 } hb_psdemux_t;
 
+typedef int (*hb_muxer_t)(hb_buffer_t *, hb_list_t *, hb_psdemux_t*);
+
 int hb_demux_ps( hb_buffer_t * ps_buf, hb_list_t * es_list, hb_psdemux_t * );
+int hb_demux_ss( hb_buffer_t * ps_buf, hb_list_t * es_list, hb_psdemux_t * );
 int hb_demux_null( hb_buffer_t * ps_buf, hb_list_t * es_list, hb_psdemux_t * );
 
+extern const hb_muxer_t hb_demux[];
+
+/***********************************************************************
+ * decmetadata.c
+ **********************************************************************/
+extern void decmetadata( hb_title_t *title );
+
 /***********************************************************************
  * dvd.c
  **********************************************************************/
-typedef struct hb_dvd_s hb_dvd_t;
+typedef union  hb_dvd_s hb_dvd_t;
 typedef struct hb_stream_s hb_stream_t;
 
 hb_dvd_t *   hb_dvd_init( char * path );
 int          hb_dvd_title_count( hb_dvd_t * );
 hb_title_t * hb_dvd_title_scan( hb_dvd_t *, int title );
-int          hb_dvd_start( hb_dvd_t *, int title, int chapter );
+int          hb_dvd_start( hb_dvd_t *, hb_title_t *title, int chapter );
 void         hb_dvd_stop( hb_dvd_t * );
 int          hb_dvd_seek( hb_dvd_t *, float );
 int          hb_dvd_read( hb_dvd_t *, hb_buffer_t * );
 int          hb_dvd_chapter( hb_dvd_t * );
 int          hb_dvd_is_break( hb_dvd_t * d );
 void         hb_dvd_close( hb_dvd_t ** );
+int          hb_dvd_angle_count( hb_dvd_t * d );
+void         hb_dvd_set_angle( hb_dvd_t * d, int angle );
 
 hb_stream_t * hb_stream_open( char * path, hb_title_t *title );
 void            hb_stream_close( hb_stream_t ** );
 hb_title_t * hb_stream_title_scan( hb_stream_t *);
 int          hb_stream_read( hb_stream_t *, hb_buffer_t *);
 int          hb_stream_seek( hb_stream_t *, float );
+int          hb_stream_seek_chapter( hb_stream_t *, int );
+int          hb_stream_chapter( hb_stream_t * );
+
 
 void       * hb_ffmpeg_context( int codec_param );
 void       * hb_ffmpeg_avstream( int codec_param );
@@ -206,7 +238,11 @@ union hb_esconfig_u
     struct
     {
        /* ac3flags stores the flags from the AC3 source, as found in scan.c */
-       int  ac3flags;
+       int     ac3flags;
+        // next two items are used by the bsinfo routine to accumulate small
+        // frames until we have enough to validate the crc.
+        int     len;        // space currently used in 'buf'
+        uint8_t buf[HB_CONFIG_MAX_SIZE-sizeof(int)];
     } a52;
 
     struct
@@ -221,10 +257,12 @@ enum
 {
     WORK_SYNC = 1,
     WORK_DECMPEG2,
-    WORK_DECSUB,
+    WORK_DECCC608,
+    WORK_DECVOBSUB,
+    WORK_DECSRTSUB,
+    WORK_ENCVOBSUB,
     WORK_RENDER,
     WORK_ENCAVCODEC,
-    WORK_ENCXVID,
     WORK_ENCX264,
     WORK_ENCTHEORA,
     WORK_DECA52,
@@ -236,7 +274,8 @@ enum
     WORK_DECLPCM,
     WORK_ENCFAAC,
     WORK_ENCLAME,
-    WORK_ENCVORBIS
+    WORK_ENCVORBIS,
+    WORK_ENC_CA_AAC
 };
 
 enum
diff --git a/libhb/module.defs b/libhb/module.defs
new file mode 100644 (file)
index 0000000..f3da3c0
--- /dev/null
@@ -0,0 +1,103 @@
+__deps__ := A52DEC BZIP2 FAAC FAAD2 FFMPEG LAME LIBDCA \
+    LIBDVDREAD LIBDVDNAV LIBICONV LIBMKV LIBOGG LIBSAMPLERATE LIBTHEORA LIBVORBIS \
+    MP4V2 MPEG2DEC PTHREADW32 X264 ZLIB
+
+$(eval $(call import.MODULE.defs,LIBHB,libhb,$(__deps__)))
+$(eval $(call import.GCC,LIBHB))
+
+###############################################################################
+
+LIBHB.src/   = $(SRC/)libhb/
+LIBHB.build/ = $(BUILD/)libhb/
+
+LIBHB.m4.in  = $(wildcard $(LIBHB.src/)*.m4)
+LIBHB.m4.out = $(patsubst $(LIBHB.src/)%.m4,$(LIBHB.build/)%,$(LIBHB.m4.in))
+
+LIBHB.c   = $(wildcard $(LIBHB.src/)*.c)
+LIBHB.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%.o,$(LIBHB.c))
+LIBHB.d   = $(LIBHB.m4.out) $(LIBHB.h.out) \
+    $(foreach n,$(LIBHB.prerequisites),$($n.INSTALL.target) )
+
+LIBHB.h.in  = $(wildcard $(LIBHB.src/)*.h)
+LIBHB.h.out = $(patsubst $(SRC/)%,$(BUILD/)%,$(LIBHB.h.in))
+
+###############################################################################
+
+LIBHB.a = $(LIBHB.build/)$(call TARGET.archive,hb)
+
+###############################################################################
+
+LIBHB.out += $(LIBHB.m4.out)
+LIBHB.out += $(LIBHB.c.o)
+LIBHB.out += $(LIBHB.h.out)
+LIBHB.out += $(LIBHB.a)
+
+###############################################################################
+
+LIBHB.GCC.D += __LIBHB__ USE_PTHREAD
+LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+
+ifeq ($(BUILD.system),cygwin)
+    LIBHB.GCC.D += SYS_CYGWIN
+else ifeq ($(BUILD.system),darwin)
+    LIBHB.GCC.D += SYS_DARWIN
+    LIBHB.c += $(wildcard $(LIBHB.src/)platform/macosx/*.c)
+else ifeq ($(BUILD.system),linux)
+    LIBHB.GCC.D += SYS_LINUX _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64
+else ifeq ($(BUILD.system),mingw)
+    LIBHB.GCC.D += SYS_MINGW PTW32_STATIC_LIB
+else ifeq ($(BUILD.system),solaris)
+    LIBHB.GCC.D += SYS_SunOS _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64
+else
+    LIBHB.platform.D = SYS_UNKNOWN
+endif
+
+## required for <libdvdread/*.h>
+ifneq (,$(filter $(BUILD.arch),ppc ppc64))
+       LIBHB.GCC.D += WORDS_BIGENDIAN
+endif
+
+###############################################################################
+
+## when defined this gives us the subdir name, or flavor of asm implementation
+ifneq (disabled,$(FEATURE.asm))
+
+LIBHB.yasm.src/   = $(LIBHB.src/)$(FEATURE.asm)/
+LIBHB.yasm.build/ = $(LIBHB.build/)$(FEATURE.asm)/
+LIBHB.yasm.asm    = $(LIBHB.yasm.src/)deinterlace-a.asm
+LIBHB.yasm.o      = $(LIBHB.yasm.asm:$(LIBHB.yasm.src/)%.asm=$(LIBHB.yasm.build/)%.o)
+LIBHB.yasm.d      = $(wildcard $(LIBHB.yasmsrc/)*.h)
+
+LIBHB.YASM.I     = $(LIBHB.yasm.src/)
+LIBHB.YASM.ASM_O = $(strip $(YASM.exe) \
+    -f $(LIBHB.YASM.f) \
+    -m $(LIBHB.YASM.m) \
+    $(LIBHB.YASM.D:%=-D%) \
+    $(LIBHB.YASM.I:%=-I%) \
+    -o $(1) $(2))
+
+LIBHB.out += $(LIBHB.yasm.o)
+
+endif
+
+###############################################################################
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+
+LIBHB.dll = $(LIBHB.build/)hb.dll
+LIBHB.lib = $(LIBHB.build/)hb.lib
+
+LIBHB.dll.libs = $(foreach n, \
+        a52 bz2 avcodec avformat avutil dca dvdnav dvdread faac faad iconv mkv mpeg2 mp3lame mp4v2 \
+        ogg pthreadGC2 samplerate swscale theora vorbis vorbisenc x264 z, \
+        $(CONTRIB.build/)lib/lib$(n).a )
+
+LIBHB.GCC.args.extra.dylib++ = -Wl,--out-implib,$(LIBHB.lib)
+LIBHB.GCC.l += iberty ws2_32
+LIBHB.out += $(LIBHB.dll) $(LIBHB.lib)
+
+endif
+
+###############################################################################
+
+BUILD.out += $(LIBHB.out)
diff --git a/libhb/module.rules b/libhb/module.rules
new file mode 100644 (file)
index 0000000..c92abab
--- /dev/null
@@ -0,0 +1,52 @@
+$(eval $(call import.MODULE.rules,LIBHB))
+
+libhb.build: $(LIBHB.a)
+
+$(LIBHB.a): | $(dir $(LIBHB.a))
+$(LIBHB.a): $(LIBHB.c.o) $(LIBHB.yasm.o)
+       $(AR.exe) rsu $@ $^
+
+$(LIBHB.c.o): $(LIBHB.d)
+$(LIBHB.c.o): | $(dir $(LIBHB.c.o))
+$(LIBHB.c.o): $(BUILD/)%.o: $(SRC/)%.c
+       $(call LIBHB.GCC.C_O,$@,$<)
+
+$(LIBHB.m4.out): $(BUILD/)project/handbrake.m4
+$(LIBHB.m4.out): | $(dir $(LIBHB.m4.out))
+$(LIBHB.m4.out): $(LIBHB.build/)%: $(LIBHB.src/)%.m4
+       $(M4.exe) -Iproject $< > $@
+
+$(LIBHB.h.out): | $(dir $(LIBHB.h.out))
+$(LIBHB.h.out): $(BUILD/)%: $(SRC/)%
+       $(CP.exe) $< $@
+
+libhb.clean:
+       $(RM.exe) -f $(LIBHB.out)
+
+###############################################################################
+
+ifneq (disabled,$(FEATURE.asm))
+
+$(LIBHB.yasm.o): $(LIBHB.yasm.d)
+$(LIBHB.yasm.o): | $(dir $(LIBHB.yasm.o))
+$(LIBHB.yasm.o): $(LIBHB.yasm.build/)%.o: $(LIBHB.yasm.src/)%.asm
+       $(call LIBHB.YASM.ASM_O,$@,$<)
+
+endif
+
+###############################################################################
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+
+libhb.build: $(LIBHB.dll)
+
+$(LIBHB.dll): | $(dirname $(LIBHB.dll) $(LIBHB.lib))
+$(LIBHB.dll): $(LIBHB.c.o) $(LIBHB.yasm.o)
+       $(call LIBHB.GCC.DYLIB++,$@,$^ $(LIBHB.dll.libs))
+
+endif
+
+###############################################################################
+
+clean: libhb.clean
+build: libhb.build
index 9960433..85839e1 100644 (file)
@@ -5,7 +5,7 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-#include "libavcodec/avcodec.h"
+#include "hbffmpeg.h"
 
 #define AVIF_HASINDEX  0x10
 #define AVIIF_KEYFRAME 0x10
@@ -332,6 +332,7 @@ static int AVIInit( hb_mux_object_t * m )
     hb_mux_data_t * mux_data;
 
     int audio_count = hb_list_count( title->list_audio );
+    int is_passthru = 0;
     int is_ac3      = 0;
     int hdrl_bytes;
     int i;
@@ -366,8 +367,6 @@ static int AVIInit( hb_mux_object_t * m )
 
     if( job->vcodec == HB_VCODEC_FFMPEG )
         h.Handler = FOURCC( "divx" );
-    else if( job->vcodec == HB_VCODEC_XVID )
-        h.Handler = FOURCC( "xvid" );
     else if( job->vcodec == HB_VCODEC_X264 )
         h.Handler = FOURCC( "h264" );
 
@@ -386,15 +385,13 @@ static int AVIInit( hb_mux_object_t * m )
     f.BitCount    = 24;
     if( job->vcodec == HB_VCODEC_FFMPEG )
         f.Compression = FOURCC( "DX50" );
-    else if( job->vcodec == HB_VCODEC_XVID )
-        f.Compression = FOURCC( "XVID" );
     else if( job->vcodec == HB_VCODEC_X264 )
         f.Compression = FOURCC( "H264" );
 #undef f
 
 #define g mux_data->vprp_header
     /* Vprp video stream header */     
-    AVRational sample_aspect_ratio = ( AVRational ){ job->pixel_aspect_width, job->pixel_aspect_height };
+    AVRational sample_aspect_ratio = ( AVRational ){ job->anamorphic.par_width, job->anamorphic.par_height };
     AVRational dar = av_mul_q( sample_aspect_ratio, ( AVRational ){ job->width, job->height } );
     int num, den;
     av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
@@ -427,6 +424,8 @@ static int AVIInit( hb_mux_object_t * m )
         audio = hb_list_item( title->list_audio, i );
 
         is_ac3 = (audio->config.out.codec == HB_ACODEC_AC3);
+        is_passthru = (audio->config.out.codec == HB_ACODEC_AC3) ||
+                      (audio->config.out.codec == HB_ACODEC_DCA);
 
         mux_data = calloc( sizeof( hb_mux_data_t ), 1 );
         audio->priv.mux_data = mux_data;
@@ -440,17 +439,17 @@ static int AVIInit( hb_mux_object_t * m )
         h.Type          = FOURCC( "auds" );
         h.InitialFrames = 1;
         h.Scale         = 1;
-        h.Rate          = is_ac3 ? ( audio->config.in.bitrate / 8 ) :
+        h.Rate          = is_passthru ? ( audio->config.in.bitrate / 8 ) :
                                    ( audio->config.out.bitrate * 1000 / 8 );
         h.Quality       = 0xFFFFFFFF;
         h.SampleSize    = 1;
 
         /* Audio stream format */
         f.FourCC         = FOURCC( "strf" );
-        if( is_ac3 )
+        if( is_passthru )
         {
             f.BytesCount     = sizeof( hb_wave_formatex_t ) - 8;
-            f.FormatTag      = 0x2000;
+            f.FormatTag      = is_ac3 ? 0x2000 : 0x2001;
             f.Channels       = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->config.in.channel_layout);
             f.SamplesPerSec  = audio->config.in.samplerate;
         }
@@ -464,7 +463,7 @@ static int AVIInit( hb_mux_object_t * m )
         }
         f.AvgBytesPerSec = h.Rate;
         f.BlockAlign     = 1;
-        if( is_ac3 )
+        if( is_passthru )
         {
             f.Size       = 0;
         }
@@ -490,10 +489,10 @@ static int AVIInit( hb_mux_object_t * m )
         /* video strf */
                sizeof( hb_bitmap_info_t ) +
         /* video vprp */
-        ( job->pixel_ratio ? sizeof( hb_avi_vprp_info_t ) : 0 ) +
+        ( job->anamorphic.mode ? sizeof( hb_avi_vprp_info_t ) : 0 ) +
         /* audios strf */
         audio_count * ( sizeof( hb_wave_formatex_t ) +
-                        ( is_ac3 ? 0 : sizeof( hb_wave_mp3_t ) ) );
+                        ( is_passthru ? 0 : sizeof( hb_wave_mp3_t ) ) );
 
     /* Here we really start to write into the file */
 
@@ -513,11 +512,11 @@ static int AVIInit( hb_mux_object_t * m )
     WriteInt32( m->file, FOURCC( "LIST" ) );
     WriteInt32( m->file, 4 + sizeof( hb_avi_stream_header_t ) +
                 sizeof( hb_bitmap_info_t )  +
-                ( job->pixel_ratio ? sizeof( hb_avi_vprp_info_t ) : 0 ) );
+                ( job->anamorphic.mode ? sizeof( hb_avi_vprp_info_t ) : 0 ) );
     WriteInt32( m->file, FOURCC( "strl" ) );
     WriteStreamHeader( m->file, &mux_data->header );
     WriteBitmapInfo( m->file, &mux_data->format.v );
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
         WriteVprpInfo( m->file, &mux_data->vprp_header );
     }
@@ -537,11 +536,11 @@ static int AVIInit( hb_mux_object_t * m )
         WriteInt32( m->file, FOURCC( "LIST" ) );
         WriteInt32( m->file, 4 + sizeof( hb_avi_stream_header_t ) +
                              sizeof( hb_wave_formatex_t ) +
-                             ( is_ac3 ? 0 : sizeof( hb_wave_mp3_t ) ) );
+                             ( is_passthru ? 0 : sizeof( hb_wave_mp3_t ) ) );
         WriteInt32( m->file, FOURCC( "strl" ) );
         WriteStreamHeader( m->file, &mux_data->header );
         WriteWaveFormatEx( m->file, &mux_data->format.a.f );
-        if( !is_ac3 )
+        if( !is_passthru )
         {
             WriteWaveMp3( m->file, &mux_data->format.a.m );
         }
@@ -600,9 +599,12 @@ static int AVIMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
     WriteInt32( m->file, job->mux_data->header.Length );
     for( i = 0; i < hb_list_count( title->list_audio ); i++ )
     {
+        int is_passthru;
         audio = hb_list_item( title->list_audio, i );
+        is_passthru = (audio->config.out.codec == HB_ACODEC_AC3) ||
+                      (audio->config.out.codec == HB_ACODEC_DCA);
         fseek( m->file, 264 + i *
-               ( 102 + ( ( audio->config.out.codec == HB_ACODEC_AC3 ) ? 0 :
+               ( 102 + ( is_passthru ? 0 :
                  sizeof( hb_wave_mp3_t ) ) ), SEEK_SET );
         WriteInt32( m->file, audio->priv.mux_data->header.Length );
     }
index b09c5c5..1f39df1 100644 (file)
@@ -13,10 +13,11 @@ struct hb_mux_object_s
 
 typedef struct
 {
-    hb_job_t * job;
-    uint64_t   pts;
-
-} hb_mux_t;
+    hb_buffer_t **fifo;
+    uint32_t    in;     // number of bufs put into fifo
+    uint32_t    out;    // number of bufs taken out of fifo
+    uint32_t    flen;   // fifo length (must be power of two)
+} mux_fifo_t;
 
 typedef struct
 {
@@ -24,72 +25,182 @@ typedef struct
     hb_mux_data_t * mux_data;
     uint64_t        frames;
     uint64_t        bytes;
-    int             eof;
+    mux_fifo_t      mf;
 } hb_track_t;
 
-static hb_track_t * GetTrack( hb_list_t * list, hb_job_t *job )
+typedef struct
 {
-    hb_buffer_t * buf;
-    hb_track_t  * track = NULL, * track2;
-    int64_t       pts = 0;
-    int           i;
+    hb_job_t    *job;
+    double      pts;        // end time of next muxing chunk
+    double      interleave; // size (in 90KHz ticks) of media chunks we mux
+    uint32_t    ntracks;    // total number of tracks we're muxing
+    uint32_t    eof;        // bitmask of track with eof
+    uint32_t    rdy;        // bitmask of tracks ready to output
+    uint32_t    allEof;     // valid bits in eof (all tracks)
+    uint32_t    allRdy;     // valid bits in rdy (audio & video tracks)
+    hb_track_t  *track[32]; // array of tracks to mux ('ntrack' elements)
+                            // NOTE- this array could be dynamically allocated
+                            // but the eof & rdy logic has to be changed to
+                            // handle more than 32 tracks anyway so we keep
+                            // it simple and fast.
+} hb_mux_t;
+
+// The muxer handles two different kinds of media: Video and audio tracks
+// are continuous: once they start they generate continuous, consecutive
+// sequence of bufs until they end. The muxer will time align all continuous
+// media tracks so that their data will be well interleaved in the output file.
+// (Smooth, low latency playback with minimal player buffering requires that
+// data that's going to be presented close together in time also be close
+// together in the output file). Since HB's audio and video encoders run at
+// different speeds, the time-aligning involves buffering *all* the continuous
+// media tracks until a frame with a timestamp beyond the current alignment
+// point arrives on the slowest fifo (usually the video encoder).
+//
+// The other kind of media, subtitles, close-captions, vobsubs and
+// similar tracks, are intermittent. They generate frames sporadically or on
+// human time scales (seconds) rather than near the video frame rate (milliseconds).
+// If intermittent sources were treated like continuous sources huge sections of
+// audio and video would get buffered waiting for the next subtitle to show up.
+// To keep this from happening the muxer doesn't wait for intermittent tracks
+// (essentially it assumes that they will always go through the HB processing
+// pipeline faster than the associated video). They are still time aligned and
+// interleaved at the appropriate point in the output file.
+
+// This routine adds another track for the muxer to process. The media input
+// stream will be read from HandBrake fifo 'fifo'. Buffers read from that
+// stream will be time-aligned with all the other media streams then passed
+// to the container-specific 'mux' routine with argument 'mux_data' (see
+// routine OutputTrackChunk). 'is_continuous' must be 1 for an audio or video
+// track and 0 otherwise (see above).
+
+static void add_mux_track( hb_mux_t *mux, hb_fifo_t *fifo, hb_mux_data_t *mux_data,
+                           int is_continuous )
+{
+    int max_tracks = sizeof(mux->track) / sizeof(*(mux->track));
+    if ( mux->ntracks >= max_tracks )
+    {
+        hb_error( "add_mux_track: too many tracks (>%d)", max_tracks );
+        return;
+    }
+
+    hb_track_t *track = calloc( sizeof( hb_track_t ), 1 );
+    track->fifo = fifo;
+    track->mux_data = mux_data;
+    track->mf.flen = 8;
+    track->mf.fifo = calloc( sizeof(track->mf.fifo[0]), track->mf.flen );
+
+    int t = mux->ntracks++;
+    mux->track[t] = track;
+    mux->allEof |= 1 << t;
+    mux->allRdy |= is_continuous << t;
+}
+
+static void mf_push( hb_track_t *track, hb_buffer_t *buf )
+{
+    uint32_t mask = track->mf.flen - 1;
+    uint32_t in = track->mf.in;
+    if ( ( ( in + 1 ) & mask ) == ( track->mf.out & mask ) )
+    {
+        // fifo is full - expand it to double the current size.
+        // This is a bit tricky because when we change the size
+        // it changes the modulus (mask) used to convert the in
+        // and out counters to fifo indices. Since existing items
+        // will be referenced at a new location after the expand
+        // we can't just realloc the fifo. If there were
+        // hundreds of fifo entries it would be worth it to have code
+        // for each of the four possible before/after configurations
+        // but these fifos are small so we just allocate a new chunk
+        // of memory then do element by element copies using the old &
+        // new masks then free the old fifo's memory..
+        track->mf.flen *= 2;
+        uint32_t nmask = track->mf.flen - 1;
+        hb_buffer_t **nfifo = malloc( track->mf.flen * sizeof(*nfifo) );
+        int indx = track->mf.out;
+        while ( indx != track->mf.in )
+        {
+            nfifo[indx & nmask] = track->mf.fifo[indx & mask];
+            ++indx;
+        }
+        free( track->mf.fifo );
+        track->mf.fifo = nfifo;
+        mask = nmask;
+    }
+    track->mf.fifo[in & mask] = buf;
+    track->mf.in = in + 1;
+}
+
+static hb_buffer_t *mf_pull( hb_track_t *track )
+{
+    hb_buffer_t *b = NULL;
+    if ( track->mf.out != track->mf.in )
+    {
+        // the fifo isn't empty
+        b = track->mf.fifo[track->mf.out & (track->mf.flen - 1)];
+        ++track->mf.out;
+    }
+    return b;
+}
+
+static hb_buffer_t *mf_peek( hb_track_t *track )
+{
+    return track->mf.out == track->mf.in ?
+                NULL : track->mf.fifo[track->mf.out & (track->mf.flen - 1)];
+}
+
+static void MoveToInternalFifos( hb_mux_t *mux )
+{
+    int i;
+    int discard = mux->job->pass != 0 && mux->job->pass != 2;
 
-    for( i = 0; i < hb_list_count( list ); i++ )
+    for( i = 0; i < mux->ntracks; ++i )
     {
-        track2 = hb_list_item( list, i );
-        if ( ! track2->eof )
+        if ( ( mux->eof & (1 << i) ) == 0 )
         {
-            buf    = hb_fifo_see( track2->fifo );
-            if( !buf )
+            hb_track_t *track = mux->track[i];
+            hb_buffer_t *buf;
+            
+            // move all the buffers on the track's fifo to our internal
+            // fifo so that (a) we don't deadlock in the reader and
+            // (b) we can control how data from multiple tracks is
+            // interleaved in the output file.
+            while ( ( buf = hb_fifo_get( track->fifo ) ) )
             {
-                // XXX the libmkv muxer will produce unplayable files if the
-                // audio & video are far out of sync.  To keep them in sync we require
-                // that *all* fifos have a buffer then we take the oldest.
-                // Unfortunately this means we can hang in a deadlock with the
-                // reader process filling the fifos.
-                if ( job->mux == HB_MUX_MKV )
+                if ( buf->size <= 0 )
                 {
-                    return NULL;
+                    // EOF - mark this track as done
+                    hb_buffer_close( &buf );
+                    mux->eof |= ( 1 << i );
+                    mux->rdy |= ( 1 << i );
+                    continue;
+                }
+                if ( discard )
+                {
+                    hb_buffer_close( &buf );
+                    continue;
+                }
+                mf_push( track, buf );
+                if ( buf->stop >= mux->pts )
+                {
+                    // buffer is past our next interleave point so
+                    // note that this track is ready to be output.
+                    mux->rdy |= ( 1 << i );
                 }
-
-                // To make sure we don't camp on one fifo & prevent the others
-                // from making progress we take the earliest data of all the
-                // data that's currently available but we don't care if some
-                // fifos don't have data.
-                continue;
-            }
-            if ( buf->size <= 0 )
-            {
-                // EOF - mark this track as done
-                buf = hb_fifo_get( track2->fifo );
-                hb_buffer_close( &buf );
-                track2->eof = 1;
-                continue;
-            }
-            if( !track || buf->start < pts )
-            {
-                track = track2;
-                pts   = buf->start;
             }
         }
     }
-    return track;
 }
 
-static int AllTracksDone( hb_list_t * list )
+static void OutputTrackChunk( hb_mux_t *mux, hb_track_t *track, hb_mux_object_t *m )
 {
-    hb_track_t  * track;
-    int           i;
+    hb_buffer_t *buf;
 
-    for( i = 0; i < hb_list_count( list ); i++ )
+    while ( ( buf = mf_peek( track ) ) != NULL && buf->start < mux->pts )
     {
-        track = hb_list_item( list, i );
-        if ( track->eof == 0 )
-        {
-            return 0;
-        }
+        m->mux( m, track->mux_data, mf_pull( track ) );
+        track->frames += 1;
+        track->bytes  += buf->size;
+        hb_buffer_close( &buf );
     }
-    return 1;
 }
 
 static void MuxerFunc( void * _mux )
@@ -97,115 +208,154 @@ static void MuxerFunc( void * _mux )
     hb_mux_t    * mux = _mux;
     hb_job_t    * job = mux->job;
     hb_title_t  * title = job->title;
-    hb_audio_t  * audio;
-    hb_list_t   * list;
-    hb_buffer_t * buf;
     hb_track_t  * track;
     int           i;
-
     hb_mux_object_t * m = NULL;
 
+    // set up to interleave track data in blocks of 1 video frame time.
+    // (the best case for buffering and playout latency). The container-
+    // specific muxers can reblock this into bigger chunks if necessary.
+    mux->interleave = 90000. * (double)job->vrate_base / (double)job->vrate;
+    mux->pts = mux->interleave;
+
     /* Get a real muxer */
     if( job->pass == 0 || job->pass == 2)
     {
         switch( job->mux )
         {
-            case HB_MUX_MP4:
-            case HB_MUX_PSP:
-                       case HB_MUX_IPOD:
-                m = hb_mux_mp4_init( job );
-                break;
-            case HB_MUX_AVI:
-                m = hb_mux_avi_init( job );
-                break;
-            case HB_MUX_OGM:
-                m = hb_mux_ogm_init( job );
-                break;
-            case HB_MUX_MKV:
-                m = hb_mux_mkv_init( job );
+        case HB_MUX_MP4:
+        case HB_MUX_PSP:
+        case HB_MUX_IPOD:
+            m = hb_mux_mp4_init( job );
+            break;
+        case HB_MUX_AVI:
+            m = hb_mux_avi_init( job );
+            break;
+        case HB_MUX_OGM:
+            m = hb_mux_ogm_init( job );
+            break;
+        case HB_MUX_MKV:
+            m = hb_mux_mkv_init( job );
+            break;
+        default:
+            hb_error( "No muxer selected, exiting" );
+            *job->die = 1;
+        }
+        /* Create file, write headers */
+        if( m )
+        {
+            m->init( m );
         }
-    }
-
-    /* Create file, write headers */
-    if( job->pass == 0 || job->pass == 2 )
-    {
-        m->init( m );
     }
 
     /* Build list of fifos we're interested in */
-    list = hb_list_init();
 
-    track           = calloc( sizeof( hb_track_t ), 1 );
-    track->fifo     = job->fifo_mpeg4;
-    track->mux_data = job->mux_data;
-    hb_list_add( list, track );
+    add_mux_track( mux, job->fifo_mpeg4, job->mux_data, 1 );
 
     for( i = 0; i < hb_list_count( title->list_audio ); i++ )
     {
-        audio           = hb_list_item( title->list_audio, i );
-        track           = calloc( sizeof( hb_track_t ), 1 );
-        track->fifo     = audio->priv.fifo_out;
-        track->mux_data = audio->priv.mux_data;
-        hb_list_add( list, track );
+        hb_audio_t  *audio = hb_list_item( title->list_audio, i );
+        add_mux_track( mux, audio->priv.fifo_out, audio->priv.mux_data, 1 );
+    }
+
+    for( i = 0; i < hb_list_count( title->list_subtitle ); i++ )
+    {
+        hb_subtitle_t  *subtitle = hb_list_item( title->list_subtitle, i );
+
+        if (subtitle->config.dest != PASSTHRUSUB)
+            continue;
+        add_mux_track( mux, subtitle->fifo_out, subtitle->mux_data, 0 );
     }
 
-       int thread_sleep_interval = 50;
-       while( !*job->die )
+    // The following 'while' is the main muxing loop.
+
+    int thread_sleep_interval = 50;
+    while( !*job->die )
     {
-        if( !( track = GetTrack( list, job ) ) )
+        MoveToInternalFifos( mux );
+        if ( ( mux->rdy & mux->allRdy ) != mux->allRdy )
         {
-            if ( AllTracksDone( list )  )
-            {
-                // all our input fifos have signaled EOF
-                break;
-            }
             hb_snooze( thread_sleep_interval );
             continue;
         }
 
-        buf = hb_fifo_get( track->fifo );
-        if( job->pass == 0 || job->pass == 2 )
+        // all tracks have at least 'interleave' ticks of data. Output
+        // all that we can in 'interleave' size chunks.
+        while ( ( mux->rdy & mux->allRdy ) == mux->allRdy )
         {
-            m->mux( m, track->mux_data, buf );
-            track->frames += 1;
-            track->bytes  += buf->size;
-            mux->pts = buf->stop;
+            for ( i = 0; i < mux->ntracks; ++i )
+            {
+                track = mux->track[i];
+                OutputTrackChunk( mux, track, m );
+
+                // if the track is at eof or still has data that's past
+                // our next interleave point then leave it marked as rdy.
+                // Otherwise clear rdy.
+                if ( ( mux->eof & (1 << i) ) == 0 &&
+                     ( track->mf.out == track->mf.in ||
+                       track->mf.fifo[(track->mf.in-1) & (track->mf.flen-1)]->stop
+                         < mux->pts + mux->interleave ) )
+                {
+                    mux->rdy &=~ ( 1 << i );
+                }
+            }
+
+            // if all the tracks are at eof we're just purging their
+            // remaining data -- keep going until all internal fifos are empty.
+            if ( mux->eof == mux->allEof )
+            {
+                for ( i = 0; i < mux->ntracks; ++i )
+                {
+                    if ( mux->track[i]->mf.out != mux->track[i]->mf.in )
+                    {
+                        break;
+                    }
+                }
+                if ( i >= mux->ntracks )
+                {
+                    goto finished;
+                }
+            }
+            mux->pts += mux->interleave;
         }
-        hb_buffer_close( &buf );
     }
 
+    // we're all done muxing -- print final stats and cleanup.
+finished:
     if( job->pass == 0 || job->pass == 2 )
     {
         struct stat sb;
         uint64_t bytes_total, frames_total;
 
-#define p state.param.muxing
         /* Update the UI */
         hb_state_t state;
-        state.state   = HB_STATE_MUXING;
-               p.progress = 0;
+        state.state = HB_STATE_MUXING;
+        state.param.muxing.progress = 0;
         hb_set_state( job->h, &state );
-#undef p
-        m->end( m );
+
+        if( m )
+        {
+            m->end( m );
+        }
 
         if( !stat( job->file, &sb ) )
         {
-            hb_deep_log( 2, "mux: file size, %lld bytes", (uint64_t) sb.st_size );
+            hb_deep_log( 2, "mux: file size, %"PRId64" bytes", (uint64_t) sb.st_size );
 
             bytes_total  = 0;
             frames_total = 0;
-            for( i = 0; i < hb_list_count( list ); i++ )
+            for( i = 0; i < mux->ntracks; ++i )
             {
-                track = hb_list_item( list, i );
-                hb_deep_log( 2, "mux: track %d, %lld bytes, %.2f kbps",
-                        i, track->bytes,
-                        90000.0 * track->bytes / mux->pts / 125 );
+                track = mux->track[i];
+                hb_log( "mux: track %d, %"PRId64" frames, %"PRId64" bytes, %.2f kbps, fifo %d",
+                        i, track->frames, track->bytes,
+                        90000.0 * track->bytes / mux->pts / 125,
+                        track->mf.flen );
                 if( !i && ( job->vquality < 0.0 || job->vquality > 1.0 ) )
                 {
                     /* Video */
-                    hb_deep_log( 2, "mux: video bitrate error, %+lld bytes",
-                            track->bytes - mux->pts * job->vbitrate *
-                            125 / 90000 );
+                    hb_deep_log( 2, "mux: video bitrate error, %+"PRId64" bytes",
+                            (int64_t)(track->bytes - mux->pts * job->vbitrate * 125 / 90000) );
                 }
                 bytes_total  += track->bytes;
                 frames_total += track->frames;
@@ -219,19 +369,22 @@ static void MuxerFunc( void * _mux )
             }
         }
     }
+    
+    if( m )
+    {
+        free( m );
+    }
 
-    free( m );
-
-    for( i = 0; i < hb_list_count( list ); i++ )
+    for( i = 0; i < mux->ntracks; ++i )
     {
-        track = hb_list_item( list, i );
+        track = mux->track[i];
         if( track->mux_data )
         {
             free( track->mux_data );
+            free( track->mf.fifo );
         }
         free( track );
     }
-    hb_list_close( &list );
 
     free( mux );
 }
index 6217820..f179cb7 100644 (file)
@@ -30,8 +30,31 @@ struct hb_mux_data_s
     uint64_t  prev_chapter_tc;
     uint16_t  current_chapter;
     int       codec;
+    int       subtitle;
+    int       sub_format;
 };
 
+static int yuv2rgb(int yuv)
+{
+    double y, Cr, Cb;
+    int r, g, b;
+
+    y =  (yuv >> 16) & 0xff;
+    Cb = (yuv >>  8) & 0xff;
+    Cr = (yuv      ) & 0xff;
+
+    r = 1.164 * (y - 16)                      + 2.018 * (Cb - 128);
+    g = 1.164 * (y - 16) - 0.813 * (Cr - 128) - 0.391 * (Cb - 128);
+    b = 1.164 * (y - 16) + 1.596 * (Cr - 128);
+    r = (r < 0) ? 0 : r;
+    g = (g < 0) ? 0 : g;
+    b = (b < 0) ? 0 : b;
+    r = (r > 255) ? 255 : r;
+    g = (g > 255) ? 255 : g;
+    b = (b > 255) ? 255 : b;
+    return (r << 16) | (g << 8) | b;
+}
+
 /**********************************************************************
  * MKVInit
  **********************************************************************
@@ -46,7 +69,7 @@ static int MKVInit( hb_mux_object_t * m )
 
     uint8_t         *avcC = NULL;
     uint8_t         default_track_flag = 1;
-    int             avcC_len, i;
+    int             avcC_len, i, j;
     ogg_packet      *ogg_headers[3];
     mk_TrackConfig *track;
 
@@ -101,7 +124,6 @@ static int MKVInit( hb_mux_object_t * m )
             if (job->areBframes)
                 track->minCache = 1;
             break;
-        case HB_VCODEC_XVID:
         case HB_VCODEC_FFMPEG:
             track->codecID = MK_VCODEC_MP4ASP;
             track->codecPrivate = job->config.mpeg4.bytes;
@@ -138,9 +160,9 @@ static int MKVInit( hb_mux_object_t * m )
     track->extra.video.pixelWidth = job->width;
     track->extra.video.pixelHeight = job->height;
     track->extra.video.displayHeight = job->height;
-    if(job->pixel_ratio)
+    if( job->anamorphic.mode )
     {
-        track->extra.video.displayWidth = job->width * ((double)job->pixel_aspect_width / (double)job->pixel_aspect_height);
+        track->extra.video.displayWidth = job->width * ((double)job->anamorphic.par_width / (double)job->anamorphic.par_height);
     }
     else
     {
@@ -158,13 +180,18 @@ static int MKVInit( hb_mux_object_t * m )
     for( i = 0; i < hb_list_count( title->list_audio ); i++ )
     {
         audio = hb_list_item( title->list_audio, i );
-        mux_data = malloc( sizeof( hb_mux_data_t ) );
+        mux_data = calloc(1, sizeof( hb_mux_data_t ) );
         audio->priv.mux_data = mux_data;
 
         mux_data->codec = audio->config.out.codec;
 
         switch (audio->config.out.codec)
         {
+            case HB_ACODEC_DCA:
+                track->codecPrivate = NULL;
+                track->codecPrivateSize = 0;
+                track->codecID = MK_ACODEC_DTS;
+                break;
             case HB_ACODEC_AC3:
                 track->codecPrivate = NULL;
                 track->codecPrivateSize = 0;
@@ -198,6 +225,7 @@ static int MKVInit( hb_mux_object_t * m )
                 }
                 break;
             case HB_ACODEC_FAAC:
+            case HB_ACODEC_CA_AAC:
                 track->codecPrivate = audio->priv.config.aac.bytes;
                 track->codecPrivateSize = audio->priv.config.aac.length;
                 track->codecID = MK_ACODEC_AAC;
@@ -213,18 +241,96 @@ static int MKVInit( hb_mux_object_t * m )
             track->flagDefault = 1;
             default_track_flag = 0;
         }
+        else
+        {
+            track->flagDefault = 0;
+        }
         track->flagEnabled = 1;
         track->trackType = MK_TRACK_AUDIO;
         track->language = audio->config.lang.iso639_2;
         track->extra.audio.samplingFreq = (float)audio->config.out.samplerate;
-        track->extra.audio.channels = (audio->config.out.codec == HB_ACODEC_AC3 ) ? HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->config.in.channel_layout) : HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+        if (audio->config.out.codec == HB_ACODEC_AC3 ||
+            audio->config.out.codec == HB_ACODEC_DCA)
+        {
+            track->extra.audio.channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->config.in.channel_layout);
+        }
+        else
+        {
+            track->extra.audio.channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
+        }
 //        track->defaultDuration = job->arate * 1000;
         mux_data->track = mk_createTrack(m->file, track);
         if (audio->config.out.codec == HB_ACODEC_VORBIS && track->codecPrivate != NULL)
           free(track->codecPrivate);
     }
 
-    if( mk_writeHeader( m->file, "HandBrake " HB_VERSION) < 0 )
+    char * subidx_fmt =
+        "size: %dx%d\n"
+        "org: %d, %d\n"
+        "scale: 100%%, 100%%\n"
+        "alpha: 100%%\n"
+        "smooth: OFF\n"
+        "fadein/out: 50, 50\n"
+        "align: OFF at LEFT TOP\n"
+        "time offset: 0\n"
+        "forced subs: %s\n"
+        "palette: %06x, %06x, %06x, %06x, %06x, %06x, "
+        "%06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x, %06x\n"
+        "custom colors: OFF, tridx: 0000, "
+        "colors: 000000, 000000, 000000, 000000\n";
+
+    for( i = 0; i < hb_list_count( title->list_subtitle ); i++ )
+    {
+        hb_subtitle_t * subtitle;
+        uint32_t        rgb[16];
+        char            subidx[2048];
+        int             len;
+
+        subtitle = hb_list_item( title->list_subtitle, i );
+        if (subtitle->config.dest != PASSTHRUSUB)
+            continue;
+
+        memset(track, 0, sizeof(mk_TrackConfig));
+        switch (subtitle->format)
+        {
+            case PICTURESUB:
+                track->codecID = MK_SUBTITLE_VOBSUB;
+                for (j = 0; j < 16; j++)
+                    rgb[j] = yuv2rgb(title->palette[j]);
+                len = snprintf(subidx, 2048, subidx_fmt, 
+                        title->width, title->height,
+                        0, 0, "OFF",
+                        rgb[0], rgb[1], rgb[2], rgb[3],
+                        rgb[4], rgb[5], rgb[6], rgb[7],
+                        rgb[8], rgb[9], rgb[10], rgb[11],
+                        rgb[12], rgb[13], rgb[14], rgb[15]);
+                track->codecPrivate = subidx;
+                track->codecPrivateSize = len + 1;
+                break;
+            case TEXTSUB:
+                track->codecID = MK_SUBTITLE_UTF8;
+                break;
+            default:
+                continue;
+        }
+        if ( subtitle->config.default_track )
+        {
+            track->flagDefault = 1;
+        }
+
+        mux_data = calloc(1, sizeof( hb_mux_data_t ) );
+        subtitle->mux_data = mux_data;
+        mux_data->subtitle = 1;
+        mux_data->sub_format = subtitle->format;
+        
+        track->flagEnabled = 1;
+        track->trackType = MK_TRACK_SUBTITLE;
+        track->language = subtitle->iso639_2;
+
+        mux_data->track = mk_createTrack(m->file, track);
+    }
+
+    if( mk_writeHeader( m->file, "HandBrake " HB_PROJECT_VERSION) < 0 )
     {
         hb_error( "Failed to write to output file, disk full?");
         *job->die = 1;
@@ -292,10 +398,34 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
                 *job->die = 1;
             }
             mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
-            mk_setFrameFlags(m->file, mux_data->track, timecode, 1);
+            mk_setFrameFlags(m->file, mux_data->track, timecode, 1, 0);
             return 0;
         }
     }
+    else if ( mux_data->subtitle )
+    {
+        uint64_t   duration;
+        timecode = buf->start * TIMECODE_SCALE;
+        if( mk_startFrame(m->file, mux_data->track) < 0)
+        {
+            hb_error( "Failed to write frame to output file, Disk Full?" );
+            *job->die = 1;
+        }
+
+        duration = buf->stop * TIMECODE_SCALE - timecode;
+        if( mux_data->sub_format == TEXTSUB )
+        {
+            mk_addFrameData(m->file, mux_data->track, buf->data, buf->size);
+            mk_setFrameFlags(m->file, mux_data->track, timecode, 1, duration);
+        }
+        else
+        {
+            mk_addFrameData(m->file, mux_data->track, buf->data, buf->size);
+            mk_setFrameFlags(m->file, mux_data->track, timecode, 1, duration);
+        }
+        mk_flushFrame(m->file, mux_data->track);
+        return 0;
+    }
     else
     {
         /* Audio */
@@ -311,7 +441,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
                 *job->die = 1;
             }
             mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
-            mk_setFrameFlags(m->file, mux_data->track, timecode, 1);
+            mk_setFrameFlags(m->file, mux_data->track, timecode, 1, 0);
             return 0;
         }
     }
@@ -323,7 +453,10 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
     }
     mk_addFrameData(m->file, mux_data->track, buf->data, buf->size);
     mk_setFrameFlags(m->file, mux_data->track, timecode,
-                     ((job->vcodec == HB_VCODEC_X264 && mux_data == job->mux_data) ? (buf->frametype == HB_FRAME_IDR) : ((buf->frametype & HB_FRAME_KEY) != 0)) );
+                     ((job->vcodec == HB_VCODEC_X264 && 
+                       mux_data == job->mux_data) ? 
+                            (buf->frametype == HB_FRAME_IDR) : 
+                            ((buf->frametype & HB_FRAME_KEY) != 0)), 0 );
     return 0;
 }
 
@@ -363,6 +496,20 @@ static int MKVEnd( hb_mux_object_t * m )
         mk_createChapterSimple(m->file, mux_data->prev_chapter_tc, mux_data->prev_chapter_tc, string);
     }
 
+    if( title->metadata )
+    {
+        hb_metadata_t *md = title->metadata;
+
+        hb_deep_log( 2, "Writing Metadata to output file...");
+        mk_createTagSimple( m->file, MK_TAG_TITLE, md->name );
+        mk_createTagSimple( m->file, "ARTIST", md->artist );
+        mk_createTagSimple( m->file, "COMPOSER", md->composer );
+        mk_createTagSimple( m->file, MK_TAG_SYNOPSIS, md->comment );
+        mk_createTagSimple( m->file, "DATE_RELEASED", md->release_date );
+        // mk_createTagSimple( m->file, "", md->album );
+        mk_createTagSimple( m->file, MK_TAG_GENRE, md->genre );
+    }
+
     if( mk_close(m->file) < 0 )
     {
         hb_error( "Failed to flush the last frame and close the output file, Disk Full?" );
index afc1f33..1264f9b 100644 (file)
@@ -9,8 +9,6 @@
 
 #include "hb.h"
 
-void AddIPodUUID(MP4FileHandle, MP4TrackId);
-
 struct hb_mux_object_s
 {
     HB_MUX_COMMON;
@@ -20,9 +18,7 @@ struct hb_mux_object_s
     /* libmp4v2 handle */
     MP4FileHandle file;
 
-    /* Cumulated durations so far, in output & input timescale units (see MP4Mux) */
-    int64_t sum_dur;        // duration in output timescale units
-    int64_t sum_dur_in;     // duration in input 90KHz timescale units
+    int64_t sum_dur;    // sum of video frame durations so far
 
     // bias to keep render offsets in ctts atom positive (set up by encx264)
     int64_t init_delay;
@@ -31,109 +27,43 @@ struct hb_mux_object_s
     MP4TrackId chapter_track;
     int current_chapter;
     uint64_t chapter_duration;
-
-    /* Sample rate of the first audio track.
-     * Used for the timescale
-     */
-    int samplerate;
 };
 
 struct hb_mux_data_s
 {
-    MP4TrackId track;
-};
+    MP4TrackId  track;
+    uint8_t     subtitle;
+    int         sub_format;
 
-struct hb_text_sample_s
-{
-    uint8_t     sample[1280];
-    uint32_t    length;
-    MP4Duration duration;
+    uint64_t    sum_dur; // sum of the frame durations so far
 };
 
-/**********************************************************************
- * MP4CreateTextSample
- **********************************************************************
- * Creates a buffer for a text track sample
- *********************************************************************/
-static struct hb_text_sample_s *MP4CreateTextSample( char *textString, uint64_t duration )
+/* Tune video track chunk duration.
+ * libmp4v2 default duration == dusamplerate == 1 second.
+ * Per van's suggestion we desire duration == 4 frames.
+ * Should be invoked immediately after track creation.
+ *
+ * return true on fail, false on success.
+ */
+static int MP4TuneTrackDurationPerChunk( hb_mux_object_t* m, MP4TrackId trackId )
 {
-    struct hb_text_sample_s *sample = NULL;
-    int stringLength = strlen(textString);
-    int x;
-
-    if( stringLength < 1024 )
-    {
-        sample = malloc( sizeof( struct hb_text_sample_s ) );
-
-        //textLength = (stringLength; // Account for BOM
-        sample->length = stringLength + 2 + 12; // Account for text length code and other marker
-        sample->duration = (MP4Duration)duration;
-
-        // 2-byte length marker
-        sample->sample[0] = (stringLength >> 8) & 0xff;
-        sample->sample[1] = stringLength & 0xff;
-
-        strncpy( (char *)&(sample->sample[2]), textString, stringLength );
-
-        x = 2 + stringLength;
-
-        // Modifier Length Marker
-        sample->sample[x] = 0x00;
-        sample->sample[x+1] = 0x00;
-        sample->sample[x+2] = 0x00;
-        sample->sample[x+3] = 0x0C;
-
-        // Modifier Type Code
-        sample->sample[x+4] = 'e';
-        sample->sample[x+5] = 'n';
-        sample->sample[x+6] = 'c';
-        sample->sample[x+7] = 'd';
-
-        // Modifier Value
-        sample->sample[x+8] = 0x00;
-        sample->sample[x+9] = 0x00;
-        sample->sample[x+10] = (256 >> 8) & 0xff;
-        sample->sample[x+11] = 256 & 0xff;
-    }
-
-    return sample;
-}
+    uint32_t tscale;
+    MP4Duration dur;
 
-/**********************************************************************
- * MP4GenerateChapterSample
- **********************************************************************
- * Creates a buffer for a text track sample
- *********************************************************************/
-static struct hb_text_sample_s *MP4GenerateChapterSample( hb_mux_object_t * m,
-                                                          uint64_t duration,
-                                                          int chapter )
-{
-    // We substract 1 from the chapter number because the chapters start at
-    // 1 but our name array starts at 0. We substract another 1 because we're
-    // writing the text of the previous chapter mark (when we get the start
-    // of chapter 2 we know the duration of chapter 1 & can write its mark).
-    hb_chapter_t *chapter_data = hb_list_item( m->job->title->list_chapter,
-                                               chapter - 2 );
-    char tmp_buffer[1024];
-    char *string = tmp_buffer;
-
-    tmp_buffer[0] = '\0';
-
-    if( chapter_data != NULL )
-    {
-        string = chapter_data->title;
-    }
+    tscale = MP4GetTrackTimeScale( m->file, trackId );
+    dur = (MP4Duration)ceil( (double)tscale * (double)m->job->vrate_base / (double)m->job->vrate * 4.0 );
 
-    if( strlen(string) == 0 || strlen(string) >= 1024 )
+    if( !MP4SetTrackDurationPerChunk( m->file, trackId, dur ))
     {
-        snprintf( tmp_buffer, 1023, "Chapter %03i", chapter - 2 );
-        string = tmp_buffer;
+        hb_error( "muxmp4.c: MP4SetTrackDurationPerChunk failed!" );
+        *m->job->die = 1;
+        return 0;
     }
 
-    return MP4CreateTextSample( string, duration );
+    hb_deep_log( 2, "muxmp4: track %u, chunk duration %"PRIu64, MP4FindTrackIndex( m->file, trackId ), dur );
+    return 1;
 }
 
-
 /**********************************************************************
  * MP4Init
  **********************************************************************
@@ -147,22 +77,11 @@ static int MP4Init( hb_mux_object_t * m )
     hb_audio_t    * audio;
     hb_mux_data_t * mux_data;
     int i;
-    uint16_t language_code;
+    int subtitle_default;
 
     /* Flags for enabling/disabling tracks in an MP4. */
     typedef enum { TRACK_DISABLED = 0x0, TRACK_ENABLED = 0x1, TRACK_IN_MOVIE = 0x2, TRACK_IN_PREVIEW = 0x4, TRACK_IN_POSTER = 0x8}  track_header_flags;
 
-    if( (audio = hb_list_item(title->list_audio, 0)) != NULL )
-    {
-        /* Need the sample rate of the first audio track to use as the timescale. */
-        m->samplerate = audio->config.out.samplerate;
-        audio = NULL;
-    }
-    else
-    {
-        m->samplerate = 90000;
-    }
-
     /* Create an empty mp4 file */
     if (job->largeFileSize)
     /* Use 64-bit MP4 file */
@@ -184,14 +103,10 @@ static int MP4Init( hb_mux_object_t * m )
     }
 
     /* Video track */
-    mux_data      = malloc( sizeof( hb_mux_data_t ) );
+    mux_data      = calloc(1, sizeof( hb_mux_data_t ) );
     job->mux_data = mux_data;
 
-    /* When using the standard 90000 timescale, QuickTime tends to have
-       synchronization issues (audio not playing at the correct speed).
-       To workaround this, we use the audio samplerate as the
-       timescale */
-    if (!(MP4SetTimeScale( m->file, m->samplerate )))
+    if (!(MP4SetTimeScale( m->file, 90000 )))
     {
         hb_error("muxmp4.c: MP4SetTimeScale failed!");
         *job->die = 1;
@@ -202,13 +117,24 @@ static int MP4Init( hb_mux_object_t * m )
     {
         /* Stolen from mp4creator */
         MP4SetVideoProfileLevel( m->file, 0x7F );
-               mux_data->track = MP4AddH264VideoTrack( m->file, m->samplerate,
+               mux_data->track = MP4AddH264VideoTrack( m->file, 90000,
                        MP4_INVALID_DURATION, job->width, job->height,
                        job->config.h264.sps[1], /* AVCProfileIndication */
                        job->config.h264.sps[2], /* profile_compat */
                        job->config.h264.sps[3], /* AVCLevelIndication */
                        3 );      /* 4 bytes length before each NAL unit */
+        if ( mux_data->track == MP4_INVALID_TRACK_ID )
+        {
+            hb_error( "muxmp4.c: MP4AddH264VideoTrack failed!" );
+            *job->die = 1;
+            return 0;
+        }
 
+        /* Tune track chunk duration */
+        if( !MP4TuneTrackDurationPerChunk( m, mux_data->track ))
+        {
+            return 0;
+        }
 
         MP4AddH264SequenceParameterSet( m->file, mux_data->track,
                 job->config.h264.sps, job->config.h264.sps_length );
@@ -226,7 +152,7 @@ static int MP4Init( hb_mux_object_t * m )
     else /* FFmpeg or XviD */
     {
         MP4SetVideoProfileLevel( m->file, MPEG4_SP_L3 );
-        mux_data->track = MP4AddVideoTrack( m->file, m->samplerate,
+        mux_data->track = MP4AddVideoTrack( m->file, 90000,
                 MP4_INVALID_DURATION, job->width, job->height,
                 MP4_MPEG4_VIDEO_TYPE );
         if (mux_data->track == MP4_INVALID_TRACK_ID)
@@ -236,6 +162,11 @@ static int MP4Init( hb_mux_object_t * m )
             return 0;
         }
 
+        /* Tune track chunk duration */
+        if( !MP4TuneTrackDurationPerChunk( m, mux_data->track ))
+        {
+            return 0;
+        }
 
         /* VOL from FFmpeg or XviD */
         if (!(MP4SetTrackESConfiguration( m->file, mux_data->track,
@@ -276,14 +207,14 @@ static int MP4Init( hb_mux_object_t * m )
         MP4AddColr(m->file, mux_data->track, 6, 1, 6);
     }
 
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
         /* PASP atom for anamorphic video */
         float width, height;
 
-        width = job->pixel_aspect_width;
+        width  = job->anamorphic.par_width;
 
-        height = job->pixel_aspect_height;
+        height = job->anamorphic.par_height;
 
         MP4AddPixelAspectRatio(m->file, mux_data->track, (uint32_t)width, (uint32_t)height);
 
@@ -293,15 +224,8 @@ static int MP4Init( hb_mux_object_t * m )
        /* add the audio tracks */
     for( i = 0; i < hb_list_count( title->list_audio ); i++ )
     {
-       static uint8_t reserved2[16] = {
-               0x00, 0x00, 0x00, 0x00,
-               0x00, 0x00, 0x00, 0x00,
-               0x00, 0x02, 0x00, 0x10,
-               0x00, 0x00, 0x00, 0x00,
-           };
-
         audio = hb_list_item( title->list_audio, i );
-        mux_data = malloc( sizeof( hb_mux_data_t ) );
+        mux_data = calloc(1, sizeof( hb_mux_data_t ) );
         audio->priv.mux_data = mux_data;
 
         if( audio->config.out.codec == HB_ACODEC_AC3 )
@@ -402,7 +326,7 @@ static int MP4Init( hb_mux_object_t * m )
 
             mux_data->track = MP4AddAC3AudioTrack(
                 m->file,
-                m->samplerate, 
+                audio->config.out.samplerate, 
                 fscod,
                 bsid,
                 bsmod,
@@ -410,6 +334,9 @@ static int MP4Init( hb_mux_object_t * m )
                 lfeon,
                 bit_rate_code);
 
+            /* Tune track chunk duration */
+            MP4TuneTrackDurationPerChunk( m, mux_data->track );
+
             if (audio->config.out.name == NULL) {
                 MP4SetTrackBytesProperty(
                     m->file, mux_data->track,
@@ -426,7 +353,11 @@ static int MP4Init( hb_mux_object_t * m )
         } else {
             mux_data->track = MP4AddAudioTrack(
                 m->file,
-                m->samplerate, 1024, MP4_MPEG4_AUDIO_TYPE );
+                audio->config.out.samplerate, 1024, MP4_MPEG4_AUDIO_TYPE );
+
+            /* Tune track chunk duration */
+            MP4TuneTrackDurationPerChunk( m, mux_data->track );
+
             if (audio->config.out.name == NULL) {
                 MP4SetTrackBytesProperty(
                     m->file, mux_data->track,
@@ -451,11 +382,7 @@ static int MP4Init( hb_mux_object_t * m )
         }
 
         /* Set the language for this track */
-        /* The language is stored as 5-bit text - 0x60 */
-        language_code = audio->config.lang.iso639_2[0] - 0x60;   language_code <<= 5;
-        language_code |= audio->config.lang.iso639_2[1] - 0x60;  language_code <<= 5;
-        language_code |= audio->config.lang.iso639_2[2] - 0x60;
-        MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.mdhd.language", language_code);
+        MP4SetTrackLanguage(m->file, mux_data->track, audio->config.lang.iso639_2);
 
         if( hb_list_count( title->list_audio ) > 1 )
         {
@@ -472,19 +399,113 @@ static int MP4Init( hb_mux_object_t * m )
                them all at once. */
         {
             MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_DISABLED | TRACK_IN_MOVIE));
-            hb_deep_log( 2, "muxp4: disabled extra audio track %i", mux_data->track-1);
+            hb_deep_log( 2, "muxmp4: disabled extra audio track %u", MP4FindTrackIndex( m->file, mux_data->track ));
+        }
+
+    }
+
+    // Quicktime requires that at least one subtitle is enabled,
+    // else it doesn't show any of the subtitles.
+    // So check to see if any of the subtitles are flagged to be
+    // the defualt.  The default will the the enabled track, else
+    // enable the first track.
+    subtitle_default = 0;
+    for( i = 0; i < hb_list_count( job->list_subtitle ); i++ )
+    {
+        hb_subtitle_t *subtitle = hb_list_item( job->list_subtitle, i );
+
+        if( subtitle && subtitle->format == TEXTSUB && 
+            subtitle->config.dest == PASSTHRUSUB )
+        {
+            if ( subtitle->config.default_track )
+                subtitle_default = 1;
         }
+    }
+    for( i = 0; i < hb_list_count( job->list_subtitle ); i++ )
+    {
+        hb_subtitle_t *subtitle = hb_list_item( job->list_subtitle, i );
 
+        if( subtitle && subtitle->format == TEXTSUB && 
+            subtitle->config.dest == PASSTHRUSUB )
+        {
+            uint64_t width, height = 60;
+            if( job->anamorphic.mode )
+                width = job->width * ( (float) job->anamorphic.par_width / job->anamorphic.par_height );
+            else
+                width = job->width;
+
+            mux_data = calloc(1, sizeof( hb_mux_data_t ) );
+            subtitle->mux_data = mux_data;
+            mux_data->subtitle = 1;
+            mux_data->sub_format = subtitle->format;
+            mux_data->track = MP4AddSubtitleTrack( m->file, 90000, width, height );
+
+            MP4SetTrackLanguage(m->file, mux_data->track, subtitle->iso639_2);
+
+            /* Tune track chunk duration */
+            MP4TuneTrackDurationPerChunk( m, mux_data->track );
+
+            const uint8_t textColor[4] = { 255,255,255,255 };
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.alternate_group", 2);
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.dataReferenceIndex", 1);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.horizontalJustification", 1);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.verticalJustification", 255);
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.bgColorAlpha", 255);
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", height);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", width);
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontID", 1);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontSize", 24);
+
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontColorRed", textColor[0]);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontColorGreen", textColor[1]);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontColorBlue", textColor[2]);
+            MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.tx3g.fontColorAlpha", textColor[3]);
+            
+            /* translate the track */
+            uint8_t* val;
+            uint8_t nval[36];
+            uint32_t *ptr32 = (uint32_t*) nval;
+            uint32_t size;
+
+            MP4GetTrackBytesProperty(m->file, mux_data->track, "tkhd.matrix", &val, &size);
+            memcpy(nval, val, size);
+
+            const uint32_t ytranslation = (job->height - height) * 0x10000;
+                
+#ifdef WORDS_BIGENDIAN
+            ptr32[7] = ytranslation;
+#else
+            /* we need to switch the endianness, as the file format expects big endian */
+            ptr32[7] = ((ytranslation & 0x000000FF) << 24) + ((ytranslation & 0x0000FF00) << 8) + 
+                            ((ytranslation & 0x00FF0000) >> 8) + ((ytranslation & 0xFF000000) >> 24);
+#endif
+
+            MP4SetTrackBytesProperty(m->file, mux_data->track, "tkhd.matrix", nval, size);  
+            if ( !subtitle_default || subtitle->config.default_track ) {
+                /* Enable the default subtitle track */
+                MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_ENABLED | TRACK_IN_MOVIE));
+                subtitle_default = 1;
+            }
+            else
+            {
+                MP4SetTrackIntegerProperty(m->file, mux_data->track, "tkhd.flags", (TRACK_DISABLED | TRACK_IN_MOVIE));
+            }
+        }
     }
 
-       if (job->chapter_markers)
+    if (job->chapter_markers)
     {
         /* add a text track for the chapters. We add the 'chap' atom to track
            one which is usually the video track & should never be disabled.
            The Quicktime spec says it doesn't matter which media track the
            chap atom is on but it has to be an enabled track. */
         MP4TrackId textTrack;
-        textTrack = MP4AddChapterTextTrack(m->file, 1);
+        textTrack = MP4AddChapterTextTrack(m->file, 1, 0);
 
         m->chapter_track = textTrack;
         m->chapter_duration = 0;
@@ -494,13 +515,259 @@ static int MP4Init( hb_mux_object_t * m )
     /* Add encoded-by metadata listing version and build date */
     char *tool_string;
     tool_string = (char *)malloc(80);
-    snprintf( tool_string, 80, "HandBrake %s %i", HB_VERSION, HB_BUILD);
-    MP4SetMetadataTool(m->file, tool_string);
+    snprintf( tool_string, 80, "HandBrake %s %i", HB_PROJECT_VERSION, HB_PROJECT_BUILD);
+
+    /* allocate,fetch,populate,store,free tags structure */
+    const MP4Tags* tags;
+    tags = MP4TagsAlloc();
+    MP4TagsFetch( tags, m->file );
+    MP4TagsSetEncodingTool( tags, tool_string );
+    MP4TagsStore( tags, m->file );
+    MP4TagsFree( tags );
+
     free(tool_string);
 
     return 0;
 }
 
+typedef struct stylerecord_s {
+    enum style_s {ITALIC, BOLD, UNDERLINE} style;
+    uint16_t start;
+    uint16_t stop;
+    struct stylerecord_s *next;
+} stylerecord;
+
+static void hb_makestylerecord( stylerecord **stack, 
+                                enum style_s style, int start )
+{
+    stylerecord *record = calloc( sizeof( stylerecord ), 1 );
+
+    if( record ) 
+    {
+        record->style = style;
+        record->start = start;
+        record->next = *stack;
+        *stack = record;
+    }
+}
+
+static void hb_makestyleatom( stylerecord *record, uint8_t *style)
+{
+    uint8_t face = 1;
+    hb_deep_log(3, "Made style '%s' from %d to %d", 
+           record->style == ITALIC ? "Italic" : record->style == BOLD ? "Bold" : "Underline", record->start, record->stop);
+    
+    switch( record->style )
+    {
+    case ITALIC:
+        face = 2;
+        break;
+    case BOLD:
+        face = 1;
+        break;
+    case UNDERLINE:
+        face = 4;
+        break;
+    default:
+        face = 2;
+        break;
+    }
+
+    style[0] = (record->start >> 8) & 0xff; // startChar
+    style[1] = record->start & 0xff;
+    style[2] = (record->stop >> 8) & 0xff;   // endChar
+    style[3] = record->stop & 0xff;
+    style[4] = (1 >> 8) & 0xff;    // font-ID
+    style[5] = 1 & 0xff;
+    style[6] = face;   // face-style-flags: 1 bold; 2 italic; 4 underline
+    style[7] = 24;      // font-size
+    style[8] = 255;     // r
+    style[9] = 255;     // g
+    style[10] = 255;    // b
+    style[11] = 255;    // a
+}
+
+/*
+ * Copy the input to output removing markup and adding markup to the style
+ * atom where appropriate.
+ */
+static void hb_muxmp4_process_subtitle_style( uint8_t *input,
+                                              uint8_t *output,
+                                              uint8_t *style, uint16_t *stylesize )
+{
+    uint8_t *reader = input;
+    uint8_t *writer = output;
+    uint8_t stylecount = 0;
+    uint16_t utf8_count = 0;         // utf8 count from start of subtitle
+    stylerecord *stylestack = NULL;
+    stylerecord *oldrecord = NULL;
+    
+    while(*reader != '\0') {
+        if( ( *reader & 0xc0 ) == 0x80 ) 
+        {
+            /*
+             * Track the utf8_count when doing markup so that we get the tx3g stops
+             * based on UTF8 chr counts rather than bytes.
+             */
+            utf8_count++;
+            hb_deep_log( 3, "MuxMP4: Counted %d UTF-8 chrs within subtitle so far", 
+                             utf8_count);
+        }
+        if (*reader == '<') {
+            /*
+             * possible markup, peek at the next chr
+             */
+            switch(*(reader+1)) {
+            case 'i':
+                if (*(reader+2) == '>') {
+                    reader += 3;
+                    hb_makestylerecord(&stylestack, ITALIC, (writer - output - utf8_count));
+                } else {
+                    *writer++ = *reader++;
+                }
+                break;
+            case 'b':
+                if (*(reader+2) == '>') {
+                    reader += 3; 
+                    hb_makestylerecord(&stylestack, BOLD, (writer - output - utf8_count));
+                } else {
+                    *writer++ = *reader++;  
+                }
+                break;
+            case 'u': 
+                if (*(reader+2) == '>') {
+                    reader += 3;
+                    hb_makestylerecord(&stylestack, UNDERLINE, (writer - output - utf8_count));
+                } else {
+                    *writer++ = *reader++;
+                }
+                break;
+            case '/':
+                switch(*(reader+2)) {
+                case 'i':
+                    if (*(reader+3) == '>') {
+                        /*
+                         * Check whether we then immediately start more markup of the same type, if so then
+                         * lets not close it now and instead continue this markup.
+                         */
+                        if ((*(reader+4) && *(reader+4) == '<') &&
+                            (*(reader+5) && *(reader+5) == 'i') &&
+                            (*(reader+6) && *(reader+6) == '>')) {
+                            /*
+                             * Opening italics right after, so don't close off these italics.
+                             */
+                            hb_deep_log(3, "Joining two sets of italics");
+                            reader += (4 + 3);
+                            continue;
+                        }
+
+
+                        if ((*(reader+4) && *(reader+4) == ' ') && 
+                            (*(reader+5) && *(reader+5) == '<') &&
+                            (*(reader+6) && *(reader+6) == 'i') &&
+                            (*(reader+7) && *(reader+7) == '>')) {
+                            /*
+                             * Opening italics right after, so don't close off these italics.
+                             */
+                            hb_deep_log(3, "Joining two sets of italics (plus space)");
+                            reader += (4 + 4);
+                            *writer++ = ' ';
+                            continue;
+                        }
+                        if (stylestack && stylestack->style == ITALIC) {
+                            uint8_t style_record[12];
+                            stylestack->stop = writer - output - utf8_count;
+                            hb_makestyleatom(stylestack, style_record);
+
+                            memcpy(style + 10 + (12 * stylecount), style_record, 12);
+                            stylecount++;
+
+                            oldrecord = stylestack;
+                            stylestack = stylestack->next;
+                            free(oldrecord);
+                        } else {
+                            hb_error("Mismatched Subtitle markup '%s'", input);
+                        }
+                        reader += 4;
+                    } else {
+                        *writer++ = *reader++;
+                    }
+                    break;
+                case 'b':
+                    if (*(reader+3) == '>') {
+                        if (stylestack && stylestack->style == BOLD) {
+                            uint8_t style_record[12];
+                            stylestack->stop = writer - output - utf8_count;
+                            hb_makestyleatom(stylestack, style_record);
+
+                            memcpy(style + 10 + (12 * stylecount), style_record, 12);
+                            stylecount++;
+                            oldrecord = stylestack;
+                            stylestack = stylestack->next;
+                            free(oldrecord);
+                        } else {
+                            hb_error("Mismatched Subtitle markup '%s'", input);
+                        }
+
+                        reader += 4;
+                    } else {
+                        *writer++ = *reader++;
+                    }
+                    break;
+                case 'u': 
+                    if (*(reader+3) == '>') {
+                        if (stylestack && stylestack->style == UNDERLINE) {
+                            uint8_t style_record[12];
+                            stylestack->stop = writer - output - utf8_count;
+                            hb_makestyleatom(stylestack, style_record);
+
+                            memcpy(style + 10 + (12 * stylecount), style_record, 12);
+                            stylecount++;
+
+                            oldrecord = stylestack;
+                            stylestack = stylestack->next;
+                            free(oldrecord);
+                        } else {
+                            hb_error("Mismatched Subtitle markup '%s'", input);
+                        }
+                        reader += 4;
+                    } else {
+                        *writer++ = *reader++;
+                    }
+                    break;
+                default:
+                    *writer++ = *reader++;
+                    break;
+                }
+                break;
+            default:
+                *writer++ = *reader++;
+                break;
+            }
+        } else {
+            *writer++ = *reader++;
+        }
+    }
+    *writer = '\0';
+
+    if( stylecount )
+    {
+        *stylesize = 10 + ( stylecount * 12 );
+
+        memcpy( style + 4, "styl", 4);
+
+        style[0] = 0;
+        style[1] = 0;
+        style[2] = (*stylesize >> 8) & 0xff;
+        style[3] = *stylesize & 0xff;
+        style[8] = (stylecount >> 8) & 0xff;
+        style[9] = stylecount & 0xff;
+
+    }
+
+}
+
 static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
                    hb_buffer_t * buf )
 {
@@ -516,76 +783,67 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
         // (we'll need it for both the video frame & the chapter track)
         if ( m->init_delay )
         {
-            offset = ( buf->start + m->init_delay ) * m->samplerate / 90000 -
-                     m->sum_dur;
+            offset = buf->start + m->init_delay - m->sum_dur;
+            if ( offset < 0 )
+            {
+                hb_log("MP4Mux: illegal render offset %"PRId64", start %"PRId64","
+                       "stop %"PRId64", sum_dur %"PRId64,
+                       offset, buf->start, buf->stop, m->sum_dur );
+                offset = 0;
+            }
         }
+
         /* Add the sample before the new frame.
            It is important that this be calculated prior to the duration
            of the new video sample, as we want to sync to right after it.
            (This is because of how durations for text tracks work in QT) */
         if( job->chapter_markers && buf->new_chap )
-        {
-            struct hb_text_sample_s *sample;
+        {    
+            hb_chapter_t *chapter = NULL;
 
             // this chapter is postioned by writing out the previous chapter.
             // the duration of the previous chapter is the duration up to but
             // not including the current frame minus the duration of all
             // chapters up to the previous.
+            // The initial and final chapters can be very short (a second or
+            // less) since they're not really chapters but just a placeholder to
+            // insert a cell command. We don't write chapters shorter than 1.5 sec.
             duration = m->sum_dur - m->chapter_duration + offset;
-            if ( duration <= 0 )
+            if ( duration >= (90000*3)/2 )
             {
-                /* The initial & final chapters can have very short durations
-                 * (less than the error in our total duration estimate) so
-                 * the duration calc above can result in a negative number.
-                 * when this happens give the chapter a short duration (1/3
-                 * of an ntsc frame time). */
-                duration = 1000 * m->samplerate / 90000;
-            }
+                chapter = hb_list_item( m->job->title->list_chapter,
+                                        buf->new_chap - 2 );
 
-            sample = MP4GenerateChapterSample( m, duration, buf->new_chap );
+                MP4AddChapter( m->file,
+                               m->chapter_track,
+                               duration,
+                               (chapter != NULL) ? chapter->title : NULL);
 
-            if( !MP4WriteSample(m->file,
-                                m->chapter_track,
-                                sample->sample,
-                                sample->length,
-                                sample->duration,
-                                0, true) )
-            {
-                hb_error("Failed to write to output file, disk full?");
-                *job->die = 1;
+                m->current_chapter = buf->new_chap;
+                m->chapter_duration += duration;
             }
-            free(sample);
-            m->current_chapter = buf->new_chap;
-            m->chapter_duration += duration;
         }
 
-        // since we're changing the sample rate we need to keep track of
-        // the truncation bias so that the audio and video don't go out
-        // of sync. m->sum_dur_in is the sum of the input durations so far.
-        // m->sum_dur is the sum of the output durations. Their difference
-        // (in output sample rate units) is the accumulated truncation bias.
-        int64_t bias = ( m->sum_dur_in * m->samplerate / 90000 ) - m->sum_dur;
-        int64_t dur_in = buf->stop - buf->start;
-        duration = dur_in * m->samplerate / 90000 + bias;
+        // We're getting the frames in decode order but the timestamps are
+        // for presentation so we have to use durations and effectively
+        // compute a DTS.
+        duration = buf->stop - buf->start;
         if ( duration <= 0 )
         {
             /* We got an illegal mp4/h264 duration. This shouldn't
                be possible and usually indicates a bug in the upstream code.
                Complain in the hope that someone will go find the bug but
                try to fix the error so that the file will still be playable. */
-            hb_log("MP4Mux: illegal duration %lld, bias %lld, start %lld (%lld),"
-                   "stop %lld (%lld), sum_dur %lld",
-                   duration, bias, buf->start * m->samplerate / 90000, buf->start,
-                   buf->stop * m->samplerate / 90000, buf->stop, m->sum_dur );
+            hb_log("MP4Mux: illegal duration %"PRId64", start %"PRId64","
+                   "stop %"PRId64", sum_dur %"PRId64,
+                   duration, buf->start, buf->stop, m->sum_dur );
             /* we don't know when the next frame starts so we can't pick a
-               valid duration for this one so we pick something "short"
-               (roughly 1/3 of an NTSC frame time) and rely on the bias calc
-               for the next frame to correct things (a duration underestimate
-               just results in a large bias on the next frame). */
-            duration = 1000 * m->samplerate / 90000;
+               valid duration for this one. we pick something "short"
+               (roughly 1/3 of an NTSC frame time) to take time from
+               the next frame. */
+            duration = 1000;
         }
         m->sum_dur += duration;
-        m->sum_dur_in += dur_in;
     }
     else
     {
@@ -593,18 +851,142 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
         duration = MP4_INVALID_DURATION;
     }
 
-    // Here's where the sample actually gets muxed.
-    if( !MP4WriteSample( m->file,
-                         mux_data->track,
-                         buf->data,
-                         buf->size,
-                         duration,
-                         offset,
-                         ((buf->frametype & HB_FRAME_KEY) != 0) ) )
+    /* Here's where the sample actually gets muxed. */
+    if( job->vcodec == HB_VCODEC_X264 && mux_data == job->mux_data )
     {
-        hb_error("Failed to write to output file, disk full?");
-        *job->die = 1;
+        /* Compute dependency flags.
+         *
+         * This mechanism is (optionally) used by media players such as QuickTime
+         * to offer better scrubbing performance. The most influential bits are
+         * MP4_SDT_HAS_NO_DEPENDENTS and MP4_SDT_EARLIER_DISPLAY_TIMES_ALLOWED.
+         *
+         * Other bits are possible but no example media using such bits have been
+         * found.
+         *
+         * It is acceptable to supply 0-bits for any samples which characteristics
+         * cannot be positively guaranteed.
+         */
+        int sync = 0;
+        uint32_t dflags = 0;
+
+        /* encoding layer signals if frame is referenced by other frames */
+        if( buf->flags & HB_FRAME_REF )
+            dflags |= MP4_SDT_HAS_DEPENDENTS;
+        else
+            dflags |= MP4_SDT_HAS_NO_DEPENDENTS; /* disposable */
+
+        switch( buf->frametype )
+        {
+            case HB_FRAME_IDR:
+                sync = 1;
+                break;
+            case HB_FRAME_I:
+                dflags |= MP4_SDT_EARLIER_DISPLAY_TIMES_ALLOWED;
+                break;
+            case HB_FRAME_P:
+                dflags |= MP4_SDT_EARLIER_DISPLAY_TIMES_ALLOWED;
+                break;
+            case HB_FRAME_BREF:
+            case HB_FRAME_B:
+            default:
+                break; /* nothing to mark */
+        }
+
+        if( !MP4WriteSampleDependency( m->file,
+                                       mux_data->track,
+                                       buf->data,
+                                       buf->size,
+                                       duration,
+                                       offset,
+                                       sync,
+                                       dflags ))
+        {
+            hb_error("Failed to write to output file, disk full?");
+            *job->die = 1;
+        }
     }
+    else if (mux_data->subtitle)
+    {
+        if( mux_data->sub_format == TEXTSUB )
+        {
+            /* Write an empty sample */
+            if ( mux_data->sum_dur < buf->start )
+            {
+                uint8_t empty[2] = {0,0};
+                if( !MP4WriteSample( m->file,
+                                    mux_data->track,
+                                    empty,
+                                    2,
+                                    buf->start - mux_data->sum_dur,
+                                    0,
+                                    1 ))
+                {
+                    hb_error("Failed to write to output file, disk full?");
+                    *job->die = 1;
+                } 
+                mux_data->sum_dur += buf->start - mux_data->sum_dur;
+            }
+            uint8_t styleatom[2048];;
+            uint16_t stylesize = 0;
+            uint8_t buffer[2048];
+            uint16_t buffersize = 0;
+            uint8_t output[2048];
+
+            *buffer = '\0';
+
+            /*
+             * Copy the subtitle into buffer stripping markup and creating
+             * style atoms for them.
+             */
+            hb_muxmp4_process_subtitle_style( buf->data,
+                                              buffer,
+                                              styleatom, &stylesize );
+
+            buffersize = strlen((char*)buffer);
+
+            hb_deep_log(3, "MuxMP4:Sub:%fs:%"PRId64":%"PRId64":%"PRId64": %s",
+                        (float)buf->start / 90000, buf->start, buf->stop, 
+                        (buf->stop - buf->start), buffer);
+
+            /* Write the subtitle sample */
+            memcpy( output + 2, buffer, buffersize );
+            memcpy( output + 2 + buffersize, styleatom, stylesize);
+            output[0] = ( buffersize >> 8 ) & 0xff;
+            output[1] = buffersize & 0xff;
+
+            if( !MP4WriteSample( m->file,
+                                 mux_data->track,
+                                 output,
+                                 buffersize + stylesize + 2,
+                                 buf->stop - buf->start,
+                                 0,
+                                 1 ))
+            {
+                hb_error("Failed to write to output file, disk full?");
+                *job->die = 1;
+            }
+
+            mux_data->sum_dur += (buf->stop - buf->start);
+        }
+    }
+    else
+    {
+        /*
+         * Audio
+         */
+        if( !MP4WriteSample( m->file,
+                             mux_data->track,
+                             buf->data,
+                             buf->size,
+                             duration,
+                             offset,
+                             ( buf->frametype & HB_FRAME_KEY ) != 0 ))
+        {
+            hb_error("Failed to write to output file, disk full?");
+            *job->die = 1;
+        }
+    }
+
 
     return 0;
 }
@@ -612,25 +994,25 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
 static int MP4End( hb_mux_object_t * m )
 {
     hb_job_t   * job   = m->job;
+    hb_title_t * title = job->title;
 
     /* Write our final chapter marker */
     if( m->job->chapter_markers )
     {
+        hb_chapter_t *chapter = NULL;
         int64_t duration = m->sum_dur - m->chapter_duration;
         /* The final chapter can have a very short duration - if it's less
-         * than a second just skip it. */
-        if ( duration >= m->samplerate )
+         * than 1.5 seconds just skip it. */
+        if ( duration >= (90000*3)/2 )
         {
 
-            struct hb_text_sample_s *sample = MP4GenerateChapterSample( m, duration,
-                                                    m->current_chapter + 1 );
-            if( ! MP4WriteSample(m->file, m->chapter_track, sample->sample,
-                                 sample->length, sample->duration, 0, true) )
-            {
-                hb_error("Failed to write to output file, disk full?");
-                *job->die = 1;
-            }
-            free(sample);
+            chapter = hb_list_item( m->job->title->list_chapter,
+                                    m->current_chapter - 1 );
+
+            MP4AddChapter( m->file,
+                           m->chapter_track,
+                           duration,
+                           (chapter != NULL) ? chapter->title : NULL);
         }
     }
 
@@ -638,7 +1020,7 @@ static int MP4End( hb_mux_object_t * m )
     {
            // Insert track edit to get A/V back in sync.  The edit amount is
            // the init_delay.
-           int64_t edit_amt = m->init_delay * m->samplerate / 90000;
+           int64_t edit_amt = m->init_delay;
            MP4AddTrackEdit(m->file, 1, MP4_INVALID_EDIT_ID, edit_amt,
                            MP4GetTrackDuration(m->file, 1), 0);
             if ( m->job->chapter_markers )
@@ -650,6 +1032,52 @@ static int MP4End( hb_mux_object_t * m )
             }
      }
 
+    /*
+     * Write the MP4 iTunes metadata if we have any metadata
+     */
+    if( title->metadata )
+    {
+        hb_metadata_t *md = title->metadata;
+        const MP4Tags* tags;
+
+        hb_deep_log( 2, "Writing Metadata to output file...");
+
+        /* allocate tags structure */
+        tags = MP4TagsAlloc();
+        /* fetch data from MP4 file (in case it already has some data) */
+        MP4TagsFetch( tags, m->file );
+
+        /* populate */
+        if( strlen( md->name ))
+            MP4TagsSetName( tags, md->name );
+        if( strlen( md->artist ))
+            MP4TagsSetArtist( tags, md->artist );
+        if( strlen( md->composer ))
+            MP4TagsSetComposer( tags, md->composer );
+        if( strlen( md->comment ))
+            MP4TagsSetComments( tags, md->comment );
+        if( strlen( md->release_date ))
+            MP4TagsSetReleaseDate( tags, md->release_date );
+        if( strlen( md->album ))
+            MP4TagsSetAlbum( tags, md->album );
+        if( strlen( md->genre ))
+            MP4TagsSetGenre( tags, md->genre );
+
+        if( md->coverart )
+        {
+            MP4TagArtwork art;
+            art.data = md->coverart;
+            art.size = md->coverart_size;
+            art.type = MP4_ART_UNDEFINED; // delegate typing to libmp4v2
+            MP4TagsAddArtwork( tags, &art );
+        }
+
+        /* push data to MP4 file */
+        MP4TagsStore( tags, m->file );
+        /* free memory associated with structure */
+        MP4TagsFree( tags );
+    }
+
     MP4Close( m->file );
 
     if ( job->mp4_optimize )
index ccb1051..885dcca 100644 (file)
@@ -153,7 +153,6 @@ static int OGMInit( hb_mux_object_t * m )
             op.packet = job->config.theora.headers[0] + sizeof(op);
             ogg_stream_packetin( &mux_data->os, &op );
             break;
-        case HB_VCODEC_XVID:
         case HB_VCODEC_X264:
         case HB_VCODEC_FFMPEG:
         {
@@ -164,10 +163,6 @@ static int OGMInit( hb_mux_object_t * m )
                 {
                     memcpy( h.sub_type, "H264", 4 );
                 }
-                else if( mux_data->codec == HB_VCODEC_XVID )
-                {
-                    memcpy( h.sub_type, "XVID", 4 );
-                }
                 else
                 {
                     memcpy( h.sub_type, "DX50", 4 );
@@ -262,7 +257,6 @@ static int OGMInit( hb_mux_object_t * m )
                 OGMFlush( m, mux_data );
             }
             break;
-        case HB_VCODEC_XVID:
         case HB_VCODEC_X264:
         case HB_VCODEC_FFMPEG:
             break;
@@ -310,7 +304,6 @@ static int OGMMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
             memcpy( op.packet, buf->data + sizeof( ogg_packet ), op.bytes );
             break;
         case HB_VCODEC_FFMPEG:
-        case HB_VCODEC_XVID:
         case HB_VCODEC_X264:
             op.bytes  = buf->size + 1;
             op.packet = malloc( op.bytes );
diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c
new file mode 100644 (file)
index 0000000..5012104
--- /dev/null
@@ -0,0 +1,353 @@
+/* This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#include "hb.h"
+#include <AudioToolbox/AudioToolbox.h>
+#include <CoreAudio/CoreAudio.h>
+
+int     encCoreAudioInit( hb_work_object_t *, hb_job_t * );
+int     encCoreAudioWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
+void    encCoreAudioClose( hb_work_object_t * );
+
+hb_work_object_t hb_encca_aac =
+{
+    WORK_ENC_CA_AAC,
+    "AAC encoder (Apple)",
+    encCoreAudioInit,
+    encCoreAudioWork,
+    encCoreAudioClose
+};
+
+struct hb_work_private_s
+{
+    hb_job_t *job;
+    
+    AudioConverterRef converter;
+    uint8_t  *obuf;
+    uint8_t  *buf;
+    hb_list_t *list;
+    unsigned long isamples, isamplesiz, omaxpacket, nchannels;
+    uint64_t pts, ibytes;
+    Float64 osamplerate;
+};
+
+#define MP4ESDescrTag                   0x03
+#define MP4DecConfigDescrTag            0x04
+#define MP4DecSpecificDescrTag          0x05
+
+// based off of mov_mp4_read_descr_len from mov.c in ffmpeg's libavformat
+static int readDescrLen(UInt8 **buffer)
+{
+       int len = 0;
+       int count = 4;
+       while (count--) {
+               int c = *(*buffer)++;
+               len = (len << 7) | (c & 0x7f);
+               if (!(c & 0x80))
+                       break;
+       }
+       return len;
+}
+
+// based off of mov_mp4_read_descr from mov.c in ffmpeg's libavformat
+static int readDescr(UInt8 **buffer, int *tag)
+{
+       *tag = *(*buffer)++;
+       return readDescrLen(buffer);
+}
+
+// based off of mov_read_esds from mov.c in ffmpeg's libavformat
+static long ReadESDSDescExt(void* descExt, UInt8 **buffer, UInt32 *size, int versionFlags)
+{
+       UInt8 *esds = (UInt8 *) descExt;
+       int tag, len;
+       *size = 0;
+
+    if (versionFlags)
+        esds += 4;             // version + flags
+       readDescr(&esds, &tag);
+       esds += 2;              // ID
+       if (tag == MP4ESDescrTag)
+               esds++;         // priority
+
+       readDescr(&esds, &tag);
+       if (tag == MP4DecConfigDescrTag) {
+               esds++;         // object type id
+               esds++;         // stream type
+               esds += 3;      // buffer size db
+               esds += 4;      // max bitrate
+               esds += 4;      // average bitrate
+
+               len = readDescr(&esds, &tag);
+               if (tag == MP4DecSpecificDescrTag) {
+                       *buffer = calloc(1, len + 8);
+                       if (*buffer) {
+                               memcpy(*buffer, esds, len);
+                               *size = len;
+                       }
+               }
+       }
+
+       return noErr;
+}
+
+/***********************************************************************
+ * hb_work_encCoreAudio_init
+ ***********************************************************************
+ *
+ **********************************************************************/
+int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
+{
+    hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
+    hb_audio_t * audio = w->audio;
+    AudioStreamBasicDescription input, output;
+    UInt32 tmp, tmpsiz = sizeof( tmp );
+    OSStatus err;
+
+    w->private_data = pv;
+    pv->job = job;
+
+    // pass the number of channels used into the private work data
+    pv->nchannels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( audio->config.out.mixdown );
+
+    bzero( &input, sizeof( AudioStreamBasicDescription ) );
+    input.mSampleRate = ( Float64 ) audio->config.out.samplerate;
+    input.mFormatID = kAudioFormatLinearPCM;
+    input.mFormatFlags = kLinearPCMFormatFlagIsFloat | kAudioFormatFlagsNativeEndian;
+    input.mBytesPerPacket = 4 * pv->nchannels;
+    input.mFramesPerPacket = 1;
+    input.mBytesPerFrame = input.mBytesPerPacket * input.mFramesPerPacket;
+    input.mChannelsPerFrame = pv->nchannels;
+    input.mBitsPerChannel = 32;
+
+    bzero( &output, sizeof( AudioStreamBasicDescription ) );
+    output.mFormatID = kAudioFormatMPEG4AAC;
+    output.mSampleRate = ( Float64 ) audio->config.out.samplerate;
+    output.mChannelsPerFrame = pv->nchannels;
+    // let CoreAudio decide the rest...
+
+    // initialise encoder
+    err = AudioConverterNew( &input, &output, &pv->converter );
+    if( err != noErr)
+    {
+        // Retry without the samplerate
+        bzero( &output, sizeof( AudioStreamBasicDescription ) );
+        output.mFormatID = kAudioFormatMPEG4AAC;
+        output.mChannelsPerFrame = pv->nchannels;
+
+        err = AudioConverterNew( &input, &output, &pv->converter );
+
+        if( err != noErr)
+        {
+            hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame );
+            *job->die = 1;
+            return 0;
+        }
+    }
+
+    if( audio->config.out.mixdown == HB_AMIXDOWN_6CH && audio->config.in.codec == HB_ACODEC_AC3 )
+    {
+        SInt32 channelMap[6] = { 2, 1, 3, 4, 5, 0 };
+        AudioConverterSetProperty( pv->converter, kAudioConverterChannelMap,
+                                   sizeof( channelMap ), channelMap );
+    }
+
+    // set encoder quality to maximum
+    tmp = kAudioConverterQuality_Max;
+    AudioConverterSetProperty( pv->converter, kAudioConverterCodecQuality,
+                               sizeof( tmp ), &tmp );
+
+    // set encoder bitrate control mode to constrained variable
+    tmp = kAudioCodecBitRateControlMode_VariableConstrained;
+    AudioConverterSetProperty( pv->converter, kAudioCodecPropertyBitRateControlMode,
+                              sizeof( tmp ), &tmp );
+
+    // get available bitrates
+    AudioValueRange *bitrates;
+    ssize_t bitrateCounts;
+    err = AudioConverterGetPropertyInfo( pv->converter, kAudioConverterApplicableEncodeBitRates,
+                                         &tmpsiz, NULL);
+    bitrates = malloc( tmpsiz );
+    err = AudioConverterGetProperty( pv->converter, kAudioConverterApplicableEncodeBitRates,
+                                     &tmpsiz, bitrates);
+    bitrateCounts = tmpsiz / sizeof( AudioValueRange );
+
+    // set bitrate
+    tmp = audio->config.out.bitrate * 1000;
+    if( tmp < bitrates[0].mMinimum )
+        tmp = bitrates[0].mMinimum;
+    if( tmp > bitrates[bitrateCounts-1].mMinimum )
+        tmp = bitrates[bitrateCounts-1].mMinimum;
+    free( bitrates );
+    AudioConverterSetProperty( pv->converter, kAudioConverterEncodeBitRate,
+                              sizeof( tmp ), &tmp );
+
+    // get real input
+    tmpsiz = sizeof( input );
+    AudioConverterGetProperty( pv->converter,
+                               kAudioConverterCurrentInputStreamDescription,
+                               &tmpsiz, &input );
+    // get real output
+    tmpsiz = sizeof( output );
+    AudioConverterGetProperty( pv->converter,
+                               kAudioConverterCurrentOutputStreamDescription,
+                               &tmpsiz, &output );
+
+    // set sizes
+    pv->isamplesiz  = input.mBytesPerPacket;
+    pv->isamples    = output.mFramesPerPacket;
+    pv->osamplerate = output.mSampleRate;
+
+    // get maximum output size
+    AudioConverterGetProperty( pv->converter,
+                               kAudioConverterPropertyMaximumOutputPacketSize,
+                               &tmpsiz, &tmp );
+    pv->omaxpacket = tmp;
+
+    // get magic cookie (elementary stream descriptor)
+    tmp = HB_CONFIG_MAX_SIZE;
+    AudioConverterGetProperty( pv->converter,
+                               kAudioConverterCompressionMagicCookie,
+                               &tmp, w->config->aac.bytes );
+    // CoreAudio returns a complete ESDS, but we only need
+    // the DecoderSpecific info.
+    UInt8* buffer = NULL;
+    ReadESDSDescExt(w->config->aac.bytes, &buffer, &tmpsiz, 0);
+    w->config->aac.length = tmpsiz;
+    memmove( w->config->aac.bytes, buffer,
+             w->config->aac.length );
+
+    pv->list = hb_list_init();
+    pv->buf = NULL;
+
+    return 0;
+}
+
+/***********************************************************************
+ * Close
+ ***********************************************************************
+ *
+ **********************************************************************/
+void encCoreAudioClose( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+
+    if( pv->converter )
+    {
+        AudioConverterDispose( pv->converter );
+        hb_list_empty( &pv->list );
+        free( pv->obuf );
+        free( pv->buf );
+        free( pv );
+        w->private_data = NULL;
+    }
+}
+
+/* Called whenever necessary by AudioConverterFillComplexBuffer */
+static OSStatus inInputDataProc( AudioConverterRef converter, UInt32 *npackets,
+                          AudioBufferList *buffers,
+                          AudioStreamPacketDescription** ignored,
+                          void *userdata )
+{
+    hb_work_private_t *pv = userdata;
+    pv->ibytes = hb_list_bytes( pv->list );
+
+    if( pv->ibytes == 0 ) {
+        *npackets = 0;
+        return noErr;
+    }
+
+    if( pv->buf != NULL )
+        free( pv->buf );
+
+    uint64_t pts, pos;
+    pv->ibytes = buffers->mBuffers[0].mDataByteSize = MIN( *npackets * pv->isamplesiz, pv->ibytes );
+    buffers->mBuffers[0].mData = pv->buf = malloc( buffers->mBuffers[0].mDataByteSize );
+
+    hb_list_getbytes( pv->list, buffers->mBuffers[0].mData,
+                      buffers->mBuffers[0].mDataByteSize, &pts, &pos );
+
+    *npackets = buffers->mBuffers[0].mDataByteSize / pv->isamplesiz;
+
+    /* transform data from [-32768,32767] to [-1.0,1.0] */
+    float *fdata = buffers->mBuffers[0].mData;
+    int i;
+
+    for( i = 0; i < *npackets * pv->nchannels; i++ )
+        fdata[i] = fdata[i] / 32768.f;
+
+    return noErr;
+}
+
+/***********************************************************************
+ * Encode
+ ***********************************************************************
+ *
+ **********************************************************************/
+static hb_buffer_t * Encode( hb_work_object_t * w )
+{
+    hb_work_private_t * pv = w->private_data;
+    UInt32 npackets = 1;
+
+    /* check if we need more data */
+    if( hb_list_bytes( pv->list ) < pv->isamples * pv->isamplesiz )
+        return NULL;
+
+    hb_buffer_t * obuf;
+    AudioStreamPacketDescription odesc = { 0 };
+    AudioBufferList obuflist = { .mNumberBuffers = 1,
+                                 .mBuffers = { { .mNumberChannels = pv->nchannels } },
+                               };
+
+    obuf = hb_buffer_init( pv->omaxpacket );
+    obuflist.mBuffers[0].mDataByteSize = obuf->size;
+    obuflist.mBuffers[0].mData = obuf->data;
+
+    AudioConverterFillComplexBuffer( pv->converter, inInputDataProc, pv, 
+                                     &npackets, &obuflist, &odesc );
+
+    if( odesc.mDataByteSize == 0 )
+        return NULL;
+
+    obuf->start = pv->pts;
+    pv->pts += 90000LL * pv->isamples / pv->osamplerate;
+    obuf->stop  = pv->pts;
+    obuf->size  = odesc.mDataByteSize;
+    obuf->frametype = HB_FRAME_AUDIO;
+
+    return obuf;
+}
+
+/***********************************************************************
+ * Work
+ ***********************************************************************
+ *
+ **********************************************************************/
+int encCoreAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
+                  hb_buffer_t ** buf_out )
+{
+    hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * buf;
+
+    if( (*buf_in)->size <= 0 )
+    {
+        // EOF on input - send it downstream & say we're done
+        *buf_out = *buf_in;
+        *buf_in = NULL;
+        return HB_WORK_DONE;
+    }
+
+    hb_list_add( pv->list, *buf_in );
+    *buf_in = NULL;
+
+    *buf_out = buf = Encode( w );
+
+    while( buf )
+    {
+        buf->next = Encode( w );
+        buf       = buf->next;
+    }
+
+    return HB_WORK_OK;
+}
index 3754a45..1200386 100644 (file)
@@ -4,31 +4,67 @@
    Homepage: <http://handbrake.fr/>.
    It may be used under the terms of the GNU General Public License. */
 
-#include <time.h>
-#include <sys/time.h>
+#ifdef USE_PTHREAD
+#ifdef SYS_LINUX
+#define _GNU_SOURCE
+#include <sched.h>
+#endif
+#include <pthread.h>
+#endif
 
-#if defined( SYS_BEOS )
-#include <OS.h>
-#include <signal.h>
-#elif defined( SYS_CYGWIN )
+#ifdef SYS_BEOS
+#include <kernel/OS.h>
+#endif
+
+#if defined(SYS_DARWIN) || defined(SYS_FREEBSD)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
+#ifdef SYS_OPENBSD
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+#endif
+
+#ifdef SYS_CYGWIN
 #include <windows.h>
-#elif defined( SYS_SunOS )
-#include <sys/processor.h>
 #endif
 
-#if USE_PTHREAD
+#ifdef SYS_MINGW
 #include <pthread.h>
+#include <windows.h>
+#endif
+
+#ifdef SYS_SunOS
+#include <sys/processor.h>
 #endif
 
-//#ifdef SYS_CYGWIN
-//#include <winsock2.h>
-//#include <ws2tcpip.h>
-//#else
+#include <time.h>
+#include <sys/time.h>
+
+
+#ifdef SYS_MINGW
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
-//#endif
+#endif
+
+#if defined( SYS_LINUX )
+#include <linux/cdrom.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#elif defined( SYS_OPENBSD )
+#include <sys/dvdio.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#endif
+
+#include <stddef.h>
 
 #include "hb.h"
 
@@ -56,6 +92,40 @@ int gettimeofday( struct timeval * tv, struct timezone * tz )
 #endif
 */
 
+int hb_dvd_region(char *device, int *region_mask)
+{
+#if defined( DVD_LU_SEND_RPC_STATE ) && defined( DVD_AUTH )
+    struct stat  st;
+    dvd_authinfo ai;
+    int          fd, ret;
+
+    fd = open( device, O_RDONLY );
+    if ( fd < 0 )
+        return -1;
+    if ( fstat( fd, &st ) < 0 )
+       {
+        close( fd );
+        return -1;
+       }
+    if ( !( S_ISBLK( st.st_mode ) || S_ISCHR( st.st_mode ) ) )
+       {
+        close( fd );
+        return -1;
+       }
+
+    ai.type = DVD_LU_SEND_RPC_STATE;
+    ret = ioctl(fd, DVD_AUTH, &ai);
+    close( fd );
+    if ( ret < 0 )
+        return ret;
+
+    *region_mask = ai.lrpcs.region_mask;
+    return 0;
+#else
+    return -1;
+#endif
+}
+
 uint64_t hb_get_date()
 {
     struct timeval tv;
@@ -78,7 +148,7 @@ void hb_snooze( int delay )
     snooze( 1000 * delay );
 #elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD) || defined( SYS_SunOS )
     usleep( 1000 * delay );
-#elif defined( SYS_CYGWIN )
+#elif defined( SYS_CYGWIN ) || defined( SYS_MINGW )
     Sleep( delay );
 #endif
 }
@@ -100,54 +170,36 @@ int hb_get_cpu_count()
     }
     cpu_count = 1;
 
-#if defined( SYS_BEOS )
-    {
-        system_info info;
-        get_system_info( &info );
-        cpu_count = info.cpu_count;
-    }
-
-#elif defined( SYS_DARWIN ) || defined( SYS_FREEBSD )
-    FILE * info;
-    char   buffer[16];
-
-    if( ( info = popen( "/usr/sbin/sysctl hw.ncpu", "r" ) ) )
-    {
-        memset( buffer, 0, 16 );
-        if( fgets( buffer, 15, info ) )
-        {
-            if( sscanf( buffer, "hw.ncpu: %d", &cpu_count ) != 1 )
-            {
-                cpu_count = 1;
-            }
-        }
-        fclose( info );
-    }
+#if defined(SYS_CYGWIN) || defined(SYS_MINGW)
+    SYSTEM_INFO cpuinfo;
+    GetSystemInfo( &cpuinfo );
+    cpu_count = cpuinfo.dwNumberOfProcessors;
 
-#elif defined( SYS_LINUX )
+#elif defined(SYS_LINUX)
+    unsigned int bit;
+    cpu_set_t p_aff;
+    memset( &p_aff, 0, sizeof(p_aff) );
+    sched_getaffinity( 0, sizeof(p_aff), &p_aff );
+    for( cpu_count = 0, bit = 0; bit < sizeof(p_aff); bit++ )
+         cpu_count += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
+
+#elif defined(SYS_BEOS)
+    system_info info;
+    get_system_info( &info );
+    cpu_count = info.cpu_count;
+
+#elif defined(SYS_DARWIN) || defined(SYS_FREEBSD) || defined(SYS_OPENBSD)
+    size_t length = sizeof( cpu_count );
+#ifdef SYS_OPENBSD
+    int mib[2] = { CTL_HW, HW_NCPU };
+    if( sysctl(mib, 2, &cpu_count, &length, NULL, 0) )
+#else
+    if( sysctlbyname("hw.ncpu", &cpu_count, &length, NULL, 0) )
+#endif
     {
-        FILE * info;
-        char   buffer[8];
-
-        if( ( info = popen( "grep -c '^processor' /proc/cpuinfo",
-                            "r" ) ) )
-        {
-            memset( buffer, 0, 8 );
-            if( fgets( buffer, 7, info ) )
-            {
-                if( sscanf( buffer, "%d", &cpu_count ) != 1 )
-                {
-                    cpu_count = 1;
-                }
-            }
-            fclose( info );
-        }
+        cpu_count = 1;
     }
 
-#elif defined( SYS_CYGWIN )
-    SYSTEM_INFO cpuinfo;
-    GetSystemInfo( &cpuinfo );
-    cpu_count = cpuinfo.dwNumberOfProcessors;
 #elif defined( SYS_SunOS )
     {
         processorid_t cpumax;
@@ -180,7 +232,7 @@ void hb_get_tempory_directory( hb_handle_t * h, char path[512] )
     char base[512];
 
     /* Create the base */
-#ifdef SYS_CYGWIN
+#if defined( SYS_CYGWIN ) || defined( SYS_MINGW )
     char *p;
     int i_size = GetTempPath( 512, base );
     if( i_size <= 0 || i_size >= 512 )
@@ -226,11 +278,11 @@ void hb_get_tempory_filename( hb_handle_t * h, char name[1024],
  ***********************************************************************/
 void hb_mkdir( char * name )
 {
-//#ifdef SYS_CYGWIN
-//    mkdir( name );
-//#else
+#ifdef SYS_MINGW
+    mkdir( name );
+#else
     mkdir( name, 0755 );
-//#endif
+#endif
 }
 
 /************************************************************************
@@ -255,6 +307,27 @@ struct hb_thread_s
 #endif
 };
 
+/* Get a unique identifier to thread and represent as 64-bit unsigned.
+ * If unsupported, the value 0 is be returned.
+ * Caller should use result only for display/log purposes.
+ */
+static uint64_t hb_thread_to_integer( const hb_thread_t* t )
+{
+#if defined( USE_PTHREAD )
+    #if defined( SYS_CYGWIN )
+        return (uint64_t)t->thread;
+    #elif defined( _WIN32 ) || defined( __MINGW32__ )
+        return (uint64_t)(ptrdiff_t)t->thread.p;
+    #elif defined( SYS_DARWIN )
+        return (unsigned long)t->thread;
+    #else
+        return (uint64_t)t->thread;
+    #endif
+#else
+    return 0;
+#endif
+}
+
 /************************************************************************
  * hb_thread_func()
  ************************************************************************
@@ -285,7 +358,7 @@ static void hb_thread_func( void * _t )
     t->function( t->arg );
 
     /* Inform that the thread can be joined now */
-    hb_deep_log( 2, "thread %x exited (\"%s\")", t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" exited (\"%s\")", hb_thread_to_integer( t ), t->name );
     hb_lock( t->lock );
     t->exited = 1;
     hb_unlock( t->lock );
@@ -330,7 +403,7 @@ hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
 //        SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL );
 #endif
 
-    hb_deep_log( 2, "thread %x started (\"%s\")", t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" started (\"%s\")", hb_thread_to_integer( t ), t->name );
     return t;
 }
 
@@ -355,8 +428,7 @@ void hb_thread_close( hb_thread_t ** _t )
 //    WaitForSingleObject( t->thread, INFINITE );
 #endif
 
-    hb_deep_log( 2, "thread %x joined (\"%s\")",
-            t->thread, t->name );
+    hb_deep_log( 2, "thread %"PRIx64" joined (\"%s\")", hb_thread_to_integer( t ), t->name );
 
     hb_lock_close( &t->lock );
     free( t->name );
@@ -572,6 +644,23 @@ hb_net_t * hb_net_open( char * address, int port )
     struct sockaddr_in   sock;
     struct hostent     * host;
 
+#ifdef SYS_MINGW
+    WSADATA wsaData;
+    int iResult, winsock_init = 0;
+
+    // Initialize Winsock
+    if (!winsock_init)
+    {
+        iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
+        if (iResult != 0)
+        {
+            hb_log("WSAStartup failed: %d", iResult);
+            return NULL;
+        }
+        winsock_init = 1;
+    }
+#endif
+
     /* TODO: find out why this doesn't work on Win32 */
     if( !( host = gethostbyname( address ) ) )
     {
index 9c21439..0f3697f 100644 (file)
@@ -19,6 +19,11 @@ int      hb_get_cpu_count();
 /* Everything from now is only used internally and hidden to the UI */
 
 /************************************************************************
+ * DVD utils
+ ***********************************************************************/
+int hb_dvd_region(char *device, int *region_mask);
+
+/************************************************************************
  * Files utils
  ***********************************************************************/
 void hb_get_tempory_directory( hb_handle_t * h, char path[512] );
@@ -43,6 +48,9 @@ typedef struct hb_thread_s hb_thread_t;
 #elif defined( SYS_CYGWIN )
 #  define HB_LOW_PRIORITY    0
 #  define HB_NORMAL_PRIORITY 1
+#elif defined( SYS_MINGW )
+#  define HB_LOW_PRIORITY    0
+#  define HB_NORMAL_PRIORITY 0
 #endif
 
 hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
diff --git a/libhb/project.h.m4 b/libhb/project.h.m4
new file mode 100644 (file)
index 0000000..7e70b5b
--- /dev/null
@@ -0,0 +1,40 @@
+changequote(<<, >>)dnl
+include(<<handbrake.m4>>)dnl
+dnl
+dnl
+dnl
+#ifndef HB_PROJECT_H
+#define HB_PROJECT_H
+
+<<#>>define HB_PROJECT_TITLE           "__HB_title"
+<<#>>define HB_PROJECT_NAME            "__HB_name"
+<<#>>define HB_PROJECT_NAME_LOWER      "__HB_name_lower"
+<<#>>define HB_PROJECT_NAME_UPPER      "__HB_name_upper"
+<<#>>define HB_PROJECT_URL_WEBSITE     "__HB_url_website"
+<<#>>define HB_PROJECT_URL_COMMUNITY   "__HB_url_community"
+<<#>>define HB_PROJECT_URL_IRC         "__HB_url_irc"
+<<#>>define HB_PROJECT_URL_APPCAST     "__HB_url_appcast"
+<<#>>define HB_PROJECT_VERSION_MAJOR   __HB_version_major
+<<#>>define HB_PROJECT_VERSION_MINOR   __HB_version_minor
+<<#>>define HB_PROJECT_VERSION_POINT   __HB_version_point
+<<#>>define HB_PROJECT_VERSION         "__HB_version"
+<<#>>define HB_PROJECT_VERSION_HEX     0x<<>>__HB_version_hex<<>>LL
+<<#>>define HB_PROJECT_BUILD           __HB_build
+<<#>>define HB_PROJECT_REPO_URL        "__HB_repo_url"
+<<#>>define HB_PROJECT_REPO_ROOT       "__HB_repo_root"
+<<#>>define HB_PROJECT_REPO_UUID       "__HB_repo_uuid"
+<<#>>define HB_PROJECT_REPO_REV        __HB_repo_rev
+<<#>>define HB_PROJECT_REPO_DATE       "__HB_repo_date"
+<<#>>define HB_PROJECT_REPO_OFFICIAL   __HB_repo_official
+<<#>>define HB_PROJECT_REPO_TYPE       "__HB_repo_type"
+
+<<#>>define HB_PROJECT_BUILD_SPEC      "__BUILD_spec"
+<<#>>define HB_PROJECT_BUILD_MACHINE   "__BUILD_machine"
+<<#>>define HB_PROJECT_BUILD_VENDOR    "__BUILD_vendor"
+<<#>>define HB_PROJECT_BUILD_SYSTEM    "__BUILD_system"
+<<#>>define HB_PROJECT_BUILD_SYSTEMF   "__BUILD_systemf"
+<<#>>define HB_PROJECT_BUILD_RELEASE   "__BUILD_release"
+<<#>>define HB_PROJECT_BUILD_TITLE     "__BUILD_title"
+<<#>>define HB_PROJECT_BUILD_ARCH      "__BUILD_arch"
+
+#endif /* HB_PROJECT_PROJECT_H */
index 9dfd915..1dda826 100644 (file)
@@ -11,6 +11,7 @@ typedef struct
     double average; // average time between packets
     int64_t last;   // last timestamp seen on this stream
     int id;         // stream id
+    int is_audio;   // != 0 if this is an audio stream
 } stream_timing_t;
 
 typedef struct
@@ -26,9 +27,10 @@ typedef struct
     int64_t        scr_offset;
     hb_psdemux_t   demux;
     int            scr_changes;
-    uint           sequence;
-    int            saw_video;
-    int            st_slots;            // size (in slots) of stream_timing array
+    uint32_t       sequence;
+    uint8_t        st_slots;        // size (in slots) of stream_timing array
+    uint8_t        saw_video;       // != 0 if we've seen video
+    uint8_t        saw_audio;       // != 0 if we've seen audio
 } hb_reader_t;
 
 /***********************************************************************
@@ -78,6 +80,21 @@ static void push_buf( const hb_reader_t *r, hb_fifo_t *fifo, hb_buffer_t *buf )
     hb_fifo_push( fifo, buf );
 }
 
+static int is_audio( hb_reader_t *r, int id )
+{
+    int i;
+    hb_audio_t *audio;
+
+    for( i = 0; ( audio = hb_list_item( r->title->list_audio, i ) ); ++i )
+    {
+        if ( audio->id == id )
+        {
+            return 1;
+        }
+    }
+    return 0;
+}
+
 // The MPEG STD (Standard Target Decoder) essentially requires that we keep
 // per-stream timing so that when there's a timing discontinuity we can
 // seemlessly join packets on either side of the discontinuity. This join
@@ -124,8 +141,14 @@ static stream_timing_t *id_to_st( hb_reader_t *r, const hb_buffer_t *buf )
         }
         st->id = buf->id;
         st->average = 30.*90.;
-        st->last = buf->renderOffset - st->average;
-
+        if ( r->saw_video )
+            st->last = buf->renderOffset - st->average;
+        else
+            st->last = -st->average;
+        if ( ( st->is_audio = is_audio( r, buf->id ) ) != 0 )
+        {
+            r->saw_audio = 1;
+        }
         st[1].id = -1;
     }
     return st;
@@ -200,34 +223,62 @@ static void ReaderFunc( void * _r )
         }
         /* end chapter mapping XXX */
 
-        if( !hb_dvd_start( r->dvd, r->title->index, start ) )
+        if( !hb_dvd_start( r->dvd, r->title, start ) )
         {
             hb_dvd_close( &r->dvd );
             return;
         }
+        if (r->job->angle)
+        {
+            hb_dvd_set_angle( r->dvd, r->job->angle );
+        }
 
         if ( r->job->start_at_preview )
         {
             // XXX code from DecodePreviews - should go into its own routine
-            hb_dvd_seek( r->dvd, (float)r->job->start_at_preview / 11. );
+            hb_dvd_seek( r->dvd, (float)r->job->start_at_preview /
+                         ( r->job->seek_points ? ( r->job->seek_points + 1.0 ) : 11.0 ) );
         }
     }
     else if ( r->stream && r->job->start_at_preview )
     {
+        
         // XXX code from DecodePreviews - should go into its own routine
-        hb_stream_seek( r->stream, (float)( r->job->start_at_preview - 1 ) / 11. );
+        hb_stream_seek( r->stream, (float)( r->job->start_at_preview - 1 ) /
+                        ( r->job->seek_points ? ( r->job->seek_points + 1.0 ) : 11.0 ) );
+
+    } 
+    else if( r->stream )
+    {
+        /*
+         * Standard stream, seek to the starting chapter, if set, and track the
+         * end chapter so that we end at the right time.
+         */
+        int start = r->job->chapter_start;
+        hb_chapter_t *chap = hb_list_item( r->title->list_chapter, chapter_end - 1 );
+        
+        chapter_end = chap->index;
+        if (start > 1)
+        {
+            chap = hb_list_item( r->title->list_chapter, start - 1 );
+            start = chap->index;
+        }
+        
+        /*
+         * Seek to the start chapter.
+         */
+        hb_stream_seek_chapter( r->stream, start );
     }
 
     list  = hb_list_init();
     hb_buffer_t *ps = hb_buffer_init( HB_DVD_READ_BUFFER_SIZE );
-    r->demux.flaky_clock = r->title->flaky_clock;
 
     while( !*r->die && !r->job->done )
     {
         if (r->dvd)
-          chapter = hb_dvd_chapter( r->dvd );
+            chapter = hb_dvd_chapter( r->dvd );
         else if (r->stream)
-          chapter = 1;
+            chapter = hb_stream_chapter( r->stream );
 
         if( chapter < 0 )
         {
@@ -278,31 +329,29 @@ static void ReaderFunc( void * _r )
             hb_set_state( r->job->h, &state );
         }
 
-        if ( r->title->demuxer == HB_NULL_DEMUXER )
-        {
-            hb_demux_null( ps, list, &r->demux );
-        }
-        else
-        {
-            hb_demux_ps( ps, list, &r->demux );
-        }
+        (hb_demux[r->title->demuxer])( ps, list, &r->demux );
 
         while( ( buf = hb_list_item( list, 0 ) ) )
         {
             hb_list_rem( list, buf );
             fifos = GetFifoForId( r->job, buf->id );
 
-            if ( ! r->saw_video )
+            if ( fifos && ! r->saw_video )
             {
-                /* The first video packet defines 'time zero' so discard
-                   data until we get a video packet with a PTS & DTS */
-                if ( buf->id == r->title->video_id && buf->start != -1 &&
-                     buf->renderOffset != -1 )
+                // The first data packet with a PTS from an audio or video stream
+                // that we're decoding defines 'time zero'. Discard packets until
+                // we get one.
+                if ( buf->start != -1 && buf->renderOffset != -1 &&
+                     ( buf->id == r->title->video_id || is_audio( r, buf->id ) ) )
                 {
                     // force a new scr offset computation
                     r->scr_changes = r->demux.scr_changes - 1;
+                    // create a stream state if we don't have one so the
+                    // offset will get computed correctly.
+                    id_to_st( r, buf );
                     r->saw_video = 1;
-                    hb_log( "reader: first SCR %lld", r->demux.last_scr );
+                    hb_log( "reader: first SCR %"PRId64" id %d DTS %"PRId64,
+                            r->demux.last_scr, buf->id, buf->renderOffset );
                 }
                 else
                 {
@@ -332,10 +381,11 @@ static void ReaderFunc( void * _r )
 
                         if ( st )
                         {
-                            // if this isn't the video stream or we don't
-                            // have audio yet then generate a new scr
-                            if ( st != r->stream_timing ||
-                                 r->stream_timing[1].id == -1 )
+                            // if this is the video stream and we don't have
+                            // audio yet or this is an audio stream
+                            // generate a new scr
+                            if ( st->is_audio ||
+                                 ( st == r->stream_timing && !r->saw_audio ) )
                             {
                                 new_scr_offset( r, buf );
                             }
@@ -343,11 +393,21 @@ static void ReaderFunc( void * _r )
                             {
                                 // defer the scr change until we get some
                                 // audio since audio has a timestamp per
-                                // frame but video doesn't. Clear the timestamps
-                                // so the decoder will regenerate them from
-                                // the frame durations.
-                                buf->start = -1;
-                                buf->renderOffset = -1;
+                                // frame but video & subtitles don't. Clear
+                                // the timestamps so the decoder will generate
+                                // them from the frame durations.
+                                if ( st != r->stream_timing )
+                                {
+                                    // not a video stream so it's probably
+                                    // subtitles - the best we can do is to
+                                    // line it up with the last video packet.
+                                    buf->start = r->stream_timing->last;
+                                }
+                                else
+                                {
+                                    buf->start = -1;
+                                    buf->renderOffset = -1;
+                                }
                             }
                         }
                         else
@@ -356,6 +416,8 @@ static void ReaderFunc( void * _r )
                             // packet of a stream we've never seen before. We
                             // have no idea what the timing should be so toss
                             // this buffer & wait for a stream we've already seen.
+                            // add stream to list of streams we have seen
+                            id_to_st( r, buf );
                             hb_buffer_close( &buf );
                             continue;
                         }
@@ -405,6 +467,13 @@ static void ReaderFunc( void * _r )
             push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
     }
 
+    hb_subtitle_t *subtitle;
+    for( n = 0; ( subtitle = hb_list_item( r->job->title->list_subtitle, n ) ); ++n )
+    {
+        if ( subtitle->fifo_in && subtitle->source == VOBSUB)
+            push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
+    }
+
     hb_list_empty( &list );
     hb_buffer_close( &ps );
     if (r->dvd)
@@ -442,8 +511,8 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
     hb_title_t    * title = job->title;
     hb_audio_t    * audio;
     hb_subtitle_t * subtitle;
-    int             i, n;
-    static hb_fifo_t * fifos[8];
+    int             i, n, count;
+    static hb_fifo_t * fifos[100];
 
     memset(fifos, 0, sizeof(fifos));
 
@@ -464,37 +533,29 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
         }
     }
 
-    if( job->indepth_scan ) {
-        /*
-         * Count the occurances of the subtitles, don't actually
-         * return any to encode unless we are looking fro forced
-         * subtitles in which case we need to look in the sub picture
-         * to see if it has the forced flag enabled.
-         */
-        for (i=0; i < hb_list_count(title->list_subtitle); i++) {
-            subtitle =  hb_list_item( title->list_subtitle, i);
-            if (id == subtitle->id) {
+    n = 0;
+    count = hb_list_count( title->list_subtitle );
+    count = count > 99 ? 99 : count;
+    for( i=0; i < count; i++ ) {
+        subtitle =  hb_list_item( title->list_subtitle, i );
+        if (id == subtitle->id) {
+            subtitle->hits++;
+            if( !job->indepth_scan || job->select_subtitle_config.force )
+            {
                 /*
-                 * A hit, count it.
+                 * Pass the subtitles to be processed if we are not scanning, or if
+                 * we are scanning and looking for forced subs, then pass them up
+                 * to decode whether the sub is a forced one.
                  */
-                subtitle->hits++;
-                if( job->subtitle_force )
-                {
-
-                    fifos[0] = subtitle->fifo_in;
-                    return fifos;
-                }
-                break;
+                fifos[n++] = subtitle->fifo_in;
             }
         }
-    } else {
-        if( ( subtitle = hb_list_item( title->list_subtitle, 0 ) ) &&
-            id == subtitle->id )
-        {
-            fifos[0] = subtitle->fifo_in;
-            return fifos;
-        }
     }
+    if ( n != 0 )
+    {
+        return fifos;
+    }
+    
     if( !job->indepth_scan )
     {
         n = 0;
index 5ca6a4c..a4943b7 100644 (file)
@@ -5,9 +5,7 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-
-#include "libavcodec/avcodec.h"
-#include "libswscale/swscale.h"
+#include "hbffmpeg.h"
 
 struct hb_work_private_s
 {
@@ -29,6 +27,11 @@ struct hb_work_private_s
     uint64_t             total_gained_time;
     int64_t              chapter_time;
     int                  chapter_val;
+    int                  count_frames;      // frames output so far
+    double               frame_rate;        // 90KHz ticks per frame (for CFR/PFR)
+    double               out_last_stop;     // where last frame ended (for CFR/PFR)
+    int                  drops;             // frames dropped (for CFR/PFR)
+    int                  dups;              // frames duped (for CFR/PFR)
 };
 
 int  renderInit( hb_work_object_t *, hb_job_t * );
@@ -199,6 +202,132 @@ static void ApplySub( hb_job_t * job, hb_buffer_t * buf,
     hb_buffer_close( _sub );
 }
 
+// delete the buffer 'out' from the chain of buffers whose head is 'buf_out'.
+// out & buf_out must be non-null (checks prior to anywhere this routine
+// can be called guarantee this) and out must be on buf_out's chain
+// (all places that call this get 'out' while traversing the chain).
+// 'out' is freed and its predecessor is returned.
+static hb_buffer_t *delete_buffer_from_chain( hb_buffer_t **buf_out, hb_buffer_t *out)
+{
+    hb_buffer_t *succ = out->next;
+    hb_buffer_t *pred = *buf_out;
+    if ( pred == out )
+    {
+        // we're deleting the first buffer
+        *buf_out = succ;
+    }
+    else
+    {
+        // target isn't the first buf so search for its predecessor.
+        while ( pred->next != out )
+        {
+            pred = pred->next;
+        }
+        // found 'out' - remove it from the chain
+        pred->next = succ;
+    }
+    out->next = 0;
+    hb_buffer_close( &out );
+    return succ;
+}
+
+// insert buffer 'succ' after buffer chain element 'pred'.
+// caller must guarantee that 'pred' and 'succ' are non-null.
+static hb_buffer_t *insert_buffer_in_chain( hb_buffer_t *pred, hb_buffer_t *succ )
+{
+    succ->next = pred->next;
+    pred->next = succ;
+    return succ;
+}
+
+// This section of the code implements video frame rate control.
+// Since filters are allowed to duplicate and drop frames (which
+// changes the timing), this has to be the last thing done in render.
+//
+// There are three options, selected by the value of job->cfr:
+//   0 - Variable Frame Rate (VFR) or 'same as source': frame times
+//       are left alone
+//   1 - Constant Frame Rate (CFR): Frame timings are adjusted so that all
+//       frames are exactly job->vrate_base ticks apart. Frames are dropped
+//       or duplicated if necessary to maintain this spacing.
+//   2 - Peak Frame Rate (PFR): job->vrate_base is treated as the peak
+//       average frame rate. I.e., the average frame rate (current frame
+//       end time divided by number of frames so far) is never allowed to be
+//       greater than job->vrate_base and frames are dropped if necessary
+//       to keep the average under this value. Other than those drops, frame
+//       times are left alone.
+//
+
+static void adjust_frame_rate( hb_work_private_t *pv, hb_buffer_t **buf_out )
+{
+    hb_buffer_t *out = *buf_out;
+
+    while ( out && out->size > 0 )
+    {
+        // this frame has to start where the last one stopped.
+        out->start = pv->out_last_stop;
+
+        // compute where this frame would stop if the frame rate were constant
+        // (this is our target stopping time for CFR and earliest possible
+        // stopping time for PFR).
+        double cfr_stop = pv->frame_rate * ( pv->count_frames + 1 );
+
+        if ( cfr_stop - (double)out->stop >= pv->frame_rate )
+        {
+            // This frame stops a frame time or more in the past - drop it
+            // but don't lose its chapter mark.
+            if ( out->new_chap )
+            {
+                pv->chapter_time = out->start;
+                pv->chapter_val = out->new_chap;
+            }
+            ++pv->drops;
+            out = delete_buffer_from_chain( buf_out, out );
+            continue;
+        }
+
+        // at this point we know that this frame doesn't push the average
+        // rate over the limit so we just pass it on for PFR. For CFR we're
+        // going to return it (with its start & stop times modified) and
+        // we may have to dup it.
+        ++pv->count_frames;
+        if ( pv->job->cfr > 1 )
+        {
+            // PFR - we're going to keep the frame but may need to
+            // adjust it's stop time to meet the average rate constraint.
+            if ( out->stop <= cfr_stop )
+            {
+                out->stop = cfr_stop;
+            }
+        }
+        else
+        {
+            // we're doing CFR so we have to either trim some time from a
+            // buffer that ends too far in the future or, if the buffer is
+            // two or more frame times long, split it into multiple pieces,
+            // each of which is a frame time long.
+            double excess_dur = (double)out->stop - cfr_stop;
+            out->stop = cfr_stop;
+            for ( ; excess_dur >= pv->frame_rate; excess_dur -= cfr_stop )
+            {
+                /* next frame too far ahead - dup current frame */
+                hb_buffer_t *dup = hb_buffer_init( out->size );
+                memcpy( dup->data, out->data, out->size );
+                hb_buffer_copy_settings( dup, out );
+                dup->new_chap = 0;
+                dup->start = cfr_stop;
+                cfr_stop += pv->frame_rate;
+                dup->stop = cfr_stop;
+                out = insert_buffer_in_chain( out, dup );
+                ++pv->dups;
+                ++pv->count_frames;
+            }
+        }
+        pv->out_last_stop = out->stop;
+        out = out->next;
+    }
+}
+
 int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                 hb_buffer_t ** buf_out )
 {
@@ -210,11 +339,47 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     if( in->size <= 0 )
     {
+        hb_buffer_t *head = NULL, *tail = NULL, *next;
+        int counter = 2;
+
         /* If the input buffer is end of stream, send out an empty one
-         * to the next stage as well. Note that this will result in us
-         * losing the current contents of the delay queue.
-         */
-        *buf_out = in;
+         * to the next stage as well. To avoid losing the contents of
+         * the delay queue connect the buffers in the delay queue in 
+         * the correct order, and add the end of stream buffer to the
+         * end.
+         */     
+        while( ( next = hb_fifo_get( pv->delay_queue ) ) != NULL )
+        {
+            
+            /* We can't use the given time stamps. Previous frames
+               might already have been extended, throwing off the
+               raw values fed to render.c. Instead, their
+               stop and start times are stored in arrays.
+               The 4th cached frame will be the to use.
+               If it needed its duration extended to make up
+               lost time, it will have happened above. */
+            next->start = pv->last_start[counter];
+            next->stop = pv->last_stop[counter--];
+            
+            if( !head && !tail )
+            {
+                head = tail = next;
+            } else {
+                tail->next = next;
+                tail = next;
+            }
+        }
+        if( tail )
+        {
+            tail->next = in;
+            *buf_out = head;
+            if ( job->cfr )
+            {
+                adjust_frame_rate( pv, buf_out );
+            }
+        } else {
+            *buf_out = in;
+        }     
         *buf_in = NULL;
         return HB_WORK_DONE;
     }
@@ -240,7 +405,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     }
 
     /* If there's a chapter mark remember it in case we delay or drop its frame */
-    if( in->new_chap && job->vfr )
+    if( in->new_chap )
     {
         pv->chapter_time = in->start;
         pv->chapter_val = in->new_chap;
@@ -291,33 +456,26 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
             }
             else if( result == FILTER_DROP )
             {
-                if( job->vfr )
-                {
-                    /* We need to compensate for the time lost by dropping this frame.
-                       Spread its duration out in quarters, because usually dropped frames
-                       maintain a 1-out-of-5 pattern and this spreads it out amongst the remaining ones.
-                       Store these in the lost_time array, which has 4 slots in it.
-                       Because not every frame duration divides evenly by 4, and we can't lose the
-                       remainder, we have to go through an awkward process to preserve it in the 4th array index. */
-                    uint64_t temp_duration = buf_tmp_out->stop - buf_tmp_out->start;
-                    pv->lost_time[0] += (temp_duration / 4);
-                    pv->lost_time[1] += (temp_duration / 4);
-                    pv->lost_time[2] += (temp_duration / 4);
-                    pv->lost_time[3] += ( temp_duration - (temp_duration / 4) - (temp_duration / 4) - (temp_duration / 4) );
-
-                    pv->total_lost_time += temp_duration;
-                    pv->dropped_frames++;
-
-                    /* Pop the frame's subtitle and dispose of it. */
-                    hb_buffer_t * subtitles = hb_fifo_get( pv->subtitle_queue );
-                    hb_buffer_close( &subtitles );
-                    buf_tmp_in = NULL;
-                    break;
-                }
-                else
-                {
-                    buf_tmp_in = buf_tmp_out;
-                }
+                /* We need to compensate for the time lost by dropping this frame.
+                   Spread its duration out in quarters, because usually dropped frames
+                   maintain a 1-out-of-5 pattern and this spreads it out amongst the remaining ones.
+                   Store these in the lost_time array, which has 4 slots in it.
+                   Because not every frame duration divides evenly by 4, and we can't lose the
+                   remainder, we have to go through an awkward process to preserve it in the 4th array index. */
+                uint64_t temp_duration = buf_tmp_out->stop - buf_tmp_out->start;
+                pv->lost_time[0] += (temp_duration / 4);
+                pv->lost_time[1] += (temp_duration / 4);
+                pv->lost_time[2] += (temp_duration / 4);
+                pv->lost_time[3] += ( temp_duration - (temp_duration / 4) - (temp_duration / 4) - (temp_duration / 4) );
+
+                pv->total_lost_time += temp_duration;
+                pv->dropped_frames++;
+
+                /* Pop the frame's subtitle and dispose of it. */
+                hb_buffer_t * subtitles = hb_fifo_get( pv->subtitle_queue );
+                hb_buffer_close( &subtitles );
+                buf_tmp_in = NULL;
+                break;
             }
         }
     }
@@ -336,7 +494,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         /* In order to make sure we have continuous time stamps, store
            the current frame's duration as starting when the last one stopped. */
         pv->last_start[0] = pv->last_stop[1];
-        pv->last_stop[0] = pv->last_start[0] + (in->stop - in->start);
+        pv->last_stop[0] = pv->last_start[0] + (buf_tmp_in->stop - buf_tmp_in->start);
     }
 
     /* Apply subtitles */
@@ -399,7 +557,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         hb_buffer_copy_settings( buf_render, buf_tmp_in );
     }
 
-    if (*buf_out && job->vfr)
+    if (*buf_out )
     {
         hb_fifo_push( pv->delay_queue, *buf_out );
         *buf_out = NULL;
@@ -410,15 +568,12 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
      * two always in there should we need to rewrite the durations on them.
      */
 
-    if( job->vfr )
+    if( hb_fifo_size( pv->delay_queue ) >= 4 )
     {
-        if( hb_fifo_size( pv->delay_queue ) >= 4 )
-        {
-            *buf_out = hb_fifo_get( pv->delay_queue );
-        }
+        *buf_out = hb_fifo_get( pv->delay_queue );
     }
 
-    if( *buf_out && job->vfr)
+    if( *buf_out )
     {
         /* The current frame exists. That means it hasn't been dropped by a filter.
            Make it accessible as ivtc_buffer so we can edit its duration if needed. */
@@ -497,6 +652,10 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     }
 
+    if ( buf_out && *buf_out && job->cfr )
+    {
+        adjust_frame_rate( pv, buf_out );
+    }
     return HB_WORK_OK;
 }
 
@@ -504,10 +663,21 @@ void renderClose( hb_work_object_t * w )
 {
     hb_work_private_t * pv = w->private_data;
 
-    hb_log("render: lost time: %lld (%i frames)", pv->total_lost_time, pv->dropped_frames);
-    hb_log("render: gained time: %lld (%i frames) (%lld not accounted for)", pv->total_gained_time, pv->extended_frames, pv->total_lost_time - pv->total_gained_time);
+    if ( pv->job->cfr )
+    {
+        hb_log("render: %d frames output, %d dropped and %d duped for CFR/PFR",
+               pv->count_frames, pv->drops, pv->dups );
+    }
+
+    hb_interjob_t * interjob = hb_interjob_get( w->private_data->job->h );
+    
+    /* Preserve dropped frame count for more accurate framerates in 2nd passes. */
+    interjob->render_dropped = pv->dropped_frames;
+
+    hb_log("render: lost time: %"PRId64" (%i frames)", pv->total_lost_time, pv->dropped_frames);
+    hb_log("render: gained time: %"PRId64" (%i frames) (%"PRId64" not accounted for)", pv->total_gained_time, pv->extended_frames, pv->total_lost_time - pv->total_gained_time);
     if (pv->dropped_frames)
-        hb_log("render: average dropped frame duration: %lld", (pv->total_lost_time / pv->dropped_frames) );
+        hb_log("render: average dropped frame duration: %"PRId64, (pv->total_lost_time / pv->dropped_frames) );
 
     /* Cleanup subtitle queue */
     if( pv->subtitle_queue )
@@ -533,10 +703,7 @@ int renderInit( hb_work_object_t * w, hb_job_t * job )
     w->private_data = pv;
     uint32_t    swsflags;
 
-    swsflags = SWS_LANCZOS;
-#ifndef __x86_64__
-    swsflags |= SWS_ACCURATE_RND;
-#endif  /* __x86_64__ */
+    swsflags = SWS_LANCZOS | SWS_ACCURATE_RND;
 
     /* Get title and title size */
     hb_title_t * title = job->title;
@@ -572,6 +739,8 @@ int renderInit( hb_work_object_t * w, hb_job_t * job )
     pv->chapter_time = 0;
     pv->chapter_val  = 0;
 
+    pv->frame_rate = (double)job->vrate_base * (1./300.);
+
     /* Setup filters */
     /* TODO: Move to work.c? */
     if( job->filters )
index 388caa2..74cc52a 100644 (file)
@@ -8,6 +8,8 @@
 #include "a52dec/a52.h"
 #include "dca.h"
 
+#define HB_MAX_PREVIEWS 30 // 30 previews = every 5 minutes of a 2.5 hour video
+
 typedef struct
 {
     hb_handle_t * h;
@@ -18,6 +20,9 @@ typedef struct
 
     hb_dvd_t    * dvd;
        hb_stream_t * stream;
+       
+    int           preview_count;
+    int           store_previews;
 
 } hb_scan_t;
 
@@ -39,7 +44,8 @@ static const char *aspect_to_string( double aspect )
 }
 
 hb_thread_t * hb_scan_init( hb_handle_t * handle, const char * path,
-                            int title_index, hb_list_t * list_title )
+                            int title_index, hb_list_t * list_title,
+                            int preview_count, int store_previews )
 {
     hb_scan_t * data = calloc( sizeof( hb_scan_t ), 1 );
 
@@ -47,7 +53,10 @@ hb_thread_t * hb_scan_init( hb_handle_t * handle, const char * path,
     data->path         = strdup( path );
     data->title_index  = title_index;
     data->list_title   = list_title;
-
+    
+    data->preview_count  = preview_count;
+    data->store_previews = store_previews;
+    
     return hb_thread_init( "scan", ScanFunc, data, HB_NORMAL_PRIORITY );
 }
 
@@ -97,36 +106,9 @@ static void ScanFunc( void * _data )
         int j;
         hb_state_t state;
         hb_audio_t * audio;
-        hb_title_t * title_tmp = NULL;
 
         title = hb_list_item( data->list_title, i );
 
-        /* I've seen a DVD with strictly identical titles. Check this
-           here and ignore it if redundant */
-        for( j = 0; j < i; j++ )
-        {
-            title_tmp = hb_list_item( data->list_title, j );
-            if( title->vts         == title_tmp->vts &&
-                title->block_start == title_tmp->block_start &&
-                title->block_end   == title_tmp->block_end &&
-                title->block_count == title_tmp->block_count )
-            {
-                break;
-            }
-            else
-            {
-                title_tmp = NULL;
-            }
-        }
-        if( title_tmp )
-        {
-            hb_log( "scan: title %d is duplicate with title %d",
-                    title->index, title_tmp->index );
-            hb_list_rem( data->list_title, title );
-            free( title );      /* This _will_ leak! */
-            continue;
-        }
-
 #define p state.param.scanning
         /* Update the UI */
         state.state   = HB_STATE_SCANNING;
@@ -159,15 +141,6 @@ static void ScanFunc( void * _data )
             j++;
         }
 
-        /* If we don't have any audio streams left, remove the title */
-        if( !hb_list_count( title->list_audio ) )
-        {
-            hb_log("scan: ignoring title %i, no audio tracks found", title->index );
-            hb_list_rem( data->list_title, title );
-            free( title );
-            continue;
-        }
-
         i++;
     }
 
@@ -192,15 +165,15 @@ static void ScanFunc( void * _data )
         /* Preserve a source's pixel aspect, if it's available. */
         if( title->pixel_aspect_width && title->pixel_aspect_height )
         {
-            job->pixel_aspect_width  = title->pixel_aspect_width;
-            job->pixel_aspect_height = title->pixel_aspect_height;
+            job->anamorphic.par_width  = title->pixel_aspect_width;
+            job->anamorphic.par_height = title->pixel_aspect_height;
         }
 
         if( title->aspect != 0 && title->aspect != 1. &&
-            !job->pixel_aspect_width && !job->pixel_aspect_height)
+            !job->anamorphic.par_width && !job->anamorphic.par_height)
         {
-            hb_reduce( &job->pixel_aspect_width, &job->pixel_aspect_height,
-                       (int)(title->aspect * title->height), title->width );
+            hb_reduce( &job->anamorphic.par_width, &job->anamorphic.par_height,
+                       (int)(title->aspect * title->height + 0.5), title->width );
         }
 
         job->width = title->width - job->crop[2] - job->crop[3];
@@ -224,8 +197,7 @@ static void ScanFunc( void * _data )
         job->vrate_base = title->rate_base;
 
         job->list_audio = hb_list_init();
-
-        job->subtitle = -1;
+        job->list_subtitle = hb_list_init();
 
         job->mux = HB_MUX_MP4;
     }
@@ -316,10 +288,10 @@ static int column_all_dark( hb_title_t *title, uint8_t* luma, int top, int botto
 
 typedef struct {
     int n;
-    int t[10];
-    int b[10];
-    int l[10];
-    int r[10];
+    int t[HB_MAX_PREVIEWS];
+    int b[HB_MAX_PREVIEWS];
+    int l[HB_MAX_PREVIEWS];
+    int r[HB_MAX_PREVIEWS];
 } crop_record_t;
 
 static void record_crop( crop_record_t *crops, int t, int b, int l, int r )
@@ -397,7 +369,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
     hb_list_t     * list_es;
     int progressive_count = 0;
     int interlaced_preview_count = 0;
-    info_list_t * info_list = calloc( 10+1, sizeof(*info_list) );
+    info_list_t * info_list = calloc( data->preview_count+1, sizeof(*info_list) );
     crop_record_t *crops = calloc( 1, sizeof(*crops) );
 
     buf_ps   = hb_buffer_init( HB_DVD_READ_BUFFER_SIZE );
@@ -406,9 +378,13 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
     hb_log( "scan: decoding previews for title %d", title->index );
 
     if (data->dvd)
-      hb_dvd_start( data->dvd, title->index, 1 );
+    {
+      hb_dvd_start( data->dvd, title, 1 );
+      title->angle_count = hb_dvd_angle_count( data->dvd );
+      hb_log( "scan: title angle(s) %d", title->angle_count );
+    }
 
-    for( i = 0; i < 10; i++ )
+    for( i = 0; i < data->preview_count; i++ )
     {
         int j;
         FILE * file_preview;
@@ -416,7 +392,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
 
         if (data->dvd)
         {
-          if( !hb_dvd_seek( data->dvd, (float) ( i + 1 ) / 11.0 ) )
+          if( !hb_dvd_seek( data->dvd, (float) ( i + 1 ) / ( data->preview_count + 1.0 ) ) )
           {
               continue;
           }
@@ -426,7 +402,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
           /* we start reading streams at zero rather than 1/11 because
            * short streams may have only one sequence header in the entire
            * file and we need it to decode any previews. */
-          if (!hb_stream_seek(data->stream, (float) i / 11.0 ) )
+          if (!hb_stream_seek(data->stream, (float) i / ( data->preview_count + 1.0 ) ) )
           {
               continue;
           }
@@ -437,8 +413,24 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
         int vcodec = title->video_codec? title->video_codec : WORK_DECMPEG2;
         hb_work_object_t *vid_decoder = hb_get_work( vcodec );
         vid_decoder->codec_param = title->video_codec_param;
+        vid_decoder->title = title;
         vid_decoder->init( vid_decoder, NULL );
         hb_buffer_t * vid_buf = NULL;
+        int vidskip = 0;
+
+        if ( title->flags & HBTF_NO_IDR )
+        {
+            // title doesn't have IDR frames so we decode but drop one second's
+            // worth of frames to allow the decoder to converge.
+            if ( ! title->rate_base )
+            {
+                vidskip = 30;
+            }
+            else
+            {
+                vidskip = (double)title->rate / (double)title->rate_base + 0.5;
+            }
+        }
 
         for( j = 0; j < 10240 ; j++ )
         {
@@ -446,6 +438,10 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
             {
               if( !hb_dvd_read( data->dvd, buf_ps ) )
               {
+                  if ( vid_buf )
+                  {
+                    break;
+                  }
                   hb_log( "Warning: Could not read data for preview %d, skipped", i + 1 );
                   goto skip_preview;
               }
@@ -454,18 +450,15 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
             {
               if ( !hb_stream_read(data->stream,buf_ps) )
               {
+                  if ( vid_buf )
+                  {
+                    break;
+                  }
                   hb_log( "Warning: Could not read data for preview %d, skipped", i + 1 );
                   goto skip_preview;
               }
             }
-            if ( title->demuxer == HB_NULL_DEMUXER )
-            {
-                hb_demux_null( buf_ps, list_es, 0 );
-            }
-            else
-            {
-                hb_demux_ps( buf_ps, list_es, 0 );
-            }
+            (hb_demux[title->demuxer])(buf_ps, list_es, 0 );
 
             while( ( buf_es = hb_list_item( list_es, 0 ) ) )
             {
@@ -473,6 +466,13 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
                 if( buf_es->id == title->video_id && vid_buf == NULL )
                 {
                     vid_decoder->work( vid_decoder, &buf_es, &vid_buf );
+                    if ( vid_buf && vidskip && --vidskip > 0 )
+                    {
+                        // we're dropping frames to get the video decoder in sync
+                        // when the video stream doesn't contain IDR frames
+                        hb_buffer_close( &vid_buf );
+                        vid_buf = NULL;
+                    }
                 }
                 else if( ! AllAudioOK( title ) )
                 {
@@ -567,20 +567,23 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
             hb_deep_log( 2, "Interlacing detected in preview frame %i", i+1);
             interlaced_preview_count++;
         }
-
-        hb_get_tempory_filename( data->h, filename, "%x%d",
-                                 (intptr_t)title, i );
-
-        file_preview = fopen( filename, "w" );
-        if( file_preview )
-        {
-            fwrite( vid_buf->data, title->width * title->height * 3 / 2,
-                    1, file_preview );
-            fclose( file_preview );
-        }
-        else
+        
+        if( data->store_previews )
         {
-            hb_log( "scan: fopen failed (%s)", filename );
+            hb_get_tempory_filename( data->h, filename, "%" PRIxPTR "%d",
+                                     (intptr_t)title, i );
+
+            file_preview = fopen( filename, "wb" );
+            if( file_preview )
+            {
+                fwrite( vid_buf->data, title->width * title->height * 3 / 2,
+                        1, file_preview );
+                fclose( file_preview );
+            }
+            else
+            {
+                hb_log( "scan: fopen failed (%s)", filename );
+            }
         }
 
         /* Detect black borders */
@@ -686,14 +689,14 @@ skip_preview:
             // aspect ratio from the DVD metadata. So, if the aspect computed
             // from the PAR is different from the container's aspect we use
             // the container's aspect & recompute the PAR from it.
-            if( title->container_aspect && title->aspect != title->container_aspect )
+            if( title->container_aspect && (int)(title->aspect * 9) != (int)(title->container_aspect * 9) )
             {
                 hb_log("scan: content PAR gives wrong aspect %.2f; "
                        "using container aspect %.2f", title->aspect,
                        title->container_aspect );
                 title->aspect = title->container_aspect;
                 hb_reduce( &title->pixel_aspect_width, &title->pixel_aspect_height,
-                           (int)(title->aspect * title->height), title->width );
+                           (int)(title->aspect * title->height + 0.5), title->width );
             }
         }
 
old mode 100755 (executable)
new mode 100644 (file)
index 156fe99..538353e
@@ -9,10 +9,10 @@
 #include <errno.h>
 
 #include "hb.h"
+#include "hbffmpeg.h"
 #include "lang.h"
 #include "a52dec/a52.h"
-#include "libavcodec/avcodec.h"
-#include "libavformat/avformat.h"
+#include "mp4v2/mp4v2.h"
 
 #define min(a, b) a < b ? a : b
 
  * doesn't handle the stream type.
  */
 typedef struct {
-    enum { U, A, V } kind; /* unknown / audio / video */
+    enum { N, U, A, V } kind; /* not handled / unknown / audio / video */
     int codec;          /* HB worker object id of codec */
     int codec_param;    /* param for codec (usually ffmpeg codec id) */
     const char* name;   /* description of type */
-    int extra_hdr;      /* needs a substream header added to PS pack */
 } stream2codec_t;
 
 #define st(id, kind, codec, codec_param, name) \
- [id] = { kind, codec, codec_param, name, 0 }
-#define se(id, kind, codec, codec_param, name) \
- [id] = { kind, codec, codec_param, name, 1 }
+ [id] = { kind, codec, codec_param, name }
 
 static const stream2codec_t st2codec[256] = {
     st(0x01, V, WORK_DECMPEG2,     0,              "MPEG1"),
     st(0x02, V, WORK_DECMPEG2,     0,              "MPEG2"),
     st(0x03, A, HB_ACODEC_MPGA,    CODEC_ID_MP2,   "MPEG1"),
     st(0x04, A, HB_ACODEC_MPGA,    CODEC_ID_MP2,   "MPEG2"),
-    st(0x05, U, 0,                 0,              "ISO 13818-1 private section"),
+    st(0x05, N, 0,                 0,              "ISO 13818-1 private section"),
     st(0x06, U, 0,                 0,              "ISO 13818-1 PES private data"),
-    st(0x07, U, 0,                 0,              "ISO 13522 MHEG"),
-    st(0x08, U, 0,                 0,              "ISO 13818-1 DSM-CC"),
-    st(0x09, U, 0,                 0,              "ISO 13818-1 auxiliary"),
-    st(0x0a, U, 0,                 0,              "ISO 13818-6 encap"),
-    st(0x0b, U, 0,                 0,              "ISO 13818-6 DSM-CC U-N msgs"),
-    st(0x0c, U, 0,                 0,              "ISO 13818-6 Stream descriptors"),
-    st(0x0d, U, 0,                 0,              "ISO 13818-6 Sections"),
-    st(0x0e, U, 0,                 0,              "ISO 13818-1 auxiliary"),
+    st(0x07, N, 0,                 0,              "ISO 13522 MHEG"),
+    st(0x08, N, 0,                 0,              "ISO 13818-1 DSM-CC"),
+    st(0x09, N, 0,                 0,              "ISO 13818-1 auxiliary"),
+    st(0x0a, N, 0,                 0,              "ISO 13818-6 encap"),
+    st(0x0b, N, 0,                 0,              "ISO 13818-6 DSM-CC U-N msgs"),
+    st(0x0c, N, 0,                 0,              "ISO 13818-6 Stream descriptors"),
+    st(0x0d, N, 0,                 0,              "ISO 13818-6 Sections"),
+    st(0x0e, N, 0,                 0,              "ISO 13818-1 auxiliary"),
     st(0x0f, A, HB_ACODEC_MPGA,    CODEC_ID_AAC,   "ISO 13818-7 AAC Audio"),
     st(0x10, V, WORK_DECAVCODECV,  CODEC_ID_MPEG4, "MPEG4"),
     st(0x11, A, HB_ACODEC_MPGA,    CODEC_ID_AAC_LATM, "MPEG4 LATM AAC"),
     st(0x12, U, 0,                 0,              "MPEG4 generic"),
 
-    st(0x14, U, 0,                 0,              "ISO 13818-6 DSM-CC download"),
+    st(0x14, N, 0,                 0,              "ISO 13818-6 DSM-CC download"),
 
     st(0x1b, V, WORK_DECAVCODECV,  CODEC_ID_H264,  "H.264"),
 
-    //st(0x80, U, 0,                 0,              "DigiCipher II Video"),
-    se(0x81, A, HB_ACODEC_AC3,     0,              "AC-3"),
-    se(0x82, A, HB_ACODEC_DCA,     0,              "HDMV DTS"),
+    st(0x80, N, 0,                 0,              "DigiCipher II Video"),
+    st(0x81, A, HB_ACODEC_AC3,     0,              "AC-3"),
+    st(0x82, A, HB_ACODEC_DCA,     0,              "HDMV DTS"),
     st(0x83, A, HB_ACODEC_LPCM,    0,              "LPCM"),
     st(0x84, A, 0,                 0,              "SDDS"),
     st(0x85, U, 0,                 0,              "ATSC Program ID"),
-    st(0x86, U, 0,                 0,              "SCTE 35 splice info"),
+    st(0x86, A, HB_ACODEC_DCA,     0,              "DTS-HD"),
     st(0x87, A, 0,                 0,              "E-AC-3"),
 
-    se(0x8a, A, HB_ACODEC_DCA,     0,              "DTS"),
+    st(0x8a, A, HB_ACODEC_DCA,     0,              "DTS"),
 
-    se(0x91, A, HB_ACODEC_AC3,     0,              "AC-3"),
-    st(0x92, U, 0,                 0,              "Subtitle"),
+    st(0x91, A, HB_ACODEC_AC3,     0,              "AC-3"),
+    st(0x92, N, 0,                 0,              "Subtitle"),
 
     st(0x94, A, 0,                 0,              "SDDS"),
     st(0xa0, V, 0,                 0,              "MSCODEC"),
@@ -92,7 +89,7 @@ typedef enum {
 } hb_stream_type_t;
 
 #define kMaxNumberVideoPIDS 1
-#define kMaxNumberAudioPIDS 15
+#define kMaxNumberAudioPIDS 31
 #define kMaxNumberDecodeStreams (kMaxNumberVideoPIDS+kMaxNumberAudioPIDS)
 #define kMaxNumberPMTStreams 32
 
@@ -105,21 +102,24 @@ struct hb_stream_s
     int     last_error_count;   /* # errors at last error message */
     int     packetsize;         /* Transport Stream packet size */
 
-    int64_t ts_lastpcr;         /* the last pcr we found in the TS stream */
-    int64_t ts_nextpcr;         /* the next pcr to put in a PS packet */
+    uint8_t need_keyframe;      // non-zero if want to start at a keyframe
+    uint8_t ts_found_pcr;       // non-zero if we've found at least one input pcr
+    int     ts_pcr_out;         // sequence number of most recent output pcr
+    int     ts_pcr_in;          // sequence number of most recent input pcr
+    int64_t ts_pcr;             // most recent input pcr
+    int64_t ts_pcrhist[4];      // circular buffer of output pcrs
 
     uint8_t *ts_packet;         /* buffer for one TS packet */
-    uint8_t *ts_buf[kMaxNumberDecodeStreams];
+    hb_buffer_t *ts_buf[kMaxNumberDecodeStreams];
     int     ts_pos[kMaxNumberDecodeStreams];
-    int8_t  ts_foundfirst[kMaxNumberDecodeStreams];
     int8_t  ts_skipbad[kMaxNumberDecodeStreams];
     int8_t  ts_streamcont[kMaxNumberDecodeStreams];
-    int8_t  ts_start[kMaxNumberDecodeStreams];
+    uint8_t ts_pkt_summary[kMaxNumberDecodeStreams][8];
 
-    uint8_t *fwrite_buf;        /* PS buffer (set by hb_ts_stream_decode) */
-    uint8_t *fwrite_buf_orig;   /* PS buffer start (set by hb_ts_stream_decode) */
+    hb_buffer_t *fwrite_buf;      /* PS buffer (set by hb_ts_stream_decode) */
 
-    uint8_t need_keyframe;
+    int      chapter;           /* Chapter that we are currently in */
+    int64_t  chapter_end;       /* HB time that the current chapter ends */
 
     /*
      * Stuff before this point is dynamic state updated as we read the
@@ -129,13 +129,19 @@ struct hb_stream_s
      */
     uint8_t ts_number_video_pids;
     uint8_t ts_number_audio_pids;
+    uint8_t ts_flags;           // stream characteristics:
+#define         TS_HAS_PCR  (1 << 0)    // at least one PCR seen
+#define         TS_HAS_RAP  (1 << 1)    // Random Access Point bit seen
+#define         TS_HAS_RSEI (1 << 2)    // "Restart point" SEI seen
+    uint8_t ts_IDRs;            // # IDRs found during duration scan
 
     int16_t ts_video_pids[kMaxNumberVideoPIDS];
     int16_t ts_audio_pids[kMaxNumberAudioPIDS];
 
-    uint8_t ts_streamid[kMaxNumberDecodeStreams];
+    uint32_t ts_format_id[kMaxNumberDecodeStreams];
+#define TS_FORMAT_ID_AC3 (('A' << 24) | ('C' << 16) | ('-' << 8) | '3')
     uint8_t ts_stream_type[kMaxNumberDecodeStreams];
-    uint8_t ts_extra_hdr[kMaxNumberDecodeStreams];
+    uint8_t ts_multiplexed[kMaxNumberDecodeStreams];
 
     char    *path;
     FILE    *file_handle;
@@ -189,7 +195,7 @@ struct hb_stream_s
 static void hb_stream_duration(hb_stream_t *stream, hb_title_t *inTitle);
 static void hb_ts_stream_init(hb_stream_t *stream);
 static void hb_ts_stream_find_pids(hb_stream_t *stream);
-static int hb_ts_stream_decode(hb_stream_t *stream, uint8_t *obuf);
+static int hb_ts_stream_decode(hb_stream_t *stream, hb_buffer_t *obuf);
 static void hb_ts_stream_reset(hb_stream_t *stream);
 static hb_audio_t *hb_ts_stream_set_audio_id_and_codec(hb_stream_t *stream,
                                                        int aud_pid_index);
@@ -270,9 +276,12 @@ static void ts_warn_helper( hb_stream_t *stream, char *log, va_list args )
     }
 }
 
+static void ts_warn( hb_stream_t*, char*, ... ) HB_WPRINTF(2,3);
+static void ts_err( hb_stream_t*, int, char*, ... ) HB_WPRINTF(3,4);
+
 static void ts_warn( hb_stream_t *stream, char *log, ... )
 {
-    va_list     args;
+    va_list args;
     va_start( args, log );
     ts_warn_helper( stream, log, args );
     va_end( args );
@@ -280,7 +289,7 @@ static void ts_warn( hb_stream_t *stream, char *log, ... )
 
 static void ts_err( hb_stream_t *stream, int curstream, char *log, ... )
 {
-    va_list     args;
+    va_list args;
     va_start( args, log );
     ts_warn_helper( stream, log, args );
     va_end( args );
@@ -298,14 +307,13 @@ static int check_ps_sync(const uint8_t *buf)
            (buf[2] == 0x01) && (buf[3] == 0xba);
 }
 
-static int check_ps_sys(const uint8_t *buf)
+static int check_ps_sc(const uint8_t *buf)
 {
     // a legal MPEG program stream must start with a Pack followed by a
-    // SYS. If we've already verified the pack, this skips over it and checks
-    // for the sys header.
+    // some other start code. If we've already verified the pack, this skip
+    // it and checks for a start code prefix.
     int pos = 14 + ( buf[13] & 0x7 );   // skip over the PACK
-    return (buf[pos+0] == 0x00) && (buf[pos+1] == 0x00) &&
-           (buf[pos+2] == 0x01) && (buf[pos+3] == 0xbb);
+    return (buf[pos+0] == 0x00) && (buf[pos+1] == 0x00) && (buf[pos+2] == 0x01);
 }
 
 static int check_ts_sync(const uint8_t *buf)
@@ -345,8 +353,9 @@ static int hb_stream_check_for_ts(const uint8_t *buf)
 
 static int hb_stream_check_for_ps(const uint8_t *buf)
 {
-    // program streams should start with a PACK then a SYS header.
-    return check_ps_sync(buf) && check_ps_sys(buf);
+    // program streams should start with a PACK then some other mpeg start
+    // code (usually a SYS but that might be missing if we only have a clip).
+    return check_ps_sync(buf) && check_ps_sc(buf);
 }
 
 static int hb_stream_check_for_dvd_ps(const uint8_t *buf)
@@ -414,7 +423,7 @@ static void hb_stream_delete_dynamic( hb_stream_t *d )
        {
                if (d->ts_buf[i])
                {
-                       free(d->ts_buf[i]);
+                       hb_buffer_close(&(d->ts_buf[i]));
                        d->ts_buf[i] = NULL;
                }
        }
@@ -427,6 +436,37 @@ static void hb_stream_delete( hb_stream_t *d )
     free( d );
 }
 
+static int audio_inactive( hb_stream_t *stream, int indx )
+{
+    int aud_indx = indx - 1;
+
+    if ( stream->ts_audio_pids[aud_indx] < 0 )
+    {
+        // PID declared inactive by hb_stream_title_scan
+        return 1;
+    }
+    if ( stream->ts_audio_pids[aud_indx] == stream->pmt_info.PCR_PID )
+    {
+        // PCR PID is always active
+        return 0;
+    }
+
+    // see if we should make the stream inactive because scan.c didn't
+    // find a valid audio bitstream.
+    int i;
+    for ( i = 0; i < hb_list_count( stream->title->list_audio ); ++i )
+    {
+        hb_audio_t *audio = hb_list_item( stream->title->list_audio, i );
+        if ( audio->id == indx )
+        {
+            return 0;
+        }
+    }
+    // not in the title's audio list - declare the PID inactive
+    stream->ts_audio_pids[aud_indx] = -stream->ts_audio_pids[aud_indx];
+    return 1;
+}
+
 /***********************************************************************
  * hb_stream_open
  ***********************************************************************
@@ -434,7 +474,7 @@ static void hb_stream_delete( hb_stream_t *d )
  **********************************************************************/
 hb_stream_t * hb_stream_open( char *path, hb_title_t *title )
 {
-    FILE *f = fopen( path, "r" );
+    FILE *f = fopen( path, "rb" );
     if ( f == NULL )
     {
         hb_log( "hb_stream_open: open %s failed", path );
@@ -474,16 +514,16 @@ hb_stream_t * hb_stream_open( char *path, hb_title_t *title )
             int i = 0;
             for ( ; i < d->ts_number_video_pids + d->ts_number_audio_pids; i++)
             {
-                d->ts_buf[i] = malloc( HB_DVD_READ_BUFFER_SIZE );
+                if ( i && audio_inactive( d, i ) )
+                {
+                    // this PID isn't wanted (we don't have a codec for it
+                    // or scan didn't find audio parameters)
+                    continue;
+                }
+                d->ts_buf[i] = hb_buffer_init(d->packetsize);
+                               d->ts_buf[i]->size = 0;
             }
             hb_stream_seek( d, 0. );
-
-            if ( d->packetsize == 188 )
-            {
-                // Assume that an over-the-air transport stream can lose PCR
-                // packets and try to filter out the timing inconsistencies.
-                title->flaky_clock = 1;
-            }
         }
         return d;
     }
@@ -575,20 +615,15 @@ void hb_stream_close( hb_stream_t ** _d )
  * now have an audio codec, type, rate, etc., associated with them. At the end
  * of the scan we delete all the audio entries that weren't found by the scan
  * or don't have a format we support. This routine deletes audio entry 'indx'
- * by copying all later entries down one slot. */
+ * by setting its PID to an invalid value so no packet will match it. (We can't
+ * move any of the entries since the index of the entry is used as the id
+ * of the media stream for HB. */
 static void hb_stream_delete_audio_entry(hb_stream_t *stream, int indx)
 {
-    int i;
-
-    for (i = indx+1; i < stream->ts_number_audio_pids; ++i)
+    if ( stream->ts_audio_pids[indx] > 0 )
     {
-        stream->ts_audio_pids[indx] = stream->ts_audio_pids[i];
-        stream->ts_stream_type[1 + indx] = stream->ts_stream_type[1+i];
-        stream->ts_extra_hdr[1 + indx] = stream->ts_extra_hdr[1+i];
-        stream->ts_streamid[1 + indx] = stream->ts_streamid[1 + i];
-        ++indx;
+        stream->ts_audio_pids[indx] = -stream->ts_audio_pids[indx];
     }
-    --stream->ts_number_audio_pids;
 }
 
 static int index_of_pid(int pid, hb_stream_t *stream)
@@ -661,20 +696,32 @@ hb_title_t * hb_stream_title_scan(hb_stream_t *stream)
             {
                 free(audio);
                 hb_stream_delete_audio_entry(stream, i);
-                --i;
             }
         }
 
-        // add the PCR PID if we don't already have it
+        // make sure we're grabbing the PCR PID
         if ( index_of_pid( stream->pmt_info.PCR_PID, stream ) < 0 )
         {
             stream->ts_audio_pids[stream->ts_number_audio_pids++] =
                 stream->pmt_info.PCR_PID;
         }
 
-        // set up the video codec to use for this title
+        // set the video id, codec & muxer
+        aTitle->video_id = 0;
         aTitle->video_codec = st2codec[stream->ts_stream_type[0]].codec;
         aTitle->video_codec_param = st2codec[stream->ts_stream_type[0]].codec_param;
+        aTitle->demuxer = HB_MPEG2_TS_DEMUXER;
+
+        if ( ( stream->ts_flags & TS_HAS_PCR ) == 0 )
+        {
+            hb_log( "transport stream missing PCRs - using video DTS instead" );
+        }
+
+        if ( stream->ts_IDRs < 1 )
+        {
+            hb_log( "transport stream doesn't seem to have video IDR frames" );
+            aTitle->flags |= HBTF_NO_IDR;
+        }
        }
     else
     {
@@ -708,10 +755,10 @@ static const uint8_t *next_packet( hb_stream_t *stream )
         off_t pos2 = align_to_next_packet(stream);
         if ( pos2 == 0 )
         {
-            hb_log( "next_packet: eof while re-establishing sync @ %lld", pos );
+            hb_log( "next_packet: eof while re-establishing sync @ %"PRId64, pos );
             return NULL;
         }
-        ts_warn( stream, "next_packet: sync lost @ %lld, regained after %lld bytes",
+        ts_warn( stream, "next_packet: sync lost @ %"PRId64", regained after %"PRId64" bytes",
                  pos, pos2 );
     }
 }
@@ -743,6 +790,89 @@ static void skip_to_next_pack( hb_stream_t *src_stream )
     }
 }
 
+static int isIframe( hb_stream_t *stream, const uint8_t *buf, int adapt_len )
+{
+    // For mpeg2: look for a gop start or i-frame picture start
+    // for h.264: look for idr nal type or a slice header for an i-frame
+    // for vc1:   look for a Sequence header
+    int i;
+    uint32_t strid = 0;
+
+
+    if ( stream->ts_stream_type[0] <= 2 )
+    {
+        // This section of the code handles MPEG-1 and MPEG-2 video streams
+        for (i = 13 + adapt_len; i < 188; i++)
+        {
+            strid = (strid << 8) | buf[i];
+            if ( ( strid >> 8 ) == 1 )
+            {
+                // we found a start code
+                uint8_t id = strid;
+                switch ( id )
+                {
+                    case 0xB8: // group_start_code (GOP header)
+                    case 0xB3: // sequence_header code
+                        return 1;
+
+                    case 0x00: // picture_start_code
+                        // picture_header, let's see if it's an I-frame
+                        if (i<185)
+                        {
+                            // check if picture_coding_type == 1
+                            if ((buf[i+2] & (0x7 << 3)) == (1 << 3))
+                            {
+                                // found an I-frame picture
+                                return 1;
+                            }
+                        }
+                        break;
+                }
+            }
+        }
+        // didn't find an I-frame
+        return 0;
+    }
+    if ( stream->ts_stream_type[0] == 0x1b )
+    {
+        // we have an h.264 stream 
+        for (i = 13 + adapt_len; i < 188; i++)
+        {
+            strid = (strid << 8) | buf[i];
+            if ( ( strid >> 8 ) == 1 )
+            {
+                // we found a start code - remove the ref_idc from the nal type
+                uint8_t nal_type = strid & 0x1f;
+                if ( nal_type == 0x05 )
+                    // h.264 IDR picture start
+                    return 1;
+            }
+        }
+        // didn't find an I-frame
+        return 0;
+    }
+    if ( stream->ts_stream_type[0] == 0xea )
+    {
+        // we have an vc1 stream 
+        for (i = 13 + adapt_len; i < 188; i++)
+        {
+            strid = (strid << 8) | buf[i];
+            if ( strid == 0x10f )
+            {
+                // the ffmpeg vc1 decoder requires a seq hdr code in the first
+                // frame.
+                return 1;
+            }
+        }
+        // didn't find an I-frame
+        return 0;
+    }
+
+    // we don't understand the stream type so just say "yes" otherwise
+    // we'll discard all the video.
+    return 1;
+}
+
 /*
  * scan the next MB of 'stream' to find the next start packet for
  * the Packetized Elementary Stream associated with TS PID 'pid'.
@@ -760,12 +890,28 @@ static const uint8_t *hb_ts_stream_getPEStype(hb_stream_t *stream, uint32_t pid)
             return 0;
         }
 
+        // while we're reading the stream, check if it has valid PCRs
+        // and/or random access points.
+        uint32_t pack_pid = ( (buf[1] & 0x1f) << 8 ) | buf[2];
+        if ( pack_pid == stream->pmt_info.PCR_PID )
+        {
+            if ( ( buf[5] & 0x10 ) &&
+                 ( ( ( buf[3] & 0x30 ) == 0x20 ) ||
+                   ( ( buf[3] & 0x30 ) == 0x30 && buf[4] > 6 ) ) )
+            {
+                stream->ts_flags |= TS_HAS_PCR;
+            }
+        }
+        if ( buf[5] & 0x40 )
+        {
+            stream->ts_flags |= TS_HAS_RAP;
+        }
+
         /*
          * The PES header is only in TS packets with 'start' set so we check
          * that first then check for the right PID.
          */
-        if ((buf[1] & 0x40) == 0 || (buf[1] & 0x1f) != (pid >> 8) ||
-            buf[2] != (pid & 0xff))
+        if ((buf[1] & 0x40) == 0 || pack_pid != pid )
         {
             // not a start packet or not the pid we want
             continue;
@@ -867,7 +1013,7 @@ struct pts_pos {
     uint64_t pts;   /* PTS from video stream */
 };
 
-#define NDURSAMPLES 16
+#define NDURSAMPLES 128
 
 // get one (position, timestamp) sampple from a transport or program
 // stream.
@@ -883,12 +1029,12 @@ static struct pts_pos hb_sample_pts(hb_stream_t *stream, uint64_t fpos)
         buf = hb_ts_stream_getPEStype( stream, stream->ts_video_pids[0] );
         if ( buf == NULL )
         {
-            hb_log("hb_sample_pts: couldn't find video packet near %llu", fpos);
+            hb_log("hb_sample_pts: couldn't find video packet near %"PRIu64, fpos);
             return pp;
         }
         if ( ( buf[7] >> 7 ) != 1 )
         {
-            hb_log("hb_sample_pts: no PTS in video packet near %llu", fpos);
+            hb_log("hb_sample_pts: no PTS in video packet near %"PRIu64, fpos);
             return pp;
         }
         pp.pts = ( ( (uint64_t)buf[9] >> 1 ) & 7 << 30 ) |
@@ -896,6 +1042,14 @@ static struct pts_pos hb_sample_pts(hb_stream_t *stream, uint64_t fpos)
                  ( ( (uint64_t)buf[11] >> 1 ) << 15 ) |
                  ( (uint64_t)buf[12] << 7 ) |
                  ( (uint64_t)buf[13] >> 1 );
+
+        if ( isIframe( stream, buf, -4 ) )
+        {
+            if (  stream->ts_IDRs < 255 )
+            {
+                ++stream->ts_IDRs;
+            }
+        }
     }
     else
     {
@@ -924,7 +1078,7 @@ static int dur_compare( const void *a, const void *b )
 static double compute_stream_rate( struct pts_pos *pp, int n )
 {
     int i, j;
-    double rates[NDURSAMPLES * NDURSAMPLES / 2];
+    double rates[NDURSAMPLES * NDURSAMPLES / 8];
     double *rp = rates;
 
     // the following nested loops compute the rates between all pairs.
@@ -939,11 +1093,13 @@ static double compute_stream_rate( struct pts_pos *pp, int n )
         // could easily fall in the inter-piece part of the data which
         // would give a bogus estimate. The 'ns' index creates an
         // asymmetry that favors locality.
-        int ns = i + ( n >> 1 );
+        int ns = i + ( n >> 3 );
         if ( ns > n )
             ns = n;
         for ( j = i+1; j < ns; ++j )
         {
+            if ( (uint64_t)(pp[j].pts - pp[i].pts) > 90000LL*3600*6 )
+                break;
             if ( pp[j].pts != pp[i].pts && pp[j].pos > pp[i].pos )
             {
                 *rp = ((double)( pp[j].pts - pp[i].pts )) /
@@ -1047,7 +1203,55 @@ int hb_stream_read( hb_stream_t * src_stream, hb_buffer_t * b )
         }
         return 1;
     }
-    return hb_ts_stream_decode( src_stream, b->data );
+    return hb_ts_stream_decode( src_stream, b );
+}
+
+int hb_stream_seek_chapter( hb_stream_t * stream, int chapter_num )
+{
+
+    if ( stream->hb_stream_type != ffmpeg )
+    {
+        // currently meaningliess for transport and program streams
+        return 1;
+    }
+    if ( !stream || !stream->title ||
+         chapter_num > hb_list_count( stream->title->list_chapter ) )
+    {
+        return 0;
+    }
+
+    int64_t sum_dur = 0;
+    hb_chapter_t *chapter = NULL;
+    int i;
+    for ( i = 0; i < chapter_num; ++i)
+    {
+        chapter = hb_list_item( stream->title->list_chapter, i );
+        sum_dur += chapter->duration;
+    }
+    stream->chapter = chapter_num - 1;
+    stream->chapter_end = sum_dur;
+
+    int64_t pos = ( ( ( sum_dur - chapter->duration ) * AV_TIME_BASE ) / 90000 );
+
+    hb_deep_log( 2, "Seeking to chapter %d: starts %"PRId64", ends %"PRId64", AV pos %"PRId64,
+                 chapter_num, sum_dur - chapter->duration, sum_dur, pos);
+
+    if ( chapter_num > 1 && pos > 0 )
+    {
+        av_seek_frame( stream->ffmpeg_ic, -1, pos, 0);
+    }
+    return 1;
+}
+
+/***********************************************************************
+ * hb_stream_chapter
+ ***********************************************************************
+ * Return the number of the chapter that we are currently in. We store
+ * the chapter number starting from 0, so + 1 for the real chpater num.
+ **********************************************************************/
+int hb_stream_chapter( hb_stream_t * src_stream )
+{
+    return( src_stream->chapter + 1 );
 }
 
 /***********************************************************************
@@ -1055,37 +1259,50 @@ int hb_stream_read( hb_stream_t * src_stream, hb_buffer_t * b )
  ***********************************************************************
  *
  **********************************************************************/
-int hb_stream_seek( hb_stream_t * src_stream, float f )
+int hb_stream_seek( hb_stream_t * stream, float f )
 {
-       if ( src_stream->hb_stream_type == ffmpeg )
+       if ( stream->hb_stream_type == ffmpeg )
     {
-        return ffmpeg_seek( src_stream, f );
+        return ffmpeg_seek( stream, f );
     }
     off_t stream_size, cur_pos, new_pos;
     double pos_ratio = f;
-    cur_pos = ftello( src_stream->file_handle );
-    fseeko( src_stream->file_handle, 0, SEEK_END );
-    stream_size = ftello( src_stream->file_handle );
+    cur_pos = ftello( stream->file_handle );
+    fseeko( stream->file_handle, 0, SEEK_END );
+    stream_size = ftello( stream->file_handle );
     new_pos = (off_t) ((double) (stream_size) * pos_ratio);
     new_pos &=~ (HB_DVD_READ_BUFFER_SIZE - 1);
 
-    int r = fseeko( src_stream->file_handle, new_pos, SEEK_SET );
+    int r = fseeko( stream->file_handle, new_pos, SEEK_SET );
     if (r == -1)
     {
-        fseeko( src_stream->file_handle, cur_pos, SEEK_SET );
+        fseeko( stream->file_handle, cur_pos, SEEK_SET );
         return 0;
     }
 
-    if ( src_stream->hb_stream_type == transport )
+    if ( stream->hb_stream_type == transport )
     {
         // We need to drop the current decoder output and move
         // forwards to the next transport stream packet.
-        hb_ts_stream_reset(src_stream);
-        src_stream->need_keyframe = ( f != 0 );
+        hb_ts_stream_reset(stream);
+        if ( f > 0 )
+        {
+            if ( stream->ts_IDRs )
+            {
+                // the stream has IDRs so look for one.
+                stream->need_keyframe = 1;
+            }
+        }
+        else
+        {
+            // we're at the beginning - say we have video sync so that we
+            // won't drop initial SPS & PPS data on an AVC stream.
+            stream->need_keyframe = 0;
+        }
     }
-    else if ( src_stream->hb_stream_type == program )
+    else if ( stream->hb_stream_type == program )
     {
-        skip_to_next_pack( src_stream );
+        skip_to_next_pack( stream );
     }
 
     return 1;
@@ -1166,15 +1383,12 @@ static hb_audio_t *hb_ts_stream_set_audio_id_and_codec(hb_stream_t *stream,
     uint8_t stype = 0;
     if (buf && buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0x01)
     {
-        // 0xbd is the normal container for AC3/DCA/PCM/etc. 0xfd indicates an
-        // extended stream id (ISO 13818-1(2007)). If we cared about the
-        // real id we'd have to look inside the PES extension to find it.
-        // But since we remap stream id's when we generate PS packets from
-        // the TS packets we can just ignore the actual id.
-        if ( buf[3] == 0xbd || buf[3] == 0xfd )
+        stype = stream->ts_stream_type[1 + aud_pid_index];
+
+        // 0xbd ("private stream 1") is the normal container for non-ISO
+        // media - AC3/DCA/PCM/etc.
+        if ( buf[3] == 0xbd )
         {
-            audio->id = 0x80bd | (aud_pid_index << 8);
-            stype = stream->ts_stream_type[1 + aud_pid_index];
             if ( st2codec[stype].kind == U )
             {
                 // XXX assume unknown stream types are AC-3 (if they're not
@@ -1183,12 +1397,38 @@ static hb_audio_t *hb_ts_stream_set_audio_id_and_codec(hb_stream_t *stream,
                 stype = 0x81;
                 stream->ts_stream_type[1 + aud_pid_index] = 0x81;
             }
-            stream->ts_streamid[1 + aud_pid_index] = 0xbd;
+        }
+        else if ( buf[3] == 0xfd )
+        {
+            // 0xfd indicates an extended stream id (ISO 13818-1(2007)).
+            // the blu ray consortium apparently forgot to read the portion
+            // of the MPEG spec that says one PID should map to one media
+            // stream and multiplexed multiple types of audio into one PID
+            // using the extended stream identifier of the PES header to
+            // distinguish them. So we have to check if that's happening and
+            // if so tell the runtime what esid we want.
+            if ( st2codec[stype].kind == A && stype == 0x83 &&
+                 stream->ts_format_id[1 + aud_pid_index] == TS_FORMAT_ID_AC3 )
+            {
+                // This is an interleaved TrueHD/AC-3 stream and the esid of
+                // the AC-3 is 0x76
+                stream->ts_multiplexed[1 + aud_pid_index] = 0x76;
+                stype = 0x81;
+                stream->ts_stream_type[1 + aud_pid_index] = 0x81;
+            }
+            if ( st2codec[stype].kind == A && stype == 0x86 )
+            {
+                // This is an interleaved DTS-HD/DTS stream and the esid of
+                // the DTS is 0x71
+                stream->ts_multiplexed[1 + aud_pid_index] = 0x71;
+                stype = 0x82;
+                stream->ts_stream_type[1 + aud_pid_index] = 0x82;
+            }
         }
         else if ((buf[3] & 0xe0) == 0xc0)
         {
-            audio->id = 0xc0 | aud_pid_index;
-            stype = stream->ts_stream_type[1 + aud_pid_index];
+            // 0xC0 - 0xCF are the normal containers for ISO-standard
+            // media (mpeg2 audio and mpeg4 AAC).
             if ( st2codec[stype].kind == U )
             {
                 // XXX assume unknown stream types are MPEG audio
@@ -1196,18 +1436,21 @@ static hb_audio_t *hb_ts_stream_set_audio_id_and_codec(hb_stream_t *stream,
                 stream->ts_stream_type[1 + aud_pid_index] = 0x03;
             }
         }
+        else
+        {
+            stype = 0;
+        }
     }
     // if we found an audio stream type & HB has a codec that can decode it
     // finish configuring the audio so we'll add it to the title's list.
     if ( st2codec[stype].kind == A && st2codec[stype].codec )
     {
-        stream->ts_streamid[1 + aud_pid_index] = audio->id;
-        stream->ts_extra_hdr[1 + aud_pid_index] = st2codec[stype].extra_hdr;
+        audio->id = 1 + aud_pid_index;
         audio->config.in.codec = st2codec[stype].codec;
         audio->config.in.codec_param = st2codec[stype].codec_param;
                set_audio_description( audio,
                   lang_for_code( stream->a52_info[aud_pid_index].lang_code ) );
-        hb_log("transport stream pid 0x%x (type 0x%x) is %s audio id 0x%x",
+        hb_log("transport stream pid 0x%x (type 0x%x) may be %s audio (id 0x%x)",
                stream->ts_audio_pids[aud_pid_index],
                stype, st2codec[stype].name, audio->id);
     }
@@ -1339,10 +1582,9 @@ static void hb_ts_stream_init(hb_stream_t *stream)
        for (i = 0; i < stream->ts_number_video_pids + stream->ts_number_audio_pids; i++)
        {
         // demuxing buffer for TS to PS conversion
-               stream->ts_buf[i] = malloc( HB_DVD_READ_BUFFER_SIZE );
+               stream->ts_buf[i] = hb_buffer_init(stream->packetsize);
+               stream->ts_buf[i]->size = 0;
        }
-
-    stream->ts_streamid[0] = 0xE0;             // stream 0 must be video
 }
 
 #define MAX_HOLE 208*80
@@ -1452,10 +1694,19 @@ static void decode_element_descriptors(hb_stream_t* stream, int esindx,
     {
         switch (dp[0])
         {
+            case 5:    // Registration descriptor
+                stream->ts_format_id[esindx+1] = (dp[2] << 24) | (dp[3] << 16) |
+                                               (dp[4] << 8)  | dp[5];
+                break;
+
             case 10:    // ISO_639_language descriptor
                 stream->a52_info[esindx].lang_code = lang_to_code(lang_for_code2((const char *)&dp[2]));
                 break;
 
+            case 0x6a:  // DVB AC-3 descriptor
+                stream->ts_stream_type[esindx+1] = 0x81;
+                break;
+
             default:
                 break;
         }
@@ -1519,33 +1770,35 @@ int decode_program_map(hb_stream_t* stream)
 
         if ( index_of_pid( elementary_PID, stream ) < 0 )
         {
-            // already have this pid - do nothing
-        }
-        if (stream->ts_number_video_pids == 0 && st2codec[stream_type].kind == V )
-        {
-            stream->ts_video_pids[0] = elementary_PID;
-            stream->ts_stream_type[0] = stream_type;
-            stream->ts_number_video_pids = 1;
-        }
-        else
-        {
-            // Defined audio stream types are 0x81 for AC-3/A52 audio and 0x03
-            // for mpeg audio. But content producers seem to use other
-            // values (0x04 and 0x06 have both been observed) so at this point
-            // we say everything that isn't a video pid is audio then at the end
-            // of hb_stream_title_scan we'll figure out which are really audio
-            // by looking at the PES headers.
-            i = stream->ts_number_audio_pids;
-            if (i < kMaxNumberAudioPIDS)
+            // don't have this pid yet
+            if (stream->ts_number_video_pids == 0 && 
+                st2codec[stream_type].kind == V )
+            {
+                stream->ts_video_pids[0] = elementary_PID;
+                stream->ts_stream_type[0] = stream_type;
+                stream->ts_number_video_pids = 1;
+            }
+            else
             {
-                stream->ts_audio_pids[i] = elementary_PID;
-                stream->ts_stream_type[1 + i] = stream_type;
-                if (ES_info_length > 0)
+                // Defined audio stream types are 0x81 for AC-3/A52 audio 
+                // and 0x03 for mpeg audio. But content producers seem to 
+                // use other values (0x04 and 0x06 have both been observed) 
+                // so at this point we say everything that isn't a video 
+                // pid is audio then at the end of hb_stream_title_scan 
+                // we'll figure out which are really audio by looking at 
+                // the PES headers.
+                i = stream->ts_number_audio_pids;
+                if (i < kMaxNumberAudioPIDS)
                 {
-                    decode_element_descriptors(stream, i, ES_info_buf,
-                                               ES_info_length);
+                    stream->ts_audio_pids[i] = elementary_PID;
+                    stream->ts_stream_type[1 + i] = stream_type;
+                    if (ES_info_length > 0)
+                    {
+                        decode_element_descriptors(stream, i, ES_info_buf,
+                                                ES_info_length);
+                    }
+                    ++stream->ts_number_audio_pids;
                 }
-                ++stream->ts_number_audio_pids;
             }
         }
 
@@ -1554,7 +1807,7 @@ int decode_program_map(hb_stream_t* stream)
         free(ES_info_buf);
 
         if (cur_pos >= section_length - 4 /* stop before the CRC */)
-        done_reading_stream_types = 1;
+            done_reading_stream_types = 1;
     }
 
        free(descriptor_buf);
@@ -1743,7 +1996,13 @@ static int decode_PAT(const uint8_t *buf, hb_stream_t *stream)
 
 static void hb_ts_stream_find_pids(hb_stream_t *stream)
 {
-       // align to first packet
+    // To be different from every other broadcaster in the world, New Zealand TV
+    // changes PMTs (and thus video & audio PIDs) when 'programs' change. Since
+    // we may have the tail of the previous program at the beginning of this
+    // file, take our PMT from the middle of the file.
+    fseeko(stream->file_handle, 0, SEEK_END);
+    uint64_t fsize = ftello(stream->file_handle);
+    fseeko(stream->file_handle, fsize >> 1, SEEK_SET);
     align_to_next_packet(stream);
 
        // Read the Transport Stream Packets (188 bytes each) looking at first for PID 0 (the PAT PID), then decode that
@@ -1793,14 +2052,6 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream)
                if ((stream->ts_number_video_pids > 0) && (stream->ts_number_audio_pids > 0))
                  break;
        }
-    // XXX - until we figure out how to handle VC1 just bail when we find it so
-    // that ffmpeg will claim the input stream.
-    if ( stream->ts_stream_type[0] == 0xea )
-    {
-        stream->ts_number_video_pids = 0;
-        stream->ts_number_audio_pids = 0;
-        return;
-    }
 
        hb_log("hb_ts_stream_find_pids - found the following PIDS");
        hb_log("    Video PIDS : ");
@@ -1823,288 +2074,102 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream)
  }
 
 
-static void fwrite64( hb_stream_t *stream, void *buf, int size )
+static void fwrite64( hb_stream_t *stream, void *buf, int len )
 {
-    if ( (stream->fwrite_buf - stream->fwrite_buf_orig) + size > 2048 )
+    if ( len > 0 )
     {
-        hb_log( "steam fwrite64 buffer overflow - writing %d with %d already",
-                size, stream->fwrite_buf - stream->fwrite_buf_orig );
-        return;
+        int pos = stream->fwrite_buf->size;
+        if ( pos + len > stream->fwrite_buf->alloc )
+        {
+            int size = MAX(stream->fwrite_buf->alloc * 2, pos + len);
+            hb_buffer_realloc(stream->fwrite_buf, size);
+        }
+        memcpy( &(stream->fwrite_buf->data[pos]), buf, len );
+        stream->fwrite_buf->size += len;
     }
-    memcpy( stream->fwrite_buf, buf, size );
-    stream->fwrite_buf += size;
-}
-
-static void write_pack(hb_stream_t* stream, uint64_t time, int stuffing)
-{
-       uint8_t buf[24];
-
-    buf[0] = 0x00;      // pack id
-    buf[1] = 0x00;
-    buf[2] = 0x01;
-    buf[3] = 0xba;
-
-    buf[4] = 0x44 |     // SCR
-             ( ( ( time >> 30 ) & 7 ) << 3 ) |
-             ( ( time >> 28 ) & 3 );
-    buf[5] = time >> 20;
-    buf[6] = 0x04 |
-             ( ( ( time >> 15 ) & 0x1f ) << 3 ) |
-             ( ( time >> 13 ) & 3 );
-    buf[7] = time >> 5;
-    buf[8] = 0x04 | ( time << 3 );
-
-    buf[9] = 0x01;      // SCR extension
-
-    buf[10] = 384000 >> (22 - 8);     // program mux rate
-    buf[11] = (uint8_t)( 384000 >> (22 - 16) );
-    buf[12] = (uint8_t)( 384000 << 2 ) | 0x03;
-
-    buf[13] = 0xf8 | stuffing;
-
-    int i;
-    for (i = 0; i < stuffing; ++i )
-        buf[14+i] = 0xff;
-
-       fwrite64(stream, buf, 14 + stuffing );
 }
 
-static void pad_buffer(hb_stream_t* stream, int pad)
+// convert a PES PTS or DTS to an int64
+static int64_t pes_timestamp( const uint8_t *pes )
 {
-       pad -= 6;
-
-       uint8_t buf[6];
-       buf[0] = 0;
-    buf[1] = 0;
-    buf[2] = 0;
-    buf[3] = 0xbe;
-       buf[4] = pad >> 8;
-    buf[5] = pad;
-
-       fwrite64(stream, buf, 6);
-
-       buf[0] = 0xff;
-    while ( --pad >= 0 )
-    {
-               fwrite64(stream, buf, 1);
-       }
-}
-
-static void make_pes_header(hb_stream_t* stream, int len, uint8_t streamid)
-{
-       uint8_t buf[9];
-
-    memset(buf, 0, sizeof(buf) );
-    buf[2] = 1;
-    buf[3] = streamid;
-    buf[4] = ( len + 3 ) >> 8;
-    buf[5] = len + 3;
-    buf[6] = 0x88;
-
-    fwrite64(stream, buf, 9);
+    int64_t ts = ( (uint64_t)(pes[0] & 0xe ) << 29 );
+    ts |= ( pes[1] << 22 ) | ( ( pes[2] >> 1 ) << 15 ) |
+          ( pes[3] << 7 ) | ( pes[4] >> 1 );
+    return ts;
 }
 
 static void generate_output_data(hb_stream_t *stream, int curstream)
 {
-    uint8_t *tdat = stream->ts_buf[curstream];
-    int len;
+    hb_buffer_t *buf = stream->fwrite_buf;
+    uint8_t *tdat = stream->ts_buf[curstream]->data;
 
-    // we always ship a PACK header plus all the data in our demux buf.
-    // AC3 audio also always needs its substream header.
-    len = 14 + stream->ts_pos[curstream];
-    if ( stream->ts_extra_hdr[curstream] )
-    {
-        len += 4;
-    }
+    buf->id = curstream;
 
-    if ( ! stream->ts_start[curstream] )
+    // check if this packet was referenced to an older pcr and if that
+    // pcr was significantly different than the one we're using now.
+    // (the reason for the uint cast on the pcr difference is that the
+    // difference is significant if it advanced by more than 200ms or if
+    // it went backwards by any amount. The negative numbers look like huge
+    // unsigned ints so the cast allows both conditions to be checked at once.
+    int bufpcr = stream->ts_buf[curstream]->cur;
+    int curpcr = stream->ts_pcr_out;
+    if ( bufpcr && bufpcr < curpcr &&
+         (uint64_t)(stream->ts_pcrhist[curpcr & 3] - stream->ts_pcrhist[bufpcr & 3]) > 200*90LL )
     {
-        // we're in the middle of a chunk of PES data - we need to add
-        // a 'continuation' PES header after the PACK header.
-        len += 9;
+        // we've sent up a new pcr but have a packet referenced to an
+        // old pcr and the difference was enough to trigger a discontinuity
+        // correction. smash the timestamps or we'll mess up the correction.
+        buf->start = -1;
+        buf->renderOffset = -1;
     }
-
-    // Write out pack header
-    // If we don't have 2048 bytes we need to pad to 2048. We can
-    // add a padding frame after our data but we need at least 7
-    // bytes of space to do it (6 bytes of header & 1 of pad). If
-    // we have fewer than 7 bytes left we need to fill the excess
-    // space with stuffing bytes added to the pack header.
-    int stuffing = 0;
-    if ( len > HB_DVD_READ_BUFFER_SIZE )
-    {
-        hb_log( "stream ts length botch %d", len );
-    }
-    if ( HB_DVD_READ_BUFFER_SIZE - len < 8)
-    {
-        stuffing = HB_DVD_READ_BUFFER_SIZE - len;
-    }
-    write_pack(stream, stream->ts_nextpcr, stuffing );
-    stream->ts_nextpcr += 10;
-
-    if ( stream->ts_start[curstream] )
+    else
     {
-        // Start frames already have a PES header but we have modify it
-        // to map from TS PID to PS stream id. Also, if the stream is AC3
-        // audio we have to insert an AC3 stream header between the end of
-        // the PES header and the start of the stream data.
-
-        stream->ts_start[curstream] = 0;
-        tdat[3] = stream->ts_streamid[curstream];
-
-        uint16_t plen = stream->ts_pos[curstream] - 6;
-        if ( stream->ts_extra_hdr[curstream] )
+        if ( stream->ts_pcr_out != stream->ts_pcr_in )
         {
-            // We have to add an AC3 header in front of the data. Add its
-            // size to the PES packet length.
-            plen += 4;
-            tdat[4] = plen >> 8;
-            tdat[5] = plen;
-
-            // Write out the PES header
-            int hdrsize = 9 + tdat[8];
-            fwrite64(stream, tdat, hdrsize);
-
-            // add a four byte DVD ac3 stream header
-            uint8_t ac3_substream_id[4];
-            int ssid = (curstream - stream->ts_number_video_pids) & 0xf;
-            ac3_substream_id[0] = 0x80 | ssid;  // substream id
-            ac3_substream_id[1] = 0x01;         // number of sync words
-            ac3_substream_id[2] = 0x00;         // first offset (16 bits)
-            ac3_substream_id[3] = 0x02;
-            fwrite64(stream, ac3_substream_id, 4);
-
-            // add the rest of the data
-            fwrite64(stream, tdat + hdrsize, stream->ts_pos[curstream] - hdrsize);
+            // we have a new pcr
+            stream->ts_pcr_out = stream->ts_pcr_in;
+            buf->stop = stream->ts_pcr;
+            stream->ts_pcrhist[stream->ts_pcr_out & 3] = stream->ts_pcr;
         }
         else
         {
-            // not audio - don't need to modify the stream so write what we've got
-            tdat[4] = plen >> 8;
-            tdat[5] = plen;
-            fwrite64( stream,  tdat, stream->ts_pos[curstream] );
+            buf->stop = -1;
         }
-    }
-    else
-    {
-        // data without a PES start header needs a simple 'continuation'
-        // PES header. AC3 audio also needs its substream header.
-        if ( stream->ts_extra_hdr[curstream] == 0 )
+
+        // put the PTS & possible DTS into 'start' & 'renderOffset' then strip
+        // off the PES header.
+        if ( tdat[7] & 0xc0 )
         {
-            make_pes_header(stream, stream->ts_pos[curstream],
-                            stream->ts_streamid[curstream]);
+            buf->start = pes_timestamp( tdat + 9 );
+            buf->renderOffset = ( tdat[7] & 0x40 )? pes_timestamp( tdat + 14 ) :
+                                                    buf->start;
         }
         else
         {
-            make_pes_header(stream, stream->ts_pos[curstream] + 4,
-                            stream->ts_streamid[curstream]);
-
-            // add a four byte DVD ac3 stream header
-            uint8_t ac3_substream_id[4];
-            int ssid = (curstream - stream->ts_number_video_pids) & 0xf;
-            ac3_substream_id[0] = 0x80 | ssid;  // substream id
-            ac3_substream_id[1] = 0x01;         // number of sync words
-            ac3_substream_id[2] = 0x00;         // first offset (16 bits)
-            ac3_substream_id[3] = 0x02;
-            fwrite64(stream, ac3_substream_id, 4);
+            buf->start = -1;
+            buf->renderOffset = -1;
         }
-        fwrite64( stream, tdat, stream->ts_pos[curstream] );
     }
+    int hlen = tdat[8] + 9;
 
-    // Write padding
-    int left = HB_DVD_READ_BUFFER_SIZE - len;
-    if ( left >= 8 )
-    {
-        pad_buffer(stream, left);
-    }
+    fwrite64( stream,  tdat + hlen, stream->ts_pos[curstream] - hlen );
 
     stream->ts_pos[curstream] = 0;
+    stream->ts_buf[curstream]->size = 0;
 }
 
-static int isIframe( hb_stream_t *stream, const uint8_t *buf, int adapt_len )
+static void hb_ts_stream_append_pkt(hb_stream_t *stream, int idx, const uint8_t *buf, int len)
 {
-    // For mpeg2: look for a gop start or i-frame picture start
-    // for h.264: look for idr nal type or a slice header for an i-frame
-    // for vc1:   ???
-    int i;
-    uint32_t strid = 0;
-
-
-    if ( stream->ts_stream_type[0] <= 2 )
-    {
-        // This section of the code handles MPEG-1 and MPEG-2 video streams
-        for (i = 13 + adapt_len; i < 188; i++)
-        {
-            strid = (strid << 8) | buf[i];
-            if ( ( strid >> 8 ) == 1 )
-            {
-                // we found a start code
-                uint8_t id = strid;
-                switch ( id )
-                {
-                    case 0xB8: // group_start_code (GOP header)
-                    case 0xB3: // sequence_header code
-                        return 1;
-
-                    case 0x00: // picture_start_code
-                        // picture_header, let's see if it's an I-frame
-                        if (i<185)
-                        {
-                            // check if picture_coding_type == 1
-                            if ((buf[i+2] & (0x7 << 3)) == (1 << 3))
-                            {
-                                // found an I-frame picture
-                                return 1;
-                            }
-                        }
-                        break;
-                }
-            }
-        }
-        // didn't find an I-frame
-        return 0;
-    }
-    if ( stream->ts_stream_type[0] == 0x1b )
+    if (stream->ts_pos[idx] + len > stream->ts_buf[idx]->alloc)
     {
-        // we have an h.264 stream 
-        for (i = 13 + adapt_len; i < 188; i++)
-        {
-            strid = (strid << 8) | buf[i];
-            if ( ( strid >> 8 ) == 1 )
-            {
-                // we found a start code - remove the ref_idc from the nal type
-                uint8_t nal_type = strid & 0x1f;
-                if ( nal_type == 0x05 )
-                    // h.264 IDR picture start
-                    return 1;
+        int size;
 
-                if ( stream->packetsize == 192 )
-                {
-                    // m2ts files have idr frames so keep looking for one
-                    continue;
-                }
-
-                // h226 in ts files (ATSC or DVB video) often seem to be
-                // missing IDR frames so look for at least an I
-                if ( nal_type == 0x01 )
-                {
-                    // h.264 slice: has to be start MB 0 & type I (2, 4, 7 or 9)
-                    uint8_t id = buf[i+1];
-                    if ( ( id >> 4 ) == 0x0b || ( id >> 2 ) == 0x25 ||
-                         id == 0x88 || id == 0x8a )
-                    {
-                        return 1;
-                    }
-                }
-            }
-        }
-        // didn't find an I-frame
-        return 0;
+        size = MAX(stream->ts_buf[idx]->alloc * 2, stream->ts_pos[idx] + len);
+        hb_buffer_realloc(stream->ts_buf[idx], size);
     }
-
-    // we don't understand the stream type so just say "yes" otherwise
-    // we'll discard all the video.
-    return 1;
+    memcpy(stream->ts_buf[idx]->data + stream->ts_pos[idx], buf, len);
+    stream->ts_pos[idx] += len;
+    stream->ts_buf[idx]->size += len;
 }
 
 /***********************************************************************
@@ -2112,19 +2177,18 @@ static int isIframe( hb_stream_t *stream, const uint8_t *buf, int adapt_len )
  ***********************************************************************
  *
  **********************************************************************/
-static int hb_ts_stream_decode( hb_stream_t *stream, uint8_t *obuf )
+static int hb_ts_stream_decode( hb_stream_t *stream, hb_buffer_t *obuf )
 {
     /*
      * stash the output buffer pointer in our stream so we don't have to
      * pass it & its original value to everything we call.
      */
+    obuf->size = 0;
     stream->fwrite_buf = obuf;
-    stream->fwrite_buf_orig = obuf;
 
        // spin until we get a packet of data from some stream or hit eof
        while ( 1 )
        {
-        int64_t pcr = stream->ts_lastpcr;
         int curstream;
 
         const uint8_t *buf = next_packet(stream);
@@ -2171,26 +2235,36 @@ static int hb_ts_stream_decode( hb_stream_t *stream, uint8_t *obuf )
                        }
                }
 
-        // if there's an adaptation header & PCR_flag is set
-        // get the PCR (Program Clock Reference)
-        if ( adapt_len > 7 && ( buf[5] & 0x10 ) != 0 )
+        if ( adapt_len > 0 )
         {
-            pcr = ( (uint64_t)buf[6] << (33 - 8) ) |
-                  ( (uint64_t)buf[7] << (33 - 16) ) |
-                  ( (uint64_t)buf[8] << (33 - 24) ) |
-                  ( (uint64_t)buf[9] << (33 - 32) ) |
-                  ( buf[10] >> 7 );
-            stream->ts_nextpcr = pcr;
-
-            // remember the pcr across calls to this routine
-            stream->ts_lastpcr = pcr;
+            if ( buf[5] & 0x40 )
+            {
+                // found a random access point
+            }
+            // if there's an adaptation header & PCR_flag is set
+            // get the PCR (Program Clock Reference)
+            if ( adapt_len > 7 && ( buf[5] & 0x10 ) != 0 )
+            {
+                stream->ts_pcr = ( (uint64_t)buf[6] << (33 - 8) ) |
+                                 ( (uint64_t)buf[7] << (33 - 16) ) |
+                                 ( (uint64_t)buf[8] << (33 - 24) ) |
+                                 ( (uint64_t)buf[9] << (33 - 32) ) |
+                                 ( buf[10] >> 7 );
+                ++stream->ts_pcr_in;
+                stream->ts_found_pcr = 1;
+            }
         }
 
-        // If we don't have a pcr yet, the right thing to do here would
-        // be a 'continue' so we don't process anything until we have a
-        // clock reference. Unfortunately the HD Home Run appears to null
-        // out the pcr field of some streams so we keep going & substitute
-        // the video stream dts for the pcr when there's no pcr.
+        // If we don't have a PCR yet but the stream has PCRs just loop
+        // so we don't process anything until we have a clock reference.
+        // Unfortunately the HD Home Run appears to null out the PCR so if
+        // we didn't detect a PCR during scan keep going and we'll use
+        // the video stream DTS for the PCR.
+
+        if ( !stream->ts_found_pcr && ( stream->ts_flags & TS_HAS_PCR ) )
+        {
+            continue;
+        }
 
                // Get continuity
         // Continuity only increments for adaption values of 0x3 or 0x01
@@ -2203,24 +2277,60 @@ static int hb_ts_stream_decode( hb_stream_t *stream, uint8_t *obuf )
             int continuity = (buf[3] & 0xF);
             if ( continuity == stream->ts_streamcont[curstream] )
             {
-                // we got a duplicate packet (usually used to introduce
-                // a PCR when one is needed). The only thing that can
-                // change in the dup is the PCR which we grabbed above
-                // so ignore the rest.
-                continue;
+                // Spliced transport streams can have duplicate 
+                // continuity counts at the splice boundary.
+                // Test to see if the packet is really a duplicate
+                // by comparing packet summaries to see if they
+                // match.
+                uint8_t summary[8];
+
+                summary[0] = adaption;
+                summary[1] = adapt_len;
+                if (adapt_len + 4 + 6 + 9 <= 188)
+                {
+                    memcpy(&summary[2], buf+4+adapt_len+9, 6);
+                }
+                else
+                {
+                    memset(&summary[2], 0, 6);
+                }
+                if ( memcmp( summary, stream->ts_pkt_summary[curstream], 8 ) == 0 )
+                {
+                    // we got a duplicate packet (usually used to introduce
+                    // a PCR when one is needed). The only thing that can
+                    // change in the dup is the PCR which we grabbed above
+                    // so ignore the rest.
+                    continue;
+                }
             }
             if ( !start && (stream->ts_streamcont[curstream] != -1) &&
-                 stream->ts_foundfirst[curstream] &&
+                 !stream->ts_skipbad[curstream] &&
                  (continuity != ( (stream->ts_streamcont[curstream] + 1) & 0xf ) ) )
                        {
                                ts_err( stream, curstream,  "continuity error: got %d expected %d",
                         (int)continuity,
                         (stream->ts_streamcont[curstream] + 1) & 0xf );
                 stream->ts_streamcont[curstream] = continuity;
-                               continue;
-                       }
-                       stream->ts_streamcont[curstream] = continuity;
-               }
+                continue;
+            }
+            stream->ts_streamcont[curstream] = continuity;
+
+            // Save a summary of this packet for later duplicate
+            // testing.  The summary includes some header information
+            // and payload bytes.  Should be enough to detect 
+            // non-duplicates.
+            stream->ts_pkt_summary[curstream][0] = adaption;
+            stream->ts_pkt_summary[curstream][1] = adapt_len;
+            if (adapt_len + 4 + 6 + 9 <= 188)
+            {
+                memcpy(&stream->ts_pkt_summary[curstream][2], 
+                        buf+4+adapt_len+9, 6);
+            }
+            else
+            {
+                memset(&stream->ts_pkt_summary[curstream][2], 0, 6);
+            }
+        }
 
         /* If we get here the packet is valid - process its data */
 
@@ -2228,39 +2338,34 @@ static int hb_ts_stream_decode( hb_stream_t *stream, uint8_t *obuf )
         {
             // Found a random access point (now we can start a frame/audio packet..)
 
+            if ( stream->need_keyframe )
+            {
+                // we're looking for the first video frame because we're
+                // doing random access during 'scan'
+                if ( curstream != 0 || !isIframe( stream, buf, adapt_len ) )
+                {
+                    // not the video stream or didn't find an I frame
+                    // but we'll only wait 255 video frames for an I frame.
+                    if ( curstream != 0 || ++stream->need_keyframe )
+                    {
+                        continue;
+                    }
+                }
+                stream->need_keyframe = 0;
+            }
+
                        // If we were skipping a bad packet, start fresh on this new PES packet..
                        if (stream->ts_skipbad[curstream] == 1)
                        {
-                // video skips to an iframe after a bad packet to minimize
-                // screen corruption
-                if ( curstream == 0 && !isIframe( stream, buf, adapt_len ) )
-                {
-                    continue;
-                }
                                stream->ts_skipbad[curstream] = 0;
                        }
 
-                       // If we don't have video yet, check to see if this is an
-            // i_frame (group of picture start)
                        if ( curstream == 0 )
             {
-                if ( !stream->ts_foundfirst[0] )
-                {
-                    if ( stream->need_keyframe )
-                    {
-                        if ( !isIframe( stream, buf, adapt_len ) )
-                        {
-                            // didn't find an I frame
-                            continue;
-                        }
-                        stream->need_keyframe = 0;
-                    }
-                    stream->ts_foundfirst[0] = 1;
-                }
                 ++stream->frames;
 
                 // if we don't have a pcr yet use the dts from this frame
-                if ( pcr == -1 )
+                if ( !stream->ts_found_pcr )
                 {
                     // PES must begin with an mpeg start code & contain
                     // a DTS or PTS.
@@ -2271,55 +2376,65 @@ static int hb_ts_stream_decode( hb_stream_t *stream, uint8_t *obuf )
                         continue;
                     }
                     // if we have a dts use it otherwise use the pts
-                    pes += (pes[7] & 0x40)? 14 : 9;
-
-                    pcr = ( (uint64_t)(pes[0] & 0xe ) << 29 );
-                    pcr |= ( pes[1] << 22 ) |
-                           ( ( pes[2] >> 1 ) << 15 ) |
-                           ( pes[3] << 7 ) |
-                           ( pes[4] >> 1 );
-                    stream->ts_nextpcr = pcr;
+                    stream->ts_pcr = pes_timestamp( pes + ( pes[7] & 0x40? 14 : 9 ) );
+                    ++stream->ts_pcr_in;
                 }
             }
-            else if ( ! stream->ts_foundfirst[curstream] )
+
+            // if this is a multiplexed stream make sure this is the
+            // substream we want.
+            if ( stream->ts_multiplexed[curstream] )
             {
-                // start other streams only after first video frame found.
-                if ( ! stream->ts_foundfirst[0] )
+                // PES must begin with an mpeg start code & contain
+                // a DTS or PTS.
+                const uint8_t *pes = buf + adapt_len + 4;
+                if ( pes[0] != 0x00 || pes[1] != 0x00 || pes[2] != 0x01 ||
+                     pes[3] != 0xfd )
                 {
+                    stream->ts_skipbad[curstream] = 1;
                     continue;
                 }
-                stream->ts_foundfirst[curstream] = 1;
-                       }
+                // the last byte of the header is the extension id. see if
+                // it's the one we want.
+                if ( pes[pes[8]+8] != stream->ts_multiplexed[curstream] )
+                {
+                    stream->ts_skipbad[curstream] = 1;
+                    continue;
+                }
+            }
 
             // If we have some data already on this stream, turn it into
             // a program stream packet. Then add the payload for this
             // packet to the current pid's buffer.
             if ( stream->ts_pos[curstream] )
             {
+                // we have to ship the old packet before updating the pcr
+                // since the packet we've been accumulating is referenced
+                // to the old pcr.
                 generate_output_data(stream, curstream);
-                stream->ts_start[curstream] = 1;
-                memcpy(stream->ts_buf[curstream],
-                       buf + 4 + adapt_len, 184 - adapt_len);
-                stream->ts_pos[curstream] = 184 - adapt_len;
+
+                // remember the pcr that was in effect when we started
+                // this packet.
+                stream->ts_buf[curstream]->cur = stream->ts_pcr_in;
+                hb_ts_stream_append_pkt(stream, curstream, buf + 4 + adapt_len,
+                                        184 - adapt_len);
                 return 1;
             }
-            stream->ts_start[curstream] = 1;
+            // remember the pcr that was in effect when we started this packet.
+            stream->ts_buf[curstream]->cur = stream->ts_pcr_in;
         }
 
                // Add the payload for this packet to the current buffer
-               if (!stream->ts_skipbad[curstream] && stream->ts_foundfirst[curstream] &&
-            (184 - adapt_len) > 0)
+               if (!stream->ts_skipbad[curstream] && (184 - adapt_len) > 0)
                {
-                       memcpy(stream->ts_buf[curstream] + stream->ts_pos[curstream],
-                   buf + 4 + adapt_len, 184 - adapt_len);
-                       stream->ts_pos[curstream] += 184 - adapt_len;
-
-            // if the next TS packet could possibly overflow our 2K output buffer
-            // we need to generate a packet now. Overflow would be 184 bytes of
-            // data + the 9 byte PES hdr + the 14 byte PACK hdr = 211 bytes.
-            if ( stream->ts_pos[curstream] >= (HB_DVD_READ_BUFFER_SIZE - 216) )
+            hb_ts_stream_append_pkt(stream, curstream, buf + 4 + adapt_len,
+                                    184 - adapt_len);
+            // see if we've hit the end of this PES packet
+            const uint8_t *pes = stream->ts_buf[curstream]->data;
+            int len = ( pes[4] << 8 ) + pes[5] + 6;
+            if ( len > 6 && stream->ts_pos[curstream] == len &&
+                 pes[0] == 0x00 && pes[1] == 0x00 && pes[2] == 0x01 )
             {
-                // we have enough data to make a PS packet
                 generate_output_data(stream, curstream);
                 return 1;
             }
@@ -2334,18 +2449,19 @@ static void hb_ts_stream_reset(hb_stream_t *stream)
        for (i=0; i < kMaxNumberDecodeStreams; i++)
        {
                stream->ts_pos[i] = 0;
-               stream->ts_foundfirst[i] = 0;
-               stream->ts_skipbad[i] = 0;
+               stream->ts_skipbad[i] = 1;
                stream->ts_streamcont[i] = -1;
-               stream->ts_start[i] = 0;
        }
 
-    stream->ts_lastpcr = -1;
-    stream->ts_nextpcr = -1;
+    stream->need_keyframe = 0;
+
+    stream->ts_found_pcr = 0;
+    stream->ts_pcr_out = 0;
+    stream->ts_pcr_in = 0;
+    stream->ts_pcr = 0;
 
     stream->frames = 0;
     stream->errors = 0;
-    stream->need_keyframe = 0;
     stream->last_error_frame = -10000;
     stream->last_error_count = 0;
 
@@ -2364,7 +2480,7 @@ static void ffmpeg_add_codec( hb_stream_t *stream, int stream_index )
     context->error_recognition = 1;
     context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK;
     AVCodec *codec = avcodec_find_decoder( context->codec_id );
-    avcodec_open( context, codec );
+    hb_avcodec_open( context, codec );
 }
 
 // The ffmpeg stream reader / parser shares a lot of state with the 
@@ -2419,9 +2535,6 @@ static int ffmpeg_codec_param( hb_stream_t *stream, int stream_index )
 // (the original scan stream was closed and no longer exists).
 static void ffmpeg_remap_stream( hb_stream_t *stream, hb_title_t *title )
 {
-    // tell ffmpeg we want a pts on every frame it returns
-    stream->ffmpeg_ic->flags |= AVFMT_FLAG_GENPTS;
-
     // all the video & audio came from the same stream so remapping
     // the video's stream slot takes care of everything.
     int slot = title->video_codec_param & (ffmpeg_sl_size - 1);
@@ -2479,6 +2592,7 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title )
     stream->hb_stream_type = ffmpeg;
     stream->ffmpeg_pkt = malloc(sizeof(*stream->ffmpeg_pkt));
     av_init_packet( stream->ffmpeg_pkt );
+    stream->chapter_end = INT64_MAX;
 
     if ( title )
     {
@@ -2605,16 +2719,6 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream )
     title->minutes  = ( dur % 3600 ) / 60;
     title->seconds  = dur % 60;
 
-    // One Chapter
-    hb_chapter_t * chapter;
-    chapter = calloc( sizeof( hb_chapter_t ), 1 );
-    chapter->index = 1;
-    chapter->duration = title->duration;
-    chapter->hours = title->hours;
-    chapter->minutes = title->minutes;
-    chapter->seconds = title->seconds;
-    hb_list_add( title->list_chapter, chapter );
-
     // set the title to decode the first video stream in the file
     title->demuxer = HB_NULL_DEMUXER;
     title->video_codec = 0;
@@ -2645,6 +2749,50 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream )
     title->container_name = strdup( ic->iformat->name );
     title->data_rate = ic->bit_rate;
 
+    hb_deep_log( 2, "Found ffmpeg %d chapters, container=%s", ic->nb_chapters, ic->iformat->name );
+
+    if( ic->nb_chapters != 0 )
+    {
+        AVChapter *m;
+        uint64_t duration_sum = 0;
+        for( i = 0; i < ic->nb_chapters; i++ )
+            if( ( m = ic->chapters[i] ) != NULL )
+            {
+                hb_chapter_t * chapter;
+                chapter = calloc( sizeof( hb_chapter_t ), 1 );
+                chapter->index    = i+1;
+                chapter->duration = ( m->end / ( (double) m->time_base.num * m->time_base.den ) ) * 90000  - duration_sum;
+                duration_sum     += chapter->duration;
+                chapter->hours    = chapter->duration / 90000 / 3600;
+                chapter->minutes  = ( ( chapter->duration / 90000 ) % 3600 ) / 60;
+                chapter->seconds  = ( chapter->duration / 90000 ) % 60;
+                strcpy( chapter->title, m->title );
+                hb_deep_log( 2, "Added chapter %i, name='%s', dur=%"PRIu64", (%02i:%02i:%02i)",
+                            chapter->index, chapter->title,
+                            chapter->duration, chapter->hours,
+                            chapter->minutes, chapter->seconds );
+                hb_list_add( title->list_chapter, chapter );
+            }
+    }
+
+    /*
+     * Fill the metadata.
+     */
+    decmetadata( title );
+
+    if( hb_list_count( title->list_chapter ) == 0 )
+    {
+        // Need at least one chapter
+        hb_chapter_t * chapter;
+        chapter = calloc( sizeof( hb_chapter_t ), 1 );
+        chapter->index = 1;
+        chapter->duration = title->duration;
+        chapter->hours = title->hours;
+        chapter->minutes = title->minutes;
+        chapter->seconds = title->seconds;
+        hb_list_add( title->list_chapter, chapter );
+    }
+
     return title;
 }
 
@@ -2655,6 +2803,52 @@ static int64_t av_to_hb_pts( int64_t pts, double conv_factor )
     return (int64_t)( (double)pts * conv_factor );
 }
 
+static int ffmpeg_is_keyframe( hb_stream_t *stream )
+{
+    uint8_t *pkt;
+
+    switch ( stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]->codec->codec_id )
+    {
+        case CODEC_ID_VC1:
+            // XXX the VC1 codec doesn't mark key frames so to get previews
+            // we do it ourselves here. The decoder gets messed up if it
+            // doesn't get a SEQ header first so we consider that to be a key frame.
+            pkt = stream->ffmpeg_pkt->data;
+            if ( !pkt[0] && !pkt[1] && pkt[2] == 1 && pkt[3] == 0x0f )
+                return 1;
+
+            return 0;
+
+        case CODEC_ID_WMV3:
+            // XXX the ffmpeg WMV3 codec doesn't mark key frames.
+            // Only M$ could make I-frame detection this complicated: there
+            // are two to four bits of unused junk ahead of the frame type
+            // so we have to look at the sequence header to find out how much
+            // to skip. Then there are three different ways of coding the type
+            // depending on whether it's main or advanced profile then whether
+            // there are bframes or not so we have to look at the sequence
+            // header to get that.
+            pkt = stream->ffmpeg_pkt->data;
+            uint8_t *seqhdr = stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]->codec->extradata;
+            int pshift = 2;
+            if ( ( seqhdr[3] & 0x02 ) == 0 )
+                // no FINTERPFLAG
+                ++pshift;
+            if ( ( seqhdr[3] & 0x80 ) == 0 )
+                // no RANGEREDUCTION
+                ++pshift;
+            if ( seqhdr[3] & 0x70 )
+                // stream has b-frames
+                return ( ( pkt[0] >> pshift ) & 0x3 ) == 0x01;
+
+            return ( ( pkt[0] >> pshift ) & 0x2 ) == 0;
+
+        default:
+            break;
+    }
+    return ( stream->ffmpeg_pkt->flags & PKT_FLAG_KEY );
+}
+
 static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf )
 {
     int err;
@@ -2701,16 +2895,15 @@ static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf )
     buf->id = stream->ffmpeg_pkt->stream_index;
     if ( buf->id == stream->ffmpeg_video_id )
     {
-        if ( stream->need_keyframe &&
-             stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]->codec->codec_id == 
-               CODEC_ID_VC1 )
+        if ( stream->need_keyframe )
         {
-            // XXX the VC1 codec doesn't seek to key frames so to get previews
-            // we do it ourselves here. The decoder gets messed up if it
-            // doesn't get a SEQ header first so we consider that to be a key frame.
-            uint8_t *pkt = stream->ffmpeg_pkt->data;
-            if ( pkt[0] || pkt[1] || pkt[2] != 1 || pkt[3] != 0x0f )
+            // we've just done a seek (generally for scan or live preview) and
+            // want to start at a keyframe. Some ffmpeg codecs seek to a key
+            // frame but most don't. So we spin until we either get a keyframe
+            // or we've looked through 50 video frames without finding one.
+            if ( ! ffmpeg_is_keyframe( stream ) && ++stream->need_keyframe < 50 )
             {
+                av_free_packet( stream->ffmpeg_pkt );
                 goto again;
             }
             stream->need_keyframe = 0;
@@ -2734,6 +2927,33 @@ static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf )
     {
         buf->start = buf->renderOffset;
     }
+
+    /*
+     * Check to see whether this video buffer is on a chapter
+     * boundary, if so mark it as such in the buffer then advance
+     * chapter_end to the end of the next chapter.
+     * If there are no chapters, chapter_end is always initialized to INT64_MAX
+     * (roughly 3 million years at our 90KHz clock rate) so the test
+     * below handles both the chapters & no chapters case.
+     */
+    if ( buf->id == stream->ffmpeg_video_id && buf->start >= stream->chapter_end )
+    {
+        hb_chapter_t *chapter = hb_list_item( stream->title->list_chapter,
+                                              stream->chapter+1 );
+        if( chapter )
+        {
+            stream->chapter++;
+            stream->chapter_end += chapter->duration;
+            buf->new_chap = stream->chapter + 1;
+            hb_deep_log( 2, "ffmpeg_read starting chapter %i at %"PRId64,
+                         buf->new_chap, buf->start);
+        } else {
+            // Must have run out of chapters, stop looking.
+            stream->chapter_end = INT64_MAX;
+        }
+    } else {
+        buf->new_chap = 0;
+    }
     av_free_packet( stream->ffmpeg_pkt );
     return 1;
 }
@@ -2741,15 +2961,19 @@ static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf )
 static int ffmpeg_seek( hb_stream_t *stream, float frac )
 {
     AVFormatContext *ic = stream->ffmpeg_ic;
-    int64_t pos = (double)ic->duration * (double)frac;
-    if ( pos )
+    if ( frac > 0. )
     {
+        int64_t pos = (double)ic->duration * (double)frac;
+        if ( ic->start_time != AV_NOPTS_VALUE && ic->start_time > 0 )
+        {
+            pos += ic->start_time;
+        }
         av_seek_frame( ic, -1, pos, 0 );
         stream->need_keyframe = 1;
     }
     else
     {
-        av_seek_frame( ic, -1, pos, AVSEEK_FLAG_BACKWARD );
+        av_seek_frame( ic, -1, 0LL, AVSEEK_FLAG_BACKWARD );
     }
     return 1;
 }
index 03de54c..94b8411 100644 (file)
@@ -5,10 +5,9 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
+#include "hbffmpeg.h"
 #include <stdio.h>
-
 #include "samplerate.h"
-#include "libavcodec/avcodec.h"
 
 #ifdef INT64_MIN
 #undef INT64_MIN /* Because it isn't defined correctly in Zeta */
@@ -45,7 +44,6 @@ struct hb_work_private_s
                                 // an eof buf. syncWork returns done when all
                                 // bits are clear.
     /* Video */
-    hb_subtitle_t * subtitle;
     int64_t pts_offset;
     int64_t next_start;         /* start time of next output frame */
     int64_t next_pts;           /* start time of next input frame */
@@ -61,6 +59,8 @@ struct hb_work_private_s
 
     /* Audio */
     hb_sync_audio_t sync_audio[8];
+    int64_t audio_passthru_slip;
+    int64_t video_pts_slip;
 
     /* Statistics */
     uint64_t st_counts[4];
@@ -96,23 +96,37 @@ int syncInit( hb_work_object_t * w, hb_job_t * job )
     pv->job            = job;
     pv->pts_offset     = INT64_MIN;
 
-    /* Calculate how many video frames we are expecting */
-    if (job->pts_to_stop)
+    if( job->pass == 2 )
     {
-        duration = job->pts_to_stop + 90000;
+        /* We already have an accurate frame count from pass 1 */
+        hb_interjob_t * interjob = hb_interjob_get( job->h );
+        pv->count_frames_max = interjob->frame_count;
     }
     else
     {
-        duration = 0;
-        for( i = job->chapter_start; i <= job->chapter_end; i++ )
+        /* Calculate how many video frames we are expecting */
+        if ( job->pts_to_stop )
+        {
+            duration = job->pts_to_stop + 90000;
+        }
+        else if( job->frame_to_stop )
         {
-            chapter   = hb_list_item( title->list_chapter, i - 1 );
-            duration += chapter->duration;
+            /* Set the duration to a rough estimate */
+            duration = ( job->frame_to_stop / ( title->rate / title->rate_base ) ) * 90000;
         }
-        duration += 90000;
-        /* 1 second safety so we're sure we won't miss anything */
+        else
+        {
+            duration = 0;
+            for( i = job->chapter_start; i <= job->chapter_end; i++ )
+            {
+                chapter   = hb_list_item( title->list_chapter, i - 1 );
+                duration += chapter->duration;
+            }
+            duration += 90000;
+            /* 1 second safety so we're sure we won't miss anything */
+        }
+        pv->count_frames_max = duration * title->rate / title->rate_base / 90000;
     }
-    pv->count_frames_max = duration * job->vrate / job->vrate_base / 90000;
 
     hb_log( "sync: expecting %d video frames", pv->count_frames_max );
     pv->busy |= 1;
@@ -120,16 +134,13 @@ int syncInit( hb_work_object_t * w, hb_job_t * job )
     /* Initialize libsamplerate for every audio track we have */
     if ( ! job->indepth_scan )
     {
-        for( i = 0; i < hb_list_count( title->list_audio ); i++ )
+        for( i = 0; i < hb_list_count( title->list_audio ) && i < 8; i++ )
         {
             pv->busy |= ( 1 << (i + 1) );
             InitAudio( w, i );
         }
     }
 
-    /* Get subtitle info, if any */
-    pv->subtitle = hb_list_item( title->list_subtitle, 0 );
-
     return 0;
 }
 
@@ -154,6 +165,16 @@ void syncClose( hb_work_object_t * w )
     hb_log( "sync: got %d frames, %d expected",
             pv->count_frames, pv->count_frames_max );
 
+    /* save data for second pass */
+    if( job->pass == 1 )
+    {
+        /* Preserve frame count for better accuracy in pass 2 */
+        hb_interjob_t * interjob = hb_interjob_get( job->h );
+        interjob->frame_count = pv->count_frames;
+        interjob->last_job = job->sequence_id;
+        interjob->total_time = pv->next_start;
+    }
+
     if (pv->drops || pv->dups )
     {
         hb_log( "sync: %d frames dropped, %d duplicated", pv->drops, pv->dups );
@@ -238,7 +259,7 @@ static void InitAudio( hb_work_object_t * w, int i )
         c->sample_rate = sync->audio->config.in.samplerate;
         c->channels    = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( sync->audio->config.in.channel_layout );
 
-        if( avcodec_open( c, codec ) < 0 )
+        if( hb_avcodec_open( c, codec ) < 0 )
         {
             hb_log( "sync: avcodec_open failed" );
             return;
@@ -257,7 +278,7 @@ static void InitAudio( hb_work_object_t * w, int i )
         }
 
         free( zeros );
-        avcodec_close( c );
+        hb_avcodec_close( c );
         av_free( c );
     }
     else
@@ -279,6 +300,9 @@ static void SyncVideo( hb_work_object_t * w )
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * cur, * next, * sub = NULL;
     hb_job_t * job = pv->job;
+    hb_subtitle_t *subtitle;
+    int i;
+    int64_t pts_skip;
 
     if( !pv->cur && !( pv->cur = hb_fifo_get( job->fifo_raw ) ) )
     {
@@ -286,10 +310,24 @@ static void SyncVideo( hb_work_object_t * w )
         return;
     }
     cur = pv->cur;
+    pts_skip = 0;
     if( cur->size == 0 )
     {
         /* we got an end-of-stream. Feed it downstream & signal that we're done. */
         hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) );
+
+        /*
+         * Push through any subtitle EOFs in case they were not synced through.
+         */
+        for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
+        {
+            subtitle = hb_list_item( job->list_subtitle, i );
+            if( subtitle->config.dest == PASSTHRUSUB )
+            {
+                hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
+            }
+        }
+
         pv->busy &=~ 1;
         return;
     }
@@ -310,6 +348,18 @@ static void SyncVideo( hb_work_object_t * w )
              * video (we don't know its duration). On DVDs the final frame
              * is often strange and dropping it seems to be a good idea. */
             hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) );
+
+            /*
+             * Push through any subtitle EOFs in case they were not synced through.
+             */
+            for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
+            {
+                subtitle = hb_list_item( job->list_subtitle, i );
+                if( subtitle->config.dest == PASSTHRUSUB )
+                {
+                    hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
+                }
+            }
             pv->busy &=~ 1;
             return;
         }
@@ -327,7 +377,7 @@ static void SyncVideo( hb_work_object_t * w )
                  * as if it started at zero so that our audio timing will
                  * be in sync.
                  */
-                hb_log( "sync: first pts is %lld", cur->start );
+                hb_log( "sync: first pts is %"PRId64, cur->start );
                 cur->start = 0;
             }
         }
@@ -343,13 +393,18 @@ static void SyncVideo( hb_work_object_t * w )
          * can deal with overlaps of up to a frame time but anything larger
          * we handle by dropping frames here.
          */
-        if ( (int64_t)( next->start - cur->start ) <= 0 )
+        if ( (int64_t)( next->start - pv->video_pts_slip - cur->start ) <= 0 )
         {
             if ( pv->first_drop == 0 )
             {
                 pv->first_drop = next->start;
             }
             ++pv->drop_count;
+            if (next->start - cur->start > 0)
+            {
+                pts_skip += next->start - cur->start;
+                pv->video_pts_slip -= next->start - cur->start;
+            }
             buf_tmp = hb_fifo_get( job->fifo_raw );
             if ( buf_tmp->new_chap )
             {
@@ -362,7 +417,7 @@ static void SyncVideo( hb_work_object_t * w )
         if ( pv->first_drop )
         {
             hb_log( "sync: video time didn't advance - dropped %d frames "
-                    "(delta %d ms, current %lld, next %lld, dur %d)",
+                    "(delta %d ms, current %"PRId64", next %"PRId64", dur %d)",
                     pv->drop_count, (int)( cur->start - pv->first_drop ) / 90,
                     cur->start, next->start, (int)( next->start - cur->start ) );
             pv->first_drop = 0;
@@ -375,218 +430,282 @@ static void SyncVideo( hb_work_object_t * w )
          */
         pv->video_sequence = cur->sequence;
 
-        /* Look for a subtitle for this frame */
-        if( pv->subtitle )
+        /*
+         * Look for a subtitle for this frame.
+         *
+         * If found then it will be tagged onto a video buffer of the correct time and 
+         * sent in to the render pipeline. This only needs to be done for VOBSUBs which
+         * get rendered, other types of subtitles can just sit in their raw_queue until
+         * delt with at muxing.
+         */
+        for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
         {
-            hb_buffer_t * sub2;
-            while( ( sub = hb_fifo_see( pv->subtitle->fifo_raw ) ) )
-            {
-                /* If two subtitles overlap, make the first one stop
-                   when the second one starts */
-                sub2 = hb_fifo_see2( pv->subtitle->fifo_raw );
-                if( sub2 && sub->stop > sub2->start )
-                    sub->stop = sub2->start;
-
-                // hb_log("0x%x: video seq: %lld  subtitle sequence: %lld",
-                //       sub, cur->sequence, sub->sequence);
-
-                if( sub->sequence > cur->sequence )
-                {
-                    /*
-                     * The video is behind where we are, so wait until
-                     * it catches up to the same reader point on the
-                     * DVD. Then our PTS should be in the same region
-                     * as the video.
-                     */
-                    sub = NULL;
-                    break;
-                }
-
-                if( sub->stop > cur->start ) {
-                    /*
-                     * The stop time is in the future, so fall through
-                     * and we'll deal with it in the next block of
-                     * code.
-                     */
-                    break;
-                }
-
-                /*
-                 * The subtitle is older than this picture, trash it
-                 */
-                sub = hb_fifo_get( pv->subtitle->fifo_raw );
-                hb_buffer_close( &sub );
-            }
+            subtitle = hb_list_item( job->list_subtitle, i );
 
             /*
-             * There is a valid subtitle, is it time to display it?
+             * Rewrite timestamps on subtitles that need it (on raw queue).
              */
-            if( sub )
+            if( subtitle->source == CC608SUB ||
+                subtitle->source == CC708SUB ||
+                subtitle->source == SRTSUB )
             {
-                if( sub->stop > sub->start)
+                /*
+                 * Rewrite timestamps on subtitles that came from Closed Captions
+                 * since they are using the MPEG2 timestamps.
+                 */
+                while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) )
                 {
                     /*
-                     * Normal subtitle which ends after it starts, check to
-                     * see that the current video is between the start and end.
+                     * Rewrite the timestamps as and when the video
+                     * (cur->start) reaches the same timestamp as a
+                     * closed caption (sub->start).
+                     *
+                     * What about discontinuity boundaries - not delt
+                     * with here - Van?
+                     *
+                     * Bypass the sync fifo altogether.
                      */
-                    if( cur->start > sub->start &&
-                        cur->start < sub->stop )
+                    if( sub->size <= 0 )
                     {
+                        sub = hb_fifo_get( subtitle->fifo_raw );
+                        hb_fifo_push( subtitle->fifo_out, sub );
+                        sub = NULL;
+                        break;
+                    } else {
                         /*
-                         * We should be playing this, so leave the
-                         * subtitle in place.
+                         * Sync the subtitles to the incoming video, and use
+                         * the matching converted video timestamp.
+                         *
+                         * Note that it doesn't appear that we need to convert 
+                         * timestamps, I guess that they were already correct,
+                         * so just push them through for rendering.
                          *
-                         * fall through to display
                          */
-                        if( ( sub->stop - sub->start ) < ( 3 * 90000 ) )
+                        if( sub->start < cur->start )
                         {
-                            /*
-                             * Subtitle is on for less than three seconds, extend
-                             * the time that it is displayed to make it easier
-                             * to read. Make it 3 seconds or until the next
-                             * subtitle is displayed.
-                             *
-                             * This is in response to Indochine which only
-                             * displays subs for 1 second - too fast to read.
-                             */
-                            sub->stop = sub->start + ( 3 * 90000 );
+                            sub = hb_fifo_get( subtitle->fifo_raw );
+                            hb_fifo_push( subtitle->fifo_out, sub );
+                        } else {
+                            sub = NULL;
+                            break;
+                        }
+                    }
+                }
+            }
 
-                            sub2 = hb_fifo_see2( pv->subtitle->fifo_raw );
+            if( subtitle->source == VOBSUB ) 
+            {
+                hb_buffer_t * sub2;
+                while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) )
+                {
+                    if( sub->size == 0 )
+                    {
+                        /*
+                         * EOF, pass it through immediately.
+                         */
+                        break;
+                    }
 
-                            if( sub2 && sub->stop > sub2->start )
-                            {
-                                sub->stop = sub2->start;
-                            }
-                        }
+                    /* If two subtitles overlap, make the first one stop
+                       when the second one starts */
+                    sub2 = hb_fifo_see2( subtitle->fifo_raw );
+                    if( sub2 && sub->stop > sub2->start )
+                    {
+                        sub->stop = sub2->start;
                     }
-                    else
+                    
+                    // hb_log("0x%x: video seq: %lld  subtitle sequence: %lld",
+                    //       sub, cur->sequence, sub->sequence);
+                    
+                    if( sub->sequence > cur->sequence )
                     {
                         /*
-                         * Defer until the play point is within the subtitle
+                         * The video is behind where we are, so wait until
+                         * it catches up to the same reader point on the
+                         * DVD. Then our PTS should be in the same region
+                         * as the video.
                          */
                         sub = NULL;
+                        break;
                     }
-                }
-                else
-                {
-                    /*
-                     * The end of the subtitle is less than the start, this is a
-                     * sign of a PTS discontinuity.
-                     */
-                    if( sub->start > cur->start )
-                    {
+                    
+                    if( sub->stop > cur->start ) {
                         /*
-                         * we haven't reached the start time yet, or
-                         * we have jumped backwards after having
-                         * already started this subtitle.
+                         * The stop time is in the future, so fall through
+                         * and we'll deal with it in the next block of
+                         * code.
                          */
-                        if( cur->start < sub->stop )
+
+                        /*
+                         * There is a valid subtitle, is it time to display it?
+                         */
+                        if( sub->stop > sub->start)
                         {
                             /*
-                             * We have jumped backwards and so should
-                             * continue displaying this subtitle.
-                             *
-                             * fall through to display.
+                             * Normal subtitle which ends after it starts, 
+                             * check to see that the current video is between 
+                             * the start and end.
                              */
+                            if( cur->start > sub->start &&
+                                cur->start < sub->stop )
+                            {
+                                /*
+                                * We should be playing this, so leave the
+                                * subtitle in place.
+                                *
+                                * fall through to display
+                                */
+                                if( ( sub->stop - sub->start ) < ( 2 * 90000 ) )
+                                {
+                                    /*
+                                     * Subtitle is on for less than three 
+                                     * seconds, extend the time that it is 
+                                     * displayed to make it easier to read. 
+                                     * Make it 3 seconds or until the next
+                                     * subtitle is displayed.
+                                     *
+                                     * This is in response to Indochine which 
+                                     * only displays subs for 1 second - 
+                                     * too fast to read.
+                                     */
+                                    sub->stop = sub->start + ( 2 * 90000 );
+                                
+                                    sub2 = hb_fifo_see2( subtitle->fifo_raw );
+                                
+                                    if( sub2 && sub->stop > sub2->start )
+                                    {
+                                        sub->stop = sub2->start;
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                /*
+                                 * Defer until the play point is within 
+                                 * the subtitle
+                                 */
+                                sub = NULL;
+                            }
                         }
                         else
                         {
                             /*
-                             * Defer until the play point is within the subtitle
+                             * The end of the subtitle is less than the start, 
+                             * this is a sign of a PTS discontinuity.
                              */
-                            sub = NULL;
+                            if( sub->start > cur->start )
+                            {
+                                /*
+                                 * we haven't reached the start time yet, or
+                                 * we have jumped backwards after having
+                                 * already started this subtitle.
+                                 */
+                                if( cur->start < sub->stop )
+                                {
+                                    /*
+                                     * We have jumped backwards and so should
+                                     * continue displaying this subtitle.
+                                     *
+                                     * fall through to display.
+                                     */
+                                }
+                                else
+                                {
+                                    /*
+                                     * Defer until the play point is 
+                                     * within the subtitle
+                                     */
+                                    sub = NULL;
+                                }
+                            } else {
+                                /*
+                                * Play this subtitle as the start is 
+                                * greater than our video point.
+                                *
+                                * fall through to display/
+                                */
+                            }
                         }
-                    } else {
+                       break;
+                    }
+                    else
+                    {
+                    
                         /*
-                         * Play this subtitle as the start is greater than our
-                         * video point.
-                         *
-                         * fall through to display/
+                         * The subtitle is older than this picture, trash it
                          */
+                        sub = hb_fifo_get( subtitle->fifo_raw );
+                        hb_buffer_close( &sub );
                     }
                 }
-            }
-        }
-
-        int64_t duration;
-        if ( job->mux & HB_MUX_AVI || job->cfr )
-        {
-            /*
-             * The concept of variable frame rate video was a bit too advanced
-             * for Microsoft so AVI doesn't support it. Since almost all dvd
-             * video is VFR we have to convert it to constant frame rate to
-             * put it in an AVI container. So here we duplicate, drop and
-             * otherwise trash video frames to appease the gods of Redmond.
-             */
-
-            /* mpeg durations are exact when expressed in ticks of the
-             * 27MHz System clock but not in HB's 90KHz PTS clock. To avoid
-             * a truncation bias that will eventually cause the audio to desync
-             * we compute the duration of the next frame using 27MHz ticks
-             * then truncate it to 90KHz. */
-            duration = ( (int64_t)(pv->count_frames + 1 ) * job->vrate_base ) / 300 -
-                       pv->next_start;
-
-            /* We don't want the input & output clocks to be exactly in phase
-             * otherwise small variations in the time will cause us to think
-             * we're a full frame off & there will be lots of drops and dups.
-             * We offset the input clock by half the duration so it's maximally
-             * out of phase with the output clock. */
-            if( cur->start < pv->next_start  - ( duration >> 1 ) )
-            {
-                /* current frame too old - drop it */
-                if ( cur->new_chap )
+                
+                /* If we have a subtitle for this picture, copy it */
+                /* FIXME: we should avoid this memcpy */
+                if( sub )
                 {
-                    pv->chap_mark = cur->new_chap;
+                    if( sub->size > 0 )
+                    {
+                        if( subtitle->config.dest == RENDERSUB )
+                        {
+                            if ( cur->sub == NULL )
+                            {
+                                /*
+                                 * Tack onto the video buffer for rendering
+                                 */
+                                cur->sub         = hb_buffer_init( sub->size );
+                                cur->sub->x      = sub->x;
+                                cur->sub->y      = sub->y;
+                                cur->sub->width  = sub->width;
+                                cur->sub->height = sub->height;
+                                memcpy( cur->sub->data, sub->data, sub->size ); 
+                            }
+                        } else {
+                            /*
+                             * Pass-Through, pop it off of the raw queue, 
+                             */
+                            sub = hb_fifo_get( subtitle->fifo_raw );
+                            hb_fifo_push( subtitle->fifo_sync, sub );
+                        }
+                    } else {
+                        /*
+                        * EOF - consume for rendered, else pass through
+                        */
+                        if( subtitle->config.dest == RENDERSUB )
+                        {
+                            sub = hb_fifo_get( subtitle->fifo_raw );
+                            hb_buffer_close( &sub );
+                        } else {
+                            sub = hb_fifo_get( subtitle->fifo_raw );
+                            hb_fifo_push( subtitle->fifo_out, sub );
+                        }
+                    }
                 }
-                hb_buffer_close( &cur );
-                pv->cur = cur = hb_fifo_get( job->fifo_raw );
-                pv->next_pts = next->start;
-                ++pv->drops;
-                continue;
             }
+        } // end subtitles
 
-            if( next->start > pv->next_start + duration + ( duration >> 1 ) )
-            {
-                /* next frame too far ahead - dup current frame */
-                buf_tmp = hb_buffer_init( cur->size );
-                hb_buffer_copy_settings( buf_tmp, cur );
-                memcpy( buf_tmp->data, cur->data, cur->size );
-                buf_tmp->sequence = cur->sequence;
-                ++pv->dups;
-            }
-            else
-            {
-                /* this frame in our time window & doesn't need to be duped */
-                buf_tmp = cur;
-                pv->cur = cur = hb_fifo_get( job->fifo_raw );
-                pv->next_pts = next->start;
-            }
-        }
-        else
+        /*
+         * Adjust the pts of the current frame so that it's contiguous
+         * with the previous frame. The start time of the current frame
+         * has to be the end time of the previous frame and the stop
+         * time has to be the start of the next frame.  We don't
+         * make any adjustments to the source timestamps other than removing
+         * the clock offsets (which also removes pts discontinuities).
+         * This means we automatically encode at the source's frame rate.
+         * MP2 uses an implicit duration (frames end when the next frame
+         * starts) but more advanced containers like MP4 use an explicit
+         * duration. Since we're looking ahead one frame we set the
+         * explicit stop time from the start time of the next frame.
+         */
+        buf_tmp = cur;
+        pv->cur = cur = hb_fifo_get( job->fifo_raw );
+        cur->sub = NULL;
+        pv->next_pts = cur->start;
+        int64_t duration = cur->start - pts_skip - buf_tmp->start;
+        pts_skip = 0;
+        if ( duration <= 0 )
         {
-            /*
-             * Adjust the pts of the current frame so that it's contiguous
-             * with the previous frame. The start time of the current frame
-             * has to be the end time of the previous frame and the stop
-             * time has to be the start of the next frame.  We don't
-             * make any adjustments to the source timestamps other than removing
-             * the clock offsets (which also removes pts discontinuities).
-             * This means we automatically encode at the source's frame rate.
-             * MP2 uses an implicit duration (frames end when the next frame
-             * starts) but more advanced containers like MP4 use an explicit
-             * duration. Since we're looking ahead one frame we set the
-             * explicit stop time from the start time of the next frame.
-             */
-            buf_tmp = cur;
-            pv->cur = cur = hb_fifo_get( job->fifo_raw );
-            pv->next_pts = cur->start;
-            duration = cur->start - buf_tmp->start;
-            if ( duration <= 0 )
-            {
-                hb_log( "sync: invalid video duration %lld, start %lld, next %lld",
-                        duration, buf_tmp->start, next->start );
-            }
+            hb_log( "sync: invalid video duration %"PRId64", start %"PRId64", next %"PRId64"",
+                    duration, buf_tmp->start, next->start );
         }
 
         buf_tmp->start = pv->next_start;
@@ -601,34 +720,20 @@ static void SyncVideo( hb_work_object_t * w )
             pv->chap_mark = 0;
         }
 
-        /* If we have a subtitle for this picture, copy it */
-        /* FIXME: we should avoid this memcpy */
-        if( sub )
-        {
-            buf_tmp->sub         = hb_buffer_init( sub->size );
-            buf_tmp->sub->x      = sub->x;
-            buf_tmp->sub->y      = sub->y;
-            buf_tmp->sub->width  = sub->width;
-            buf_tmp->sub->height = sub->height;
-            memcpy( buf_tmp->sub->data, sub->data, sub->size );
-        }
-
         /* Push the frame to the renderer */
         hb_fifo_push( job->fifo_sync, buf_tmp );
 
         /* Update UI */
         UpdateState( w );
-
-        /* Make sure we won't get more frames then expected */
-        if( pv->count_frames >= pv->count_frames_max * 2)
+        
+        if( job->frame_to_stop && pv->count_frames > job->frame_to_stop )
         {
-            hb_log( "sync: got too many frames (%d), exiting early",
-                    pv->count_frames );
-
             // Drop an empty buffer into our output to ensure that things
             // get flushed all the way out.
             hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) );
             pv->busy &=~ 1;
+            hb_log( "sync: reached %d frames, exiting early (%i busy)",
+                    pv->count_frames, pv->busy );
             return;
         }
     }
@@ -711,8 +816,10 @@ static void SyncAudio( hb_work_object_t * w, int i )
     hb_audio_t      * audio = sync->audio;
     hb_buffer_t     * buf;
     hb_fifo_t       * fifo;
+    int64_t start;
 
-    if( audio->config.out.codec == HB_ACODEC_AC3 )
+    if( audio->config.out.codec == HB_ACODEC_AC3 ||
+        audio->config.out.codec == HB_ACODEC_DCA )
     {
         fifo = audio->priv.fifo_out;
     }
@@ -723,6 +830,7 @@ static void SyncAudio( hb_work_object_t * w, int i )
 
     while( !hb_fifo_is_full( fifo ) && ( buf = hb_fifo_see( audio->priv.fifo_raw ) ) )
     {
+        start = buf->start - pv->audio_passthru_slip;
         /* if the next buffer is an eof send it downstream */
         if ( buf->size <= 0 )
         {
@@ -731,13 +839,19 @@ static void SyncAudio( hb_work_object_t * w, int i )
             pv->busy &=~ (1 << (i + 1) );
             return;
         }
-        if ( (int64_t)( buf->start - sync->next_pts ) < 0 )
+        if( job->frame_to_stop && pv->count_frames >= job->frame_to_stop )
+        {
+            hb_fifo_push( fifo, hb_buffer_init(0) );
+            pv->busy &=~ (1 << (i + 1) );
+            return;
+        }
+        if ( (int64_t)( start - sync->next_pts ) < 0 )
         {
             // audio time went backwards.
             // If our output clock is more than a half frame ahead of the
             // input clock drop this frame to move closer to sync.
             // Otherwise drop frames until the input clock matches the output clock.
-            if ( sync->first_drop || sync->next_start - buf->start > 90*15 )
+            if ( sync->first_drop || sync->next_start - start > 90*15 )
             {
                 // Discard data that's in the past.
                 if ( sync->first_drop == 0 )
@@ -749,30 +863,30 @@ static void SyncAudio( hb_work_object_t * w, int i )
                 hb_buffer_close( &buf );
                 continue;
             }
-            sync->next_pts = buf->start;
+            sync->next_pts = start;
         }
         if ( sync->first_drop )
         {
             // we were dropping old data but input buf time is now current
             hb_log( "sync: audio %d time went backwards %d ms, dropped %d frames "
-                    "(next %lld, current %lld)", i,
+                    "(next %"PRId64", current %"PRId64")", i,
                     (int)( sync->next_pts - sync->first_drop ) / 90,
                     sync->drop_count, sync->first_drop, sync->next_pts );
             sync->first_drop = 0;
             sync->drop_count = 0;
-            sync->next_pts = buf->start;
+            sync->next_pts = start;
         }
-        if ( buf->start - sync->next_pts >= (90 * 70) )
+        if ( start - sync->next_pts >= (90 * 70) )
         {
-            if ( buf->start - sync->next_pts > (90000LL * 60) )
+            if ( start - sync->next_pts > (90000LL * 60) )
             {
                 // there's a gap of more than a minute between the last
                 // frame and this. assume we got a corrupted timestamp
                 // and just drop the next buf.
                 hb_log( "sync: %d minute time gap in audio %d - dropping buf"
-                        "  start %lld, next %lld",
-                        (int)((buf->start - sync->next_pts) / (90000*60)),
-                        i, buf->start, sync->next_pts );
+                        "  start %"PRId64", next %"PRId64,
+                        (int)((start - sync->next_pts) / (90000*60)),
+                        i, start, sync->next_pts );
                 buf = hb_fifo_get( audio->priv.fifo_raw );
                 hb_buffer_close( &buf );
                 continue;
@@ -780,12 +894,24 @@ static void SyncAudio( hb_work_object_t * w, int i )
             /*
              * there's a gap of at least 70ms between the last
              * frame we processed & the next. Fill it with silence.
+             * Or in the case of DCA, skip some frames from the
+             * other streams.
              */
+            if( sync->audio->config.out.codec == HB_ACODEC_DCA )
+            {
+                hb_log( "sync: audio gap %d ms. Skipping frames. Audio %d"
+                        "  start %"PRId64", next %"PRId64,
+                        (int)((start - sync->next_pts) / 90),
+                        i, start, sync->next_pts );
+                pv->audio_passthru_slip += (start - sync->next_pts);
+                pv->video_pts_slip += (start - sync->next_pts);
+                return;
+            }
             hb_log( "sync: adding %d ms of silence to audio %d"
-                    "  start %lld, next %lld",
-                    (int)((buf->start - sync->next_pts) / 90),
-                    i, buf->start, sync->next_pts );
-            InsertSilence( w, i, buf->start - sync->next_pts );
+                    "  start %"PRId64", next %"PRId64,
+                    (int)((start - sync->next_pts) / 90),
+                    i, start, sync->next_pts );
+            InsertSilence( w, i, start - sync->next_pts );
             return;
         }
 
@@ -847,6 +973,8 @@ static void UpdateState( hb_work_object_t * w )
     if( !pv->count_frames )
     {
         pv->st_first = hb_get_date();
+        pv->job->st_pause_date = -1;
+        pv->job->st_paused = 0;
     }
     pv->count_frames++;
 
@@ -874,7 +1002,7 @@ static void UpdateState( hb_work_object_t * w )
     {
         int eta;
         p.rate_avg = 1000.0 * (float) pv->st_counts[3] /
-            (float) ( pv->st_dates[3] - pv->st_first );
+            (float) ( pv->st_dates[3] - pv->st_first - pv->job->st_paused);
         eta = (float) ( pv->count_frames_max - pv->st_counts[3] ) /
             p.rate_avg;
         p.hours   = eta / 3600;
index 599d82e..9f72523 100644 (file)
@@ -30,170 +30,55 @@ static void UpdateFunc( void * _data )
 {
 
     hb_update_t * data = (hb_update_t *) _data;
-       
-       char     * hb_query, * hb_query_two;
+
+    char* const url  = HB_PROJECT_URL_APPCAST;
+    char* const urlz = url + strlen( HB_PROJECT_URL_APPCAST ); /* marks null-term */
+    char        url_host[64];
+    char        url_path[128];
+    char        query[256];
+
        hb_net_t * net;
     int        ret;
     char       buf[4096];
     char     * cur, * end;
     int        size;
-    int        stable, unstable;
-    char       stable_str[16], unstable_str[16];
+    int        i_vers;
+    char       s_vers[32]; /* must be no larger than hb_handle_s.version */
     int        i;
-       
+
     /* Setup hb_query and hb_query_two with the correct appcast file */
-    if( HB_BUILD % 100 )
-    {  
-        hb_log("Using http://handbrake.fr/appcast_unstable.xml (primary)");
-        hb_log("Using http://handbrake.fr/appcast.xml (secondary)");
-    }
-       else 
-       {
-        hb_log("Using http://handbrake.fr/appcast.xml (primary)");
-        hb_log("Using http://handbrake.fr/appcast_unstable.xml (secondary)");
-    }
-       
-       hb_query = "GET /appcast.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
-    hb_query_two = "GET /appcast_unstable.xml HTTP/1.0\r\nHost: handbrake.fr\r\n\r\n";
+    hb_log( "Using %s", url );
 
-       /* Grab the data from the web server */
-    if( !( net = hb_net_open( "handbrake.fr", 80 ) ) )
-    {
+    /* extract host part */
+    cur = strstr( HB_PROJECT_URL_APPCAST, "//" );
+    if( !cur || cur+2 > urlz )
         goto error;
-    }
+    cur += 2;
 
-    if( hb_net_send( net, hb_query ) < 0 )
-    {
-        hb_log("Error: Unable to connect to server");
-        hb_net_close( &net );
+    end = strstr( cur, "/" );
+    if( !end || end > urlz )
         goto error;
-    }
 
-    size = 0;
-    memset( buf, 0, 4096 );
-    for( ;; )
-    {
-        ret = hb_net_recv( net, &buf[size], sizeof( buf ) - size );
-        if( ret < 1 )
-        {
-            hb_net_close( &net );
-            break;
-        }
-        size += ret;
-    }
+    memset( url_host, 0, sizeof(url_host) );
+    strncpy( url_host, cur, (end-cur) );
 
-    cur = buf;
-    end = &buf[sizeof( buf )];
-       
-    /* Make sure we got it */
-    cur += 9;
-    if( size < 15 || strncmp( cur, "200 OK", 6 ) )
-    {
-        hb_log("Error: We did not get a 200 OK from the server. \n");
+    /* extract path part */
+    memset( url_path, 0, sizeof(url_path) );
+    strncpy( url_path, end, (urlz-end) );
+
+    if( !strlen( url_path ))
         goto error;
-    }
-    cur += 6;
 
-    /* Find the end of the headers and the beginning of the content */
-    for( ; &cur[3] < end; cur++ )
-    {
-        if( cur[0] == '\r' && cur[1] == '\n' &&
-            cur[2] == '\r' && cur[3] == '\n' )
-        {
-            cur += 4;
-            break;
-        }
-    }
+    memset( query, 0, sizeof(query) );
+    snprintf( query, sizeof(query), "GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", url_path, url_host );
 
-    if( cur >= end )
-    {
-        hb_log("Error: Found the end of the buffer before the end of the HTTP header information! \n");
-        goto error;
-    }
-       
-    /*
-     * Find the <cli> tag
-     * Scan though each character of the buffer until we find that the first 4 characters of "cur" are "<cli"
-     */
-    for(i=0 ; &cur[3] < end; i++, cur++ )
-    {
-        if( cur[0] == 'c' && cur[1] == 'l' && cur[2] == 'i' && cur[3] == '>' )
-        {
-            cur += 1;
-            break;
-        }
-                
-        /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
-        if (( i > 768) || ( cur >= end ))
-               {
-            hb_log("Error: Did not find the <cli> tag in the expected maximum amount of characters into the file. \n");
-            goto error;
-               }
-    }
-        
-    if( cur >= end )
-    {
-        goto error;
-    }
-       
-    /*
-     * Ok, The above code didn't position cur, it only found <cli so we need to shift cur along 3 places.
-     * After which, the next 10 characters are the build number
-     */
-    cur += 3;
-       
-    if( cur >= end )
-    {
-        hb_log("Error: Unexpected end of buffer! Could not find the build information. \n");
-        goto error;
-    }
-       
-       /* Stable HB_BUILD */
-    stable = strtol( cur, &cur, 10 );
-               
-    if( cur >= end )
-    {
-     hb_log("Error: Unexpected end of buffer! \n");
-        goto error;
-    }
-       
-    /*
-     * The Version number is 2 places after the build, so shift cur, 2 places.
-     * Get all the characters in cur until the point where " is found.
-     */
-    cur += 2;
-       
-    if( cur >= end )
-    {
-        hb_log("Error: Unexpected end of buffer! Could not get version number. \n");
-        goto error;
-    }
-    memset( stable_str, 0, sizeof( stable_str ) );
-    for( i = 0;   i < sizeof( stable_str ) - 1 && cur < end && *cur != '"'; i++, cur++ )
-    {
-        stable_str[i] = *cur;
-               
-        /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
-        if (( i > 7) || ( cur >= end ))
-        {
-            hb_log("Error: Version number too long, or end of buffer reached. \n");
-            goto error;
-        }
-    }
-       
-    if( cur >= end )
-    {
-        goto error;
-    }
-       
-       /* HANDLE THE SECOND APPCAST FILE NOW */
     /* Grab the data from the web server */
-    if( !( net = hb_net_open( "handbrake.fr", 80 ) ) )
+    if( !( net = hb_net_open( url_host, 80 ) ) )
     {
         goto error;
     }
-       
-       if( hb_net_send( net, hb_query_two ) < 0 )
+
+    if( hb_net_send( net, query ) < 0 )
     {
         hb_log("Error: Unable to connect to server");
         hb_net_close( &net );
@@ -220,7 +105,6 @@ static void UpdateFunc( void * _data )
     cur += 9;
     if( size < 15 || strncmp( cur, "200 OK", 6 ) )
     {
-        /* Something went wrong */
         hb_log("Error: We did not get a 200 OK from the server. \n");
         goto error;
     }
@@ -255,7 +139,7 @@ static void UpdateFunc( void * _data )
             break;
         }
                 
-        // If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.
+        /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
         if (( i > 768) || ( cur >= end ))
                {
             hb_log("Error: Did not find the <cli> tag in the expected maximum amount of characters into the file. \n");
@@ -280,12 +164,12 @@ static void UpdateFunc( void * _data )
         goto error;
     }
        
-       /* UnStable HB_BUILD */
-    unstable = strtol( cur, &cur, 10 );
-               
+    /* Stable HB_PROJECT_BUILD */
+    i_vers = strtol( cur, &cur, 10 );
+
     if( cur >= end )
     {
-     hb_log("Error: Unexpected end of buffer! \n");
+        hb_log("Error: Unexpected end of buffer! \n");
         goto error;
     }
        
@@ -300,46 +184,32 @@ static void UpdateFunc( void * _data )
         hb_log("Error: Unexpected end of buffer! Could not get version number. \n");
         goto error;
     }
-    memset( unstable_str, 0, sizeof( unstable_str ) );
-    for( i = 0;   i < sizeof( unstable_str ) - 1 && cur < end && *cur != '"'; i++, cur++ )
+    memset( s_vers, 0, sizeof( s_vers ) );
+    for( i = 0;   i < sizeof( s_vers ) - 1 && cur < end && *cur != '"'; i++, cur++ )
     {
-        unstable_str[i] = *cur;
+        s_vers[i] = *cur;
                
-        // If the version number is longer than 7 characters, or the end is reached, something has gone wrong.
-        if (( i > 7) || ( cur >= end ))
+        /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
+        if (( cur >= end ))
         {
             hb_log("Error: Version number too long, or end of buffer reached. \n");
             goto error;
         }
     }
-       
+
     if( cur >= end )
     {
         goto error;
     }
-       
+
     /* Print the version information */
-    hb_log( "latest stable: %s, build %d", stable_str, stable );
-       hb_log( "latest unstable: %s, build %d", unstable_str, unstable );
-       
+    hb_log( "latest: %s, build %d", s_vers, i_vers );
+
     /* Return the build information */
-       if( HB_BUILD % 100 )
-    {
-        /* We are runnning an unstable build */
-        if( unstable > HB_BUILD )
-        {
-            memcpy( data->version, unstable_str, sizeof( unstable_str ) );
-            *(data->build) = unstable;
-        }
-    }
-    else
+    if( i_vers > HB_PROJECT_BUILD )
     {
-        /* We are runnning an stable build */
-        if( stable > HB_BUILD )
-        {
-            memcpy( data->version, stable_str, sizeof( stable_str ) );
-            *(data->build) = stable;
-        }
+        memcpy( data->version, s_vers, sizeof(s_vers) );
+        *(data->build) = i_vers;
     }
 
 error:
index 2538f41..2209b15 100644 (file)
@@ -7,6 +7,7 @@
 #include "hb.h"
 #include "a52dec/a52.h"
 #include "dca.h"
+#include "libavformat/avformat.h"
 
 typedef struct
 {
@@ -105,6 +106,7 @@ hb_work_object_t * hb_codec_encoder( int codec )
         case HB_ACODEC_FAAC:   return hb_get_work( WORK_ENCFAAC );
         case HB_ACODEC_LAME:   return hb_get_work( WORK_ENCLAME );
         case HB_ACODEC_VORBIS: return hb_get_work( WORK_ENCVORBIS );
+        case HB_ACODEC_CA_AAC:  return hb_get_work( WORK_ENC_CA_AAC );
     }
     return NULL;
 }
@@ -113,7 +115,7 @@ hb_work_object_t * hb_codec_encoder( int codec )
  * Displays job parameters in the debug log.
  * @param job Handle work hb_job_t.
  */
-hb_display_job_info( hb_job_t * job )
+void hb_display_job_info( hb_job_t * job )
 {
     hb_title_t * title = job->title;
     hb_audio_t   * audio;
@@ -185,31 +187,42 @@ hb_display_job_info( hb_job_t * job )
         hb_log( "     + bitrate %d kbps", title->video_bitrate / 1000 );
     }
     
-    if( job->vfr)
-    {
-        hb_log( "   + frame rate: %.3f fps -> variable fps",
-            (float) title->rate / (float) title->rate_base );
-    }
-    else if( !job->cfr )
+    if( !job->cfr )
     {
         hb_log( "   + frame rate: same as source (around %.3f fps)",
             (float) title->rate / (float) title->rate_base );
     }
     else
     {
-        hb_log( "   + frame rate: %.3f fps -> constant %.3f fps",
-            (float) title->rate / (float) title->rate_base, (float) job->vrate / (float) job->vrate_base );
+        static const char *frtypes[] = {
+            "", "constant", "peak rate limited to"
+        };
+        hb_log( "   + frame rate: %.3f fps -> %s %.3f fps",
+            (float) title->rate / (float) title->rate_base, frtypes[job->cfr],
+            (float) job->vrate / (float) job->vrate_base );
     }
 
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
-        hb_log( "   + %s anamorphic", job->pixel_ratio == 1 ? "strict" : "loose" );
+        hb_log( "   + %s anamorphic", job->anamorphic.mode == 1 ? "strict" : job->anamorphic.mode == 2? "loose" : "custom" );
+        if( job->anamorphic.mode == 3 && job->anamorphic.keep_display_aspect )
+        {
+            hb_log( "     + keeping source display aspect ratio"); 
+        }
+        if( job->anamorphic.modulus != 16 )
+        {
+            hb_log( "     + modulus: %i", job->anamorphic.modulus ); 
+        }
         hb_log( "     + storage dimensions: %d * %d -> %d * %d, crop %d/%d/%d/%d",
                     title->width, title->height, job->width, job->height,
                     job->crop[0], job->crop[1], job->crop[2], job->crop[3] );
-        hb_log( "     + pixel aspect ratio: %i / %i", job->pixel_aspect_width, job->pixel_aspect_height );
+        if( job->anamorphic.itu_par )
+        {
+            hb_log( "     + using ITU pixel aspect ratio values"); 
+        }
+        hb_log( "     + pixel aspect ratio: %i / %i", job->anamorphic.par_width, job->anamorphic.par_height );
         hb_log( "     + display dimensions: %.0f * %i",
-            (float)( job->width * job->pixel_aspect_width / job->pixel_aspect_height ), job->height );
+            (float)( job->width * job->anamorphic.par_width / job->anamorphic.par_height ), job->height );
     }
     else
     {
@@ -243,10 +256,6 @@ hb_display_job_info( hb_job_t * job )
                 hb_log( "   + encoder: FFmpeg" );
                 break;
 
-            case HB_VCODEC_XVID:
-                hb_log( "   + encoder: XviD" );
-                break;
-
             case HB_VCODEC_X264:
                 hb_log( "   + encoder: x264" );
                 if( job->x264opts != NULL && *job->x264opts != '\0' )
@@ -264,7 +273,7 @@ hb_display_job_info( hb_job_t * job )
         }
         else if( job->vquality > 1 )
         {
-            hb_log( "     + quality: %.0f %s", job->vquality, job->crf && job->vcodec == HB_VCODEC_X264 ? "(RF)" : "(QP)" ); 
+            hb_log( "     + quality: %.2f %s", job->vquality, job->vcodec == HB_VCODEC_X264 ? "(RF)" : "(QP)" ); 
         }
         else
         {
@@ -272,13 +281,18 @@ hb_display_job_info( hb_job_t * job )
         }
     }
 
-    for( i=0; i < hb_list_count(title->list_subtitle); i++ )
+    for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
     {
         subtitle =  hb_list_item( title->list_subtitle, i );
 
         if( subtitle )
         {
-            hb_log( " * subtitle track %i, %s (id %x)", job->subtitle+1, subtitle->lang, subtitle->id);
+            hb_log( " * subtitle track %i, %s (id %x) %s [%s] -> %s ", subtitle->track, subtitle->lang, subtitle->id,
+                    subtitle->format == PICTURESUB ? "Picture" : "Text",
+                    subtitle->source == VOBSUB ? "VOBSUB" : 
+                    ((subtitle->source == CC608SUB ||
+                      subtitle->source == CC708SUB) ? "CC" : "SRT"),
+                    subtitle->config.dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
         }
     }
 
@@ -311,7 +325,7 @@ hb_display_job_info( hb_job_t * job )
                 }
             }
 
-            if ( audio->config.out.dynamic_range_compression > 1 && (audio->config.out.codec != HB_ACODEC_AC3) && (audio->config.out.codec != HB_ACODEC_DCA))
+            if ( audio->config.out.dynamic_range_compression && (audio->config.out.codec != HB_ACODEC_AC3) && (audio->config.out.codec != HB_ACODEC_DCA))
             {
                 hb_log("   + dynamic range compression: %f", audio->config.out.dynamic_range_compression);
             }
@@ -324,14 +338,35 @@ hb_display_job_info( hb_job_t * job )
             else
             {
                 hb_log( "   + encoder: %s", ( audio->config.out.codec == HB_ACODEC_FAAC ) ?
-                    "faac" : ( ( audio->config.out.codec == HB_ACODEC_LAME ) ? "lame" :
-                    "vorbis" ) );
+                    "faac" : ( ( audio->config.out.codec == HB_ACODEC_LAME ) ?
+                    "lame" : ( ( audio->config.out.codec == HB_ACODEC_CA_AAC ) ?
+                              "ca_aac" : "vorbis"  ) ) );
                 hb_log( "     + bitrate: %d kbps, samplerate: %d Hz", audio->config.out.bitrate, audio->config.out.samplerate );            
             }
         }
     }
 }
 
+/* Corrects framerates when actual duration and frame count numbers are known. */
+void correct_framerate( hb_job_t * job )
+{
+    int real_frames;
+
+    hb_interjob_t * interjob = hb_interjob_get( job->h );
+
+    if( ( job->sequence_id & 0xFFFFFF ) != ( interjob->last_job & 0xFFFFFF) )
+        return; // Interjob information is for a different encode.
+
+    /* Cache the original framerate before altering it. */
+    interjob->vrate = job->vrate;
+    interjob->vrate_base = job->vrate_base;
+
+    real_frames = interjob->frame_count - interjob->render_dropped;
+
+    job->vrate = job->vrate_base * ( (double)real_frames * 90000 / interjob->total_time );
+}
+
+
 /**
  * Job initialization rountine.
  * Initializes fifos.
@@ -348,6 +383,7 @@ static void do_job( hb_job_t * job, int cpu_count )
     hb_title_t    * title;
     int             i, j;
     hb_work_object_t * w;
+    hb_interjob_t * interjob;
 
     hb_audio_t   * audio;
     hb_subtitle_t * subtitle;
@@ -359,50 +395,47 @@ static void do_job( hb_job_t * job, int cpu_count )
     unsigned int subtitle_hit = 0;
 
     title = job->title;
+    interjob = hb_interjob_get( job->h );
+
+    if( job->pass == 2 && !job->cfr )
+    {
+        correct_framerate( job );
+    }
 
     job->list_work = hb_list_init();
 
     hb_log( "starting job" );
 
-    if ( job->pixel_ratio == 1 )
-    {
-       /* Correct the geometry of the output movie when using PixelRatio */
-       job->height=title->height-job->crop[0]-job->crop[1];
-       job->width=title->width-job->crop[2]-job->crop[3];
-    }
-    else if ( job->pixel_ratio == 2 )
+    if( job->anamorphic.mode )
     {
+        hb_set_anamorphic_size(job, &job->width, &job->height, &job->anamorphic.par_width, &job->anamorphic.par_height);
 
-        /* While keeping the DVD storage aspect, resize the job width and height
-           so they fit into the user's specified dimensions. */
-        hb_set_anamorphic_size(job, &job->width, &job->height, &job->pixel_aspect_width, &job->pixel_aspect_height);
-    }
-
-    if( job->pixel_ratio && job->vcodec == HB_VCODEC_FFMPEG)
-    {
-        /* Just to make working with ffmpeg even more fun,
-           lavc's MPEG-4 encoder can't handle PAR values >= 255,
-           even though AVRational does. Adjusting downwards
-           distorts the display aspect slightly, but such is life. */
-        while ((job->pixel_aspect_width & ~0xFF) ||
-               (job->pixel_aspect_height & ~0xFF))
+        if( job->vcodec == HB_VCODEC_FFMPEG )
         {
-            job->pixel_aspect_width >>= 1;
-            job->pixel_aspect_height >>= 1;
+            /* Just to make working with ffmpeg even more fun,
+               lavc's MPEG-4 encoder can't handle PAR values >= 255,
+               even though AVRational does. Adjusting downwards
+               distorts the display aspect slightly, but such is life. */
+            while ((job->anamorphic.par_width & ~0xFF) ||
+                   (job->anamorphic.par_height & ~0xFF))
+            {
+                job->anamorphic.par_width >>= 1;
+                job->anamorphic.par_height >>= 1;
+            }
         }
     }
-
+    
     /* Keep width and height within these boundaries,
        but ignore for anamorphic. For "loose" anamorphic encodes,
        this stuff is covered in the pixel_ratio section above.    */
-    if ( job->maxHeight && ( job->height > job->maxHeight ) && ( !job->pixel_ratio ) )
+    if ( job->maxHeight && ( job->height > job->maxHeight ) && ( !job->anamorphic.mode ) )
     {
         job->height = job->maxHeight;
         hb_fix_aspect( job, HB_KEEP_HEIGHT );
         hb_log( "Height out of bounds, scaling down to %i", job->maxHeight );
         hb_log( "New dimensions %i * %i", job->width, job->height );
     }
-    if ( job->maxWidth && ( job->width > job->maxWidth ) && ( !job->pixel_ratio ) )
+    if ( job->maxWidth && ( job->width > job->maxWidth ) && ( !job->anamorphic.mode ) )
     {
         job->width = job->maxWidth;
         hb_fix_aspect( job, HB_KEEP_WIDTH );
@@ -410,16 +443,19 @@ static void do_job( hb_job_t * job, int cpu_count )
         hb_log( "New dimensions %i * %i", job->width, job->height );
     }
 
-    if( ( job->mux & HB_MUX_AVI ) || job->cfr )
+    if( job->mux & HB_MUX_AVI )
     {
-        /* VFR detelecine is not compatible with AVI or constant frame rates. */
-        job->vfr = 0;
+        // The concept of variable frame rate video was a bit too advanced
+        // for Microsoft so AVI doesn't support it. Since almost all dvd
+        // video is VFR we have to convert it to constant frame rate to
+        // put it in an AVI container. So duplicate, drop and
+        // otherwise trash video frames to appease the gods of Redmond.
+        job->cfr = 1;
     }
 
-    if ( job->vfr )
+    if ( job->cfr == 0 )
     {
-        /* Ensure we're using "Same as source" FPS,
-           aka VFR, if we're doing VFR detelecine. */
+        /* Ensure we're using "Same as source" FPS */
         job->vrate_base = title->rate_base;
     }
 
@@ -455,9 +491,6 @@ static void do_job( hb_job_t * job, int cpu_count )
         case HB_VCODEC_FFMPEG:
             w = hb_get_work( WORK_ENCAVCODEC );
             break;
-        case HB_VCODEC_XVID:
-            w = hb_get_work( WORK_ENCXVID );
-            break;
         case HB_VCODEC_X264:
             w = hb_get_work( WORK_ENCX264 );
             break;
@@ -472,51 +505,112 @@ static void do_job( hb_job_t * job, int cpu_count )
         hb_list_add( job->list_work, w );
     }
 
-    if( job->select_subtitle && !job->indepth_scan )
+    /*
+     * Look for the scanned subtitle in the existing subtitle list
+     */
+    if ( !job->indepth_scan && interjob->select_subtitle &&
+         ( job->pass == 0 || job->pass == 2 ) )
     {
         /*
-         * Must be second pass of a two pass with subtitle scan enabled, so
-         * add the subtitle that we found on the first pass for use in this
-         * pass.
+         * Disable forced subtitles if we didn't find any in the scan
+         * so that we display normal subtitles instead.
+         *
+         * select_subtitle implies that we did a scan.
          */
-        if (*(job->select_subtitle))
+        if( interjob->select_subtitle->config.force && 
+            interjob->select_subtitle->forced_hits == 0 )
+        {
+            interjob->select_subtitle->config.force = 0;
+        }
+        for( i=0; i < hb_list_count(title->list_subtitle); i++ )
+        {
+            subtitle =  hb_list_item( title->list_subtitle, i );
+
+            if( subtitle )
+            {
+                /*
+                * Disable forced subtitles if we didn't find any in the scan
+                * so that we display normal subtitles instead.
+                *
+                * select_subtitle implies that we did a scan.
+                */
+                if( interjob->select_subtitle->id == subtitle->id )
+                {
+                    *subtitle = *(interjob->select_subtitle);
+                    free( interjob->select_subtitle );
+                    interjob->select_subtitle = NULL;
+                }
+            }
+        }
+
+        if( interjob->select_subtitle )
         {
-            hb_list_add( title->list_subtitle, *( job->select_subtitle ) );
+            /*
+             * Its not in the existing list
+             *
+             * Must be second pass of a two pass with subtitle scan enabled, so
+             * add the subtitle that we found on the first pass for use in this
+             * pass.
+             */
+            hb_list_add( title->list_subtitle, interjob->select_subtitle );
+            interjob->select_subtitle = NULL;
         }
     }
 
+
     for( i=0; i < hb_list_count(title->list_subtitle); i++ )
     {
         subtitle =  hb_list_item( title->list_subtitle, i );
 
         if( subtitle )
         {
-            subtitle->fifo_in  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
-            subtitle->fifo_raw = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
-
-            /*
-             * Disable forced subtitles if we didn't find any in the scan
-             * so that we display normal subtitles instead.
-             *
-             * select_subtitle implies that we did a scan.
-             */
-            if( !job->indepth_scan && job->subtitle_force &&
-                job->select_subtitle )
-            {
-                if( subtitle->forced_hits == 0 )
-                {
-                    job->subtitle_force = 0;
-                }
-            }
+            subtitle->fifo_in   = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
+            subtitle->fifo_raw  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
+            subtitle->fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
+            subtitle->fifo_out  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
 
-            if (!job->indepth_scan || job->subtitle_force) {
+            if( (!job->indepth_scan || job->select_subtitle_config.force) && 
+                subtitle->source == VOBSUB ) {
                 /*
                  * Don't add threads for subtitles when we are scanning, unless
                  * looking for forced subtitles.
                  */
-                w = hb_get_work( WORK_DECSUB );
+                w = hb_get_work( WORK_DECVOBSUB );
+                w->fifo_in  = subtitle->fifo_in;
+                w->fifo_out = subtitle->fifo_raw;
+                w->subtitle = subtitle;
+                hb_list_add( job->list_work, w );
+            }
+
+            if( !job->indepth_scan && subtitle->source == CC608SUB )
+            {
+                w = hb_get_work( WORK_DECCC608 );
+                w->fifo_in  = subtitle->fifo_in;
+                w->fifo_out = subtitle->fifo_raw;
+                hb_list_add( job->list_work, w );
+            }
+
+            if( !job->indepth_scan && subtitle->source == SRTSUB )
+            {
+                w = hb_get_work( WORK_DECSRTSUB );
                 w->fifo_in  = subtitle->fifo_in;
                 w->fifo_out = subtitle->fifo_raw;
+                w->subtitle = subtitle;
+                hb_list_add( job->list_work, w );
+            }
+
+            if( !job->indepth_scan && 
+                subtitle->format == PICTURESUB
+                && subtitle->config.dest == PASSTHRUSUB )
+            {
+                /*
+                 * Passing through a subtitle picture, this will have to
+                 * be rle encoded before muxing.
+                 */
+                w = hb_get_work( WORK_ENCVOBSUB );
+                w->fifo_in  = subtitle->fifo_sync;
+                w->fifo_out = subtitle->fifo_out;
+                w->subtitle = subtitle;
                 hb_list_add( job->list_work, w );
             }
         }
@@ -524,9 +618,14 @@ static void do_job( hb_job_t * job, int cpu_count )
 
     if( !job->indepth_scan )
     {
-    /* if we are doing passthru, and the input codec is not the same as the output
-     * codec, then remove this audio from the job */
-    /* otherwise, Bad Things will happen */
+    // if we are doing passthru, and the input codec is not the same as the output
+    // codec, then remove this audio from the job. If we're not doing passthru and
+    // the input codec is the 'internal' ffmpeg codec, make sure that only one
+    // audio references that audio stream since the codec context is specific to
+    // the audio id & multiple copies of the same stream will garble the audio
+    // or cause aborts.
+    uint8_t aud_id_uses[MAX_STREAMS];
+    memset( aud_id_uses, 0, sizeof(aud_id_uses) );
     for( i = 0; i < hb_list_count( title->list_audio ); )
     {
         audio = hb_list_item( title->list_audio, i );
@@ -539,6 +638,18 @@ static void do_job( hb_job_t * job, int cpu_count )
             free( audio );
             continue;
         }
+        if ( audio->config.in.codec == HB_ACODEC_FFMPEG )
+        {
+            if ( aud_id_uses[audio->id] )
+            {
+                hb_log( "Multiple decodes of audio id %d, removing track %d",
+                        audio->id, audio->config.out.track );
+                hb_list_rem( title->list_audio, audio );
+                free( audio );
+                continue;
+            }
+            ++aud_id_uses[audio->id];
+        }
         /* Adjust output track number, in case we removed one.
          * Output tracks sadly still need to be in sequential order.
          */
@@ -567,7 +678,8 @@ static void do_job( hb_job_t * job, int cpu_count )
             /* sense-check the requested mixdown */
 
             if( audio->config.out.mixdown == 0 &&
-                audio->config.out.codec != HB_ACODEC_AC3 )
+                audio->config.out.codec != HB_ACODEC_AC3 && 
+                audio->config.out.codec != HB_ACODEC_DCA )
             {
                 /*
                  * Mixdown wasn't specified and this is not pass-through,
@@ -710,7 +822,7 @@ static void do_job( hb_job_t * job, int cpu_count )
         audio->priv.fifo_in   = hb_fifo_init( 32 );
         audio->priv.fifo_raw  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
         audio->priv.fifo_sync = hb_fifo_init( 32 );
-        audio->priv.fifo_out  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
+        audio->priv.fifo_out  = hb_fifo_init( 8 * FIFO_CPU_MULT * cpu_count );
 
 
         /*
@@ -733,7 +845,8 @@ static void do_job( hb_job_t * job, int cpu_count )
         /*
          * Audio Encoder Thread
          */
-        if( audio->config.out.codec != HB_ACODEC_AC3 )
+        if( audio->config.out.codec != HB_ACODEC_AC3 &&
+            audio->config.out.codec != HB_ACODEC_DCA )
         {
             /*
              * Add the encoder thread if not doing AC-3 pass through
@@ -844,6 +957,8 @@ cleanup:
         {
             hb_fifo_close( &subtitle->fifo_in );
             hb_fifo_close( &subtitle->fifo_raw );
+            hb_fifo_close( &subtitle->fifo_sync );
+            hb_fifo_close( &subtitle->fifo_out );
         }
     }
     for( i = 0; i < hb_list_count( title->list_audio ); i++ )
@@ -868,9 +983,14 @@ cleanup:
         for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
         {
             subtitle =  hb_list_item( title->list_subtitle, i );
+
             hb_log( "Subtitle stream 0x%x '%s': %d hits (%d forced)",
                     subtitle->id, subtitle->lang, subtitle->hits,
                     subtitle->forced_hits );
+
+            if( subtitle->hits == 0 )
+                continue;
+
             if( subtitle->hits > subtitle_highest )
             {
                 subtitle_highest = subtitle->hits;
@@ -892,67 +1012,48 @@ cleanup:
             }
         }
 
-        if( job->native_language ) {
+        
+        if( subtitle_forced_id )
+        {
             /*
-             * We still have a native_language, so the audio and subtitles are
-             * different, so in this case it is a foreign film and we want to
-             * select the subtitle with the highest hits in our language.
+             * If there are any subtitle streams with forced subtitles
+             * then select it in preference to the lowest.
              */
-            subtitle_hit = subtitle_highest_id;
-            hb_log( "Found a native-language subtitle id 0x%x", subtitle_hit);
-        } else {
-            if( subtitle_forced_id )
-            {
-                /*
-                 * If there are any subtitle streams with forced subtitles
-                 * then select it in preference to the lowest.
-                 */
-                subtitle_hit = subtitle_forced_id;
-                hb_log("Found a subtitle candidate id 0x%x (contains forced subs)",
-                       subtitle_hit);
-            } else if( subtitle_lowest < subtitle_highest )
+            subtitle_hit = subtitle_forced_id;
+            hb_log("Found a subtitle candidate id 0x%x (contains forced subs)",
+                   subtitle_hit);
+        } else if( subtitle_lowest < subtitle_highest )
+        {
+            /*
+             * OK we have more than one, and the lowest is lower,
+             * but how much lower to qualify for turning it on by
+             * default?
+             *
+             * Let's say 10% as a default.
+             */
+            if( subtitle_lowest < ( subtitle_highest * 0.1 ) )
             {
-                /*
-                 * OK we have more than one, and the lowest is lower,
-                 * but how much lower to qualify for turning it on by
-                 * default?
-                 *
-                 * Let's say 10% as a default.
-                 */
-                if( subtitle_lowest < ( subtitle_highest * 0.1 ) )
-                {
-                    subtitle_hit = subtitle_lowest_id;
-                    hb_log( "Found a subtitle candidate id 0x%x",
-                            subtitle_hit );
-                } else {
-                    hb_log( "No candidate subtitle detected during subtitle-scan");
-                }
+                subtitle_hit = subtitle_lowest_id;
+                hb_log( "Found a subtitle candidate id 0x%x",
+                        subtitle_hit );
+            } else {
+                hb_log( "No candidate subtitle detected during subtitle-scan");
             }
         }
     }
 
-    if( job->select_subtitle )
+    if( job->indepth_scan )
     {
-        if( job->indepth_scan )
+        for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
         {
-            for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
+            subtitle =  hb_list_item( title->list_subtitle, i );
+            if( subtitle->id == subtitle_hit )
             {
-                subtitle =  hb_list_item( title->list_subtitle, i );
-                if( subtitle->id == subtitle_hit )
-                {
-                    hb_list_rem( title->list_subtitle, subtitle );
-                    *( job->select_subtitle ) = subtitle;
-                }
+                subtitle->config = job->select_subtitle_config;
+                hb_list_rem( title->list_subtitle, subtitle );
+                interjob->select_subtitle = subtitle;
+                break;
             }
-        } else {
-            /*
-             * Must be the end of pass 0 or 2 - we don't need this anymore.
-             *
-             * Have to put the subtitle list back together in the title though
-             * or the GUI will have a hissy fit.
-             */
-            free( job->select_subtitle );
-            job->select_subtitle = NULL;
         }
     }
 
index e8071b5..94d06c8 100644 (file)
 
 - (id)tableView:(NSTableView *)aTableView
       objectValueForTableColumn:(NSTableColumn *)aTableColumn
-      row:(int)rowIndex;
+      row:(NSInteger)rowIndex;
       
 - (void)tableView:(NSTableView *)aTableView
         setObjectValue:(id)anObject
         forTableColumn:(NSTableColumn *)aTableColumn
-        row:(int)rowIndex;
+        row:(NSInteger)rowIndex;
 @end
index 0ad5651..893c2dc 100644 (file)
@@ -61,7 +61,7 @@
 - (void)tableView:(NSTableView *)aTableView
         setObjectValue:(id)anObject
         forTableColumn:(NSTableColumn *)aTableColumn
-        row:(int)rowIndex
+        row:(NSInteger)rowIndex
 {
     if(aTableColumn != nil && [[aTableColumn identifier] intValue] == 2)
     {
@@ -80,7 +80,7 @@
 
 - (id)tableView:(NSTableView *)aTableView
       objectValueForTableColumn:(NSTableColumn *)aTableColumn
-      row:(int)rowIndex
+      row:(NSInteger)rowIndex
 {
     NSString *cellEntry =  @"__DATA ERROR__";
 
@@ -111,11 +111,11 @@ a timer to avoid interfering with the chain of events that handles the edit. */
     NSTableView *chapterTable = [notification object];
     NSInteger column = [chapterTable editedColumn];
     NSInteger row = [chapterTable editedRow];
-    int textMovement;
+    NSInteger textMovement;
 
     // Edit the cell in the next row, same column
     row++;
-    textMovement = [[[notification userInfo] objectForKey:@"NSTextMovement"] intValue];
+    textMovement = [[[notification userInfo] objectForKey:@"NSTextMovement"] integerValue];
     if( textMovement == NSReturnTextMovement && row < [chapterTable numberOfRows] )
     {
         NSArray *info = [NSArray arrayWithObjects:chapterTable,
index 3625efd..07a0272 100644 (file)
 #include "hb.h"
 
 #import "ChapterTitles.h"
+#import "HBSubtitles.h"
 #import "PictureController.h"
+#import "HBPreviewController.h"
 #import "HBQueueController.h"
 #import "HBAdvancedController.h"
 #import "HBPreferencesController.h"
 #import "HBPresets.h"
+
 @class HBOutputPanelController;
 
 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
@@ -25,8 +28,10 @@ BOOL                        fIsDragging;
 
 }
 @end
+
 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
 {
+    NSImage                      * fApplicationIcon;
     IBOutlet NSWindow            * fWindow;
 
     /* Main Menu Outlets */
@@ -39,10 +44,14 @@ BOOL                        fIsDragging;
     IBOutlet NSTextField          * fScanSrcTitleNumField;
     IBOutlet NSButton             * fScanSrcTitleCancelButton;
     IBOutlet NSButton             * fScanSrcTitleOpenButton;
+
     
-    /* Picture panel */
+    /* Picture Settings */
     PictureController            * fPictureController;
     
+    /* Picture Preview */
+    PreviewController            * fPreviewController;
+    
     /* Advanced options tab */
     HBAdvancedController         * fAdvancedOptions;
        IBOutlet NSBox               * fAdvancedView;
@@ -62,6 +71,12 @@ BOOL                        fIsDragging;
     IBOutlet NSTextField         * fSrcDVD2Field;
     IBOutlet NSTextField         * fSrcTitleField;
     IBOutlet NSPopUpButton       * fSrcTitlePopUp;
+    
+    
+    /* lib dvd nav specific */
+    IBOutlet NSTextField         * fSrcAngleLabel;
+    IBOutlet NSPopUpButton       * fSrcAnglePopUp;
+    
     IBOutlet NSTextField         * fSrcChapterField;
     IBOutlet NSPopUpButton       * fSrcChapterStartPopUp;
     IBOutlet NSTextField         * fSrcChapterToField;
@@ -90,6 +105,8 @@ BOOL                        fIsDragging;
     IBOutlet NSTextField         * fVidEncoderField;
     IBOutlet NSPopUpButton       * fVidEncoderPopUp;
     IBOutlet NSTextField         * fVidQualityField;
+    IBOutlet NSTextField         * fVidQualityRFLabel;
+    IBOutlet NSTextField         * fVidQualityRFField;
     IBOutlet NSMatrix            * fVidQualityMatrix;
     IBOutlet NSButtonCell        * fVidTargetCell;
     IBOutlet NSTextField         * fVidTargetSizeField;
@@ -97,34 +114,15 @@ BOOL                        fIsDragging;
     IBOutlet NSTextField         * fVidBitrateField;
     IBOutlet NSButtonCell        * fVidConstantCell;
     IBOutlet NSSlider            * fVidQualitySlider;
-    IBOutlet NSButton            * fVidGrayscaleCheck;
     IBOutlet NSButton            * fVidTwoPassCheck;
     IBOutlet NSButton            * fVidTurboPassCheck;
        
-       /* Picture Settings box */
-       IBOutlet NSTextField         * fPicLabelSettings;
-       IBOutlet NSTextField         * fPicLabelSrc;
-    IBOutlet NSTextField         * fPicSettingsSrc;
-       IBOutlet NSTextField         * fPicLabelOutp;
-    IBOutlet NSTextField         * fPicSettingsOutp;
-    IBOutlet NSTextField         * fPicLabelAnamorphic;
-    IBOutlet NSTextField         * fPicSettingsAnamorphic;
-    
-    IBOutlet NSTextField         * fPicLabelAr;
-       IBOutlet NSTextField         * fPicLabelAutoCrop;
-    IBOutlet NSTextField         * fPicLabelDetelecine;
-       IBOutlet NSTextField         * fPicLabelDeinterlace;
-    IBOutlet NSTextField         * fPicLabelDecomb;
-    IBOutlet NSTextField         * fPicLabelDenoise;
-    IBOutlet NSTextField         * fPicLabelDeblock;
-       IBOutlet NSTextField         * fPicSettingDeinterlace;
-    IBOutlet NSTextField         * fPicSettingDecomb;
-       IBOutlet NSTextField         * fPicSettingARkeep;
-       IBOutlet NSTextField         * fPicSettingPAR;
-       IBOutlet NSTextField         * fPicSettingAutoCrop;
-       IBOutlet NSTextField         * fPicSettingDetelecine;
-       IBOutlet NSTextField         * fPicSettingDenoise;
-    IBOutlet NSTextField         * fPicSettingDeblock;
+       /* Status read out fileds for picture sizing */
+    IBOutlet NSTextField         * fPictureSizeField;
+    IBOutlet NSTextField         * fPictureCroppingField;
+       
+    /* Status read out fileds for video filters */
+    IBOutlet NSTextField         * fVideoFiltersField;
        
        /* Picture variables */
        int                        PicOrigOutputWidth;
@@ -137,6 +135,12 @@ BOOL                        fIsDragging;
     IBOutlet NSTextField         * fSubField;
     IBOutlet NSPopUpButton       * fSubPopUp;
        IBOutlet NSButton            * fSubForcedCheck;
+    
+    
+    IBOutlet NSTableView         * fSubtitlesTable;
+       HBSubtitles                  * fSubtitlesDelegate;
+    IBOutlet NSButton            * fBrowseSrtFileButton;
+    
        
     /* Audio box */
     /* Track Labels */
@@ -198,7 +202,6 @@ BOOL                        fIsDragging;
        ChapterTitles                * fChapterTitlesDelegate;
        
     /* Bottom */
-    IBOutlet NSButton            * fPictureButton;
     IBOutlet NSTextField         * fStatusField;
     IBOutlet NSProgressIndicator * fRipIndicator;
        BOOL                           fRipIndicatorShown;
@@ -231,7 +234,8 @@ BOOL                        fIsDragging;
     NSMutableDictionary          *presetUserDefaultParentParent;
     int                        presetCurrentBuiltInCount; // keeps track of the current number of built in presets
     IBOutlet NSPanel             * fAddPresetPanel;
-       /* new NSOutline View for the presets */
+       
+    /* NSOutline View for the presets */
     NSArray                      *fDraggedNodes;
     IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
     IBOutlet NSButton            * fPresetsAdd;
@@ -240,6 +244,7 @@ BOOL                        fIsDragging;
 
     hb_handle_t                  * fHandle;
     
+    /* Queue variables */
     hb_handle_t              * fQueueEncodeLibhb;           // libhb for HB Encoding
        hb_title_t                   * fTitle;
     hb_title_t                   * fQueueEncodeTitle;
@@ -259,8 +264,13 @@ BOOL                        fIsDragging;
     BOOL                           applyQueueToScan;
        NSString                      * currentSource;
     NSString                     * browsedSourceDisplayName;
+    
+    double                         dockIconProgress;
 }
-- (void) writeToActivityLog:(char *) format, ...;
+
+- (IBAction) showAboutPanel:(id)sender;
+
+- (void) writeToActivityLog:(const char *) format, ...;
 - (IBAction) browseSources: (id) sender;
 - (void) browseSourcesDone: (NSOpenPanel *) sheet
                 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
@@ -288,17 +298,26 @@ BOOL                        fIsDragging;
 - (IBAction) audioTrackPopUpChanged: (id) sender;
 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
 - (IBAction) audioTrackMixdownChanged: (id) sender;
-- (IBAction) subtitleSelectionChanged: (id) sender;
 - (void) prepareJob;
 - (IBAction) browseFile: (id) sender;
 - (void)     browseFileDone: (NSSavePanel *) sheet
                  returnCode: (int) returnCode contextInfo: (void *) contextInfo;
 
 - (IBAction) videoMatrixChanged: (id) sender;
+
 - (IBAction) qualitySliderChanged: (id) sender;
+- (void) setupQualitySlider;
+
 - (IBAction) audioDRCSliderChanged: (id) sender;
+- (IBAction) browseImportSrtFile: (id) sender;
+- (void) browseImportSrtFileDone: (NSSavePanel *) sheet
+                     returnCode: (int) returnCode contextInfo: (void *) contextInfo;
 
 - (IBAction) showPicturePanel: (id) sender;
+- (void) picturePanelFullScreen;
+- (void) picturePanelWindowed;
+- (IBAction) showPreviewWindow: (id) sender;
+- (void)pictureSettingsDidChange;
 - (IBAction) calculatePictureSizing: (id) sender;
 - (IBAction) openMainWindow: (id) sender;
 
@@ -313,7 +332,7 @@ BOOL                        fIsDragging;
 - (IBAction)applyQueueSettings:(id)sender;
 - (void) removeQueueFileItem:(int) queueItemToRemove;
 - (void) clearQueueAllItems;
-- (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
+- (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
 - (void)getQueueStats;
 - (void)setQueueEncodingItemsAsPending;
 - (IBAction) addToQueue: (id) sender;
@@ -359,10 +378,19 @@ BOOL                        fIsDragging;
 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
 /* We use this to provide tooltips for the items in the presets outline view */
 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
-
+- (void) checkBuiltInsForUpdates;
 /* We use this to actually select the preset and act accordingly */
 - (IBAction)selectPreset:(id)sender;    
 
+/* Export / Import Presets */
+- (IBAction) browseExportPresetFile: (id) sender;
+- (void) browseExportPresetFileDone: (NSSavePanel *) sheet
+             returnCode: (int) returnCode contextInfo: (void *) contextInfo;
+             
+- (IBAction) browseImportPresetFile: (id) sender;
+- (void) browseImportPresetDone: (NSSavePanel *) sheet
+                   returnCode: (int) returnCode contextInfo: (void *) contextInfo;
+
 /* Manage User presets */    
 - (void) loadPresets;
 - (IBAction) customSettingUsed: (id) sender;
@@ -391,9 +419,15 @@ BOOL                        fIsDragging;
 - (IBAction)showDebugOutputPanel:(id)sender;
 - (void)setupToolbar;
 
-
+- (void) prepareJobForPreview;
 - (void) remindUserOfSleepOrShutdown;
 
-- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex;
+- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
+
+- (int) hbInstances;
+
+
+
+
 @end
 
diff --git a/macosx/Controller.m b/macosx/Controller.m
new file mode 100644 (file)
index 0000000..7960b2d
--- /dev/null
@@ -0,0 +1,7636 @@
+/* $Id: Controller.mm,v 1.79 2005/11/04 19:41:32 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#import "Controller.h"
+#import "HBOutputPanelController.h"
+#import "HBPreferencesController.h"
+#import "HBDVDDetector.h"
+#import "HBPresets.h"
+#import "HBPreviewController.h"
+
+#define DragDropSimplePboardType       @"MyCustomOutlineViewPboardType"
+
+/* We setup the toolbar values here ShowPreviewIdentifier */
+static NSString *        ToggleDrawerIdentifier             = @"Toggle Drawer Item Identifier";
+static NSString *        StartEncodingIdentifier            = @"Start Encoding Item Identifier";
+static NSString *        PauseEncodingIdentifier            = @"Pause Encoding Item Identifier";
+static NSString *        ShowQueueIdentifier                = @"Show Queue Item Identifier";
+static NSString *        AddToQueueIdentifier               = @"Add to Queue Item Identifier";
+static NSString *        ShowPictureIdentifier             = @"Show Picture Window Item Identifier";
+static NSString *        ShowPreviewIdentifier             = @"Show Preview Window Item Identifier";
+static NSString *        ShowActivityIdentifier             = @"Debug Output Item Identifier";
+static NSString *        ChooseSourceIdentifier             = @"Choose Source Item Identifier";
+
+
+/*******************************
+ * HBController implementation *
+ *******************************/
+@implementation HBController
+
+- (id)init
+{
+    self = [super init];
+    if( !self )
+    {
+        return nil;
+    }
+
+    /* replace bundled app icon with one which is 32/64-bit savvy */
+#if defined( __LP64__ )
+    fApplicationIcon = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"HandBrake-64.icns"]];
+#else
+    fApplicationIcon = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"HandBrake.icns"]];
+#endif
+    if( fApplicationIcon != nil )
+        [NSApp setApplicationIconImage:fApplicationIcon];
+    
+    [HBPreferencesController registerUserDefaults];
+    fHandle = NULL;
+    fQueueEncodeLibhb = NULL;
+    /* Check for check for the app support directory here as
+     * outputPanel needs it right away, as may other future methods
+     */
+    NSString *libraryDir = [NSSearchPathForDirectoriesInDomains( NSLibraryDirectory,
+                                                                NSUserDomainMask,
+                                                                YES ) objectAtIndex:0];
+    AppSupportDirectory = [[libraryDir stringByAppendingPathComponent:@"Application Support"]
+                           stringByAppendingPathComponent:@"HandBrake"];
+    if( ![[NSFileManager defaultManager] fileExistsAtPath:AppSupportDirectory] )
+    {
+        [[NSFileManager defaultManager] createDirectoryAtPath:AppSupportDirectory
+                                                   attributes:nil];
+    }
+    /* Check for and create the App Support Preview directory if necessary */
+    NSString *PreviewDirectory = [AppSupportDirectory stringByAppendingPathComponent:@"Previews"];
+    if( ![[NSFileManager defaultManager] fileExistsAtPath:PreviewDirectory] )
+    {
+        [[NSFileManager defaultManager] createDirectoryAtPath:PreviewDirectory
+                                                   attributes:nil];
+    }                                                            
+    outputPanel = [[HBOutputPanelController alloc] init];
+    fPictureController = [[PictureController alloc] init];
+    fQueueController = [[HBQueueController alloc] init];
+    fAdvancedOptions = [[HBAdvancedController alloc] init];
+    /* we init the HBPresets class which currently is only used
+     * for updating built in presets, may move more functionality
+     * there in the future
+     */
+    fPresetsBuiltin = [[HBPresets alloc] init];
+    fPreferencesController = [[HBPreferencesController alloc] init];
+    /* Lets report the HandBrake version number here to the activity log and text log file */
+    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+    [self writeToActivityLog: "%s", [versionStringFull UTF8String]];    
+    
+    return self;
+}
+
+
+- (void) applicationDidFinishLaunching: (NSNotification *) notification
+{
+    /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */
+    int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue];
+    fHandle = hb_init(loggingLevel, 0);
+    /* Optional dvd nav UseDvdNav*/
+    hb_dvd_set_dvdnav([[[NSUserDefaults standardUserDefaults] objectForKey:@"UseDvdNav"] boolValue]);
+    /* Init a separate instance of libhb for user scanning and setting up jobs */
+    fQueueEncodeLibhb = hb_init(loggingLevel, 0);
+    
+       // Set the Growl Delegate
+    [GrowlApplicationBridge setGrowlDelegate: self];
+    /* Init others controllers */
+    [fPictureController SetHandle: fHandle];
+    [fPictureController   setHBController: self];
+    
+    [fQueueController   setHandle: fQueueEncodeLibhb];
+    [fQueueController   setHBController: self];
+
+    fChapterTitlesDelegate = [[ChapterTitles alloc] init];
+    [fChapterTable setDataSource:fChapterTitlesDelegate];
+    [fChapterTable setDelegate:fChapterTitlesDelegate];
+    
+    /* setup the subtitles delegate and connections to table */
+    fSubtitlesDelegate = [[HBSubtitles alloc] init];
+    [fSubtitlesTable setDataSource:fSubtitlesDelegate];
+    [fSubtitlesTable setDelegate:fSubtitlesDelegate];
+    [fSubtitlesTable setRowHeight:25.0];
+    
+    [fPresetsOutlineView setAutosaveName:@"Presets View"];
+    [fPresetsOutlineView setAutosaveExpandedItems:YES];
+    
+    dockIconProgress = 0;
+
+    /* Call UpdateUI every 1/2 sec */
+    [[NSRunLoop currentRunLoop] addTimer:[NSTimer
+                                          scheduledTimerWithTimeInterval:0.5 target:self
+                                          selector:@selector(updateUI:) userInfo:nil repeats:YES]
+                                 forMode:NSDefaultRunLoopMode];
+
+    // Open debug output window now if it was visible when HB was closed
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"])
+        [self showDebugOutputPanel:nil];
+
+    // Open queue window now if it was visible when HB was closed
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"])
+        [self showQueueWindow:nil];
+
+       [self openMainWindow:nil];
+    
+    /* We have to set the bool to tell hb what to do after a scan
+     * Initially we set it to NO until we start processing the queue
+     */
+     applyQueueToScan = NO;
+    
+    /* Now we re-check the queue array to see if there are
+     * any remaining encodes to be done in it and ask the
+     * user if they want to reload the queue */
+    if ([QueueFileArray count] > 0)
+       {
+        /* run  getQueueStats to see whats in the queue file */
+        [self getQueueStats];
+        /* this results in these values
+         * fEncodingQueueItem = 0;
+         * fPendingCount = 0;
+         * fCompletedCount = 0;
+         * fCanceledCount = 0;
+         * fWorkingCount = 0;
+         */
+        
+        /*On Screen Notification*/
+        NSString * alertTitle;
+        
+        /* We check to see if there is already another instance of hb running.
+         * Note: hbInstances == 1 means we are the only instance of HandBrake.app
+         */
+        if ([self hbInstances] > 1)
+        {
+        alertTitle = [NSString stringWithFormat:
+                         NSLocalizedString(@"There is already an instance of HandBrake running.", @"")];
+        NSBeginCriticalAlertSheet(
+                                      alertTitle,
+                                      NSLocalizedString(@"Reload Queue", nil),
+                                      nil,
+                                      nil,
+                                      fWindow, self,
+                                      nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil,
+                                      NSLocalizedString(@" HandBrake will now load up the existing queue.", nil));    
+        }
+        else
+        {
+            if (fWorkingCount > 0)
+            {
+                alertTitle = [NSString stringWithFormat:
+                              NSLocalizedString(@"HandBrake Has Detected %d Previously Encoding Item and %d Pending Item(s) In Your Queue.", @""),
+                              fWorkingCount,fPendingCount];
+            }
+            else
+            {
+                alertTitle = [NSString stringWithFormat:
+                              NSLocalizedString(@"HandBrake Has Detected %d Pending Item(s) In Your Queue.", @""),
+                              fPendingCount];
+            }
+            
+            NSBeginCriticalAlertSheet(
+                                      alertTitle,
+                                      NSLocalizedString(@"Reload Queue", nil),
+                                      nil,
+                                      NSLocalizedString(@"Empty Queue", nil),
+                                      fWindow, self,
+                                      nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil,
+                                      NSLocalizedString(@" Do you want to reload them ?", nil));
+        }
+        
+        // call didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
+        // right below to either clear the old queue or keep it loaded up.
+    }
+    else
+    {
+        /* We show whichever open source window specified in LaunchSourceBehavior preference key */
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
+        {
+            [self browseSources:nil];
+        }
+        
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source (Title Specific)"])
+        {
+            [self browseSources:(id)fOpenSourceTitleMMenu];
+        }
+    }
+}
+
+- (int) hbInstances
+{
+    /* check to see if another instance of HandBrake.app is running */
+    NSArray *runningAppDictionaries = [[NSWorkspace sharedWorkspace] launchedApplications];
+    NSDictionary *aDictionary;
+    int hbInstances = 0;
+    for (aDictionary in runningAppDictionaries)
+       {
+        //     NSLog(@"Open App: %@", [aDictionary valueForKey:@"NSApplicationName"]);
+        
+        if ([[aDictionary valueForKey:@"NSApplicationName"] isEqualToString:@"HandBrake"])
+               {
+            hbInstances++;
+               }
+       }
+    return hbInstances;
+}
+
+- (void) didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
+{
+    if (returnCode == NSAlertOtherReturn)
+    {
+        [self clearQueueAllItems];
+        /* We show whichever open source window specified in LaunchSourceBehavior preference key */
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
+        {
+            [self browseSources:nil];
+        }
+        
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source (Title Specific)"])
+        {
+            [self browseSources:(id)fOpenSourceTitleMMenu];
+        }
+    }
+    else
+    {
+        if ([self hbInstances] == 1)
+        {
+            [self setQueueEncodingItemsAsPending];
+        }
+        [self showQueueWindow:NULL];
+    }
+}
+
+- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app
+{
+    /* if we are in preview full screen mode, we need to go to
+     * windowed mode and release the display before we terminate.
+     * We do it here (instead of applicationWillTerminate) so we 
+     * release the displays and can then see the alerts below.
+     */
+    if ([fPictureController previewFullScreenMode] == YES)
+    {
+        [fPictureController previewGoWindowed:nil];
+    }
+    
+    hb_state_t s;
+    hb_get_state( fQueueEncodeLibhb, &s );
+    
+    if ( s.state != HB_STATE_IDLE )
+    {
+        int result = NSRunCriticalAlertPanel(
+                                             NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
+                                             NSLocalizedString(@"If you quit HandBrake your current encode will be reloaded into your queue at next launch. Do you want to quit anyway?", nil),
+                                             NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil, @"A movie" );
+        
+        if (result == NSAlertDefaultReturn)
+        {
+            return NSTerminateNow;
+        }
+        else
+            return NSTerminateCancel;
+    }
+    
+    // Warn if items still in the queue
+    else if ( fPendingCount > 0 )
+    {
+        int result = NSRunCriticalAlertPanel(
+                                             NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
+                                             NSLocalizedString(@"There are pending encodes in your queue. Do you want to quit anyway?",nil),
+                                             NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil);
+        
+        if ( result == NSAlertDefaultReturn )
+            return NSTerminateNow;
+        else
+            return NSTerminateCancel;
+    }
+    
+    return NSTerminateNow;
+}
+
+- (void)applicationWillTerminate:(NSNotification *)aNotification
+{
+    
+    [browsedSourceDisplayName release];
+    [outputPanel release];
+       [fQueueController release];
+    [fPreviewController release];
+    [fPictureController release];
+    [fApplicationIcon release];
+
+       hb_close(&fHandle);
+    hb_close(&fQueueEncodeLibhb);
+}
+
+
+- (void) awakeFromNib
+{
+    [fWindow center];
+    [fWindow setExcludedFromWindowsMenu:YES];
+    [fAdvancedOptions setView:fAdvancedView];
+    
+    /* lets setup our presets drawer for drag and drop here */
+    [fPresetsOutlineView registerForDraggedTypes: [NSArray arrayWithObject:DragDropSimplePboardType] ];
+    [fPresetsOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
+    [fPresetsOutlineView setVerticalMotionCanBeginDrag: YES];
+    
+    /* Initialize currentScanCount so HB can use it to
+     evaluate successive scans */
+       currentScanCount = 0;
+    
+    
+    /* Init UserPresets .plist */
+       [self loadPresets];
+    
+    /* Init QueueFile .plist */
+    [self loadQueueFile];
+       
+    fRipIndicatorShown = NO;  // initially out of view in the nib
+    
+    /* For 64 bit builds, the threaded animation in the progress
+     * indicators conflicts with the animation in the advanced tab
+     * for reasons not completely clear. jbrjake found a note in the
+     * 10.5 dev notes regarding this possiblility. It was also noted
+     * that unless specified, setUsesThreadedAnimation defaults to true.
+     * So, at least for now we set the indicator animation to NO for
+     * both the scan and regular progress indicators for both 32 and 64 bit
+     * as it test out fine on both and there is no reason our progress indicators
+     * should require their own thread.
+     */
+
+    [fScanIndicator setUsesThreadedAnimation:NO];
+    [fRipIndicator setUsesThreadedAnimation:NO];
+  
+    
+    
+       /* Show/Dont Show Presets drawer upon launch based
+     on user preference DefaultPresetsDrawerShow*/
+       if( [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0 )
+       {
+        [fPresetDrawer setDelegate:self];
+        NSSize drawerSize = NSSizeFromString( [[NSUserDefaults standardUserDefaults] 
+                                               stringForKey:@"Drawer Size"] );
+        if( drawerSize.width )
+            [fPresetDrawer setContentSize: drawerSize];
+               [fPresetDrawer open];
+       }
+    
+    /* Initially set the dvd angle widgets to hidden (dvdnav only) */
+    [fSrcAngleLabel setHidden:YES];
+    [fSrcAnglePopUp setHidden:YES];
+    
+    /* Destination box*/
+    NSMenuItem *menuItem;
+    [fDstFormatPopUp removeAllItems];
+    // MP4 file
+    menuItem = [[fDstFormatPopUp menu] addItemWithTitle:@"MP4 file" action: NULL keyEquivalent: @""];
+    [menuItem setTag: HB_MUX_MP4];
+       // MKV file
+    menuItem = [[fDstFormatPopUp menu] addItemWithTitle:@"MKV file" action: NULL keyEquivalent: @""];
+    [menuItem setTag: HB_MUX_MKV];
+    
+    [fDstFormatPopUp selectItemAtIndex: 0];
+    
+    [self formatPopUpChanged:nil];
+    
+       /* We enable the create chapters checkbox here since we are .mp4 */
+       [fCreateChapterMarkers setEnabled: YES];
+       if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultChapterMarkers"] > 0)
+       {
+               [fCreateChapterMarkers setState: NSOnState];
+       }
+    
+    
+    
+    
+    [fDstFile2Field setStringValue: [NSString stringWithFormat:
+                                     @"%@/Desktop/Movie.mp4", NSHomeDirectory()]];
+    
+    /* Video encoder */
+    [fVidEncoderPopUp removeAllItems];
+    [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
+    
+    
+    
+    /* Video quality */
+    [fVidTargetSizeField setIntValue: 700];
+       [fVidBitrateField    setIntValue: 1000];
+    
+    [fVidQualityMatrix   selectCell: fVidBitrateCell];
+    [self videoMatrixChanged:nil];
+    
+    /* Video framerate */
+    [fVidRatePopUp removeAllItems];
+       [fVidRatePopUp addItemWithTitle: NSLocalizedString( @"Same as source", @"" )];
+    for( int i = 0; i < hb_video_rates_count; i++ )
+    {
+        if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]])
+               {
+                       [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
+                                             [NSString stringWithUTF8String: hb_video_rates[i].string], @" (NTSC Film)"]];
+               }
+               else if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]])
+               {
+                       [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
+                                             [NSString stringWithUTF8String: hb_video_rates[i].string], @" (PAL Film/Video)"]];
+               }
+               else if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]])
+               {
+                       [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
+                                             [NSString stringWithUTF8String: hb_video_rates[i].string], @" (NTSC Video)"]];
+               }
+               else
+               {
+                       [fVidRatePopUp addItemWithTitle:
+             [NSString stringWithUTF8String: hb_video_rates[i].string]];
+               }
+    }
+    [fVidRatePopUp selectItemAtIndex: 0];
+       
+       /* Set Auto Crop to On at launch */
+    [fPictureController setAutoCrop:YES];
+       
+       /* Audio bitrate */
+    [fAudTrack1BitratePopUp removeAllItems];
+    for( int i = 0; i < hb_audio_bitrates_count; i++ )
+    {
+        [fAudTrack1BitratePopUp addItemWithTitle:
+         [NSString stringWithUTF8String: hb_audio_bitrates[i].string]];
+        
+    }
+    [fAudTrack1BitratePopUp selectItemAtIndex: hb_audio_bitrates_default];
+       
+    /* Audio samplerate */
+    [fAudTrack1RatePopUp removeAllItems];
+    for( int i = 0; i < hb_audio_rates_count; i++ )
+    {
+        [fAudTrack1RatePopUp addItemWithTitle:
+         [NSString stringWithUTF8String: hb_audio_rates[i].string]];
+    }
+    [fAudTrack1RatePopUp selectItemAtIndex: hb_audio_rates_default];
+       
+    /* Bottom */
+    [fStatusField setStringValue: @""];
+    
+    [self enableUI: NO];
+       [self setupToolbar];
+    
+       /* We disable the Turbo 1st pass checkbox since we are not x264 */
+       [fVidTurboPassCheck setEnabled: NO];
+       [fVidTurboPassCheck setState: NSOffState];
+    
+    
+       /* lets get our default prefs here */
+       [self getDefaultPresets:nil];
+       /* lets initialize the current successful scancount here to 0 */
+       currentSuccessfulScanCount = 0;
+    
+    
+}
+
+- (void) enableUI: (bool) b
+{
+    NSControl * controls[] =
+    { fSrcTitleField, fSrcTitlePopUp,
+        fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
+        fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
+        fDstFormatField, fDstFormatPopUp, fDstFile1Field, fDstFile2Field,
+        fDstBrowseButton, fVidRateField, fVidRatePopUp,fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
+        fPictureSizeField,fPictureCroppingField, fVideoFiltersField,fVidQualityMatrix, fSubField, fSubPopUp,
+        fAudSourceLabel, fAudCodecLabel, fAudMixdownLabel, fAudSamplerateLabel, fAudBitrateLabel,
+        fAudTrack1Label, fAudTrack2Label, fAudTrack3Label, fAudTrack4Label,
+        fAudLang1PopUp, fAudLang2PopUp, fAudLang3PopUp, fAudLang4PopUp,
+        fAudTrack1CodecPopUp, fAudTrack2CodecPopUp, fAudTrack3CodecPopUp, fAudTrack4CodecPopUp,
+        fAudTrack1MixPopUp, fAudTrack2MixPopUp, fAudTrack3MixPopUp, fAudTrack4MixPopUp,
+        fAudTrack1RatePopUp, fAudTrack2RatePopUp, fAudTrack3RatePopUp, fAudTrack4RatePopUp,
+        fAudTrack1BitratePopUp, fAudTrack2BitratePopUp, fAudTrack3BitratePopUp, fAudTrack4BitratePopUp,
+        fAudDrcLabel, fAudTrack1DrcSlider, fAudTrack1DrcField, fAudTrack2DrcSlider,
+        fAudTrack2DrcField, fAudTrack3DrcSlider, fAudTrack3DrcField, fAudTrack4DrcSlider,fAudTrack4DrcField,
+        fQueueStatus,fPresetsAdd,fPresetsDelete,fSrcAngleLabel,fSrcAnglePopUp,
+               fCreateChapterMarkers,fVidTurboPassCheck,fDstMp4LargeFileCheck,fSubForcedCheck,fPresetsOutlineView,
+    fAudDrcLabel,fDstMp4HttpOptFileCheck,fDstMp4iPodFileCheck,fVidQualityRFField,fVidQualityRFLabel};
+    
+    for( unsigned i = 0;
+        i < sizeof( controls ) / sizeof( NSControl * ); i++ )
+    {
+        if( [[controls[i] className] isEqualToString: @"NSTextField"] )
+        {
+            NSTextField * tf = (NSTextField *) controls[i];
+            if( ![tf isBezeled] )
+            {
+                [tf setTextColor: b ? [NSColor controlTextColor] :
+                 [NSColor disabledControlTextColor]];
+                continue;
+            }
+        }
+        [controls[i] setEnabled: b];
+        
+    }
+    
+       if (b) {
+        
+        /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
+        /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
+        [self setEnabledStateOfAudioMixdownControls:nil];
+        /* we also call calculatePictureSizing here to sense check if we already have vfr selected */
+        [self calculatePictureSizing:nil];
+        
+       } else {
+        
+               [fPresetsOutlineView setEnabled: NO];
+        
+       }
+    
+    [self videoMatrixChanged:nil];
+    [fAdvancedOptions enableUI:b];
+}
+
+
+/***********************************************************************
+ * UpdateDockIcon
+ ***********************************************************************
+ * Shows a progression bar on the dock icon, filled according to
+ * 'progress' (0.0 <= progress <= 1.0).
+ * Called with progress < 0.0 or progress > 1.0, restores the original
+ * icon.
+ **********************************************************************/
+- (void) UpdateDockIcon: (float) progress
+{
+    NSData * tiff;
+    NSBitmapImageRep * bmp;
+    uint32_t * pen;
+    uint32_t black = htonl( 0x000000FF );
+    uint32_t red   = htonl( 0xFF0000FF );
+    uint32_t white = htonl( 0xFFFFFFFF );
+    int row_start, row_end;
+    int i, j;
+
+    if( progress < 0.0 || progress > 1.0 )
+    {
+        [NSApp setApplicationIconImage: fApplicationIcon];
+        return;
+    }
+
+    /* Get it in a raw bitmap form */
+    tiff = [fApplicationIcon TIFFRepresentationUsingCompression:
+            NSTIFFCompressionNone factor: 1.0];
+    bmp = [NSBitmapImageRep imageRepWithData: tiff];
+    
+    /* Draw the progression bar */
+    /* It's pretty simple (ugly?) now, but I'm no designer */
+
+    row_start = 3 * (int) [bmp size].height / 4;
+    row_end   = 7 * (int) [bmp size].height / 8;
+
+    for( i = row_start; i < row_start + 2; i++ )
+    {
+        pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
+        for( j = 0; j < (int) [bmp size].width; j++ )
+        {
+            pen[j] = black;
+        }
+    }
+    for( i = row_start + 2; i < row_end - 2; i++ )
+    {
+        pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
+        pen[0] = black;
+        pen[1] = black;
+        for( j = 2; j < (int) [bmp size].width - 2; j++ )
+        {
+            if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) )
+            {
+                pen[j] = red;
+            }
+            else
+            {
+                pen[j] = white;
+            }
+        }
+        pen[j]   = black;
+        pen[j+1] = black;
+    }
+    for( i = row_end - 2; i < row_end; i++ )
+    {
+        pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
+        for( j = 0; j < (int) [bmp size].width; j++ )
+        {
+            pen[j] = black;
+        }
+    }
+
+    /* Now update the dock icon */
+    tiff = [bmp TIFFRepresentationUsingCompression:
+            NSTIFFCompressionNone factor: 1.0];
+    NSImage* icon = [[NSImage alloc] initWithData: tiff];
+    [NSApp setApplicationIconImage: icon];
+    [icon release];
+}
+
+- (void) updateUI: (NSTimer *) timer
+{
+    
+    /* Update UI for fHandle (user scanning instance of libhb ) */
+    
+    hb_list_t  * list;
+    list = hb_get_titles( fHandle );
+    /* check to see if there has been a new scan done
+     this bypasses the constraints of HB_STATE_WORKING
+     not allowing setting a newly scanned source */
+       int checkScanCount = hb_get_scancount( fHandle );
+       if( checkScanCount > currentScanCount )
+       {
+               currentScanCount = checkScanCount;
+        [fScanIndicator setIndeterminate: NO];
+        [fScanIndicator setDoubleValue: 0.0];
+        [fScanIndicator setHidden: YES];
+               [self showNewScan:nil];
+       }
+    
+    hb_state_t s;
+    hb_get_state( fHandle, &s );
+    
+    switch( s.state )
+    {
+        case HB_STATE_IDLE:
+            break;
+#define p s.param.scanning
+        case HB_STATE_SCANNING:
+               {
+            [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
+                                            NSLocalizedString( @"Scanning title %d of %d...", @"" ),
+                                            p.title_cur, p.title_count]];
+            [fScanIndicator setHidden: NO];
+            [fScanIndicator setDoubleValue: 100.0 * ((double)( p.title_cur - 1 ) / p.title_count)];
+            break;
+               }
+#undef p
+            
+#define p s.param.scandone
+        case HB_STATE_SCANDONE:
+        {
+            [fScanIndicator setIndeterminate: NO];
+            [fScanIndicator setDoubleValue: 0.0];
+            [fScanIndicator setHidden: YES];
+                       [self writeToActivityLog:"ScanDone state received from fHandle"];
+            [self showNewScan:nil];
+            [[fWindow toolbar] validateVisibleItems];
+            
+                       break;
+        }
+#undef p
+            
+#define p s.param.working
+        case HB_STATE_WORKING:
+        {
+            
+            break;
+        }
+#undef p
+            
+#define p s.param.muxing
+        case HB_STATE_MUXING:
+        {
+            
+            break;
+        }
+#undef p
+            
+        case HB_STATE_PAUSED:
+            break;
+            
+        case HB_STATE_WORKDONE:
+        {
+            break;
+        }
+    }
+    
+    
+    /* Update UI for fQueueEncodeLibhb */
+    // hb_list_t  * list;
+    // list = hb_get_titles( fQueueEncodeLibhb ); //fQueueEncodeLibhb
+    /* check to see if there has been a new scan done
+     this bypasses the constraints of HB_STATE_WORKING
+     not allowing setting a newly scanned source */
+       
+    checkScanCount = hb_get_scancount( fQueueEncodeLibhb );
+       if( checkScanCount > currentScanCount )
+       {
+               currentScanCount = checkScanCount;
+       }
+    
+    //hb_state_t s;
+    hb_get_state( fQueueEncodeLibhb, &s );
+    
+    switch( s.state )
+    {
+        case HB_STATE_IDLE:
+            break;
+#define p s.param.scanning
+        case HB_STATE_SCANNING:
+               {
+            [fStatusField setStringValue: [NSString stringWithFormat:
+                                           NSLocalizedString( @"Queue Scanning title %d of %d...", @"" ),
+                                           p.title_cur, p.title_count]];
+            
+            /* Set the status string in fQueueController as well */                               
+            [fQueueController setQueueStatusString: [NSString stringWithFormat:
+                                                     NSLocalizedString( @"Queue Scanning title %d of %d...", @"" ),
+                                                     p.title_cur, p.title_count]];
+            break;
+               }
+#undef p
+            
+#define p s.param.scandone
+        case HB_STATE_SCANDONE:
+        {
+                       [self writeToActivityLog:"ScanDone state received from fQueueEncodeLibhb"];
+            [self processNewQueueEncode];
+            [[fWindow toolbar] validateVisibleItems];
+            
+                       break;
+        }
+#undef p
+            
+#define p s.param.working
+        case HB_STATE_WORKING:
+        {
+            NSMutableString * string;
+            NSString * pass_desc;
+                       /* Update text field */
+            if (p.job_cur == 1 && p.job_count > 1)
+            {
+                if ([[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SubtitleList"] && [[[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex]objectForKey:@"SubtitleList"] objectAtIndex:0] objectForKey:@"subtitleSourceTrackNum"] intValue] == 1)
+                {
+                    pass_desc = @"(subtitle scan)";   
+                }
+                else
+                {
+                    pass_desc = @"";
+                }
+            }
+            else
+            {
+                pass_desc = @"";
+            }
+            
+                       string = [NSMutableString stringWithFormat: NSLocalizedString( @"Encoding: pass %d %@ of %d, %.2f %%", @"" ), p.job_cur, pass_desc, p.job_count, 100.0 * p.progress];
+            
+                       if( p.seconds > -1 )
+            {
+                [string appendFormat:
+                 NSLocalizedString( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", @"" ),
+                 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
+            }
+            
+            [fStatusField setStringValue: string];
+            /* Set the status string in fQueueController as well */
+            [fQueueController setQueueStatusString: string];
+            /* Update slider */
+            CGFloat progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
+            [fRipIndicator setIndeterminate: NO];
+            [fRipIndicator setDoubleValue:100.0 * progress_total];
+            
+            // If progress bar hasn't been revealed at the bottom of the window, do
+            // that now. This code used to be in doRip. I moved it to here to handle
+            // the case where hb_start is called by HBQueueController and not from
+            // HBController.
+            if( !fRipIndicatorShown )
+            {
+                NSRect frame = [fWindow frame];
+                if( frame.size.width <= 591 )
+                    frame.size.width = 591;
+                frame.size.height += 36;
+                frame.origin.y -= 36;
+                [fWindow setFrame:frame display:YES animate:YES];
+                fRipIndicatorShown = YES;
+                
+            }
+
+            /* Update dock icon */
+            if( dockIconProgress < 100.0 * progress_total )
+            {
+                [self UpdateDockIcon: progress_total];
+                dockIconProgress += 5;
+            }
+
+            break;
+        }
+#undef p
+            
+#define p s.param.muxing
+        case HB_STATE_MUXING:
+        {
+            /* Update text field */
+            [fStatusField setStringValue: NSLocalizedString( @"Muxing...", @"" )];
+            /* Set the status string in fQueueController as well */
+            [fQueueController setQueueStatusString: NSLocalizedString( @"Muxing...", @"" )];
+            /* Update slider */
+            [fRipIndicator setIndeterminate: YES];
+            [fRipIndicator startAnimation: nil];
+            
+            /* Update dock icon */
+            [self UpdateDockIcon: 1.0];
+            
+                       break;
+        }
+#undef p
+            
+        case HB_STATE_PAUSED:
+                   [fStatusField setStringValue: NSLocalizedString( @"Paused", @"" )];
+            [fQueueController setQueueStatusString: NSLocalizedString( @"Paused", @"" )];
+            
+                       break;
+            
+        case HB_STATE_WORKDONE:
+        {
+            // HB_STATE_WORKDONE happpens as a result of libhb finishing all its jobs
+            // or someone calling hb_stop. In the latter case, hb_stop does not clear
+            // out the remaining passes/jobs in the queue. We'll do that here.
+            
+            // Delete all remaining jobs of this encode.
+            [fStatusField setStringValue: NSLocalizedString( @"Encode Finished.", @"" )];
+            /* Set the status string in fQueueController as well */
+            [fQueueController setQueueStatusString: NSLocalizedString( @"Encode Finished.", @"" )];
+            [fRipIndicator setIndeterminate: NO];
+            [fRipIndicator stopAnimation: nil];
+            [fRipIndicator setDoubleValue: 0.0];
+            [[fWindow toolbar] validateVisibleItems];
+            
+            /* Restore dock icon */
+            [self UpdateDockIcon: -1.0];
+            dockIconProgress = 0;
+            
+            if( fRipIndicatorShown )
+            {
+                NSRect frame = [fWindow frame];
+                if( frame.size.width <= 591 )
+                                   frame.size.width = 591;
+                frame.size.height += -36;
+                frame.origin.y -= -36;
+                [fWindow setFrame:frame display:YES animate:YES];
+                               fRipIndicatorShown = NO;
+                       }
+            /* Since we are done with this encode, tell output to stop writing to the
+             * individual encode log
+             */
+                       [outputPanel endEncodeLog];
+            /* Check to see if the encode state has not been cancelled
+             to determine if we should check for encode done notifications */
+                       if( fEncodeState != 2 )
+            {
+                NSString *pathOfFinishedEncode;
+                /* Get the output file name for the finished encode */
+                pathOfFinishedEncode = [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"DestinationPath"];
+                
+                /* Both the Growl Alert and Sending to MetaX can be done as encodes roll off the queue */
+                /* Growl alert */
+                [self showGrowlDoneNotification:pathOfFinishedEncode];
+                /* Send to MetaX */
+                [self sendToMetaX:pathOfFinishedEncode];
+                
+                /* since we have successfully completed an encode, we increment the queue counter */
+                [self incrementQueueItemDone:nil]; 
+                
+                /* all end of queue actions below need to be done after all queue encodes have finished 
+                 * and there are no pending jobs left to process
+                 */
+                if (fPendingCount == 0)
+                {
+                    /* If Alert Window or Window and Growl has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
+                       [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] )
+                    {
+                        /*On Screen Notification*/
+                        int status;
+                        NSBeep();
+                        status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake queue is done!", @"OK", nil, nil);
+                        [NSApp requestUserAttention:NSCriticalRequest];
+                    }
+                    
+                    /* If sleep has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] )
+                    {
+                        /* Sleep */
+                        NSDictionary* errorDict;
+                        NSAppleEventDescriptor* returnDescriptor = nil;
+                        NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+                                                       @"tell application \"Finder\" to sleep"];
+                        returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+                        [scriptObject release];
+                    }
+                    /* If Shutdown has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] )
+                    {
+                        /* Shut Down */
+                        NSDictionary* errorDict;
+                        NSAppleEventDescriptor* returnDescriptor = nil;
+                        NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+                                                       @"tell application \"Finder\" to shut down"];
+                        returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+                        [scriptObject release];
+                    }
+                    
+                }
+                
+                
+            }
+            
+            break;
+        }
+    }
+    
+}
+
+/* We use this to write messages to stderr from the macgui which show up in the activity window and log*/
+- (void) writeToActivityLog:(const char *) format, ...
+{
+    va_list args;
+    va_start(args, format);
+    if (format != nil)
+    {
+        char str[1024];
+        vsnprintf( str, 1024, format, args );
+
+        time_t _now = time( NULL );
+        struct tm * now  = localtime( &_now );
+        fprintf(stderr, "[%02d:%02d:%02d] macgui: %s\n", now->tm_hour, now->tm_min, now->tm_sec, str );
+    }
+    va_end(args);
+}
+
+#pragma mark -
+#pragma mark Toolbar
+// ============================================================
+// NSToolbar Related Methods
+// ============================================================
+
+- (void) setupToolbar {
+    NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: @"HandBrake Toolbar"] autorelease];
+
+    [toolbar setAllowsUserCustomization: YES];
+    [toolbar setAutosavesConfiguration: YES];
+    [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
+
+    [toolbar setDelegate: self];
+
+    [fWindow setToolbar: toolbar];
+}
+
+- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier:
+    (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
+    NSToolbarItem * item = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
+
+    if ([itemIdent isEqualToString: ToggleDrawerIdentifier])
+    {
+        [item setLabel: @"Toggle Presets"];
+        [item setPaletteLabel: @"Toggler Presets"];
+        [item setToolTip: @"Open/Close Preset Drawer"];
+        [item setImage: [NSImage imageNamed: @"Drawer"]];
+        [item setTarget: self];
+        [item setAction: @selector(toggleDrawer:)];
+        [item setAutovalidates: NO];
+    }
+    else if ([itemIdent isEqualToString: StartEncodingIdentifier])
+    {
+        [item setLabel: @"Start"];
+        [item setPaletteLabel: @"Start Encoding"];
+        [item setToolTip: @"Start Encoding"];
+        [item setImage: [NSImage imageNamed: @"Play"]];
+        [item setTarget: self];
+        [item setAction: @selector(Rip:)];
+    }
+    else if ([itemIdent isEqualToString: ShowQueueIdentifier])
+    {
+        [item setLabel: @"Show Queue"];
+        [item setPaletteLabel: @"Show Queue"];
+        [item setToolTip: @"Show Queue"];
+        [item setImage: [NSImage imageNamed: @"Queue"]];
+        [item setTarget: self];
+        [item setAction: @selector(showQueueWindow:)];
+        [item setAutovalidates: NO];
+    }
+    else if ([itemIdent isEqualToString: AddToQueueIdentifier])
+    {
+        [item setLabel: @"Add to Queue"];
+        [item setPaletteLabel: @"Add to Queue"];
+        [item setToolTip: @"Add to Queue"];
+        [item setImage: [NSImage imageNamed: @"AddToQueue"]];
+        [item setTarget: self];
+        [item setAction: @selector(addToQueue:)];
+    }
+    else if ([itemIdent isEqualToString: PauseEncodingIdentifier])
+    {
+        [item setLabel: @"Pause"];
+        [item setPaletteLabel: @"Pause Encoding"];
+        [item setToolTip: @"Pause Encoding"];
+        [item setImage: [NSImage imageNamed: @"Pause"]];
+        [item setTarget: self];
+        [item setAction: @selector(Pause:)];
+    }
+    else if ([itemIdent isEqualToString: ShowPictureIdentifier])
+    {
+        [item setLabel: @"Picture Settings"];
+        [item setPaletteLabel: @"Show Picture Settings"];
+        [item setToolTip: @"Show Picture Settings"];
+        [item setImage: [NSImage imageNamed: @"pref-picture"]];
+        [item setTarget: self];
+        [item setAction: @selector(showPicturePanel:)];
+    }
+    else if ([itemIdent isEqualToString: ShowPreviewIdentifier])
+    {
+        [item setLabel: @"Preview Window"];
+        [item setPaletteLabel: @"Show Preview"];
+        [item setToolTip: @"Show Preview"];
+        //[item setImage: [NSImage imageNamed: @"pref-picture"]];
+        [item setImage: [NSImage imageNamed: @"Brushed_Window"]];
+        [item setTarget: self];
+        [item setAction: @selector(showPreviewWindow:)];
+    }
+    else if ([itemIdent isEqualToString: ShowActivityIdentifier]) 
+    {
+        [item setLabel: @"Activity Window"];
+        [item setPaletteLabel: @"Show Activity Window"];
+        [item setToolTip: @"Show Activity Window"];
+        [item setImage: [NSImage imageNamed: @"ActivityWindow"]];
+        [item setTarget: self];
+        [item setAction: @selector(showDebugOutputPanel:)];
+        [item setAutovalidates: NO];
+    }
+    else if ([itemIdent isEqualToString: ChooseSourceIdentifier])
+    {
+        [item setLabel: @"Source"];
+        [item setPaletteLabel: @"Source"];
+        [item setToolTip: @"Choose Video Source"];
+        [item setImage: [NSImage imageNamed: @"Source"]];
+        [item setTarget: self];
+        [item setAction: @selector(browseSources:)];
+    }
+    else
+    {
+        return nil;
+    }
+
+    return item;
+}
+
+- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
+{
+    return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier,
+        PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier, NSToolbarFlexibleSpaceItemIdentifier, 
+               NSToolbarSpaceItemIdentifier, ShowPictureIdentifier, ShowPreviewIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
+}
+
+- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
+{
+    return [NSArray arrayWithObjects:  StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier,
+        ChooseSourceIdentifier, ShowQueueIdentifier, ShowPictureIdentifier, ShowPreviewIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
+        NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
+        NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
+}
+
+- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
+{
+    NSString * ident = [toolbarItem itemIdentifier];
+        
+    if (fHandle)
+    {
+        hb_state_t s;
+        
+        hb_get_state( fHandle, &s );
+        if (s.state == HB_STATE_SCANNING && ([ident isEqualToString: StartEncodingIdentifier] || [ident isEqualToString: AddToQueueIdentifier]))
+            return NO;
+        
+        hb_get_state2( fQueueEncodeLibhb, &s );
+        
+        if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING)
+        {
+            if ([ident isEqualToString: StartEncodingIdentifier])
+            {
+                [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];
+                [toolbarItem setLabel: @"Stop"];
+                [toolbarItem setPaletteLabel: @"Stop"];
+                [toolbarItem setToolTip: @"Stop Encoding"];
+                return YES;
+            }
+            if ([ident isEqualToString: PauseEncodingIdentifier])
+            {
+                [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
+                [toolbarItem setLabel: @"Pause"];
+                [toolbarItem setPaletteLabel: @"Pause Encoding"];
+                [toolbarItem setToolTip: @"Pause Encoding"];
+                return YES;
+            }
+            if (SuccessfulScan)
+            {
+                if ([ident isEqualToString: AddToQueueIdentifier])
+                    return YES;
+                if ([ident isEqualToString: ShowPictureIdentifier])
+                    return YES;
+                if ([ident isEqualToString: ShowPreviewIdentifier])
+                    return YES;
+            }
+        }
+        else if (s.state == HB_STATE_PAUSED)
+        {
+            if ([ident isEqualToString: PauseEncodingIdentifier])
+            {
+                [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
+                [toolbarItem setLabel: @"Resume"];
+                [toolbarItem setPaletteLabel: @"Resume Encoding"];
+                [toolbarItem setToolTip: @"Resume Encoding"];
+                return YES;
+            }
+            if ([ident isEqualToString: StartEncodingIdentifier])
+                return YES;
+            if ([ident isEqualToString: AddToQueueIdentifier])
+                return YES;
+            if ([ident isEqualToString: ShowPictureIdentifier])
+                return YES;
+            if ([ident isEqualToString: ShowPreviewIdentifier])
+                return YES;
+        }
+        else if (s.state == HB_STATE_SCANNING)
+            return NO;
+        else if (s.state == HB_STATE_WORKDONE || s.state == HB_STATE_SCANDONE || SuccessfulScan)
+        {
+            if ([ident isEqualToString: StartEncodingIdentifier])
+            {
+                [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
+                if (hb_count(fHandle) > 0)
+                    [toolbarItem setLabel: @"Start Queue"];
+                else
+                    [toolbarItem setLabel: @"Start"];
+                [toolbarItem setPaletteLabel: @"Start Encoding"];
+                [toolbarItem setToolTip: @"Start Encoding"];
+                return YES;
+            }
+            if ([ident isEqualToString: AddToQueueIdentifier])
+                return YES;
+            if ([ident isEqualToString: ShowPictureIdentifier])
+                return YES;
+            if ([ident isEqualToString: ShowPreviewIdentifier])
+                return YES;
+        }
+
+    }
+    /* If there are any pending queue items, make sure the start/stop button is active */
+    if ([ident isEqualToString: StartEncodingIdentifier] && fPendingCount > 0)
+        return YES;
+    if ([ident isEqualToString: ShowQueueIdentifier])
+        return YES;
+    if ([ident isEqualToString: ToggleDrawerIdentifier])
+        return YES;
+    if ([ident isEqualToString: ChooseSourceIdentifier])
+        return YES;
+    if ([ident isEqualToString: ShowActivityIdentifier])
+        return YES;
+    
+    return NO;
+}
+
+- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
+{
+    SEL action = [menuItem action];
+    
+    hb_state_t s;
+    hb_get_state2( fHandle, &s );
+    
+    if (fHandle)
+    {
+        if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
+            return SuccessfulScan && [fWindow attachedSheet] == nil;
+        
+        if (action == @selector(browseSources:))
+        {
+            if (s.state == HB_STATE_SCANNING)
+                return NO;
+            else
+                return [fWindow attachedSheet] == nil;
+        }
+        if (action == @selector(selectDefaultPreset:))
+            return [fPresetsOutlineView selectedRow] >= 0 && [fWindow attachedSheet] == nil;
+        if (action == @selector(Pause:))
+        {
+            if (s.state == HB_STATE_WORKING)
+            {
+                if(![[menuItem title] isEqualToString:@"Pause Encoding"])
+                    [menuItem setTitle:@"Pause Encoding"];
+                return YES;
+            }
+            else if (s.state == HB_STATE_PAUSED)
+            {
+                if(![[menuItem title] isEqualToString:@"Resume Encoding"])
+                    [menuItem setTitle:@"Resume Encoding"];
+                return YES;
+            }
+            else
+                return NO;
+        }
+        if (action == @selector(Rip:))
+        {
+            if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING || s.state == HB_STATE_PAUSED)
+            {
+                if(![[menuItem title] isEqualToString:@"Stop Encoding"])
+                    [menuItem setTitle:@"Stop Encoding"];
+                return YES;
+            }
+            else if (SuccessfulScan)
+            {
+                if(![[menuItem title] isEqualToString:@"Start Encoding"])
+                    [menuItem setTitle:@"Start Encoding"];
+                return [fWindow attachedSheet] == nil;
+            }
+            else
+                return NO;
+        }
+    }
+    if( action == @selector(setDefaultPreset:) )
+    {
+        return [fPresetsOutlineView selectedRow] != -1;
+    }
+
+    return YES;
+}
+
+#pragma mark -
+#pragma mark Encode Done Actions
+// register a test notification and make
+// it enabled by default
+#define SERVICE_NAME @"Encode Done"
+- (NSDictionary *)registrationDictionaryForGrowl 
+{ 
+    NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: 
+    [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL, 
+    [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT, 
+    nil]; 
+
+    return registrationDictionary; 
+} 
+
+-(void)showGrowlDoneNotification:(NSString *) filePath
+{
+    /* This end of encode action is called as each encode rolls off of the queue */
+    NSString * finishedEncode = filePath;
+    /* strip off the path to just show the file name */
+    finishedEncode = [finishedEncode lastPathComponent];
+    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] || 
+        [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
+    {
+        NSString * growlMssg = [NSString stringWithFormat: @"your HandBrake encode %@ is done!",finishedEncode];
+        [GrowlApplicationBridge 
+         notifyWithTitle:@"Put down that cocktail..." 
+         description:growlMssg 
+         notificationName:SERVICE_NAME
+         iconData:nil 
+         priority:0 
+         isSticky:1 
+         clickContext:nil];
+    }
+    
+}
+-(void)sendToMetaX:(NSString *) filePath
+{
+    /* This end of encode action is called as each encode rolls off of the queue */
+    if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
+    {
+        NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", filePath, @"\")"]];
+        [myScript executeAndReturnError: nil];
+        [myScript release];
+    }
+}
+#pragma mark -
+#pragma mark Get New Source
+
+/*Opens the source browse window, called from Open Source widgets */
+- (IBAction) browseSources: (id) sender
+{
+    NSOpenPanel * panel;
+       
+    panel = [NSOpenPanel openPanel];
+    [panel setAllowsMultipleSelection: NO];
+    [panel setCanChooseFiles: YES];
+    [panel setCanChooseDirectories: YES ];
+    NSString * sourceDirectory;
+       if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"])
+       {
+               sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"];
+       }
+       else
+       {
+               sourceDirectory = @"~/Desktop";
+               sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
+       }
+    /* we open up the browse sources sheet here and call for browseSourcesDone after the sheet is closed
+        * to evaluate whether we want to specify a title, we pass the sender in the contextInfo variable
+        */
+    [panel beginSheetForDirectory: sourceDirectory file: nil types: nil
+                   modalForWindow: fWindow modalDelegate: self
+                   didEndSelector: @selector( browseSourcesDone:returnCode:contextInfo: )
+                      contextInfo: sender]; 
+}
+
+- (void) browseSourcesDone: (NSOpenPanel *) sheet
+                returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    /* we convert the sender content of contextInfo back into a variable called sender
+     * mostly just for consistency for evaluation later
+     */
+    id sender = (id)contextInfo;
+    /* User selected a file to open */
+       if( returnCode == NSOKButton )
+    {
+            /* Free display name allocated previously by this code */
+        [browsedSourceDisplayName release];
+       
+        NSString *scanPath = [[sheet filenames] objectAtIndex: 0];
+        /* we set the last searched source directory in the prefs here */
+        NSString *sourceDirectory = [scanPath stringByDeletingLastPathComponent];
+        [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"];
+        /* we order out sheet, which is the browse window as we need to open
+         * the title selection sheet right away
+         */
+        [sheet orderOut: self];
+        
+        if (sender == fOpenSourceTitleMMenu || [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
+        {
+            /* We put the chosen source path in the source display text field for the
+             * source title selection sheet in which the user specifies the specific title to be
+             * scanned  as well as the short source name in fSrcDsplyNameTitleScan just for display
+             * purposes in the title panel
+             */
+            /* Full Path */
+            [fScanSrcTitlePathField setStringValue:scanPath];
+            NSString *displayTitlescanSourceName;
+
+            if ([[scanPath lastPathComponent] isEqualToString: @"VIDEO_TS"])
+            {
+                /* If VIDEO_TS Folder is chosen, choose its parent folder for the source display name
+                 we have to use the title->dvd value so we get the proper name of the volume if a physical dvd is the source*/
+                displayTitlescanSourceName = [[scanPath stringByDeletingLastPathComponent] lastPathComponent];
+            }
+            else
+            {
+                /* if not the VIDEO_TS Folder, we can assume the chosen folder is the source name */
+                displayTitlescanSourceName = [scanPath lastPathComponent];
+            }
+            /* we set the source display name in the title selection dialogue */
+            [fSrcDsplyNameTitleScan setStringValue:displayTitlescanSourceName];
+            /* we set the attempted scans display name for main window to displayTitlescanSourceName*/
+            browsedSourceDisplayName = [displayTitlescanSourceName retain];
+            /* We show the actual sheet where the user specifies the title to be scanned
+             * as we are going to do a title specific scan
+             */
+            [self showSourceTitleScanPanel:nil];
+        }
+        else
+        {
+            /* We are just doing a standard full source scan, so we specify "0" to libhb */
+            NSString *path = [[sheet filenames] objectAtIndex: 0];
+            
+            /* We check to see if the chosen file at path is a package */
+            if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:path])
+            {
+                [self writeToActivityLog: "trying to open a package at: %s", [path UTF8String]];
+                /* We check to see if this is an .eyetv package */
+                if ([[path pathExtension] isEqualToString: @"eyetv"])
+                {
+                    [self writeToActivityLog:"trying to open eyetv package"];
+                    /* We're looking at an EyeTV package - try to open its enclosed
+                     .mpg media file */
+                     browsedSourceDisplayName = [[[path stringByDeletingPathExtension] lastPathComponent] retain];
+                    NSString *mpgname;
+                    int n = [[path stringByAppendingString: @"/"]
+                             completePathIntoString: &mpgname caseSensitive: YES
+                             matchesIntoArray: nil
+                             filterTypes: [NSArray arrayWithObject: @"mpg"]];
+                    if (n > 0)
+                    {
+                        /* Found an mpeg inside the eyetv package, make it our scan path 
+                        and call performScan on the enclosed mpeg */
+                        path = mpgname;
+                        [self writeToActivityLog:"found mpeg in eyetv package"];
+                        [self performScan:path scanTitleNum:0];
+                    }
+                    else
+                    {
+                        /* We did not find an mpeg file in our package, so we do not call performScan */
+                        [self writeToActivityLog:"no valid mpeg in eyetv package"];
+                    }
+                }
+                /* We check to see if this is a .dvdmedia package */
+                else if ([[path pathExtension] isEqualToString: @"dvdmedia"])
+                {
+                    /* path IS a package - but dvdmedia packages can be treaded like normal directories */
+                    browsedSourceDisplayName = [[[path stringByDeletingPathExtension] lastPathComponent] retain];
+                    [self writeToActivityLog:"trying to open dvdmedia package"];
+                    [self performScan:path scanTitleNum:0];
+                }
+                else
+                {
+                    /* The package is not an eyetv package, so we do not call performScan */
+                    [self writeToActivityLog:"unable to open package"];
+                }
+            }
+            else // path is not a package, so we treat it as a dvd parent folder or VIDEO_TS folder
+            {
+                /* path is not a package, so we call perform scan directly on our file */
+                if ([[path lastPathComponent] isEqualToString: @"VIDEO_TS"])
+                {
+                    [self writeToActivityLog:"trying to open video_ts folder (video_ts folder chosen)"];
+                    /* If VIDEO_TS Folder is chosen, choose its parent folder for the source display name*/
+                    browsedSourceDisplayName = [[[path stringByDeletingLastPathComponent] lastPathComponent] retain];
+                }
+                else
+                {
+                    [self writeToActivityLog:"trying to open video_ts folder (parent directory chosen)"];
+                    /* if not the VIDEO_TS Folder, we can assume the chosen folder is the source name */
+                    /* make sure we remove any path extension as this can also be an '.mpg' file */
+                    browsedSourceDisplayName = [[path lastPathComponent] retain];
+                }
+                [self performScan:path scanTitleNum:0];
+            }
+
+        }
+
+    }
+}
+
+- (IBAction)showAboutPanel:(id)sender
+{
+    NSMutableDictionary* d = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
+        fApplicationIcon, @"ApplicationIcon",
+        nil ];
+    [NSApp orderFrontStandardAboutPanelWithOptions:d];
+    [d release];
+}
+
+/* Here we open the title selection sheet where we can specify an exact title to be scanned */
+- (IBAction) showSourceTitleScanPanel: (id) sender
+{
+    /* We default the title number to be scanned to "0" which results in a full source scan, unless the
+    * user changes it
+    */
+    [fScanSrcTitleNumField setStringValue: @"0"];
+       /* Show the panel */
+       [NSApp beginSheet:fScanSrcTitlePanel modalForWindow:fWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
+}
+
+- (IBAction) closeSourceTitleScanPanel: (id) sender
+{
+    [NSApp endSheet: fScanSrcTitlePanel];
+    [fScanSrcTitlePanel orderOut: self];
+
+    if(sender == fScanSrcTitleOpenButton)
+    {
+        /* We setup the scan status in the main window to indicate a source title scan */
+        [fSrcDVD2Field setStringValue: @"Opening a new source title ..."];
+               [fScanIndicator setHidden: NO];
+        [fScanIndicator setIndeterminate: YES];
+        [fScanIndicator startAnimation: nil];
+               
+        /* We use the performScan method to actually perform the specified scan passing the path and the title
+            * to be scanned
+            */
+        [self performScan:[fScanSrcTitlePathField stringValue] scanTitleNum:[fScanSrcTitleNumField intValue]];
+    }
+}
+
+/* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/
+- (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum
+{
+    /* set the bool applyQueueToScan so that we dont apply a queue setting to the final scan */
+    applyQueueToScan = NO;
+    /* use a bool to determine whether or not we can decrypt using vlc */
+    BOOL cancelScanDecrypt = 0;
+    NSString *path = scanPath;
+    HBDVDDetector *detector = [HBDVDDetector detectorForPath:path];
+    
+    // Notify ChapterTitles that there's no title
+    [fChapterTitlesDelegate resetWithTitle:nil];
+    [fChapterTable reloadData];
+    
+    // Notify Subtitles that there's no title
+    [fSubtitlesDelegate resetWithTitle:nil];
+    [fSubtitlesTable reloadData];
+    
+    [self enableUI: NO];
+    
+    if( [detector isVideoDVD] )
+    {
+        int hb_arch;
+#if defined( __LP64__ )
+        /* we are 64 bit */
+        hb_arch = 64;
+#else
+        /* we are 32 bit */
+        hb_arch = 32;
+#endif 
+        
+        
+        // The chosen path was actually on a DVD, so use the raw block
+        // device path instead.
+        path = [detector devicePath];
+        [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]];
+        
+        /* lets check for vlc here to make sure we have a dylib available to use for decrypting */
+        NSString *vlcPath = @"/Applications/VLC.app/Contents/MacOS/lib/libdvdcss.2.dylib";
+        NSFileManager * fileManager = [NSFileManager defaultManager];
+           if ([fileManager fileExistsAtPath:vlcPath] == 0) 
+           {
+            /*vlc not found in /Applications so we set the bool to cancel scanning to 1 */
+            cancelScanDecrypt = 1;
+            [self writeToActivityLog: "VLC app not found for decrypting physical dvd"];
+            int status;
+            status = NSRunAlertPanel(@"HandBrake could not find VLC or your VLC is out of date.",@"Please download and install VLC media player in your /Applications folder if you wish to read encrypted DVDs.", @"Get VLC", @"Cancel Scan", @"Attempt Scan Anyway");
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            if (status == NSAlertDefaultReturn)
+            {
+                /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */
+                [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]];
+            }
+            else if (status == NSAlertAlternateReturn)
+            {
+                /* User chose to cancel the scan */
+                [self writeToActivityLog: "cannot open physical dvd , scan cancelled"];
+            }
+            else
+            {
+                /* User chose to override our warning and scan the physical dvd anyway, at their own peril. on an encrypted dvd this produces massive log files and fails */
+                cancelScanDecrypt = 0;
+                [self writeToActivityLog: "user overrode vlc warning -trying to open physical dvd without decryption"];
+            }
+            
+        }
+        else
+        {
+            /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */
+            [self writeToActivityLog: "VLC app found for decrypting physical dvd"];
+        }
+        /* test for architecture of the vlc app */
+        NSArray *vlc_architecturesArray = [[NSBundle bundleWithPath:@"/Applications/VLC.app"] executableArchitectures];
+        BOOL vlcIntel32bit = NO;
+        BOOL vlcIntel64bit = NO;
+        BOOL vlcPPC32bit = NO;
+        BOOL vlcPPC64bit = NO;
+        /* check the available architectures for vlc and note accordingly */
+        NSEnumerator *enumerator = [vlc_architecturesArray objectEnumerator];
+        id tempObject;
+        while (tempObject = [enumerator nextObject])
+        {
+            
+            if ([tempObject intValue] == NSBundleExecutableArchitectureI386)
+            {
+                vlcIntel32bit = YES;   
+            }
+            if ([tempObject intValue] == NSBundleExecutableArchitectureX86_64)
+            {
+                vlcIntel64bit = YES;   
+            }
+            if ([tempObject intValue] == NSBundleExecutableArchitecturePPC)
+            {
+                vlcPPC32bit = YES;   
+            }
+            if ([tempObject intValue] == NSBundleExecutableArchitecturePPC64)
+            {
+                vlcPPC64bit = YES;   
+            }
+            
+        }
+        /* Write vlc architecture findings to activity window */
+        if (vlcIntel32bit)
+        {
+            [self writeToActivityLog: " 32-Bit VLC app found for decrypting physical dvd"];
+        }
+        if (vlcIntel64bit)
+        {
+            [self writeToActivityLog: " 64-Bit VLC app found for decrypting physical dvd"];
+        }
+        
+        
+        
+        if (hb_arch == 64 && !vlcIntel64bit && cancelScanDecrypt != 1)
+        {
+            
+            /* we are 64 bit */
+            
+            /* Appropriate VLC not found, so cancel */
+            cancelScanDecrypt = 1;
+            [self writeToActivityLog: "This version of HandBrake is 64 bit, 64 bit version of vlc not found, scan cancelled"];
+            /*On Screen Notification*/
+            int status;
+            NSBeep();
+            status = NSRunAlertPanel(@"This version of HandBrake is 64 bit, VLC found but not 64 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 64 bit VLC", nil);
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            if (status == NSAlertDefaultReturn)
+            {
+                /* User chose to cancel the scan */
+                [self writeToActivityLog: "cannot open physical dvd VLC found but not 64 bit, scan cancelled"];
+                cancelScanDecrypt = 1;
+            }
+            else if (status == NSAlertDefaultReturn)
+            {
+                [self writeToActivityLog: "user overrode 64-bit warning trying to open physical dvd without proper decryption"];
+                cancelScanDecrypt = 0;
+            }
+            else
+            {
+                /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */
+                [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]];
+            }
+            
+        }    
+        else if (hb_arch == 32 && !vlcIntel32bit && cancelScanDecrypt != 1)
+        {
+            /* we are 32 bit */
+            /* Appropriate VLC not found, so cancel */
+            cancelScanDecrypt = 1;
+            [self writeToActivityLog: "This version of HandBrake is 32 bit, 32 bit version of vlc not found, scan cancelled"];
+            /*On Screen Notification*/
+            int status;
+            NSBeep();
+            status = NSRunAlertPanel(@"This version of HandBrake is 32 bit, VLC found but not 32 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 32 bit VLC", nil);
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            if (status == NSAlertDefaultReturn)
+            {
+                /* User chose to cancel the scan */
+                [self writeToActivityLog: "cannot open physical dvd VLC found but not 32 bit, scan cancelled"];
+                cancelScanDecrypt = 1;
+            }
+            else if (status == NSAlertDefaultReturn)
+            {
+                [self writeToActivityLog: "user overrode 32-bit warning trying to open physical dvd without proper decryption"];
+                cancelScanDecrypt = 0;
+            }
+            else
+            {
+                /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */
+                [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]];
+            }
+            
+        } 
+    }
+    
+    if (cancelScanDecrypt == 0)
+    {
+        /* we actually pass the scan off to libhb here */
+        /* If there is no title number passed to scan, we use "0"
+         * which causes the default behavior of a full source scan
+         */
+        if (!scanTitleNum)
+        {
+            scanTitleNum = 0;
+        }
+        if (scanTitleNum > 0)
+        {
+            [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
+        }
+        /* We use our advance pref to determine how many previews to scan */
+        int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+        /* set title to NULL */
+        //fTitle = NULL;
+        hb_scan( fHandle, [path UTF8String], scanTitleNum, hb_num_previews, 1 );
+        [fSrcDVD2Field setStringValue:@"Scanning new source ..."];
+    }
+}
+
+- (IBAction) showNewScan:(id)sender
+{
+    hb_list_t  * list;
+       hb_title_t * title;
+       int indxpri=0;    // Used to search the longuest title (default in combobox)
+       int longuestpri=0; // Used to search the longuest title (default in combobox)
+    
+
+        list = hb_get_titles( fHandle );
+        
+        if( !hb_list_count( list ) )
+        {
+            /* We display a message if a valid dvd source was not chosen */
+            [fSrcDVD2Field setStringValue: @"No Valid Source Found"];
+            SuccessfulScan = NO;
+            
+            // Notify ChapterTitles that there's no title
+            [fSubtitlesDelegate resetWithTitle:nil];
+            [fSubtitlesTable reloadData];
+            
+            // Notify Subtitles that there's no title
+            [fChapterTitlesDelegate resetWithTitle:nil];
+            [fChapterTable reloadData];
+        }
+        else
+        {
+            /* We increment the successful scancount here by one,
+             which we use at the end of this function to tell the gui
+             if this is the first successful scan since launch and whether
+             or not we should set all settings to the defaults */
+            
+            currentSuccessfulScanCount++;
+            
+            [[fWindow toolbar] validateVisibleItems];
+            
+            [fSrcTitlePopUp removeAllItems];
+            for( int i = 0; i < hb_list_count( list ); i++ )
+            {
+                title = (hb_title_t *) hb_list_item( list, i );
+                
+                currentSource = [NSString stringWithUTF8String: title->name];
+                /*Set DVD Name at top of window with the browsedSourceDisplayName grokked right before -performScan */
+                [fSrcDVD2Field setStringValue:browsedSourceDisplayName];
+                
+                /* Use the dvd name in the default output field here
+                 May want to add code to remove blank spaces for some dvd names*/
+                /* Check to see if the last destination has been set,use if so, if not, use Desktop */
+                if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"])
+                {
+                    [fDstFile2Field setStringValue: [NSString stringWithFormat:
+                                                     @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[browsedSourceDisplayName stringByDeletingPathExtension]]];
+                }
+                else
+                {
+                    [fDstFile2Field setStringValue: [NSString stringWithFormat:
+                                                     @"%@/Desktop/%@.mp4", NSHomeDirectory(),[browsedSourceDisplayName stringByDeletingPathExtension]]];
+                }
+                
+                
+                if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds)
+                {
+                    longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds;
+                    indxpri=i;
+                }
+                
+                [fSrcTitlePopUp addItemWithTitle: [NSString
+                                                   stringWithFormat: @"%d - %02dh%02dm%02ds",
+                                                   title->index, title->hours, title->minutes,
+                                                   title->seconds]];
+            }
+            
+            // Select the longuest title
+            [fSrcTitlePopUp selectItemAtIndex: indxpri];
+            [self titlePopUpChanged:nil];
+            
+            SuccessfulScan = YES;
+            [self enableUI: YES];
+
+            /* if its the initial successful scan after awakeFromNib */
+            if (currentSuccessfulScanCount == 1)
+            {
+                [self selectDefaultPreset:nil];
+                
+                // Open preview window now if it was visible when HB was closed
+                if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreviewWindowIsOpen"])
+                    [self showPreviewWindow:nil];
+                
+                // Open picture sizing window now if it was visible when HB was closed
+                if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PictureSizeWindowIsOpen"])
+                    [self showPicturePanel:nil];
+                
+            }
+
+            
+        }
+
+}
+
+
+#pragma mark -
+#pragma mark New Output Destination
+
+- (IBAction) browseFile: (id) sender
+{
+    /* Open a panel to let the user choose and update the text field */
+    NSSavePanel * panel = [NSSavePanel savePanel];
+       /* We get the current file name and path from the destination field here */
+       [panel beginSheetForDirectory: [[fDstFile2Field stringValue] stringByDeletingLastPathComponent] file: [[fDstFile2Field stringValue] lastPathComponent]
+                                  modalForWindow: fWindow modalDelegate: self
+                                  didEndSelector: @selector( browseFileDone:returnCode:contextInfo: )
+                                         contextInfo: NULL];
+}
+
+- (void) browseFileDone: (NSSavePanel *) sheet
+             returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSOKButton )
+    {
+        [fDstFile2Field setStringValue: [sheet filename]];
+        /* Save this path to the prefs so that on next browse destination window it opens there */
+        NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
+        [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];   
+    }
+}
+
+
+#pragma mark -
+#pragma mark Main Window Control
+
+- (IBAction) openMainWindow: (id) sender
+{
+    [fWindow  makeKeyAndOrderFront:nil];
+}
+
+- (BOOL) windowShouldClose: (id) sender
+{
+    return YES;
+}
+
+- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
+{
+    if( !flag ) {
+        [fWindow  makeKeyAndOrderFront:nil];
+                
+        return YES;
+    }
+    
+    return NO;
+}
+
+- (NSSize) drawerWillResizeContents:(NSDrawer *) drawer toSize:(NSSize) contentSize {
+       [[NSUserDefaults standardUserDefaults] setObject:NSStringFromSize( contentSize ) forKey:@"Drawer Size"];
+       return contentSize;
+}
+
+#pragma mark -
+#pragma mark Queue File
+
+- (void) loadQueueFile {
+       /* We declare the default NSFileManager into fileManager */
+       NSFileManager * fileManager = [NSFileManager defaultManager];
+       /*We define the location of the user presets file */
+    QueueFile = @"~/Library/Application Support/HandBrake/Queue.plist";
+       QueueFile = [[QueueFile stringByExpandingTildeInPath]retain];
+    /* We check for the presets.plist */
+       if ([fileManager fileExistsAtPath:QueueFile] == 0)
+       {
+               [fileManager createFileAtPath:QueueFile contents:nil attributes:nil];
+       }
+
+       QueueFileArray = [[NSMutableArray alloc] initWithContentsOfFile:QueueFile];
+       /* lets check to see if there is anything in the queue file .plist */
+    if (nil == QueueFileArray)
+       {
+        /* if not, then lets initialize an empty array */
+               QueueFileArray = [[NSMutableArray alloc] init];
+        
+     /* Initialize our curQueueEncodeIndex to 0
+     * so we can use it to track which queue
+     * item is to be used to track our encodes */
+     /* NOTE: this should be changed if and when we
+      * are able to get the last unfinished encode
+      * in the case of a crash or shutdown */
+    
+       }
+    else
+    {
+    [self clearQueueEncodedItems];
+    }
+    currentQueueEncodeIndex = 0;
+}
+
+- (void)addQueueFileItem
+{
+        [QueueFileArray addObject:[self createQueueFileItem]];
+        [self saveQueueFileItem];
+
+}
+
+- (void) removeQueueFileItem:(int) queueItemToRemove
+{
+   
+   /* Find out if the item we are removing is a cancelled (3) or a finished (0) item*/
+   if ([[[QueueFileArray objectAtIndex:queueItemToRemove] objectForKey:@"Status"] intValue] == 3 || [[[QueueFileArray objectAtIndex:queueItemToRemove] objectForKey:@"Status"] intValue] == 0)
+    {
+    /* Since we are removing a cancelled or finished item, WE need to decrement the currentQueueEncodeIndex
+     * by one to keep in sync with the queue array
+     */
+    currentQueueEncodeIndex--;
+    [self writeToActivityLog: "removeQueueFileItem: Removing a cancelled/finished encode, decrement currentQueueEncodeIndex to %d", currentQueueEncodeIndex];
+    }
+    [QueueFileArray removeObjectAtIndex:queueItemToRemove];
+    [self saveQueueFileItem];
+
+}
+
+- (void)saveQueueFileItem
+{
+    [QueueFileArray writeToFile:QueueFile atomically:YES];
+    [fQueueController setQueueArray: QueueFileArray];
+    [self getQueueStats];
+}
+
+- (void)getQueueStats
+{
+/* lets get the stats on the status of the queue array */
+
+fEncodingQueueItem = 0;
+fPendingCount = 0;
+fCompletedCount = 0;
+fCanceledCount = 0;
+fWorkingCount = 0;
+
+    /* We use a number system to set the encode status of the queue item
+     * in controller.mm
+     * 0 == already encoded
+     * 1 == is being encoded
+     * 2 == is yet to be encoded
+     * 3 == cancelled
+     */
+
+       int i = 0;
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+       while (tempObject = [enumerator nextObject])
+       {
+               NSDictionary *thisQueueDict = tempObject;
+               if ([[thisQueueDict objectForKey:@"Status"] intValue] == 0) // Completed
+               {
+                       fCompletedCount++;      
+               }
+               if ([[thisQueueDict objectForKey:@"Status"] intValue] == 1) // being encoded
+               {
+                       fWorkingCount++;
+            fEncodingQueueItem = i;    
+               }
+        if ([[thisQueueDict objectForKey:@"Status"] intValue] == 2) // pending         
+        {
+                       fPendingCount++;
+               }
+        if ([[thisQueueDict objectForKey:@"Status"] intValue] == 3) // cancelled               
+        {
+                       fCanceledCount++;
+               }
+               i++;
+       }
+
+    /* Set the queue status field in the main window */
+    NSMutableString * string;
+    if (fPendingCount == 1)
+    {
+        string = [NSMutableString stringWithFormat: NSLocalizedString( @"%d encode pending in the queue", @"" ), fPendingCount];
+    }
+    else
+    {
+        string = [NSMutableString stringWithFormat: NSLocalizedString( @"%d encode(s) pending in the queue", @"" ), fPendingCount];
+    }
+    [fQueueStatus setStringValue:string];
+}
+
+/* This method will set any item marked as encoding back to pending
+ * currently used right after a queue reload
+ */
+- (void) setQueueEncodingItemsAsPending
+{
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+    NSMutableArray *tempArray;
+    tempArray = [NSMutableArray array];
+    /* we look here to see if the preset is we move on to the next one */
+    while ( tempObject = [enumerator nextObject] )  
+    {
+        /* If the queue item is marked as "encoding" (1)
+         * then change its status back to pending (2) which effectively
+         * puts it back into the queue to be encoded
+         */
+        if ([[tempObject objectForKey:@"Status"] intValue] == 1)
+        {
+            [tempObject setObject:[NSNumber numberWithInt: 2] forKey:@"Status"];
+        }
+        [tempArray addObject:tempObject];
+    }
+    
+    [QueueFileArray setArray:tempArray];
+    [self saveQueueFileItem];
+}
+
+
+/* This method will clear the queue of any encodes that are not still pending
+ * this includes both successfully completed encodes as well as cancelled encodes */
+- (void) clearQueueEncodedItems
+{
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+    NSMutableArray *tempArray;
+    tempArray = [NSMutableArray array];
+    /* we look here to see if the preset is we move on to the next one */
+    while ( tempObject = [enumerator nextObject] )  
+    {
+        /* If the queue item is either completed (0) or cancelled (3) from the
+         * last session, then we put it in tempArray to be deleted from QueueFileArray.
+         * NOTE: this means we retain pending (2) and also an item that is marked as
+         * still encoding (1). If the queue has an item that is still marked as encoding
+         * from a previous session, we can conlude that HB was either shutdown, or crashed
+         * during the encodes so we keep it and tell the user in the "Load Queue Alert"
+         */
+        if ([[tempObject objectForKey:@"Status"] intValue] == 0 || [[tempObject objectForKey:@"Status"] intValue] == 3)
+        {
+            [tempArray addObject:tempObject];
+        }
+    }
+    
+    [QueueFileArray removeObjectsInArray:tempArray];
+    [self saveQueueFileItem];
+}
+
+/* This method will clear the queue of all encodes. effectively creating an empty queue */
+- (void) clearQueueAllItems
+{
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+    NSMutableArray *tempArray;
+    tempArray = [NSMutableArray array];
+    /* we look here to see if the preset is we move on to the next one */
+    while ( tempObject = [enumerator nextObject] )  
+    {
+        [tempArray addObject:tempObject];
+    }
+    
+    [QueueFileArray removeObjectsInArray:tempArray];
+    [self saveQueueFileItem];
+}
+
+/* This method will duplicate prepareJob however into the
+ * queue .plist instead of into the job structure so it can
+ * be recalled later */
+- (NSDictionary *)createQueueFileItem
+{
+    NSMutableDictionary *queueFileJob = [[NSMutableDictionary alloc] init];
+    
+       hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,
+            [fSrcTitlePopUp indexOfSelectedItem] );
+    hb_job_t * job = title->job;
+    
+    
+    
+    /* We use a number system to set the encode status of the queue item
+     * 0 == already encoded
+     * 1 == is being encoded
+     * 2 == is yet to be encoded
+     * 3 == cancelled
+     */
+    [queueFileJob setObject:[NSNumber numberWithInt:2] forKey:@"Status"];
+    /* Source and Destination Information */
+    
+    [queueFileJob setObject:[NSString stringWithUTF8String: title->dvd] forKey:@"SourcePath"];
+    [queueFileJob setObject:[fSrcDVD2Field stringValue] forKey:@"SourceName"];
+    [queueFileJob setObject:[NSNumber numberWithInt:title->index] forKey:@"TitleNumber"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fSrcAnglePopUp indexOfSelectedItem] + 1] forKey:@"TitleAngle"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fSrcChapterStartPopUp indexOfSelectedItem] + 1] forKey:@"ChapterStart"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fSrcChapterEndPopUp indexOfSelectedItem] + 1] forKey:@"ChapterEnd"];
+    
+    [queueFileJob setObject:[fDstFile2Field stringValue] forKey:@"DestinationPath"];
+    
+    /* Lets get the preset info if there is any */
+    [queueFileJob setObject:[fPresetSelectedDisplay stringValue] forKey:@"PresetName"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPresetsOutlineView selectedRow]] forKey:@"PresetIndexNum"];
+    
+    [queueFileJob setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
+    /* Chapter Markers*/
+    /* If we have only one chapter or a title without chapters, set chapter markers to off */
+    if ([fSrcChapterStartPopUp indexOfSelectedItem] ==  [fSrcChapterEndPopUp indexOfSelectedItem])
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
+    }
+    else
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
+    }
+       
+    /* We need to get the list of chapter names to put into an array and store 
+     * in our queue, so they can be reapplied in prepareJob when this queue
+     * item comes up if Chapter Markers is set to on.
+     */
+     int i;
+     NSMutableArray *ChapterNamesArray = [[NSMutableArray alloc] init];
+     int chaptercount = hb_list_count( fTitle->list_chapter );
+     for( i = 0; i < chaptercount; i++ )
+    {
+        hb_chapter_t *chapter = (hb_chapter_t *) hb_list_item( fTitle->list_chapter, i );
+        if( chapter != NULL )
+        {
+          [ChapterNamesArray addObject:[NSString stringWithCString:chapter->title encoding:NSUTF8StringEncoding]];
+        }
+    }
+    [queueFileJob setObject:[NSMutableArray arrayWithArray: ChapterNamesArray] forKey:@"ChapterNames"];
+    [ChapterNamesArray autorelease];
+    
+    /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+       [queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4LargeFileCheck state]] forKey:@"Mp4LargeFile"];
+    /* Mux mp4 with http optimization */
+    [queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4HttpOptFileCheck state]] forKey:@"Mp4HttpOptimize"];
+    /* Add iPod uuid atom */
+    [queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4iPodFileCheck state]] forKey:@"Mp4iPodCompatible"];
+    
+    /* Codecs */
+       /* Video encoder */
+       [queueFileJob setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
+       /* x264 Option String */
+       [queueFileJob setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
+
+       [queueFileJob setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
+       [queueFileJob setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
+       [queueFileJob setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
+       [queueFileJob setObject:[NSNumber numberWithFloat:[fVidQualityRFField floatValue]] forKey:@"VideoQualitySlider"];
+    /* Framerate */
+    [queueFileJob setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
+    
+       /* 2 Pass Encoding */
+       [queueFileJob setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
+       /* Turbo 2 pass Encoding fVidTurboPassCheck*/
+       [queueFileJob setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
+    
+       /* Picture Sizing */
+       /* Use Max Picture settings for whatever the dvd is.*/
+       [queueFileJob setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
+    /* if we are custom anamorphic, store the exact storage, par and display dims */
+    if (fTitle->job->anamorphic.mode == 3)
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.modulus] forKey:@"PicturePARModulus"];
+        
+        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PicturePARStorageWidth"];
+        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PicturePARStorageHeight"];
+        
+        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.par_width] forKey:@"PicturePARPixelWidth"];
+        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.par_height] forKey:@"PicturePARPixelHeight"];
+        
+        [queueFileJob setObject:[NSNumber numberWithFloat:fTitle->job->anamorphic.dar_width] forKey:@"PicturePARDisplayWidth"];
+        [queueFileJob setObject:[NSNumber numberWithFloat:fTitle->job->anamorphic.dar_height] forKey:@"PicturePARDisplayHeight"];
+
+    }
+    NSString * pictureSummary;
+    pictureSummary = [fPictureSizeField stringValue];
+    [queueFileJob setObject:pictureSummary forKey:@"PictureSizingSummary"];                 
+    /* Set crop settings here */
+       [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
+    [queueFileJob setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
+    [queueFileJob setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
+       [queueFileJob setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
+       [queueFileJob setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
+    
+    /* Picture Filters */
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
+    [queueFileJob setObject:[fPictureController detelecineCustomString] forKey:@"PictureDetelecineCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController useDecomb]] forKey:@"PictureDecombDeinterlace"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController decomb]] forKey:@"PictureDecomb"];
+    [queueFileJob setObject:[fPictureController decombCustomString] forKey:@"PictureDecombCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
+    [queueFileJob setObject:[fPictureController deinterlaceCustomString] forKey:@"PictureDeinterlaceCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
+    [queueFileJob setObject:[fPictureController denoiseCustomString] forKey:@"PictureDenoiseCustom"];
+    
+    [queueFileJob setObject:[NSString stringWithFormat:@"%d",[fPictureController deblock]] forKey:@"PictureDeblock"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController grayscale]] forKey:@"VideoGrayScale"];
+    
+    /*Audio*/
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:[fAudLang1PopUp indexOfSelectedItem]] forKey:@"Audio1Track"];
+        [queueFileJob setObject:[fAudLang1PopUp titleOfSelectedItem] forKey:@"Audio1TrackDescription"];
+        [queueFileJob setObject:[fAudTrack1CodecPopUp titleOfSelectedItem] forKey:@"Audio1Encoder"];
+        [queueFileJob setObject:[fAudTrack1MixPopUp titleOfSelectedItem] forKey:@"Audio1Mixdown"];
+        [queueFileJob setObject:[fAudTrack1RatePopUp titleOfSelectedItem] forKey:@"Audio1Samplerate"];
+        [queueFileJob setObject:[fAudTrack1BitratePopUp titleOfSelectedItem] forKey:@"Audio1Bitrate"];
+        [queueFileJob setObject:[NSNumber numberWithFloat:[fAudTrack1DrcSlider floatValue]] forKey:@"Audio1TrackDRCSlider"];
+    }
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:[fAudLang2PopUp indexOfSelectedItem]] forKey:@"Audio2Track"];
+        [queueFileJob setObject:[fAudLang2PopUp titleOfSelectedItem] forKey:@"Audio2TrackDescription"];
+        [queueFileJob setObject:[fAudTrack2CodecPopUp titleOfSelectedItem] forKey:@"Audio2Encoder"];
+        [queueFileJob setObject:[fAudTrack2MixPopUp titleOfSelectedItem] forKey:@"Audio2Mixdown"];
+        [queueFileJob setObject:[fAudTrack2RatePopUp titleOfSelectedItem] forKey:@"Audio2Samplerate"];
+        [queueFileJob setObject:[fAudTrack2BitratePopUp titleOfSelectedItem] forKey:@"Audio2Bitrate"];
+        [queueFileJob setObject:[NSNumber numberWithFloat:[fAudTrack2DrcSlider floatValue]] forKey:@"Audio2TrackDRCSlider"];
+    }
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:[fAudLang3PopUp indexOfSelectedItem]] forKey:@"Audio3Track"];
+        [queueFileJob setObject:[fAudLang3PopUp titleOfSelectedItem] forKey:@"Audio3TrackDescription"];
+        [queueFileJob setObject:[fAudTrack3CodecPopUp titleOfSelectedItem] forKey:@"Audio3Encoder"];
+        [queueFileJob setObject:[fAudTrack3MixPopUp titleOfSelectedItem] forKey:@"Audio3Mixdown"];
+        [queueFileJob setObject:[fAudTrack3RatePopUp titleOfSelectedItem] forKey:@"Audio3Samplerate"];
+        [queueFileJob setObject:[fAudTrack3BitratePopUp titleOfSelectedItem] forKey:@"Audio3Bitrate"];
+        [queueFileJob setObject:[NSNumber numberWithFloat:[fAudTrack3DrcSlider floatValue]] forKey:@"Audio3TrackDRCSlider"];
+    }
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        [queueFileJob setObject:[NSNumber numberWithInt:[fAudLang4PopUp indexOfSelectedItem]] forKey:@"Audio4Track"];
+        [queueFileJob setObject:[fAudLang4PopUp titleOfSelectedItem] forKey:@"Audio4TrackDescription"];
+        [queueFileJob setObject:[fAudTrack4CodecPopUp titleOfSelectedItem] forKey:@"Audio4Encoder"];
+        [queueFileJob setObject:[fAudTrack4MixPopUp titleOfSelectedItem] forKey:@"Audio4Mixdown"];
+        [queueFileJob setObject:[fAudTrack4RatePopUp titleOfSelectedItem] forKey:@"Audio4Samplerate"];
+        [queueFileJob setObject:[fAudTrack4BitratePopUp titleOfSelectedItem] forKey:@"Audio4Bitrate"];
+        [queueFileJob setObject:[NSNumber numberWithFloat:[fAudTrack4DrcSlider floatValue]] forKey:@"Audio4TrackDRCSlider"];
+    }
+    
+       /* Subtitles*/
+    NSMutableArray *subtitlesArray = [[NSMutableArray alloc] init];
+    [queueFileJob setObject:[NSArray arrayWithArray: [fSubtitlesDelegate getSubtitleArray: subtitlesArray]] forKey:@"SubtitleList"];
+    [subtitlesArray autorelease];
+
+    /* Now we go ahead and set the "job->values in the plist for passing right to fQueueEncodeLibhb */
+     
+    [queueFileJob setObject:[NSNumber numberWithInt:[fSrcChapterStartPopUp indexOfSelectedItem] + 1] forKey:@"JobChapterStart"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fSrcChapterEndPopUp indexOfSelectedItem] + 1] forKey:@"JobChapterEnd"];
+    
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[[fDstFormatPopUp selectedItem] tag]] forKey:@"JobFileFormatMux"];
+    
+    /* Codecs */
+       /* Video encoder */
+       [queueFileJob setObject:[NSNumber numberWithInt:[[fVidEncoderPopUp selectedItem] tag]] forKey:@"JobVideoEncoderVcodec"];
+       
+    /* Framerate */
+    [queueFileJob setObject:[NSNumber numberWithInt:[fVidRatePopUp indexOfSelectedItem]] forKey:@"JobIndexVideoFramerate"];
+    [queueFileJob setObject:[NSNumber numberWithInt:title->rate] forKey:@"JobVrate"];
+    [queueFileJob setObject:[NSNumber numberWithInt:title->rate_base] forKey:@"JobVrateBase"];
+       
+    /* Picture Sizing */
+       /* Use Max Picture settings for whatever the dvd is.*/
+       [queueFileJob setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
+    
+    /* Set crop settings here */
+       [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
+    [queueFileJob setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
+    [queueFileJob setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
+       [queueFileJob setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
+       [queueFileJob setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
+    
+    
+    /*Audio*/
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+    {
+        //[queueFileJob setObject:[fAudTrack1CodecPopUp indexOfSelectedItem] forKey:@"JobAudio1Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack1CodecPopUp selectedItem] tag]] forKey:@"JobAudio1Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack1MixPopUp selectedItem] tag]] forKey:@"JobAudio1Mixdown"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack1RatePopUp selectedItem] tag]] forKey:@"JobAudio1Samplerate"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack1BitratePopUp selectedItem] tag]] forKey:@"JobAudio1Bitrate"];
+     }
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        //[queueFileJob setObject:[fAudTrack1CodecPopUp indexOfSelectedItem] forKey:@"JobAudio2Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack2CodecPopUp selectedItem] tag]] forKey:@"JobAudio2Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack2MixPopUp selectedItem] tag]] forKey:@"JobAudio2Mixdown"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack2RatePopUp selectedItem] tag]] forKey:@"JobAudio2Samplerate"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack2BitratePopUp selectedItem] tag]] forKey:@"JobAudio2Bitrate"];
+    }
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        //[queueFileJob setObject:[fAudTrack1CodecPopUp indexOfSelectedItem] forKey:@"JobAudio3Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack3CodecPopUp selectedItem] tag]] forKey:@"JobAudio3Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack3MixPopUp selectedItem] tag]] forKey:@"JobAudio3Mixdown"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack3RatePopUp selectedItem] tag]] forKey:@"JobAudio3Samplerate"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack3BitratePopUp selectedItem] tag]] forKey:@"JobAudio3Bitrate"];
+    }
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        //[queueFileJob setObject:[fAudTrack1CodecPopUp indexOfSelectedItem] forKey:@"JobAudio4Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack4CodecPopUp selectedItem] tag]] forKey:@"JobAudio4Encoder"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack4MixPopUp selectedItem] tag]] forKey:@"JobAudio4Mixdown"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack4RatePopUp selectedItem] tag]] forKey:@"JobAudio4Samplerate"];
+        [queueFileJob setObject:[NSNumber numberWithInt:[[fAudTrack4BitratePopUp selectedItem] tag]] forKey:@"JobAudio4Bitrate"];
+    }
+
+    /* we need to auto relase the queueFileJob and return it */
+    [queueFileJob autorelease];
+    return queueFileJob;
+
+}
+
+/* this is actually called from the queue controller to modify the queue array and return it back to the queue controller */
+- (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex
+{
+    NSUInteger index = [indexSet lastIndex];
+    NSUInteger aboveInsertIndexCount = 0;
+    
+    
+    NSUInteger removeIndex;
+        
+    if (index >= insertIndex)
+    {
+        removeIndex = index + aboveInsertIndexCount;
+        aboveInsertIndexCount++;
+    }
+    else
+    {
+        removeIndex = index;
+        insertIndex--;
+    }
+
+    id object = [[QueueFileArray objectAtIndex:removeIndex] retain];
+    [QueueFileArray removeObjectAtIndex:removeIndex];
+    [QueueFileArray insertObject:object atIndex:insertIndex];
+    [object release];
+        
+    index = [indexSet indexLessThanIndex:index];
+
+   /* We save all of the Queue data here 
+    * and it also gets sent back to the queue controller*/
+    [self saveQueueFileItem]; 
+    
+}
+
+
+#pragma mark -
+#pragma mark Queue Job Processing
+
+- (void) incrementQueueItemDone:(int) queueItemDoneIndexNum
+{
+    int i = currentQueueEncodeIndex;
+    [[QueueFileArray objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Status"];
+       
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+       /* We Reload the New Table data for presets */
+    //[fPresetsOutlineView reloadData];
+
+    /* Since we have now marked a queue item as done
+     * we can go ahead and increment currentQueueEncodeIndex 
+     * so that if there is anything left in the queue we can
+     * go ahead and move to the next item if we want to */
+    currentQueueEncodeIndex++ ;
+    [self writeToActivityLog: "incrementQueueItemDone currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
+    int queueItems = [QueueFileArray count];
+    /* If we still have more items in our queue, lets go to the next one */
+    if (currentQueueEncodeIndex < queueItems)
+    {
+    [self writeToActivityLog: "incrementQueueItemDone currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
+    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
+    }
+    else
+    {
+        [self writeToActivityLog: "incrementQueueItemDone the %d item queue is complete", currentQueueEncodeIndex - 1];
+    }
+}
+
+/* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/
+- (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum
+{
+   /* Tell HB to output a new activity log file for this encode */
+    [outputPanel startEncodeLog:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"DestinationPath"]];
+    
+    
+     /* use a bool to determine whether or not we can decrypt using vlc */
+    BOOL cancelScanDecrypt = 0;
+    /* set the bool so that showNewScan knows to apply the appropriate queue
+    * settings as this is a queue rescan
+    */
+    applyQueueToScan = YES;
+    NSString *path = scanPath;
+    HBDVDDetector *detector = [HBDVDDetector detectorForPath:path];
+
+        /*On Screen Notification*/
+        //int status;
+        //status = NSRunAlertPanel(@"HandBrake is now loading up a new queue item...",@"Would You Like to wait until you add another encode?", @"Cancel", @"Okay", nil);
+        //[NSApp requestUserAttention:NSCriticalRequest];
+
+    if( [detector isVideoDVD] )
+    {
+        // The chosen path was actually on a DVD, so use the raw block
+        // device path instead.
+        path = [detector devicePath];
+        [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]];
+
+        /* lets check for vlc here to make sure we have a dylib available to use for decrypting */
+        NSString *vlcPath = @"/Applications/VLC.app";
+        NSFileManager * fileManager = [NSFileManager defaultManager];
+           if ([fileManager fileExistsAtPath:vlcPath] == 0) 
+           {
+            /*vlc not found in /Applications so we set the bool to cancel scanning to 1 */
+            cancelScanDecrypt = 1;
+            [self writeToActivityLog: "VLC app not found for decrypting physical dvd"];
+            int status;
+            status = NSRunAlertPanel(@"HandBrake could not find VLC.",@"Please download and install VLC media player in your /Applications folder if you wish to read encrypted DVDs.", @"Get VLC", @"Cancel Scan", @"Attempt Scan Anyway");
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            if (status == NSAlertDefaultReturn)
+            {
+                /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */
+                [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/"]];
+            }
+            else if (status == NSAlertAlternateReturn)
+            {
+            /* User chose to cancel the scan */
+            [self writeToActivityLog: "cannot open physical dvd , scan cancelled"];
+            }
+            else
+            {
+            /* User chose to override our warning and scan the physical dvd anyway, at their own peril. on an encrypted dvd this produces massive log files and fails */
+            cancelScanDecrypt = 0;
+            [self writeToActivityLog: "user overrode vlc warning -trying to open physical dvd without decryption"];
+            }
+
+        }
+        else
+        {
+            /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */
+            [self writeToActivityLog: "VLC app found for decrypting physical dvd"];
+        }
+    }
+
+    if (cancelScanDecrypt == 0)
+    {
+        /* we actually pass the scan off to libhb here */
+        /* If there is no title number passed to scan, we use "0"
+         * which causes the default behavior of a full source scan
+         */
+        if (!scanTitleNum)
+        {
+            scanTitleNum = 0;
+        }
+        if (scanTitleNum > 0)
+        {
+            [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
+        }
+        
+        [self writeToActivityLog: "performNewQueueScan currentQueueEncodeIndex is: %d", currentQueueEncodeIndex];
+        /* We use our advance pref to determine how many previews to scan */
+        int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+        hb_scan( fQueueEncodeLibhb, [path UTF8String], scanTitleNum, hb_num_previews, 0 );
+    }
+}
+
+/* This method was originally used to load up a new queue item in the gui and
+ * then start processing it. However we now have modified -prepareJob and use a second
+ * instance of libhb to do our actual encoding, therefor right now it is not required. 
+ * Nonetheless I want to leave this in here
+ * because basically its everything we need to be able to actually modify a pending queue
+ * item in the gui and resave it. At least for now - dynaflash
+ */
+
+- (IBAction)applyQueueSettings:(id)sender
+{
+    NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
+    hb_job_t * job = fTitle->job;
+    
+    /* Set title number and chapters */
+    /* since the queue only scans a single title, we really don't need to pick a title */
+    //[fSrcTitlePopUp selectItemAtIndex: [[queueToApply objectForKey:@"TitleNumber"] intValue] - 1];
+    
+    [fSrcChapterStartPopUp selectItemAtIndex: [[queueToApply objectForKey:@"ChapterStart"] intValue] - 1];
+    [fSrcChapterEndPopUp selectItemAtIndex: [[queueToApply objectForKey:@"ChapterEnd"] intValue] - 1];
+    
+    /* File Format */
+    [fDstFormatPopUp selectItemWithTitle:[queueToApply objectForKey:@"FileFormat"]];
+    [self formatPopUpChanged:nil];
+    
+    /* Chapter Markers*/
+    [fCreateChapterMarkers setState:[[queueToApply objectForKey:@"ChapterMarkers"] intValue]];
+    /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+    [fDstMp4LargeFileCheck setState:[[queueToApply objectForKey:@"Mp4LargeFile"] intValue]];
+    /* Mux mp4 with http optimization */
+    [fDstMp4HttpOptFileCheck setState:[[queueToApply objectForKey:@"Mp4HttpOptimize"] intValue]];
+    
+    /* Video encoder */
+    /* We set the advanced opt string here if applicable*/
+    [fVidEncoderPopUp selectItemWithTitle:[queueToApply objectForKey:@"VideoEncoder"]];
+    [fAdvancedOptions setOptions:[queueToApply objectForKey:@"x264Option"]];
+    
+    /* Lets run through the following functions to get variables set there */
+    [self videoEncoderPopUpChanged:nil];
+    /* Set the state of ipod compatible with Mp4iPodCompatible. Only for x264*/
+    [fDstMp4iPodFileCheck setState:[[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue]];
+    [self calculateBitrate:nil];
+    
+    /* Video quality */
+    [fVidQualityMatrix selectCellAtRow:[[queueToApply objectForKey:@"VideoQualityType"] intValue] column:0];
+    
+    [fVidTargetSizeField setStringValue:[queueToApply objectForKey:@"VideoTargetSize"]];
+    [fVidBitrateField setStringValue:[queueToApply objectForKey:@"VideoAvgBitrate"]];
+    [fVidQualitySlider setFloatValue:[[queueToApply objectForKey:@"VideoQualitySlider"] floatValue]];
+    
+    [self videoMatrixChanged:nil];
+    
+    /* Video framerate */
+    /* For video preset video framerate, we want to make sure that Same as source does not conflict with the
+     detected framerate in the fVidRatePopUp so we use index 0*/
+    if ([[queueToApply objectForKey:@"VideoFramerate"] isEqualToString:@"Same as source"])
+    {
+        [fVidRatePopUp selectItemAtIndex: 0];
+    }
+    else
+    {
+        [fVidRatePopUp selectItemWithTitle:[queueToApply objectForKey:@"VideoFramerate"]];
+    }
+    
+    /* 2 Pass Encoding */
+    [fVidTwoPassCheck setState:[[queueToApply objectForKey:@"VideoTwoPass"] intValue]];
+    [self twoPassCheckboxChanged:nil];
+    /* Turbo 1st pass for 2 Pass Encoding */
+    [fVidTurboPassCheck setState:[[queueToApply objectForKey:@"VideoTurboTwoPass"] intValue]];
+    
+    /*Audio*/
+    if ([queueToApply objectForKey:@"Audio1Track"] > 0)
+    {
+        if ([fAudLang1PopUp indexOfSelectedItem] == 0)
+        {
+            [fAudLang1PopUp selectItemAtIndex: 1];
+        }
+        [self audioTrackPopUpChanged: fAudLang1PopUp];
+        [fAudTrack1CodecPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio1Encoder"]];
+        [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
+        [fAudTrack1MixPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio1Mixdown"]];
+        /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+         * mixdown*/
+        if  ([fAudTrack1MixPopUp selectedItem] == nil)
+        {
+            [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
+        }
+        [fAudTrack1RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Samplerate"]];
+        /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+        if (![[queueToApply objectForKey:@"Audio1Encoder"] isEqualToString:@"AC3 Passthru"])
+        {
+            [fAudTrack1BitratePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio1Bitrate"]];
+        }
+        [fAudTrack1DrcSlider setFloatValue:[[queueToApply objectForKey:@"Audio1TrackDRCSlider"] floatValue]];
+        [self audioDRCSliderChanged: fAudTrack1DrcSlider];
+    }
+    if ([queueToApply objectForKey:@"Audio2Track"] > 0)
+    {
+        if ([fAudLang2PopUp indexOfSelectedItem] == 0)
+        {
+            [fAudLang2PopUp selectItemAtIndex: 1];
+        }
+        [self audioTrackPopUpChanged: fAudLang2PopUp];
+        [fAudTrack2CodecPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio2Encoder"]];
+        [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
+        [fAudTrack2MixPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio2Mixdown"]];
+        /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+         * mixdown*/
+        if  ([fAudTrack2MixPopUp selectedItem] == nil)
+        {
+            [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
+        }
+        [fAudTrack2RatePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio2Samplerate"]];
+        /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+        if (![[queueToApply objectForKey:@"Audio2Encoder"] isEqualToString:@"AC3 Passthru"])
+        {
+            [fAudTrack2BitratePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio2Bitrate"]];
+        }
+        [fAudTrack2DrcSlider setFloatValue:[[queueToApply objectForKey:@"Audio2TrackDRCSlider"] floatValue]];
+        [self audioDRCSliderChanged: fAudTrack2DrcSlider];
+    }
+    if ([queueToApply objectForKey:@"Audio3Track"] > 0)
+    {
+        if ([fAudLang3PopUp indexOfSelectedItem] == 0)
+        {
+            [fAudLang3PopUp selectItemAtIndex: 1];
+        }
+        [self audioTrackPopUpChanged: fAudLang3PopUp];
+        [fAudTrack3CodecPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio3Encoder"]];
+        [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
+        [fAudTrack3MixPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio3Mixdown"]];
+        /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+         * mixdown*/
+        if  ([fAudTrack3MixPopUp selectedItem] == nil)
+        {
+            [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
+        }
+        [fAudTrack3RatePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio3Samplerate"]];
+        /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+        if (![[queueToApply objectForKey:@"Audio3Encoder"] isEqualToString: @"AC3 Passthru"])
+        {
+            [fAudTrack3BitratePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio3Bitrate"]];
+        }
+        [fAudTrack3DrcSlider setFloatValue:[[queueToApply objectForKey:@"Audio3TrackDRCSlider"] floatValue]];
+        [self audioDRCSliderChanged: fAudTrack3DrcSlider];
+    }
+    if ([queueToApply objectForKey:@"Audio4Track"] > 0)
+    {
+        if ([fAudLang4PopUp indexOfSelectedItem] == 0)
+        {
+            [fAudLang4PopUp selectItemAtIndex: 1];
+        }
+        [self audioTrackPopUpChanged: fAudLang4PopUp];
+        [fAudTrack4CodecPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio4Encoder"]];
+        [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
+        [fAudTrack4MixPopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio4Mixdown"]];
+        /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+         * mixdown*/
+        if  ([fAudTrack4MixPopUp selectedItem] == nil)
+        {
+            [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
+        }
+        [fAudTrack4RatePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio4Samplerate"]];
+        /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+        if (![[chosenPreset objectForKey:@"Audio4Encoder"] isEqualToString:@"AC3 Passthru"])
+        {
+            [fAudTrack4BitratePopUp selectItemWithTitle:[queueToApply objectForKey:@"Audio4Bitrate"]];
+        }
+        [fAudTrack4DrcSlider setFloatValue:[[queueToApply objectForKey:@"Audio4TrackDRCSlider"] floatValue]];
+        [self audioDRCSliderChanged: fAudTrack4DrcSlider];
+    }
+    
+    
+    /*Subtitles*/
+    [fSubPopUp selectItemWithTitle:[queueToApply objectForKey:@"Subtitles"]];
+    /* Forced Subtitles */
+    [fSubForcedCheck setState:[[queueToApply objectForKey:@"SubtitlesForced"] intValue]];
+    
+    /* Picture Settings */
+    /* we check to make sure the presets width/height does not exceed the sources width/height */
+    if (fTitle->width < [[queueToApply objectForKey:@"PictureWidth"]  intValue] || fTitle->height < [[queueToApply objectForKey:@"PictureHeight"]  intValue])
+    {
+        /* if so, then we use the sources height and width to avoid scaling up */
+        job->width = fTitle->width;
+        job->height = fTitle->height;
+    }
+    else // source width/height is >= the preset height/width
+    {
+        /* we can go ahead and use the presets values for height and width */
+        job->width = [[queueToApply objectForKey:@"PictureWidth"]  intValue];
+        job->height = [[queueToApply objectForKey:@"PictureHeight"]  intValue];
+    }
+    job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"]  intValue];
+    if (job->keep_ratio == 1)
+    {
+        hb_fix_aspect( job, HB_KEEP_WIDTH );
+        if( job->height > fTitle->height )
+        {
+            job->height = fTitle->height;
+            hb_fix_aspect( job, HB_KEEP_HEIGHT );
+        }
+    }
+    job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
+    
+    
+    /* If Cropping is set to custom, then recall all four crop values from
+     when the preset was created and apply them */
+    if ([[queueToApply objectForKey:@"PictureAutoCrop"]  intValue] == 0)
+    {
+        [fPictureController setAutoCrop:NO];
+        
+        /* Here we use the custom crop values saved at the time the preset was saved */
+        job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"]  intValue];
+        job->crop[1] = [[queueToApply objectForKey:@"PictureBottomCrop"]  intValue];
+        job->crop[2] = [[queueToApply objectForKey:@"PictureLeftCrop"]  intValue];
+        job->crop[3] = [[queueToApply objectForKey:@"PictureRightCrop"]  intValue];
+        
+    }
+    else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
+    {
+        [fPictureController setAutoCrop:YES];
+        /* Here we use the auto crop values determined right after scan */
+        job->crop[0] = AutoCropTop;
+        job->crop[1] = AutoCropBottom;
+        job->crop[2] = AutoCropLeft;
+        job->crop[3] = AutoCropRight;
+        
+    }
+    
+    /* Filters */
+    /* Deinterlace */
+    [fPictureController setDeinterlace:[[queueToApply objectForKey:@"PictureDeinterlace"] intValue]];
+    
+    /* Detelecine */
+    [fPictureController setDetelecine:[[queueToApply objectForKey:@"PictureDetelecine"] intValue]];
+    /* Denoise */
+    [fPictureController setDenoise:[[queueToApply objectForKey:@"PictureDenoise"] intValue]];
+    /* Deblock */
+    [fPictureController setDeblock:[[queueToApply objectForKey:@"PictureDeblock"] intValue]];
+    /* Decomb */
+    [fPictureController setDecomb:[[queueToApply objectForKey:@"PictureDecomb"] intValue]];
+    /* Grayscale */
+    [fPictureController setGrayscale:[[queueToApply objectForKey:@"VideoGrayScale"] intValue]];
+    
+    [self calculatePictureSizing:nil];
+    
+    
+    /* somehow we need to figure out a way to tie the queue item to a preset if it used one */
+    //[queueFileJob setObject:[fPresetSelectedDisplay stringValue] forKey:@"PresetName"];
+    //    [queueFileJob setObject:[NSNumber numberWithInt:[fPresetsOutlineView selectedRow]] forKey:@"PresetIndexNum"];
+    if ([queueToApply objectForKey:@"PresetIndexNum"]) // This item used a preset so insert that info
+       {
+               /* Deselect the currently selected Preset if there is one*/
+        //[fPresetsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[[queueToApply objectForKey:@"PresetIndexNum"] intValue]] byExtendingSelection:NO];
+        //[self selectPreset:nil];
+               
+        //[fPresetsOutlineView selectRow:[[queueToApply objectForKey:@"PresetIndexNum"] intValue]];
+               /* Change UI to show "Custom" settings are being used */
+               //[fPresetSelectedDisplay setStringValue: [[queueToApply objectForKey:@"PresetName"] stringValue]];
+        
+               curUserPresetChosenNum = nil;
+       }
+    else
+    {
+        /* Deselect the currently selected Preset if there is one*/
+               [fPresetsOutlineView deselectRow:[fPresetsOutlineView selectedRow]];
+               /* Change UI to show "Custom" settings are being used */
+               [fPresetSelectedDisplay setStringValue: @"Custom"];
+        
+               //curUserPresetChosenNum = nil;
+    }
+    
+    /* We need to set this bool back to NO, in case the user wants to do a scan */
+    //applyQueueToScan = NO;
+    
+    /* so now we go ahead and process the new settings */
+    [self processNewQueueEncode];
+}
+
+
+
+/* This assumes that we have re-scanned and loaded up a new queue item to send to libhb as fQueueEncodeLibhb */
+- (void) processNewQueueEncode
+{
+    hb_list_t  * list  = hb_get_titles( fQueueEncodeLibhb );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan
+    hb_job_t * job = title->job;
+    
+    if( !hb_list_count( list ) )
+    {
+        [self writeToActivityLog: "processNewQueueEncode WARNING nothing found in the title list"];
+    }
+    
+    NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
+    [self writeToActivityLog: "Preset: %s", [[queueToApply objectForKey:@"PresetName"] UTF8String]];
+    [self writeToActivityLog: "processNewQueueEncode number of passes expected is: %d", ([[queueToApply objectForKey:@"VideoTwoPass"] intValue] + 1)];
+    job->file = [[queueToApply objectForKey:@"DestinationPath"] UTF8String];
+    //[self writeToActivityLog: "processNewQueueEncode sending to prepareJob"];
+    [self prepareJob];
+    
+    /*
+     * If scanning we need to do some extra setup of the job.
+     */
+    if( job->indepth_scan == 1 )
+    {
+        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->indepth_scan = 1;  
+
+        
+        /*
+         * Add the pre-scan job
+         */
+        hb_add( fQueueEncodeLibhb, job );
+        job->x264opts = x264opts_tmp;
+    }
+
+    
+    if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 )
+    {
+        job->indepth_scan = 0;
+        
+
+        
+        job->pass = 1;
+        
+        hb_add( fQueueEncodeLibhb, job );
+        
+        job->pass = 2;
+        
+        job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */  
+        strcpy(job->x264opts, [[queueToApply objectForKey:@"x264Option"] UTF8String]);
+        
+        hb_add( fQueueEncodeLibhb, job );
+        
+    }
+    else
+    {
+        job->indepth_scan = 0;
+        job->pass = 0;
+        
+        hb_add( fQueueEncodeLibhb, job );
+    }
+       
+    NSString *destinationDirectory = [[queueToApply objectForKey:@"DestinationPath"] stringByDeletingLastPathComponent];
+       [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
+       /* Lets mark our new encode as 1 or "Encoding" */
+    [queueToApply setObject:[NSNumber numberWithInt:1] forKey:@"Status"];
+    [self saveQueueFileItem];
+    
+    /* we need to clean up the subtitle tracks after the job(s) have been set  */
+    int num_subtitle_tracks = hb_list_count(job->list_subtitle);
+    int ii;
+    for(ii = 0; ii < num_subtitle_tracks; ii++)
+    {
+        hb_subtitle_t * subtitle;
+        subtitle = (hb_subtitle_t *)hb_list_item(job->list_subtitle, 0);
+        
+
+        hb_list_rem(job->list_subtitle, subtitle);
+        free(subtitle);
+    }
+    
+    
+    /* We should be all setup so let 'er rip */   
+    [self doRip];
+}
+
+#pragma mark -
+#pragma mark Live Preview
+/* Note,this is much like prepareJob, but directly sets the job vars so Picture Preview
+ * can encode to its temp preview directory and playback. This is *not* used for any actual user
+ * encodes
+ */
+- (void) prepareJobForPreview
+{
+    hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,
+            [fSrcTitlePopUp indexOfSelectedItem] );
+    hb_job_t * job = title->job;
+    hb_audio_config_t * audio;
+    /* set job->angle for libdvdnav */
+    job->angle = [fSrcAnglePopUp indexOfSelectedItem] + 1;
+    /* Chapter selection */
+    job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
+    job->chapter_end   = [fSrcChapterEndPopUp   indexOfSelectedItem] + 1;
+       
+    /* Format (Muxer) and Video Encoder */
+    job->mux = [[fDstFormatPopUp selectedItem] tag];
+    job->vcodec = [[fVidEncoderPopUp selectedItem] tag];
+
+    job->chapter_markers = 0;
+    
+       if( job->vcodec & HB_VCODEC_X264 )
+    {
+               
+               /* Below Sends x264 options to the core library if x264 is selected*/
+               /* Lets use this as per Nyx, Thanks Nyx!*/
+               job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
+               /* For previews we ignore the turbo option for the first pass of two since we only use 1 pass */
+               strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
+
+        
+    }
+
+    /* Video settings */
+   /* Set vfr to 0 as it's only on if using same as source in the framerate popup
+     * and detelecine is on, so we handle that in the logic below
+     */
+    job->vfr = 0;
+    if( [fVidRatePopUp indexOfSelectedItem] > 0 )
+    {
+        /* a specific framerate has been chosen */
+        job->vrate      = 27000000;
+        job->vrate_base = hb_video_rates[[fVidRatePopUp indexOfSelectedItem]-1].rate;
+        /* We are not same as source so we set job->cfr to 1 
+         * to enable constant frame rate since user has specified
+         * a specific framerate*/
+        job->cfr = 1;
+    }
+    else
+    {
+        /* We are same as source (variable) */
+        job->vrate      = title->rate;
+        job->vrate_base = title->rate_base;
+        /* We are same as source so we set job->cfr to 0 
+         * to enable true same as source framerate */
+        job->cfr = 0;
+        /* If we are same as source and we have detelecine on, we need to turn on
+         * job->vfr
+         */
+        if ([fPictureController detelecine] == 1)
+        {
+            job->vfr = 1;
+        }
+    }
+
+    switch( [fVidQualityMatrix selectedRow] )
+    {
+        case 0:
+            /* Target size.
+               Bitrate should already have been calculated and displayed
+               in fVidBitrateField, so let's just use it */
+        case 1:
+            job->vquality = -1.0;
+            job->vbitrate = [fVidBitrateField intValue];
+            break;
+        case 2:
+            job->vquality = [fVidQualityRFField floatValue];
+            job->vbitrate = 0;
+            break;
+    }
+
+    /* Subtitle settings */
+    NSMutableArray *subtitlesArray = nil;
+    subtitlesArray = [[NSMutableArray alloc] initWithArray:[fSubtitlesDelegate getSubtitleArray: subtitlesArray]];
+    
+    
+    
+ int subtitle = nil;
+int force;
+int burned;
+int def;
+bool one_burned = FALSE;
+
+    int i = 0;
+    NSEnumerator *enumerator = [subtitlesArray objectEnumerator];
+    id tempObject;
+    while (tempObject = [enumerator nextObject])
+    {
+        
+        subtitle = [[tempObject objectForKey:@"subtitleSourceTrackNum"] intValue];
+        force = [[tempObject objectForKey:@"subtitleTrackForced"] intValue];
+        burned = [[tempObject objectForKey:@"subtitleTrackBurned"] intValue];
+        def = [[tempObject objectForKey:@"subtitleTrackDefault"] intValue];
+        
+        /* since the subtitleSourceTrackNum 0 is "None" in our array of the subtitle popups,
+         * we want to ignore it for display as well as encoding.
+         */
+        if (subtitle > 0)
+        {
+            /* if i is 0, then we are in the first item of the subtitles which we need to 
+             * check for the "Foreign Audio Search" which would be subtitleSourceTrackNum of 1
+             * bearing in mind that for all tracks subtitleSourceTrackNum of 0 is None.
+             */
+            
+            /* if we are on the first track and using "Foreign Audio Search" */ 
+            if (i == 0 && subtitle == 1)
+            {
+                /* NOTE: Currently foreign language search is borked for preview.
+                 * Commented out but left in for initial commit. */
+                
+                
+                [self writeToActivityLog: "Foreign Language Search: %d", 1];
+                
+                job->indepth_scan = 1;
+                if (burned == 1 || job->mux != HB_MUX_MP4)
+                {
+                    if (burned != 1 && job->mux == HB_MUX_MKV)
+                    {
+                        job->select_subtitle_config.dest = PASSTHRUSUB;
+                    }
+                    else
+                    {
+                        job->select_subtitle_config.dest = RENDERSUB;
+                    }
+                    
+                    job->select_subtitle_config.force = force;
+                    job->select_subtitle_config.default_track = def;
+                    
+                }
+                
+                
+            }
+            else
+            {
+                
+                /* for the actual source tracks, we must subtract the non source entries so 
+                 * that the menu index matches the source subtitle_list index for convenience */
+                if (i == 0)
+                {
+                    /* for the first track, the source tracks start at menu index 2 ( None is 0,
+                     * Foreign Language Search is 1) so subtract 2 */
+                    subtitle = subtitle - 2;
+                }
+                else
+                {
+                    /* for all other tracks, the source tracks start at menu index 1 (None is 0)
+                     * so subtract 1. */
+                    
+                    subtitle = subtitle - 1;
+                }
+                
+                /* We are setting a source subtitle so access the source subtitle info */  
+                hb_subtitle_t * subt;
+                
+                subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
+                
+                /* if we are getting the subtitles from an external srt file */
+                if ([[tempObject objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"])
+                {
+                    hb_subtitle_config_t sub_config;
+                    
+                    sub_config.offset = [[tempObject objectForKey:@"subtitleTrackSrtOffset"] intValue];
+                    
+                    /* we need to srncpy file path and char code */
+                    strncpy(sub_config.src_filename, [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String], 128);
+                    strncpy(sub_config.src_codeset, [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String], 40);
+                    
+                    sub_config.force = 0;
+                    sub_config.dest = PASSTHRUSUB;
+                    sub_config.default_track = def;
+                    
+                    hb_srt_add( job, &sub_config, [[tempObject objectForKey:@"subtitleTrackSrtLanguageIso3"] UTF8String]);
+                }
+                
+                if (subt != NULL)
+                {
+                    [self writeToActivityLog: "Setting Subtitle: %s", subt];
+
+                    hb_subtitle_config_t sub_config = subt->config;
+                    
+                    if (!burned && job->mux == HB_MUX_MKV && 
+                        subt->format == PICTURESUB)
+                    {
+                        sub_config.dest = PASSTHRUSUB;
+                    }
+                    else if (!burned && job->mux == HB_MUX_MP4 && 
+                             subt->format == PICTURESUB)
+                    {
+                        // Skip any non-burned vobsubs when output is mp4
+                        continue;
+                    }
+                    else if ( burned && subt->format == PICTURESUB )
+                    {
+                        // Only allow one subtitle to be burned into the video
+                        if (one_burned)
+                            continue;
+                        one_burned = TRUE;
+                    }
+                    sub_config.force = force;
+                    sub_config.default_track = def;
+                    hb_subtitle_add( job, &sub_config, subtitle );
+                }   
+                
+            }
+        }
+        i++;
+    }
+   
+    
+    
+[subtitlesArray autorelease];    
+    
+    
+    /* Audio tracks and mixdowns */
+    /* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+    /* Now lets add our new tracks to the audio list here */
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack1CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack1MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack1BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack1RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack1DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }  
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack2CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack2MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack2BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack2RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack2DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+    
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack3CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack3MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack3BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack3RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack3DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack4CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack4MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack4BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack4RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack4DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    
+    
+    /* Filters */
+    
+    /* Though Grayscale is not really a filter, per se
+     * we put it here since its in the filters panel
+     */
+     
+    if ([fPictureController grayscale])
+    {
+        job->grayscale = 1;
+    }
+    else
+    {
+        job->grayscale = 0;
+    }
+    
+    /* Initialize the filters list */
+    job->filters = hb_list_init();
+    
+    /* Now lets call the filters if applicable.
+    * The order of the filters is critical
+    */
+    
+       /* Detelecine */
+    if ([fPictureController detelecine] == 1)
+    {
+        /* use a custom detelecine string */
+        hb_filter_detelecine.settings = (char *) [[fPictureController detelecineCustomString] UTF8String];
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    if ([fPictureController detelecine] == 2)
+    {
+        /* Default */
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    
+    
+    
+    if ([fPictureController useDecomb] == 1)
+    {
+        /* Decomb */
+        /* we add the custom string if present */
+        if ([fPictureController decomb] == 1)
+        {
+            /* use a custom decomb string */
+            hb_filter_decomb.settings = (char *) [[fPictureController decombCustomString] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        if ([fPictureController decomb] == 2)
+        {
+            /* Run old deinterlacer fd by default */
+            //hb_filter_decomb.settings = (char *) [[fPicSettingDecomb stringValue] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+    }
+    else
+    {
+        
+        /* Deinterlace */
+        if ([fPictureController deinterlace] == 1)
+        {
+            /* we add the custom string if present */
+            hb_filter_deinterlace.settings = (char *) [[fPictureController deinterlaceCustomString] UTF8String];
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([fPictureController deinterlace] == 2)
+        {
+            /* Run old deinterlacer fd by default */
+            hb_filter_deinterlace.settings = "-1"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );
+        }
+        else if ([fPictureController deinterlace] == 3)
+        {
+            /* Yadif mode 0 (without spatial deinterlacing.) */
+            hb_filter_deinterlace.settings = "2"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([fPictureController deinterlace] == 4)
+        {
+            /* Yadif (with spatial deinterlacing) */
+            hb_filter_deinterlace.settings = "0"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        
+       }
+    
+    /* Denoise */
+       if ([fPictureController denoise] == 1) // custom in popup
+       {
+               /* we add the custom string if present */
+        hb_filter_denoise.settings = (char *) [[fPictureController denoiseCustomString] UTF8String]; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    else if ([fPictureController denoise] == 2) // Weak in popup
+       {
+               hb_filter_denoise.settings = "2:1:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([fPictureController denoise] == 3) // Medium in popup
+       {
+               hb_filter_denoise.settings = "3:2:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([fPictureController denoise] == 4) // Strong in popup
+       {
+               hb_filter_denoise.settings = "7:7:5:5"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    
+    
+    /* Deblock  (uses pp7 default) */
+    /* NOTE: even though there is a valid deblock setting of 0 for the filter, for 
+     * the macgui's purposes a value of 0 actually means to not even use the filter
+     * current hb_filter_deblock.settings valid ranges are from 5 - 15 
+     */
+    if ([fPictureController deblock] != 0)
+    {
+        NSString *deblockStringValue = [NSString stringWithFormat: @"%d",[fPictureController deblock]];
+        hb_filter_deblock.settings = (char *) [deblockStringValue UTF8String];
+        hb_list_add( job->filters, &hb_filter_deblock );
+    }
+
+}
+
+
+#pragma mark -
+#pragma mark Job Handling
+
+
+- (void) prepareJob
+{
+    
+    NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
+    hb_list_t  * list  = hb_get_titles( fQueueEncodeLibhb );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan
+    hb_job_t * job = title->job;
+    hb_audio_config_t * audio;
+    /* Title Angle for dvdnav */
+    job->angle = [[queueToApply objectForKey:@"TitleAngle"] intValue];
+    /* Chapter selection */
+    job->chapter_start = [[queueToApply objectForKey:@"JobChapterStart"] intValue];
+    job->chapter_end   = [[queueToApply objectForKey:@"JobChapterEnd"] intValue];
+       
+    /* Format (Muxer) and Video Encoder */
+    job->mux = [[queueToApply objectForKey:@"JobFileFormatMux"] intValue];
+    job->vcodec = [[queueToApply objectForKey:@"JobVideoEncoderVcodec"] intValue];
+    
+    
+    /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
+    if( [[queueToApply objectForKey:@"Mp4LargeFile"] intValue] == 1)
+    {
+        job->largeFileSize = 1;
+    }
+    else
+    {
+        job->largeFileSize = 0;
+    }
+    /* We set http optimized mp4 here */
+    if( [[queueToApply objectForKey:@"Mp4HttpOptimize"] intValue] == 1 )
+    {
+        job->mp4_optimize = 1;
+    }
+    else
+    {
+        job->mp4_optimize = 0;
+    }
+
+       
+    /* We set the chapter marker extraction here based on the format being
+     mpeg4 or mkv and the checkbox being checked */
+    if ([[queueToApply objectForKey:@"ChapterMarkers"] intValue] == 1)
+    {
+        job->chapter_markers = 1;
+        
+        /* now lets get our saved chapter names out the array in the queue file
+         * and insert them back into the title chapter list. We have it here,
+         * because unless we are inserting chapter markers there is no need to
+         * spend the overhead of iterating through the chapter names array imo
+         * Also, note that if for some reason we don't apply chapter names, the
+         * chapters just come out 001, 002, etc. etc.
+         */
+         
+        NSMutableArray *ChapterNamesArray = [queueToApply objectForKey:@"ChapterNames"];
+        int i = 0;
+        NSEnumerator *enumerator = [ChapterNamesArray objectEnumerator];
+        id tempObject;
+        while (tempObject = [enumerator nextObject])
+        {
+            hb_chapter_t *chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
+            if( chapter != NULL )
+            {
+                strncpy( chapter->title, [tempObject UTF8String], 1023);
+                chapter->title[1023] = '\0';
+            }
+            i++;
+        }
+    }
+    else
+    {
+        job->chapter_markers = 0;
+    }
+    
+    if( job->vcodec & HB_VCODEC_X264 )
+    {
+               if ([[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue] == 1)
+           {
+            job->ipod_atom = 1;
+               }
+        else
+        {
+            job->ipod_atom = 0;
+        }
+               
+               
+               /* Below Sends x264 options to the core library if x264 is selected*/
+               /* Lets use this as per Nyx, Thanks Nyx!*/
+               job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
+               /* Turbo first pass if two pass and Turbo First pass is selected */
+               if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 && [[queueToApply objectForKey:@"VideoTurboTwoPass"] intValue] == 1 )
+               {
+                       /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
+                       NSString *firstPassOptStringTurbo = @":ref=1:subme=2:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
+                       /* append the "Turbo" string variable to the existing opts string.
+             Note: the "Turbo" string must be appended, not prepended to work properly*/
+                       NSString *firstPassOptStringCombined = [[queueToApply objectForKey:@"x264Option"] stringByAppendingString:firstPassOptStringTurbo];
+                       strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
+               }
+               else
+               {
+                       strcpy(job->x264opts, [[queueToApply objectForKey:@"x264Option"] UTF8String]);
+               }
+        
+    }
+    
+    
+    /* Picture Size Settings */
+    job->width = [[queueToApply objectForKey:@"PictureWidth"]  intValue];
+    job->height = [[queueToApply objectForKey:@"PictureHeight"]  intValue];
+    
+    job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"]  intValue];
+    job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
+    if ([[queueToApply objectForKey:@"PicturePAR"]  intValue] == 3)
+    {
+        /* insert our custom values here for capuj */
+        job->width = [[queueToApply objectForKey:@"PicturePARStorageWidth"]  intValue];
+        job->height = [[queueToApply objectForKey:@"PicturePARStorageHeight"]  intValue];
+        
+        job->anamorphic.modulus = [[queueToApply objectForKey:@"PicturePARModulus"] intValue];
+        
+        job->anamorphic.par_width = [[queueToApply objectForKey:@"PicturePARPixelWidth"]  intValue];
+        job->anamorphic.par_height = [[queueToApply objectForKey:@"PicturePARPixelHeight"]  intValue];
+        
+        job->anamorphic.dar_width = [[queueToApply objectForKey:@"PicturePARDisplayWidth"]  floatValue];
+        job->anamorphic.dar_height = [[queueToApply objectForKey:@"PicturePARDisplayHeight"]  floatValue];
+    }
+    
+    /* Here we use the crop values saved at the time the preset was saved */
+    job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"]  intValue];
+    job->crop[1] = [[queueToApply objectForKey:@"PictureBottomCrop"]  intValue];
+    job->crop[2] = [[queueToApply objectForKey:@"PictureLeftCrop"]  intValue];
+    job->crop[3] = [[queueToApply objectForKey:@"PictureRightCrop"]  intValue];
+    
+    /* Video settings */
+    /* Framerate */
+    
+    /* Set vfr to 0 as it's only on if using same as source in the framerate popup
+     * and detelecine is on, so we handle that in the logic below
+     */
+    job->vfr = 0;
+    if( [[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue] > 0 )
+    {
+        /* a specific framerate has been chosen */
+        job->vrate      = 27000000;
+        job->vrate_base = hb_video_rates[[[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue]-1].rate;
+        /* We are not same as source so we set job->cfr to 1 
+         * to enable constant frame rate since user has specified
+         * a specific framerate*/
+        job->cfr = 1;
+    }
+    else
+    {
+        /* We are same as source (variable) */
+        job->vrate      = [[queueToApply objectForKey:@"JobVrate"] intValue];
+        job->vrate_base = [[queueToApply objectForKey:@"JobVrateBase"] intValue];
+        /* We are same as source so we set job->cfr to 0 
+         * to enable true same as source framerate */
+        job->cfr = 0;
+        /* If we are same as source and we have detelecine on, we need to turn on
+         * job->vfr
+         */
+        if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
+        {
+            job->vfr = 1;
+        }
+    }
+    
+    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] != 2 )
+    {
+        /* Target size.
+         Bitrate should already have been calculated and displayed
+         in fVidBitrateField, so let's just use it same as abr*/
+        job->vquality = -1.0;
+        job->vbitrate = [[queueToApply objectForKey:@"VideoAvgBitrate"] intValue];
+    }
+    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 2 )
+    {
+        job->vquality = [[queueToApply objectForKey:@"VideoQualitySlider"] floatValue];
+        job->vbitrate = 0;
+        
+    }
+    
+    job->grayscale = [[queueToApply objectForKey:@"VideoGrayScale"] intValue];
+    
+
+
+#pragma mark -
+#pragma mark Process Subtitles to libhb
+
+/* Map the settings in the dictionaries for the SubtitleList array to match title->list_subtitle
+ * which means that we need to account for the offset of non source language settings in from
+ * the NSPopUpCell menu. For all of the objects in the SubtitleList array this means 0 is "None"
+ * from the popup menu, additionally the first track has "Foreign Audio Search" at 1. So we use
+ * an int to offset the index number for the objectForKey:@"subtitleSourceTrackNum" to map that
+ * to the source tracks position in title->list_subtitle.
+ */
+
+int subtitle = nil;
+int force;
+int burned;
+int def;
+bool one_burned = FALSE;
+
+    int i = 0;
+    NSEnumerator *enumerator = [[queueToApply objectForKey:@"SubtitleList"] objectEnumerator];
+    id tempObject;
+    while (tempObject = [enumerator nextObject])
+    {
+        
+        subtitle = [[tempObject objectForKey:@"subtitleSourceTrackNum"] intValue];
+        force = [[tempObject objectForKey:@"subtitleTrackForced"] intValue];
+        burned = [[tempObject objectForKey:@"subtitleTrackBurned"] intValue];
+        def = [[tempObject objectForKey:@"subtitleTrackDefault"] intValue];
+        
+        /* since the subtitleSourceTrackNum 0 is "None" in our array of the subtitle popups,
+         * we want to ignore it for display as well as encoding.
+         */
+        if (subtitle > 0)
+        {
+            /* if i is 0, then we are in the first item of the subtitles which we need to 
+             * check for the "Foreign Audio Search" which would be subtitleSourceTrackNum of 1
+             * bearing in mind that for all tracks subtitleSourceTrackNum of 0 is None.
+             */
+            
+            /* if we are on the first track and using "Foreign Audio Search" */ 
+            if (i == 0 && subtitle == 1)
+            {
+                [self writeToActivityLog: "Foreign Language Search: %d", 1];
+                
+                job->indepth_scan = 1;
+                if (burned == 1 || job->mux != HB_MUX_MP4)
+                {
+                    if (burned != 1 && job->mux == HB_MUX_MKV)
+                    {
+                        job->select_subtitle_config.dest = PASSTHRUSUB;
+                    }
+                    else
+                    {
+                        job->select_subtitle_config.dest = RENDERSUB;
+                    }
+                    
+                    job->select_subtitle_config.force = force;
+                    job->select_subtitle_config.default_track = def;
+                }
+                
+                
+            }
+            else
+            {
+                
+                /* for the actual source tracks, we must subtract the non source entries so 
+                 * that the menu index matches the source subtitle_list index for convenience */
+                if (i == 0)
+                {
+                    /* for the first track, the source tracks start at menu index 2 ( None is 0,
+                     * Foreign Language Search is 1) so subtract 2 */
+                    subtitle = subtitle - 2;
+                }
+                else
+                {
+                    /* for all other tracks, the source tracks start at menu index 1 (None is 0)
+                     * so subtract 1. */
+                    
+                    subtitle = subtitle - 1;
+                }
+                
+                /* We are setting a source subtitle so access the source subtitle info */  
+                hb_subtitle_t * subt;
+                
+                subt = (hb_subtitle_t *)hb_list_item(title->list_subtitle, subtitle);
+                
+                /* if we are getting the subtitles from an external srt file */
+                if ([[tempObject objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"])
+                {
+                    hb_subtitle_config_t sub_config;
+                    
+                    sub_config.offset = [[tempObject objectForKey:@"subtitleTrackSrtOffset"] intValue];
+                    
+                    /* we need to srncpy file name and codeset */
+                    //sub_config.src_filename = [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String];
+                    strncpy(sub_config.src_filename, [[tempObject objectForKey:@"subtitleSourceSrtFilePath"] UTF8String], 128);
+                    //sub_config.src_codeset = [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String];
+                    strncpy(sub_config.src_codeset, [[tempObject objectForKey:@"subtitleTrackSrtCharCode"] UTF8String], 40);
+                    
+                    sub_config.force = 0;
+                    sub_config.dest = PASSTHRUSUB;
+                    sub_config.default_track = def;
+                    
+                    hb_srt_add( job, &sub_config, [[tempObject objectForKey:@"subtitleTrackSrtLanguageIso3"] UTF8String]);
+                }
+                
+                
+                if (subt != NULL)
+                {
+                    [self writeToActivityLog: "Setting Subtitle: %s", subt];
+
+                    hb_subtitle_config_t sub_config = subt->config;
+                    
+                    if (!burned && job->mux == HB_MUX_MKV && 
+                        subt->format == PICTURESUB)
+                    {
+                        sub_config.dest = PASSTHRUSUB;
+                    }
+                    else if (!burned && job->mux == HB_MUX_MP4 && 
+                             subt->format == PICTURESUB)
+                    {
+                        // Skip any non-burned vobsubs when output is mp4
+                        continue;
+                    }
+                    else if ( burned && subt->format == PICTURESUB )
+                    {
+                        // Only allow one subtitle to be burned into the video
+                        if (one_burned)
+                            continue;
+                        one_burned = TRUE;
+                    }
+                    sub_config.force = force;
+                    sub_config.default_track = def;
+                    hb_subtitle_add( job, &sub_config, subtitle );
+                }   
+                
+            }
+        }
+        i++;
+    }
+
+#pragma mark -
+
+   
+    /* Audio tracks and mixdowns */
+    /* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+    /* Now lets add our new tracks to the audio list here */
+    if ([[queueToApply objectForKey:@"Audio1Track"] intValue] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
+        audio->out.codec = [[queueToApply objectForKey:@"JobAudio1Encoder"] intValue];
+        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio1Mixdown"] intValue];
+        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio1Bitrate"] intValue];
+        audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio1Samplerate"] intValue];
+        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio1TrackDRCSlider"] floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }  
+    if ([[queueToApply objectForKey:@"Audio2Track"] intValue] > 0)
+    {
+        
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [[queueToApply objectForKey:@"Audio2Track"] intValue] - 1;
+        [self writeToActivityLog: "prepareJob audiotrack 2 is: %d", audio->in.track];
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [[queueToApply objectForKey:@"Audio2Track"] intValue] - 1;
+        audio->out.codec = [[queueToApply objectForKey:@"JobAudio2Encoder"] intValue];
+        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio2Mixdown"] intValue];
+        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio2Bitrate"] intValue];
+        audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio2Samplerate"] intValue];
+        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio2TrackDRCSlider"] floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }
+    
+    if ([[queueToApply objectForKey:@"Audio3Track"] intValue] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [[queueToApply objectForKey:@"Audio3Track"] intValue] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [[queueToApply objectForKey:@"Audio3Track"] intValue] - 1;
+        audio->out.codec = [[queueToApply objectForKey:@"JobAudio3Encoder"] intValue];
+        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio3Mixdown"] intValue];
+        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio3Bitrate"] intValue];
+        audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio3Samplerate"] intValue];
+        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio3TrackDRCSlider"] floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);        
+    }
+    
+    if ([[queueToApply objectForKey:@"Audio4Track"] intValue] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [[queueToApply objectForKey:@"Audio4Track"] intValue] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [[queueToApply objectForKey:@"Audio4Track"] intValue] - 1;
+        audio->out.codec = [[queueToApply objectForKey:@"JobAudio4Encoder"] intValue];
+        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio4Mixdown"] intValue];
+        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio4Bitrate"] intValue];
+        audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio4Samplerate"] intValue];
+        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio4TrackDRCSlider"] floatValue];
+        
+        hb_audio_add( job, audio );
+        
+
+    }
+    
+    /* Filters */ 
+    job->filters = hb_list_init();
+    
+    /* Now lets call the filters if applicable.
+     * The order of the filters is critical
+     */
+    /* Detelecine */
+    if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
+    {
+        /* use a custom detelecine string */
+        hb_filter_detelecine.settings = (char *) [[queueToApply objectForKey:@"PictureDetelecineCustom"] UTF8String];
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 2)
+    {
+        /* Use libhb's default values */
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    
+    if ([[queueToApply objectForKey:@"PictureDecombDeinterlace"] intValue] == 1)
+    {
+        /* Decomb */
+        /* we add the custom string if present */
+        if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 1)
+        {
+            /* use a custom decomb string */
+            hb_filter_decomb.settings = (char *) [[queueToApply objectForKey:@"PictureDecombCustom"] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 2)
+        {
+            /* Use libhb default */
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        
+    }
+    else
+    {
+        
+        /* Deinterlace */
+        if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 1)
+        {
+            /* we add the custom string if present */
+            hb_filter_deinterlace.settings = (char *) [[queueToApply objectForKey:@"PictureDeinterlaceCustom"] UTF8String];
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 2)
+        {
+            /* Run old deinterlacer fd by default */
+            hb_filter_deinterlace.settings = "-1"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 3)
+        {
+            /* Yadif mode 0 (without spatial deinterlacing.) */
+            hb_filter_deinterlace.settings = "2"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 4)
+        {
+            /* Yadif (with spatial deinterlacing) */
+            hb_filter_deinterlace.settings = "0"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        
+        
+    }
+    /* Denoise */
+       if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 1) // Custom in popup
+       {
+               /* we add the custom string if present */
+        hb_filter_denoise.settings = (char *) [[queueToApply objectForKey:@"PictureDenoiseCustom"] UTF8String];
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 2) // Weak in popup
+       {
+               hb_filter_denoise.settings = "2:1:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 3) // Medium in popup
+       {
+               hb_filter_denoise.settings = "3:2:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 4) // Strong in popup
+       {
+               hb_filter_denoise.settings = "7:7:5:5"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    
+    
+    /* Deblock  (uses pp7 default) */
+    /* NOTE: even though there is a valid deblock setting of 0 for the filter, for 
+     * the macgui's purposes a value of 0 actually means to not even use the filter
+     * current hb_filter_deblock.settings valid ranges are from 5 - 15 
+     */
+    if ([[queueToApply objectForKey:@"PictureDeblock"] intValue] != 0)
+    {
+        hb_filter_deblock.settings = (char *) [[queueToApply objectForKey:@"PictureDeblock"] UTF8String];
+        hb_list_add( job->filters, &hb_filter_deblock );
+    }
+[self writeToActivityLog: "prepareJob exiting"];    
+}
+
+
+
+/* addToQueue: puts up an alert before ultimately calling doAddToQueue
+*/
+- (IBAction) addToQueue: (id) sender
+{
+       /* We get the destination directory from the destination field here */
+       NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
+       /* We check for a valid destination here */
+       if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0) 
+       {
+               NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
+        return;
+       }
+    
+    BOOL fileExists;
+    fileExists = NO;
+    
+    BOOL fileExistsInQueue;
+    fileExistsInQueue = NO;
+    
+    /* We check for and existing file here */
+    if([[NSFileManager defaultManager] fileExistsAtPath: [fDstFile2Field stringValue]])
+    {
+        fileExists = YES;
+    }
+    
+    /* We now run through the queue and make sure we are not overwriting an exisiting queue item */
+    int i = 0;
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+       while (tempObject = [enumerator nextObject])
+       {
+               NSDictionary *thisQueueDict = tempObject;
+               if ([[thisQueueDict objectForKey:@"DestinationPath"] isEqualToString: [fDstFile2Field stringValue]])
+               {
+                       fileExistsInQueue = YES;        
+               }
+        i++;
+       }
+    
+    
+       if(fileExists == YES)
+    {
+        NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists.", @"" ),
+                                  NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
+                                  @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
+                                  NULL, NULL, [NSString stringWithFormat:
+                                               NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
+                                               [fDstFile2Field stringValue]] );
+    }
+    else if (fileExistsInQueue == YES)
+    {
+    NSBeginCriticalAlertSheet( NSLocalizedString( @"There is already a queue item for this destination.", @"" ),
+                                  NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
+                                  @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
+                                  NULL, NULL, [NSString stringWithFormat:
+                                               NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
+                                               [fDstFile2Field stringValue]] );
+    }
+    else
+    {
+        [self doAddToQueue];
+    }
+}
+
+/* overwriteAddToQueueAlertDone: called from the alert posted by addToQueue that asks
+   the user if they want to overwrite an exiting movie file.
+*/
+- (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
+    returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSAlertAlternateReturn )
+        [self doAddToQueue];
+}
+
+- (void) doAddToQueue
+{
+    [self addQueueFileItem ];
+}
+
+
+
+/* Rip: puts up an alert before ultimately calling doRip
+*/
+- (IBAction) Rip: (id) sender
+{
+    [self writeToActivityLog: "Rip: Pending queue count is %d", fPendingCount];
+    /* Rip or Cancel ? */
+    hb_state_t s;
+    hb_get_state2( fQueueEncodeLibhb, &s );
+    
+    if(s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED)
+       {
+        [self Cancel: sender];
+        return;
+    }
+    
+    /* We check to see if we need to warn the user that the computer will go to sleep
+                 or shut down when encoding is finished */
+                [self remindUserOfSleepOrShutdown];
+    
+    // If there are pending jobs in the queue, then this is a rip the queue
+    if (fPendingCount > 0)
+    {
+        /* here lets start the queue with the first pending item */
+        [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; 
+        
+        return;
+    }
+    
+    // Before adding jobs to the queue, check for a valid destination.
+    
+    NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
+    if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0) 
+    {
+        NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
+        return;
+    }
+    
+    /* We check for duplicate name here */
+    if( [[NSFileManager defaultManager] fileExistsAtPath:[fDstFile2Field stringValue]] )
+    {
+        NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists", @"" ),
+                                  NSLocalizedString( @"Cancel", "" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
+                                  @selector( overWriteAlertDone:returnCode:contextInfo: ),
+                                  NULL, NULL, [NSString stringWithFormat:
+                                               NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
+                                               [fDstFile2Field stringValue]] );
+        
+        // overWriteAlertDone: will be called when the alert is dismissed. It will call doRip.
+    }
+    else
+    {
+        /* if there are no pending jobs in the queue, then add this one to the queue and rip
+         otherwise, just rip the queue */
+        if(fPendingCount == 0)
+        {
+            [self doAddToQueue];
+        }
+        
+        /* go right to processing the new queue encode */
+        [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; 
+        
+    }
+}
+
+/* overWriteAlertDone: called from the alert posted by Rip: that asks the user if they
+   want to overwrite an exiting movie file.
+*/
+- (void) overWriteAlertDone: (NSWindow *) sheet
+    returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSAlertAlternateReturn )
+    {
+        /* if there are no jobs in the queue, then add this one to the queue and rip 
+        otherwise, just rip the queue */
+        if( fPendingCount == 0 )
+        {
+            [self doAddToQueue];
+        }
+
+        NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
+        [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
+        [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; 
+      
+    }
+}
+
+- (void) remindUserOfSleepOrShutdown
+{
+       if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
+       {
+               /*Warn that computer will sleep after encoding*/
+               int reminduser;
+               NSBeep();
+               reminduser = NSRunAlertPanel(@"The computer will sleep after encoding is done.",@"You have selected to sleep the computer after encoding. To turn off sleeping, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
+               [NSApp requestUserAttention:NSCriticalRequest];
+               if ( reminduser == NSAlertAlternateReturn )
+               {
+                       [self showPreferencesWindow:nil];
+               }
+       }
+       else if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
+       {
+               /*Warn that computer will shut down after encoding*/
+               int reminduser;
+               NSBeep();
+               reminduser = NSRunAlertPanel(@"The computer will shut down after encoding is done.",@"You have selected to shut down the computer after encoding. To turn off shut down, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
+               [NSApp requestUserAttention:NSCriticalRequest];
+               if ( reminduser == NSAlertAlternateReturn )
+               {
+                       [self showPreferencesWindow:nil];
+               }
+       }
+
+}
+
+
+- (void) doRip
+{
+    /* Let libhb do the job */
+    hb_start( fQueueEncodeLibhb );
+    /*set the fEncodeState State */
+       fEncodeState = 1;
+}
+
+
+//------------------------------------------------------------------------------------
+// Displays an alert asking user if the want to cancel encoding of current job.
+// Cancel: returns immediately after posting the alert. Later, when the user
+// acknowledges the alert, doCancelCurrentJob is called.
+//------------------------------------------------------------------------------------
+- (IBAction)Cancel: (id)sender
+{
+    if (!fQueueController) return;
+    
+  hb_pause( fQueueEncodeLibhb );
+    NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"You are currently encoding. What would you like to do ?", nil)];
+   
+    // Which window to attach the sheet to?
+    NSWindow * docWindow;
+    if ([sender respondsToSelector: @selector(window)])
+        docWindow = [sender window];
+    else
+        docWindow = fWindow;
+        
+    NSBeginCriticalAlertSheet(
+            alertTitle,
+            NSLocalizedString(@"Continue Encoding", nil),
+            NSLocalizedString(@"Cancel Current and Stop", nil),
+            NSLocalizedString(@"Cancel Current and Continue", nil),
+            docWindow, self,
+            nil, @selector(didDimissCancel:returnCode:contextInfo:), nil,
+            NSLocalizedString(@"Your encode will be cancelled if you don't continue encoding.", nil));
+    
+    // didDimissCancelCurrentJob:returnCode:contextInfo: will be called when the dialog is dismissed
+}
+
+- (void) didDimissCancel: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
+{
+   hb_resume( fQueueEncodeLibhb );
+     if (returnCode == NSAlertOtherReturn)
+    {
+        [self doCancelCurrentJob];  // <- this also stops libhb
+    }
+    if (returnCode == NSAlertAlternateReturn)
+    {
+    [self doCancelCurrentJobAndStop];
+    }
+}
+
+//------------------------------------------------------------------------------------
+// Cancels and deletes the current job and stops libhb from processing the remaining
+// encodes.
+//------------------------------------------------------------------------------------
+- (void) doCancelCurrentJob
+{
+    // Stop the current job. hb_stop will only cancel the current pass and then set
+    // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
+    // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
+    // remaining passes of the job and then start the queue back up if there are any
+    // remaining jobs.
+     
+    
+    hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
+    
+    // now that we've stopped the currently encoding job, lets mark it as cancelled
+    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
+    // and as always, save it in the queue .plist...
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+    // so now lets move to 
+    currentQueueEncodeIndex++ ;
+    // ... and see if there are more items left in our queue
+    int queueItems = [QueueFileArray count];
+    /* If we still have more items in our queue, lets go to the next one */
+    if (currentQueueEncodeIndex < queueItems)
+    {
+    [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
+    [self writeToActivityLog: "doCancelCurrentJob moving to the next job"];
+    
+    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
+    }
+    else
+    {
+        [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"];
+    }
+
+}
+
+- (void) doCancelCurrentJobAndStop
+{
+    hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+                
+    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
+    
+    // now that we've stopped the currently encoding job, lets mark it as cancelled
+    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
+    // and as always, save it in the queue .plist...
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+    // so now lets move to 
+    currentQueueEncodeIndex++ ;
+    [self writeToActivityLog: "cancelling current job and stopping the queue"];
+}
+- (IBAction) Pause: (id) sender
+{
+    hb_state_t s;
+    hb_get_state2( fQueueEncodeLibhb, &s );
+
+    if( s.state == HB_STATE_PAUSED )
+    {
+        hb_resume( fQueueEncodeLibhb );
+    }
+    else
+    {
+        hb_pause( fQueueEncodeLibhb );
+    }
+}
+
+#pragma mark -
+#pragma mark GUI Controls Changed Methods
+
+- (IBAction) titlePopUpChanged: (id) sender
+{
+    hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t*)
+        hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
+
+    /* If Auto Naming is on. We create an output filename of dvd name - title number */
+    if( [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0 && ( hb_list_count( list ) > 1 ) )
+       {
+               [fDstFile2Field setStringValue: [NSString stringWithFormat:
+                       @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent],
+                       [browsedSourceDisplayName stringByDeletingPathExtension],
+            title->index,
+                       [[fDstFile2Field stringValue] pathExtension]]]; 
+       }
+
+    /* Update chapter popups */
+    [fSrcChapterStartPopUp removeAllItems];
+    [fSrcChapterEndPopUp   removeAllItems];
+    for( int i = 0; i < hb_list_count( title->list_chapter ); i++ )
+    {
+        [fSrcChapterStartPopUp addItemWithTitle: [NSString
+            stringWithFormat: @"%d", i + 1]];
+        [fSrcChapterEndPopUp addItemWithTitle: [NSString
+            stringWithFormat: @"%d", i + 1]];
+    }
+
+    [fSrcChapterStartPopUp selectItemAtIndex: 0];
+    [fSrcChapterEndPopUp   selectItemAtIndex:
+        hb_list_count( title->list_chapter ) - 1];
+    [self chapterPopUpChanged:nil];
+    
+    /* if using dvd nav, show the angle widget */
+    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"UseDvdNav"] boolValue])
+    {
+        [fSrcAngleLabel setHidden:NO];
+        [fSrcAnglePopUp setHidden:NO];
+        
+        [fSrcAnglePopUp removeAllItems];
+        for( int i = 0; i < title->angle_count; i++ )
+        {
+            [fSrcAnglePopUp addItemWithTitle: [NSString stringWithFormat: @"%d", i + 1]];
+        }
+        [fSrcAnglePopUp selectItemAtIndex: 0];
+    }
+    else
+    {
+        [fSrcAngleLabel setHidden:YES];
+        [fSrcAnglePopUp setHidden:YES];
+    }
+    
+    /* Start Get and set the initial pic size for display */
+       hb_job_t * job = title->job;
+       fTitle = title;
+    
+    /* Set Auto Crop to on upon selecting a new title  */
+    [fPictureController setAutoCrop:YES];
+    
+       /* We get the originial output picture width and height and put them
+       in variables for use with some presets later on */
+       PicOrigOutputWidth = job->width;
+       PicOrigOutputHeight = job->height;
+       AutoCropTop = job->crop[0];
+       AutoCropBottom = job->crop[1];
+       AutoCropLeft = job->crop[2];
+       AutoCropRight = job->crop[3];
+
+       /* Reset the new title in fPictureController &&  fPreviewController*/
+    [fPictureController SetTitle:title];
+
+        
+    /* Update Subtitle Table */
+    [fSubtitlesDelegate resetWithTitle:title];
+    [fSubtitlesTable reloadData];
+    
+
+    /* Update chapter table */
+    [fChapterTitlesDelegate resetWithTitle:title];
+    [fChapterTable reloadData];
+
+   /* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+
+    /* Update audio popups */
+    [self addAllAudioTracksToPopUp: fAudLang1PopUp];
+    [self addAllAudioTracksToPopUp: fAudLang2PopUp];
+    [self addAllAudioTracksToPopUp: fAudLang3PopUp];
+    [self addAllAudioTracksToPopUp: fAudLang4PopUp];
+    /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */
+       NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"];
+        [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1];
+    [self selectAudioTrackInPopUp:fAudLang2PopUp searchPrefixString:nil selectIndexIfNotFound:0];
+    [self selectAudioTrackInPopUp:fAudLang3PopUp searchPrefixString:nil selectIndexIfNotFound:0];
+    [self selectAudioTrackInPopUp:fAudLang4PopUp searchPrefixString:nil selectIndexIfNotFound:0];
+
+       /* changing the title may have changed the audio channels on offer, */
+       /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
+       [self audioTrackPopUpChanged: fAudLang1PopUp];
+       [self audioTrackPopUpChanged: fAudLang2PopUp];
+    [self audioTrackPopUpChanged: fAudLang3PopUp];
+    [self audioTrackPopUpChanged: fAudLang4PopUp];
+
+    [fVidRatePopUp selectItemAtIndex: 0];
+
+    /* we run the picture size values through calculatePictureSizing to get all picture setting        information*/
+       [self calculatePictureSizing:nil];
+
+   /* lets call tableViewSelected to make sure that any preset we have selected is enforced after a title change */
+    [self selectPreset:nil];
+}
+
+- (IBAction) chapterPopUpChanged: (id) sender
+{
+
+       /* If start chapter popup is greater than end chapter popup,
+       we set the end chapter popup to the same as start chapter popup */
+       if ([fSrcChapterStartPopUp indexOfSelectedItem] > [fSrcChapterEndPopUp indexOfSelectedItem])
+       {
+               [fSrcChapterEndPopUp selectItemAtIndex: [fSrcChapterStartPopUp indexOfSelectedItem]];
+    }
+
+               
+       hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t *)
+        hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
+
+    hb_chapter_t * chapter;
+    int64_t        duration = 0;
+    for( int i = [fSrcChapterStartPopUp indexOfSelectedItem];
+         i <= [fSrcChapterEndPopUp indexOfSelectedItem]; i++ )
+    {
+        chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
+        duration += chapter->duration;
+    }
+    
+    duration /= 90000; /* pts -> seconds */
+    [fSrcDuration2Field setStringValue: [NSString stringWithFormat:
+        @"%02lld:%02lld:%02lld", duration / 3600, ( duration / 60 ) % 60,
+        duration % 60]];
+
+    [self calculateBitrate: sender];
+    
+    if ( [fSrcChapterStartPopUp indexOfSelectedItem] ==  [fSrcChapterEndPopUp indexOfSelectedItem] )
+    {
+    /* Disable chapter markers for any source with less than two chapters as it makes no sense. */
+    [fCreateChapterMarkers setEnabled: NO];
+    [fCreateChapterMarkers setState: NSOffState];
+    }
+    else
+    {
+    [fCreateChapterMarkers setEnabled: YES];
+    }
+}
+
+- (IBAction) formatPopUpChanged: (id) sender
+{
+    NSString * string = [fDstFile2Field stringValue];
+    int format = [fDstFormatPopUp indexOfSelectedItem];
+    char * ext = NULL;
+       /* Initially set the large file (64 bit formatting) output checkbox to hidden */
+    [fDstMp4LargeFileCheck setHidden: YES];
+    [fDstMp4HttpOptFileCheck setHidden: YES];
+    [fDstMp4iPodFileCheck setHidden: YES];
+    
+    /* Update the Video Codec PopUp */
+    /* lets get the tag of the currently selected item first so we might reset it later */
+    int selectedVidEncoderTag;
+    selectedVidEncoderTag = [[fVidEncoderPopUp selectedItem] tag];
+    
+    /* Note: we now store the video encoder int values from common.c in the tags of each popup for easy retrieval later */
+    [fVidEncoderPopUp removeAllItems];
+    NSMenuItem *menuItem;
+    /* These video encoders are available to all of our current muxers, so lets list them once here */
+    menuItem = [[fVidEncoderPopUp menu] addItemWithTitle:@"MPEG-4 (FFmpeg)" action: NULL keyEquivalent: @""];
+    [menuItem setTag: HB_VCODEC_FFMPEG];
+    
+    switch( format )
+    {
+        case 0:
+                       /*Get Default MP4 File Extension*/
+                       if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
+                       {
+                               ext = "m4v";
+                       }
+                       else
+                       {
+                               ext = "mp4";
+                       }
+            /* Add additional video encoders here */
+            menuItem = [[fVidEncoderPopUp menu] addItemWithTitle:@"H.264 (x264)" action: NULL keyEquivalent: @""];
+            [menuItem setTag: HB_VCODEC_X264];
+            /* We show the mp4 option checkboxes here since we are mp4 */
+            [fCreateChapterMarkers setEnabled: YES];
+                       [fDstMp4LargeFileCheck setHidden: NO];
+                       [fDstMp4HttpOptFileCheck setHidden: NO];
+            [fDstMp4iPodFileCheck setHidden: NO];
+            break;
+            
+            case 1:
+            ext = "mkv";
+            /* Add additional video encoders here */
+            menuItem = [[fVidEncoderPopUp menu] addItemWithTitle:@"H.264 (x264)" action: NULL keyEquivalent: @""];
+            [menuItem setTag: HB_VCODEC_X264];
+            menuItem = [[fVidEncoderPopUp menu] addItemWithTitle:@"VP3 (Theora)" action: NULL keyEquivalent: @""];
+            [menuItem setTag: HB_VCODEC_THEORA];
+            /* We enable the create chapters checkbox here */
+                       [fCreateChapterMarkers setEnabled: YES];
+                       break;
+            
+
+    }
+    /* tell fSubtitlesDelegate we have a new video container */
+    
+    [fSubtitlesDelegate containerChanged:[[fDstFormatPopUp selectedItem] tag]];
+    [fSubtitlesTable reloadData];
+    /* if we have a previously selected vid encoder tag, then try to select it */
+    if (selectedVidEncoderTag)
+    {
+        [fVidEncoderPopUp selectItemWithTag: selectedVidEncoderTag];
+    }
+    else
+    {
+        [fVidEncoderPopUp selectItemAtIndex: 0];
+    }
+
+    [self audioAddAudioTrackCodecs: fAudTrack1CodecPopUp];
+    [self audioAddAudioTrackCodecs: fAudTrack2CodecPopUp];
+    [self audioAddAudioTrackCodecs: fAudTrack3CodecPopUp];
+    [self audioAddAudioTrackCodecs: fAudTrack4CodecPopUp];
+
+    if( format == 0 )
+        [self autoSetM4vExtension: sender];
+    else
+        [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@.%s", [string stringByDeletingPathExtension], ext]];
+
+    if( SuccessfulScan )
+    {
+        /* Add/replace to the correct extension */
+        [self audioTrackPopUpChanged: fAudLang1PopUp];
+        [self audioTrackPopUpChanged: fAudLang2PopUp];
+        [self audioTrackPopUpChanged: fAudLang3PopUp];
+        [self audioTrackPopUpChanged: fAudLang4PopUp];
+
+        if( [fVidEncoderPopUp selectedItem] == nil )
+        {
+
+            [fVidEncoderPopUp selectItemAtIndex:0];
+            [self videoEncoderPopUpChanged:nil];
+
+            /* changing the format may mean that we can / can't offer mono or 6ch, */
+            /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
+
+            /* We call the method to properly enable/disable turbo 2 pass */
+            [self twoPassCheckboxChanged: sender];
+            /* We call method method to change UI to reflect whether a preset is used or not*/
+        }
+    }
+       [self customSettingUsed: sender];
+}
+
+- (IBAction) autoSetM4vExtension: (id) sender
+{
+    if ( [fDstFormatPopUp indexOfSelectedItem] )
+        return;
+
+    NSString * extension = @"mp4";
+
+    if( [[fAudTrack1CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ||
+                                                        [[fAudTrack3CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ||
+                                                        [[fAudTrack4CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ||
+                                                        [fCreateChapterMarkers state] == NSOnState ||
+                                                        [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0 )
+    {
+        extension = @"m4v";
+    }
+
+    if( [extension isEqualTo: [[fDstFile2Field stringValue] pathExtension]] )
+        return;
+    else
+        [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@.%@",
+                                    [[fDstFile2Field stringValue] stringByDeletingPathExtension], extension]];
+}
+
+/* Method to determine if we should change the UI
+To reflect whether or not a Preset is being used or if
+the user is using "Custom" settings by determining the sender*/
+- (IBAction) customSettingUsed: (id) sender
+{
+       if ([sender stringValue])
+       {
+               /* Deselect the currently selected Preset if there is one*/
+               [fPresetsOutlineView deselectRow:[fPresetsOutlineView selectedRow]];
+               /* Change UI to show "Custom" settings are being used */
+               [fPresetSelectedDisplay setStringValue: @"Custom"];
+
+               curUserPresetChosenNum = nil;
+       }
+[self calculateBitrate:nil];
+}
+
+
+#pragma mark -
+#pragma mark - Video
+
+- (IBAction) videoEncoderPopUpChanged: (id) sender
+{
+    hb_job_t * job = fTitle->job;
+    int videoEncoder = [[fVidEncoderPopUp selectedItem] tag];
+    
+    [fAdvancedOptions setHidden:YES];
+    /* If we are using x264 then show the x264 advanced panel*/
+    if (videoEncoder == HB_VCODEC_X264)
+    {
+        [fAdvancedOptions setHidden:NO];
+        [self autoSetM4vExtension: sender];
+    }
+
+    if (videoEncoder == HB_VCODEC_FFMPEG)
+    {
+        /* We set the iPod atom checkbox to disabled and uncheck it as its only for x264 in the mp4
+         container. Format is taken care of in formatPopUpChanged method by hiding and unchecking
+         anything other than MP4.
+         */ 
+        [fDstMp4iPodFileCheck setEnabled: NO];
+        [fDstMp4iPodFileCheck setState: NSOffState];
+    }
+    else
+    {
+        [fDstMp4iPodFileCheck setEnabled: YES];
+    }
+    [self setupQualitySlider];
+       [self calculatePictureSizing: sender];
+       [self twoPassCheckboxChanged: sender];
+}
+
+
+- (IBAction) twoPassCheckboxChanged: (id) sender
+{
+       /* check to see if x264 is chosen */
+       if([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_X264)
+    {
+               if( [fVidTwoPassCheck state] == NSOnState)
+               {
+                       [fVidTurboPassCheck setHidden: NO];
+               }
+               else
+               {
+                       [fVidTurboPassCheck setHidden: YES];
+                       [fVidTurboPassCheck setState: NSOffState];
+               }
+               /* Make sure Two Pass is checked if Turbo is checked */
+               if( [fVidTurboPassCheck state] == NSOnState)
+               {
+                       [fVidTwoPassCheck setState: NSOnState];
+               }
+       }
+       else
+       {
+               [fVidTurboPassCheck setHidden: YES];
+               [fVidTurboPassCheck setState: NSOffState];
+       }
+       
+       /* We call method method to change UI to reflect whether a preset is used or not*/
+       [self customSettingUsed: sender];
+}
+
+- (IBAction ) videoFrameRateChanged: (id) sender
+{
+    /* We call method method to calculatePictureSizing to error check detelecine*/
+    [self calculatePictureSizing: sender];
+
+    /* We call method method to change UI to reflect whether a preset is used or not*/
+       [self customSettingUsed: sender];
+}
+- (IBAction) videoMatrixChanged: (id) sender;
+{
+    bool target, bitrate, quality;
+
+    target = bitrate = quality = false;
+    if( [fVidQualityMatrix isEnabled] )
+    {
+        switch( [fVidQualityMatrix selectedRow] )
+        {
+            case 0:
+                target = true;
+                break;
+            case 1:
+                bitrate = true;
+                break;
+            case 2:
+                quality = true;
+                break;
+        }
+    }
+    [fVidTargetSizeField  setEnabled: target];
+    [fVidBitrateField     setEnabled: bitrate];
+    [fVidQualitySlider    setEnabled: quality];
+    [fVidQualityRFField   setEnabled: quality];
+    [fVidQualityRFLabel    setEnabled: quality];
+    [fVidTwoPassCheck     setEnabled: !quality &&
+        [fVidQualityMatrix isEnabled]];
+    if( quality )
+    {
+        [fVidTwoPassCheck setState: NSOffState];
+               [fVidTurboPassCheck setHidden: YES];
+               [fVidTurboPassCheck setState: NSOffState];
+    }
+
+    [self qualitySliderChanged: sender];
+    [self calculateBitrate: sender];
+       [self customSettingUsed: sender];
+}
+
+/* Use this method to setup the quality slider for cq/rf values depending on
+ * the video encoder selected.
+ */
+- (void) setupQualitySlider
+{
+    /* Get the current slider maxValue to check for a change in slider scale later
+     * so that we can choose a new similar value on the new slider scale */
+    float previousMaxValue = [fVidQualitySlider maxValue];
+    float previousPercentOfSliderScale = [fVidQualitySlider floatValue] / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue] + 1);
+    NSString * qpRFLabelString = @"QP:";
+    /* x264 0-51 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_X264)
+    {
+        [fVidQualitySlider setMinValue:0.0];
+        [fVidQualitySlider setMaxValue:51.0];
+        /* As x264 allows for qp/rf values that are fractional, we get the value from the preferences */
+        int fractionalGranularity = 1 / [[NSUserDefaults standardUserDefaults] floatForKey:@"x264CqSliderFractional"];
+        [fVidQualitySlider setNumberOfTickMarks:(([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) * fractionalGranularity) + 1];
+        qpRFLabelString = @"RF:";
+    }
+    /* ffmpeg  1-31 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_FFMPEG )
+    {
+        [fVidQualitySlider setMinValue:1.0];
+        [fVidQualitySlider setMaxValue:31.0];
+        [fVidQualitySlider setNumberOfTickMarks:31];
+    }
+    /* Theora 0-63 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_THEORA)
+    {
+        [fVidQualitySlider setMinValue:0.0];
+        [fVidQualitySlider setMaxValue:63.0];
+        [fVidQualitySlider setNumberOfTickMarks:64];
+    }
+    [fVidQualityRFLabel setStringValue:qpRFLabelString];
+    
+    /* check to see if we have changed slider scales */
+    if (previousMaxValue != [fVidQualitySlider maxValue])
+    {
+        /* if so, convert the old setting to the new scale as close as possible based on percentages */
+        float rf =  ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue] + 1) * previousPercentOfSliderScale;
+        [fVidQualitySlider setFloatValue:rf];
+    }
+    
+    [self qualitySliderChanged:nil];
+}
+
+- (IBAction) qualitySliderChanged: (id) sender
+{
+    /* Our constant quality slider is in a range based
+     * on each encoders qp/rf values. The range depends
+     * on the encoder. Also, the range is inverse of quality
+     * for all of the encoders *except* for theora
+     * (ie. as the "quality" goes up, the cq or rf value
+     * actually goes down). Since the IB sliders always set
+     * their max value at the right end of the slider, we
+     * will calculate the inverse, so as the slider floatValue
+     * goes up, we will show the inverse in the rf field
+     * so, the floatValue at the right for x264 would be 51
+     * and our rf field needs to show 0 and vice versa.
+     */
+    
+    float sliderRfInverse = ([fVidQualitySlider maxValue] - [fVidQualitySlider floatValue]) + [fVidQualitySlider minValue];
+    /* If the encoder is theora, use the float, otherwise use the inverse float*/
+    float sliderRfToPercent;
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_THEORA)
+    {
+        [fVidQualityRFField setStringValue: [NSString stringWithFormat: @"%.2f", [fVidQualitySlider floatValue]]];
+        sliderRfToPercent = [fVidQualityRFField floatValue] / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]);   
+    }
+    else
+    {
+        [fVidQualityRFField setStringValue: [NSString stringWithFormat: @"%.2f", sliderRfInverse]];
+        sliderRfToPercent = ( ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue])  - ([fVidQualityRFField floatValue] - [fVidQualitySlider minValue])) / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]);
+    }
+    [fVidConstantCell setTitle: [NSString stringWithFormat:
+                                 NSLocalizedString( @"Constant quality: %.2f %%", @"" ), 100 * sliderRfToPercent]];
+    
+    [self customSettingUsed: sender];
+}
+
+- (void) controlTextDidChange: (NSNotification *) notification
+{
+    [self calculateBitrate:nil];
+}
+
+- (IBAction) calculateBitrate: (id) sender
+{
+    if( !fHandle || [fVidQualityMatrix selectedRow] != 0 || !SuccessfulScan )
+    {
+        return;
+    }
+
+    hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,
+            [fSrcTitlePopUp indexOfSelectedItem] );
+    hb_job_t * job = title->job;
+    hb_audio_config_t * audio;
+    /* For  hb_calc_bitrate in addition to the Target Size in MB out of the
+     * Target Size Field, we also need the job info for the Muxer, the Chapters
+     * as well as all of the audio track info.
+     * This used to be accomplished by simply calling prepareJob here, however
+     * since the resilient queue sets the queue array values instead of the job
+     * values directly, we duplicate the old prepareJob code here for the variables
+     * needed
+     */
+    job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
+    job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1; 
+    job->mux = [[fDstFormatPopUp selectedItem] tag];
+    
+    /* Audio goes here */
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+    /* Now we need our audio info here for each track if applicable */
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack1CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack1MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack1BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack1RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack1DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }  
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack2CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack2MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack2BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack2RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack2DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+    
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack3CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack3MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack3BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack3RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack3DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack4CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack4MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack4BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack4RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack4DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+       
+[fVidBitrateField setIntValue: hb_calc_bitrate( job, [fVidTargetSizeField intValue] )];
+}
+
+#pragma mark -
+#pragma mark - Picture
+
+/* lets set the picture size back to the max from right after title scan
+   Lets use an IBAction here as down the road we could always use a checkbox
+   in the gui to easily take the user back to max. Remember, the compiler
+   resolves IBActions down to -(void) during compile anyway */
+- (IBAction) revertPictureSizeToMax: (id) sender
+{
+       hb_job_t * job = fTitle->job;
+       /* Here we apply the title source and height */
+    job->width = fTitle->width;
+    job->height = fTitle->height;
+    
+    [self calculatePictureSizing: sender];
+    /* We call method to change UI to reflect whether a preset is used or not*/    
+    [self customSettingUsed: sender];
+}
+
+/**
+ * Registers changes made in the Picture Settings Window.
+ */
+
+- (void)pictureSettingsDidChange 
+{
+       [self calculatePictureSizing:nil];
+}
+
+/* Get and Display Current Pic Settings in main window */
+- (IBAction) calculatePictureSizing: (id) sender
+{
+       if (fTitle->job->anamorphic.mode > 0)
+       {
+        fTitle->job->keep_ratio = 0;
+       }
+    
+    [fPictureSizeField setStringValue: [NSString stringWithFormat:@"Picture Size: %@", [fPictureController getPictureSizeInfoString]]];
+    
+    NSString *picCropping;
+    /* Set the display field for crop as per boolean */
+       if (![fPictureController autoCrop])
+       {
+        picCropping =  @"Custom";
+       }
+       else
+       {
+               picCropping =  @"Auto";
+       }
+    picCropping = [picCropping stringByAppendingString:[NSString stringWithFormat:@" %d/%d/%d/%d",fTitle->job->crop[0],fTitle->job->crop[1],fTitle->job->crop[2],fTitle->job->crop[3]]];
+    
+    [fPictureCroppingField setStringValue: [NSString stringWithFormat:@"Picture Cropping: %@",picCropping]];
+    
+    NSString *videoFilters;
+    videoFilters = @"";
+    /* Detelecine */
+    if ([fPictureController detelecine] == 2) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:@" - Detelecine (Default)"];
+    }
+    else if ([fPictureController detelecine] == 1) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Detelecine (%@)",[fPictureController detelecineCustomString]]];
+    }
+    
+    
+    if ([fPictureController useDecomb] == 1)
+    {
+        /* Decomb */
+        if ([fPictureController decomb] == 2)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Decomb (Default)"];
+        }
+        else if ([fPictureController decomb] == 1)
+        {
+            videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Decomb (%@)",[fPictureController decombCustomString]]];
+        }
+    }
+    else
+    {
+        /* Deinterlace */
+        if ([fPictureController deinterlace] > 0)
+        {
+            fTitle->job->deinterlace  = 1;
+        }
+        else
+        {
+            fTitle->job->deinterlace  = 0;
+        }
+        
+        if ([fPictureController deinterlace] == 2)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Fast)"];
+        }
+        else if ([fPictureController deinterlace] == 3)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Slow)"];
+        }
+        else if ([fPictureController deinterlace] == 4)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Slower)"];
+        }
+        else if ([fPictureController deinterlace] == 1)
+        {
+            videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Deinterlace (%@)",[fPictureController deinterlaceCustomString]]];
+        }
+       }
+    
+    
+    /* Denoise */
+       if ([fPictureController denoise] == 2)
+       {
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Weak)"];
+    }
+       else if ([fPictureController denoise] == 3)
+       {
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Medium)"];
+    }
+       else if ([fPictureController denoise] == 4)
+       {
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Strong)"];
+       }
+    else if ([fPictureController denoise] == 1)
+       {
+               videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Denoise (%@)",[fPictureController denoiseCustomString]]];
+       }
+    
+    /* Deblock */
+    if ([fPictureController deblock] > 0) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Deblock (%d)",[fPictureController deblock]]];
+    }
+       
+    /* Grayscale */
+    if ([fPictureController grayscale]) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:@" - Grayscale"];
+    }
+    [fVideoFiltersField setStringValue: [NSString stringWithFormat:@"Video Filters: %@", videoFilters]];
+    
+    //[fPictureController reloadStillPreview]; 
+}
+
+
+#pragma mark -
+#pragma mark - Audio and Subtitles
+- (IBAction) audioCodecsPopUpChanged: (id) sender
+{
+    
+    NSPopUpButton * audiotrackPopUp;
+    NSPopUpButton * sampleratePopUp;
+    NSPopUpButton * bitratePopUp;
+    NSPopUpButton * audiocodecPopUp;
+    if (sender == fAudTrack1CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang1PopUp;
+        audiocodecPopUp = fAudTrack1CodecPopUp;
+        sampleratePopUp = fAudTrack1RatePopUp;
+        bitratePopUp = fAudTrack1BitratePopUp;
+    }
+    else if (sender == fAudTrack2CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang2PopUp;
+        audiocodecPopUp = fAudTrack2CodecPopUp;
+        sampleratePopUp = fAudTrack2RatePopUp;
+        bitratePopUp = fAudTrack2BitratePopUp;
+    }
+    else if (sender == fAudTrack3CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang3PopUp;
+        audiocodecPopUp = fAudTrack3CodecPopUp;
+        sampleratePopUp = fAudTrack3RatePopUp;
+        bitratePopUp = fAudTrack3BitratePopUp;
+    }
+    else
+    {
+        audiotrackPopUp = fAudLang4PopUp;
+        audiocodecPopUp = fAudTrack4CodecPopUp;
+        sampleratePopUp = fAudTrack4RatePopUp;
+        bitratePopUp = fAudTrack4BitratePopUp;
+    }
+       
+    /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
+       /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
+    [self audioTrackPopUpChanged: audiotrackPopUp];
+    
+}
+
+- (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender
+{
+    /* We will be setting the enabled/disabled state of each tracks audio controls based on
+     * the settings of the source audio for that track. We leave the samplerate and bitrate
+     * to audiotrackMixdownChanged
+     */
+    
+    /* We will first verify that a lower track number has been selected before enabling each track
+     * for example, make sure a track is selected for track 1 before enabling track 2, etc.
+     */
+    if ([fAudLang1PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudLang2PopUp setEnabled: NO];
+        [fAudLang2PopUp selectItemAtIndex: 0];
+    }
+    else
+    {
+        [fAudLang2PopUp setEnabled: YES];
+    }
+    
+    if ([fAudLang2PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudLang3PopUp setEnabled: NO];
+        [fAudLang3PopUp selectItemAtIndex: 0];
+    }
+    else
+    {
+        [fAudLang3PopUp setEnabled: YES];
+    }
+    if ([fAudLang3PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudLang4PopUp setEnabled: NO];
+        [fAudLang4PopUp selectItemAtIndex: 0];
+    }
+    else
+    {
+        [fAudLang4PopUp setEnabled: YES];
+    }
+    /* enable/disable the mixdown text and popupbutton for audio track 1 */
+    [fAudTrack1CodecPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack1MixPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack1RatePopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack1BitratePopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack1DrcSlider setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack1DrcField setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    if ([fAudLang1PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudTrack1CodecPopUp removeAllItems];
+        [fAudTrack1MixPopUp removeAllItems];
+        [fAudTrack1RatePopUp removeAllItems];
+        [fAudTrack1BitratePopUp removeAllItems];
+        [fAudTrack1DrcSlider setFloatValue: 0.00];
+        [self audioDRCSliderChanged: fAudTrack1DrcSlider];
+    }
+    else if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack1MixPopUp selectedItem] tag] == HB_ACODEC_DCA)
+    {
+        [fAudTrack1RatePopUp setEnabled: NO];
+        [fAudTrack1BitratePopUp setEnabled: NO];
+        [fAudTrack1DrcSlider setEnabled: NO];
+        [fAudTrack1DrcField setEnabled: NO];
+    }
+    
+    /* enable/disable the mixdown text and popupbutton for audio track 2 */
+    [fAudTrack2CodecPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack2MixPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack2RatePopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack2BitratePopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack2DrcSlider setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack2DrcField setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    if ([fAudLang2PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudTrack2CodecPopUp removeAllItems];
+        [fAudTrack2MixPopUp removeAllItems];
+        [fAudTrack2RatePopUp removeAllItems];
+        [fAudTrack2BitratePopUp removeAllItems];
+        [fAudTrack2DrcSlider setFloatValue: 0.00];
+        [self audioDRCSliderChanged: fAudTrack2DrcSlider];
+    }
+    else if ([[fAudTrack2MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2MixPopUp selectedItem] tag] == HB_ACODEC_DCA)
+    {
+        [fAudTrack2RatePopUp setEnabled: NO];
+        [fAudTrack2BitratePopUp setEnabled: NO];
+        [fAudTrack2DrcSlider setEnabled: NO];
+        [fAudTrack2DrcField setEnabled: NO];
+    }
+    
+    /* enable/disable the mixdown text and popupbutton for audio track 3 */
+    [fAudTrack3CodecPopUp setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack3MixPopUp setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack3RatePopUp setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack3BitratePopUp setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack3DrcSlider setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack3DrcField setEnabled: ([fAudLang3PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    if ([fAudLang3PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudTrack3CodecPopUp removeAllItems];
+        [fAudTrack3MixPopUp removeAllItems];
+        [fAudTrack3RatePopUp removeAllItems];
+        [fAudTrack3BitratePopUp removeAllItems];
+        [fAudTrack3DrcSlider setFloatValue: 0.00];
+        [self audioDRCSliderChanged: fAudTrack3DrcSlider];
+    }
+    else if ([[fAudTrack3MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack3MixPopUp selectedItem] tag] == HB_ACODEC_DCA)
+    {
+        [fAudTrack3RatePopUp setEnabled: NO];
+        [fAudTrack3BitratePopUp setEnabled: NO];
+        [fAudTrack3DrcSlider setEnabled: NO];
+        [fAudTrack3DrcField setEnabled: NO];
+    }
+    
+    /* enable/disable the mixdown text and popupbutton for audio track 4 */
+    [fAudTrack4CodecPopUp setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack4MixPopUp setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack4RatePopUp setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack4BitratePopUp setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack4DrcSlider setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    [fAudTrack4DrcField setEnabled: ([fAudLang4PopUp indexOfSelectedItem] == 0) ? NO : YES];
+    if ([fAudLang4PopUp indexOfSelectedItem] == 0)
+    {
+        [fAudTrack4CodecPopUp removeAllItems];
+        [fAudTrack4MixPopUp removeAllItems];
+        [fAudTrack4RatePopUp removeAllItems];
+        [fAudTrack4BitratePopUp removeAllItems];
+        [fAudTrack4DrcSlider setFloatValue: 0.00];
+        [self audioDRCSliderChanged: fAudTrack4DrcSlider];
+    }
+    else if ([[fAudTrack4MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack4MixPopUp selectedItem] tag] == HB_ACODEC_DCA)
+    {
+        [fAudTrack4RatePopUp setEnabled: NO];
+        [fAudTrack4BitratePopUp setEnabled: NO];
+        [fAudTrack4DrcSlider setEnabled: NO];
+        [fAudTrack4DrcField setEnabled: NO];
+    }
+    
+}
+
+- (IBAction) addAllAudioTracksToPopUp: (id) sender
+{
+
+    hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t*)
+        hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
+
+       hb_audio_config_t * audio;
+
+    [sender removeAllItems];
+    [sender addItemWithTitle: NSLocalizedString( @"None", @"" )];
+    for( int i = 0; i < hb_list_count( title->list_audio ); i++ )
+    {
+        audio = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, i );
+        [[sender menu] addItemWithTitle:
+            [NSString stringWithUTF8String: audio->lang.description]
+            action: NULL keyEquivalent: @""];
+    }
+    [sender selectItemAtIndex: 0];
+
+}
+
+- (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound
+{
+
+    /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
+    /* e.g. to find the first French track, pass in an NSString * of "Francais" */
+    /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
+    /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
+
+       if (searchPrefixString)
+       {
+
+        for( int i = 0; i < [sender numberOfItems]; i++ )
+        {
+            /* Try to find the desired search string */
+            if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
+            {
+                [sender selectItemAtIndex: i];
+                return;
+            }
+        }
+        /* couldn't find the string, so select the requested "search string not found" item */
+        /* index of 0 means select the "none" item */
+        /* index of 1 means select the first audio track */
+        [sender selectItemAtIndex: selectIndexIfNotFound];
+       }
+    else
+    {
+        /* if no search string is provided, then select the selectIndexIfNotFound item */
+        [sender selectItemAtIndex: selectIndexIfNotFound];
+    }
+
+}
+- (IBAction) audioAddAudioTrackCodecs: (id)sender
+{
+    int format = [fDstFormatPopUp indexOfSelectedItem];
+    
+    /* setup pointers to the appropriate popups for the correct track */
+    NSPopUpButton * audiocodecPopUp;
+    NSPopUpButton * audiotrackPopUp;
+    if (sender == fAudTrack1CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang1PopUp;
+        audiocodecPopUp = fAudTrack1CodecPopUp;
+    }
+    else if (sender == fAudTrack2CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang2PopUp;
+        audiocodecPopUp = fAudTrack2CodecPopUp;
+    }
+    else if (sender == fAudTrack3CodecPopUp)
+    {
+        audiotrackPopUp = fAudLang3PopUp;
+        audiocodecPopUp = fAudTrack3CodecPopUp;
+    }
+    else
+    {
+        audiotrackPopUp = fAudLang4PopUp;
+        audiocodecPopUp = fAudTrack4CodecPopUp;
+    }
+    
+    [audiocodecPopUp removeAllItems];
+    /* Make sure "None" isnt selected in the source track */
+    if ([audiotrackPopUp indexOfSelectedItem] > 0)
+    {
+        [audiocodecPopUp setEnabled:YES];
+        NSMenuItem *menuItem;
+        /* We setup our appropriate popups for codecs and put the int value in the popup tag for easy retrieval */
+        switch( format )
+        {
+            case 0:
+                /* MP4 */
+                // FAAC
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (faac)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_FAAC];
+
+                // CA_AAC
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (CoreAudio)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_CA_AAC];
+
+                // AC3 Passthru
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AC3 Passthru" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_AC3];
+                break;
+                
+            case 1:
+                /* MKV */
+                // FAAC
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (faac)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_FAAC];
+                // CA_AAC
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (CoreAudio)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_CA_AAC];
+                // AC3 Passthru
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AC3 Passthru" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_AC3];
+                // DTS Passthru
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"DTS Passthru" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_DCA];
+                // MP3
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"MP3 (lame)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_LAME];
+                // Vorbis
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"Vorbis (vorbis)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_VORBIS];
+                break;
+                
+            case 2: 
+                /* AVI */
+                // MP3
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"MP3 (lame)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_LAME];
+                // AC3 Passthru
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AC3 Passthru" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_AC3];
+                break;
+                
+            case 3:
+                /* OGM */
+                // Vorbis
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"Vorbis (vorbis)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_VORBIS];
+                // MP3
+                menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"MP3 (lame)" action: NULL keyEquivalent: @""];
+                [menuItem setTag: HB_ACODEC_LAME];
+                break;
+        }
+        [audiocodecPopUp selectItemAtIndex:0];
+    }
+    else
+    {
+        [audiocodecPopUp setEnabled:NO];
+    }
+}
+
+- (IBAction) audioTrackPopUpChanged: (id) sender
+{
+    /* utility function to call audioTrackPopUpChanged without passing in a mixdown-to-use */
+    [self audioTrackPopUpChanged: sender mixdownToUse: 0];
+}
+
+- (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
+{
+    
+    /* make sure we have a selected title before continuing */
+    if (fTitle == NULL) return;
+    /* if the sender is the lanaguage popup and there is nothing in the codec popup, lets call
+    * audioAddAudioTrackCodecs on the codec popup to populate it properly before moving on
+    */
+    if (sender == fAudLang1PopUp && [[fAudTrack1CodecPopUp menu] numberOfItems] == 0)
+    {
+        [self audioAddAudioTrackCodecs: fAudTrack1CodecPopUp];
+    }
+    if (sender == fAudLang2PopUp && [[fAudTrack2CodecPopUp menu] numberOfItems] == 0)
+    {
+        [self audioAddAudioTrackCodecs: fAudTrack2CodecPopUp];
+    }
+    if (sender == fAudLang3PopUp && [[fAudTrack3CodecPopUp menu] numberOfItems] == 0)
+    {
+        [self audioAddAudioTrackCodecs: fAudTrack3CodecPopUp];
+    }
+    if (sender == fAudLang4PopUp && [[fAudTrack4CodecPopUp menu] numberOfItems] == 0)
+    {
+        [self audioAddAudioTrackCodecs: fAudTrack4CodecPopUp];
+    }
+    
+    /* Now lets make the sender the appropriate Audio Track popup from this point on */
+    if (sender == fAudTrack1CodecPopUp || sender == fAudTrack1MixPopUp)
+    {
+        sender = fAudLang1PopUp;
+    }
+    if (sender == fAudTrack2CodecPopUp || sender == fAudTrack2MixPopUp)
+    {
+        sender = fAudLang2PopUp;
+    }
+    if (sender == fAudTrack3CodecPopUp || sender == fAudTrack3MixPopUp)
+    {
+        sender = fAudLang3PopUp;
+    }
+    if (sender == fAudTrack4CodecPopUp || sender == fAudTrack4MixPopUp)
+    {
+        sender = fAudLang4PopUp;
+    }
+    
+    /* pointer to this track's mixdown, codec, sample rate and bitrate NSPopUpButton's */
+    NSPopUpButton * mixdownPopUp;
+    NSPopUpButton * audiocodecPopUp;
+    NSPopUpButton * sampleratePopUp;
+    NSPopUpButton * bitratePopUp;
+    if (sender == fAudLang1PopUp)
+    {
+        mixdownPopUp = fAudTrack1MixPopUp;
+        audiocodecPopUp = fAudTrack1CodecPopUp;
+        sampleratePopUp = fAudTrack1RatePopUp;
+        bitratePopUp = fAudTrack1BitratePopUp;
+    }
+    else if (sender == fAudLang2PopUp)
+    {
+        mixdownPopUp = fAudTrack2MixPopUp;
+        audiocodecPopUp = fAudTrack2CodecPopUp;
+        sampleratePopUp = fAudTrack2RatePopUp;
+        bitratePopUp = fAudTrack2BitratePopUp;
+    }
+    else if (sender == fAudLang3PopUp)
+    {
+        mixdownPopUp = fAudTrack3MixPopUp;
+        audiocodecPopUp = fAudTrack3CodecPopUp;
+        sampleratePopUp = fAudTrack3RatePopUp;
+        bitratePopUp = fAudTrack3BitratePopUp;
+    }
+    else
+    {
+        mixdownPopUp = fAudTrack4MixPopUp;
+        audiocodecPopUp = fAudTrack4CodecPopUp;
+        sampleratePopUp = fAudTrack4RatePopUp;
+        bitratePopUp = fAudTrack4BitratePopUp;
+    }
+
+    /* get the index of the selected audio Track*/
+    int thisAudioIndex = [sender indexOfSelectedItem] - 1;
+
+    /* pointer for the hb_audio_s struct we will use later on */
+    hb_audio_config_t * audio;
+
+    int acodec;
+    /* check if the audio mixdown controls need their enabled state changing */
+    [self setEnabledStateOfAudioMixdownControls:nil];
+
+    if (thisAudioIndex != -1)
+    {
+
+        /* get the audio */
+        audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, thisAudioIndex );// Should "fTitle" be title and be setup ?
+
+        /* actually manipulate the proper mixdowns here */
+        /* delete the previous audio mixdown options */
+        [mixdownPopUp removeAllItems];
+
+        acodec = [[audiocodecPopUp selectedItem] tag];
+
+        if (audio != NULL)
+        {
+
+            /* find out if our selected output audio codec supports mono and / or 6ch */
+            /* we also check for an input codec of AC3 or DCA,
+             as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
+            /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
+             but this may change in the future, so they are separated for flexibility */
+            int audioCodecsSupportMono =
+                    (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
+                    (acodec != HB_ACODEC_LAME);
+            int audioCodecsSupport6Ch =
+                    (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
+                    (acodec != HB_ACODEC_LAME);
+            
+            /* check for AC-3 passthru */
+            if (audio->in.codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
+            {
+                
+            NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                 [NSString stringWithUTF8String: "AC3 Passthru"]
+                                               action: NULL keyEquivalent: @""];
+             [menuItem setTag: HB_ACODEC_AC3];   
+            }
+            else if (audio->in.codec == HB_ACODEC_DCA && acodec == HB_ACODEC_DCA)
+            {
+            NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                 [NSString stringWithUTF8String: "DTS Passthru"]
+                                               action: NULL keyEquivalent: @""];
+             [menuItem setTag: HB_ACODEC_DCA]; 
+            }
+            else
+            {
+                
+                /* add the appropriate audio mixdown menuitems to the popupbutton */
+                /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
+                 so that we can reference the mixdown later */
+                
+                /* keep a track of the min and max mixdowns we used, so we can select the best match later */
+                int minMixdownUsed = 0;
+                int maxMixdownUsed = 0;
+                
+                /* get the input channel layout without any lfe channels */
+                int layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
+                
+                /* do we want to add a mono option? */
+                if (audioCodecsSupportMono == 1)
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[0].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: hb_audio_mixdowns[0].amixdown];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
+                }
+                
+                /* do we want to add a stereo option? */
+                /* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
+                /* also offer stereo if we have a stereo-or-better source */
+                if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO)
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[1].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: hb_audio_mixdowns[1].amixdown];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
+                }
+                
+                /* do we want to add a dolby surround (DPL1) option? */
+                if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY)
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[2].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: hb_audio_mixdowns[2].amixdown];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
+                }
+                
+                /* do we want to add a dolby pro logic 2 (DPL2) option? */
+                if (layout == HB_INPUT_CH_LAYOUT_3F2R)
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[3].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: hb_audio_mixdowns[3].amixdown];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
+                }
+                
+                /* do we want to add a 6-channel discrete option? */
+                if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE))
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[4].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: hb_audio_mixdowns[4].amixdown];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
+                }
+                
+                /* do we want to add an AC-3 passthrough option? */
+                if (audio->in.codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3) 
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[5].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: HB_ACODEC_AC3];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[5].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[5].amixdown);
+                }
+                
+                /* do we want to add a DTS Passthru option ? HB_ACODEC_DCA*/
+                if (audio->in.codec == HB_ACODEC_DCA && acodec == HB_ACODEC_DCA) 
+                {
+                    NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
+                                            [NSString stringWithUTF8String: hb_audio_mixdowns[5].human_readable_name]
+                                                                          action: NULL keyEquivalent: @""];
+                    [menuItem setTag: HB_ACODEC_DCA];
+                    if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[5].amixdown;
+                    maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[5].amixdown);
+                }
+                
+                /* auto-select the best mixdown based on our saved mixdown preference */
+                
+                /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
+                /* ultimately this should be a prefs option */
+                int useMixdown;
+                
+                /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
+                if (mixdownToUse > 0)
+                {
+                    useMixdown = mixdownToUse;
+                }
+                else
+                {
+                    useMixdown = HB_AMIXDOWN_DOLBYPLII;
+                }
+                
+                /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
+                if (useMixdown > maxMixdownUsed)
+                { 
+                    useMixdown = maxMixdownUsed;
+                }
+                
+                /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
+                if (useMixdown < minMixdownUsed)
+                { 
+                    useMixdown = minMixdownUsed;
+                }
+                
+                /* select the (possibly-amended) preferred mixdown */
+                [mixdownPopUp selectItemWithTag: useMixdown];
+
+            }
+            /* In the case of a source track that is not AC3 and the user tries to use AC3 Passthru (which does not work)
+             * we force the Audio Codec choice back to a workable codec. We use MP3 for avi and aac for all
+             * other containers.
+             */
+            if (audio->in.codec != HB_ACODEC_AC3 && [[audiocodecPopUp selectedItem] tag] == HB_ACODEC_AC3)
+            {
+                /* If we are using the avi container, we select MP3 as there is no aac available*/
+                if ([[fDstFormatPopUp selectedItem] tag] == HB_MUX_AVI)
+                {
+                    [audiocodecPopUp selectItemWithTag: HB_ACODEC_LAME];
+                }
+                else
+                {
+                    [audiocodecPopUp selectItemWithTag: HB_ACODEC_FAAC];
+                }
+            }
+            
+            /* In the case of a source track that is not DTS and the user tries to use DTS Passthru (which does not work)
+             * we force the Audio Codec choice back to a workable codec. We use MP3 for avi and aac for all
+             * other containers.
+             */
+            if (audio->in.codec != HB_ACODEC_DCA && [[audiocodecPopUp selectedItem] tag] == HB_ACODEC_DCA)
+            {
+                /* If we are using the avi container, we select MP3 as there is no aac available*/
+                if ([[fDstFormatPopUp selectedItem] tag] == HB_MUX_AVI)
+                {
+                    [audiocodecPopUp selectItemWithTag: HB_ACODEC_LAME];
+                }
+                else
+                {
+                    [audiocodecPopUp selectItemWithTag: HB_ACODEC_FAAC];
+                }
+            }
+            
+            /* Setup our samplerate and bitrate popups we will need based on mixdown */
+            [self audioTrackMixdownChanged: mixdownPopUp];            
+        }
+    
+    }
+    if( [fDstFormatPopUp indexOfSelectedItem] == 0 )
+    {
+        [self autoSetM4vExtension: sender];
+    }
+}
+
+- (IBAction) audioTrackMixdownChanged: (id) sender
+{
+    
+    int acodec;
+    /* setup pointers to all of the other audio track controls
+    * we will need later
+    */
+    NSPopUpButton * mixdownPopUp;
+    NSPopUpButton * sampleratePopUp;
+    NSPopUpButton * bitratePopUp;
+    NSPopUpButton * audiocodecPopUp;
+    NSPopUpButton * audiotrackPopUp;
+    NSSlider * drcSlider;
+    NSTextField * drcField;
+    if (sender == fAudTrack1MixPopUp)
+    {
+        audiotrackPopUp = fAudLang1PopUp;
+        audiocodecPopUp = fAudTrack1CodecPopUp;
+        mixdownPopUp = fAudTrack1MixPopUp;
+        sampleratePopUp = fAudTrack1RatePopUp;
+        bitratePopUp = fAudTrack1BitratePopUp;
+        drcSlider = fAudTrack1DrcSlider;
+        drcField = fAudTrack1DrcField;
+    }
+    else if (sender == fAudTrack2MixPopUp)
+    {
+        audiotrackPopUp = fAudLang2PopUp;
+        audiocodecPopUp = fAudTrack2CodecPopUp;
+        mixdownPopUp = fAudTrack2MixPopUp;
+        sampleratePopUp = fAudTrack2RatePopUp;
+        bitratePopUp = fAudTrack2BitratePopUp;
+        drcSlider = fAudTrack2DrcSlider;
+        drcField = fAudTrack2DrcField;
+    }
+    else if (sender == fAudTrack3MixPopUp)
+    {
+        audiotrackPopUp = fAudLang3PopUp;
+        audiocodecPopUp = fAudTrack3CodecPopUp;
+        mixdownPopUp = fAudTrack3MixPopUp;
+        sampleratePopUp = fAudTrack3RatePopUp;
+        bitratePopUp = fAudTrack3BitratePopUp;
+        drcSlider = fAudTrack3DrcSlider;
+        drcField = fAudTrack3DrcField;
+    }
+    else
+    {
+        audiotrackPopUp = fAudLang4PopUp;
+        audiocodecPopUp = fAudTrack4CodecPopUp;
+        mixdownPopUp = fAudTrack4MixPopUp;
+        sampleratePopUp = fAudTrack4RatePopUp;
+        bitratePopUp = fAudTrack4BitratePopUp;
+        drcSlider = fAudTrack4DrcSlider;
+        drcField = fAudTrack4DrcField;
+    }
+    acodec = [[audiocodecPopUp selectedItem] tag];
+    /* storage variable for the min and max bitrate allowed for this codec */
+    int minbitrate;
+    int maxbitrate;
+    
+    switch( acodec )
+    {
+        case HB_ACODEC_FAAC:
+            /* check if we have a 6ch discrete conversion in either audio track */
+            if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
+            {
+                /* FAAC has a minimum of 192 kbps for 6-channel discrete */
+                minbitrate = 192;
+                /* If either mixdown popup includes 6-channel discrete, then allow up to 448 kbps */
+                maxbitrate = 448;
+                break;
+            }
+            else
+            {
+                /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
+                minbitrate = 32;
+                /* FAAC won't honour anything more than 160 for stereo, so let's not offer it */
+                /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
+                maxbitrate = 160;
+                break;
+            }
+
+        case HB_ACODEC_CA_AAC:
+            /* check if we have a 6ch discrete conversion in either audio track */
+            if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
+            {
+                minbitrate = 128;
+                maxbitrate = 768;
+                break;
+            }
+            else
+            {
+                minbitrate = 64;
+                maxbitrate = 320;
+                break;
+            }
+
+            case HB_ACODEC_LAME:
+            /* Lame is happy using our min bitrate of 32 kbps */
+            minbitrate = 32;
+            /* Lame won't encode if the bitrate is higher than 320 kbps */
+            maxbitrate = 320;
+            break;
+            
+            case HB_ACODEC_VORBIS:
+            if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
+            {
+                /* Vorbis causes a crash if we use a bitrate below 192 kbps with 6 channel */
+                minbitrate = 192;
+                /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
+                maxbitrate = 384;
+                break;
+            }
+            else
+            {
+                /* Vorbis causes a crash if we use a bitrate below 48 kbps */
+                minbitrate = 48;
+                /* Vorbis can cope with 384 kbps quite happily, even for stereo */
+                maxbitrate = 384;
+                break;
+            }
+            
+            default:
+            /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
+            minbitrate = 32;
+            maxbitrate = 384;
+            
+    }
+    
+    /* make sure we have a selected title before continuing */
+    if (fTitle == NULL) return;
+    /* get the audio so we can find out what input rates are*/
+    hb_audio_config_t * audio;
+    audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, [audiotrackPopUp indexOfSelectedItem] - 1 );
+    int inputbitrate = audio->in.bitrate / 1000;
+    int inputsamplerate = audio->in.samplerate;
+    
+    if ([[mixdownPopUp selectedItem] tag] != HB_ACODEC_AC3 && [[mixdownPopUp selectedItem] tag] != HB_ACODEC_DCA)
+    {
+        [bitratePopUp removeAllItems];
+        
+        for( int i = 0; i < hb_audio_bitrates_count; i++ )
+        {
+            if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
+            {
+                /* add a new menuitem for this bitrate */
+                NSMenuItem *menuItem = [[bitratePopUp menu] addItemWithTitle:
+                                        [NSString stringWithUTF8String: hb_audio_bitrates[i].string]
+                                                                      action: NULL keyEquivalent: @""];
+                /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */
+                [menuItem setTag: hb_audio_bitrates[i].rate];
+            }
+        }
+        
+        /* select the default bitrate (but use 384 for 6-ch AAC) */
+        if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
+        {
+            [bitratePopUp selectItemWithTag: 384];
+        }
+        else
+        {
+            [bitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
+        }
+    }
+    /* populate and set the sample rate popup */
+    /* Audio samplerate */
+    [sampleratePopUp removeAllItems];
+    /* we create a same as source selection (Auto) so that we can choose to use the input sample rate */
+    NSMenuItem *menuItem = [[sampleratePopUp menu] addItemWithTitle: @"Auto" action: NULL keyEquivalent: @""];
+    [menuItem setTag: inputsamplerate];
+    
+    for( int i = 0; i < hb_audio_rates_count; i++ )
+    {
+        NSMenuItem *menuItem = [[sampleratePopUp menu] addItemWithTitle:
+                                [NSString stringWithUTF8String: hb_audio_rates[i].string]
+                                                                 action: NULL keyEquivalent: @""];
+        [menuItem setTag: hb_audio_rates[i].rate];
+    }
+    /* We use the input sample rate as the default sample rate as downsampling just makes audio worse
+    * and there is no compelling reason to use anything else as default, though the users default
+    * preset will likely override any setting chosen here.
+    */
+    [sampleratePopUp selectItemWithTag: inputsamplerate];
+    
+    
+    /* Since AC3 Pass Thru and DTS Pass Thru uses the input bitrate and sample rate, we get the input tracks
+    * bitrate and display it in the bitrate popup even though libhb happily ignores any bitrate input from
+    * the gui. We do this for better user feedback in the audio tab as well as the queue for the most part
+    */
+    if ([[mixdownPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[mixdownPopUp selectedItem] tag] == HB_ACODEC_DCA)
+    {
+        
+        /* lets also set the bitrate popup to the input bitrate as thats what passthru will use */
+        [bitratePopUp removeAllItems];
+        NSMenuItem *menuItem = [[bitratePopUp menu] addItemWithTitle:
+                                [NSString stringWithFormat:@"%d", inputbitrate]
+                                                              action: NULL keyEquivalent: @""];
+        [menuItem setTag: inputbitrate];
+        /* For ac3 passthru we disable the sample rate and bitrate popups as well as the drc slider*/
+        [bitratePopUp setEnabled: NO];
+        [sampleratePopUp setEnabled: NO];
+        
+        [drcSlider setFloatValue: 0.00];
+        [self audioDRCSliderChanged: drcSlider];
+        [drcSlider setEnabled: NO];
+        [drcField setEnabled: NO];
+    }
+    else
+    {
+        [sampleratePopUp setEnabled: YES];
+        [bitratePopUp setEnabled: YES];
+        [drcSlider setEnabled: YES];
+        [drcField setEnabled: YES];
+    }
+[self calculateBitrate:nil];    
+}
+
+- (IBAction) audioDRCSliderChanged: (id) sender
+{
+    NSSlider * drcSlider;
+    NSTextField * drcField;
+    if (sender == fAudTrack1DrcSlider)
+    {
+        drcSlider = fAudTrack1DrcSlider;
+        drcField = fAudTrack1DrcField;
+    }
+    else if (sender == fAudTrack2DrcSlider)
+    {
+        drcSlider = fAudTrack2DrcSlider;
+        drcField = fAudTrack2DrcField;
+    }
+    else if (sender == fAudTrack3DrcSlider)
+    {
+        drcSlider = fAudTrack3DrcSlider;
+        drcField = fAudTrack3DrcField;
+    }
+    else
+    {
+        drcSlider = fAudTrack4DrcSlider;
+        drcField = fAudTrack4DrcField;
+    }
+    
+    /* If we are between 0.0 and 1.0 on the slider, snap it to 1.0 */
+    if ([drcSlider floatValue] > 0.0 && [drcSlider floatValue] < 1.0)
+    {
+        [drcSlider setFloatValue:1.0];
+    }
+    
+    
+    [drcField setStringValue: [NSString stringWithFormat: @"%.2f", [drcSlider floatValue]]];
+    /* For now, do not call this until we have an intelligent way to determine audio track selections
+    * compared to presets
+    */
+    //[self customSettingUsed: sender];
+}
+
+#pragma mark -
+
+- (IBAction) browseImportSrtFile: (id) sender
+{
+
+    NSOpenPanel * panel;
+       
+    panel = [NSOpenPanel openPanel];
+    [panel setAllowsMultipleSelection: NO];
+    [panel setCanChooseFiles: YES];
+    [panel setCanChooseDirectories: NO ];
+    NSString * sourceDirectory;
+       if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"])
+       {
+               sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"];
+       }
+       else
+       {
+               sourceDirectory = @"~/Desktop";
+               sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
+       }
+    /* we open up the browse srt sheet here and call for browseImportSrtFileDone after the sheet is closed */
+    NSArray *fileTypes = [NSArray arrayWithObjects:@"plist", @"srt", nil];
+    [panel beginSheetForDirectory: sourceDirectory file: nil types: fileTypes
+                   modalForWindow: fWindow modalDelegate: self
+                   didEndSelector: @selector( browseImportSrtFileDone:returnCode:contextInfo: )
+                      contextInfo: sender];
+}
+
+- (void) browseImportSrtFileDone: (NSSavePanel *) sheet
+                     returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSOKButton )
+    {
+        NSString *importSrtDirectory = [[sheet filename] stringByDeletingLastPathComponent];
+        NSString *importSrtFilePath = [sheet filename];
+        [[NSUserDefaults standardUserDefaults] setObject:importSrtDirectory forKey:@"LastSrtImportDirectory"];
+        
+        /* now pass the string off to fSubtitlesDelegate to add the srt file to the dropdown */
+        [fSubtitlesDelegate createSubtitleSrtTrack:importSrtFilePath];
+        
+        [fSubtitlesTable reloadData];
+        
+    }
+}                                           
+
+#pragma mark -
+#pragma mark Open New Windows
+
+- (IBAction) openHomepage: (id) sender
+{
+    [[NSWorkspace sharedWorkspace] openURL: [NSURL
+        URLWithString:@"http://handbrake.fr/"]];
+}
+
+- (IBAction) openForums: (id) sender
+{
+    [[NSWorkspace sharedWorkspace] openURL: [NSURL
+        URLWithString:@"http://handbrake.fr/forum/"]];
+}
+- (IBAction) openUserGuide: (id) sender
+{
+    [[NSWorkspace sharedWorkspace] openURL: [NSURL
+        URLWithString:@"http://handbrake.fr/trac/wiki/HandBrakeGuide"]];
+}
+
+/**
+ * Shows debug output window.
+ */
+- (IBAction)showDebugOutputPanel:(id)sender
+{
+    [outputPanel showOutputPanel:sender];
+}
+
+/**
+ * Shows preferences window.
+ */
+- (IBAction) showPreferencesWindow: (id) sender
+{
+    NSWindow * window = [fPreferencesController window];
+    if (![window isVisible])
+        [window center];
+
+    [window makeKeyAndOrderFront: nil];
+}
+
+/**
+ * Shows queue window.
+ */
+- (IBAction) showQueueWindow:(id)sender
+{
+    [fQueueController showQueueWindow:sender];
+}
+
+
+- (IBAction) toggleDrawer:(id)sender {
+    [fPresetDrawer toggle:self];
+}
+
+/**
+ * Shows Picture Settings Window.
+ */
+
+- (IBAction) showPicturePanel: (id) sender
+{
+       [fPictureController showPictureWindow:sender];
+}
+
+- (void) picturePanelFullScreen
+{
+       [fPictureController setToFullScreenMode];
+}
+
+- (void) picturePanelWindowed
+{
+       [fPictureController setToWindowedMode];
+}
+
+- (IBAction) showPreviewWindow: (id) sender
+{
+       [fPictureController showPreviewWindow:sender];
+}
+
+#pragma mark -
+#pragma mark Preset Outline View Methods
+#pragma mark - Required
+/* These are required by the NSOutlineView Datasource Delegate */
+
+
+/* used to specify the number of levels to show for each item */
+- (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item
+{
+    /* currently use no levels to test outline view viability */
+    if (item == nil) // for an outline view the root level of the hierarchy is always nil
+    {
+        return [UserPresets count];
+    }
+    else
+    {
+        /* we need to return the count of the array in ChildrenArray for this folder */
+        NSArray *children = nil;
+        children = [item objectForKey:@"ChildrenArray"];
+        if ([children count] > 0)
+        {
+            return [children count];
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}
+
+/* We use this to deterimine children of an item */
+- (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item
+{
+    
+    /* we need to return the count of the array in ChildrenArray for this folder */
+    NSArray *children = nil;
+    if (item == nil)
+    {
+        children = UserPresets;
+    }
+    else
+    {
+        if ([item objectForKey:@"ChildrenArray"])
+        {
+            children = [item objectForKey:@"ChildrenArray"];
+        }
+    }   
+    if ((children == nil) || ( [children count] <= (NSUInteger) index))
+    {
+        return nil;
+    }
+    else
+    {
+        return [children objectAtIndex:index];
+    }
+    
+    
+    // We are only one level deep, so we can't be asked about children
+    //NSAssert (NO, @"Presets View outlineView:child:ofItem: currently can't handle nested items.");
+    //return nil;
+}
+
+/* We use this to determine if an item should be expandable */
+- (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item
+{
+    
+    /* we need to return the count of the array in ChildrenArray for this folder */
+    NSArray *children= nil;
+    if (item == nil)
+    {
+        children = UserPresets;
+    }
+    else
+    {
+        if ([item objectForKey:@"ChildrenArray"])
+        {
+            children = [item objectForKey:@"ChildrenArray"];
+        }
+    }   
+    
+    /* To deterimine if an item should show a disclosure triangle
+     * we could do it by the children count as so:
+     * if ([children count] < 1)
+     * However, lets leave the triangle show even if there are no
+     * children to help indicate a folder, just like folder in the
+     * finder can show a disclosure triangle even when empty
+     */
+    
+    /* We need to determine if the item is a folder */
+   if ([[item objectForKey:@"Folder"] intValue] == 1)
+   {
+        return YES;
+    }
+    else
+    {
+        return NO;
+    }
+    
+}
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item
+{
+    // Our outline view has no levels, but we can still expand every item. Doing so
+    // just makes the row taller. See heightOfRowByItem below.
+//return ![(HBQueueOutlineView*)outlineView isDragging];
+
+return YES;
+}
+
+
+/* Used to tell the outline view which information is to be displayed per item */
+- (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
+{
+       /* We have two columns right now, icon and PresetName */
+       
+    if ([[tableColumn identifier] isEqualToString:@"PresetName"])
+    {
+        return [item objectForKey:@"PresetName"];
+    }
+    else
+    {
+        //return @"";
+        return nil;
+    }
+}
+
+- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
+{
+    return [NSKeyedUnarchiver unarchiveObjectWithData:object];
+}
+- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
+{
+    return [NSKeyedArchiver archivedDataWithRootObject:item];
+}
+
+#pragma mark - Added Functionality (optional)
+/* Use to customize the font and display characteristics of the title cell */
+- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
+{
+    if ([[tableColumn identifier] isEqualToString:@"PresetName"])
+    {
+        NSFont *txtFont;
+        NSColor *fontColor;
+        NSColor *shadowColor;
+        txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
+        /*check to see if its a selected row */
+        if ([fPresetsOutlineView selectedRow] == [fPresetsOutlineView rowForItem:item])
+        {
+            
+            fontColor = [NSColor blackColor];
+            shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0];
+        }
+        else
+        {
+            if ([[item objectForKey:@"Type"] intValue] == 0)
+            {
+                fontColor = [NSColor blueColor];
+            }
+            else // User created preset, use a black font
+            {
+                fontColor = [NSColor blackColor];
+            }
+            /* check to see if its a folder */
+            //if ([[item objectForKey:@"Folder"] intValue] == 1)
+            //{
+            //fontColor = [NSColor greenColor];
+            //}
+            
+            
+        }
+        /* We use Bold Text for the HB Default */
+        if ([[item objectForKey:@"Default"] intValue] == 1)// 1 is HB default
+        {
+            txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
+        }
+        /* We use Bold Text for the User Specified Default */
+        if ([[item objectForKey:@"Default"] intValue] == 2)// 2 is User default
+        {
+            txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
+        }
+        
+        
+        [cell setTextColor:fontColor];
+        [cell setFont:txtFont];
+        
+    }
+}
+
+/* We use this to edit the name field in the outline view */
+- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
+{
+    if ([[tableColumn identifier] isEqualToString:@"PresetName"])
+    {
+        id theRecord;
+        
+        theRecord = item;
+        [theRecord setObject:object forKey:@"PresetName"];
+        
+        [self sortPresets];
+        
+        [fPresetsOutlineView reloadData];
+        /* We save all of the preset data here */
+        [self savePreset];
+    }
+}
+/* We use this to provide tooltips for the items in the presets outline view */
+- (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation
+{
+    //if ([[tc identifier] isEqualToString:@"PresetName"])
+    //{
+        /* initialize the tooltip contents variable */
+        NSString *loc_tip;
+        /* if there is a description for the preset, we show it in the tooltip */
+        if ([item objectForKey:@"PresetDescription"])
+        {
+            loc_tip = [item objectForKey:@"PresetDescription"];
+            return (loc_tip);
+        }
+        else
+        {
+            loc_tip = @"No description available";
+        }
+        return (loc_tip);
+    //}
+}
+
+#pragma mark -
+#pragma mark Preset Outline View Methods (dragging related)
+
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
+{
+       // Dragging is only allowed for custom presets.
+    //[[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Default"] intValue] != 1
+       if ([[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Type"] intValue] == 0) // 0 is built in preset
+    {
+        return NO;
+    }
+    // Don't retain since this is just holding temporaral drag information, and it is
+    //only used during a drag!  We could put this in the pboard actually.
+    fDraggedNodes = items;
+    // Provide data for our custom type, and simple NSStrings.
+    [pboard declareTypes:[NSArray arrayWithObjects: DragDropSimplePboardType, nil] owner:self];
+    
+    // the actual data doesn't matter since DragDropSimplePboardType drags aren't recognized by anyone but us!.
+    [pboard setData:[NSData data] forType:DragDropSimplePboardType]; 
+    
+    return YES;
+}
+
+- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
+{
+       
+       // Don't allow dropping ONTO an item since they can't really contain any children.
+    
+    BOOL isOnDropTypeProposal = index == NSOutlineViewDropOnItemIndex;
+    if (isOnDropTypeProposal)
+        return NSDragOperationNone;
+    
+    // Don't allow dropping INTO an item since they can't really contain any children as of yet.
+       if (item != nil)
+       {
+               index = [fPresetsOutlineView rowForItem: item] + 1;
+               item = nil;
+       }
+    
+    // Don't allow dropping into the Built In Presets.
+    if (index < presetCurrentBuiltInCount)
+    {
+        return NSDragOperationNone;
+        index = MAX (index, presetCurrentBuiltInCount);
+       }    
+       
+    [outlineView setDropItem:item dropChildIndex:index];
+    return NSDragOperationGeneric;
+}
+
+
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
+{
+    /* first, lets see if we are dropping into a folder */
+    if ([[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] && [[[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] intValue] == 1) // if its a folder
+       {
+    NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
+    childrenArray = [[fPresetsOutlineView itemAtRow:index] objectForKey:@"ChildrenArray"];
+    [childrenArray addObject:item];
+    [[fPresetsOutlineView itemAtRow:index] setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
+    [childrenArray autorelease];
+    }
+    else // We are not, so we just move the preset into the existing array 
+    {
+        NSMutableIndexSet *moveItems = [NSMutableIndexSet indexSet];
+        id obj;
+        NSEnumerator *enumerator = [fDraggedNodes objectEnumerator];
+        while (obj = [enumerator nextObject])
+        {
+            [moveItems addIndex:[UserPresets indexOfObject:obj]];
+        }
+        // Successful drop, lets rearrange the view and save it all
+        [self moveObjectsInPresetsArray:UserPresets fromIndexes:moveItems toIndex: index];
+    }
+    [fPresetsOutlineView reloadData];
+    [self savePreset];
+    return YES;
+}
+
+- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex
+{
+    NSUInteger index = [indexSet lastIndex];
+    NSUInteger aboveInsertIndexCount = 0;
+    
+    NSUInteger removeIndex;
+
+    if (index >= insertIndex)
+    {
+        removeIndex = index + aboveInsertIndexCount;
+        aboveInsertIndexCount++;
+    }
+    else
+    {
+        removeIndex = index;
+        insertIndex--;
+    }
+
+    id object = [[array objectAtIndex:removeIndex] retain];
+    [array removeObjectAtIndex:removeIndex];
+    [array insertObject:object atIndex:insertIndex];
+    [object release];
+
+    index = [indexSet indexLessThanIndex:index];
+}
+
+
+
+#pragma mark - Functional Preset NSOutlineView Methods
+
+- (IBAction)selectPreset:(id)sender
+{
+    
+    if ([fPresetsOutlineView selectedRow] >= 0 && [[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Folder"] intValue] != 1)
+    {
+        chosenPreset = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
+        [fPresetSelectedDisplay setStringValue:[chosenPreset objectForKey:@"PresetName"]];
+        
+        if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
+        {
+            [fPresetSelectedDisplay setStringValue:[NSString stringWithFormat:@"%@ (Default)", [chosenPreset objectForKey:@"PresetName"]]];
+        }
+        else
+        {
+            [fPresetSelectedDisplay setStringValue:[chosenPreset objectForKey:@"PresetName"]];
+        }
+        
+        /* File Format */
+        [fDstFormatPopUp selectItemWithTitle:[chosenPreset objectForKey:@"FileFormat"]];
+        [self formatPopUpChanged:nil];
+        
+        /* Chapter Markers*/
+        [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
+        /* check to see if we have only one chapter */
+        [self chapterPopUpChanged:nil];
+        
+        /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+        [fDstMp4LargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
+        /* Mux mp4 with http optimization */
+        [fDstMp4HttpOptFileCheck setState:[[chosenPreset objectForKey:@"Mp4HttpOptimize"] intValue]];
+        
+        /* Video encoder */
+        [fVidEncoderPopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoEncoder"]];
+        /* We set the advanced opt string here if applicable*/
+        [fAdvancedOptions setOptions:[chosenPreset objectForKey:@"x264Option"]];
+        
+        /* Lets run through the following functions to get variables set there */
+        [self videoEncoderPopUpChanged:nil];
+        /* Set the state of ipod compatible with Mp4iPodCompatible. Only for x264*/
+        [fDstMp4iPodFileCheck setState:[[chosenPreset objectForKey:@"Mp4iPodCompatible"] intValue]];
+        [self calculateBitrate:nil];
+        
+        /* Video quality */
+        [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
+        
+        [fVidTargetSizeField setStringValue:[chosenPreset objectForKey:@"VideoTargetSize"]];
+        [fVidBitrateField setStringValue:[chosenPreset objectForKey:@"VideoAvgBitrate"]];
+        
+        /* Since we are now using RF Values for the slider, we detect if the preset uses an old quality float.
+         * So, check to see if the quality value is less than 1.0 which should indicate the old ".062" type
+         * quality preset. Caveat: in the case of x264, where the RF scale starts at 0, it would misinterpret
+         * a preset that uses 0.0 - 0.99 for RF as an old style preset. Not sure how to get around that one yet,
+         * though it should be a corner case since it would pretty much be a preset for lossless encoding. */
+        if ([[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue] < 1.0)
+        {
+            /* For the quality slider we need to convert the old percent's to the new rf scales */
+            float rf =  (([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) * [[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]);
+            [fVidQualitySlider setFloatValue:rf];
+            
+        }
+        else
+        {
+            /* Since theora's qp value goes up from left to right, we can just set the slider float value */
+            if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_THEORA)
+            {
+                [fVidQualitySlider setFloatValue:[[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]];
+            }
+            else
+            {
+                /* since ffmpeg and x264 use an "inverted" slider (lower qp/rf values indicate a higher quality) we invert the value on the slider */
+                [fVidQualitySlider setFloatValue:([fVidQualitySlider maxValue] + [fVidQualitySlider minValue]) - [[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]];
+            }
+        }
+        
+        [self videoMatrixChanged:nil];
+        
+        /* Video framerate */
+        /* For video preset video framerate, we want to make sure that Same as source does not conflict with the
+         detected framerate in the fVidRatePopUp so we use index 0*/
+        if ([[chosenPreset objectForKey:@"VideoFramerate"] isEqualToString:@"Same as source"])
+        {
+            [fVidRatePopUp selectItemAtIndex: 0];
+        }
+        else
+        {
+            [fVidRatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoFramerate"]];
+        }
+        
+        
+        /* 2 Pass Encoding */
+        [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
+        [self twoPassCheckboxChanged:nil];
+        
+        /* Turbo 1st pass for 2 Pass Encoding */
+        [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
+        
+        /*Audio*/
+        /* First we check to see if we are using the current audio track layout based on AudioList array */
+        if ([chosenPreset objectForKey:@"AudioList"])
+        {
+            
+            /* pointer to this track's mixdown, codec, sample rate and bitrate NSPopUpButton's */
+            NSPopUpButton * trackLangPopUp = nil;
+            NSPopUpButton * mixdownPopUp = nil;
+            NSPopUpButton * audiocodecPopUp = nil;
+            NSPopUpButton * sampleratePopUp = nil;
+            NSPopUpButton * bitratePopUp = nil;
+            NSSlider      * drcSlider = nil;
+            
+            
+            /* Populate the audio widgets based on the contents of the AudioList array */
+            int i = 0;
+            NSEnumerator *enumerator = [[chosenPreset objectForKey:@"AudioList"] objectEnumerator];
+            id tempObject;
+            while (tempObject = [enumerator nextObject])
+            {
+                i++;
+                if( i == 1 )
+                {
+                    trackLangPopUp = fAudLang1PopUp;
+                    mixdownPopUp = fAudTrack1MixPopUp;
+                    audiocodecPopUp = fAudTrack1CodecPopUp;
+                    sampleratePopUp = fAudTrack1RatePopUp;
+                    bitratePopUp = fAudTrack1BitratePopUp;
+                    drcSlider = fAudTrack1DrcSlider;
+                }
+                if( i == 2 )
+                {
+                    trackLangPopUp = fAudLang2PopUp;
+                    mixdownPopUp = fAudTrack2MixPopUp;
+                    audiocodecPopUp = fAudTrack2CodecPopUp;
+                    sampleratePopUp = fAudTrack2RatePopUp;
+                    bitratePopUp = fAudTrack2BitratePopUp;
+                    drcSlider = fAudTrack2DrcSlider;
+                }
+                if( i == 3 )
+                {
+                    trackLangPopUp = fAudLang3PopUp;
+                    mixdownPopUp = fAudTrack3MixPopUp;
+                    audiocodecPopUp = fAudTrack3CodecPopUp;
+                    sampleratePopUp = fAudTrack3RatePopUp;
+                    bitratePopUp = fAudTrack3BitratePopUp;
+                    drcSlider = fAudTrack3DrcSlider;
+                }
+                if( i == 4 )
+                {
+                    trackLangPopUp = fAudLang4PopUp;
+                    mixdownPopUp = fAudTrack4MixPopUp;
+                    audiocodecPopUp = fAudTrack4CodecPopUp;
+                    sampleratePopUp = fAudTrack4RatePopUp;
+                    bitratePopUp = fAudTrack4BitratePopUp;
+                    drcSlider = fAudTrack4DrcSlider;
+                }
+                
+                
+                if ([trackLangPopUp indexOfSelectedItem] == 0)
+                {
+                    [trackLangPopUp selectItemAtIndex: 1];
+                }
+                [self audioTrackPopUpChanged: trackLangPopUp];
+                [audiocodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]];
+                /* check our pref for core audio and use it in place of faac if applicable */
+                if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && 
+                    [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"])
+                {
+                    [audiocodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"];
+                }                    
+                
+                [self audioTrackPopUpChanged: audiocodecPopUp];
+                [mixdownPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]];
+                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+                 * mixdown*/
+                if  ([mixdownPopUp selectedItem] == nil)
+                {
+                    [self audioTrackPopUpChanged: audiocodecPopUp];
+                }
+                [sampleratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]];
+                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+                if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"])
+                {
+                    [bitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]];
+                }
+                [drcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]];
+                [self audioDRCSliderChanged: drcSlider];
+                
+                
+                /* If we are any track greater than 1 check to make sure we have a matching source codec is using ac3 passthru or dts passthru,
+                 * if not we will set the track to "None". Track 1 is allowed to mixdown to a suitable DPL2 mix if we cannot passthru */
+                
+                if( i > 1 )
+                {
+                    /* Check to see if the preset asks for a passhthru track (AC3 or DTS) and verify there is a matching source track if not, set the track to "None". */
+                    if (([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] || [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"])  && [trackLangPopUp indexOfSelectedItem] != 0)
+                    {
+                        hb_audio_config_t * audio;
+                        /* get the audio source audio codec */
+                        audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, [trackLangPopUp indexOfSelectedItem] - 1 );
+                        if (audio != NULL && [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] && audio->in.codec != HB_ACODEC_AC3 ||
+                            [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"] && audio->in.codec != HB_ACODEC_DCA )
+                        {
+                            /* We have a preset using ac3 passthru but no ac3 source audio, so set the track to "None" and bail */
+                            if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"])
+                            {
+                                [self writeToActivityLog: "Preset calls for AC3 Pass thru ..."];
+                            }
+                            if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"])
+                            {
+                                [self writeToActivityLog: "Preset calls for DTS Pass thru ..."];
+                            }
+                            [self writeToActivityLog: "No matching source codec, setting track  %d to None", i];
+                            [trackLangPopUp selectItemAtIndex: 0];
+                            [self audioTrackPopUpChanged: trackLangPopUp]; 
+                        }   
+                    }
+                }
+            }
+            
+            /* We now cleanup any extra audio tracks that may have been previously set if we need to */
+            
+            if (i < 4)
+            {
+                [fAudLang4PopUp selectItemAtIndex: 0];
+                [self audioTrackPopUpChanged: fAudLang4PopUp];
+                
+                if (i < 3)
+                {
+                    [fAudLang3PopUp selectItemAtIndex: 0];
+                    [self audioTrackPopUpChanged: fAudLang3PopUp];
+                    
+                    if (i < 2)
+                    {
+                        [fAudLang2PopUp selectItemAtIndex: 0];
+                        [self audioTrackPopUpChanged: fAudLang2PopUp];
+                    }
+                }
+            }
+            
+        }
+        else
+        {
+            if ([chosenPreset objectForKey:@"Audio1Track"] > 0)
+            {
+                if ([fAudLang1PopUp indexOfSelectedItem] == 0)
+                {
+                    [fAudLang1PopUp selectItemAtIndex: 1];
+                }
+                [self audioTrackPopUpChanged: fAudLang1PopUp];
+                [fAudTrack1CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Encoder"]];
+                /* check our pref for core audio and use it in place of faac if applicable */
+                if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && 
+                    [[chosenPreset objectForKey:@"Audio1Encoder"] isEqualToString: @"AAC (faac)"])
+                {
+                    [fAudTrack1CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"];
+                }
+                [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
+                [fAudTrack1MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Mixdown"]];
+                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+                 * mixdown*/
+                if  ([fAudTrack1MixPopUp selectedItem] == nil)
+                {
+                    [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
+                }
+                [fAudTrack1RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Samplerate"]];
+                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+                if (![[chosenPreset objectForKey:@"Audio1Encoder"] isEqualToString:@"AC3 Passthru"])
+                {
+                    [fAudTrack1BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Bitrate"]];
+                }
+                [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio1TrackDRCSlider"] floatValue]];
+                [self audioDRCSliderChanged: fAudTrack1DrcSlider];
+            }
+            
+            if ([chosenPreset objectForKey:@"Audio2Track"] > 0)
+            {
+                if ([fAudLang2PopUp indexOfSelectedItem] == 0)
+                {
+                    [fAudLang2PopUp selectItemAtIndex: 1];
+                }
+                [self audioTrackPopUpChanged: fAudLang2PopUp];
+                [fAudTrack2CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Encoder"]];
+                /* check our pref for core audio and use it in place of faac if applicable */
+                if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && 
+                    [[chosenPreset objectForKey:@"Audio2Encoder"] isEqualToString: @"AAC (faac)"])
+                {
+                    [fAudTrack2CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"];
+                }
+                [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
+                [fAudTrack2MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Mixdown"]];
+                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+                 * mixdown*/
+                if  ([fAudTrack2MixPopUp selectedItem] == nil)
+                {
+                    [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
+                }
+                [fAudTrack2RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Samplerate"]];
+                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+                if (![[chosenPreset objectForKey:@"Audio2Encoder"] isEqualToString:@"AC3 Passthru"])
+                {
+                    [fAudTrack2BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Bitrate"]];
+                }
+                [fAudTrack2DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio2TrackDRCSlider"] floatValue]];
+                [self audioDRCSliderChanged: fAudTrack2DrcSlider];
+            }
+            if ([chosenPreset objectForKey:@"Audio3Track"] > 0)
+            {
+                if ([fAudLang3PopUp indexOfSelectedItem] == 0)
+                {
+                    [fAudLang3PopUp selectItemAtIndex: 1];
+                }
+                [self audioTrackPopUpChanged: fAudLang3PopUp];
+                [fAudTrack3CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Encoder"]];
+                /* check our pref for core audio and use it in place of faac if applicable */
+                if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && 
+                    [[chosenPreset objectForKey:@"Audio3Encoder"] isEqualToString: @"AAC (faac)"])
+                {
+                    [fAudTrack3CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"];
+                }
+                [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
+                [fAudTrack3MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Mixdown"]];
+                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+                 * mixdown*/
+                if  ([fAudTrack3MixPopUp selectedItem] == nil)
+                {
+                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
+                }
+                [fAudTrack3RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Samplerate"]];
+                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+                if (![[chosenPreset objectForKey:@"Audio3Encoder"] isEqualToString: @"AC3 Passthru"])
+                {
+                    [fAudTrack3BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Bitrate"]];
+                }
+                [fAudTrack3DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio3TrackDRCSlider"] floatValue]];
+                [self audioDRCSliderChanged: fAudTrack3DrcSlider];
+            }
+            if ([chosenPreset objectForKey:@"Audio4Track"] > 0)
+            {
+                if ([fAudLang4PopUp indexOfSelectedItem] == 0)
+                {
+                    [fAudLang4PopUp selectItemAtIndex: 1];
+                }
+                [self audioTrackPopUpChanged: fAudLang4PopUp];
+                [fAudTrack4CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Encoder"]];
+                /* check our pref for core audio and use it in place of faac if applicable */
+                if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && 
+                    [[chosenPreset objectForKey:@"Audio4Encoder"] isEqualToString: @"AAC (faac)"])
+                {
+                    [fAudTrack4CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"];
+                }
+                [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
+                [fAudTrack4MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Mixdown"]];
+                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+                 * mixdown*/
+                if  ([fAudTrack4MixPopUp selectedItem] == nil)
+                {
+                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
+                }
+                [fAudTrack4RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Samplerate"]];
+                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+                if (![[chosenPreset objectForKey:@"Audio4Encoder"] isEqualToString:@"AC3 Passthru"])
+                {
+                    [fAudTrack4BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Bitrate"]];
+                }
+                [fAudTrack4DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio4TrackDRCSlider"] floatValue]];
+                [self audioDRCSliderChanged: fAudTrack4DrcSlider];
+            }
+            
+            /* We now cleanup any extra audio tracks that may have been previously set if we need to */
+            
+            if (![chosenPreset objectForKey:@"Audio2Track"] || [chosenPreset objectForKey:@"Audio2Track"] == 0)
+            {
+                [fAudLang2PopUp selectItemAtIndex: 0];
+                [self audioTrackPopUpChanged: fAudLang2PopUp];
+            }
+            if (![chosenPreset objectForKey:@"Audio3Track"] || [chosenPreset objectForKey:@"Audio3Track"] > 0)
+            {
+                [fAudLang3PopUp selectItemAtIndex: 0];
+                [self audioTrackPopUpChanged: fAudLang3PopUp];
+            }
+            if (![chosenPreset objectForKey:@"Audio4Track"] || [chosenPreset objectForKey:@"Audio4Track"] > 0)
+            {
+                [fAudLang4PopUp selectItemAtIndex: 0];
+                [self audioTrackPopUpChanged: fAudLang4PopUp];
+            }
+        }
+        
+        /*Subtitles*/
+        [fSubPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Subtitles"]];
+        /* Forced Subtitles */
+        [fSubForcedCheck setState:[[chosenPreset objectForKey:@"SubtitlesForced"] intValue]];
+        
+        /* Picture Settings */
+        /* Note: objectForKey:@"UsesPictureSettings" refers to picture size, which encompasses:
+         * height, width, keep ar, anamorphic and crop settings.
+         * picture filters are handled separately below.
+         */
+        /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None" 
+         * ( 2 is use max for source and 1 is use exact size when the preset was created ) and the 
+         * preset completely ignores any picture sizing values in the preset.
+         */
+        if ([[chosenPreset objectForKey:@"UsesPictureSettings"]  intValue] > 0)
+        {
+            hb_job_t * job = fTitle->job;
+            
+            /* If Cropping is set to custom, then recall all four crop values from
+             when the preset was created and apply them */
+            if ([[chosenPreset objectForKey:@"PictureAutoCrop"]  intValue] == 0)
+            {
+                [fPictureController setAutoCrop:NO];
+                
+                /* Here we use the custom crop values saved at the time the preset was saved */
+                job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"]  intValue];
+                job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"]  intValue];
+                job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"]  intValue];
+                job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"]  intValue];
+                
+            }
+            else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
+            {
+                [fPictureController setAutoCrop:YES];
+                /* Here we use the auto crop values determined right after scan */
+                job->crop[0] = AutoCropTop;
+                job->crop[1] = AutoCropBottom;
+                job->crop[2] = AutoCropLeft;
+                job->crop[3] = AutoCropRight;
+                
+            }
+            
+            
+            /* Check to see if the objectForKey:@"UsesPictureSettings is 2 which is "Use Max for the source */
+            if ([[chosenPreset objectForKey:@"UsesPictureSettings"]  intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"]  intValue] == 1)
+            {
+                /* Use Max Picture settings for whatever the dvd is.*/
+                [self revertPictureSizeToMax:nil];
+                job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"]  intValue];
+                if (job->keep_ratio == 1)
+                {
+                    hb_fix_aspect( job, HB_KEEP_WIDTH );
+                    if( job->height > fTitle->height )
+                    {
+                        job->height = fTitle->height;
+                        hb_fix_aspect( job, HB_KEEP_HEIGHT );
+                    }
+                }
+                job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
+            }
+            else // /* If not 0 or 2 we assume objectForKey:@"UsesPictureSettings is 1 which is "Use picture sizing from when the preset was set" */
+            {
+                /* we check to make sure the presets width/height does not exceed the sources width/height */
+                if (fTitle->width < [[chosenPreset objectForKey:@"PictureWidth"]  intValue] || fTitle->height < [[chosenPreset objectForKey:@"PictureHeight"]  intValue])
+                {
+                    /* if so, then we use the sources height and width to avoid scaling up */
+                    //job->width = fTitle->width;
+                    //job->height = fTitle->height;
+                    [self revertPictureSizeToMax:nil];
+                }
+                else // source width/height is >= the preset height/width
+                {
+                    /* we can go ahead and use the presets values for height and width */
+                    job->width = [[chosenPreset objectForKey:@"PictureWidth"]  intValue];
+                    job->height = [[chosenPreset objectForKey:@"PictureHeight"]  intValue];
+                }
+                job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"]  intValue];
+                if (job->keep_ratio == 1)
+                {
+                    hb_fix_aspect( job, HB_KEEP_WIDTH );
+                    if( job->height > fTitle->height )
+                    {
+                        job->height = fTitle->height;
+                        hb_fix_aspect( job, HB_KEEP_HEIGHT );
+                    }
+                }
+                job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
+                
+            }
+            
+            
+        }
+        /* If the preset has an objectForKey:@"UsesPictureFilters", and handle the filters here */
+        if ([chosenPreset objectForKey:@"UsesPictureFilters"] && [[chosenPreset objectForKey:@"UsesPictureFilters"]  intValue] > 0)
+        {
+            /* Filters */
+            
+            /* We only allow *either* Decomb or Deinterlace. So check for the PictureDecombDeinterlace key.
+             * also, older presets may not have this key, in which case we also check to see if that preset had  PictureDecomb
+             * specified, in which case we use decomb and ignore any possible Deinterlace settings as using both was less than
+             * sane.
+             */
+            [fPictureController setUseDecomb:1];
+            [fPictureController setDecomb:0];
+            [fPictureController setDeinterlace:0];
+            if ([[chosenPreset objectForKey:@"PictureDecombDeinterlace"] intValue] == 1 || [[chosenPreset objectForKey:@"PictureDecomb"] intValue] > 0)
+            {
+                /* we are using decomb */
+                /* Decomb */
+                if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] > 0)
+                {
+                    [fPictureController setDecomb:[[chosenPreset objectForKey:@"PictureDecomb"] intValue]];
+                    
+                    /* if we are using "Custom" in the decomb setting, also set the custom string*/
+                    if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] == 1)
+                    {
+                        [fPictureController setDecombCustomString:[chosenPreset objectForKey:@"PictureDecombCustom"]];    
+                    }
+                }
+             }
+            else
+            {
+                /* We are using Deinterlace */
+                /* Deinterlace */
+                if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] > 0)
+                {
+                    [fPictureController setUseDecomb:0];
+                    [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
+                    /* if we are using "Custom" in the deinterlace setting, also set the custom string*/
+                    if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] == 1)
+                    {
+                        [fPictureController setDeinterlaceCustomString:[chosenPreset objectForKey:@"PictureDeinterlaceCustom"]];    
+                    }
+                }
+            }
+            
+            
+            /* Detelecine */
+            if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] > 0)
+            {
+                [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
+                /* if we are using "Custom" in the detelecine setting, also set the custom string*/
+                if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] == 1)
+                {
+                    [fPictureController setDetelecineCustomString:[chosenPreset objectForKey:@"PictureDetelecineCustom"]];    
+                }
+            }
+            else
+            {
+                [fPictureController setDetelecine:0];
+            }
+            
+            /* Denoise */
+            if ([[chosenPreset objectForKey:@"PictureDenoise"] intValue] > 0)
+            {
+                [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
+                /* if we are using "Custom" in the denoise setting, also set the custom string*/
+                if ([[chosenPreset objectForKey:@"PictureDenoise"] intValue] == 1)
+                {
+                    [fPictureController setDenoiseCustomString:[chosenPreset objectForKey:@"PictureDenoiseCustom"]];    
+                }
+            }
+            else
+            {
+                [fPictureController setDenoise:0];
+            }   
+            
+            /* Deblock */
+            if ([[chosenPreset objectForKey:@"PictureDeblock"] intValue] == 1)
+            {
+                /* if its a one, then its the old on/off deblock, set on to 5*/
+                [fPictureController setDeblock:5];
+            }
+            else
+            {
+                /* use the settings intValue */
+                [fPictureController setDeblock:[[chosenPreset objectForKey:@"PictureDeblock"] intValue]];
+            }
+            
+            if ([[chosenPreset objectForKey:@"VideoGrayScale"] intValue] == 1)
+            {
+                [fPictureController setGrayscale:1];
+            }
+            else
+            {
+                [fPictureController setGrayscale:0];
+            }
+        }
+        /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */
+        [fPictureController SetTitle:fTitle];
+        [fPictureController SetTitle:fTitle];
+        [self calculatePictureSizing:nil];
+    }
+}
+
+
+#pragma mark -
+#pragma mark Manage Presets
+
+- (void) loadPresets {
+       /* We declare the default NSFileManager into fileManager */
+       NSFileManager * fileManager = [NSFileManager defaultManager];
+       /*We define the location of the user presets file */
+    UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
+       UserPresetsFile = [[UserPresetsFile stringByExpandingTildeInPath]retain];
+    /* We check for the presets.plist */
+       if ([fileManager fileExistsAtPath:UserPresetsFile] == 0)
+       {
+               [fileManager createFileAtPath:UserPresetsFile contents:nil attributes:nil];
+       }
+
+       UserPresets = [[NSMutableArray alloc] initWithContentsOfFile:UserPresetsFile];
+       if (nil == UserPresets)
+       {
+               UserPresets = [[NSMutableArray alloc] init];
+               [self addFactoryPresets:nil];
+       }
+       [fPresetsOutlineView reloadData];
+    
+    [self checkBuiltInsForUpdates];
+}
+
+- (void) checkBuiltInsForUpdates {
+    
+       BOOL updateBuiltInPresets = NO;
+    int i = 0;
+    NSEnumerator *enumerator = [UserPresets objectEnumerator];
+    id tempObject;
+    while (tempObject = [enumerator nextObject])
+    {
+        /* iterate through the built in presets to see if any have an old build number */
+        NSMutableDictionary *thisPresetDict = tempObject;
+        /*Key Type == 0 is built in, and key PresetBuildNumber is the build number it was created with */
+        if ([[thisPresetDict objectForKey:@"Type"] intValue] == 0)             
+        {
+                       if (![thisPresetDict objectForKey:@"PresetBuildNumber"] || [[thisPresetDict objectForKey:@"PresetBuildNumber"] intValue] < [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] intValue])
+            {
+                updateBuiltInPresets = YES;
+            }  
+               }
+        i++;
+    }
+    /* if we have built in presets to update, then do so AlertBuiltInPresetUpdate*/
+    if ( updateBuiltInPresets == YES)
+    {
+        if( [[NSUserDefaults standardUserDefaults] boolForKey:@"AlertBuiltInPresetUpdate"] == YES)
+        {
+            /* Show an alert window that built in presets will be updated */
+            /*On Screen Notification*/
+            int status;
+            NSBeep();
+            status = NSRunAlertPanel(@"HandBrake has determined your built in presets are out of date...",@"HandBrake will now update your built-in presets.", @"OK", nil, nil);
+            [NSApp requestUserAttention:NSCriticalRequest];
+        }
+        /* when alert is dismissed, go ahead and update the built in presets */
+        [self addFactoryPresets:nil];
+    }
+    
+}
+
+
+- (IBAction) showAddPresetPanel: (id) sender
+{
+    /* Deselect the currently selected Preset if there is one*/
+    [fPresetsOutlineView deselectRow:[fPresetsOutlineView selectedRow]];
+
+    /* Populate the preset picture settings popup here */
+    [fPresetNewPicSettingsPopUp removeAllItems];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
+    [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
+    [fPresetNewPicSettingsPopUp selectItemAtIndex: 0]; 
+    /* Uncheck the preset use filters checkbox */
+    [fPresetNewPicFiltersCheck setState:NSOffState];
+    // fPresetNewFolderCheck
+    [fPresetNewFolderCheck setState:NSOffState];
+    /* Erase info from the input fields*/
+       [fPresetNewName setStringValue: @""];
+       [fPresetNewDesc setStringValue: @""];
+       /* Show the panel */
+       [NSApp beginSheet:fAddPresetPanel modalForWindow:fWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
+}
+
+- (IBAction) closeAddPresetPanel: (id) sender
+{
+    [NSApp endSheet: fAddPresetPanel];
+    [fAddPresetPanel orderOut: self];
+}
+
+- (IBAction)addUserPreset:(id)sender
+{
+    if (![[fPresetNewName stringValue] length])
+            NSRunAlertPanel(@"Warning!", @"You need to insert a name for the preset.", @"OK", nil , nil);
+    else
+    {
+        /* Here we create a custom user preset */
+        [UserPresets addObject:[self createPreset]];
+        [self addPreset];
+
+        [self closeAddPresetPanel:nil];
+    }
+}
+- (void)addPreset
+{
+
+       
+       /* We Reload the New Table data for presets */
+    [fPresetsOutlineView reloadData];
+   /* We save all of the preset data here */
+    [self savePreset];
+}
+
+- (void)sortPresets
+{
+
+       
+       /* We Sort the Presets By Factory or Custom */
+       NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type" 
+                                                    ascending:YES] autorelease];
+       /* We Sort the Presets Alphabetically by name  We do not use this now as we have drag and drop*/
+       /*
+    NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName" 
+                                                    ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
+       //NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
+    
+    */
+    /* Since we can drag and drop our custom presets, lets just sort by type and not name */
+    NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,nil];
+       NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
+       [UserPresets setArray:sortedArray];
+       
+
+}
+
+- (IBAction)insertPreset:(id)sender
+{
+    int index = [fPresetsOutlineView selectedRow];
+    [UserPresets insertObject:[self createPreset] atIndex:index];
+    [fPresetsOutlineView reloadData];
+    [self savePreset];
+}
+
+- (NSDictionary *)createPreset
+{
+    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
+    /* Preset build number */
+    [preset setObject:[NSString stringWithFormat: @"%d", [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] intValue]] forKey:@"PresetBuildNumber"];
+    [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
+       /* Get the New Preset Name from the field in the AddPresetPanel */
+    [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
+    /* Set whether or not this is to be a folder fPresetNewFolderCheck*/
+    [preset setObject:[NSNumber numberWithBool:[fPresetNewFolderCheck state]] forKey:@"Folder"];
+       /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
+       [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
+       /*Set whether or not this is default, at creation set to 0*/
+       [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
+    if ([fPresetNewFolderCheck state] == YES)
+    {
+        /* initialize and set an empty array for children here since we are a new folder */
+        NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
+        [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
+        [childrenArray autorelease];
+    }
+    else // we are not creating a preset folder, so we go ahead with the rest of the preset info
+    {
+        /*Get the whether or not to apply pic Size and Cropping (includes Anamorphic)*/
+        [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
+        /* Get whether or not to use the current Picture Filter settings for the preset */
+        [preset setObject:[NSNumber numberWithInt:[fPresetNewPicFiltersCheck state]] forKey:@"UsesPictureFilters"];
+        
+        /* Get New Preset Description from the field in the AddPresetPanel*/
+        [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
+        /* File Format */
+        [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
+        /* Chapter Markers fCreateChapterMarkers*/
+        [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
+        /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4LargeFileCheck state]] forKey:@"Mp4LargeFile"];
+        /* Mux mp4 with http optimization */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4HttpOptFileCheck state]] forKey:@"Mp4HttpOptimize"];
+        /* Add iPod uuid atom */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4iPodFileCheck state]] forKey:@"Mp4iPodCompatible"];
+        
+        /* Codecs */
+        /* Video encoder */
+        [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
+        /* x264 Option String */
+        [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
+        
+        [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
+        [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
+        [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
+        [preset setObject:[NSNumber numberWithFloat:[fVidQualityRFField floatValue]] forKey:@"VideoQualitySlider"];
+        
+        /* Video framerate */
+        if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected
+        {
+            [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
+        }
+        else // we can record the actual titleOfSelectedItem
+        {
+            [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
+        }
+        
+        /* 2 Pass Encoding */
+        [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
+        /* Turbo 2 pass Encoding fVidTurboPassCheck*/
+        [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
+        /*Picture Settings*/
+        hb_job_t * job = fTitle->job;
+        /* Picture Sizing */
+        /* Use Max Picture settings for whatever the dvd is.*/
+        [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
+        
+        /* Set crop settings here */
+        [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
+        
+        /* Picture Filters */
+        [preset setObject:[NSNumber numberWithInt:[fPictureController useDecomb]] forKey:@"PictureDecombDeinterlace"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
+        [preset setObject:[fPictureController deinterlaceCustomString] forKey:@"PictureDeinterlaceCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
+        [preset setObject:[fPictureController detelecineCustomString] forKey:@"PictureDetelecineCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
+        [preset setObject:[fPictureController denoiseCustomString] forKey:@"PictureDenoiseCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureController deblock]] forKey:@"PictureDeblock"]; 
+        [preset setObject:[NSNumber numberWithInt:[fPictureController decomb]] forKey:@"PictureDecomb"];
+        [preset setObject:[fPictureController decombCustomString] forKey:@"PictureDecombCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureController grayscale]] forKey:@"VideoGrayScale"];
+        
+        /*Audio*/
+        NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
+        /* we actually call the methods for the nests here */
+        if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+        {
+            NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+            [audioTrack1Array setObject:[NSNumber numberWithInt:[fAudLang1PopUp indexOfSelectedItem]] forKey:@"AudioTrack"];
+            [audioTrack1Array setObject:[fAudLang1PopUp titleOfSelectedItem] forKey:@"AudioTrackDescription"];
+            [audioTrack1Array setObject:[fAudTrack1CodecPopUp titleOfSelectedItem] forKey:@"AudioEncoder"];
+            [audioTrack1Array setObject:[fAudTrack1MixPopUp titleOfSelectedItem] forKey:@"AudioMixdown"];
+            [audioTrack1Array setObject:[fAudTrack1RatePopUp titleOfSelectedItem] forKey:@"AudioSamplerate"];
+            [audioTrack1Array setObject:[fAudTrack1BitratePopUp titleOfSelectedItem] forKey:@"AudioBitrate"];
+            [audioTrack1Array setObject:[NSNumber numberWithFloat:[fAudTrack1DrcSlider floatValue]] forKey:@"AudioTrackDRCSlider"];
+            [audioTrack1Array autorelease];
+            [audioListArray addObject:audioTrack1Array];
+        }
+        
+        if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+        {
+            NSMutableDictionary *audioTrack2Array = [[NSMutableDictionary alloc] init];
+            [audioTrack2Array setObject:[NSNumber numberWithInt:[fAudLang2PopUp indexOfSelectedItem]] forKey:@"AudioTrack"];
+            [audioTrack2Array setObject:[fAudLang2PopUp titleOfSelectedItem] forKey:@"AudioTrackDescription"];
+            [audioTrack2Array setObject:[fAudTrack2CodecPopUp titleOfSelectedItem] forKey:@"AudioEncoder"];
+            [audioTrack2Array setObject:[fAudTrack2MixPopUp titleOfSelectedItem] forKey:@"AudioMixdown"];
+            [audioTrack2Array setObject:[fAudTrack2RatePopUp titleOfSelectedItem] forKey:@"AudioSamplerate"];
+            [audioTrack2Array setObject:[fAudTrack2BitratePopUp titleOfSelectedItem] forKey:@"AudioBitrate"];
+            [audioTrack2Array setObject:[NSNumber numberWithFloat:[fAudTrack2DrcSlider floatValue]] forKey:@"AudioTrackDRCSlider"];
+            [audioTrack2Array autorelease];
+            [audioListArray addObject:audioTrack2Array];
+        }
+        
+        if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+        {
+            NSMutableDictionary *audioTrack3Array = [[NSMutableDictionary alloc] init];
+            [audioTrack3Array setObject:[NSNumber numberWithInt:[fAudLang3PopUp indexOfSelectedItem]] forKey:@"AudioTrack"];
+            [audioTrack3Array setObject:[fAudLang3PopUp titleOfSelectedItem] forKey:@"AudioTrackDescription"];
+            [audioTrack3Array setObject:[fAudTrack3CodecPopUp titleOfSelectedItem] forKey:@"AudioEncoder"];
+            [audioTrack3Array setObject:[fAudTrack3MixPopUp titleOfSelectedItem] forKey:@"AudioMixdown"];
+            [audioTrack3Array setObject:[fAudTrack3RatePopUp titleOfSelectedItem] forKey:@"AudioSamplerate"];
+            [audioTrack3Array setObject:[fAudTrack3BitratePopUp titleOfSelectedItem] forKey:@"AudioBitrate"];
+            [audioTrack3Array setObject:[NSNumber numberWithFloat:[fAudTrack3DrcSlider floatValue]] forKey:@"AudioTrackDRCSlider"];
+            [audioTrack3Array autorelease];
+            [audioListArray addObject:audioTrack3Array];
+        }
+        
+        if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+        {
+            NSMutableDictionary *audioTrack4Array = [[NSMutableDictionary alloc] init];
+            [audioTrack4Array setObject:[NSNumber numberWithInt:[fAudLang4PopUp indexOfSelectedItem]] forKey:@"AudioTrack"];
+            [audioTrack4Array setObject:[fAudLang4PopUp titleOfSelectedItem] forKey:@"AudioTrackDescription"];
+            [audioTrack4Array setObject:[fAudTrack4CodecPopUp titleOfSelectedItem] forKey:@"AudioEncoder"];
+            [audioTrack4Array setObject:[fAudTrack4MixPopUp titleOfSelectedItem] forKey:@"AudioMixdown"];
+            [audioTrack4Array setObject:[fAudTrack4RatePopUp titleOfSelectedItem] forKey:@"AudioSamplerate"];
+            [audioTrack4Array setObject:[fAudTrack4BitratePopUp titleOfSelectedItem] forKey:@"AudioBitrate"];
+            [audioTrack4Array setObject:[NSNumber numberWithFloat:[fAudTrack4DrcSlider floatValue]] forKey:@"AudioTrackDRCSlider"];
+            [audioTrack4Array autorelease];
+            [audioListArray addObject:audioTrack4Array];
+        }
+        
+        
+        [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
+
+        
+        /* Temporarily remove subtitles from creating a new preset as it has to be converted over to use the new
+         * subititle array code. */
+        /* Subtitles*/
+        //[preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
+        /* Forced Subtitles */
+        //[preset setObject:[NSNumber numberWithInt:[fSubForcedCheck state]] forKey:@"SubtitlesForced"];
+    }
+    [preset autorelease];
+    return preset;
+    
+}
+
+- (void)savePreset
+{
+    [UserPresets writeToFile:UserPresetsFile atomically:YES];
+       /* We get the default preset in case it changed */
+       [self getDefaultPresets:nil];
+
+}
+
+- (IBAction)deletePreset:(id)sender
+{
+    
+    
+    if ( [fPresetsOutlineView numberOfSelectedRows] == 0 )
+    {
+        return;
+    }
+    /* Alert user before deleting preset */
+       int status;
+    status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
+    
+    if ( status == NSAlertDefaultReturn ) 
+    {
+        int presetToModLevel = [fPresetsOutlineView levelForItem: [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]]];
+        NSDictionary *presetToMod = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
+        NSDictionary *presetToModParent = [fPresetsOutlineView parentForItem: presetToMod];
+        
+        NSEnumerator *enumerator;
+        NSMutableArray *presetsArrayToMod;
+        NSMutableArray *tempArray;
+        id tempObject;
+        /* If we are a root level preset, we are modding the UserPresets array */
+        if (presetToModLevel == 0)
+        {
+            presetsArrayToMod = UserPresets;
+        }
+        else // We have a parent preset, so we modify the chidren array object for key
+        {
+            presetsArrayToMod = [presetToModParent objectForKey:@"ChildrenArray"]; 
+        }
+        
+        enumerator = [presetsArrayToMod objectEnumerator];
+        tempArray = [NSMutableArray array];
+        
+        while (tempObject = [enumerator nextObject]) 
+        {
+            NSDictionary *thisPresetDict = tempObject;
+            if (thisPresetDict == presetToMod)
+            {
+                [tempArray addObject:tempObject];
+            }
+        }
+        
+        [presetsArrayToMod removeObjectsInArray:tempArray];
+        [fPresetsOutlineView reloadData];
+        [self savePreset];   
+    }
+}
+
+
+#pragma mark -
+#pragma mark Import Export Preset(s)
+
+- (IBAction) browseExportPresetFile: (id) sender
+{
+    /* Open a panel to let the user choose where and how to save the export file */
+    NSSavePanel * panel = [NSSavePanel savePanel];
+       /* We get the current file name and path from the destination field here */
+    NSString *defaultExportDirectory = [NSString stringWithFormat: @"%@/Desktop/", NSHomeDirectory()];
+
+       [panel beginSheetForDirectory: defaultExportDirectory file: @"HB_Export.plist"
+                                  modalForWindow: fWindow modalDelegate: self
+                                  didEndSelector: @selector( browseExportPresetFileDone:returnCode:contextInfo: )
+                                         contextInfo: NULL];
+}
+
+- (void) browseExportPresetFileDone: (NSSavePanel *) sheet
+                   returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSOKButton )
+    {
+        NSString *presetExportDirectory = [[sheet filename] stringByDeletingLastPathComponent];
+        NSString *exportPresetsFile = [sheet filename];
+        [[NSUserDefaults standardUserDefaults] setObject:presetExportDirectory forKey:@"LastPresetExportDirectory"];
+        /* We check for the presets.plist */
+        if ([[NSFileManager defaultManager] fileExistsAtPath:exportPresetsFile] == 0)
+        {
+            [[NSFileManager defaultManager] createFileAtPath:exportPresetsFile contents:nil attributes:nil];
+        }
+        NSMutableArray * presetsToExport = [[NSMutableArray alloc] initWithContentsOfFile:exportPresetsFile];
+        if (nil == presetsToExport)
+        {
+            presetsToExport = [[NSMutableArray alloc] init];
+            
+            /* now get and add selected presets to export */
+            
+        }
+        if ([fPresetsOutlineView selectedRow] >= 0 && [[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Folder"] intValue] != 1)
+        {
+            [presetsToExport addObject:[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]]];
+            [presetsToExport writeToFile:exportPresetsFile atomically:YES];
+            
+        }
+        
+    }
+}
+
+
+- (IBAction) browseImportPresetFile: (id) sender
+{
+
+    NSOpenPanel * panel;
+       
+    panel = [NSOpenPanel openPanel];
+    [panel setAllowsMultipleSelection: NO];
+    [panel setCanChooseFiles: YES];
+    [panel setCanChooseDirectories: NO ];
+    NSString * sourceDirectory;
+       if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastPresetImportDirectory"])
+       {
+               sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastPresetImportDirectory"];
+       }
+       else
+       {
+               sourceDirectory = @"~/Desktop";
+               sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
+       }
+    /* we open up the browse sources sheet here and call for browseSourcesDone after the sheet is closed
+        * to evaluate whether we want to specify a title, we pass the sender in the contextInfo variable
+        */
+    /* set this for allowed file types, not sure if we should allow xml or not */
+    NSArray *fileTypes = [NSArray arrayWithObjects:@"plist", @"xml", nil];
+    [panel beginSheetForDirectory: sourceDirectory file: nil types: fileTypes
+                   modalForWindow: fWindow modalDelegate: self
+                   didEndSelector: @selector( browseImportPresetDone:returnCode:contextInfo: )
+                      contextInfo: sender];
+}
+
+- (void) browseImportPresetDone: (NSSavePanel *) sheet
+                     returnCode: (int) returnCode contextInfo: (void *) contextInfo
+{
+    if( returnCode == NSOKButton )
+    {
+        NSString *importPresetsDirectory = [[sheet filename] stringByDeletingLastPathComponent];
+        NSString *importPresetsFile = [sheet filename];
+        [[NSUserDefaults standardUserDefaults] setObject:importPresetsDirectory forKey:@"LastPresetImportDirectory"];
+        /* NOTE: here we need to do some sanity checking to verify we do not hose up our presets file   */
+        NSMutableArray * presetsToImport = [[NSMutableArray alloc] initWithContentsOfFile:importPresetsFile];
+        /* iterate though the new array of presets to import and add them to our presets array */
+        int i = 0;
+        NSEnumerator *enumerator = [presetsToImport objectEnumerator];
+        id tempObject;
+        while (tempObject = [enumerator nextObject])
+        {
+            /* make any changes to the incoming preset we see fit */
+            /* make sure the incoming preset is not tagged as default */
+            [tempObject setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
+            /* prepend "(imported) to the name of the incoming preset for clarification since it can be changed */
+            NSString * prependedName = [@"(import) " stringByAppendingString:[tempObject objectForKey:@"PresetName"]] ;
+            [tempObject setObject:prependedName forKey:@"PresetName"];
+            
+            /* actually add the new preset to our presets array */
+            [UserPresets addObject:tempObject];
+            i++;
+        }
+        [presetsToImport autorelease];
+        [self sortPresets];
+        [self addPreset];
+        
+    }
+}
+
+#pragma mark -
+#pragma mark Manage Default Preset
+
+- (IBAction)getDefaultPresets:(id)sender
+{
+       presetHbDefault = nil;
+    presetUserDefault = nil;
+    presetUserDefaultParent = nil;
+    presetUserDefaultParentParent = nil;
+    NSMutableDictionary *presetHbDefaultParent = nil;
+    NSMutableDictionary *presetHbDefaultParentParent = nil;
+    
+    int i = 0;
+    BOOL userDefaultFound = NO;
+    presetCurrentBuiltInCount = 0;
+    /* First we iterate through the root UserPresets array to check for defaults */
+    NSEnumerator *enumerator = [UserPresets objectEnumerator];
+       id tempObject;
+       while (tempObject = [enumerator nextObject])
+       {
+               NSMutableDictionary *thisPresetDict = tempObject;
+               if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
+               {
+                       presetHbDefault = thisPresetDict;       
+               }
+               if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
+               {
+                       presetUserDefault = thisPresetDict;
+            userDefaultFound = YES;
+        }
+        if ([[thisPresetDict objectForKey:@"Type"] intValue] == 0) // Type 0 is a built in preset              
+        {
+                       presetCurrentBuiltInCount++; // <--increment the current number of built in presets     
+               }
+               i++;
+        
+        /* if we run into a folder, go to level 1 and iterate through the children arrays for the default */
+        if ([thisPresetDict objectForKey:@"ChildrenArray"])
+        {
+            NSMutableDictionary *thisPresetDictParent = thisPresetDict;
+            NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+            id tempObject;
+            while (tempObject = [enumerator nextObject])
+            {
+                NSMutableDictionary *thisPresetDict = tempObject;
+                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
+                {
+                    presetHbDefault = thisPresetDict;
+                    presetHbDefaultParent = thisPresetDictParent;
+                }
+                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
+                {
+                    presetUserDefault = thisPresetDict;
+                    presetUserDefaultParent = thisPresetDictParent;
+                    userDefaultFound = YES;
+                }
+                
+                /* if we run into a folder, go to level 2 and iterate through the children arrays for the default */
+                if ([thisPresetDict objectForKey:@"ChildrenArray"])
+                {
+                    NSMutableDictionary *thisPresetDictParentParent = thisPresetDict;
+                    NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+                    id tempObject;
+                    while (tempObject = [enumerator nextObject])
+                    {
+                        NSMutableDictionary *thisPresetDict = tempObject;
+                        if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
+                        {
+                            presetHbDefault = thisPresetDict;
+                            presetHbDefaultParent = thisPresetDictParent;
+                            presetHbDefaultParentParent = thisPresetDictParentParent;  
+                        }
+                        if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
+                        {
+                            presetUserDefault = thisPresetDict;
+                            presetUserDefaultParent = thisPresetDictParent;
+                            presetUserDefaultParentParent = thisPresetDictParentParent;
+                            userDefaultFound = YES;    
+                        }
+                        
+                    }
+                }
+            }
+        }
+        
+       }
+    /* check to see if a user specified preset was found, if not then assign the parents for
+     * the presetHbDefault so that we can open the parents for the nested presets
+     */
+    if (userDefaultFound == NO)
+    {
+        presetUserDefaultParent = presetHbDefaultParent;
+        presetUserDefaultParentParent = presetHbDefaultParentParent;
+    }
+}
+
+- (IBAction)setDefaultPreset:(id)sender
+{
+/* We need to determine if the item is a folder */
+   if ([[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Folder"] intValue] == 1)
+   {
+   return;
+   }
+
+    int i = 0;
+    NSEnumerator *enumerator = [UserPresets objectEnumerator];
+       id tempObject;
+       /* First make sure the old user specified default preset is removed */
+    while (tempObject = [enumerator nextObject])
+       {
+               NSMutableDictionary *thisPresetDict = tempObject;
+               if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
+               {
+                       [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"]; 
+               }
+               
+               /* if we run into a folder, go to level 1 and iterate through the children arrays for the default */
+        if ([thisPresetDict objectForKey:@"ChildrenArray"])
+        {
+            NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+            id tempObject;
+            int ii = 0;
+            while (tempObject = [enumerator nextObject])
+            {
+                NSMutableDictionary *thisPresetDict1 = tempObject;
+                if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
+                {
+                    [[[thisPresetDict objectForKey:@"ChildrenArray"] objectAtIndex:ii] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];        
+                }
+                /* if we run into a folder, go to level 2 and iterate through the children arrays for the default */
+                if ([thisPresetDict1 objectForKey:@"ChildrenArray"])
+                {
+                    NSEnumerator *enumerator = [[thisPresetDict1 objectForKey:@"ChildrenArray"] objectEnumerator];
+                    id tempObject;
+                    int iii = 0;
+                    while (tempObject = [enumerator nextObject])
+                    {
+                        if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
+                        {
+                            [[[thisPresetDict1 objectForKey:@"ChildrenArray"] objectAtIndex:iii] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];      
+                        }
+                        iii++;
+                    }
+                }
+                ii++;
+            }
+            
+        }
+        i++; 
+       }
+    
+    
+    int presetToModLevel = [fPresetsOutlineView levelForItem: [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]]];
+    NSDictionary *presetToMod = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
+    NSDictionary *presetToModParent = [fPresetsOutlineView parentForItem: presetToMod];
+    
+    
+    NSMutableArray *presetsArrayToMod;
+    NSMutableArray *tempArray;
+    
+    /* If we are a root level preset, we are modding the UserPresets array */
+    if (presetToModLevel == 0)
+    {
+        presetsArrayToMod = UserPresets;
+    }
+    else // We have a parent preset, so we modify the chidren array object for key
+    {
+        presetsArrayToMod = [presetToModParent objectForKey:@"ChildrenArray"]; 
+    }
+    
+    enumerator = [presetsArrayToMod objectEnumerator];
+    tempArray = [NSMutableArray array];
+    int iiii = 0;
+    while (tempObject = [enumerator nextObject]) 
+    {
+        NSDictionary *thisPresetDict = tempObject;
+        if (thisPresetDict == presetToMod)
+        {
+            if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 2
+            {
+                [[presetsArrayToMod objectAtIndex:iiii] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];       
+            }
+        }
+     iiii++;
+     }
+    
+    
+    /* We save all of the preset data here */
+    [self savePreset];
+    /* We Reload the New Table data for presets */
+    [fPresetsOutlineView reloadData];
+}
+
+- (IBAction)selectDefaultPreset:(id)sender
+{
+       NSMutableDictionary *presetToMod;
+    /* if there is a user specified default, we use it */
+       if (presetUserDefault)
+       {
+        presetToMod = presetUserDefault;
+    }
+       else if (presetHbDefault) //else we use the built in default presetHbDefault
+       {
+        presetToMod = presetHbDefault;
+       }
+    else
+    {
+    return;
+    }
+    
+    if (presetUserDefaultParent != nil)
+    {
+        [fPresetsOutlineView expandItem:presetUserDefaultParent];
+        
+    }
+    if (presetUserDefaultParentParent != nil)
+    {
+        [fPresetsOutlineView expandItem:presetUserDefaultParentParent];
+        
+    }
+    
+    [fPresetsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[fPresetsOutlineView rowForItem: presetToMod]] byExtendingSelection:NO];
+       [self selectPreset:nil];
+}
+
+
+#pragma mark -
+#pragma mark Manage Built In Presets
+
+
+- (IBAction)deleteFactoryPresets:(id)sender
+{
+    //int status;
+    NSEnumerator *enumerator = [UserPresets objectEnumerator];
+       id tempObject;
+    
+       //NSNumber *index;
+    NSMutableArray *tempArray;
+
+
+        tempArray = [NSMutableArray array];
+        /* we look here to see if the preset is we move on to the next one */
+        while ( tempObject = [enumerator nextObject] )  
+               {
+                       /* if the preset is "Factory" then we put it in the array of
+                       presets to delete */
+                       if ([[tempObject objectForKey:@"Type"] intValue] == 0)
+                       {
+                               [tempArray addObject:tempObject];
+                       }
+        }
+        
+        [UserPresets removeObjectsInArray:tempArray];
+        [fPresetsOutlineView reloadData];
+        [self savePreset];   
+
+}
+
+   /* We use this method to recreate new, updated factory presets */
+- (IBAction)addFactoryPresets:(id)sender
+{
+    
+    /* First, we delete any existing built in presets */
+    [self deleteFactoryPresets: sender];
+    /* Then we generate new built in presets programmatically with fPresetsBuiltin
+     * which is all setup in HBPresets.h and  HBPresets.m*/
+    [fPresetsBuiltin generateBuiltinPresets:UserPresets];
+    /* update build number for built in presets */
+    /* iterate though the new array of presets to import and add them to our presets array */
+    int i = 0;
+    NSEnumerator *enumerator = [UserPresets objectEnumerator];
+    id tempObject;
+    while (tempObject = [enumerator nextObject])
+    {
+        /* Record the apps current build number in the PresetBuildNumber key */
+        if ([[tempObject objectForKey:@"Type"] intValue] == 0) // Type 0 is a built in preset          
+        {
+            /* Preset build number */
+            [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] intValue]] forKey:@"PresetBuildNumber"];
+        }
+        i++;
+    }
+    /* report the built in preset updating to the activity log */
+    [self writeToActivityLog: "built in presets updated to build number: %d", [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] intValue]];
+    
+    [self sortPresets];
+    [self addPreset];
+    
+}
+
+
+@end
+
+/*******************************
+ * Subclass of the HBPresetsOutlineView *
+ *******************************/
+
+@implementation HBPresetsOutlineView
+- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent*)dragEvent offset:(NSPointPointer)dragImageOffset
+{
+    fIsDragging = YES;
+
+    // By default, NSTableView only drags an image of the first column. Change this to
+    // drag an image of the queue's icon and PresetName columns.
+    NSArray * cols = [NSArray arrayWithObjects: [self tableColumnWithIdentifier:@"PresetName"], nil];
+    return [super dragImageForRowsWithIndexes:dragRows tableColumns:cols event:dragEvent offset:dragImageOffset];
+}
+
+
+
+- (void) mouseDown:(NSEvent *)theEvent
+{
+    [super mouseDown:theEvent];
+       fIsDragging = NO;
+}
+
+
+
+- (BOOL) isDragging;
+{
+    return fIsDragging;
+}
+@end
+
+
+
index ac8ca58..0d48266 100644 (file)
@@ -1,18 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9F33</string>
-               <string key="IBDocument.InterfaceBuilderVersion">658</string>
-               <string key="IBDocument.AppKitVersion">949.34</string>
-               <string key="IBDocument.HIToolboxVersion">352.00</string>
+               <string key="IBDocument.SystemVersion">10B504</string>
+               <string key="IBDocument.InterfaceBuilderVersion">732</string>
+               <string key="IBDocument.AppKitVersion">1038.2</string>
+               <string key="IBDocument.HIToolboxVersion">437.00</string>
+               <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                       <string key="NS.object.0">732</string>
+               </object>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
+                       <integer value="5"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys" id="0">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
                <object class="NSMutableArray" key="IBDocument.RootObjects" id="658768339">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <object class="NSCustomObject" id="674763238">
@@ -25,7 +39,7 @@
                                <string key="NSClassName">NSApplication</string>
                        </object>
                        <object class="NSCustomView" id="738514360">
-                               <nil key="NSNextResponder"/>
+                               <reference key="NSNextResponder"/>
                                <int key="NSvFlags">256</int>
                                <object class="NSMutableArray" key="NSSubviews">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -40,7 +54,7 @@
                                                        <int key="NSCellFlags2">264192</int>
                                                        <object class="NSFont" key="NSSupport" id="22">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">9.000000e+00</double>
+                                                               <double key="NSSize">9</double>
                                                                <int key="NSfFlags">3614</int>
                                                        </object>
                                                        <reference key="NSControlView" ref="502806021"/>
                                                        <string key="NSContents">Reference Frames:</string>
                                                        <object class="NSFont" key="NSSupport" id="826935898">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">1.000000e+01</double>
+                                                               <double key="NSSize">10</double>
                                                                <int key="NSfFlags">2843</int>
                                                        </object>
                                                        <reference key="NSControlView" ref="496835891"/>
                                                                <string key="NSColorName">controlColor</string>
                                                                <object class="NSColor" key="NSColor">
                                                                        <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+                                                                       <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
                                                                </object>
                                                        </object>
                                                        <object class="NSColor" key="NSTextColor" id="555417541">
                                        <object class="NSTextField" id="444018704">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{20, 214}, {128, 13}}</string>
+                                               <string key="NSFrame">{{94, 210}, {54, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="660394934">
                                                        <reference key="NSTextColor" ref="555417541"/>
                                                </object>
                                        </object>
+                                       <object class="NSTextField" id="965170034">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{48, 179}, {100, 26}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="517356884">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">71303168</int>
+                                                       <string key="NSContents">Adaptive B-Frames:</string>
+                                                       <reference key="NSSupport" ref="826935898"/>
+                                                       <reference key="NSControlView" ref="965170034"/>
+                                                       <reference key="NSBackgroundColor" ref="1006136775"/>
+                                                       <reference key="NSTextColor" ref="555417541"/>
+                                               </object>
+                                       </object>
                                        <object class="NSPopUpButton" id="463613064">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
                                                        <int key="NSArrowPosition">1</int>
                                                </object>
                                        </object>
+                                       <object class="NSPopUpButton" id="646401135">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{150, 191}, {84, 15}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="468935027">
+                                                       <int key="NSCellFlags">-2076049856</int>
+                                                       <int key="NSCellFlags2">264704</int>
+                                                       <reference key="NSSupport" ref="22"/>
+                                                       <reference key="NSControlView" ref="646401135"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">1</int>
+                                                       <reference key="NSAlternateImage" ref="22"/>
+                                                       <string key="NSAlternateContents"/>
+                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                               <characters key="NS.bytes"/>
+                                                       </object>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="84181884">
+                                                               <reference key="NSMenu" ref="884041487"/>
+                                                               <string key="NSTitle">Item1</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="98535564"/>
+                                                               <reference key="NSMixedImage" ref="993852628"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <reference key="NSTarget" ref="468935027"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="884041487">
+                                                               <object class="NSMutableString" key="NSTitle">
+                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                               </object>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <reference ref="84181884"/>
+                                                                       <object class="NSMenuItem" id="148376841">
+                                                                               <reference key="NSMenu" ref="884041487"/>
+                                                                               <string key="NSTitle">Item2</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="98535564"/>
+                                                                               <reference key="NSMixedImage" ref="993852628"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="468935027"/>
+                                                                       </object>
+                                                                       <object class="NSMenuItem" id="425106023">
+                                                                               <reference key="NSMenu" ref="884041487"/>
+                                                                               <string key="NSTitle">Item3</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="98535564"/>
+                                                                               <reference key="NSMixedImage" ref="993852628"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="468935027"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSPreferredEdge">3</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">1</int>
+                                               </object>
+                                       </object>
                                        <object class="NSPopUpButton" id="1012635724">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{407, 222}, {83, 15}}</string>
+                                               <string key="NSFrame">{{407, 243}, {83, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="597433555">
                                        <object class="NSTextField" id="34095372">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 142}, {142, 13}}</string>
+                                               <string key="NSFrame">{{426, 157}, {37, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="368733355">
                                        <object class="NSTextField" id="677509567">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{429, 121}, {96, 13}}</string>
+                                               <string key="NSFrame">{{564, 243}, {96, 13}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="652898624">
                                        <object class="NSTextField" id="570675882">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 121}, {142, 13}}</string>
+                                               <string key="NSFrame">{{578, 261}, {82, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="622431002">
                                                        <string key="NSContents">Box</string>
                                                        <object class="NSFont" key="NSSupport" id="1073480903">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">1.300000e+01</double>
+                                                               <double key="NSSize">13</double>
                                                                <int key="NSfFlags">1044</int>
                                                        </object>
                                                        <object class="NSColor" key="NSBackgroundColor" id="431629906">
                                                        <string key="NSContents"/>
                                                        <object class="NSFont" key="NSSupport" id="26">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">1.100000e+01</double>
+                                                               <double key="NSSize">11</double>
                                                                <int key="NSfFlags">3100</int>
                                                        </object>
                                                        <reference key="NSControlView" ref="862092551"/>
                                        <object class="NSTextField" id="9309938">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 244}, {142, 13}}</string>
+                                               <string key="NSFrame">{{263, 223}, {142, 13}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="625397549">
                                        <object class="NSPopUpButton" id="108597901">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{407, 243}, {83, 15}}</string>
+                                               <string key="NSFrame">{{407, 222}, {83, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="1015445713">
                                        <object class="NSTextField" id="335373847">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 223}, {142, 13}}</string>
+                                               <string key="NSFrame">{{263, 245}, {142, 13}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="492298910">
                                        <object class="NSTextField" id="677007332">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{20, 172}, {128, 13}}</string>
+                                               <string key="NSFrame">{{46, 144}, {102, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="288316749">
                                        <object class="NSTextField" id="34260806">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{20, 151}, {128, 13}}</string>
+                                               <string key="NSFrame">{{43, 126}, {105, 14}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="124098371">
                                                        <reference key="NSTextColor" ref="555417541"/>
                                                </object>
                                        </object>
+                                       <object class="NSTextField" id="777985871">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{254, 127}, {151, 26}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="996811218">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">71434240</int>
+                                                       <string key="NSContents">Psychovisual Rate Distortion:</string>
+                                                       <reference key="NSSupport" ref="826935898"/>
+                                                       <reference key="NSControlView" ref="777985871"/>
+                                                       <reference key="NSBackgroundColor" ref="1006136775"/>
+                                                       <reference key="NSTextColor" ref="555417541"/>
+                                               </object>
+                                       </object>
                                        <object class="NSTextField" id="751714853">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{20, 193}, {128, 13}}</string>
+                                               <string key="NSFrame">{{60, 165}, {88, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="651032081">
                                        <object class="NSPopUpButton" id="1028233887">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{150, 192}, {84, 15}}</string>
+                                               <string key="NSFrame">{{150, 168}, {84, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="96368274">
                                        <object class="NSPopUpButton" id="130462646">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{407, 162}, {63, 15}}</string>
+                                               <string key="NSFrame">{{618, 217}, {63, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="1069442299">
                                        <object class="NSPopUpButton" id="497968468">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{479, 162}, {63, 15}}</string>
+                                               <string key="NSFrame">{{618, 193}, {63, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="691127886">
                                        <object class="NSTextField" id="529644976">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 163}, {142, 13}}</string>
+                                               <string key="NSFrame">{{554, 214}, {62, 17}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="343844477">
                                        <object class="NSButton" id="749948454">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{148, 171}, {22, 16}}</string>
+                                               <string key="NSFrame">{{148, 147}, {22, 16}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="98290860">
                                        <object class="NSButton" id="1035779890">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{148, 150}, {22, 16}}</string>
+                                               <string key="NSFrame">{{148, 126}, {22, 16}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="773053098">
                                        <object class="NSButton" id="928128304">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{405, 120}, {22, 16}}</string>
+                                               <string key="NSFrame">{{660, 264}, {22, 16}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="1016156756">
                                        <object class="NSButton" id="140207359">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{525, 120}, {22, 16}}</string>
+                                               <string key="NSFrame">{{660, 242}, {22, 16}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="401971973">
                                        <object class="NSPopUpButton" id="907540673">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{407, 141}, {83, 15}}</string>
+                                               <string key="NSFrame">{{463, 161}, {83, 15}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="804220802">
                                        <object class="NSTextField" id="516451639">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 193}, {142, 13}}</string>
+                                               <string key="NSFrame">{{358, 192}, {47, 14}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="562573539">
                                        <object class="NSButton" id="612818913">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{525, 99}, {22, 16}}</string>
+                                               <string key="NSFrame">{{405, 160}, {22, 16}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="12489527">
                                        <object class="NSTextField" id="5114506">
                                                <reference key="NSNextResponder" ref="738514360"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{263, 100}, {262, 13}}</string>
+                                               <string key="NSFrame">{{286, 162}, {119, 13}}</string>
                                                <reference key="NSSuperview" ref="738514360"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="894602850">
                                                        <reference key="NSTextColor" ref="555417541"/>
                                                </object>
                                        </object>
+                                       <object class="NSSlider" id="734910001">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{408, 137}, {96, 16}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSSliderCell" key="NSCell" id="737375773">
+                                                       <int key="NSCellFlags">-2079981824</int>
+                                                       <int key="NSCellFlags2">262144</int>
+                                                       <string key="NSContents"/>
+                                                       <reference key="NSSupport" ref="22"/>
+                                                       <reference key="NSControlView" ref="734910001"/>
+                                                       <double key="NSMaxValue">1</double>
+                                                       <double key="NSMinValue">0.0</double>
+                                                       <double key="NSValue">1</double>
+                                                       <double key="NSAltIncValue">0.0</double>
+                                                       <int key="NSNumberOfTickMarks">11</int>
+                                                       <int key="NSTickMarkPosition">0</int>
+                                                       <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
+                                                       <bool key="NSVertical">NO</bool>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="149148764">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{306, 115}, {99, 14}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="950560055">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">71434240</int>
+                                                       <string key="NSContents">Psychovisual Trellis</string>
+                                                       <reference key="NSSupport" ref="826935898"/>
+                                                       <reference key="NSControlView" ref="149148764"/>
+                                                       <reference key="NSBackgroundColor" ref="1006136775"/>
+                                                       <reference key="NSTextColor" ref="555417541"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSSlider" id="747005200">
+                                               <reference key="NSNextResponder" ref="738514360"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{408, 113}, {96, 16}}</string>
+                                               <reference key="NSSuperview" ref="738514360"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSSliderCell" key="NSCell" id="148673163">
+                                                       <int key="NSCellFlags">-2079981824</int>
+                                                       <int key="NSCellFlags2">262144</int>
+                                                       <string key="NSContents"/>
+                                                       <reference key="NSSupport" ref="22"/>
+                                                       <reference key="NSControlView" ref="747005200"/>
+                                                       <double key="NSMaxValue">1</double>
+                                                       <double key="NSMinValue">0.0</double>
+                                                       <double key="NSValue">0.0</double>
+                                                       <double key="NSAltIncValue">0.0</double>
+                                                       <int key="NSNumberOfTickMarks">11</int>
+                                                       <int key="NSTickMarkPosition">0</int>
+                                                       <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
+                                                       <bool key="NSVertical">NO</bool>
+                                               </object>
+                                       </object>
                                </object>
                                <string key="NSFrameSize">{700, 290}</string>
+                               <reference key="NSSuperview"/>
                                <string key="NSClassName">NSView</string>
                                <string key="NSExtension">NSResponder</string>
                        </object>
                                        </object>
                                        <int key="connectionID">257</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optPsyRDLabel</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="777985871"/>
+                                       </object>
+                                       <int key="connectionID">386</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optPsyRDSlider</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="734910001"/>
+                                       </object>
+                                       <int key="connectionID">387</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optPsyTrellisLabel</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="149148764"/>
+                                       </object>
+                                       <int key="connectionID">392</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optPsyTrellisSlider</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="747005200"/>
+                                       </object>
+                                       <int key="connectionID">393</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">X264AdvancedOptionsChanged:</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="734910001"/>
+                                       </object>
+                                       <int key="connectionID">394</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">X264AdvancedOptionsChanged:</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="747005200"/>
+                                       </object>
+                                       <int key="connectionID">395</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optBAdaptLabel</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="965170034"/>
+                                       </object>
+                                       <int key="connectionID">404</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fX264optBAdaptPopUp</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="646401135"/>
+                                       </object>
+                                       <int key="connectionID">405</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">X264AdvancedOptionsChanged:</string>
+                                               <reference key="source" ref="674763238"/>
+                                               <reference key="destination" ref="646401135"/>
+                                       </object>
+                                       <int key="connectionID">406</int>
+                               </object>
                        </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                <object class="NSArray" key="orderedObjects">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">0</int>
-                                               <object class="NSArray" key="object" id="181588572">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                               </object>
+                                               <reference key="object" ref="0"/>
                                                <reference key="children" ref="658768339"/>
                                                <nil key="parent"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-2</int>
                                                <reference key="object" ref="674763238"/>
-                                               <reference key="parent" ref="181588572"/>
-                                               <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">File's Owner</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-1</int>
                                                <reference key="object" ref="670200792"/>
-                                               <reference key="parent" ref="181588572"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">First Responder</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-3</int>
                                                <reference key="object" ref="620160606"/>
-                                               <reference key="parent" ref="181588572"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Application</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <reference ref="444018704"/>
                                                        <reference ref="463613064"/>
                                                        <reference ref="1012635724"/>
-                                                       <reference ref="34095372"/>
-                                                       <reference ref="677509567"/>
-                                                       <reference ref="570675882"/>
                                                        <reference ref="945084535"/>
                                                        <reference ref="126101945"/>
                                                        <reference ref="862092551"/>
                                                        <reference ref="751714853"/>
                                                        <reference ref="1028233887"/>
                                                        <reference ref="498769415"/>
-                                                       <reference ref="130462646"/>
-                                                       <reference ref="497968468"/>
-                                                       <reference ref="529644976"/>
                                                        <reference ref="977241029"/>
                                                        <reference ref="749948454"/>
-                                                       <reference ref="928128304"/>
-                                                       <reference ref="140207359"/>
-                                                       <reference ref="907540673"/>
                                                        <reference ref="523657812"/>
                                                        <reference ref="473093704"/>
                                                        <reference ref="516451639"/>
                                                        <reference ref="526934709"/>
                                                        <reference ref="180296347"/>
-                                                       <reference ref="612818913"/>
-                                                       <reference ref="5114506"/>
                                                        <reference ref="34260806"/>
                                                        <reference ref="1035779890"/>
-                                               </object>
-                                               <reference key="parent" ref="181588572"/>
+                                                       <reference ref="570675882"/>
+                                                       <reference ref="928128304"/>
+                                                       <reference ref="677509567"/>
+                                                       <reference ref="140207359"/>
+                                                       <reference ref="130462646"/>
+                                                       <reference ref="529644976"/>
+                                                       <reference ref="497968468"/>
+                                                       <reference ref="612818913"/>
+                                                       <reference ref="5114506"/>
+                                                       <reference ref="34095372"/>
+                                                       <reference ref="907540673"/>
+                                                       <reference ref="777985871"/>
+                                                       <reference ref="734910001"/>
+                                                       <reference ref="149148764"/>
+                                                       <reference ref="747005200"/>
+                                                       <reference ref="965170034"/>
+                                                       <reference ref="646401135"/>
+                                               </object>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">x264</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="743280560"/>
                                                </object>
-                                               <reference key="parent" ref="181588572"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">empty</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <reference key="object" ref="19515960"/>
                                                <reference key="parent" ref="838480608"/>
                                        </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">382</int>
+                                               <reference key="object" ref="777985871"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="996811218"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">383</int>
+                                               <reference key="object" ref="996811218"/>
+                                               <reference key="parent" ref="777985871"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">384</int>
+                                               <reference key="object" ref="734910001"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="737375773"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">385</int>
+                                               <reference key="object" ref="737375773"/>
+                                               <reference key="parent" ref="734910001"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">388</int>
+                                               <reference key="object" ref="149148764"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="950560055"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">389</int>
+                                               <reference key="object" ref="747005200"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="148673163"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">390</int>
+                                               <reference key="object" ref="148673163"/>
+                                               <reference key="parent" ref="747005200"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">391</int>
+                                               <reference key="object" ref="950560055"/>
+                                               <reference key="parent" ref="149148764"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">396</int>
+                                               <reference key="object" ref="965170034"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="517356884"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">397</int>
+                                               <reference key="object" ref="517356884"/>
+                                               <reference key="parent" ref="965170034"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">398</int>
+                                               <reference key="object" ref="646401135"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="468935027"/>
+                                               </object>
+                                               <reference key="parent" ref="738514360"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">399</int>
+                                               <reference key="object" ref="468935027"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="884041487"/>
+                                               </object>
+                                               <reference key="parent" ref="646401135"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">400</int>
+                                               <reference key="object" ref="884041487"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="148376841"/>
+                                                       <reference ref="425106023"/>
+                                                       <reference ref="84181884"/>
+                                               </object>
+                                               <reference key="parent" ref="468935027"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">401</int>
+                                               <reference key="object" ref="148376841"/>
+                                               <reference key="parent" ref="884041487"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">402</int>
+                                               <reference key="object" ref="425106023"/>
+                                               <reference key="parent" ref="884041487"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">403</int>
+                                               <reference key="object" ref="84181884"/>
+                                               <reference key="parent" ref="884041487"/>
+                                       </object>
                                </object>
                        </object>
                        <object class="NSMutableDictionary" key="flattenedProperties">
                                <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSMutableArray" key="dict.sortedKeys">
+                               <object class="NSArray" key="dict.sortedKeys">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                       <string>-1.IBPluginDependency</string>
-                                       <string>-2.IBPluginDependency</string>
                                        <string>-3.IBPluginDependency</string>
                                        <string>-3.ImportedFromIB2</string>
                                        <string>10.IBPluginDependency</string>
                                        <string>33.ImportedFromIB2</string>
                                        <string>34.IBPluginDependency</string>
                                        <string>34.ImportedFromIB2</string>
+                                       <string>342.IBPluginDependency</string>
+                                       <string>343.IBPluginDependency</string>
+                                       <string>344.IBPluginDependency</string>
+                                       <string>345.IBPluginDependency</string>
+                                       <string>346.IBPluginDependency</string>
+                                       <string>347.IBPluginDependency</string>
+                                       <string>348.IBPluginDependency</string>
+                                       <string>349.IBPluginDependency</string>
                                        <string>35.IBPluginDependency</string>
                                        <string>35.ImportedFromIB2</string>
+                                       <string>350.IBPluginDependency</string>
+                                       <string>351.IBPluginDependency</string>
+                                       <string>352.IBPluginDependency</string>
+                                       <string>353.IBPluginDependency</string>
+                                       <string>354.IBPluginDependency</string>
+                                       <string>355.IBPluginDependency</string>
+                                       <string>356.IBPluginDependency</string>
+                                       <string>357.IBPluginDependency</string>
+                                       <string>358.IBPluginDependency</string>
                                        <string>36.IBPluginDependency</string>
                                        <string>36.ImportedFromIB2</string>
+                                       <string>361.IBPluginDependency</string>
+                                       <string>362.IBPluginDependency</string>
+                                       <string>363.IBPluginDependency</string>
+                                       <string>364.IBPluginDependency</string>
+                                       <string>365.IBPluginDependency</string>
+                                       <string>366.IBPluginDependency</string>
+                                       <string>367.IBPluginDependency</string>
+                                       <string>368.IBPluginDependency</string>
                                        <string>37.IBAttributePlaceholdersKey</string>
                                        <string>37.IBPluginDependency</string>
                                        <string>37.ImportedFromIB2</string>
+                                       <string>371.IBPluginDependency</string>
+                                       <string>372.IBPluginDependency</string>
+                                       <string>373.IBPluginDependency</string>
+                                       <string>374.IBPluginDependency</string>
+                                       <string>375.IBPluginDependency</string>
+                                       <string>376.IBPluginDependency</string>
+                                       <string>377.IBPluginDependency</string>
+                                       <string>378.IBPluginDependency</string>
+                                       <string>379.IBPluginDependency</string>
                                        <string>38.IBAttributePlaceholdersKey</string>
                                        <string>38.IBPluginDependency</string>
                                        <string>38.ImportedFromIB2</string>
+                                       <string>380.IBPluginDependency</string>
+                                       <string>381.IBPluginDependency</string>
+                                       <string>382.IBAttributePlaceholdersKey</string>
+                                       <string>382.IBPluginDependency</string>
+                                       <string>382.ImportedFromIB2</string>
+                                       <string>383.IBPluginDependency</string>
+                                       <string>384.IBPluginDependency</string>
+                                       <string>385.IBPluginDependency</string>
+                                       <string>388.IBAttributePlaceholdersKey</string>
+                                       <string>388.IBPluginDependency</string>
+                                       <string>388.ImportedFromIB2</string>
+                                       <string>389.IBPluginDependency</string>
                                        <string>39.IBAttributePlaceholdersKey</string>
                                        <string>39.IBPluginDependency</string>
                                        <string>39.ImportedFromIB2</string>
+                                       <string>390.IBPluginDependency</string>
+                                       <string>391.IBPluginDependency</string>
+                                       <string>396.IBAttributePlaceholdersKey</string>
+                                       <string>396.IBPluginDependency</string>
+                                       <string>396.ImportedFromIB2</string>
+                                       <string>397.IBPluginDependency</string>
+                                       <string>398.IBAttributePlaceholdersKey</string>
+                                       <string>398.IBPluginDependency</string>
+                                       <string>398.ImportedFromIB2</string>
+                                       <string>399.IBPluginDependency</string>
                                        <string>40.IBPluginDependency</string>
                                        <string>40.ImportedFromIB2</string>
+                                       <string>400.IBPluginDependency</string>
+                                       <string>400.ImportedFromIB2</string>
+                                       <string>401.IBPluginDependency</string>
+                                       <string>401.ImportedFromIB2</string>
+                                       <string>402.IBPluginDependency</string>
+                                       <string>402.ImportedFromIB2</string>
+                                       <string>403.IBPluginDependency</string>
+                                       <string>403.ImportedFromIB2</string>
                                        <string>41.IBPluginDependency</string>
                                        <string>41.ImportedFromIB2</string>
                                        <string>42.IBPluginDependency</string>
                                <object class="NSMutableArray" key="dict.values">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <integer value="1" id="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="496835891"/>
-                                                       <string type="base64-UTF8" key="toolTip">U2FuZSB2YWx1ZXMgYXJlIDEtNi4gVGhlIG1vcmUgeW91IGFkZCwgdGhlIGhpZ2hlciB0aGUgcXVhbGl0
-eSDigJQgYnV0IHRoZSBzbG93ZXIgdGhlIGVuY29kZS4gQmUgY2FyZWZ1bC4uLnRvbyBtYW55IGFuZCBR
-dWlja1RpbWUgc3RydWdnbGUgdG8gcGxheSB0aGUgdmlkZW8gYmFjay4</string>
-                                               </object>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="444018704"/>
-                                                       <string key="toolTip">Sane values are 1-6. B-Frames are smaller than other frames, so they let you pack in more quality at the same bitrate. Use more of them with animated material: 9-16.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="463613064"/>
-                                                       <string key="toolTip">Sane values are 1-6. B-Frames are smaller than other frames, so they let you pack in more quality at the same bitrate. Use more of them with animated material: 9-16.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="1012635724"/>
-                                                       <string type="base64-UTF8" key="toolTip">VGhpcyBzZXR0aW5nIGlzIGZpbmVyLWdyYWluZWQgdGhhbiB0aGUgbW90aW9uIGVzdGltYXRpb24gc2V0
-dGluZ3MgYWJvdmUuIEluc3RlYWQgb2YgZGVhbGluZyB3aXRoIHdob2xlIHBpeGVscywgaXQgZGVhbHMg
-d2l0aCBmcmFjdGlvbmFsIHBpeGVscy4gNCwgSGFuZEJyYWtlJ3MgZGVmYXVsdCwgbWVhbnMgbG9va2lu
-ZyBhdCBxdWFydGVyIHBpeGVscyAocXBlbCkuIEhpZ2hlciBsZXZlbHMgaW5jcmVhc2UgcXVhbGl0eSBi
-eSBkaXZpZGluZyB0aGUgcGl4ZWwgbW9yZSwgYnV0IHRha2UgbG9uZ2VyIHRvIGVuY29kZS4gVXNpbmcg
-NiBvciA3IHR1cm5zIHVubG9ja3MgdGhlIGFiaWxpdHkgdG8gdHVybiBvbiBtb3JlIGFkdmFuY2VkIGZl
-YXR1cmVzIGxpa2UgQi1GcmFtZSByYXRlIGRpc3RvcnRpb24uA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="34095372"/>
-                                                       <string key="toolTip">Trellis fine-tunes how bitrate is doled out, so it can reduce file size/bitrate or increase quality. A value of 2 forces it to be used more often than a value of 1.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="677509567"/>
-                                                       <string key="toolTip">Only use this with constant quality encoding. It increases quality but also bitrate/file size.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="570675882"/>
-                                                       <string key="toolTip">This can help with blocking on solid colors like blue skies, but it also slows down the encode.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>{{42, 754}, {700, 290}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="286114143"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2l0aCB0aGlzIG9uLCBkaWZmZXJlbnQgcGFydHMgb2YgYSBmcmFtZSB3aWxsIHJlZmVyIGJhY2sgdG8g
-ZGlmZmVyZW50IHByaW9yIGZyYW1lcywgZGVwZW5kaW5nIG9uIHdoYXQncyBiZXN0IGZvciB0aGF0IHBh
-cnQgb2YgdGhlIGltYWdlLg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="463632258"/>
-                                                       <string key="toolTip">This sets the shape of the area x264 searches when estimating motion. Your choices are a diamond, a hexagon, a more complex hexagonal shape, or searching the entire frame. You are best off using Uneven Multi-Hexagonal searching.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="501486901"/>
-                                                       <string key="toolTip">This sets the shape of the area x264 searches when estimating motion. Your choices are a diamond, a hexagon, a more complex hexagonal shape, or searching the entire frame. You are best off using Uneven Multi-Hexagonal searching.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="9309938"/>
-                                                       <string key="toolTip">This range is the radius, in pixels, x264 should use for motion estimation searches. It only has an effect when you use Uneven Multi-Hexagonal or Exhaustive searching. 24, 32, and 64 are good values.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="108597901"/>
-                                                       <string key="toolTip">This range is the radius, in pixels, x264 should use for motion estimation searches. It only has an effect when you use Uneven Multi-Hexagonal or Exhaustive searching. 24, 32, and 64 are good values.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="335373847"/>
-                                                       <string type="base64-UTF8" key="toolTip">VGhpcyBzZXR0aW5nIGlzIGZpbmVyLWdyYWluZWQgdGhhbiB0aGUgbW90aW9uIGVzdGltYXRpb24gc2V0
-dGluZ3MgYWJvdmUuIEluc3RlYWQgb2YgZGVhbGluZyB3aXRoIHdob2xlIHBpeGVscywgaXQgZGVhbHMg
-d2l0aCBmcmFjdGlvbmFsIHBpeGVscy4gNCwgSGFuZEJyYWtlJ3MgZGVmYXVsdCwgbWVhbnMgbG9va2lu
-ZyBhdCBxdWFydGVyIHBpeGVscyAocXBlbCkuIEhpZ2hlciBsZXZlbHMgaW5jcmVhc2UgcXVhbGl0eSBi
-eSBkaXZpZGluZyB0aGUgcGl4ZWwgbW9yZSwgYnV0IHRha2UgbG9uZ2VyIHRvIGVuY29kZS4gVXNpbmcg
-NiBvciA3IHR1cm5zIHVubG9ja3MgdGhlIGFiaWxpdHkgdG8gdHVybiBvbiBtb3JlIGFkdmFuY2VkIGZl
-YXR1cmVzIGxpa2UgQi1GcmFtZSByYXRlIGRpc3RvcnRpb24uA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="677007332"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2l0aCB3ZWlnaHRlZCBCLWZyYW1lIHByZWRpY3Rpb24gZW5hYmxlZCwgeDI2NCB3aWxsIGNvbnNpZGVy
-IGhvdyBmYXIgYXdheSB0aGUgcHJldmlvdXMgYW5kIG5leHQgUC1mcmFtZXMgYXJlLCBiZWZvcmUgZGVj
-aWRpbmcgdG8gbWFrZSBhIGZyYW1lIGEgQi1mcmFtZS4gVGhlIGVmZmVjdCBpcyB0aGF0IHgyNjQgd2ls
-bCB1c2UgZmV3ZXIgQi1mcmFtZXMgd2hlbiB0aGV5J2QgbG9vayBiYWQg4oCUIHdoZW4gaXQgY2FuJ3Qg
-YWNjdXJhdGVseSBwcmVkaWN0IG1vdGlvbi4gT2J2aW91c2x5LCB0aGlzIG9ubHkgd29ya3Mgd2hlbiB5
-b3UgdGVsbCB4MjY0IHRvIHVzZSBtb3JlIHRoYW4gMSBCLWZyYW1lLiA</string>
-                                               </object>
-                                       </object>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="34260806"/>
-                                                       <string type="base64-UTF8" key="toolTip">Qi1mcmFtZSBweXJhbWlkcyBhcmUgYSBIaWdoIFByb2ZpbGUgZmVhdHVyZS4gVGhpcyBtZWFucyB0aGF0
-IGlmIHlvdSBlbmFibGUgaXQsIFlPVVIgVklERU8gV0lMTCBOT1QgUExBWSBJTiBRVUlDS1RJTUUuIFB5
-cmFtaWRhbCBCLWZyYW1lcyBtZWFuIHRoYXQgQi1mcmFtZXMgZG9uJ3QganVzdCByZWZlcmVuY2Ugc3Vy
-cm91bmRpbmcgcmVmZXJlbmNlIGZyYW1lcyDigJQgaW5zdGVhZCwgaXQgYWxzbyB0cmVhdHMgYSBwcmV2
-aW91cyBCLWZyYW1lIGFzIGEgcmVmZXJlbmNlLCBpbXByb3ZpbmcgcXVhbGl0eS9sb3dlcmluZyBiaXRy
-YXRlIGF0IHRoZSBleHBlbnNlIG9mIGNvbXBsZXhpdHkuIExvZ2ljYWxseSwgdG8gcmVmZXJlbmNlIGFu
-IGVhcmxpZXIgQi1mcmFtZSwgeW91IG11c3QgdGVsbCB4MjY0IHRvIHVzZSBhdCBsZWFzdCAyIEItZnJh
-bWVzLg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="751714853"/>
-                                                       <string type="base64-UTF8" key="toolTip">RGlyZWN0IHByZWRpY3Rpb24gdGVsbHMgeDI2NCB3aGF0IG1ldGhvZCB0byB1c2Ugd2hlbiBndWVzc2lu
-ZyBtb3Rpb24gZm9yIGNlcnRhaW4gcGFydHMgb2YgYSBCLWZyYW1lLiBJdCBjYW4gZWl0aGVyIGxvb2sg
-YXQgb3RoZXIgcGFydHMgb2YgdGhlIGN1cnJlbnQgZnJhbWUgKHNwYXRpYWwpIG9yIGNvbXBhcmUgYWdh
-aW5zdCB0aGUgcHJlY2VkaW5nIGZyYW1lICh0ZW1wb3JhbCkuIFlvdSdyZSBiZXN0IG9mZiBzZXR0aW5n
-IHRoaXMgdG8gYXV0b21hdGljLCBzbyB4MjY0IGRlY2lkZXMgd2hpY2ggbWV0aG9kIGlzIGJlc3Qgb24g
-aXRzIG93bi4gRG9uJ3Qgc2VsZWN0IG5vbmUgYXNzdW1pbmcgaXQgd2lsbCBiZSBmYXN0ZXI7IGluc3Rl
-YWQgaXQgd2lsbCB0YWtlIGxvbmdlciBhbmQgbG9vayB3b3JzZS4gSWYgeW91J3JlIGdvaW5nIHRvIGNo
-b29zZSBiZXR3ZWVuIHNwYXRpYWwgYW5kIHRlbXBvcmFsLCBzcGF0aWFsIGlzIHVzdWFsbHkgYmV0dGVy
-Lg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>{{0, 724}, {700, 290}}</string>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>{{692, 501}, {700, 290}}</string>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="1028233887"/>
-                                                       <string type="base64-UTF8" key="toolTip">RGlyZWN0IHByZWRpY3Rpb24gdGVsbHMgeDI2NCB3aGF0IG1ldGhvZCB0byB1c2Ugd2hlbiBndWVzc2lu
-ZyBtb3Rpb24gZm9yIGNlcnRhaW4gcGFydHMgb2YgYSBCLWZyYW1lLiBJdCBjYW4gZWl0aGVyIGxvb2sg
-YXQgb3RoZXIgcGFydHMgb2YgdGhlIGN1cnJlbnQgZnJhbWUgKHNwYXRpYWwpIG9yIGNvbXBhcmUgYWdh
-aW5zdCB0aGUgcHJlY2VkaW5nIGZyYW1lICh0ZW1wb3JhbCkuIFlvdSdyZSBiZXN0IG9mZiBzZXR0aW5n
-IHRoaXMgdG8gYXV0b21hdGljLCBzbyB4MjY0IGRlY2lkZXMgd2hpY2ggbWV0aG9kIGlzIGJlc3Qgb24g
-aXRzIG93bi4gRG9uJ3Qgc2VsZWN0IG5vbmUgYXNzdW1pbmcgaXQgd2lsbCBiZSBmYXN0ZXI7IGluc3Rl
-YWQgaXQgd2lsbCB0YWtlIGxvbmdlciBhbmQgbG9vayB3b3JzZS4gSWYgeW91J3JlIGdvaW5nIHRvIGNo
-b29zZSBiZXR3ZWVuIHNwYXRpYWwgYW5kIHRlbXBvcmFsLCBzcGF0aWFsIGlzIHVzdWFsbHkgYmV0dGVy
-Lg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="130462646"/>
-                                                       <string type="base64-UTF8" key="toolTip">eDI2NCBpbmNsdWRlcyBhbiBpbi1sb29wIGRlYmxvY2tpbmcgZmlsdGVyLiBXaGF0IHRoaXMgbWVhbnMg
-aXMgdGhhdCBibG9ja3kgY29tcHJlc3Npb24gYXJ0aWZhY3RzIGFyZSBzbW9vdGhlZCBhd2F5IHdoZW4g
-eW91IHBsYXkgYmFjayB0aGUgdmlkZW8uIEl0IGhhcyB0d28gc2V0dGluZ3M6IHN0cmVuZ3RoIGFuZCB0
-aHJlc2hvbGQsIGp1c3QgbGlrZSBhIHNpbXBsZSBmaWx0ZXIgaW4gUGhvdG9zaG9wLiBTdHJlbmd0aCBj
-b250cm9scyB0aGUgYW1vdW50IG9mIGRlYmxvY2tpbmcgYXBwbGllZCB0byB0aGUgd2hvbGUgZnJhbWUu
-IElmIHlvdSBkcm9wIGRvd24gYmVsb3cgMCwgeW91IHJlZHVjZSB0aGUgYW1vdW50IG9mIGJsdXJyaW5n
-LiBHbyB0b28gbmVnYXRpdmUsIGFuZCB5b3UnbGwgZ2V0IGFuIGVmZmVjdCBzb21ld2hhdCBsaWtlIG92
-ZXJzaGFycGVuaW5nIGFuIGltYWdlLiBHbyBpbnRvIHBvc2l0aXZlIHZhbHVlcywgYW5kIHRoZSBpbWFn
-ZSBtYXkgYmVjb21lIHRvbyBzb2Z0LiBUaHJlc2hvbGQgY29udHJvbHMgaG93IHNlbnNpdGl2ZSB0aGUg
-ZmlsdGVyIGlzIHRvIHdoZXRoZXIgc29tZXRoaW5nIGluIGEgYmxvY2sgaXMgZGV0YWlsIHRoYXQgbmVl
-ZHMgdG8gYmUgcHJlc2VydmVkOiBsb3dlciBudW1iZXJzIGJsdXIgZGV0YWlscyBsZXNzLiBUaGUgZGVm
-YXVsdCBkZWJsb2NraW5nIHZhbHVlcyBhcmUgMCBhbmQgMC4gVGhpcyBkb2VzIG5vdCBtZWFuIHplcm8g
-ZGVibG9ja2luZy4gSXQgbWVhbnMgeDI2NCB3aWxsIGFwcGx5IHRoZSByZWd1bGFyIGRlYmxvY2tpbmcg
-c3RyZW5ndGggYW5kIHRocmVzaG9sZHMgdGhlIGNvZGVjIGF1dGhvcnMgaGF2ZSBzZWxlY3RlZCBhcyB3
-b3JraW5nIHRoZSBiZXN0IGluIG1vc3QgY2FzZXMuIFdoaWxlIG1hbnksIG1hbnkgcGVvcGxlIHN0aWNr
-IHdpdGggdGhlIGRlZmF1bHQgZGVibG9ja2luZyB2YWx1ZXMgb2YgMCwwLCBvdGhlciBwZW9wbGUgZGlz
-YWdyZWUuIFNvbWUgcHJlZmVyIGEgc2xpZ2h0bHkgbGVzcyBibHVycmVkIGltYWdlIGZvciBsaXZlIGFj
-dGlvbiBtYXRlcmlhbCwgYW5kIHVzZSB2YWx1ZXMgbGlrZSAtMiwtMSBvciAtMiwtMi4gT3RoZXJzIHdp
-bGwgcmFpc2UgaXQgdG8gMSwxIG9yIGV2ZW4gMywzIGZvciBhbmltYXRpb24uIFdoaWxlIHRoZSB2YWx1
-ZXMgZm9yIGVhY2ggc2V0dGluZyBleHRlbmQgZnJvbSAtNiB0byA2LCB0aGUgY29uc2Vuc3VzIGlzIHRo
-YXQgZ29pbmcgYmVsb3cgLTMgb3IgYWJvdmUgMyBpcyB3b3J0aGxlc3MuA</string>
-                                               </object>
-                                       </object>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="502806021"/>
-                                                       <string type="base64-UTF8" key="toolTip">U2FuZSB2YWx1ZXMgYXJlIDEtNi4gVGhlIG1vcmUgeW91IGFkZCwgdGhlIGhpZ2hlciB0aGUgcXVhbGl0
-eSDigJQgYnV0IHRoZSBzbG93ZXIgdGhlIGVuY29kZS4</string>
-                                               </object>
-                                       </object>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="497968468"/>
-                                                       <string type="base64-UTF8" key="toolTip">eDI2NCBpbmNsdWRlcyBhbiBpbi1sb29wIGRlYmxvY2tpbmcgZmlsdGVyLiBXaGF0IHRoaXMgbWVhbnMg
-aXMgdGhhdCBibG9ja3kgY29tcHJlc3Npb24gYXJ0aWZhY3RzIGFyZSBzbW9vdGhlZCBhd2F5IHdoZW4g
-eW91IHBsYXkgYmFjayB0aGUgdmlkZW8uIEl0IGhhcyB0d28gc2V0dGluZ3M6IHN0cmVuZ3RoIGFuZCB0
-aHJlc2hvbGQsIGp1c3QgbGlrZSBhIHNpbXBsZSBmaWx0ZXIgaW4gUGhvdG9zaG9wLiBTdHJlbmd0aCBj
-b250cm9scyB0aGUgYW1vdW50IG9mIGRlYmxvY2tpbmcgYXBwbGllZCB0byB0aGUgd2hvbGUgZnJhbWUu
-IElmIHlvdSBkcm9wIGRvd24gYmVsb3cgMCwgeW91IHJlZHVjZSB0aGUgYW1vdW50IG9mIGJsdXJyaW5n
-LiBHbyB0b28gbmVnYXRpdmUsIGFuZCB5b3UnbGwgZ2V0IGFuIGVmZmVjdCBzb21ld2hhdCBsaWtlIG92
-ZXJzaGFycGVuaW5nIGFuIGltYWdlLiBHbyBpbnRvIHBvc2l0aXZlIHZhbHVlcywgYW5kIHRoZSBpbWFn
-ZSBtYXkgYmVjb21lIHRvbyBzb2Z0LiBUaHJlc2hvbGQgY29udHJvbHMgaG93IHNlbnNpdGl2ZSB0aGUg
-ZmlsdGVyIGlzIHRvIHdoZXRoZXIgc29tZXRoaW5nIGluIGEgYmxvY2sgaXMgZGV0YWlsIHRoYXQgbmVl
-ZHMgdG8gYmUgcHJlc2VydmVkOiBsb3dlciBudW1iZXJzIGJsdXIgZGV0YWlscyBsZXNzLiBUaGUgZGVm
-YXVsdCBkZWJsb2NraW5nIHZhbHVlcyBhcmUgMCBhbmQgMC4gVGhpcyBkb2VzIG5vdCBtZWFuIHplcm8g
-ZGVibG9ja2luZy4gSXQgbWVhbnMgeDI2NCB3aWxsIGFwcGx5IHRoZSByZWd1bGFyIGRlYmxvY2tpbmcg
-c3RyZW5ndGggYW5kIHRocmVzaG9sZHMgdGhlIGNvZGVjIGF1dGhvcnMgaGF2ZSBzZWxlY3RlZCBhcyB3
-b3JraW5nIHRoZSBiZXN0IGluIG1vc3QgY2FzZXMuIFdoaWxlIG1hbnksIG1hbnkgcGVvcGxlIHN0aWNr
-IHdpdGggdGhlIGRlZmF1bHQgZGVibG9ja2luZyB2YWx1ZXMgb2YgMCwwLCBvdGhlciBwZW9wbGUgZGlz
-YWdyZWUuIFNvbWUgcHJlZmVyIGEgc2xpZ2h0bHkgbGVzcyBibHVycmVkIGltYWdlIGZvciBsaXZlIGFj
-dGlvbiBtYXRlcmlhbCwgYW5kIHVzZSB2YWx1ZXMgbGlrZSAtMiwtMSBvciAtMiwtMi4gT3RoZXJzIHdp
-bGwgcmFpc2UgaXQgdG8gMSwxIG9yIGV2ZW4gMywzIGZvciBhbmltYXRpb24uIFdoaWxlIHRoZSB2YWx1
-ZXMgZm9yIGVhY2ggc2V0dGluZyBleHRlbmQgZnJvbSAtNiB0byA2LCB0aGUgY29uc2Vuc3VzIGlzIHRo
-YXQgZ29pbmcgYmVsb3cgLTMgb3IgYWJvdmUgMyBpcyB3b3J0aGxlc3MuA</string>
-                                               </object>
-                                       </object>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="529644976"/>
-                                                       <string type="base64-UTF8" key="toolTip">eDI2NCBpbmNsdWRlcyBhbiBpbi1sb29wIGRlYmxvY2tpbmcgZmlsdGVyLiBXaGF0IHRoaXMgbWVhbnMg
-aXMgdGhhdCBibG9ja3kgY29tcHJlc3Npb24gYXJ0aWZhY3RzIGFyZSBzbW9vdGhlZCBhd2F5IHdoZW4g
-eW91IHBsYXkgYmFjayB0aGUgdmlkZW8uIEl0IGhhcyB0d28gc2V0dGluZ3M6IHN0cmVuZ3RoIGFuZCB0
-aHJlc2hvbGQsIGp1c3QgbGlrZSBhIHNpbXBsZSBmaWx0ZXIgaW4gUGhvdG9zaG9wLiBTdHJlbmd0aCBj
-b250cm9scyB0aGUgYW1vdW50IG9mIGRlYmxvY2tpbmcgYXBwbGllZCB0byB0aGUgd2hvbGUgZnJhbWUu
-IElmIHlvdSBkcm9wIGRvd24gYmVsb3cgMCwgeW91IHJlZHVjZSB0aGUgYW1vdW50IG9mIGJsdXJyaW5n
-LiBHbyB0b28gbmVnYXRpdmUsIGFuZCB5b3UnbGwgZ2V0IGFuIGVmZmVjdCBzb21ld2hhdCBsaWtlIG92
-ZXJzaGFycGVuaW5nIGFuIGltYWdlLiBHbyBpbnRvIHBvc2l0aXZlIHZhbHVlcywgYW5kIHRoZSBpbWFn
-ZSBtYXkgYmVjb21lIHRvbyBzb2Z0LiBUaHJlc2hvbGQgY29udHJvbHMgaG93IHNlbnNpdGl2ZSB0aGUg
-ZmlsdGVyIGlzIHRvIHdoZXRoZXIgc29tZXRoaW5nIGluIGEgYmxvY2sgaXMgZGV0YWlsIHRoYXQgbmVl
-ZHMgdG8gYmUgcHJlc2VydmVkOiBsb3dlciBudW1iZXJzIGJsdXIgZGV0YWlscyBsZXNzLiBUaGUgZGVm
-YXVsdCBkZWJsb2NraW5nIHZhbHVlcyBhcmUgMCBhbmQgMC4gVGhpcyBkb2VzIG5vdCBtZWFuIHplcm8g
-ZGVibG9ja2luZy4gSXQgbWVhbnMgeDI2NCB3aWxsIGFwcGx5IHRoZSByZWd1bGFyIGRlYmxvY2tpbmcg
-c3RyZW5ndGggYW5kIHRocmVzaG9sZHMgdGhlIGNvZGVjIGF1dGhvcnMgaGF2ZSBzZWxlY3RlZCBhcyB3
-b3JraW5nIHRoZSBiZXN0IGluIG1vc3QgY2FzZXMuIFdoaWxlIG1hbnksIG1hbnkgcGVvcGxlIHN0aWNr
-IHdpdGggdGhlIGRlZmF1bHQgZGVibG9ja2luZyB2YWx1ZXMgb2YgMCwwLCBvdGhlciBwZW9wbGUgZGlz
-YWdyZWUuIFNvbWUgcHJlZmVyIGEgc2xpZ2h0bHkgbGVzcyBibHVycmVkIGltYWdlIGZvciBsaXZlIGFj
-dGlvbiBtYXRlcmlhbCwgYW5kIHVzZSB2YWx1ZXMgbGlrZSAtMiwtMSBvciAtMiwtMi4gT3RoZXJzIHdp
-bGwgcmFpc2UgaXQgdG8gMSwxIG9yIGV2ZW4gMywzIGZvciBhbmltYXRpb24uIFdoaWxlIHRoZSB2YWx1
-ZXMgZm9yIGVhY2ggc2V0dGluZyBleHRlbmQgZnJvbSAtNiB0byA2LCB0aGUgY29uc2Vuc3VzIGlzIHRo
-YXQgZ29pbmcgYmVsb3cgLTMgb3IgYWJvdmUgMyBpcyB3b3J0aGxlc3MuA</string>
-                                               </object>
-                                       </object>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="977241029"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2l0aCB0aGlzIG9uLCBkaWZmZXJlbnQgcGFydHMgb2YgYSBmcmFtZSB3aWxsIHJlZmVyIGJhY2sgdG8g
-ZGlmZmVyZW50IHByaW9yIGZyYW1lcywgZGVwZW5kaW5nIG9uIHdoYXQncyBiZXN0IGZvciB0aGF0IHBh
-cnQgb2YgdGhlIGltYWdlLg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="749948454"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2l0aCB3ZWlnaHRlZCBCLWZyYW1lIHByZWRpY3Rpb24gZW5hYmxlZCwgeDI2NCB3aWxsIGNvbnNpZGVy
-IGhvdyBmYXIgYXdheSB0aGUgcHJldmlvdXMgYW5kIG5leHQgUC1mcmFtZXMgYXJlLCBiZWZvcmUgZGVj
-aWRpbmcgdG8gbWFrZSBhIGZyYW1lIGEgQi1mcmFtZS4gVGhlIGVmZmVjdCBpcyB0aGF0IHgyNjQgd2ls
-bCB1c2UgZmV3ZXIgQi1mcmFtZXMgd2hlbiB0aGV5J2QgbG9vayBiYWQg4oCUIHdoZW4gaXQgY2FuJ3Qg
-YWNjdXJhdGVseSBwcmVkaWN0IG1vdGlvbi4gT2J2aW91c2x5LCB0aGlzIG9ubHkgd29ya3Mgd2hlbiB5
-b3UgdGVsbCB4MjY0IHRvIHVzZSBtb3JlIHRoYW4gMSBCLWZyYW1lLiA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="1035779890"/>
-                                                       <string type="base64-UTF8" key="toolTip">Qi1mcmFtZSBweXJhbWlkcyBhcmUgYSBIaWdoIFByb2ZpbGUgZmVhdHVyZS4gVGhpcyBtZWFucyB0aGF0
-IGlmIHlvdSBlbmFibGUgaXQsIFlPVVIgVklERU8gV0lMTCBOT1QgUExBWSBJTiBRVUlDS1RJTUUuIFB5
-cmFtaWRhbCBCLWZyYW1lcyBtZWFuIHRoYXQgQi1mcmFtZXMgZG9uJ3QganVzdCByZWZlcmVuY2Ugc3Vy
-cm91bmRpbmcgcmVmZXJlbmNlIGZyYW1lcyDigJQgaW5zdGVhZCwgaXQgYWxzbyB0cmVhdHMgYSBwcmV2
-aW91cyBCLWZyYW1lIGFzIGEgcmVmZXJlbmNlLCBpbXByb3ZpbmcgcXVhbGl0eS9sb3dlcmluZyBiaXRy
-YXRlIGF0IHRoZSBleHBlbnNlIG9mIGNvbXBsZXhpdHkuIExvZ2ljYWxseSwgdG8gcmVmZXJlbmNlIGFu
-IGVhcmxpZXIgQi1mcmFtZSwgeW91IG11c3QgdGVsbCB4MjY0IHRvIHVzZSBhdCBsZWFzdCAyIEItZnJh
-bWVzLg</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="928128304"/>
-                                                       <string key="toolTip">This can help with blocking on solid colors like blue skies, but it also slows down the encode.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>{{-21, 171}, {700, 290}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>{{692, 501}, {700, 290}}</string>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="140207359"/>
-                                                       <string key="toolTip">Only use this with constant quality encoding. It increases quality but also bitrate/file size.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="907540673"/>
-                                                       <string key="toolTip">Trellis fine-tunes how bitrate is doled out, so it can reduce file size/bitrate or increase quality. A value of 2 forces it to be used more often than a value of 1.</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="473093704"/>
-                                                       <string type="base64-UTF8" key="toolTip">QW5hbHlzaXMgY29udHJvbHMgaG93IGZpbmVseSB4MjY0IGRpdmlkZXMgdXAgYSBmcmFtZSB0byBjYXB0
-dXJlIGRldGFpbC4gRnVsbCBtYWNyb2Jsb2NrcyBhcmUgMTZ4MTYgcGl4ZWxzLCBidXQgeDI2NCBjYW4g
-Z28gZG93biBhbGwgdGhlIHdheSB0byA0eDQgYmxvY2tzIGlmIGl0IGp1ZGdlcyBpdCBuZWNlc3Nhcnku
-IEJ5IGRlZmF1bHQgaXQgb25seSBicmVha3MgdXAga2V5IGZyYW1lcyB0aGF0IG11Y2guIFRvIGdpdmUg
-eDI2NCB0aGUgZnJlZWRvbSB0byBtYWtlIHRoZSBiZXN0IGRlY2lzaW9ucyBmb3IgYWxsIGZyYW1lcywg
-dXNlICJhbGwiIGFuYWx5c2lzLiBJZiB5b3Ugd2FudCB0byBjcmVhdGUgYSBoaWdoIHByb2ZpbGUgSC4y
-NjQgdmlkZW8gKHdoaWNoIGlzIGxlc3MgY29tcGF0aWJsZSB3aXRoIHRoZSB3b3JsZCBhdCBsYXJnZSB0
-aGFuIG1haW4gcHJvZmlsZSksIGFsc28gY2hlY2sgdGhlICI4eDggRENUIGJsb2NrcyIgYm94IHRvIGFk
-ZCB5ZXQgYW5vdGhlciBibG9jayBzaXplIGZvciBhbmFseXNpcy4</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="516451639"/>
-                                                       <string type="base64-UTF8" key="toolTip">QW5hbHlzaXMgY29udHJvbHMgaG93IGZpbmVseSB4MjY0IGRpdmlkZXMgdXAgYSBmcmFtZSB0byBjYXB0
-dXJlIGRldGFpbC4gRnVsbCBtYWNyb2Jsb2NrcyBhcmUgMTZ4MTYgcGl4ZWxzLCBidXQgeDI2NCBjYW4g
-Z28gZG93biBhbGwgdGhlIHdheSB0byA0eDQgYmxvY2tzIGlmIGl0IGp1ZGdlcyBpdCBuZWNlc3Nhcnku
-IEJ5IGRlZmF1bHQgaXQgb25seSBicmVha3MgdXAga2V5IGZyYW1lcyB0aGF0IG11Y2guIFRvIGdpdmUg
-eDI2NCB0aGUgZnJlZWRvbSB0byBtYWtlIHRoZSBiZXN0IGRlY2lzaW9ucyBmb3IgYWxsIGZyYW1lcywg
-dXNlICJhbGwiIGFuYWx5c2lzLiBJZiB5b3Ugd2FudCB0byBjcmVhdGUgYSBoaWdoIHByb2ZpbGUgSC4y
-NjQgdmlkZW8gKHdoaWNoIGlzIGxlc3MgY29tcGF0aWJsZSB3aXRoIHRoZSB3b3JsZCBhdCBsYXJnZSB0
-aGFuIG1haW4gcHJvZmlsZSksIGFsc28gY2hlY2sgdGhlICI4eDggRENUIGJsb2NrcyIgYm94IHRvIGFk
-ZCB5ZXQgYW5vdGhlciBibG9jayBzaXplIGZvciBhbmFseXNpcy4</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="526934709"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2hlbiBBbmFseXNpcyBpcyBzZXQgdG8gImFsbCwiIGNoZWNraW5nIHRoaXMgYm94IGxldHMgeDI2NCBi
-cmVhayBrZXkgZnJhbWVzIGRvd24gaW50byA4eDggYmxvY2tzIG9mIHBpeGVscyBmb3IgYW5hbHlzaXMu
-IFRoaXMgaXMgYSBoaWdoIHByb2ZpbGUgZmVhdHVyZSBvZiBILjI2NCwgd2hpY2ggbWFrZXMgaXQgbGVz
-cyBjb21wYXRpYmxlLiBJdCBzaG91bGQgc2xpZ2h0bHkgZGVjcmVhc2UgYml0cmF0ZSBvciBpbXByb3Zl
-IHF1YWxpdHkuA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="180296347"/>
-                                                       <string type="base64-UTF8" key="toolTip">V2hlbiBBbmFseXNpcyBpcyBzZXQgdG8gImFsbCwiIGNoZWNraW5nIHRoaXMgYm94IGxldHMgeDI2NCBi
-cmVhayBrZXkgZnJhbWVzIGRvd24gaW50byA4eDggYmxvY2tzIG9mIHBpeGVscyBmb3IgYW5hbHlzaXMu
-IFRoaXMgaXMgYSBoaWdoIHByb2ZpbGUgZmVhdHVyZSBvZiBILjI2NCwgd2hpY2ggbWFrZXMgaXQgbGVz
-cyBjb21wYXRpYmxlLiBJdCBzaG91bGQgc2xpZ2h0bHkgZGVjcmVhc2UgYml0cmF0ZSBvciBpbXByb3Zl
-IHF1YWxpdHkuA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
                                                <string key="NS.key.0">ToolTip</string>
                                                <object class="IBToolTipAttribute" key="NS.object.0">
                                                        <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="612818913"/>
-                                                       <string type="base64-UTF8" key="toolTip">Q0FCQUMsIG9yIGNvbnRleHQgYWRhcHRpdmUgYmluYXJ5IGFyaXRobWV0aWMgY29kaW5nLCBpcyB1c2Vk
-IGJ5IHgyNjQgdG8gcmVkdWNlIHRoZSBiaXRyYXRlIG5lZWRlZCBmb3IgYSBnaXZlbiBxdWFsaXR5IGJ5
-IDE1JS4gVGhpcyBtYWtlcyBpdCB2ZXJ5IGNvb2wgYW5kIHZlcnkgdXNlZnVsLCBhbmQgaXQgc2hvdWxk
-IGJlIGxlZnQgb24gd2hlbmV2ZXIgcG9zc2libGUuIEhvd2V2ZXIsIGl0IGlzIGluY29tcGF0aWJsZSB3
-aXRoIHRoZSBpUG9kIDUuNUcsIGFuZCBtYWtlcyB0aGUgQXBwbGVUViBzdHJ1Z2dsZS4gU28gdHVybiBp
-dCBvZmYgZm9yIHRob3NlLiBDQUJBQyBpcyBhIGtpbmQgb2YgZW50cm9weSBjb2RpbmcsIHdoaWNoIG1l
-YW5zIHRoYXQgaXQgY29tcHJlc3NlcyBkYXRhIGJ5IG1ha2luZyBzaG9ydGhhbmQgc3ltYm9scyB0byBy
-ZXByZXNlbnQgbG9uZyBzdHJlYW1zIG9mIGRhdGEuIFRoZSAiZW50cm9weSIgcGFydCBtZWFucyB0aGF0
-IHRoZSBzeW1ib2xzIGl0IHVzZXMgdGhlIG1vc3Qgb2Z0ZW4gYXJlIHRoZSBzbWFsbGVzdC4gV2hlbiB5
-b3UgZGlzYWJsZSBDQUJBQywgYW5vdGhlciBlbnRyb3B5IGNvZGluZyBzY2hlbWUgZ2V0cyBlbmFibGVk
-LCBjYWxsZWQgQ0FWTEMgKGNvbnRleHQgYWRhcHRpdmUgdmFyaWFibGUtbGVuZ3RoIGNvZGluZykuIENB
-VkxDIGlzIGEgbG90IGxlc3MgZWZmaWNpZW50LCB3aGljaCBpcyB3aHkgaXQgbmVlZHMgMTUlIG1vcmUg
-Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
-                                               </object>
-                                       </object>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                                       <reference key="object" ref="1035779890"/>
+                                                       <string key="toolTip">B-frame pyramids are a High Profile feature. This means that if you enable it, YOUR VIDEO WILL NOT PLAY IN QUICKTIME. Pyramidal B-frames mean that B-frames don't just reference surrounding reference frames â€” instead, it also treats a previous B-frame as a reference, improving quality/lowering bitrate at the expense of complexity. Logically, to reference an earlier B-frame, you must tell x264 to use at least 2 B-frames.</string>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
                                        <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">ToolTip</string>
-                                               <object class="IBToolTipAttribute" key="NS.object.0">
-                                                       <string key="name">ToolTip</string>
-                                                       <reference key="object" ref="5114506"/>
-                                                       <string type="base64-UTF8" key="toolTip">Q0FCQUMsIG9yIGNvbnRleHQgYWRhcHRpdmUgYmluYXJ5IGFyaXRobWV0aWMgY29kaW5nLCBpcyB1c2Vk
-IGJ5IHgyNjQgdG8gcmVkdWNlIHRoZSBiaXRyYXRlIG5lZWRlZCBmb3IgYSBnaXZlbiBxdWFsaXR5IGJ5
-IDE1JS4gVGhpcyBtYWtlcyBpdCB2ZXJ5IGNvb2wgYW5kIHZlcnkgdXNlZnVsLCBhbmQgaXQgc2hvdWxk
-IGJlIGxlZnQgb24gd2hlbmV2ZXIgcG9zc2libGUuIEhvd2V2ZXIsIGl0IGlzIGluY29tcGF0aWJsZSB3
-aXRoIHRoZSBpUG9kIDUuNUcsIGFuZCBtYWtlcyB0aGUgQXBwbGVUViBzdHJ1Z2dsZS4gU28gdHVybiBp
-dCBvZmYgZm9yIHRob3NlLiBDQUJBQyBpcyBhIGtpbmQgb2YgZW50cm9weSBjb2RpbmcsIHdoaWNoIG1l
-YW5zIHRoYXQgaXQgY29tcHJlc3NlcyBkYXRhIGJ5IG1ha2luZyBzaG9ydGhhbmQgc3ltYm9scyB0byBy
-ZXByZXNlbnQgbG9uZyBzdHJlYW1zIG9mIGRhdGEuIFRoZSAiZW50cm9weSIgcGFydCBtZWFucyB0aGF0
-IHRoZSBzeW1ib2xzIGl0IHVzZXMgdGhlIG1vc3Qgb2Z0ZW4gYXJlIHRoZSBzbWFsbGVzdC4gV2hlbiB5
-b3UgZGlzYWJsZSBDQUJBQywgYW5vdGhlciBlbnRyb3B5IGNvZGluZyBzY2hlbWUgZ2V0cyBlbmFibGVk
-LCBjYWxsZWQgQ0FWTEMgKGNvbnRleHQgYWRhcHRpdmUgdmFyaWFibGUtbGVuZ3RoIGNvZGluZykuIENB
-VkxDIGlzIGEgbG90IGxlc3MgZWZmaWNpZW50LCB3aGljaCBpcyB3aHkgaXQgbmVlZHMgMTUlIG1vcmUg
-Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                        </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                               </object>
-                       </object>
-                       <object class="NSMutableDictionary" key="unlocalizedProperties">
-                               <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSArray" key="dict.sortedKeys">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
-                               <object class="NSMutableArray" key="dict.values">
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <object class="NSMutableDictionary">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <reference key="dict.sortedKeys" ref="0"/>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                               </object>
+                       </object>
+                       <object class="NSMutableDictionary" key="unlocalizedProperties">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <reference key="dict.sortedKeys" ref="0"/>
+                               <object class="NSMutableArray" key="dict.values">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                </object>
                        </object>
                        <nil key="activeLocalization"/>
                        <object class="NSMutableDictionary" key="localizations">
                                <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSArray" key="dict.sortedKeys">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
+                               <reference key="dict.sortedKeys" ref="0"/>
                                <object class="NSMutableArray" key="dict.values">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                </object>
                        </object>
                        <nil key="sourceID"/>
-                       <int key="maxID">381</int>
+                       <int key="maxID">406</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3577,8 +3889,9 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                        <string key="superclassName">NSObject</string>
                                        <object class="NSMutableDictionary" key="actions">
                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                               <object class="NSMutableArray" key="dict.sortedKeys">
+                                               <object class="NSArray" key="dict.sortedKeys">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>X264AdvancedOptionsAnimate:</string>
                                                        <string>X264AdvancedOptionsChanged:</string>
                                                        <string>X264AdvancedOptionsSet:</string>
                                                        <string>X264AdvancedOptionsSetCurrentSettings:</string>
@@ -3590,11 +3903,12 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>id</string>
                                                        <string>id</string>
                                                        <string>id</string>
+                                                       <string>id</string>
                                                </object>
                                        </object>
                                        <object class="NSMutableDictionary" key="outlets">
                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                               <object class="NSMutableArray" key="dict.sortedKeys">
+                                               <object class="NSArray" key="dict.sortedKeys">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <string>fDisplayX264Options</string>
                                                        <string>fDisplayX264OptionsLabel</string>
@@ -3604,15 +3918,13 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>fX264optAlphaDeblockPopUp</string>
                                                        <string>fX264optAnalyseLabel</string>
                                                        <string>fX264optAnalysePopUp</string>
+                                                       <string>fX264optBAdaptLabel</string>
+                                                       <string>fX264optBAdaptPopUp</string>
                                                        <string>fX264optBPyramidLabel</string>
                                                        <string>fX264optBPyramidSwitch</string>
-                                                       <string>fX264optBRDOLabel</string>
-                                                       <string>fX264optBRDOSwitch</string>
                                                        <string>fX264optBetaDeblockPopUp</string>
                                                        <string>fX264optBframesLabel</string>
                                                        <string>fX264optBframesPopUp</string>
-                                                       <string>fX264optBiMELabel</string>
-                                                       <string>fX264optBiMESwitch</string>
                                                        <string>fX264optCabacLabel</string>
                                                        <string>fX264optCabacSwitch</string>
                                                        <string>fX264optDeblockLabel</string>
@@ -3628,6 +3940,10 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>fX264optNfpskipSwitch</string>
                                                        <string>fX264optNodctdcmtLabel</string>
                                                        <string>fX264optNodctdcmtSwitch</string>
+                                                       <string>fX264optPsyRDLabel</string>
+                                                       <string>fX264optPsyRDSlider</string>
+                                                       <string>fX264optPsyTrellisLabel</string>
+                                                       <string>fX264optPsyTrellisSlider</string>
                                                        <string>fX264optRefLabel</string>
                                                        <string>fX264optRefPopUp</string>
                                                        <string>fX264optSubmeLabel</string>
@@ -3650,7 +3966,7 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
-                                                       <string>NSButton</string>
+                                                       <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSPopUpButton</string>
@@ -3659,8 +3975,6 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSTextField</string>
-                                                       <string>NSButton</string>
-                                                       <string>NSTextField</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
@@ -3674,6 +3988,10 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSTextField</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
@@ -3701,21 +4019,612 @@ Yml0cmF0ZSB0byBhY2hpZXZlIHRoZSBzYW1lIHF1YWxpdHkgYXMgQ0FCQUMuA</string>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
+                                               <string key="majorKey">IBUserSource</string>
+                                               <string key="minorKey"/>
+                                       </object>
+                               </object>
+                       </object>
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSActionCell</string>
+                                       <string key="superclassName">NSCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="698143150">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="211278098">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="802363589">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSBox</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSBox.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButton</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButtonCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSCell</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSControl</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="990093763">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSControl.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSFormatter</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenu</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="435556569">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItem</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="988534394">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItemCell</string>
+                                       <string key="superclassName">NSButtonCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItemCell.h</string>
                                        </object>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBUserSource</string>
-                                               <string key="minorKey"/>
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="698143150"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="211278098"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="802363589"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="990093763"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string>
                                        </object>
                                </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="435556569"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="719781483">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Growl.framework/Headers/GrowlApplicationBridge.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKImageBrowserView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKSaveOptions.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/ImageKitDeprecated.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFDocument.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedAudioOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedVideoOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureFileOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureVideoPreviewOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovie.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovieView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionParameterView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionPickerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzFilters.framework/Headers/QuartzFilterManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuickLookUI.framework/Headers/QLPreviewPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUAppcast.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUUpdater.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButton</string>
+                                       <string key="superclassName">NSButton</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButtonCell</string>
+                                       <string key="superclassName">NSMenuItemCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSSlider</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSlider.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSSliderCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSliderCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextField</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextFieldCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <reference key="sourceIdentifier" ref="988534394"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <reference key="sourceIdentifier" ref="719781483"/>
+                               </object>
                        </object>
                </object>
                <int key="IBDocument.localizationMode">0</int>
-               <string key="IBDocument.LastKnownRelativeProjectPath">../../HandBrake.xcodeproj</string>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+                       <integer value="1050" key="NS.object.0"/>
+               </object>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
+                       <integer value="3000" key="NS.object.0"/>
+               </object>
+               <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+               <string key="IBDocument.LastKnownRelativeProjectPath">../HandBrake.xcodeproj</string>
                <int key="IBDocument.defaultPropertyAccessControl">3</int>
        </data>
 </archive>
index ce0ff23..e569119 100644 (file)
@@ -1,19 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9F33</string>
-               <string key="IBDocument.InterfaceBuilderVersion">670</string>
-               <string key="IBDocument.AppKitVersion">949.34</string>
-               <string key="IBDocument.HIToolboxVersion">352.00</string>
+               <string key="IBDocument.SystemVersion">9L30</string>
+               <string key="IBDocument.InterfaceBuilderVersion">677</string>
+               <string key="IBDocument.AppKitVersion">949.54</string>
+               <string key="IBDocument.HIToolboxVersion">353.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
-                       <integer value="1478"/>
+                       <integer value="57"/>
+                       <integer value="5196"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
                <object class="NSMutableArray" key="IBDocument.RootObjects" id="411085004">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <object class="NSCustomObject" id="1046316778">
                                                                <object class="NSTabViewItem" id="107038816">
                                                                        <string key="NSIdentifier">1</string>
                                                                        <object class="NSView" key="NSView" id="1053078401">
-                                                                               <reference key="NSNextResponder" ref="712502892"/>
+                                                                               <nil key="NSNextResponder"/>
                                                                                <int key="NSvFlags">256</int>
                                                                                <object class="NSMutableArray" key="NSSubviews">
                                                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                                                        <object class="NSTextField" id="521019277">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{357, 259}, {46, 14}}</string>
+                                                                                               <string key="NSFrame">{{289, 259}, {46, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="200565868">
                                                                                        <object class="NSMatrix" id="229000833">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{411, 211}, {146, 63}}</string>
+                                                                                               <string key="NSFrame">{{343, 211}, {167, 63}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <int key="NSNumRows">3</int>
                                                                                                                <int key="NSPeriodicInterval">75</int>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <string key="NSCellSize">{146, 15}</string>
+                                                                                               <string key="NSCellSize">{167, 15}</string>
                                                                                                <string key="NSIntercellSpacing">{4, 9}</string>
                                                                                                <int key="NSMatrixFlags">1143472128</int>
                                                                                                <string key="NSCellClass">NSActionCell</string>
                                                                                        <object class="NSTextField" id="127917338">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{562, 257}, {84, 19}}</string>
+                                                                                               <string key="NSFrame">{{512, 257}, {84, 19}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="850340172">
                                                                                        <object class="NSTextField" id="783405221">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{562, 233}, {84, 19}}</string>
+                                                                                               <string key="NSFrame">{{512, 233}, {84, 19}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="351953267">
                                                                                        <object class="NSSlider" id="239657287">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{433, 185}, {213, 18}}</string>
+                                                                                               <string key="NSFrame">{{292, 186}, {405, 16}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSSliderCell" key="NSCell" id="160453387">
                                                                                                        <int key="NSCellFlags">67501824</int>
-                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                       <int key="NSCellFlags2">262144</int>
                                                                                                        <object class="NSMutableString" key="NSContents">
                                                                                                                <characters key="NS.bytes"/>
                                                                                                        </object>
-                                                                                                       <object class="NSFont" key="NSSupport">
-                                                                                                               <string key="NSName">Helvetica-Oblique</string>
-                                                                                                               <double key="NSSize">1.200000e+01</double>
-                                                                                                               <int key="NSfFlags">16</int>
+                                                                                                       <object class="NSFont" key="NSSupport" id="22">
+                                                                                                               <string key="NSName">LucidaGrande</string>
+                                                                                                               <double key="NSSize">9.000000e+00</double>
+                                                                                                               <int key="NSfFlags">3614</int>
                                                                                                        </object>
                                                                                                        <reference key="NSControlView" ref="239657287"/>
-                                                                                                       <double key="NSMaxValue">1.000000e+00</double>
+                                                                                                       <double key="NSMaxValue">5.100000e+01</double>
                                                                                                        <double key="NSMinValue">0.000000e+00</double>
-                                                                                                       <double key="NSValue">5.400000e-01</double>
+                                                                                                       <double key="NSValue">1.900000e+01</double>
                                                                                                        <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                                       <int key="NSNumberOfTickMarks">101</int>
+                                                                                                       <int key="NSNumberOfTickMarks">205</int>
                                                                                                        <int key="NSTickMarkPosition">1</int>
                                                                                                        <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
                                                                                                        <bool key="NSVertical">NO</bool>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="219409733">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{14, 119}, {93, 17}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="215270136">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents">Picture Settings</string>
-                                                                                                       <object class="NSFont" key="NSSupport" id="27">
-                                                                                                               <string key="NSName">LucidaGrande-Bold</string>
-                                                                                                               <double key="NSSize">1.100000e+01</double>
-                                                                                                               <int key="NSfFlags">3357</int>
-                                                                                                       </object>
-                                                                                                       <reference key="NSControlView" ref="219409733"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="373965512">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{14, 99}, {96, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="656776160">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Source:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="373965512"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="917474208">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{14, 77}, {96, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="1021257184">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Output:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="917474208"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="946417297">
+                                                                                       <object class="NSTextField" id="987137669">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{246, 99}, {100, 14}}</string>
+                                                                                               <string key="NSFrame">{{14, 63}, {686, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="531090746">
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="537000521">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Keep aspect ratio:</string>
+                                                                                                       <int key="NSCellFlags2">4194304</int>
+                                                                                                       <string key="NSContents">Picture Size: </string>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="946417297"/>
+                                                                                                       <reference key="NSControlView" ref="987137669"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="982947780">
+                                                                                       <object class="NSTextField" id="690304958">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{354, 99}, {47, 14}}</string>
+                                                                                               <string key="NSFrame">{{538, 211}, {56, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="86719269">
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="923732752">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
+                                                                                                       <int key="NSCellFlags2">-2143158272</int>
                                                                                                        <string key="NSContents"/>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="982947780"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSBox" id="839994488">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{115, 125}, {582, 5}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <string key="NSOffsets">{0, 0}</string>
-                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">0</int>
-                                                                                                       <string key="NSContents">Box</string>
-                                                                                                       <reference key="NSSupport" ref="273283760"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="138233214"/>
-                                                                                                       <object class="NSColor" key="NSTextColor">
-                                                                                                               <int key="NSColorSpace">3</int>
-                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                       <object class="NSNumberFormatter" key="NSFormatter" id="580574518">
+                                                                                                               <object class="NSMutableDictionary" key="NS.attributes">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSMutableArray" key="dict.sortedKeys">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <string>allowsFloats</string>
+                                                                                                                               <string>formatterBehavior</string>
+                                                                                                                               <string>lenient</string>
+                                                                                                                               <string>locale</string>
+                                                                                                                               <string>negativeInfinitySymbol</string>
+                                                                                                                               <string>nilSymbol</string>
+                                                                                                                               <string>numberStyle</string>
+                                                                                                                               <string>positiveInfinitySymbol</string>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSMutableArray" key="dict.values">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <boolean value="YES"/>
+                                                                                                                               <integer value="1040"/>
+                                                                                                                               <boolean value="NO" id="6"/>
+                                                                                                                               <object class="NSLocale">
+                                                                                                                                       <string key="NS.identifier"/>
+                                                                                                                               </object>
+                                                                                                                               <string type="base64-UTF8">LeKIng</string>
+                                                                                                                               <string/>
+                                                                                                                               <integer value="1" id="9"/>
+                                                                                                                               <string type="base64-UTF8">K+KIng</string>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <string key="NS.positiveformat">#,##0.###</string>
+                                                                                                               <string key="NS.negativeformat">#,##0.###</string>
+                                                                                                               <nil key="NS.positiveattrs"/>
+                                                                                                               <nil key="NS.negativeattrs"/>
+                                                                                                               <object class="NSAttributedString" key="NS.zero">
+                                                                                                                       <nil key="NSString"/>
+                                                                                                               </object>
+                                                                                                               <object class="NSAttributedString" key="NS.nil">
+                                                                                                                       <string key="NSString"/>
+                                                                                                               </object>
+                                                                                                               <object class="NSAttributedString" key="NS.nan">
+                                                                                                                       <string key="NSString">NaN</string>
+                                                                                                                       <object class="NSDictionary" key="NSAttributes">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="NSArray" key="dict.sortedKeys">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               </object>
+                                                                                                                               <object class="NSMutableArray" key="dict.values">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSDecimalNumberPlaceholder" key="NS.min" id="464006568">
+                                                                                                                       <int key="NS.exponent">0</int>
+                                                                                                                       <int key="NS.length">0</int>
+                                                                                                                       <bool key="NS.negative">YES</bool>
+                                                                                                                       <bool key="NS.compact">NO</bool>
+                                                                                                                       <int key="NS.mantissa.bo">1</int>
+                                                                                                                       <bytes key="NS.mantissa">AAAAAAAAAAAAAAAAAAAAAA</bytes>
+                                                                                                               </object>
+                                                                                                               <reference key="NS.max" ref="464006568"/>
+                                                                                                               <object class="NSDecimalNumberHandler" key="NS.rounding">
+                                                                                                                       <int key="NS.roundingmode">3</int>
+                                                                                                                       <bool key="NS.raise.overflow">YES</bool>
+                                                                                                                       <bool key="NS.raise.underflow">YES</bool>
+                                                                                                                       <bool key="NS.raise.dividebyzero">YES</bool>
+                                                                                                               </object>
+                                                                                                               <string key="NS.decimal">.</string>
+                                                                                                               <string key="NS.thousand">,</string>
+                                                                                                               <bool key="NS.hasthousands">YES</bool>
+                                                                                                               <bool key="NS.localized">NO</bool>
+                                                                                                               <bool key="NS.allowsfloats">YES</bool>
                                                                                                        </object>
-                                                                                               </object>
-                                                                                               <int key="NSBorderType">3</int>
-                                                                                               <int key="NSBoxType">2</int>
-                                                                                               <int key="NSTitlePosition">0</int>
-                                                                                               <bool key="NSTransparent">NO</bool>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="710962186">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{14, 55}, {96, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="26279285">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Anamorphic:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="710962186"/>
+                                                                                                       <reference key="NSControlView" ref="690304958"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="145957234">
+                                                                                       <object class="NSTextField" id="323705695">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">-2147483392</int>
-                                                                                               <string key="NSFrame">{{119, 38}, {37, 14}}</string>
+                                                                                               <int key="NSvFlags">256</int>
+                                                                                               <string key="NSFrame">{{509, 211}, {28, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="497251062">
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="936221726">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">4194304</int>
-                                                                                                       <string key="NSContents"/>
+                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                       <string key="NSContents">RF:</string>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="145957234"/>
+                                                                                                       <reference key="NSControlView" ref="323705695"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSButton" id="37121296">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{580, 95}, {122, 28}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSButtonCell" key="NSCell" id="969536223">
-                                                                                                       <int key="NSCellFlags">-2080244224</int>
-                                                                                                       <int key="NSCellFlags2">134348800</int>
-                                                                                                       <string type="base64-UTF8" key="NSContents">UGljdHVyZSBTZXR0aW5nc+KApg</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="37121296"/>
-                                                                                                       <int key="NSButtonFlags">-2038284033</int>
-                                                                                                       <int key="NSButtonFlags2">1</int>
-                                                                                                       <reference key="NSAlternateImage" ref="26"/>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                               <characters key="NS.bytes"/>
-                                                                                                       </object>
-                                                                                                       <int key="NSPeriodicDelay">200</int>
-                                                                                                       <int key="NSPeriodicInterval">25</int>
-                                                                                               </object>
-                                                                                       </object>
                                                                                        <object class="NSTextField" id="690364175">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{312, 77}, {34, 14}}</string>
+                                                                                               <string key="NSFrame">{{14, 45}, {686, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="508148739">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Crop:</string>
+                                                                                                       <int key="NSCellFlags2">4194304</int>
+                                                                                                       <string key="NSContents">Picture Cropping:</string>
                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                        <reference key="NSControlView" ref="690364175"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="820525517">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{354, 76}, {47, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="76686465">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="820525517"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="585235372">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{503, 79}, {56, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="782049171">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="585235372"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="1068503811">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{503, 60}, {56, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="626403977">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1068503811"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="1060179806">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{427, 99}, {68, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="344072439">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Denoise:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1060179806"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="511739402">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{503, 40}, {56, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="315802325">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="511739402"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="458722452">
+                                                                                       <object class="NSTextField" id="503933842">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{427, 40}, {68, 14}}</string>
+                                                                                               <string key="NSFrame">{{14, 17}, {686, 14}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="133553303">
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="109092334">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Deblock:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="458722452"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="1072509220">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{503, 99}, {56, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="965262561">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1072509220"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="43900501">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{427, 79}, {68, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="1005519170">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Detelecine:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="43900501"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="999897202">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{427, 60}, {68, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="749563917">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Deinterlace:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="999897202"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="1017614971">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{119, 99}, {99, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="370959642">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1017614971"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="580175226">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{119, 77}, {99, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="82054988">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="580175226"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="149133624">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{119, 55}, {155, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="334116173">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
+                                                                                                       <int key="NSCellFlags2">4194304</int>
+                                                                                                       <string key="NSContents">Video Filters:</string>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="149133624"/>
+                                                                                                       <reference key="NSControlView" ref="503933842"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        <object class="NSPopUpButton" id="222980245">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{123, 229}, {168, 22}}</string>
+                                                                                               <string key="NSFrame">{{106, 229}, {149, 22}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSPopUpButtonCell" key="NSCell" id="343952154">
                                                                                        <object class="NSButton" id="1000247853">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{123, 188}, {124, 18}}</string>
+                                                                                               <string key="NSFrame">{{106, 208}, {124, 18}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSButtonCell" key="NSCell" id="860863090">
                                                                                        <object class="NSButton" id="447003158">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{140, 170}, {107, 16}}</string>
+                                                                                               <string key="NSFrame">{{123, 190}, {107, 16}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSButtonCell" key="NSCell" id="1070893195">
                                                                                        <object class="NSPopUpButton" id="12330413">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{123, 254}, {168, 22}}</string>
+                                                                                               <string key="NSFrame">{{106, 254}, {149, 22}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSPopUpButtonCell" key="NSCell" id="1018849574">
                                                                                                        <int key="NSArrowPosition">1</int>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSButton" id="586924601">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{123, 210}, {133, 18}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSButtonCell" key="NSCell" id="531797832">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">131072</int>
-                                                                                                       <string key="NSContents">Grayscale encoding</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="586924601"/>
-                                                                                                       <int key="NSButtonFlags">1211912703</int>
-                                                                                                       <int key="NSButtonFlags2">2</int>
-                                                                                                       <reference key="NSAlternateImage" ref="624832340"/>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <string key="NSKeyEquivalent"/>
-                                                                                                       <int key="NSPeriodicDelay">200</int>
-                                                                                                       <int key="NSPeriodicInterval">25</int>
-                                                                                               </object>
-                                                                                       </object>
                                                                                        <object class="NSTextField" id="463960465">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{-1, 231}, {119, 17}}</string>
+                                                                                               <string key="NSFrame">{{9, 231}, {92, 17}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="509250281">
                                                                                        <object class="NSTextField" id="1064150725">
                                                                                                <reference key="NSNextResponder" ref="1053078401"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{11, 256}, {107, 17}}</string>
+                                                                                               <string key="NSFrame">{{14, 256}, {87, 17}}</string>
                                                                                                <reference key="NSSuperview" ref="1053078401"/>
                                                                                                <bool key="NSEnabled">YES</bool>
                                                                                                <object class="NSTextFieldCell" key="NSCell" id="451922400">
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="946167393">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{503, 21}, {140, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="152262221">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">272629760</int>
-                                                                                                       <string key="NSContents"/>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="946167393"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="554762309">
-                                                                                               <reference key="NSNextResponder" ref="1053078401"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{428, 17}, {68, 17}}</string>
-                                                                                               <reference key="NSSuperview" ref="1053078401"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="2157">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Decomb:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="554762309"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
                                                                                </object>
                                                                                <string key="NSFrame">{{10, 25}, {714, 305}}</string>
-                                                                               <reference key="NSSuperview" ref="712502892"/>
                                                                        </object>
                                                                        <string key="NSLabel">Video</string>
                                                                        <reference key="NSColor" ref="242973447"/>
                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                        <reference key="NSControlView" ref="290434291"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="122023676">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{572, 248}, {80, 13}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <reference key="NSNextKeyView" ref="351922892"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="92788757">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">138674176</int>
-                                                                                                       <string key="NSContents">Bitrate (kbps)</string>
-                                                                                                       <object class="NSFont" key="NSSupport" id="22">
-                                                                                                               <string key="NSName">LucidaGrande</string>
-                                                                                                               <double key="NSSize">9.000000e+00</double>
-                                                                                                               <int key="NSfFlags">3614</int>
-                                                                                                       </object>
-                                                                                                       <reference key="NSControlView" ref="122023676"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                                       <object class="NSPopUpButton" id="351922892">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{578, 221}, {66, 22}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <reference key="NSNextKeyView" ref="436388527"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="569025834">
-                                                                                                       <int key="NSCellFlags">-2076049856</int>
-                                                                                                       <int key="NSCellFlags2">132096</int>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="351922892"/>
-                                                                                                       <int key="NSButtonFlags">109199615</int>
-                                                                                                       <int key="NSButtonFlags2">1</int>
-                                                                                                       <reference key="NSAlternateImage" ref="995413175"/>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                               <characters key="NS.bytes"/>
-                                                                                                       </object>
-                                                                                                       <int key="NSPeriodicDelay">400</int>
-                                                                                                       <int key="NSPeriodicInterval">75</int>
-                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="53010878">
-                                                                                                               <reference key="NSMenu" ref="389043188"/>
-                                                                                                               <string key="NSTitle"/>
-                                                                                                               <string key="NSKeyEquiv"/>
-                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                               <int key="NSState">1</int>
-                                                                                                               <reference key="NSOnImage" ref="447995298"/>
-                                                                                                               <reference key="NSMixedImage" ref="760317610"/>
-                                                                                                               <string key="NSAction">_popUpItemAction:</string>
-                                                                                                               <reference key="NSTarget" ref="569025834"/>
-                                                                                                       </object>
-                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                                       <object class="NSMenu" key="NSMenu" id="389043188">
-                                                                                                               <object class="NSMutableString" key="NSTitle">
-                                                                                                                       <characters key="NS.bytes">OtherViews</characters>
-                                                                                                               </object>
-                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
-                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                                       <reference ref="53010878"/>
-                                                                                                               </object>
-                                                                                                       </object>
-                                                                                                       <int key="NSPreferredEdge">3</int>
-                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
-                                                                                                       <bool key="NSAltersState">YES</bool>
-                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                       <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="436388527">
+                                                                                       <object class="NSTextField" id="122023676">
                                                                                                <reference key="NSNextResponder" ref="738554558"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{-10, 48}, {70, 14}}</string>
+                                                                                               <string key="NSFrame">{{572, 248}, {80, 13}}</string>
                                                                                                <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <reference key="NSNextKeyView" ref="506492318"/>
+                                                                                               <reference key="NSNextKeyView" ref="351922892"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="95314231">
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="92788757">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">71303168</int>
-                                                                                                       <string key="NSContents">Subtitles:</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="436388527"/>
+                                                                                                       <int key="NSCellFlags2">138674176</int>
+                                                                                                       <string key="NSContents">Bitrate (kbps)</string>
+                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                       <reference key="NSControlView" ref="122023676"/>
                                                                                                        <reference key="NSBackgroundColor" ref="242973447"/>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSPopUpButton" id="506492318">
+                                                                                       <object class="NSPopUpButton" id="351922892">
                                                                                                <reference key="NSNextResponder" ref="738554558"/>
                                                                                                <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{65, 42}, {157, 22}}</string>
+                                                                                               <string key="NSFrame">{{578, 221}, {66, 22}}</string>
                                                                                                <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <reference key="NSNextKeyView" ref="712502892"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="636153290">
+                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="569025834">
                                                                                                        <int key="NSCellFlags">-2076049856</int>
                                                                                                        <int key="NSCellFlags2">132096</int>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="506492318"/>
+                                                                                                       <reference key="NSControlView" ref="351922892"/>
                                                                                                        <int key="NSButtonFlags">109199615</int>
                                                                                                        <int key="NSButtonFlags2">1</int>
-                                                                                                       <reference key="NSAlternateImage" ref="26"/>
+                                                                                                       <reference key="NSAlternateImage" ref="995413175"/>
                                                                                                        <string key="NSAlternateContents"/>
                                                                                                        <object class="NSMutableString" key="NSKeyEquivalent">
                                                                                                                <characters key="NS.bytes"/>
                                                                                                        </object>
                                                                                                        <int key="NSPeriodicDelay">400</int>
                                                                                                        <int key="NSPeriodicInterval">75</int>
-                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="432645698">
-                                                                                                               <reference key="NSMenu" ref="121028261"/>
+                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="53010878">
+                                                                                                               <reference key="NSMenu" ref="389043188"/>
                                                                                                                <string key="NSTitle"/>
                                                                                                                <string key="NSKeyEquiv"/>
                                                                                                                <int key="NSKeyEquivModMask">1048576</int>
                                                                                                                <reference key="NSOnImage" ref="447995298"/>
                                                                                                                <reference key="NSMixedImage" ref="760317610"/>
                                                                                                                <string key="NSAction">_popUpItemAction:</string>
-                                                                                                               <reference key="NSTarget" ref="636153290"/>
+                                                                                                               <reference key="NSTarget" ref="569025834"/>
                                                                                                        </object>
                                                                                                        <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                                       <object class="NSMenu" key="NSMenu" id="121028261">
+                                                                                                       <object class="NSMenu" key="NSMenu" id="389043188">
                                                                                                                <object class="NSMutableString" key="NSTitle">
                                                                                                                        <characters key="NS.bytes">OtherViews</characters>
                                                                                                                </object>
                                                                                                                <object class="NSMutableArray" key="NSMenuItems">
                                                                                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                                       <reference ref="432645698"/>
+                                                                                                                       <reference ref="53010878"/>
                                                                                                                </object>
                                                                                                        </object>
                                                                                                        <int key="NSPreferredEdge">3</int>
                                                                                                        <int key="NSArrowPosition">1</int>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSButton" id="691038230">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <string key="NSFrame">{{229, 46}, {147, 17}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSButtonCell" key="NSCell" id="944590907">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">131072</int>
-                                                                                                       <string key="NSContents">Forced Subtitles Only</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="691038230"/>
-                                                                                                       <int key="NSButtonFlags">1211912703</int>
-                                                                                                       <int key="NSButtonFlags2">2</int>
-                                                                                                       <reference key="NSAlternateImage" ref="624832340"/>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <string key="NSKeyEquivalent"/>
-                                                                                                       <int key="NSPeriodicDelay">200</int>
-                                                                                                       <int key="NSPeriodicInterval">25</int>
-                                                                                               </object>
-                                                                                       </object>
                                                                                        <object class="NSTextField" id="978534247">
                                                                                                <reference key="NSNextResponder" ref="738554558"/>
                                                                                                <int key="NSvFlags">268</int>
                                                                                                        <int key="NSCellFlags">67239488</int>
                                                                                                        <int key="NSCellFlags2">272761856</int>
                                                                                                        <string key="NSContents">Audio Tracks</string>
-                                                                                                       <object class="NSFont" key="NSSupport" id="347509359">
+                                                                                                       <object class="NSFont" key="NSSupport">
                                                                                                                <string key="NSName">LucidaGrande-Bold</string>
                                                                                                                <double key="NSSize">1.100000e+01</double>
                                                                                                                <int key="NSfFlags">16</int>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSBox" id="124979328">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">268</int>
-                                                                                               <string key="NSFrame">{{86, 84}, {624, 5}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <string key="NSOffsets">{0, 0}</string>
-                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">0</int>
-                                                                                                       <string key="NSContents">Box</string>
-                                                                                                       <reference key="NSSupport" ref="273283760"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="138233214"/>
-                                                                                                       <object class="NSColor" key="NSTextColor">
-                                                                                                               <int key="NSColorSpace">3</int>
-                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-                                                                                                       </object>
-                                                                                               </object>
-                                                                                               <int key="NSBorderType">3</int>
-                                                                                               <int key="NSBoxType">2</int>
-                                                                                               <int key="NSTitlePosition">0</int>
-                                                                                               <bool key="NSTransparent">NO</bool>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="844196518">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">268</int>
-                                                                                               <string key="NSFrame">{{17, 79}, {54, 14}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="653177228">
-                                                                                                       <int key="NSCellFlags">67239488</int>
-                                                                                                       <int key="NSCellFlags2">272761856</int>
-                                                                                                       <string key="NSContents">Subtitles</string>
-                                                                                                       <reference key="NSSupport" ref="347509359"/>
-                                                                                                       <reference key="NSControlView" ref="844196518"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
-                                                                                               </object>
-                                                                                       </object>
                                                                                        <object class="NSPopUpButton" id="135824882">
                                                                                                <reference key="NSNextResponder" ref="738554558"/>
                                                                                                <int key="NSvFlags">256</int>
                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                        <reference key="NSControlView" ref="861218370"/>
                                                                                                        <double key="NSMaxValue">4.000000e+00</double>
-                                                                                                       <double key="NSMinValue">1.000000e+00</double>
-                                                                                                       <double key="NSValue">1.000000e+00</double>
+                                                                                                       <double key="NSMinValue">0.000000e+00</double>
+                                                                                                       <double key="NSValue">0.000000e+00</double>
                                                                                                        <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                                       <int key="NSNumberOfTickMarks">12</int>
+                                                                                                       <int key="NSNumberOfTickMarks">16</int>
                                                                                                        <int key="NSTickMarkPosition">0</int>
                                                                                                        <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
                                                                                                        <bool key="NSVertical">NO</bool>
                                                                                                        </object>
                                                                                                        <reference key="NSControlView" ref="695663835"/>
                                                                                                        <double key="NSMaxValue">4.000000e+00</double>
-                                                                                                       <double key="NSMinValue">1.000000e+00</double>
-                                                                                                       <double key="NSValue">1.000000e+00</double>
+                                                                                                       <double key="NSMinValue">0.000000e+00</double>
+                                                                                                       <double key="NSValue">0.000000e+00</double>
                                                                                                        <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                                       <int key="NSNumberOfTickMarks">12</int>
+                                                                                                       <int key="NSNumberOfTickMarks">16</int>
                                                                                                        <int key="NSTickMarkPosition">0</int>
                                                                                                        <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
                                                                                                        <bool key="NSVertical">NO</bool>
                                                                                                        <reference key="NSSupport" ref="478239882"/>
                                                                                                        <reference key="NSControlView" ref="229696812"/>
                                                                                                        <double key="NSMaxValue">4.000000e+00</double>
-                                                                                                       <double key="NSMinValue">1.000000e+00</double>
-                                                                                                       <double key="NSValue">1.000000e+00</double>
+                                                                                                       <double key="NSMinValue">0.000000e+00</double>
+                                                                                                       <double key="NSValue">0.000000e+00</double>
                                                                                                        <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                                       <int key="NSNumberOfTickMarks">12</int>
+                                                                                                       <int key="NSNumberOfTickMarks">16</int>
                                                                                                        <int key="NSTickMarkPosition">0</int>
                                                                                                        <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
                                                                                                        <bool key="NSVertical">NO</bool>
                                                                                                        <reference key="NSSupport" ref="478239882"/>
                                                                                                        <reference key="NSControlView" ref="927860050"/>
                                                                                                        <double key="NSMaxValue">4.000000e+00</double>
-                                                                                                       <double key="NSMinValue">1.000000e+00</double>
-                                                                                                       <double key="NSValue">1.000000e+00</double>
+                                                                                                       <double key="NSMinValue">0.000000e+00</double>
+                                                                                                       <double key="NSValue">0.000000e+00</double>
                                                                                                        <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                                       <int key="NSNumberOfTickMarks">12</int>
+                                                                                                       <int key="NSNumberOfTickMarks">16</int>
                                                                                                        <int key="NSTickMarkPosition">0</int>
                                                                                                        <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
                                                                                                        <bool key="NSVertical">NO</bool>
                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="850861055">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
+                                                                                       <object class="NSTextField" id="850861055">
+                                                                                               <reference key="NSNextResponder" ref="738554558"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <string key="NSFrame">{{685, 197}, {26, 11}}</string>
+                                                                                               <reference key="NSSuperview" ref="738554558"/>
+                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="539528192">
+                                                                                                       <int key="NSCellFlags">67239488</int>
+                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                       <string key="NSContents">1.0</string>
+                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                       <reference key="NSControlView" ref="850861055"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
+                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <object class="NSTextField" id="988102670">
+                                                                                               <reference key="NSNextResponder" ref="738554558"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <string key="NSFrame">{{686, 168}, {26, 11}}</string>
+                                                                                               <reference key="NSSuperview" ref="738554558"/>
+                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="477201006">
+                                                                                                       <int key="NSCellFlags">67239488</int>
+                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                       <string key="NSContents">1.0</string>
+                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                       <reference key="NSControlView" ref="988102670"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
+                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <object class="NSTextField" id="758473796">
+                                                                                               <reference key="NSNextResponder" ref="738554558"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <string key="NSFrame">{{685, 140}, {26, 11}}</string>
+                                                                                               <reference key="NSSuperview" ref="738554558"/>
+                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                               <object class="NSTextFieldCell" key="NSCell" id="941741345">
+                                                                                                       <int key="NSCellFlags">67239488</int>
+                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                       <string key="NSContents">1.0</string>
+                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                       <reference key="NSControlView" ref="758473796"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
+                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                               </object>
+                                                                                       </object>
+                                                                               </object>
+                                                                               <string key="NSFrame">{{10, 25}, {714, 305}}</string>
+                                                                               <reference key="NSNextKeyView" ref="198352083"/>
+                                                                       </object>
+                                                                       <string key="NSLabel">Audio</string>
+                                                                       <reference key="NSColor" ref="242973447"/>
+                                                                       <reference key="NSTabView" ref="712502892"/>
+                                                               </object>
+                                                               <object class="NSTabViewItem" id="799016137">
+                                                                       <string key="NSIdentifier">3</string>
+                                                                       <object class="NSView" key="NSView" id="756255803">
+                                                                               <reference key="NSNextResponder" ref="712502892"/>
+                                                                               <int key="NSvFlags">256</int>
+                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                       <object class="NSScrollView" id="596256174">
+                                                                                               <reference key="NSNextResponder" ref="756255803"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSClipView" id="705918581">
+                                                                                                               <reference key="NSNextResponder" ref="596256174"/>
+                                                                                                               <int key="NSvFlags">2304</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSTableView" id="587237088">
+                                                                                                                               <reference key="NSNextResponder" ref="705918581"/>
+                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                               <string key="NSFrameSize">{678, 241}</string>
+                                                                                                                               <reference key="NSSuperview" ref="705918581"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTableHeaderView" key="NSHeaderView" id="569585004">
+                                                                                                                                       <reference key="NSNextResponder" ref="139191276"/>
+                                                                                                                                       <int key="NSvFlags">256</int>
+                                                                                                                                       <string key="NSFrameSize">{678, 17}</string>
+                                                                                                                                       <reference key="NSSuperview" ref="139191276"/>
+                                                                                                                                       <reference key="NSTableView" ref="587237088"/>
+                                                                                                                               </object>
+                                                                                                                               <object class="_NSCornerView" key="NSCornerView" id="10217663">
+                                                                                                                                       <reference key="NSNextResponder" ref="596256174"/>
+                                                                                                                                       <int key="NSvFlags">-2147483392</int>
+                                                                                                                                       <string key="NSFrame">{{-26, 0}, {16, 17}}</string>
+                                                                                                                                       <reference key="NSSuperview" ref="596256174"/>
+                                                                                                                               </object>
+                                                                                                                               <object class="NSMutableArray" key="NSTableColumns">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="NSTableColumn" id="274341565">
+                                                                                                                                               <string key="NSIdentifier">track</string>
+                                                                                                                                               <double key="NSWidth">1.670000e+02</double>
+                                                                                                                                               <double key="NSMinWidth">4.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">1.000000e+03</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
+                                                                                                                                                       <string key="NSContents">Track</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <object class="NSColor" key="NSBackgroundColor">
+                                                                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                                                                               <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSColor" key="NSTextColor" id="188451177">
+                                                                                                                                                               <int key="NSColorSpace">6</int>
+                                                                                                                                                               <string key="NSCatalogName">System</string>
+                                                                                                                                                               <string key="NSColorName">headerTextColor</string>
+                                                                                                                                                               <reference key="NSColor" ref="544409939"/>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSPopUpButtonCell" key="NSDataCell" id="426946554">
+                                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">100679935</int>
+                                                                                                                                                       <int key="NSButtonFlags2">129</int>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="1026748451">
+                                                                                                                                                               <reference key="NSMenu" ref="472498711"/>
+                                                                                                                                                               <string key="NSTitle">Pop Up</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="447995298"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="760317610"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="426946554"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                                       <object class="NSMenu" key="NSMenu" id="472498711">
+                                                                                                                                                               <string key="NSTitle">OtherViews</string>
+                                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                       <reference ref="1026748451"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                                       <int key="NSArrowPosition">2</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="1033748386">
+                                                                                                                                               <string key="NSIdentifier">forced</string>
+                                                                                                                                               <double key="NSWidth">7.500000e+01</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">134219776</int>
+                                                                                                                                                       <string key="NSContents">Forced Only</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <object class="NSColor" key="NSBackgroundColor" id="1045207104">
+                                                                                                                                                               <int key="NSColorSpace">6</int>
+                                                                                                                                                               <string key="NSCatalogName">System</string>
+                                                                                                                                                               <string key="NSColorName">headerColor</string>
+                                                                                                                                                               <reference key="NSColor" ref="809784795"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSButtonCell" key="NSDataCell" id="13236417">
+                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                                       <string key="NSContents">Check</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">1215582719</int>
+                                                                                                                                                       <int key="NSButtonFlags2">130</int>
+                                                                                                                                                       <reference key="NSNormalImage" ref="887198214"/>
+                                                                                                                                                       <reference key="NSAlternateImage" ref="624832340"/>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">25</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="362209136">
+                                                                                                                                               <string key="NSIdentifier">burned</string>
+                                                                                                                                               <double key="NSWidth">6.500000e+01</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">134219776</int>
+                                                                                                                                                       <string key="NSContents">Burned In</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="1045207104"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSButtonCell" key="NSDataCell" id="704907857">
+                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                                       <string key="NSContents">Check</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">1215582719</int>
+                                                                                                                                                       <int key="NSButtonFlags2">130</int>
+                                                                                                                                                       <reference key="NSNormalImage" ref="887198214"/>
+                                                                                                                                                       <reference key="NSAlternateImage" ref="624832340"/>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">25</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="270619684">
+                                                                                                                                               <string key="NSIdentifier">default</string>
+                                                                                                                                               <double key="NSWidth">5.400000e+01</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">134219776</int>
+                                                                                                                                                       <string key="NSContents">Default</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="1045207104"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSButtonCell" key="NSDataCell" id="299034685">
+                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                                       <string key="NSContents">Check</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">1215582719</int>
+                                                                                                                                                       <int key="NSButtonFlags2">130</int>
+                                                                                                                                                       <reference key="NSNormalImage" ref="887198214"/>
+                                                                                                                                                       <reference key="NSAlternateImage" ref="624832340"/>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">25</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="116912874">
+                                                                                                                                               <string key="NSIdentifier">srt_lang</string>
+                                                                                                                                               <double key="NSWidth">1.120000e+02</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
+                                                                                                                                                       <string key="NSContents">Srt Language</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="1045207104"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSPopUpButtonCell" key="NSDataCell" id="688461412">
+                                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                                       <int key="NSCellFlags2">133120</int>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">100679935</int>
+                                                                                                                                                       <int key="NSButtonFlags2">129</int>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="341659302">
+                                                                                                                                                               <reference key="NSMenu" ref="808277525"/>
+                                                                                                                                                               <string key="NSTitle">Pop Up</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="447995298"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="760317610"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="688461412"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                                       <object class="NSMenu" key="NSMenu" id="808277525">
+                                                                                                                                                               <string key="NSTitle">OtherViews</string>
+                                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                       <reference ref="341659302"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="180322215">
+                                                                                                                                               <string key="NSIdentifier">srt_charcode</string>
+                                                                                                                                               <double key="NSWidth">1.230000e+02</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
+                                                                                                                                                       <string key="NSContents">Srt Char Code</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="1045207104"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSPopUpButtonCell" key="NSDataCell" id="483232645">
+                                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                                       <int key="NSCellFlags2">133120</int>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <int key="NSButtonFlags">100679935</int>
+                                                                                                                                                       <int key="NSButtonFlags2">129</int>
+                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="66454705">
+                                                                                                                                                               <reference key="NSMenu" ref="427130300"/>
+                                                                                                                                                               <string key="NSTitle">Pop Up</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="447995298"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="760317610"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="483232645"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                                       <object class="NSMenu" key="NSMenu" id="427130300">
+                                                                                                                                                               <string key="NSTitle">OtherViews</string>
+                                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                       <reference ref="66454705"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSTableColumn" id="526590234">
+                                                                                                                                               <string key="NSIdentifier">srt_offset</string>
+                                                                                                                                               <double key="NSWidth">6.100000e+01</double>
+                                                                                                                                               <double key="NSMinWidth">1.000000e+01</double>
+                                                                                                                                               <double key="NSMaxWidth">3.402823e+38</double>
+                                                                                                                                               <object class="NSTableHeaderCell" key="NSHeaderCell">
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
+                                                                                                                                                       <string key="NSContents">Srt Offset</string>
+                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="1045207104"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSTextFieldCell" key="NSDataCell" id="43785715">
+                                                                                                                                                       <int key="NSCellFlags">337772096</int>
+                                                                                                                                                       <int key="NSCellFlags2">272630784</int>
+                                                                                                                                                       <string key="NSContents">Text</string>
+                                                                                                                                                       <reference key="NSSupport" ref="273283760"/>
+                                                                                                                                                       <reference key="NSControlView" ref="587237088"/>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
+                                                                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSResizingMask">3</int>
+                                                                                                                                               <bool key="NSIsResizeable">YES</bool>
+                                                                                                                                               <bool key="NSIsEditable">YES</bool>
+                                                                                                                                               <reference key="NSTableView" ref="587237088"/>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <double key="NSIntercellSpacingWidth">3.000000e+00</double>
+                                                                                                                               <double key="NSIntercellSpacingHeight">2.000000e+00</double>
+                                                                                                                               <reference key="NSBackgroundColor" ref="809784795"/>
+                                                                                                                               <object class="NSColor" key="NSGridColor" id="156710040">
+                                                                                                                                       <int key="NSColorSpace">6</int>
+                                                                                                                                       <string key="NSCatalogName">System</string>
+                                                                                                                                       <string key="NSColorName">gridColor</string>
+                                                                                                                                       <object class="NSColor" key="NSColor">
+                                                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                                                               <bytes key="NSWhite">MC41AA</bytes>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <double key="NSRowHeight">1.700000e+01</double>
+                                                                                                                               <int key="NSTvFlags">1379926016</int>
+                                                                                                                               <int key="NSColumnAutoresizingStyle">4</int>
+                                                                                                                               <int key="NSDraggingSourceMaskForLocal">15</int>
+                                                                                                                               <int key="NSDraggingSourceMaskForNonLocal">0</int>
+                                                                                                                               <bool key="NSAllowsTypeSelect">NO</bool>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <string key="NSFrame">{{1, 17}, {678, 241}}</string>
+                                                                                                               <reference key="NSSuperview" ref="596256174"/>
+                                                                                                               <reference key="NSNextKeyView" ref="587237088"/>
+                                                                                                               <reference key="NSDocView" ref="587237088"/>
+                                                                                                               <object class="NSColor" key="NSBGColor" id="355843302">
+                                                                                                                       <int key="NSColorSpace">6</int>
+                                                                                                                       <string key="NSCatalogName">System</string>
+                                                                                                                       <string key="NSColorName">controlBackgroundColor</string>
+                                                                                                                       <reference key="NSColor" ref="458742033"/>
+                                                                                                               </object>
+                                                                                                               <int key="NScvFlags">4</int>
+                                                                                                       </object>
+                                                                                                       <object class="NSScroller" id="40751315">
+                                                                                                               <reference key="NSNextResponder" ref="596256174"/>
+                                                                                                               <int key="NSvFlags">-2147483392</int>
+                                                                                                               <string key="NSFrame">{{-100, -100}, {15, 206}}</string>
+                                                                                                               <reference key="NSSuperview" ref="596256174"/>
+                                                                                                               <reference key="NSTarget" ref="596256174"/>
+                                                                                                               <string key="NSAction">_doScroller:</string>
+                                                                                                               <double key="NSCurValue">3.700000e+01</double>
+                                                                                                               <double key="NSPercent">1.947368e-01</double>
+                                                                                                       </object>
+                                                                                                       <object class="NSScroller" id="892147391">
+                                                                                                               <reference key="NSNextResponder" ref="596256174"/>
+                                                                                                               <int key="NSvFlags">-2147483392</int>
+                                                                                                               <string key="NSFrame">{{-100, -100}, {685, 15}}</string>
+                                                                                                               <reference key="NSSuperview" ref="596256174"/>
+                                                                                                               <int key="NSsFlags">1</int>
+                                                                                                               <reference key="NSTarget" ref="596256174"/>
+                                                                                                               <string key="NSAction">_doScroller:</string>
+                                                                                                               <double key="NSPercent">5.714286e-01</double>
+                                                                                                       </object>
+                                                                                                       <object class="NSClipView" id="139191276">
+                                                                                                               <reference key="NSNextResponder" ref="596256174"/>
+                                                                                                               <int key="NSvFlags">2304</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <reference ref="569585004"/>
+                                                                                                               </object>
+                                                                                                               <string key="NSFrame">{{1, 0}, {678, 17}}</string>
+                                                                                                               <reference key="NSSuperview" ref="596256174"/>
+                                                                                                               <reference key="NSNextKeyView" ref="569585004"/>
+                                                                                                               <reference key="NSDocView" ref="569585004"/>
+                                                                                                               <reference key="NSBGColor" ref="355843302"/>
+                                                                                                               <int key="NScvFlags">4</int>
+                                                                                                       </object>
+                                                                                                       <reference ref="10217663"/>
+                                                                                               </object>
+                                                                                               <string key="NSFrame">{{17, 17}, {680, 259}}</string>
+                                                                                               <reference key="NSSuperview" ref="756255803"/>
+                                                                                               <reference key="NSNextKeyView" ref="705918581"/>
+                                                                                               <int key="NSsFlags">514</int>
+                                                                                               <reference key="NSVScroller" ref="40751315"/>
+                                                                                               <reference key="NSHScroller" ref="892147391"/>
+                                                                                               <reference key="NSContentView" ref="705918581"/>
+                                                                                               <reference key="NSHeaderClipView" ref="139191276"/>
+                                                                                               <reference key="NSCornerView" ref="10217663"/>
+                                                                                               <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+                                                                                       </object>
+                                                                                       <object class="NSButton" id="377401502">
+                                                                                               <reference key="NSNextResponder" ref="756255803"/>
                                                                                                <int key="NSvFlags">268</int>
-                                                                                               <string key="NSFrame">{{685, 197}, {26, 11}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
+                                                                                               <string key="NSFrame">{{16, 283}, {116, 16}}</string>
+                                                                                               <reference key="NSSuperview" ref="756255803"/>
                                                                                                <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="539528192">
-                                                                                                       <int key="NSCellFlags">67239488</int>
-                                                                                                       <int key="NSCellFlags2">272892928</int>
-                                                                                                       <string key="NSContents">1.0</string>
+                                                                                               <object class="NSButtonCell" key="NSCell" id="206924163">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">134479872</int>
+                                                                                                       <string key="NSContents">Add External SRT ...</string>
                                                                                                        <reference key="NSSupport" ref="22"/>
-                                                                                                       <reference key="NSControlView" ref="850861055"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                                       <reference key="NSControlView" ref="377401502"/>
+                                                                                                       <int key="NSButtonFlags">-2038284033</int>
+                                                                                                       <int key="NSButtonFlags2">129</int>
+                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                       <int key="NSPeriodicInterval">25</int>
                                                                                                </object>
                                                                                        </object>
-                                                                                       <object class="NSTextField" id="988102670">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">268</int>
-                                                                                               <string key="NSFrame">{{686, 168}, {26, 11}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="477201006">
-                                                                                                       <int key="NSCellFlags">67239488</int>
-                                                                                                       <int key="NSCellFlags2">272892928</int>
-                                                                                                       <string key="NSContents">1.0</string>
-                                                                                                       <reference key="NSSupport" ref="22"/>
-                                                                                                       <reference key="NSControlView" ref="988102670"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                               </object>
+                                                                               <string key="NSFrame">{{10, 25}, {714, 305}}</string>
+                                                                               <reference key="NSSuperview" ref="712502892"/>
+                                                                       </object>
+                                                                       <string key="NSLabel">Subtitles</string>
+                                                                       <reference key="NSColor" ref="242973447"/>
+                                                                       <reference key="NSTabView" ref="712502892"/>
+                                                               </object>
+                                                               <object class="NSTabViewItem" id="744678564">
+                                                                       <string key="NSIdentifier">5</string>
+                                                                       <object class="NSView" key="NSView" id="833271282">
+                                                                               <nil key="NSNextResponder"/>
+                                                                               <int key="NSvFlags">256</int>
+                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                       <object class="NSBox" id="231506045">
+                                                                                               <reference key="NSNextResponder" ref="833271282"/>
+                                                                                               <int key="NSvFlags">256</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="815869140">
+                                                                                                               <reference key="NSNextResponder" ref="231506045"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <string key="NSFrameSize">{700, 290}</string>
+                                                                                                               <reference key="NSSuperview" ref="231506045"/>
+                                                                                                       </object>
                                                                                                </object>
-                                                                                       </object>
-                                                                                       <object class="NSTextField" id="758473796">
-                                                                                               <reference key="NSNextResponder" ref="738554558"/>
-                                                                                               <int key="NSvFlags">268</int>
-                                                                                               <string key="NSFrame">{{685, 140}, {26, 11}}</string>
-                                                                                               <reference key="NSSuperview" ref="738554558"/>
-                                                                                               <bool key="NSEnabled">YES</bool>
-                                                                                               <object class="NSTextFieldCell" key="NSCell" id="941741345">
-                                                                                                       <int key="NSCellFlags">67239488</int>
-                                                                                                       <int key="NSCellFlags2">272892928</int>
-                                                                                                       <string key="NSContents">1.0</string>
-                                                                                                       <reference key="NSSupport" ref="22"/>
-                                                                                                       <reference key="NSControlView" ref="758473796"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="242973447"/>
-                                                                                                       <reference key="NSTextColor" ref="701609070"/>
+                                                                                               <string key="NSFrame">{{7, 8}, {700, 290}}</string>
+                                                                                               <reference key="NSSuperview" ref="833271282"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents">Box</string>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="138233214"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                       </object>
                                                                                                </object>
+                                                                                               <reference key="NSContentView" ref="815869140"/>
+                                                                                               <int key="NSBorderType">0</int>
+                                                                                               <int key="NSBoxType">3</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
                                                                                </object>
                                                                                <string key="NSFrame">{{10, 25}, {714, 305}}</string>
-                                                                               <reference key="NSNextKeyView" ref="198352083"/>
                                                                        </object>
-                                                                       <string type="base64-UTF8" key="NSLabel">QXVkaW8gJiBTdWJ0aXRsZXM</string>
+                                                                       <string key="NSLabel">Advanced</string>
                                                                        <reference key="NSColor" ref="242973447"/>
                                                                        <reference key="NSTabView" ref="712502892"/>
                                                                </object>
                                                                <object class="NSTabViewItem" id="291470012">
-                                                                       <string key="NSIdentifier">3</string>
+                                                                       <string key="NSIdentifier">4</string>
                                                                        <object class="NSView" key="NSView" id="440990725">
                                                                                <nil key="NSNextResponder"/>
                                                                                <int key="NSvFlags">256</int>
                                                                                                                                                <double key="NSMinWidth">4.000000e+01</double>
                                                                                                                                                <double key="NSMaxWidth">1.000000e+03</double>
                                                                                                                                                <object class="NSTableHeaderCell" key="NSHeaderCell">
-                                                                                                                                                       <int key="NSCellFlags">75628032</int>
-                                                                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
                                                                                                                                                        <string key="NSContents">Chapter</string>
                                                                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                                                                        <object class="NSColor" key="NSBackgroundColor" id="754789485">
                                                                                                                                                                <int key="NSColorSpace">3</int>
                                                                                                                                                                <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
                                                                                                                                                        </object>
-                                                                                                                                                       <object class="NSColor" key="NSTextColor" id="188451177">
-                                                                                                                                                               <int key="NSColorSpace">6</int>
-                                                                                                                                                               <string key="NSCatalogName">System</string>
-                                                                                                                                                               <string key="NSColorName">headerTextColor</string>
-                                                                                                                                                               <reference key="NSColor" ref="544409939"/>
-                                                                                                                                                       </object>
+                                                                                                                                                       <reference key="NSTextColor" ref="188451177"/>
                                                                                                                                                </object>
                                                                                                                                                <object class="NSTextFieldCell" key="NSDataCell" id="686068440">
                                                                                                                                                        <int key="NSCellFlags">337772096</int>
                                                                                                                                                        <string key="NSContents">Text Cell</string>
                                                                                                                                                        <reference key="NSSupport" ref="995413175"/>
                                                                                                                                                        <reference key="NSControlView" ref="595654978"/>
-                                                                                                                                                       <object class="NSColor" key="NSBackgroundColor" id="355843302">
-                                                                                                                                                               <int key="NSColorSpace">6</int>
-                                                                                                                                                               <string key="NSCatalogName">System</string>
-                                                                                                                                                               <string key="NSColorName">controlBackgroundColor</string>
-                                                                                                                                                               <reference key="NSColor" ref="458742033"/>
-                                                                                                                                                       </object>
+                                                                                                                                                       <reference key="NSBackgroundColor" ref="355843302"/>
                                                                                                                                                        <reference key="NSTextColor" ref="701609070"/>
                                                                                                                                                </object>
                                                                                                                                                <int key="NSResizingMask">3</int>
                                                                                                                                                <double key="NSMinWidth">7.721729e+01</double>
                                                                                                                                                <double key="NSMaxWidth">1.000000e+03</double>
                                                                                                                                                <object class="NSTableHeaderCell" key="NSHeaderCell">
-                                                                                                                                                       <int key="NSCellFlags">75628032</int>
-                                                                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                                                                       <int key="NSCellFlags2">2048</int>
                                                                                                                                                        <string key="NSContents">Chapter Title</string>
                                                                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                                                                        <reference key="NSBackgroundColor" ref="754789485"/>
                                                                                                                                <double key="NSIntercellSpacingWidth">3.000000e+00</double>
                                                                                                                                <double key="NSIntercellSpacingHeight">2.000000e+00</double>
                                                                                                                                <reference key="NSBackgroundColor" ref="809784795"/>
-                                                                                                                               <object class="NSColor" key="NSGridColor" id="156710040">
-                                                                                                                                       <int key="NSColorSpace">6</int>
-                                                                                                                                       <string key="NSCatalogName">System</string>
-                                                                                                                                       <string key="NSColorName">gridColor</string>
-                                                                                                                                       <object class="NSColor" key="NSColor">
-                                                                                                                                               <int key="NSColorSpace">3</int>
-                                                                                                                                               <bytes key="NSWhite">MC41AA</bytes>
-                                                                                                                                       </object>
-                                                                                                                               </object>
+                                                                                                                               <reference key="NSGridColor" ref="156710040"/>
                                                                                                                                <double key="NSRowHeight">1.700000e+01</double>
                                                                                                                                <int key="NSTvFlags">-700448768</int>
                                                                                                                                <int key="NSColumnAutoresizingStyle">4</int>
                                                                                                        </object>
                                                                                                        <object class="NSScroller" id="1033243513">
                                                                                                                <reference key="NSNextResponder" ref="307620967"/>
-                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <int key="NSvFlags">-2147483392</int>
                                                                                                                <string key="NSFrame">{{-100, -100}, {488, 15}}</string>
                                                                                                                <reference key="NSSuperview" ref="307620967"/>
                                                                                                                <reference key="NSNextKeyView" ref="814110287"/>
                                                                        <reference key="NSColor" ref="242973447"/>
                                                                        <reference key="NSTabView" ref="712502892"/>
                                                                </object>
-                                                               <object class="NSTabViewItem" id="744678564">
-                                                                       <string key="NSIdentifier">4</string>
-                                                                       <object class="NSView" key="NSView" id="833271282">
-                                                                               <nil key="NSNextResponder"/>
-                                                                               <int key="NSvFlags">256</int>
-                                                                               <object class="NSMutableArray" key="NSSubviews">
-                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                       <object class="NSBox" id="231506045">
-                                                                                               <reference key="NSNextResponder" ref="833271282"/>
-                                                                                               <int key="NSvFlags">256</int>
-                                                                                               <object class="NSMutableArray" key="NSSubviews">
-                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                       <object class="NSView" id="815869140">
-                                                                                                               <reference key="NSNextResponder" ref="231506045"/>
-                                                                                                               <int key="NSvFlags">256</int>
-                                                                                                               <string key="NSFrameSize">{700, 290}</string>
-                                                                                                               <reference key="NSSuperview" ref="231506045"/>
-                                                                                                       </object>
-                                                                                               </object>
-                                                                                               <string key="NSFrame">{{7, 8}, {700, 290}}</string>
-                                                                                               <reference key="NSSuperview" ref="833271282"/>
-                                                                                               <string key="NSOffsets">{0, 0}</string>
-                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
-                                                                                                       <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">0</int>
-                                                                                                       <string key="NSContents">Box</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSBackgroundColor" ref="138233214"/>
-                                                                                                       <object class="NSColor" key="NSTextColor">
-                                                                                                               <int key="NSColorSpace">3</int>
-                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-                                                                                                       </object>
-                                                                                               </object>
-                                                                                               <reference key="NSContentView" ref="815869140"/>
-                                                                                               <int key="NSBorderType">0</int>
-                                                                                               <int key="NSBoxType">3</int>
-                                                                                               <int key="NSTitlePosition">0</int>
-                                                                                               <bool key="NSTransparent">NO</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <string key="NSFrame">{{10, 25}, {714, 305}}</string>
-                                                                       </object>
-                                                                       <string key="NSLabel">Advanced</string>
-                                                                       <reference key="NSColor" ref="242973447"/>
-                                                                       <reference key="NSTabView" ref="712502892"/>
-                                                               </object>
                                                        </object>
-                                                       <reference key="NSSelectedTabViewItem" ref="107038816"/>
+                                                       <reference key="NSSelectedTabViewItem" ref="799016137"/>
                                                        <reference key="NSFont" ref="26"/>
                                                        <int key="NSTvFlags">134217728</int>
                                                        <bool key="NSAllowTruncatedLabels">YES</bool>
                                                        <bool key="NSDrawsBackground">YES</bool>
                                                        <object class="NSMutableArray" key="NSSubviews">
                                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <reference ref="1053078401"/>
+                                                               <reference ref="756255803"/>
                                                        </object>
                                                </object>
                                                <object class="NSTextField" id="586321835">
                                                                <int key="NSCellFlags">67239424</int>
                                                                <int key="NSCellFlags2">4325376</int>
                                                                <string key="NSContents">Source:</string>
-                                                               <reference key="NSSupport" ref="27"/>
+                                                               <object class="NSFont" key="NSSupport" id="27">
+                                                                       <string key="NSName">LucidaGrande-Bold</string>
+                                                                       <double key="NSSize">1.100000e+01</double>
+                                                                       <int key="NSfFlags">3357</int>
+                                                               </object>
                                                                <reference key="NSControlView" ref="586321835"/>
                                                                <reference key="NSBackgroundColor" ref="242973447"/>
                                                                <reference key="NSTextColor" ref="701609070"/>
                                                <object class="NSPopUpButton" id="766125203">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{76, 490}, {177, 22}}</string>
+                                                       <string key="NSFrame">{{76, 490}, {165, 22}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSPopUpButtonCell" key="NSCell" id="821198683">
                                                <object class="NSTextField" id="1053010160">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{321, 495}, {65, 14}}</string>
+                                                       <string key="NSFrame">{{346, 495}, {65, 14}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="17369297">
                                                <object class="NSPopUpButton" id="971754180">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{388, 490}, {65, 22}}</string>
+                                                       <string key="NSFrame">{{413, 490}, {65, 22}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSPopUpButtonCell" key="NSCell" id="286887304">
                                                                <int key="NSArrowPosition">1</int>
                                                        </object>
                                                </object>
+                                               <object class="NSTextField" id="303369850">
+                                                       <reference key="NSNextResponder" ref="168918359"/>
+                                                       <int key="NSvFlags">264</int>
+                                                       <string key="NSFrame">{{241, 492}, {46, 17}}</string>
+                                                       <reference key="NSSuperview" ref="168918359"/>
+                                                       <bool key="NSEnabled">YES</bool>
+                                                       <object class="NSTextFieldCell" key="NSCell" id="677126774">
+                                                               <int key="NSCellFlags">67239424</int>
+                                                               <int key="NSCellFlags2">71303168</int>
+                                                               <string key="NSContents">Angle:</string>
+                                                               <reference key="NSSupport" ref="26"/>
+                                                               <reference key="NSControlView" ref="303369850"/>
+                                                               <reference key="NSBackgroundColor" ref="242973447"/>
+                                                               <reference key="NSTextColor" ref="701609070"/>
+                                                       </object>
+                                               </object>
+                                               <object class="NSPopUpButton" id="460320725">
+                                                       <reference key="NSNextResponder" ref="168918359"/>
+                                                       <int key="NSvFlags">264</int>
+                                                       <string key="NSFrame">{{286, 490}, {57, 22}}</string>
+                                                       <reference key="NSSuperview" ref="168918359"/>
+                                                       <bool key="NSEnabled">YES</bool>
+                                                       <object class="NSPopUpButtonCell" key="NSCell" id="567459641">
+                                                               <int key="NSCellFlags">-2076049856</int>
+                                                               <int key="NSCellFlags2">132096</int>
+                                                               <reference key="NSSupport" ref="26"/>
+                                                               <reference key="NSControlView" ref="460320725"/>
+                                                               <int key="NSButtonFlags">109199615</int>
+                                                               <int key="NSButtonFlags2">1</int>
+                                                               <reference key="NSAlternateImage" ref="26"/>
+                                                               <string key="NSAlternateContents"/>
+                                                               <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                       <characters key="NS.bytes"/>
+                                                               </object>
+                                                               <int key="NSPeriodicDelay">400</int>
+                                                               <int key="NSPeriodicInterval">75</int>
+                                                               <object class="NSMenuItem" key="NSMenuItem" id="62890346">
+                                                                       <reference key="NSMenu" ref="651682595"/>
+                                                                       <string key="NSTitle"/>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSKeyEquivModMask">1048576</int>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <int key="NSState">1</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                                       <string key="NSAction">_popUpItemAction:</string>
+                                                                       <reference key="NSTarget" ref="567459641"/>
+                                                               </object>
+                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                               <object class="NSMenu" key="NSMenu" id="651682595">
+                                                                       <object class="NSMutableString" key="NSTitle">
+                                                                               <characters key="NS.bytes">OtherViews</characters>
+                                                                       </object>
+                                                                       <object class="NSMutableArray" key="NSMenuItems">
+                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                               <reference ref="62890346"/>
+                                                                       </object>
+                                                               </object>
+                                                               <int key="NSPreferredEdge">3</int>
+                                                               <bool key="NSUsesItemFromMenu">YES</bool>
+                                                               <bool key="NSAltersState">YES</bool>
+                                                               <int key="NSArrowPosition">1</int>
+                                                       </object>
+                                               </object>
                                                <object class="NSPopUpButton" id="453345136">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{510, 490}, {65, 22}}</string>
+                                                       <string key="NSFrame">{{532, 490}, {65, 22}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSPopUpButtonCell" key="NSCell" id="564669343">
                                                <object class="NSTextField" id="200266929">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{455, 494}, {51, 15}}</string>
+                                                       <string key="NSFrame">{{479, 494}, {51, 15}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="904849236">
                                                <object class="NSTextField" id="1023408378">
                                                        <reference key="NSNextResponder" ref="168918359"/>
                                                        <int key="NSvFlags">264</int>
-                                                       <string key="NSFrame">{{27, 440}, {47, 14}}</string>
+                                                       <string key="NSFrame">{{27, 437}, {47, 17}}</string>
                                                        <reference key="NSSuperview" ref="168918359"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="834340599">
                                                                        <reference key="NSOnImage" ref="447995298"/>
                                                                        <reference key="NSMixedImage" ref="760317610"/>
                                                                </object>
+                                                               <object class="NSMenuItem" id="985983659">
+                                                                       <reference key="NSMenu" ref="1035150210"/>
+                                                                       <string type="base64-UTF8" key="NSTitle">Q2hlY2sgZm9yIFVwZGF0ZXPigKY</string>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSKeyEquivModMask">1048576</int>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                               </object>
                                                                <object class="NSMenuItem" id="912853376">
                                                                        <reference key="NSMenu" ref="1035150210"/>
                                                                        <bool key="NSIsDisabled">YES</bool>
                                                                        <reference key="NSOnImage" ref="447995298"/>
                                                                        <reference key="NSMixedImage" ref="760317610"/>
                                                                </object>
-                                                               <object class="NSMenuItem" id="985983659">
-                                                                       <reference key="NSMenu" ref="1035150210"/>
-                                                                       <string key="NSTitle">Check for updates ...</string>
-                                                                       <string key="NSKeyEquiv"/>
-                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                       <reference key="NSOnImage" ref="447995298"/>
-                                                                       <reference key="NSMixedImage" ref="760317610"/>
-                                                               </object>
                                                                <object class="NSMenuItem" id="802148601">
                                                                        <reference key="NSMenu" ref="1035150210"/>
                                                                        <bool key="NSIsDisabled">YES</bool>
                                                                </object>
                                                                <object class="NSMenuItem" id="360013803">
                                                                        <reference key="NSMenu" ref="1035150210"/>
-                                                                       <string key="NSTitle">Hide Others</string>
-                                                                       <string key="NSKeyEquiv">h</string>
-                                                                       <int key="NSKeyEquivModMask">1572864</int>
+                                                                       <string key="NSTitle">Hide Others</string>
+                                                                       <string key="NSKeyEquiv">h</string>
+                                                                       <int key="NSKeyEquivModMask">1572864</int>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                               </object>
+                                                               <object class="NSMenuItem" id="750596130">
+                                                                       <reference key="NSMenu" ref="1035150210"/>
+                                                                       <string key="NSTitle">Show All</string>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSKeyEquivModMask">1048576</int>
                                                                        <int key="NSMnemonicLoc">2147483647</int>
                                                                        <reference key="NSOnImage" ref="447995298"/>
                                                                        <reference key="NSMixedImage" ref="760317610"/>
                                                                        <reference key="NSOnImage" ref="447995298"/>
                                                                        <reference key="NSMixedImage" ref="760317610"/>
                                                                </object>
+                                                               <object class="NSMenuItem" id="734454745">
+                                                                       <reference key="NSMenu" ref="112579544"/>
+                                                                       <string key="NSTitle">Export ...</string>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                               </object>
+                                                               <object class="NSMenuItem" id="685593004">
+                                                                       <reference key="NSMenu" ref="112579544"/>
+                                                                       <string key="NSTitle">Import ...</string>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                               </object>
                                                                <object class="NSMenuItem" id="454042588">
                                                                        <reference key="NSMenu" ref="112579544"/>
                                                                        <string key="NSTitle">Select Default Preset</string>
                                                                        <reference key="NSOnImage" ref="447995298"/>
                                                                        <reference key="NSMixedImage" ref="760317610"/>
                                                                </object>
+                                                               <object class="NSMenuItem" id="157409278">
+                                                                       <reference key="NSMenu" ref="919178355"/>
+                                                                       <string key="NSTitle">Preview Window</string>
+                                                                       <string key="NSKeyEquiv"/>
+                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                       <reference key="NSOnImage" ref="447995298"/>
+                                                                       <reference key="NSMixedImage" ref="760317610"/>
+                                                               </object>
                                                                <object class="NSMenuItem" id="302989927">
                                                                        <reference key="NSMenu" ref="919178355"/>
                                                                        <string key="NSTitle">Activity Window</string>
                                                                                                <double key="NSMinWidth">4.000000e+01</double>
                                                                                                <double key="NSMaxWidth">1.000000e+03</double>
                                                                                                <object class="NSTableHeaderCell" key="NSHeaderCell">
-                                                                                                       <int key="NSCellFlags">75628032</int>
-                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <int key="NSCellFlags">75628096</int>
+                                                                                                       <int key="NSCellFlags2">2048</int>
                                                                                                        <string key="NSContents">Presets</string>
                                                                                                        <reference key="NSSupport" ref="26"/>
                                                                                                        <object class="NSColor" key="NSBackgroundColor">
                                                        </object>
                                                        <object class="NSScroller" id="573337548">
                                                                <reference key="NSNextResponder" ref="33643505"/>
-                                                               <int key="NSvFlags">256</int>
+                                                               <int key="NSvFlags">-2147483392</int>
                                                                <string key="NSFrame">{{-100, -100}, {183, 15}}</string>
                                                                <reference key="NSSuperview" ref="33643505"/>
                                                                <int key="NSsFlags">1</int>
                                        <int key="connectionID">139</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">orderFrontStandardAboutPanel:</string>
-                                               <reference key="source" ref="1046316778"/>
-                                               <reference key="destination" ref="218095211"/>
-                                       </object>
-                                       <int key="connectionID">142</int>
-                               </object>
-                               <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">delegate</string>
                                                <reference key="source" ref="1046316778"/>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fVidGrayscaleCheck</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="586924601"/>
-                                       </object>
-                                       <int key="connectionID">1603</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
                                                <string key="label">fVidQualityField</string>
                                                <reference key="source" ref="2258723"/>
                                                <reference key="destination" ref="521019277"/>
                                        <int key="connectionID">1620</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fSubPopUp</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="506492318"/>
-                                       </object>
-                                       <int key="connectionID">1637</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">showPicturePanel:</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="37121296"/>
-                                       </object>
-                                       <int key="connectionID">1735</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelSrc</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="373965512"/>
-                                       </object>
-                                       <int key="connectionID">1743</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelSettings</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="219409733"/>
-                                       </object>
-                                       <int key="connectionID">1744</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelOutp</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="917474208"/>
-                                       </object>
-                                       <int key="connectionID">1745</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelAr</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="946417297"/>
-                                       </object>
-                                       <int key="connectionID">1748</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPictureButton</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="37121296"/>
-                                       </object>
-                                       <int key="connectionID">1750</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fSubField</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="436388527"/>
-                                       </object>
-                                       <int key="connectionID">1758</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelAnamorphic</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="710962186"/>
-                                       </object>
-                                       <int key="connectionID">1783</int>
-                               </object>
-                               <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">performFindPanelAction:</string>
                                                <reference key="source" ref="952684036"/>
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">customSettingUsed:</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="586924601"/>
-                                       </object>
-                                       <int key="connectionID">1912</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">customSettingUsed:</string>
-                                               <reference key="source" ref="2258723"/>
                                                <reference key="destination" ref="135824882"/>
                                        </object>
                                        <int key="connectionID">1914</int>
                                        <int key="connectionID">2448</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingDetelecine</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="585235372"/>
-                                       </object>
-                                       <int key="connectionID">2459</int>
-                               </object>
-                               <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">videoFrameRateChanged:</string>
                                                <reference key="source" ref="2258723"/>
                                        <int key="connectionID">2496</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fSubForcedCheck</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="691038230"/>
-                                       </object>
-                                       <int key="connectionID">2505</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">subtitleSelectionChanged:</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="506492318"/>
-                                       </object>
-                                       <int key="connectionID">2506</int>
-                               </object>
-                               <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">performClose:</string>
                                                <reference key="source" ref="952684036"/>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelDetelecine</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="43900501"/>
-                                       </object>
-                                       <int key="connectionID">2520</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelAutoCrop</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="690364175"/>
-                                       </object>
-                                       <int key="connectionID">2521</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelDenoise</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="1060179806"/>
-                                       </object>
-                                       <int key="connectionID">2522</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelDeinterlace</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="999897202"/>
-                                       </object>
-                                       <int key="connectionID">2523</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingDeinterlace</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="1068503811"/>
-                                       </object>
-                                       <int key="connectionID">2524</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingARkeep</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="982947780"/>
-                                       </object>
-                                       <int key="connectionID">2526</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingAutoCrop</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="820525517"/>
-                                       </object>
-                                       <int key="connectionID">2527</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingDenoise</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="1072509220"/>
-                                       </object>
-                                       <int key="connectionID">2529</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingPAR</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="145957234"/>
-                                       </object>
-                                       <int key="connectionID">2531</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
                                                <string key="label">fPresetNewDesc</string>
                                                <reference key="source" ref="2258723"/>
                                                <reference key="destination" ref="511645357"/>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelDeblock</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="458722452"/>
-                                       </object>
-                                       <int key="connectionID">2696</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingDeblock</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="511739402"/>
-                                       </object>
-                                       <int key="connectionID">2697</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
                                                <string key="label">fOpenSourceTitleMMenu</string>
                                                <reference key="source" ref="2258723"/>
                                                <reference key="destination" ref="865776798"/>
                                        <int key="connectionID">4581</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingsSrc</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="1017614971"/>
-                                       </object>
-                                       <int key="connectionID">4842</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingsOutp</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="580175226"/>
-                                       </object>
-                                       <int key="connectionID">4843</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingsAnamorphic</string>
-                                               <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="149133624"/>
-                                       </object>
-                                       <int key="connectionID">4844</int>
-                               </object>
-                               <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">checkForUpdates:</string>
                                                <reference key="source" ref="159095366"/>
                                        <int key="connectionID">5121</int>
                                </object>
                                <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">setDefaultPreset:</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="950937431"/>
+                                       </object>
+                                       <int key="connectionID">5138</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">addFactoryPresets:</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="583192244"/>
+                                       </object>
+                                       <int key="connectionID">5139</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">autoSetM4vExtension:</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="719511430"/>
+                                       </object>
+                                       <int key="connectionID">5152</int>
+                               </object>
+                               <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicSettingDecomb</string>
+                                               <string key="label">fPresetNewFolderCheck</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="946167393"/>
+                                               <reference key="destination" ref="786415813"/>
                                        </object>
-                                       <int key="connectionID">5126</int>
+                                       <int key="connectionID">5155</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPicLabelDecomb</string>
+                                               <string key="label">fVidEncoderField</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="554762309"/>
+                                               <reference key="destination" ref="1064150725"/>
                                        </object>
-                                       <int key="connectionID">5127</int>
+                                       <int key="connectionID">5156</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">setDefaultPreset:</string>
+                                               <string key="label">showPreviewWindow:</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="950937431"/>
+                                               <reference key="destination" ref="157409278"/>
                                        </object>
-                                       <int key="connectionID">5138</int>
+                                       <int key="connectionID">5158</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureSizeField</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="987137669"/>
+                                       </object>
+                                       <int key="connectionID">5169</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureCroppingField</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="690364175"/>
+                                       </object>
+                                       <int key="connectionID">5170</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fVideoFiltersField</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="503933842"/>
+                                       </object>
+                                       <int key="connectionID">5173</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fVidQualityRFField</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="690304958"/>
+                                       </object>
+                                       <int key="connectionID">5176</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fVidQualityRFLabel</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="323705695"/>
+                                       </object>
+                                       <int key="connectionID">5179</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fSrcAngleLabel</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="303369850"/>
+                                       </object>
+                                       <int key="connectionID">5186</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fSrcAnglePopUp</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="460320725"/>
+                                       </object>
+                                       <int key="connectionID">5187</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">addFactoryPresets:</string>
+                                               <string key="label">browseExportPresetFile:</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="583192244"/>
+                                               <reference key="destination" ref="734454745"/>
+                                       </object>
+                                       <int key="connectionID">5191</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">browseImportPresetFile:</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="685593004"/>
+                                       </object>
+                                       <int key="connectionID">5193</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fSubtitlesTable</string>
+                                               <reference key="source" ref="2258723"/>
+                                               <reference key="destination" ref="587237088"/>
                                        </object>
-                                       <int key="connectionID">5139</int>
+                                       <int key="connectionID">5214</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">autoSetM4vExtension:</string>
+                                               <string key="label">showAboutPanel:</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="719511430"/>
+                                               <reference key="destination" ref="218095211"/>
                                        </object>
-                                       <int key="connectionID">5152</int>
+                                       <int key="connectionID">5245</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPresetNewFolderCheck</string>
+                                               <string key="label">fBrowseSrtFileButton</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="786415813"/>
+                                               <reference key="destination" ref="377401502"/>
                                        </object>
-                                       <int key="connectionID">5155</int>
+                                       <int key="connectionID">5248</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fVidEncoderField</string>
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">browseImportSrtFile:</string>
                                                <reference key="source" ref="2258723"/>
-                                               <reference key="destination" ref="1064150725"/>
+                                               <reference key="destination" ref="377401502"/>
                                        </object>
-                                       <int key="connectionID">5156</int>
+                                       <int key="connectionID">5249</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">unhideAllApplications:</string>
+                                               <reference key="source" ref="952684036"/>
+                                               <reference key="destination" ref="750596130"/>
+                                       </object>
+                                       <int key="connectionID">5281</int>
                                </object>
                        </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">0</int>
-                                               <object class="NSArray" key="object" id="836211765">
+                                               <object class="NSArray" key="object" id="3896795">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                </object>
                                                <reference key="children" ref="411085004"/>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-2</int>
                                                <reference key="object" ref="1046316778"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-1</int>
                                                <reference key="object" ref="952684036"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">First Responder</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-3</int>
                                                <reference key="object" ref="300550588"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">Application</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="168918359"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">MainWindow</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <reference ref="581806074"/>
                                                        <reference ref="553453876"/>
                                                        <reference ref="921877174"/>
+                                                       <reference ref="303369850"/>
+                                                       <reference ref="460320725"/>
                                                </object>
                                                <reference key="parent" ref="192660081"/>
                                        </object>
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="157300012"/>
                                                        <reference ref="107038816"/>
-                                                       <reference ref="291470012"/>
                                                        <reference ref="744678564"/>
+                                                       <reference ref="799016137"/>
+                                                       <reference ref="291470012"/>
                                                </object>
                                                <reference key="parent" ref="168918359"/>
                                        </object>
                                                        <reference ref="290434291"/>
                                                        <reference ref="122023676"/>
                                                        <reference ref="351922892"/>
-                                                       <reference ref="506492318"/>
-                                                       <reference ref="436388527"/>
                                                        <reference ref="64899409"/>
                                                        <reference ref="354208181"/>
                                                        <reference ref="211624488"/>
                                                        <reference ref="68754422"/>
-                                                       <reference ref="691038230"/>
                                                        <reference ref="978534247"/>
                                                        <reference ref="460286942"/>
-                                                       <reference ref="124979328"/>
-                                                       <reference ref="844196518"/>
                                                        <reference ref="135824882"/>
                                                        <reference ref="592255786"/>
                                                        <reference ref="466865421"/>
                                                <reference key="parent" ref="738554558"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">1634</int>
-                                               <reference key="object" ref="506492318"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="636153290"/>
-                                               </object>
-                                               <reference key="parent" ref="738554558"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1638</int>
-                                               <reference key="object" ref="436388527"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="95314231"/>
-                                               </object>
-                                               <reference key="parent" ref="738554558"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">1962</int>
                                                <reference key="object" ref="64899409"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="parent" ref="738554558"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">2504</int>
-                                               <reference key="object" ref="691038230"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="944590907"/>
-                                               </object>
-                                               <reference key="parent" ref="738554558"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">3075</int>
                                                <reference key="object" ref="978534247"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="parent" ref="738554558"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">3081</int>
-                                               <reference key="object" ref="124979328"/>
-                                               <reference key="parent" ref="738554558"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">3082</int>
-                                               <reference key="object" ref="844196518"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="653177228"/>
-                                               </object>
-                                               <reference key="parent" ref="738554558"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">1477</int>
                                                <reference key="object" ref="107038816"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="object" ref="1053078401"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="521019277"/>
-                                                       <reference ref="229000833"/>
-                                                       <reference ref="127917338"/>
-                                                       <reference ref="783405221"/>
-                                                       <reference ref="239657287"/>
                                                        <reference ref="222980245"/>
                                                        <reference ref="1000247853"/>
                                                        <reference ref="447003158"/>
                                                        <reference ref="12330413"/>
-                                                       <reference ref="586924601"/>
                                                        <reference ref="463960465"/>
                                                        <reference ref="1064150725"/>
-                                                       <reference ref="373965512"/>
-                                                       <reference ref="917474208"/>
-                                                       <reference ref="946417297"/>
-                                                       <reference ref="982947780"/>
-                                                       <reference ref="839994488"/>
-                                                       <reference ref="710962186"/>
-                                                       <reference ref="145957234"/>
+                                                       <reference ref="987137669"/>
                                                        <reference ref="690364175"/>
-                                                       <reference ref="820525517"/>
-                                                       <reference ref="585235372"/>
-                                                       <reference ref="1068503811"/>
-                                                       <reference ref="1060179806"/>
-                                                       <reference ref="511739402"/>
-                                                       <reference ref="458722452"/>
-                                                       <reference ref="1072509220"/>
-                                                       <reference ref="43900501"/>
-                                                       <reference ref="999897202"/>
-                                                       <reference ref="1017614971"/>
-                                                       <reference ref="580175226"/>
-                                                       <reference ref="149133624"/>
-                                                       <reference ref="946167393"/>
-                                                       <reference ref="554762309"/>
-                                                       <reference ref="219409733"/>
-                                                       <reference ref="37121296"/>
+                                                       <reference ref="503933842"/>
+                                                       <reference ref="521019277"/>
+                                                       <reference ref="229000833"/>
+                                                       <reference ref="127917338"/>
+                                                       <reference ref="783405221"/>
+                                                       <reference ref="239657287"/>
+                                                       <reference ref="690304958"/>
+                                                       <reference ref="323705695"/>
                                                </object>
                                                <reference key="parent" ref="107038816"/>
                                        </object>
                                                <reference key="parent" ref="1053078401"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">1516</int>
-                                               <reference key="object" ref="586924601"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="531797832"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1713</int>
-                                               <reference key="object" ref="37121296"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="969536223"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1714</int>
-                                               <reference key="object" ref="219409733"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="215270136"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1717</int>
-                                               <reference key="object" ref="373965512"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="656776160"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1723</int>
-                                               <reference key="object" ref="917474208"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1021257184"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1729</int>
-                                               <reference key="object" ref="946417297"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="531090746"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1731</int>
-                                               <reference key="object" ref="999897202"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="749563917"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1739</int>
-                                               <reference key="object" ref="982947780"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="86719269"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1740</int>
-                                               <reference key="object" ref="1068503811"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="626403977"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1753</int>
-                                               <reference key="object" ref="839994488"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <object class="NSView" id="859460623">
-                                                               <nil key="NSNextResponder"/>
-                                                               <int key="NSvFlags">256</int>
-                                                               <string key="NSFrame">{{2, 2}, {125, 1}}</string>
-                                                               <reference key="NSNextKeyView" ref="946417297"/>
-                                                       </object>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1754</int>
-                                               <reference key="object" ref="859460623"/>
-                                               <reference key="parent" ref="839994488"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1772</int>
-                                               <reference key="object" ref="710962186"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="26279285"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1773</int>
-                                               <reference key="object" ref="145957234"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="497251062"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">2361</int>
                                                <reference key="object" ref="447003158"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="parent" ref="1053078401"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">2377</int>
-                                               <reference key="object" ref="820525517"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="76686465"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2451</int>
-                                               <reference key="object" ref="43900501"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1005519170"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2452</int>
-                                               <reference key="object" ref="585235372"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="782049171"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2472</int>
-                                               <reference key="object" ref="1060179806"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="344072439"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2473</int>
-                                               <reference key="object" ref="1072509220"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="965262561"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2694</int>
-                                               <reference key="object" ref="511739402"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="315802325"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">2695</int>
-                                               <reference key="object" ref="458722452"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="133553303"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4836</int>
-                                               <reference key="object" ref="1017614971"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="370959642"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4838</int>
-                                               <reference key="object" ref="580175226"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="82054988"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4840</int>
-                                               <reference key="object" ref="149133624"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="334116173"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">1989</int>
                                                <reference key="object" ref="291470012"/>
                                                <object class="NSMutableArray" key="children">
                                                        <reference ref="692187614"/>
                                                        <reference ref="226787934"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">MainMenu</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <reference ref="782330144"/>
                                                        <reference ref="802148601"/>
                                                        <reference ref="985983659"/>
+                                                       <reference ref="750596130"/>
                                                </object>
                                                <reference key="parent" ref="116324948"/>
                                        </object>
                                                        <reference ref="87484946"/>
                                                        <reference ref="849279674"/>
                                                        <reference ref="1034427275"/>
+                                                       <reference ref="157409278"/>
                                                </object>
                                                <reference key="parent" ref="610133626"/>
                                        </object>
                                                        <reference ref="644928468"/>
                                                        <reference ref="180231"/>
                                                        <reference ref="454042588"/>
+                                                       <reference ref="734454745"/>
+                                                       <reference ref="685593004"/>
                                                </object>
                                                <reference key="parent" ref="226787934"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">240</int>
                                                <reference key="object" ref="2258723"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">HBController</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="168254512"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">DonePanel</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                        <object class="IBObjectRecord">
                                                <int key="objectID">1841</int>
                                                <reference key="object" ref="972647787"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">PresetsDrawer</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <reference ref="699919504"/>
                                                        <reference ref="886184281"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">PresetsView</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="69290042"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">AddPresetPanel</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="867624722"/>
                                                </object>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                                <string key="objectName">SourceTitlePanel</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <reference key="parent" ref="592255786"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">4855</int>
-                                               <reference key="object" ref="636153290"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="121028261"/>
-                                               </object>
-                                               <reference key="parent" ref="506492318"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4856</int>
-                                               <reference key="object" ref="95314231"/>
-                                               <reference key="parent" ref="436388527"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">4857</int>
                                                <reference key="object" ref="581778322"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="parent" ref="68754422"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">4861</int>
-                                               <reference key="object" ref="944590907"/>
-                                               <reference key="parent" ref="691038230"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">4862</int>
                                                <reference key="object" ref="211433572"/>
                                                <reference key="parent" ref="978534247"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">4864</int>
-                                               <reference key="object" ref="653177228"/>
-                                               <reference key="parent" ref="844196518"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">4872</int>
                                                <reference key="object" ref="200565868"/>
                                                <reference key="parent" ref="521019277"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">4880</int>
-                                               <reference key="object" ref="451922400"/>
-                                               <reference key="parent" ref="1064150725"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4881</int>
-                                               <reference key="object" ref="531797832"/>
-                                               <reference key="parent" ref="586924601"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4882</int>
-                                               <reference key="object" ref="969536223"/>
-                                               <reference key="parent" ref="37121296"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4883</int>
-                                               <reference key="object" ref="215270136"/>
-                                               <reference key="parent" ref="219409733"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4884</int>
-                                               <reference key="object" ref="656776160"/>
-                                               <reference key="parent" ref="373965512"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4885</int>
-                                               <reference key="object" ref="1021257184"/>
-                                               <reference key="parent" ref="917474208"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4886</int>
-                                               <reference key="object" ref="531090746"/>
-                                               <reference key="parent" ref="946417297"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4887</int>
-                                               <reference key="object" ref="749563917"/>
-                                               <reference key="parent" ref="999897202"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4888</int>
-                                               <reference key="object" ref="86719269"/>
-                                               <reference key="parent" ref="982947780"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4889</int>
-                                               <reference key="object" ref="626403977"/>
-                                               <reference key="parent" ref="1068503811"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4890</int>
-                                               <reference key="object" ref="26279285"/>
-                                               <reference key="parent" ref="710962186"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4891</int>
-                                               <reference key="object" ref="497251062"/>
-                                               <reference key="parent" ref="145957234"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4892</int>
-                                               <reference key="object" ref="1070893195"/>
-                                               <reference key="parent" ref="447003158"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4893</int>
-                                               <reference key="object" ref="508148739"/>
-                                               <reference key="parent" ref="690364175"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4894</int>
-                                               <reference key="object" ref="76686465"/>
-                                               <reference key="parent" ref="820525517"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4895</int>
-                                               <reference key="object" ref="1005519170"/>
-                                               <reference key="parent" ref="43900501"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4896</int>
-                                               <reference key="object" ref="782049171"/>
-                                               <reference key="parent" ref="585235372"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4897</int>
-                                               <reference key="object" ref="344072439"/>
-                                               <reference key="parent" ref="1060179806"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4898</int>
-                                               <reference key="object" ref="965262561"/>
-                                               <reference key="parent" ref="1072509220"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4899</int>
-                                               <reference key="object" ref="315802325"/>
-                                               <reference key="parent" ref="511739402"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4900</int>
-                                               <reference key="object" ref="133553303"/>
-                                               <reference key="parent" ref="458722452"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">4901</int>
-                                               <reference key="object" ref="370959642"/>
-                                               <reference key="parent" ref="1017614971"/>
+                                               <reference key="object" ref="451922400"/>
+                                               <reference key="parent" ref="1064150725"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">4902</int>
-                                               <reference key="object" ref="82054988"/>
-                                               <reference key="parent" ref="580175226"/>
+                                               <int key="objectID">4892</int>
+                                               <reference key="object" ref="1070893195"/>
+                                               <reference key="parent" ref="447003158"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">4903</int>
-                                               <reference key="object" ref="334116173"/>
-                                               <reference key="parent" ref="149133624"/>
+                                               <int key="objectID">4893</int>
+                                               <reference key="object" ref="508148739"/>
+                                               <reference key="parent" ref="690364175"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">4904</int>
                                                <reference key="parent" ref="80517384"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">1635</int>
-                                               <reference key="object" ref="121028261"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="432645698"/>
-                                               </object>
-                                               <reference key="parent" ref="636153290"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">1636</int>
-                                               <reference key="object" ref="432645698"/>
-                                               <reference key="parent" ref="121028261"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">1963</int>
                                                <reference key="object" ref="142584693"/>
                                                <object class="NSMutableArray" key="children">
                                        <object class="IBObjectRecord">
                                                <int key="objectID">4963</int>
                                                <reference key="object" ref="159095366"/>
-                                               <reference key="parent" ref="836211765"/>
+                                               <reference key="parent" ref="3896795"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">4964</int>
                                                <reference key="parent" ref="758473796"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">5122</int>
-                                               <reference key="object" ref="946167393"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="152262221"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">5123</int>
-                                               <reference key="object" ref="152262221"/>
-                                               <reference key="parent" ref="946167393"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">5124</int>
-                                               <reference key="object" ref="554762309"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="2157"/>
-                                               </object>
-                                               <reference key="parent" ref="1053078401"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">5125</int>
-                                               <reference key="object" ref="2157"/>
-                                               <reference key="parent" ref="554762309"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">5130</int>
                                                <reference key="object" ref="886184281"/>
                                                <object class="NSMutableArray" key="children">
                                                <reference key="object" ref="977106207"/>
                                                <reference key="parent" ref="786415813"/>
                                        </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5157</int>
+                                               <reference key="object" ref="157409278"/>
+                                               <reference key="parent" ref="919178355"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5167</int>
+                                               <reference key="object" ref="987137669"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="537000521"/>
+                                               </object>
+                                               <reference key="parent" ref="1053078401"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5168</int>
+                                               <reference key="object" ref="537000521"/>
+                                               <reference key="parent" ref="987137669"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5171</int>
+                                               <reference key="object" ref="503933842"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="109092334"/>
+                                               </object>
+                                               <reference key="parent" ref="1053078401"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5172</int>
+                                               <reference key="object" ref="109092334"/>
+                                               <reference key="parent" ref="503933842"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5174</int>
+                                               <reference key="object" ref="690304958"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="923732752"/>
+                                               </object>
+                                               <reference key="parent" ref="1053078401"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5175</int>
+                                               <reference key="object" ref="923732752"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="580574518"/>
+                                               </object>
+                                               <reference key="parent" ref="690304958"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5177</int>
+                                               <reference key="object" ref="323705695"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="936221726"/>
+                                               </object>
+                                               <reference key="parent" ref="1053078401"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5178</int>
+                                               <reference key="object" ref="936221726"/>
+                                               <reference key="parent" ref="323705695"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5180</int>
+                                               <reference key="object" ref="303369850"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="677126774"/>
+                                               </object>
+                                               <reference key="parent" ref="168918359"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5181</int>
+                                               <reference key="object" ref="460320725"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="567459641"/>
+                                               </object>
+                                               <reference key="parent" ref="168918359"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5182</int>
+                                               <reference key="object" ref="567459641"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="651682595"/>
+                                               </object>
+                                               <reference key="parent" ref="460320725"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5183</int>
+                                               <reference key="object" ref="651682595"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="62890346"/>
+                                               </object>
+                                               <reference key="parent" ref="567459641"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5184</int>
+                                               <reference key="object" ref="62890346"/>
+                                               <reference key="parent" ref="651682595"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5185</int>
+                                               <reference key="object" ref="677126774"/>
+                                               <reference key="parent" ref="303369850"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5188</int>
+                                               <reference key="object" ref="734454745"/>
+                                               <reference key="parent" ref="112579544"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5192</int>
+                                               <reference key="object" ref="685593004"/>
+                                               <reference key="parent" ref="112579544"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5194</int>
+                                               <reference key="object" ref="799016137"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="756255803"/>
+                                               </object>
+                                               <reference key="parent" ref="712502892"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5195</int>
+                                               <reference key="object" ref="756255803"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="596256174"/>
+                                                       <reference ref="377401502"/>
+                                               </object>
+                                               <reference key="parent" ref="799016137"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5196</int>
+                                               <reference key="object" ref="596256174"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="40751315"/>
+                                                       <reference ref="892147391"/>
+                                                       <reference ref="587237088"/>
+                                                       <reference ref="569585004"/>
+                                               </object>
+                                               <reference key="parent" ref="756255803"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5197</int>
+                                               <reference key="object" ref="40751315"/>
+                                               <reference key="parent" ref="596256174"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5198</int>
+                                               <reference key="object" ref="892147391"/>
+                                               <reference key="parent" ref="596256174"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5199</int>
+                                               <reference key="object" ref="587237088"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="274341565"/>
+                                                       <reference ref="1033748386"/>
+                                                       <reference ref="362209136"/>
+                                                       <reference ref="270619684"/>
+                                                       <reference ref="116912874"/>
+                                                       <reference ref="180322215"/>
+                                                       <reference ref="526590234"/>
+                                               </object>
+                                               <reference key="parent" ref="596256174"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5201</int>
+                                               <reference key="object" ref="274341565"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="426946554"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5215</int>
+                                               <reference key="object" ref="1033748386"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="13236417"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5217</int>
+                                               <reference key="object" ref="362209136"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="704907857"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5219</int>
+                                               <reference key="object" ref="270619684"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="299034685"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5225</int>
+                                               <reference key="object" ref="426946554"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="472498711"/>
+                                               </object>
+                                               <reference key="parent" ref="274341565"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5226</int>
+                                               <reference key="object" ref="472498711"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1026748451"/>
+                                               </object>
+                                               <reference key="parent" ref="426946554"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5227</int>
+                                               <reference key="object" ref="1026748451"/>
+                                               <reference key="parent" ref="472498711"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5232</int>
+                                               <reference key="object" ref="13236417"/>
+                                               <reference key="parent" ref="1033748386"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5233</int>
+                                               <reference key="object" ref="704907857"/>
+                                               <reference key="parent" ref="362209136"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5234</int>
+                                               <reference key="object" ref="299034685"/>
+                                               <reference key="parent" ref="270619684"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5244</int>
+                                               <reference key="object" ref="569585004"/>
+                                               <reference key="parent" ref="596256174"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5246</int>
+                                               <reference key="object" ref="377401502"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="206924163"/>
+                                               </object>
+                                               <reference key="parent" ref="756255803"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5247</int>
+                                               <reference key="object" ref="206924163"/>
+                                               <reference key="parent" ref="377401502"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5250</int>
+                                               <reference key="object" ref="116912874"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="688461412"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5252</int>
+                                               <reference key="object" ref="180322215"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="483232645"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5254</int>
+                                               <reference key="object" ref="526590234"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="43785715"/>
+                                               </object>
+                                               <reference key="parent" ref="587237088"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5268</int>
+                                               <reference key="object" ref="688461412"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="808277525"/>
+                                               </object>
+                                               <reference key="parent" ref="116912874"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5269</int>
+                                               <reference key="object" ref="808277525"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="341659302"/>
+                                               </object>
+                                               <reference key="parent" ref="688461412"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5270</int>
+                                               <reference key="object" ref="341659302"/>
+                                               <reference key="parent" ref="808277525"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5271</int>
+                                               <reference key="object" ref="483232645"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="427130300"/>
+                                               </object>
+                                               <reference key="parent" ref="180322215"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5272</int>
+                                               <reference key="object" ref="427130300"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="66454705"/>
+                                               </object>
+                                               <reference key="parent" ref="483232645"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5273</int>
+                                               <reference key="object" ref="66454705"/>
+                                               <reference key="parent" ref="427130300"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5278</int>
+                                               <reference key="object" ref="43785715"/>
+                                               <reference key="parent" ref="526590234"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5279</int>
+                                               <reference key="object" ref="580574518"/>
+                                               <reference key="parent" ref="923732752"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5280</int>
+                                               <reference key="object" ref="750596130"/>
+                                               <reference key="parent" ref="1035150210"/>
+                                       </object>
                                </object>
                        </object>
                        <object class="NSMutableDictionary" key="flattenedProperties">
                                        <string>1190.ImportedFromIB2</string>
                                        <string>1191.IBPluginDependency</string>
                                        <string>1191.ImportedFromIB2</string>
+                                       <string>1192.IBEditorWindowLastContentRect</string>
                                        <string>1192.IBPluginDependency</string>
                                        <string>1192.ImportedFromIB2</string>
                                        <string>1193.IBPluginDependency</string>
                                        <string>1198.ImportedFromIB2</string>
                                        <string>1200.IBPluginDependency</string>
                                        <string>1200.ImportedFromIB2</string>
+                                       <string>1209.IBEditorWindowLastContentRect</string>
                                        <string>1209.IBPluginDependency</string>
                                        <string>1209.ImportedFromIB2</string>
                                        <string>136.IBPluginDependency</string>
                                        <string>1514.ImportedFromIB2</string>
                                        <string>1515.IBPluginDependency</string>
                                        <string>1515.ImportedFromIB2</string>
-                                       <string>1516.IBPluginDependency</string>
-                                       <string>1516.ImportedFromIB2</string>
                                        <string>1518.IBPluginDependency</string>
                                        <string>1518.ImportedFromIB2</string>
                                        <string>1519.IBPluginDependency</string>
                                        <string>1628.ImportedFromIB2</string>
                                        <string>1629.IBPluginDependency</string>
                                        <string>1629.ImportedFromIB2</string>
-                                       <string>1634.IBPluginDependency</string>
-                                       <string>1634.ImportedFromIB2</string>
-                                       <string>1635.IBPluginDependency</string>
-                                       <string>1635.ImportedFromIB2</string>
-                                       <string>1636.IBPluginDependency</string>
-                                       <string>1636.ImportedFromIB2</string>
-                                       <string>1638.IBPluginDependency</string>
-                                       <string>1638.ImportedFromIB2</string>
-                                       <string>1713.IBPluginDependency</string>
-                                       <string>1713.ImportedFromIB2</string>
-                                       <string>1714.IBPluginDependency</string>
-                                       <string>1714.ImportedFromIB2</string>
-                                       <string>1717.IBPluginDependency</string>
-                                       <string>1717.ImportedFromIB2</string>
-                                       <string>1723.IBPluginDependency</string>
-                                       <string>1723.ImportedFromIB2</string>
-                                       <string>1729.IBPluginDependency</string>
-                                       <string>1729.ImportedFromIB2</string>
-                                       <string>1731.IBPluginDependency</string>
-                                       <string>1731.ImportedFromIB2</string>
-                                       <string>1739.IBPluginDependency</string>
-                                       <string>1739.ImportedFromIB2</string>
-                                       <string>1740.IBPluginDependency</string>
-                                       <string>1740.ImportedFromIB2</string>
-                                       <string>1753.IBPluginDependency</string>
-                                       <string>1753.ImportedFromIB2</string>
-                                       <string>1754.IBPluginDependency</string>
-                                       <string>1754.ImportedFromIB2</string>
-                                       <string>1772.IBPluginDependency</string>
-                                       <string>1772.ImportedFromIB2</string>
-                                       <string>1773.IBPluginDependency</string>
-                                       <string>1773.ImportedFromIB2</string>
                                        <string>1795.IBPluginDependency</string>
                                        <string>1795.ImportedFromIB2</string>
+                                       <string>1796.IBEditorWindowLastContentRect</string>
                                        <string>1796.IBPluginDependency</string>
                                        <string>1796.ImportedFromIB2</string>
                                        <string>1797.IBPluginDependency</string>
                                        <string>1843.ImportedFromIB2</string>
                                        <string>1843.editorWindowContentRectSynchronizationRect</string>
                                        <string>1867.IBEditorWindowLastContentRect</string>
-                                       <string>1867.IBPluginDependency</string>
                                        <string>1867.IBWindowTemplateEditedContentRect</string>
                                        <string>1867.ImportedFromIB2</string>
                                        <string>1867.editorWindowContentRectSynchronizationRect</string>
                                        <string>1900.ImportedFromIB2</string>
                                        <string>1948.IBPluginDependency</string>
                                        <string>1948.ImportedFromIB2</string>
+                                       <string>1949.IBEditorWindowLastContentRect</string>
                                        <string>1949.IBPluginDependency</string>
                                        <string>1949.ImportedFromIB2</string>
                                        <string>1950.IBPluginDependency</string>
                                        <string>2016.IBPluginDependency</string>
                                        <string>2016.ImportedFromIB2</string>
                                        <string>21.IBEditorWindowLastContentRect</string>
-                                       <string>21.IBPluginDependency</string>
                                        <string>21.IBViewEditorWindowController.showingLayoutRectangles</string>
                                        <string>21.IBWindowTemplateEditedContentRect</string>
                                        <string>21.ImportedFromIB2</string>
                                        <string>2368.ImportedFromIB2</string>
                                        <string>2375.IBPluginDependency</string>
                                        <string>2375.ImportedFromIB2</string>
-                                       <string>2377.IBPluginDependency</string>
-                                       <string>2377.ImportedFromIB2</string>
                                        <string>240.IBPluginDependency</string>
                                        <string>240.ImportedFromIB2</string>
                                        <string>2421.IBPluginDependency</string>
                                        <string>2444.ImportedFromIB2</string>
                                        <string>2445.IBPluginDependency</string>
                                        <string>2445.ImportedFromIB2</string>
-                                       <string>2451.IBPluginDependency</string>
-                                       <string>2451.ImportedFromIB2</string>
-                                       <string>2452.IBPluginDependency</string>
-                                       <string>2452.ImportedFromIB2</string>
-                                       <string>2472.IBPluginDependency</string>
-                                       <string>2472.ImportedFromIB2</string>
-                                       <string>2473.IBPluginDependency</string>
-                                       <string>2473.ImportedFromIB2</string>
                                        <string>2488.IBPluginDependency</string>
                                        <string>2488.ImportedFromIB2</string>
                                        <string>2494.IBPluginDependency</string>
                                        <string>2494.ImportedFromIB2</string>
-                                       <string>2504.IBPluginDependency</string>
-                                       <string>2504.ImportedFromIB2</string>
                                        <string>2507.IBPluginDependency</string>
                                        <string>2507.ImportedFromIB2</string>
                                        <string>2508.IBPluginDependency</string>
                                        <string>2672.ImportedFromIB2</string>
                                        <string>2673.IBPluginDependency</string>
                                        <string>2673.ImportedFromIB2</string>
-                                       <string>2694.IBPluginDependency</string>
-                                       <string>2694.ImportedFromIB2</string>
-                                       <string>2695.IBPluginDependency</string>
-                                       <string>2695.ImportedFromIB2</string>
                                        <string>2698.IBPluginDependency</string>
                                        <string>2698.ImportedFromIB2</string>
                                        <string>2701.IBEditorWindowLastContentRect</string>
-                                       <string>2701.IBPluginDependency</string>
                                        <string>2701.IBWindowTemplateEditedContentRect</string>
                                        <string>2701.ImportedFromIB2</string>
                                        <string>2701.editorWindowContentRectSynchronizationRect</string>
                                        <string>2839.ImportedFromIB2</string>
                                        <string>2840.IBPluginDependency</string>
                                        <string>2840.ImportedFromIB2</string>
+                                       <string>29.IBEditorWindowLastContentRect</string>
                                        <string>29.IBPluginDependency</string>
                                        <string>29.ImportedFromIB2</string>
                                        <string>29.editorWindowContentRectSynchronizationRect</string>
                                        <string>3075.ImportedFromIB2</string>
                                        <string>3077.IBPluginDependency</string>
                                        <string>3077.ImportedFromIB2</string>
-                                       <string>3081.IBPluginDependency</string>
-                                       <string>3081.ImportedFromIB2</string>
-                                       <string>3082.IBPluginDependency</string>
-                                       <string>3082.ImportedFromIB2</string>
                                        <string>3203.IBPluginDependency</string>
                                        <string>3203.ImportedFromIB2</string>
                                        <string>3205.IBPluginDependency</string>
                                        <string>4317.ImportedFromIB2</string>
                                        <string>4322.IBPluginDependency</string>
                                        <string>4322.ImportedFromIB2</string>
-                                       <string>434.IBPluginDependency</string>
                                        <string>434.IBWindowTemplateEditedContentRect</string>
                                        <string>434.ImportedFromIB2</string>
                                        <string>434.editorWindowContentRectSynchronizationRect</string>
                                        <string>4579.IBAttributePlaceholdersKey</string>
                                        <string>4579.IBPluginDependency</string>
                                        <string>4579.ImportedFromIB2</string>
-                                       <string>4836.IBPluginDependency</string>
-                                       <string>4836.ImportedFromIB2</string>
-                                       <string>4838.IBPluginDependency</string>
-                                       <string>4838.ImportedFromIB2</string>
-                                       <string>4840.IBPluginDependency</string>
-                                       <string>4840.ImportedFromIB2</string>
+                                       <string>4846.IBPluginDependency</string>
+                                       <string>4847.IBPluginDependency</string>
+                                       <string>4848.IBPluginDependency</string>
+                                       <string>4849.IBPluginDependency</string>
+                                       <string>4850.IBPluginDependency</string>
+                                       <string>4851.IBPluginDependency</string>
+                                       <string>4852.IBPluginDependency</string>
+                                       <string>4853.IBPluginDependency</string>
+                                       <string>4854.IBPluginDependency</string>
+                                       <string>4857.IBPluginDependency</string>
+                                       <string>4858.IBPluginDependency</string>
+                                       <string>4859.IBPluginDependency</string>
+                                       <string>4860.IBPluginDependency</string>
+                                       <string>4862.IBPluginDependency</string>
+                                       <string>4872.IBPluginDependency</string>
+                                       <string>4873.IBPluginDependency</string>
+                                       <string>4874.IBPluginDependency</string>
+                                       <string>4875.IBPluginDependency</string>
+                                       <string>4876.IBPluginDependency</string>
+                                       <string>4877.IBPluginDependency</string>
+                                       <string>4878.IBPluginDependency</string>
+                                       <string>4879.IBPluginDependency</string>
+                                       <string>4880.IBPluginDependency</string>
+                                       <string>4892.IBPluginDependency</string>
+                                       <string>4893.IBPluginDependency</string>
+                                       <string>4904.IBPluginDependency</string>
+                                       <string>4905.IBPluginDependency</string>
+                                       <string>4906.IBPluginDependency</string>
+                                       <string>4907.IBPluginDependency</string>
+                                       <string>4908.IBPluginDependency</string>
+                                       <string>4909.IBPluginDependency</string>
+                                       <string>4910.IBPluginDependency</string>
+                                       <string>4911.IBPluginDependency</string>
+                                       <string>4912.IBPluginDependency</string>
+                                       <string>4913.IBPluginDependency</string>
+                                       <string>4914.IBPluginDependency</string>
+                                       <string>4915.IBPluginDependency</string>
+                                       <string>4916.IBPluginDependency</string>
+                                       <string>4917.IBPluginDependency</string>
+                                       <string>4918.IBPluginDependency</string>
+                                       <string>4919.IBPluginDependency</string>
+                                       <string>4920.IBPluginDependency</string>
+                                       <string>4923.IBPluginDependency</string>
+                                       <string>4924.IBPluginDependency</string>
+                                       <string>4925.IBPluginDependency</string>
+                                       <string>4926.IBPluginDependency</string>
+                                       <string>4927.IBPluginDependency</string>
+                                       <string>4928.IBPluginDependency</string>
+                                       <string>4929.IBPluginDependency</string>
+                                       <string>4930.IBPluginDependency</string>
+                                       <string>4932.IBPluginDependency</string>
+                                       <string>4933.IBPluginDependency</string>
+                                       <string>4934.IBPluginDependency</string>
+                                       <string>4935.IBPluginDependency</string>
+                                       <string>4936.IBPluginDependency</string>
+                                       <string>4937.IBPluginDependency</string>
+                                       <string>4938.IBPluginDependency</string>
+                                       <string>4939.IBPluginDependency</string>
+                                       <string>4940.IBPluginDependency</string>
+                                       <string>4941.IBPluginDependency</string>
+                                       <string>4942.IBPluginDependency</string>
+                                       <string>4943.IBPluginDependency</string>
+                                       <string>4944.IBPluginDependency</string>
+                                       <string>4945.IBPluginDependency</string>
+                                       <string>4946.IBPluginDependency</string>
+                                       <string>4947.IBPluginDependency</string>
+                                       <string>4948.IBPluginDependency</string>
+                                       <string>4949.IBPluginDependency</string>
+                                       <string>4950.IBPluginDependency</string>
+                                       <string>4951.IBPluginDependency</string>
+                                       <string>4952.IBPluginDependency</string>
+                                       <string>4953.IBPluginDependency</string>
+                                       <string>4954.IBPluginDependency</string>
+                                       <string>4955.IBPluginDependency</string>
                                        <string>4955.IBShouldRemoveOnLegacySave</string>
+                                       <string>4956.IBPluginDependency</string>
                                        <string>4956.IBShouldRemoveOnLegacySave</string>
+                                       <string>4957.IBPluginDependency</string>
                                        <string>4957.IBShouldRemoveOnLegacySave</string>
+                                       <string>4958.IBPluginDependency</string>
                                        <string>4958.IBShouldRemoveOnLegacySave</string>
+                                       <string>4959.IBPluginDependency</string>
                                        <string>4959.IBShouldRemoveOnLegacySave</string>
+                                       <string>4960.IBPluginDependency</string>
                                        <string>4960.IBShouldRemoveOnLegacySave</string>
+                                       <string>4961.IBPluginDependency</string>
                                        <string>4961.IBShouldRemoveOnLegacySave</string>
                                        <string>4963.IBPluginDependency</string>
                                        <string>4964.IBPluginDependency</string>
                                        <string>4967.IBAttributePlaceholdersKey</string>
                                        <string>4967.IBPluginDependency</string>
                                        <string>4967.ImportedFromIB2</string>
+                                       <string>4968.IBPluginDependency</string>
                                        <string>4980.IBPluginDependency</string>
                                        <string>4980.ImportedFromIB2</string>
+                                       <string>4981.IBPluginDependency</string>
                                        <string>4982.IBPluginDependency</string>
                                        <string>4982.ImportedFromIB2</string>
                                        <string>4983.IBPluginDependency</string>
                                        <string>4983.ImportedFromIB2</string>
                                        <string>4984.IBPluginDependency</string>
                                        <string>4984.ImportedFromIB2</string>
+                                       <string>4985.IBPluginDependency</string>
                                        <string>4986.IBPluginDependency</string>
                                        <string>4986.ImportedFromIB2</string>
                                        <string>4987.IBPluginDependency</string>
                                        <string>4987.ImportedFromIB2</string>
                                        <string>4988.IBPluginDependency</string>
                                        <string>4988.ImportedFromIB2</string>
+                                       <string>4989.IBPluginDependency</string>
                                        <string>4992.IBPluginDependency</string>
                                        <string>4992.ImportedFromIB2</string>
+                                       <string>4993.IBPluginDependency</string>
                                        <string>4994.IBPluginDependency</string>
                                        <string>4994.ImportedFromIB2</string>
+                                       <string>4995.IBPluginDependency</string>
                                        <string>4996.IBPluginDependency</string>
                                        <string>4996.ImportedFromIB2</string>
+                                       <string>4997.IBPluginDependency</string>
                                        <string>4998.IBPluginDependency</string>
                                        <string>4998.ImportedFromIB2</string>
                                        <string>4999.IBPluginDependency</string>
                                        <string>4999.ImportedFromIB2</string>
                                        <string>5000.IBPluginDependency</string>
                                        <string>5000.ImportedFromIB2</string>
+                                       <string>5001.IBPluginDependency</string>
                                        <string>5002.IBPluginDependency</string>
                                        <string>5002.ImportedFromIB2</string>
                                        <string>5003.IBPluginDependency</string>
                                        <string>5003.ImportedFromIB2</string>
                                        <string>5004.IBPluginDependency</string>
                                        <string>5004.ImportedFromIB2</string>
+                                       <string>5005.IBPluginDependency</string>
                                        <string>5006.IBPluginDependency</string>
                                        <string>5006.ImportedFromIB2</string>
                                        <string>5007.IBPluginDependency</string>
                                        <string>5007.ImportedFromIB2</string>
                                        <string>5008.IBPluginDependency</string>
                                        <string>5008.ImportedFromIB2</string>
+                                       <string>5009.IBPluginDependency</string>
                                        <string>5010.IBPluginDependency</string>
                                        <string>5010.ImportedFromIB2</string>
                                        <string>5011.IBPluginDependency</string>
                                        <string>5011.ImportedFromIB2</string>
                                        <string>5012.IBPluginDependency</string>
                                        <string>5012.ImportedFromIB2</string>
+                                       <string>5013.IBPluginDependency</string>
                                        <string>5014.IBPluginDependency</string>
                                        <string>5014.ImportedFromIB2</string>
                                        <string>5014.editorWindowContentRectSynchronizationRect</string>
                                        <string>5015.ImportedFromIB2</string>
                                        <string>5016.IBPluginDependency</string>
                                        <string>5016.ImportedFromIB2</string>
+                                       <string>5017.IBPluginDependency</string>
                                        <string>5018.IBPluginDependency</string>
                                        <string>5018.ImportedFromIB2</string>
                                        <string>5018.editorWindowContentRectSynchronizationRect</string>
                                        <string>5019.ImportedFromIB2</string>
                                        <string>5040.IBPluginDependency</string>
                                        <string>5040.ImportedFromIB2</string>
+                                       <string>5041.IBPluginDependency</string>
                                        <string>5042.IBPluginDependency</string>
                                        <string>5042.ImportedFromIB2</string>
                                        <string>5043.IBPluginDependency</string>
                                        <string>5043.ImportedFromIB2</string>
                                        <string>5044.IBPluginDependency</string>
                                        <string>5044.ImportedFromIB2</string>
+                                       <string>5045.IBPluginDependency</string>
                                        <string>5046.IBPluginDependency</string>
                                        <string>5046.ImportedFromIB2</string>
                                        <string>5047.IBPluginDependency</string>
                                        <string>5047.ImportedFromIB2</string>
                                        <string>5048.IBPluginDependency</string>
                                        <string>5048.ImportedFromIB2</string>
+                                       <string>5049.IBPluginDependency</string>
                                        <string>5050.IBPluginDependency</string>
                                        <string>5050.ImportedFromIB2</string>
                                        <string>5050.editorWindowContentRectSynchronizationRect</string>
                                        <string>5051.ImportedFromIB2</string>
                                        <string>5052.IBPluginDependency</string>
                                        <string>5052.ImportedFromIB2</string>
+                                       <string>5053.IBPluginDependency</string>
                                        <string>5054.IBPluginDependency</string>
                                        <string>5054.ImportedFromIB2</string>
                                        <string>5054.editorWindowContentRectSynchronizationRect</string>
                                        <string>5055.ImportedFromIB2</string>
                                        <string>5056.IBPluginDependency</string>
                                        <string>5056.ImportedFromIB2</string>
+                                       <string>5057.IBPluginDependency</string>
                                        <string>5058.IBPluginDependency</string>
                                        <string>5058.ImportedFromIB2</string>
                                        <string>5058.editorWindowContentRectSynchronizationRect</string>
                                        <string>5059.ImportedFromIB2</string>
                                        <string>5060.IBPluginDependency</string>
                                        <string>5060.ImportedFromIB2</string>
+                                       <string>5061.IBPluginDependency</string>
                                        <string>5062.IBPluginDependency</string>
                                        <string>5062.ImportedFromIB2</string>
                                        <string>5062.editorWindowContentRectSynchronizationRect</string>
                                        <string>5098.IBPluginDependency</string>
                                        <string>5099.IBPluginDependency</string>
                                        <string>5099.ImportedFromIB2</string>
+                                       <string>5100.IBPluginDependency</string>
                                        <string>5101.IBPluginDependency</string>
                                        <string>5101.ImportedFromIB2</string>
+                                       <string>5102.IBPluginDependency</string>
                                        <string>5103.IBPluginDependency</string>
                                        <string>5103.ImportedFromIB2</string>
+                                       <string>5104.IBPluginDependency</string>
                                        <string>5105.IBPluginDependency</string>
                                        <string>5105.ImportedFromIB2</string>
+                                       <string>5106.IBPluginDependency</string>
                                        <string>5107.IBPluginDependency</string>
                                        <string>5107.ImportedFromIB2</string>
-                                       <string>5122.IBPluginDependency</string>
-                                       <string>5122.ImportedFromIB2</string>
-                                       <string>5124.IBPluginDependency</string>
-                                       <string>5124.ImportedFromIB2</string>
+                                       <string>5108.IBPluginDependency</string>
                                        <string>5130.IBPluginDependency</string>
                                        <string>5131.IBPluginDependency</string>
                                        <string>5132.IBEditorWindowLastContentRect</string>
                                        <string>5135.IBPluginDependency</string>
                                        <string>5153.IBPluginDependency</string>
                                        <string>5153.ImportedFromIB2</string>
+                                       <string>5154.IBPluginDependency</string>
+                                       <string>5157.IBPluginDependency</string>
+                                       <string>5167.IBPluginDependency</string>
+                                       <string>5167.ImportedFromIB2</string>
+                                       <string>5168.IBPluginDependency</string>
+                                       <string>5171.IBPluginDependency</string>
+                                       <string>5171.ImportedFromIB2</string>
+                                       <string>5172.IBPluginDependency</string>
+                                       <string>5174.IBPluginDependency</string>
+                                       <string>5174.ImportedFromIB2</string>
+                                       <string>5175.IBPluginDependency</string>
+                                       <string>5177.IBPluginDependency</string>
+                                       <string>5177.ImportedFromIB2</string>
+                                       <string>5178.IBPluginDependency</string>
+                                       <string>5180.IBPluginDependency</string>
+                                       <string>5180.ImportedFromIB2</string>
+                                       <string>5181.IBPluginDependency</string>
+                                       <string>5181.ImportedFromIB2</string>
+                                       <string>5182.IBPluginDependency</string>
+                                       <string>5183.IBPluginDependency</string>
+                                       <string>5183.ImportedFromIB2</string>
+                                       <string>5184.IBPluginDependency</string>
+                                       <string>5184.ImportedFromIB2</string>
+                                       <string>5185.IBPluginDependency</string>
+                                       <string>5188.IBPluginDependency</string>
+                                       <string>5192.IBPluginDependency</string>
+                                       <string>5194.IBPluginDependency</string>
+                                       <string>5195.IBPluginDependency</string>
+                                       <string>5196.IBPluginDependency</string>
+                                       <string>5197.IBPluginDependency</string>
+                                       <string>5198.IBPluginDependency</string>
+                                       <string>5199.IBPluginDependency</string>
+                                       <string>5201.IBPluginDependency</string>
+                                       <string>5215.IBPluginDependency</string>
+                                       <string>5217.IBPluginDependency</string>
+                                       <string>5219.IBPluginDependency</string>
+                                       <string>5225.IBPluginDependency</string>
+                                       <string>5226.IBEditorWindowLastContentRect</string>
+                                       <string>5226.IBPluginDependency</string>
+                                       <string>5227.IBPluginDependency</string>
+                                       <string>5232.IBPluginDependency</string>
+                                       <string>5233.IBPluginDependency</string>
+                                       <string>5234.IBPluginDependency</string>
+                                       <string>5244.IBPluginDependency</string>
+                                       <string>5246.IBPluginDependency</string>
+                                       <string>5247.IBPluginDependency</string>
+                                       <string>5250.IBPluginDependency</string>
+                                       <string>5252.IBPluginDependency</string>
+                                       <string>5254.IBPluginDependency</string>
+                                       <string>5268.IBPluginDependency</string>
+                                       <string>5269.IBPluginDependency</string>
+                                       <string>5270.IBPluginDependency</string>
+                                       <string>5271.IBPluginDependency</string>
+                                       <string>5272.IBPluginDependency</string>
+                                       <string>5273.IBPluginDependency</string>
+                                       <string>5278.IBPluginDependency</string>
+                                       <string>5279.IBNumberFormatterBehaviorMetadataKey</string>
+                                       <string>5279.IBNumberFormatterLocalizesFormatMetadataKey</string>
+                                       <string>5279.IBPluginDependency</string>
+                                       <string>5280.IBPluginDependency</string>
+                                       <string>5280.ImportedFromIB2</string>
                                        <string>56.IBPluginDependency</string>
                                        <string>56.ImportedFromIB2</string>
+                                       <string>57.IBEditorWindowLastContentRect</string>
                                        <string>57.IBPluginDependency</string>
                                        <string>57.ImportedFromIB2</string>
                                        <string>57.editorWindowContentRectSynchronizationRect</string>
                                        <string>970.IBPluginDependency</string>
                                        <string>970.ImportedFromIB2</string>
                                        <string>971.IBPluginDependency</string>
-                                       <string>971.ImportedFromIB2</string>
-                                       <string>973.IBPluginDependency</string>
-                                       <string>973.ImportedFromIB2</string>
-                               </object>
-                               <object class="NSMutableArray" key="dict.values">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <integer value="1" id="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <string>971.ImportedFromIB2</string>
+                                       <string>973.IBPluginDependency</string>
+                                       <string>973.ImportedFromIB2</string>
+                               </object>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <object class="NSMutableDictionary">
-                                               <string key="NS.key.0">InitialTabViewItem</string>
-                                               <object class="IBInitialTabViewItemAttribute" key="NS.object.0">
-                                                       <string key="name">InitialTabViewItem</string>
-                                                       <reference key="object" ref="712502892"/>
-                                                       <reference key="initialTabViewItem" ref="107038816"/>
-                                               </object>
-                                       </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{587, 747}, {211, 183}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{434, 787}, {284, 143}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <object class="NSMutableDictionary">
+                                               <string key="NS.key.0">InitialTabViewItem</string>
+                                               <object class="IBInitialTabViewItemAttribute" key="NS.object.0">
+                                                       <string key="name">InitialTabViewItem</string>
+                                                       <reference key="object" ref="712502892"/>
+                                                       <reference key="initialTabViewItem" ref="107038816"/>
+                                               </object>
+                                       </object>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>{{673, 530}, {83, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{673, 530}, {83, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{476, 687}, {253, 243}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{454, 306}, {270, 550}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <integer value="0" id="8"/>
+                                       <integer value="0"/>
                                        <reference ref="9"/>
                                        <string>{{720, 261}, {270, 550}}</string>
                                        <string>{{275, 198}, {338, 318}}</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{275, 198}, {338, 318}}</string>
                                        <reference ref="9"/>
                                        <string>{{421, 536}, {338, 318}}</string>
-                                       <reference ref="9"/>
+                                       <reference ref="6"/>
                                        <reference ref="9"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
                                        <string>{338, 232}</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{520, 797}, {236, 133}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>{{171, 168}, {760, 550}}</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="8"/>
-                                       <string>{{171, 168}, {760, 550}}</string>
+                                       <string>{{257, 300}, {760, 550}}</string>
+                                       <reference ref="6"/>
+                                       <string>{{257, 300}, {760, 550}}</string>
                                        <reference ref="9"/>
                                        <string>{{65, 541}, {760, 550}}</string>
-                                       <reference ref="9"/>
+                                       <reference ref="6"/>
                                        <reference ref="9"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
                                        <string>{213, 107}</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>{{72, 851}, {392, 144}}</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{72, 851}, {392, 144}}</string>
                                        <reference ref="9"/>
                                        <string>{{303, 988}, {392, 144}}</string>
-                                       <reference ref="9"/>
+                                       <reference ref="6"/>
                                        <reference ref="9"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
                                        <string>{213, 107}</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{325, 930}, {394, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{63, 836}, {394, 20}}</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>HBPresetsOutlineView</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{57, 766}, {300, 233}}</string>
                                        <reference ref="9"/>
                                        <string>{{57, 766}, {300, 233}}</string>
-                                       <reference ref="9"/>
+                                       <reference ref="6"/>
                                        <reference ref="9"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
                                        <string>{213, 107}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{418, 529}, {122, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{418, 529}, {122, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{601, 501}, {79, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{673, 530}, {83, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{673, 530}, {83, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{673, 530}, {83, 20}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{304, 383}, {226, 63}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{923, 222}, {226, 63}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{154, 542}, {700, 18}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1041"/>
+                                       <reference ref="6"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{337, 757}, {232, 173}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>{{75, 683}, {235, 153}}</string>
                                </object>
                        </object>
                        <nil key="sourceID"/>
-                       <int key="maxID">5156</int>
+                       <int key="maxID">5490</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <object class="NSMutableArray" key="referencedPartialClassDescriptions">
                                                        <string>audioTrackMixdownChanged:</string>
                                                        <string>audioTrackPopUpChanged:</string>
                                                        <string>autoSetM4vExtension:</string>
+                                                       <string>browseExportPresetFile:</string>
                                                        <string>browseFile:</string>
+                                                       <string>browseImportPresetFile:</string>
+                                                       <string>browseImportSrtFile:</string>
                                                        <string>browseSources:</string>
                                                        <string>calculateBitrate:</string>
                                                        <string>calculatePictureSizing:</string>
                                                        <string>selectPreset:</string>
                                                        <string>setDefaultPreset:</string>
                                                        <string>setEnabledStateOfAudioMixdownControls:</string>
+                                                       <string>showAboutPanel:</string>
                                                        <string>showAddPresetPanel:</string>
                                                        <string>showDebugOutputPanel:</string>
                                                        <string>showNewScan:</string>
                                                        <string>showPicturePanel:</string>
                                                        <string>showPreferencesWindow:</string>
+                                                       <string>showPreviewWindow:</string>
                                                        <string>showQueueWindow:</string>
                                                        <string>showSourceTitleScanPanel:</string>
-                                                       <string>subtitleSelectionChanged:</string>
                                                        <string>titlePopUpChanged:</string>
                                                        <string>twoPassCheckboxChanged:</string>
                                                        <string>videoEncoderPopUpChanged:</string>
                                                        <string>id</string>
                                                        <string>id</string>
                                                        <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
                                                </object>
                                        </object>
                                        <object class="NSMutableDictionary" key="outlets">
                                                        <string>fAudTrack4Label</string>
                                                        <string>fAudTrack4MixPopUp</string>
                                                        <string>fAudTrack4RatePopUp</string>
+                                                       <string>fBrowseSrtFileButton</string>
                                                        <string>fChapterTable</string>
                                                        <string>fCreateChapterMarkers</string>
                                                        <string>fDstBrowseButton</string>
                                                        <string>fDstMp4HttpOptFileCheck</string>
                                                        <string>fDstMp4LargeFileCheck</string>
                                                        <string>fDstMp4iPodFileCheck</string>
-                                                       <string>fPicLabelAnamorphic</string>
-                                                       <string>fPicLabelAr</string>
-                                                       <string>fPicLabelAutoCrop</string>
-                                                       <string>fPicLabelDeblock</string>
-                                                       <string>fPicLabelDecomb</string>
-                                                       <string>fPicLabelDeinterlace</string>
-                                                       <string>fPicLabelDenoise</string>
-                                                       <string>fPicLabelDetelecine</string>
-                                                       <string>fPicLabelOutp</string>
-                                                       <string>fPicLabelSettings</string>
-                                                       <string>fPicLabelSrc</string>
-                                                       <string>fPicSettingARkeep</string>
-                                                       <string>fPicSettingAutoCrop</string>
-                                                       <string>fPicSettingDeblock</string>
-                                                       <string>fPicSettingDecomb</string>
-                                                       <string>fPicSettingDeinterlace</string>
-                                                       <string>fPicSettingDenoise</string>
-                                                       <string>fPicSettingDetelecine</string>
-                                                       <string>fPicSettingPAR</string>
-                                                       <string>fPicSettingsAnamorphic</string>
-                                                       <string>fPicSettingsOutp</string>
-                                                       <string>fPicSettingsSrc</string>
-                                                       <string>fPictureButton</string>
+                                                       <string>fPictureCroppingField</string>
+                                                       <string>fPictureSizeField</string>
                                                        <string>fPresetDrawer</string>
                                                        <string>fPresetNewDesc</string>
                                                        <string>fPresetNewFolderCheck</string>
                                                        <string>fScanSrcTitleOpenButton</string>
                                                        <string>fScanSrcTitlePanel</string>
                                                        <string>fScanSrcTitlePathField</string>
+                                                       <string>fSrcAngleLabel</string>
+                                                       <string>fSrcAnglePopUp</string>
                                                        <string>fSrcChapterEndPopUp</string>
                                                        <string>fSrcChapterField</string>
                                                        <string>fSrcChapterStartPopUp</string>
                                                        <string>fSubField</string>
                                                        <string>fSubForcedCheck</string>
                                                        <string>fSubPopUp</string>
+                                                       <string>fSubtitlesTable</string>
                                                        <string>fVidBitrateCell</string>
                                                        <string>fVidBitrateField</string>
                                                        <string>fVidConstantCell</string>
                                                        <string>fVidEncoderField</string>
                                                        <string>fVidEncoderPopUp</string>
-                                                       <string>fVidGrayscaleCheck</string>
                                                        <string>fVidQualityField</string>
                                                        <string>fVidQualityMatrix</string>
+                                                       <string>fVidQualityRFField</string>
+                                                       <string>fVidQualityRFLabel</string>
                                                        <string>fVidQualitySlider</string>
                                                        <string>fVidRateField</string>
                                                        <string>fVidRatePopUp</string>
                                                        <string>fVidTargetSizeField</string>
                                                        <string>fVidTurboPassCheck</string>
                                                        <string>fVidTwoPassCheck</string>
+                                                       <string>fVideoFiltersField</string>
                                                        <string>fWindow</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSPopUpButton</string>
+                                                       <string>NSButton</string>
                                                        <string>NSTableView</string>
                                                        <string>NSButton</string>
                                                        <string>NSButton</string>
                                                        <string>NSButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSTextField</string>
-                                                       <string>NSButton</string>
                                                        <string>NSDrawer</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSButton</string>
                                                        <string>NSPanel</string>
                                                        <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSPopUpButton</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSPopUpButton</string>
+                                                       <string>NSTableView</string>
                                                        <string>NSButtonCell</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButtonCell</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
-                                                       <string>NSButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSMatrix</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSSlider</string>
                                                        <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSButton</string>
                                                        <string>NSButton</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSWindow</string>
                                                </object>
                                        </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
-                                       </object>
-                               </object>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">NSObject</string>
-                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
                                        </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">SUUpdater</string>
                                        <string key="superclassName">NSObject</string>
-                                       <object class="NSMutableDictionary" key="actions">
-                                               <string key="NS.key.0">checkForUpdates:</string>
-                                               <string key="NS.object.0">id</string>
-                                       </object>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
index 6fcd19c..b3328dc 100644 (file)
@@ -1,19 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9F33</string>
-               <string key="IBDocument.InterfaceBuilderVersion">670</string>
-               <string key="IBDocument.AppKitVersion">949.34</string>
-               <string key="IBDocument.HIToolboxVersion">352.00</string>
+               <string key="IBDocument.SystemVersion">9G55</string>
+               <string key="IBDocument.InterfaceBuilderVersion">677</string>
+               <string key="IBDocument.AppKitVersion">949.43</string>
+               <string key="IBDocument.HIToolboxVersion">353.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <integer value="11"/>
+                       <integer value="6"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
                <object class="NSMutableArray" key="IBDocument.RootObjects" id="640353287">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <object class="NSCustomObject" id="282956917">
@@ -28,7 +38,7 @@
                        <object class="NSWindowTemplate" id="1026712888">
                                <int key="NSWindowStyleMask">15</int>
                                <int key="NSWindowBacking">2</int>
-                               <string key="NSWindowRect">{{155, 772}, {379, 371}}</string>
+                               <string key="NSWindowRect">{{155, 772}, {378, 371}}</string>
                                <int key="NSWTFlags">-260571136</int>
                                <string key="NSWindowTitle">Activity Window - HandBrake</string>
                                <string key="NSWindowClass">NSPanel</string>
@@ -38,7 +48,7 @@
                                <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
                                <string key="NSWindowContentMinSize">{214.502, 107}</string>
                                <object class="NSView" key="NSWindowView" id="1055997608">
-                                       <nil key="NSNextResponder"/>
+                                       <reference key="NSNextResponder"/>
                                        <int key="NSvFlags">256</int>
                                        <object class="NSMutableArray" key="NSSubviews">
                                                <bool key="EncodedWithXMLCoder">YES</bool>
                                                                        <double key="NSPercent">9.456522e-01</double>
                                                                </object>
                                                        </object>
-                                                       <string key="NSFrame">{{0, -1}, {380, 373}}</string>
+                                                       <string key="NSFrame">{{-1, -1}, {380, 373}}</string>
                                                        <reference key="NSSuperview" ref="1055997608"/>
                                                        <reference key="NSNextKeyView" ref="630219039"/>
                                                        <int key="NSsFlags">18</int>
                                                        <bytes key="NSScrollAmts">AAAAAAAAAAAAAAAAAAAAAA</bytes>
                                                </object>
                                        </object>
-                                       <string key="NSFrameSize">{379, 371}</string>
+                                       <string key="NSFrameSize">{378, 371}</string>
+                                       <reference key="NSSuperview"/>
                                </object>
                                <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
                                <string key="NSMinSize">{214.502, 129}</string>
                                        <string>35.ImportedFromIB2</string>
                                        <string>37.IBPluginDependency</string>
                                        <string>37.ImportedFromIB2</string>
+                                       <string>39.IBPluginDependency</string>
                                        <string>39.IBShouldRemoveOnLegacySave</string>
+                                       <string>40.IBPluginDependency</string>
                                        <string>40.IBShouldRemoveOnLegacySave</string>
                                        <string>42.IBPluginDependency</string>
                                        <string>42.ImportedFromIB2</string>
                                        <string>43.IBPluginDependency</string>
                                        <string>43.ImportedFromIB2</string>
-                                       <string>5.IBPluginDependency</string>
+                                       <string>5.IBEditorWindowLastContentRect</string>
+                                       <string>5.IBWindowTemplateEditedContentRect</string>
                                        <string>5.ImportedFromIB2</string>
                                        <string>5.windowTemplate.hasMaxSize</string>
                                        <string>5.windowTemplate.hasMinSize</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <string>{{319, 676}, {358, 123}}</string>
+                                       <string>{{319, 676}, {300, 123}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
-                                       <reference ref="9"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
                                        <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="9"/>
+                                       <string>{{597, 246}, {378, 371}}</string>
+                                       <string>{{597, 246}, {378, 371}}</string>
                                        <reference ref="9"/>
+                                       <boolean value="NO"/>
                                        <reference ref="9"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
                                        <string>{214.502, 107}</string>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
-                                       </object>
-                               </object>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">NSObject</string>
-                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
                                        </object>
diff --git a/macosx/English.lproj/PicturePreview.xib b/macosx/English.lproj/PicturePreview.xib
new file mode 100644 (file)
index 0000000..d8eba8b
--- /dev/null
@@ -0,0 +1,2219 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
+       <data>
+               <int key="IBDocument.SystemTarget">1050</int>
+               <string key="IBDocument.SystemVersion">10A432</string>
+               <string key="IBDocument.InterfaceBuilderVersion">732</string>
+               <string key="IBDocument.AppKitVersion">1038</string>
+               <string key="IBDocument.HIToolboxVersion">437.00</string>
+               <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                               <string>com.apple.QTKitIBPlugin</string>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <string>732</string>
+                               <string>1584</string>
+                       </object>
+               </object>
+               <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <integer value="257"/>
+               </object>
+               <object class="NSArray" key="IBDocument.PluginDependencies">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <string>com.apple.QTKitIBPlugin</string>
+                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+               </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys" id="0">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
+               <object class="NSMutableArray" key="IBDocument.RootObjects" id="273418435">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSCustomObject" id="355312334">
+                               <string key="NSClassName">PreviewController</string>
+                       </object>
+                       <object class="NSCustomObject" id="844574444">
+                               <string key="NSClassName">FirstResponder</string>
+                       </object>
+                       <object class="NSCustomObject" id="837220151">
+                               <string key="NSClassName">NSApplication</string>
+                       </object>
+                       <object class="NSWindowTemplate" id="616825745">
+                               <int key="NSWindowStyleMask">7</int>
+                               <int key="NSWindowBacking">2</int>
+                               <string key="NSWindowRect">{{142, 519}, {480, 360}}</string>
+                               <int key="NSWTFlags">1886913536</int>
+                               <string key="NSWindowTitle">HandBrake Preview</string>
+                               <string key="NSWindowClass">NSPanel</string>
+                               <object class="NSMutableString" key="NSViewClass">
+                                       <characters key="NS.bytes">View</characters>
+                               </object>
+                               <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
+                               <object class="NSView" key="NSWindowView" id="49161063">
+                                       <reference key="NSNextResponder"/>
+                                       <int key="NSvFlags">274</int>
+                                       <object class="NSMutableArray" key="NSSubviews">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="NSBox" id="289177107">
+                                                       <reference key="NSNextResponder" ref="49161063"/>
+                                                       <int key="NSvFlags">18</int>
+                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                               <object class="NSView" id="353606868">
+                                                                       <reference key="NSNextResponder" ref="289177107"/>
+                                                                       <int key="NSvFlags">256</int>
+                                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                               <object class="NSImageView" id="844127024">
+                                                                                       <reference key="NSNextResponder" ref="353606868"/>
+                                                                                       <int key="NSvFlags">274</int>
+                                                                                       <object class="NSMutableSet" key="NSDragTypes">
+                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                               <object class="NSArray" key="set.sortedObjects">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <string>Apple PDF pasteboard type</string>
+                                                                                                       <string>Apple PICT pasteboard type</string>
+                                                                                                       <string>Apple PNG pasteboard type</string>
+                                                                                                       <string>NSFilenamesPboardType</string>
+                                                                                                       <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
+                                                                                                       <string>NeXT TIFF v4.0 pasteboard type</string>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <string key="NSFrame">{{-3, -3}, {488, 368}}</string>
+                                                                                       <reference key="NSSuperview" ref="353606868"/>
+                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                       <object class="NSImageCell" key="NSCell" id="955430771">
+                                                                                               <int key="NSCellFlags">130560</int>
+                                                                                               <int key="NSCellFlags2">33554432</int>
+                                                                                               <int key="NSAlign">0</int>
+                                                                                               <int key="NSScale">1</int>
+                                                                                               <int key="NSStyle">3</int>
+                                                                                               <bool key="NSAnimates">NO</bool>
+                                                                                       </object>
+                                                                                       <bool key="NSEditable">YES</bool>
+                                                                               </object>
+                                                                               <object class="QTMovieView" id="48693112">
+                                                                                       <reference key="NSNextResponder" ref="353606868"/>
+                                                                                       <int key="NSvFlags">274</int>
+                                                                                       <object class="NSMutableSet" key="NSDragTypes">
+                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                               <object class="NSArray" key="set.sortedObjects">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <string>Apple URL pasteboard type</string>
+                                                                                                       <string>CorePasteboardFlavorType 0x6D6F6F76</string>
+                                                                                                       <string>NSFilenamesPboardType</string>
+                                                                                                       <string>QTMoviePasteboardType</string>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <string key="NSFrameSize">{482, 362}</string>
+                                                                                       <reference key="NSSuperview" ref="353606868"/>
+                                                                                       <object class="NSColor" key="kCoderFillColor">
+                                                                                               <int key="NSColorSpace">1</int>
+                                                                                               <bytes key="NSRGB">MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA</bytes>
+                                                                                       </object>
+                                                                                       <boolean value="YES" key="kCoderControllerVisible"/>
+                                                                                       <boolean value="YES" key="kCoderPreservesAspectRatio"/>
+                                                                                       <nil key="kCoderMovie"/>
+                                                                                       <boolean value="NO" key="kCoderEditable"/>
+                                                                               </object>
+                                                                               <object class="NSBox" id="92351498">
+                                                                                       <reference key="NSNextResponder" ref="353606868"/>
+                                                                                       <int key="NSvFlags">-2147483611</int>
+                                                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                               <object class="NSView" id="385854969">
+                                                                                                       <reference key="NSNextResponder" ref="92351498"/>
+                                                                                                       <int key="NSvFlags">256</int>
+                                                                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                               <object class="NSButton" id="798240356">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">292</int>
+                                                                                                                       <string key="NSFrame">{{18, 8}, {77, 25}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSButtonCell" key="NSCell" id="975305481">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">134479872</int>
+                                                                                                                               <string key="NSContents">Live Preview</string>
+                                                                                                                               <object class="NSFont" key="NSSupport" id="22">
+                                                                                                                                       <string key="NSName">LucidaGrande</string>
+                                                                                                                                       <double key="NSSize">9</double>
+                                                                                                                                       <int key="NSfFlags">3614</int>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSControlView" ref="798240356"/>
+                                                                                                                               <int key="NSButtonFlags">-2038284033</int>
+                                                                                                                               <int key="NSButtonFlags2">163</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSButton" id="537831590">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">289</int>
+                                                                                                                       <string key="NSFrame">{{251, 8}, {69, 25}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSButtonCell" key="NSCell" id="29238952">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">134479872</int>
+                                                                                                                               <string key="NSContents">Full Screen</string>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="537831590"/>
+                                                                                                                               <int key="NSButtonFlags">-2038284033</int>
+                                                                                                                               <int key="NSButtonFlags2">163</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSButton" id="141370142">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">289</int>
+                                                                                                                       <string key="NSFrame">{{364, 8}, {54, 25}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSButtonCell" key="NSCell" id="606007744">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">134479872</int>
+                                                                                                                               <string key="NSContents">Settings</string>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="141370142"/>
+                                                                                                                               <int key="NSButtonFlags">-2038284033</int>
+                                                                                                                               <int key="NSButtonFlags2">163</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSButton" id="81685190">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">289</int>
+                                                                                                                       <string key="NSFrame">{{325, 8}, {34, 25}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSButtonCell" key="NSCell" id="847033897">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">134479872</int>
+                                                                                                                               <string key="NSContents">&lt;-&gt;</string>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="81685190"/>
+                                                                                                                               <int key="NSButtonFlags">-2038284033</int>
+                                                                                                                               <int key="NSButtonFlags2">163</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSTextField" id="66510867">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">289</int>
+                                                                                                                       <string key="NSFrame">{{117, 15}, {75, 11}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSTextFieldCell" key="NSCell" id="567286013">
+                                                                                                                               <int key="NSCellFlags">68288064</int>
+                                                                                                                               <int key="NSCellFlags2">71566336</int>
+                                                                                                                               <string key="NSContents">Duration (sec):</string>
+                                                                                                                               <object class="NSFont" key="NSSupport" id="811969608">
+                                                                                                                                       <string key="NSName">LucidaGrande-Bold</string>
+                                                                                                                                       <double key="NSSize">9</double>
+                                                                                                                                       <int key="NSfFlags">16</int>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSControlView" ref="66510867"/>
+                                                                                                                               <object class="NSColor" key="NSBackgroundColor" id="407686733">
+                                                                                                                                       <int key="NSColorSpace">6</int>
+                                                                                                                                       <string key="NSCatalogName">System</string>
+                                                                                                                                       <string key="NSColorName">controlColor</string>
+                                                                                                                                       <object class="NSColor" key="NSColor">
+                                                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                                                               <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <object class="NSColor" key="NSTextColor">
+                                                                                                                                       <int key="NSColorSpace">1</int>
+                                                                                                                                       <bytes key="NSRGB">MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA</bytes>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSPopUpButton" id="598619000">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">289</int>
+                                                                                                                       <string key="NSFrame">{{196, 12}, {45, 15}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSPopUpButtonCell" key="NSCell" id="953108737">
+                                                                                                                               <int key="NSCellFlags">-2076049856</int>
+                                                                                                                               <int key="NSCellFlags2">264192</int>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="598619000"/>
+                                                                                                                               <int key="NSButtonFlags">109199615</int>
+                                                                                                                               <int key="NSButtonFlags2">1</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">400</int>
+                                                                                                                               <int key="NSPeriodicInterval">75</int>
+                                                                                                                               <object class="NSMenuItem" key="NSMenuItem" id="372655630">
+                                                                                                                                       <reference key="NSMenu" ref="501672847"/>
+                                                                                                                                       <string key="NSTitle">Item 1</string>
+                                                                                                                                       <string key="NSKeyEquiv"/>
+                                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                       <int key="NSState">1</int>
+                                                                                                                                       <object class="NSCustomResource" key="NSOnImage" id="858043985">
+                                                                                                                                               <string key="NSClassName">NSImage</string>
+                                                                                                                                               <string key="NSResourceName">NSMenuCheckmark</string>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSCustomResource" key="NSMixedImage" id="700487240">
+                                                                                                                                               <string key="NSClassName">NSImage</string>
+                                                                                                                                               <string key="NSResourceName">NSMenuMixedState</string>
+                                                                                                                                       </object>
+                                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                       <reference key="NSTarget" ref="953108737"/>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                               <object class="NSMenu" key="NSMenu" id="501672847">
+                                                                                                                                       <string key="NSTitle">OtherViews</string>
+                                                                                                                                       <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                               <reference ref="372655630"/>
+                                                                                                                                               <object class="NSMenuItem" id="607756368">
+                                                                                                                                                       <reference key="NSMenu" ref="501672847"/>
+                                                                                                                                                       <string key="NSTitle">Item 2</string>
+                                                                                                                                                       <string key="NSKeyEquiv"/>
+                                                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                       <reference key="NSOnImage" ref="858043985"/>
+                                                                                                                                                       <reference key="NSMixedImage" ref="700487240"/>
+                                                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                       <reference key="NSTarget" ref="953108737"/>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSMenuItem" id="272743761">
+                                                                                                                                                       <reference key="NSMenu" ref="501672847"/>
+                                                                                                                                                       <string key="NSTitle">Item 3</string>
+                                                                                                                                                       <string key="NSKeyEquiv"/>
+                                                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                       <reference key="NSOnImage" ref="858043985"/>
+                                                                                                                                                       <reference key="NSMixedImage" ref="700487240"/>
+                                                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                       <reference key="NSTarget" ref="953108737"/>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <int key="NSPreferredEdge">1</int>
+                                                                                                                               <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                               <bool key="NSAltersState">YES</bool>
+                                                                                                                               <int key="NSArrowPosition">2</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSSlider" id="396925210">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">290</int>
+                                                                                                                       <string key="NSFrame">{{18, 40}, {400, 16}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSSliderCell" key="NSCell" id="639767004">
+                                                                                                                               <int key="NSCellFlags">67501824</int>
+                                                                                                                               <int key="NSCellFlags2">262144</int>
+                                                                                                                               <string key="NSContents"/>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="396925210"/>
+                                                                                                                               <double key="NSMaxValue">9</double>
+                                                                                                                               <double key="NSMinValue">0.0</double>
+                                                                                                                               <double key="NSValue">0.0</double>
+                                                                                                                               <double key="NSAltIncValue">0.0</double>
+                                                                                                                               <int key="NSNumberOfTickMarks">10</int>
+                                                                                                                               <int key="NSTickMarkPosition">1</int>
+                                                                                                                               <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
+                                                                                                                               <bool key="NSVertical">NO</bool>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSTextField" id="628196212">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">290</int>
+                                                                                                                       <string key="NSFrame">{{15, 56}, {406, 20}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSTextFieldCell" key="NSCell" id="921881842">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">4325376</int>
+                                                                                                                               <string key="NSContents"/>
+                                                                                                                               <object class="NSFont" key="NSSupport" id="476446081">
+                                                                                                                                       <string key="NSName">LucidaGrande-Bold</string>
+                                                                                                                                       <double key="NSSize">11</double>
+                                                                                                                                       <int key="NSfFlags">16</int>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSControlView" ref="628196212"/>
+                                                                                                                               <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                               <object class="NSColor" key="NSTextColor" id="978544139">
+                                                                                                                                       <int key="NSColorSpace">1</int>
+                                                                                                                                       <bytes key="NSRGB">MSAxIDEAA</bytes>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSTextField" id="245200984">
+                                                                                                                       <reference key="NSNextResponder" ref="385854969"/>
+                                                                                                                       <int key="NSvFlags">290</int>
+                                                                                                                       <string key="NSFrame">{{16, 81}, {406, 12}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="385854969"/>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSTextFieldCell" key="NSCell" id="1032360651">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">4456448</int>
+                                                                                                                               <string key="NSContents"/>
+                                                                                                                               <reference key="NSSupport" ref="811969608"/>
+                                                                                                                               <reference key="NSControlView" ref="245200984"/>
+                                                                                                                               <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                               <reference key="NSTextColor" ref="978544139"/>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                       </object>
+                                                                                                       <string key="NSFrame">{{2, 2}, {436, 96}}</string>
+                                                                                                       <reference key="NSSuperview" ref="92351498"/>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <string key="NSFrame">{{21, 90}, {440, 100}}</string>
+                                                                                       <reference key="NSSuperview" ref="353606868"/>
+                                                                                       <string key="NSOffsets">{0, 0}</string>
+                                                                                       <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                               <int key="NSCellFlags2">0</int>
+                                                                                               <string key="NSContents">Picture Controls</string>
+                                                                                               <object class="NSFont" key="NSSupport" id="26">
+                                                                                                       <string key="NSName">LucidaGrande</string>
+                                                                                                       <double key="NSSize">11</double>
+                                                                                                       <int key="NSfFlags">3100</int>
+                                                                                               </object>
+                                                                                               <object class="NSColor" key="NSBackgroundColor" id="384686844">
+                                                                                                       <int key="NSColorSpace">6</int>
+                                                                                                       <string key="NSCatalogName">System</string>
+                                                                                                       <string key="NSColorName">textBackgroundColor</string>
+                                                                                                       <object class="NSColor" key="NSColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MQA</bytes>
+                                                                                                       </object>
+                                                                                               </object>
+                                                                                               <object class="NSColor" key="NSTextColor">
+                                                                                                       <int key="NSColorSpace">3</int>
+                                                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <reference key="NSContentView" ref="385854969"/>
+                                                                                       <int key="NSBorderType">1</int>
+                                                                                       <int key="NSBoxType">4</int>
+                                                                                       <int key="NSTitlePosition">0</int>
+                                                                                       <bool key="NSTransparent">NO</bool>
+                                                                                       <real value="2" key="NSBorderWidth2"/>
+                                                                                       <double key="NSCornerRadius2">26</double>
+                                                                                       <reference key="NSBorderColor2" ref="978544139"/>
+                                                                                       <object class="NSColor" key="NSFillColor2">
+                                                                                               <int key="NSColorSpace">1</int>
+                                                                                               <bytes key="NSRGB">MCAwIDAgMC43NQA</bytes>
+                                                                                       </object>
+                                                                               </object>
+                                                                               <object class="NSBox" id="768906858">
+                                                                                       <reference key="NSNextResponder" ref="353606868"/>
+                                                                                       <int key="NSvFlags">-2147483611</int>
+                                                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                               <object class="NSView" id="1067699710">
+                                                                                                       <reference key="NSNextResponder" ref="768906858"/>
+                                                                                                       <int key="NSvFlags">256</int>
+                                                                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                               <object class="NSProgressIndicator" id="196868285">
+                                                                                                                       <reference key="NSNextResponder" ref="1067699710"/>
+                                                                                                                       <int key="NSvFlags">-2147482368</int>
+                                                                                                                       <object class="NSPSMatrix" key="NSDrawMatrix"/>
+                                                                                                                       <string key="NSFrame">{{23, 26}, {336, 12}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="1067699710"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <int key="NSpiFlags">16650</int>
+                                                                                                                       <double key="NSMinValue">20</double>
+                                                                                                                       <double key="NSMaxValue">100</double>
+                                                                                                               </object>
+                                                                                                               <object class="NSButton" id="569473100">
+                                                                                                                       <reference key="NSNextResponder" ref="1067699710"/>
+                                                                                                                       <int key="NSvFlags">265</int>
+                                                                                                                       <string key="NSFrame">{{366, 21}, {46, 25}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="1067699710"/>
+                                                                                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                               <object class="CIColorMonochrome">
+                                                                                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                                                                                               <float key="red">0.70196080207824707</float>
+                                                                                                                                               <float key="green">0.70196080207824707</float>
+                                                                                                                                               <float key="blue">0.70196080207824707</float>
+                                                                                                                                               <float key="alpha">1</float>
+                                                                                                                                       </object>
+                                                                                                                                       <integer value="1" key="CI_inputIntensity"/>
+                                                                                                                                       <bool key="CIEnabled">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSButtonCell" key="NSCell" id="908165435">
+                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                               <int key="NSCellFlags2">134479872</int>
+                                                                                                                               <string key="NSContents">Cancel</string>
+                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                               <reference key="NSControlView" ref="569473100"/>
+                                                                                                                               <int key="NSButtonFlags">-2038284033</int>
+                                                                                                                               <int key="NSButtonFlags2">163</int>
+                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <object class="NSTextField" id="986015194">
+                                                                                                                       <reference key="NSNextResponder" ref="1067699710"/>
+                                                                                                                       <int key="NSvFlags">256</int>
+                                                                                                                       <string key="NSFrame">{{21, 59}, {394, 14}}</string>
+                                                                                                                       <reference key="NSSuperview" ref="1067699710"/>
+                                                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                                                       <object class="NSTextFieldCell" key="NSCell" id="304208899">
+                                                                                                                               <int key="NSCellFlags">68288064</int>
+                                                                                                                               <int key="NSCellFlags2">4326400</int>
+                                                                                                                               <string key="NSContents">Preparing Preview</string>
+                                                                                                                               <reference key="NSSupport" ref="476446081"/>
+                                                                                                                               <reference key="NSControlView" ref="986015194"/>
+                                                                                                                               <object class="NSColor" key="NSBackgroundColor">
+                                                                                                                                       <int key="NSColorSpace">2</int>
+                                                                                                                                       <bytes key="NSRGB">MC45MDE5NjA4NSAwLjkwMTk2MDg1IDAuOTAxOTYwODUgMAA</bytes>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSTextColor" ref="978544139"/>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                       </object>
+                                                                                                       <string key="NSFrame">{{2, 2}, {436, 96}}</string>
+                                                                                                       <reference key="NSSuperview" ref="768906858"/>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <string key="NSFrame">{{21, 90}, {440, 100}}</string>
+                                                                                       <reference key="NSSuperview" ref="353606868"/>
+                                                                                       <string key="NSOffsets">{0, 0}</string>
+                                                                                       <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                               <int key="NSCellFlags2">0</int>
+                                                                                               <string key="NSContents">Encoding Controls</string>
+                                                                                               <reference key="NSSupport" ref="26"/>
+                                                                                               <reference key="NSBackgroundColor" ref="384686844"/>
+                                                                                               <object class="NSColor" key="NSTextColor">
+                                                                                                       <int key="NSColorSpace">3</int>
+                                                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                               </object>
+                                                                                       </object>
+                                                                                       <reference key="NSContentView" ref="1067699710"/>
+                                                                                       <int key="NSBorderType">1</int>
+                                                                                       <int key="NSBoxType">4</int>
+                                                                                       <int key="NSTitlePosition">0</int>
+                                                                                       <bool key="NSTransparent">NO</bool>
+                                                                                       <real value="2" key="NSBorderWidth2"/>
+                                                                                       <double key="NSCornerRadius2">26</double>
+                                                                                       <reference key="NSBorderColor2" ref="978544139"/>
+                                                                                       <object class="NSColor" key="NSFillColor2">
+                                                                                               <int key="NSColorSpace">1</int>
+                                                                                               <bytes key="NSRGB">MCAwIDAgMC43NQA</bytes>
+                                                                                       </object>
+                                                                               </object>
+                                                                       </object>
+                                                                       <string key="NSFrameSize">{480, 360}</string>
+                                                                       <reference key="NSSuperview" ref="289177107"/>
+                                                               </object>
+                                                       </object>
+                                                       <string key="NSFrameSize">{480, 360}</string>
+                                                       <reference key="NSSuperview" ref="49161063"/>
+                                                       <string key="NSOffsets">{0, 0}</string>
+                                                       <object class="NSTextFieldCell" key="NSTitleCell">
+                                                               <int key="NSCellFlags">67239424</int>
+                                                               <int key="NSCellFlags2">0</int>
+                                                               <string key="NSContents">Box</string>
+                                                               <reference key="NSSupport" ref="26"/>
+                                                               <reference key="NSBackgroundColor" ref="384686844"/>
+                                                               <object class="NSColor" key="NSTextColor">
+                                                                       <int key="NSColorSpace">3</int>
+                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                               </object>
+                                                       </object>
+                                                       <reference key="NSContentView" ref="353606868"/>
+                                                       <int key="NSBorderType">1</int>
+                                                       <int key="NSBoxType">4</int>
+                                                       <int key="NSTitlePosition">0</int>
+                                                       <bool key="NSTransparent">NO</bool>
+                                                       <real value="0.0" key="NSBorderWidth2"/>
+                                                       <object class="NSColor" key="NSBorderColor2">
+                                                               <int key="NSColorSpace">3</int>
+                                                               <bytes key="NSWhite">MCAwLjQ0AA</bytes>
+                                                       </object>
+                                                       <object class="NSColor" key="NSFillColor2">
+                                                               <int key="NSColorSpace">1</int>
+                                                               <bytes key="NSRGB">MC43MDE5NjA4IDAuNzAxOTYwOCAwLjcwMTk2MDgAA</bytes>
+                                                       </object>
+                                               </object>
+                                       </object>
+                                       <string key="NSFrameSize">{480, 360}</string>
+                                       <reference key="NSSuperview"/>
+                               </object>
+                               <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
+                               <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
+                       </object>
+               </object>
+               <object class="IBObjectContainer" key="IBDocument.Objects">
+                       <object class="NSMutableArray" key="connectionRecords">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fInfoField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="628196212"/>
+                                       </object>
+                                       <int key="connectionID">73</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureView</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="844127024"/>
+                                       </object>
+                                       <int key="connectionID">181</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">window</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="616825745"/>
+                                       </object>
+                                       <int key="connectionID">184</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fMovieView</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="48693112"/>
+                                       </object>
+                                       <int key="connectionID">208</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureSlider</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="396925210"/>
+                                       </object>
+                                       <int key="connectionID">211</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">pictureSliderChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="396925210"/>
+                                       </object>
+                                       <int key="connectionID">212</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fMovieCreationProgressIndicator</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="196868285"/>
+                                       </object>
+                                       <int key="connectionID">214</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fCreatePreviewMovieButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="798240356"/>
+                                       </object>
+                                       <int key="connectionID">217</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">createMoviePreview:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="798240356"/>
+                                       </object>
+                                       <int key="connectionID">218</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPreviewMovieStatusField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="986015194"/>
+                                       </object>
+                                       <int key="connectionID">225</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPreviewMovieLengthPopUp</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="598619000"/>
+                                       </object>
+                                       <int key="connectionID">232</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">previewDurationPopUpChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="598619000"/>
+                                       </object>
+                                       <int key="connectionID">233</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPreviewWindow</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="616825745"/>
+                                       </object>
+                                       <int key="connectionID">244</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fEncodingControlBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="768906858"/>
+                                       </object>
+                                       <int key="connectionID">253</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureControlBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="92351498"/>
+                                       </object>
+                                       <int key="connectionID">254</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureViewArea</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="289177107"/>
+                                       </object>
+                                       <int key="connectionID">258</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fCancelPreviewMovieButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="569473100"/>
+                                       </object>
+                                       <int key="connectionID">263</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">createMoviePreview:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="569473100"/>
+                                       </object>
+                                       <int key="connectionID">264</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fFullScreenToggleButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="537831590"/>
+                                       </object>
+                                       <int key="connectionID">267</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">toggleScreenMode:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="537831590"/>
+                                       </object>
+                                       <int key="connectionID">270</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureSettingsToggleButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="141370142"/>
+                                       </object>
+                                       <int key="connectionID">273</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">showPictureSettings:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="141370142"/>
+                                       </object>
+                                       <int key="connectionID">274</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fScaleToScreenToggleButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="81685190"/>
+                                       </object>
+                                       <int key="connectionID">277</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">toggleScaleToScreen:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="81685190"/>
+                                       </object>
+                                       <int key="connectionID">279</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fscaleInfoField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="245200984"/>
+                                       </object>
+                                       <int key="connectionID">282</int>
+                               </object>
+                       </object>
+                       <object class="IBMutableOrderedSet" key="objectRecords">
+                               <object class="NSArray" key="orderedObjects">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">0</int>
+                                               <reference key="object" ref="0"/>
+                                               <reference key="children" ref="273418435"/>
+                                               <nil key="parent"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">-2</int>
+                                               <reference key="object" ref="355312334"/>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">File's Owner</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">-1</int>
+                                               <reference key="object" ref="844574444"/>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">First Responder</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">-3</int>
+                                               <reference key="object" ref="837220151"/>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">Application</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5</int>
+                                               <reference key="object" ref="616825745"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="49161063"/>
+                                               </object>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">PreviewPanel</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">6</int>
+                                               <reference key="object" ref="49161063"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="289177107"/>
+                                               </object>
+                                               <reference key="parent" ref="616825745"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">257</int>
+                                               <reference key="object" ref="289177107"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="844127024"/>
+                                                       <reference ref="92351498"/>
+                                                       <reference ref="768906858"/>
+                                                       <reference ref="48693112"/>
+                                               </object>
+                                               <reference key="parent" ref="49161063"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">252</int>
+                                               <reference key="object" ref="768906858"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="986015194"/>
+                                                       <reference ref="569473100"/>
+                                                       <reference ref="196868285"/>
+                                               </object>
+                                               <reference key="parent" ref="289177107"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">213</int>
+                                               <reference key="object" ref="196868285"/>
+                                               <reference key="parent" ref="768906858"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">223</int>
+                                               <reference key="object" ref="986015194"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="304208899"/>
+                                               </object>
+                                               <reference key="parent" ref="768906858"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">224</int>
+                                               <reference key="object" ref="304208899"/>
+                                               <reference key="parent" ref="986015194"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">251</int>
+                                               <reference key="object" ref="92351498"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="628196212"/>
+                                                       <reference ref="798240356"/>
+                                                       <reference ref="396925210"/>
+                                                       <reference ref="537831590"/>
+                                                       <reference ref="141370142"/>
+                                                       <reference ref="245200984"/>
+                                                       <reference ref="81685190"/>
+                                                       <reference ref="66510867"/>
+                                                       <reference ref="598619000"/>
+                                               </object>
+                                               <reference key="parent" ref="289177107"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">38</int>
+                                               <reference key="object" ref="628196212"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="921881842"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">215</int>
+                                               <reference key="object" ref="798240356"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="975305481"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">234</int>
+                                               <reference key="object" ref="66510867"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="567286013"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">226</int>
+                                               <reference key="object" ref="598619000"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="953108737"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">209</int>
+                                               <reference key="object" ref="396925210"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="639767004"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">210</int>
+                                               <reference key="object" ref="639767004"/>
+                                               <reference key="parent" ref="396925210"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">227</int>
+                                               <reference key="object" ref="953108737"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="501672847"/>
+                                               </object>
+                                               <reference key="parent" ref="598619000"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">228</int>
+                                               <reference key="object" ref="501672847"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="372655630"/>
+                                                       <reference ref="607756368"/>
+                                                       <reference ref="272743761"/>
+                                               </object>
+                                               <reference key="parent" ref="953108737"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">231</int>
+                                               <reference key="object" ref="372655630"/>
+                                               <reference key="parent" ref="501672847"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">230</int>
+                                               <reference key="object" ref="607756368"/>
+                                               <reference key="parent" ref="501672847"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">229</int>
+                                               <reference key="object" ref="272743761"/>
+                                               <reference key="parent" ref="501672847"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">235</int>
+                                               <reference key="object" ref="567286013"/>
+                                               <reference key="parent" ref="66510867"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">216</int>
+                                               <reference key="object" ref="975305481"/>
+                                               <reference key="parent" ref="798240356"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">165</int>
+                                               <reference key="object" ref="921881842"/>
+                                               <reference key="parent" ref="628196212"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">261</int>
+                                               <reference key="object" ref="569473100"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="908165435"/>
+                                               </object>
+                                               <reference key="parent" ref="768906858"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">262</int>
+                                               <reference key="object" ref="908165435"/>
+                                               <reference key="parent" ref="569473100"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">265</int>
+                                               <reference key="object" ref="537831590"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="29238952"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">266</int>
+                                               <reference key="object" ref="29238952"/>
+                                               <reference key="parent" ref="537831590"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">271</int>
+                                               <reference key="object" ref="141370142"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="606007744"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">272</int>
+                                               <reference key="object" ref="606007744"/>
+                                               <reference key="parent" ref="141370142"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">275</int>
+                                               <reference key="object" ref="81685190"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="847033897"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">276</int>
+                                               <reference key="object" ref="847033897"/>
+                                               <reference key="parent" ref="81685190"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">280</int>
+                                               <reference key="object" ref="245200984"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1032360651"/>
+                                               </object>
+                                               <reference key="parent" ref="92351498"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">281</int>
+                                               <reference key="object" ref="1032360651"/>
+                                               <reference key="parent" ref="245200984"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">179</int>
+                                               <reference key="object" ref="844127024"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="955430771"/>
+                                               </object>
+                                               <reference key="parent" ref="289177107"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">180</int>
+                                               <reference key="object" ref="955430771"/>
+                                               <reference key="parent" ref="844127024"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">207</int>
+                                               <reference key="object" ref="48693112"/>
+                                               <reference key="parent" ref="289177107"/>
+                                       </object>
+                               </object>
+                       </object>
+                       <object class="NSMutableDictionary" key="flattenedProperties">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="NSArray" key="dict.sortedKeys">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                       <string>-3.IBPluginDependency</string>
+                                       <string>-3.ImportedFromIB2</string>
+                                       <string>165.IBPluginDependency</string>
+                                       <string>179.IBPluginDependency</string>
+                                       <string>180.IBPluginDependency</string>
+                                       <string>207.IBPluginDependency</string>
+                                       <string>209.IBPluginDependency</string>
+                                       <string>210.IBPluginDependency</string>
+                                       <string>213.IBPluginDependency</string>
+                                       <string>215.IBPluginDependency</string>
+                                       <string>215.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>215.IBViewIntegration.shadowColor</string>
+                                       <string>215.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>215.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>216.IBPluginDependency</string>
+                                       <string>223.IBPluginDependency</string>
+                                       <string>224.IBPluginDependency</string>
+                                       <string>226.IBPluginDependency</string>
+                                       <string>226.ImportedFromIB2</string>
+                                       <string>227.IBPluginDependency</string>
+                                       <string>228.IBEditorWindowLastContentRect</string>
+                                       <string>228.IBPluginDependency</string>
+                                       <string>228.ImportedFromIB2</string>
+                                       <string>229.IBPluginDependency</string>
+                                       <string>229.ImportedFromIB2</string>
+                                       <string>230.IBPluginDependency</string>
+                                       <string>230.ImportedFromIB2</string>
+                                       <string>231.IBPluginDependency</string>
+                                       <string>231.ImportedFromIB2</string>
+                                       <string>234.IBPluginDependency</string>
+                                       <string>235.IBPluginDependency</string>
+                                       <string>251.IBPluginDependency</string>
+                                       <string>251.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>251.IBViewIntegration.shadowColor</string>
+                                       <string>251.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>251.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>252.IBPluginDependency</string>
+                                       <string>252.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>252.IBViewIntegration.shadowColor</string>
+                                       <string>252.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>252.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>257.IBPluginDependency</string>
+                                       <string>261.IBPluginDependency</string>
+                                       <string>262.IBPluginDependency</string>
+                                       <string>265.IBPluginDependency</string>
+                                       <string>265.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>265.IBViewIntegration.shadowColor</string>
+                                       <string>265.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>265.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>266.IBPluginDependency</string>
+                                       <string>271.IBPluginDependency</string>
+                                       <string>271.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>271.IBViewIntegration.shadowColor</string>
+                                       <string>271.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>271.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>272.IBPluginDependency</string>
+                                       <string>275.IBPluginDependency</string>
+                                       <string>275.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>275.IBViewIntegration.shadowColor</string>
+                                       <string>275.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>275.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>276.IBPluginDependency</string>
+                                       <string>280.IBPluginDependency</string>
+                                       <string>280.ImportedFromIB2</string>
+                                       <string>281.IBPluginDependency</string>
+                                       <string>38.IBPluginDependency</string>
+                                       <string>38.ImportedFromIB2</string>
+                                       <string>5.IBEditorWindowLastContentRect</string>
+                                       <string>5.IBPluginDependency</string>
+                                       <string>5.IBViewEditorWindowController.showingLayoutRectangles</string>
+                                       <string>5.IBWindowTemplateEditedContentRect</string>
+                                       <string>5.ImportedFromIB2</string>
+                                       <string>5.editorWindowContentRectSynchronizationRect</string>
+                                       <string>5.windowTemplate.hasMaxSize</string>
+                                       <string>5.windowTemplate.hasMinSize</string>
+                                       <string>5.windowTemplate.maxSize</string>
+                                       <string>5.windowTemplate.minSize</string>
+                                       <string>6.IBPluginDependency</string>
+                                       <string>6.ImportedFromIB2</string>
+                               </object>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.QTKitIBPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <object class="NSColor" id="864448722">
+                                               <int key="NSColorSpace">3</int>
+                                               <bytes key="NSWhite">MAA</bytes>
+                                       </object>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{656, 304}, {87, 48}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <reference ref="864448722"/>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <reference ref="864448722"/>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <reference ref="864448722"/>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <reference ref="864448722"/>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="0"/>
+                                       <reference ref="864448722"/>
+                                       <integer value="0"/>
+                                       <integer value="0"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>{{411, 519}, {480, 360}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <boolean value="NO"/>
+                                       <string>{{411, 519}, {480, 360}}</string>
+                                       <integer value="1"/>
+                                       <string>{{221, 276}, {533, 580}}</string>
+                                       <boolean value="NO"/>
+                                       <integer value="0"/>
+                                       <string>{3.40282e+38, 3.40282e+38}</string>
+                                       <string>{453, 550}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                               </object>
+                       </object>
+                       <object class="NSMutableDictionary" key="unlocalizedProperties">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <reference key="dict.sortedKeys" ref="0"/>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                               </object>
+                       </object>
+                       <nil key="activeLocalization"/>
+                       <object class="NSMutableDictionary" key="localizations">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <reference key="dict.sortedKeys" ref="0"/>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                               </object>
+                       </object>
+                       <nil key="sourceID"/>
+                       <int key="maxID">282</int>
+               </object>
+               <object class="IBClassDescriber" key="IBDocument.Classes">
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">FirstResponder</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBUserSource</string>
+                                               <string key="minorKey"/>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSBox</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBUserSource</string>
+                                               <string key="minorKey"/>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBUserSource</string>
+                                               <string key="minorKey"/>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">PreviewController</string>
+                                       <string key="superclassName">NSWindowController</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="NSArray" key="dict.sortedKeys">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>SettingsChanged:</string>
+                                                       <string>createMoviePreview:</string>
+                                                       <string>goFullScreen:</string>
+                                                       <string>goWindowedScreen:</string>
+                                                       <string>pictureSliderChanged:</string>
+                                                       <string>previewDurationPopUpChanged:</string>
+                                                       <string>showMoviePreview:</string>
+                                                       <string>showPictureSettings:</string>
+                                                       <string>showPreviewWindow:</string>
+                                                       <string>toggleScaleToScreen:</string>
+                                                       <string>toggleScreenMode:</string>
+                                               </object>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>NSString</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                               </object>
+                                       </object>
+                                       <object class="NSMutableDictionary" key="outlets">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="NSArray" key="dict.sortedKeys">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>fCancelPreviewMovieButton</string>
+                                                       <string>fCreatePreviewMovieButton</string>
+                                                       <string>fEncodingControlBox</string>
+                                                       <string>fFullScreenToggleButton</string>
+                                                       <string>fInfoField</string>
+                                                       <string>fMovieCreationProgressIndicator</string>
+                                                       <string>fMovieView</string>
+                                                       <string>fPictureControlBox</string>
+                                                       <string>fPictureSettingsToggleButton</string>
+                                                       <string>fPictureSlider</string>
+                                                       <string>fPictureView</string>
+                                                       <string>fPictureViewArea</string>
+                                                       <string>fPreviewMovieLengthPopUp</string>
+                                                       <string>fPreviewMovieStatusField</string>
+                                                       <string>fPreviewWindow</string>
+                                                       <string>fScaleToScreenToggleButton</string>
+                                                       <string>fShowPreviewMovieButton</string>
+                                                       <string>fscaleInfoField</string>
+                                               </object>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>NSButton</string>
+                                                       <string>NSButton</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSButton</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSProgressIndicator</string>
+                                                       <string>QTMovieView</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSButton</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSImageView</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSPopUpButton</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSWindow</string>
+                                                       <string>NSButton</string>
+                                                       <string>NSButton</string>
+                                                       <string>NSTextField</string>
+                                               </object>
+                                       </object>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBProjectSource</string>
+                                               <string key="minorKey">HBPreviewController.h</string>
+                                       </object>
+                               </object>
+                       </object>
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSActionCell</string>
+                                       <string key="superclassName">NSCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="852395521">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1064118338">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="21201792">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSBox</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSBox.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButton</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButtonCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSCell</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSControl</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="459245493">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSControl.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSFormatter</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSImageCell</string>
+                                       <string key="superclassName">NSCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSImageCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSImageView</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSImageView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenu</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="533344225">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItem</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="225291440">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItemCell</string>
+                                       <string key="superclassName">NSButtonCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItemCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="852395521"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="1064118338"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="21201792"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="459245493"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="533344225"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="865317367">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="386772046">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="79748535">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Growl.framework/Headers/GrowlApplicationBridge.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKImageBrowserView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKSaveOptions.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/ImageKitDeprecated.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFDocument.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedAudioOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedVideoOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureFileOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureVideoPreviewOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovie.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="68262679">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovieView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionParameterView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionPickerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzFilters.framework/Headers/QuartzFilterManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuickLookUI.framework/Headers/QLPreviewPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUAppcast.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUUpdater.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPanel</string>
+                                       <string key="superclassName">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButton</string>
+                                       <string key="superclassName">NSButton</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButtonCell</string>
+                                       <string key="superclassName">NSMenuItemCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSProgressIndicator</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSProgressIndicator.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSSlider</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSlider.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSSliderCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSliderCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSString</string>
+                                       <reference key="sourceIdentifier" ref="865317367"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSString</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSStringDrawing.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSString</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSPathUtilities.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSString</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSString.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSString</string>
+                                       <reference key="sourceIdentifier" ref="79748535"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextField</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextFieldCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <reference key="sourceIdentifier" ref="225291440"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <reference key="sourceIdentifier" ref="386772046"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindowController</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <string key="NS.key.0">showWindow:</string>
+                                               <string key="NS.object.0">id</string>
+                                       </object>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">QTMovieView</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="NSArray" key="dict.sortedKeys">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>add:</string>
+                                                       <string>addScaled:</string>
+                                                       <string>copy:</string>
+                                                       <string>cut:</string>
+                                                       <string>delete:</string>
+                                                       <string>gotoBeginning:</string>
+                                                       <string>gotoEnd:</string>
+                                                       <string>gotoNextSelectionPoint:</string>
+                                                       <string>gotoPosterFrame:</string>
+                                                       <string>gotoPreviousSelectionPoint:</string>
+                                                       <string>paste:</string>
+                                                       <string>pause:</string>
+                                                       <string>play:</string>
+                                                       <string>replace:</string>
+                                                       <string>selectAll:</string>
+                                                       <string>selectNone:</string>
+                                                       <string>stepBackward:</string>
+                                                       <string>stepForward:</string>
+                                                       <string>trim:</string>
+                                               </object>
+                                               <object class="NSMutableArray" key="dict.values">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                               </object>
+                                       </object>
+                                       <reference key="sourceIdentifier" ref="68262679"/>
+                               </object>
+                       </object>
+               </object>
+               <int key="IBDocument.localizationMode">0</int>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+                       <integer value="1050" key="NS.object.0"/>
+               </object>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
+                       <integer value="3000" key="NS.object.0"/>
+               </object>
+               <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+               <string key="IBDocument.LastKnownRelativeProjectPath">../HandBrake.xcodeproj</string>
+               <int key="IBDocument.defaultPropertyAccessControl">3</int>
+       </data>
+</archive>
index aa3cd14..2630cee 100644 (file)
@@ -1,19 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9F33</string>
-               <string key="IBDocument.InterfaceBuilderVersion">670</string>
-               <string key="IBDocument.AppKitVersion">949.34</string>
-               <string key="IBDocument.HIToolboxVersion">352.00</string>
+               <string key="IBDocument.SystemVersion">9G55</string>
+               <string key="IBDocument.InterfaceBuilderVersion">677</string>
+               <string key="IBDocument.AppKitVersion">949.43</string>
+               <string key="IBDocument.HIToolboxVersion">353.00</string>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
-                       <integer value="23"/>
+                       <integer value="436"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
                <object class="NSMutableArray" key="IBDocument.RootObjects" id="273418435">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <object class="NSCustomObject" id="355312334">
                                <string key="NSClassName">NSApplication</string>
                        </object>
                        <object class="NSWindowTemplate" id="616825745">
-                               <int key="NSWindowStyleMask">1</int>
+                               <int key="NSWindowStyleMask">8215</int>
                                <int key="NSWindowBacking">2</int>
-                               <string key="NSWindowRect">{{482, 298}, {453, 558}}</string>
-                               <int key="NSWTFlags">1886912512</int>
+                               <string key="NSWindowRect">{{63, 414}, {849, 399}}</string>
+                               <int key="NSWTFlags">-260570112</int>
                                <string key="NSWindowTitle">Picture Settings</string>
                                <string key="NSWindowClass">NSPanel</string>
                                <object class="NSMutableString" key="NSViewClass">
                                        <characters key="NS.bytes">View</characters>
                                </object>
                                <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
-                               <string key="NSWindowContentMinSize">{453, 558}</string>
                                <object class="NSView" key="NSWindowView" id="49161063">
                                        <reference key="NSNextResponder"/>
                                        <int key="NSvFlags">256</int>
                                        <object class="NSMutableArray" key="NSSubviews">
                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                               <object class="NSButton" id="41752677">
+                                               <object class="NSTextField" id="922381307">
                                                        <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">289</int>
-                                                       <string key="NSFrame">{{346, 58}, {92, 28}}</string>
+                                                       <int key="NSvFlags">256</int>
+                                                       <string key="NSFrame">{{19, 474}, {55, 17}}</string>
                                                        <reference key="NSSuperview" ref="49161063"/>
                                                        <bool key="NSEnabled">YES</bool>
-                                                       <object class="NSButtonCell" key="NSCell" id="785935474">
+                                                       <object class="NSTextFieldCell" key="NSCell" id="1037100053">
                                                                <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">134348800</int>
-                                                               <string key="NSContents">Next</string>
+                                                               <int key="NSCellFlags2">4194304</int>
+                                                               <string key="NSContents">Size</string>
                                                                <object class="NSFont" key="NSSupport" id="26">
                                                                        <string key="NSName">LucidaGrande</string>
                                                                        <double key="NSSize">1.100000e+01</double>
                                                                        <int key="NSfFlags">3100</int>
                                                                </object>
-                                                               <reference key="NSControlView" ref="41752677"/>
-                                                               <int key="NSButtonFlags">-2038284033</int>
-                                                               <int key="NSButtonFlags2">1</int>
-                                                               <object class="NSFont" key="NSAlternateImage" id="687090323">
-                                                                       <string key="NSName">LucidaGrande</string>
-                                                                       <double key="NSSize">1.100000e+01</double>
-                                                                       <int key="NSfFlags">16</int>
+                                                               <reference key="NSControlView" ref="922381307"/>
+                                                               <object class="NSColor" key="NSBackgroundColor" id="407686733">
+                                                                       <int key="NSColorSpace">6</int>
+                                                                       <string key="NSCatalogName">System</string>
+                                                                       <string key="NSColorName">controlColor</string>
+                                                                       <object class="NSColor" key="NSColor">
+                                                                               <int key="NSColorSpace">3</int>
+                                                                               <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+                                                                       </object>
                                                                </object>
-                                                               <string key="NSAlternateContents"/>
-                                                               <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                       <characters key="NS.bytes"/>
+                                                               <object class="NSColor" key="NSTextColor">
+                                                                       <int key="NSColorSpace">1</int>
+                                                                       <bytes key="NSRGB">MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA</bytes>
                                                                </object>
-                                                               <int key="NSPeriodicDelay">200</int>
-                                                               <int key="NSPeriodicInterval">25</int>
                                                        </object>
                                                </object>
-                                               <object class="NSButton" id="862464620">
+                                               <object class="NSButton" id="892118626">
                                                        <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">289</int>
-                                                       <string key="NSFrame">{{241, 59}, {101, 28}}</string>
+                                                       <int key="NSvFlags">268</int>
+                                                       <string key="NSFrame">{{19, 373}, {57, 25}}</string>
                                                        <reference key="NSSuperview" ref="49161063"/>
+                                                       <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                               <object class="CIColorMonochrome">
+                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                               <float key="red">7.019608e-01</float>
+                                                                               <float key="green">7.019608e-01</float>
+                                                                               <float key="blue">7.019608e-01</float>
+                                                                               <float key="alpha">1.000000e+00</float>
+                                                                       </object>
+                                                                       <real value="1.000000e+00" key="CI_inputIntensity" id="559925184"/>
+                                                                       <bool key="CIEnabled">YES</bool>
+                                                               </object>
+                                                       </object>
                                                        <bool key="NSEnabled">YES</bool>
-                                                       <object class="NSButtonCell" key="NSCell" id="212457967">
+                                                       <object class="NSButtonCell" key="NSCell" id="533593716">
                                                                <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">134348800</int>
-                                                               <string key="NSContents">Previous</string>
-                                                               <reference key="NSSupport" ref="26"/>
-                                                               <reference key="NSControlView" ref="862464620"/>
+                                                               <int key="NSCellFlags2">134479872</int>
+                                                               <string key="NSContents">Preview</string>
+                                                               <object class="NSFont" key="NSSupport" id="22">
+                                                                       <string key="NSName">LucidaGrande</string>
+                                                                       <double key="NSSize">9.000000e+00</double>
+                                                                       <int key="NSfFlags">3614</int>
+                                                               </object>
+                                                               <reference key="NSControlView" ref="892118626"/>
                                                                <int key="NSButtonFlags">-2038284033</int>
-                                                               <int key="NSButtonFlags2">1</int>
-                                                               <reference key="NSAlternateImage" ref="687090323"/>
+                                                               <int key="NSButtonFlags2">163</int>
                                                                <string key="NSAlternateContents"/>
-                                                               <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                       <characters key="NS.bytes"/>
-                                                               </object>
+                                                               <string key="NSKeyEquivalent"/>
                                                                <int key="NSPeriodicDelay">200</int>
                                                                <int key="NSPeriodicInterval">25</int>
                                                        </object>
                                                </object>
-                                               <object class="NSBox" id="574970834">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">290</int>
-                                                       <string key="NSFrame">{{20, 58}, {413, 5}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <string key="NSOffsets">{0, 0}</string>
-                                                       <object class="NSTextFieldCell" key="NSTitleCell">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">0</int>
-                                                               <string key="NSContents">Box</string>
-                                                               <object class="NSFont" key="NSSupport" id="1003998324">
-                                                                       <string key="NSName">LucidaGrande</string>
-                                                                       <double key="NSSize">1.300000e+01</double>
-                                                                       <int key="NSfFlags">1044</int>
-                                                               </object>
-                                                               <object class="NSColor" key="NSBackgroundColor" id="406287577">
-                                                                       <int key="NSColorSpace">6</int>
-                                                                       <string key="NSCatalogName">System</string>
-                                                                       <string key="NSColorName">textBackgroundColor</string>
-                                                                       <object class="NSColor" key="NSColor" id="45357611">
-                                                                               <int key="NSColorSpace">3</int>
-                                                                               <bytes key="NSWhite">MQA</bytes>
-                                                                       </object>
-                                                               </object>
-                                                               <object class="NSColor" key="NSTextColor">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-                                                               </object>
-                                                       </object>
-                                                       <int key="NSBorderType">3</int>
-                                                       <int key="NSBoxType">2</int>
-                                                       <int key="NSTitlePosition">0</int>
-                                                       <bool key="NSTransparent">NO</bool>
-                                               </object>
-                                               <object class="NSTextField" id="628196212">
+                                               <object class="NSTextField" id="154029488">
                                                        <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">290</int>
-                                                       <string key="NSFrame">{{17, 22}, {320, 17}}</string>
+                                                       <int key="NSvFlags">292</int>
+                                                       <string key="NSFrame">{{18, 6}, {425, 19}}</string>
                                                        <reference key="NSSuperview" ref="49161063"/>
                                                        <bool key="NSEnabled">YES</bool>
-                                                       <object class="NSTextFieldCell" key="NSCell" id="921881842">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">4194304</int>
+                                                       <object class="NSTextFieldCell" key="NSCell" id="63504302">
+                                                               <int key="NSCellFlags">-2079195584</int>
+                                                               <int key="NSCellFlags2">4457472</int>
                                                                <string key="NSContents"/>
-                                                               <reference key="NSSupport" ref="1003998324"/>
-                                                               <reference key="NSControlView" ref="628196212"/>
-                                                               <object class="NSColor" key="NSBackgroundColor" id="407686733">
-                                                                       <int key="NSColorSpace">6</int>
-                                                                       <string key="NSCatalogName">System</string>
-                                                                       <string key="NSColorName">controlColor</string>
-                                                                       <object class="NSColor" key="NSColor">
-                                                                               <int key="NSColorSpace">3</int>
-                                                                               <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
-                                                                       </object>
+                                                               <reference key="NSSupport" ref="22"/>
+                                                               <reference key="NSControlView" ref="154029488"/>
+                                                               <object class="NSColor" key="NSBackgroundColor">
+                                                                       <int key="NSColorSpace">1</int>
+                                                                       <bytes key="NSRGB">MC4yIDAuMiAwLjIAA</bytes>
                                                                </object>
-                                                               <object class="NSColor" key="NSTextColor" id="1053668690">
-                                                                       <int key="NSColorSpace">6</int>
-                                                                       <string key="NSCatalogName">System</string>
-                                                                       <string key="NSColorName">controlTextColor</string>
-                                                                       <object class="NSColor" key="NSColor" id="590886446">
-                                                                               <int key="NSColorSpace">3</int>
-                                                                               <bytes key="NSWhite">MAA</bytes>
-                                                                       </object>
+                                                               <object class="NSColor" key="NSTextColor" id="852384715">
+                                                                       <int key="NSColorSpace">1</int>
+                                                                       <bytes key="NSRGB">MSAxIDEAA</bytes>
                                                                </object>
                                                        </object>
                                                </object>
-                                               <object class="NSButton" id="345100891">
+                                               <object class="NSTabView" id="570027662">
                                                        <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">289</int>
-                                                       <string key="NSFrame">{{339, 12}, {100, 32}}</string>
+                                                       <int key="NSvFlags">18</int>
+                                                       <string key="NSFrame">{{15, 19}, {821, 362}}</string>
                                                        <reference key="NSSuperview" ref="49161063"/>
-                                                       <bool key="NSEnabled">YES</bool>
-                                                       <object class="NSButtonCell" key="NSCell" id="352183359">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">134217728</int>
-                                                               <string key="NSContents">Close</string>
-                                                               <reference key="NSSupport" ref="1003998324"/>
-                                                               <reference key="NSControlView" ref="345100891"/>
-                                                               <int key="NSButtonFlags">-2038284033</int>
-                                                               <int key="NSButtonFlags2">1</int>
-                                                               <reference key="NSAlternateImage" ref="1003998324"/>
-                                                               <string key="NSAlternateContents"/>
-                                                               <string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
-                                                               <int key="NSPeriodicDelay">200</int>
-                                                               <int key="NSPeriodicInterval">25</int>
+                                                       <object class="NSArray" key="NSViewContentFilters">
+                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                               <object class="CIColorMonochrome">
+                                                                       <object class="CIColor" key="CI_inputColor">
+                                                                               <float key="red">7.019608e-01</float>
+                                                                               <float key="green">7.019608e-01</float>
+                                                                               <float key="blue">7.019608e-01</float>
+                                                                               <float key="alpha">1.000000e+00</float>
+                                                                       </object>
+                                                                       <real value="1.000000e+00" key="CI_inputIntensity"/>
+                                                                       <bool key="CIEnabled">YES</bool>
+                                                               </object>
                                                        </object>
-                                               </object>
-                                               <object class="NSBox" id="1064912113">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">265</int>
-                                                       <object class="NSMutableArray" key="NSSubviews">
+                                                       <object class="NSMutableArray" key="NSTabViewItems">
                                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <object class="NSView" id="114416973">
-                                                                       <reference key="NSNextResponder" ref="1064912113"/>
-                                                                       <int key="NSvFlags">256</int>
-                                                                       <object class="NSMutableArray" key="NSSubviews">
-                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                               <object class="NSStepper" id="580805308">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{112, 65}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="44321990">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="580805308"/>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">2.000000e+00</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSStepper" id="510144318">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{155, 35}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="759792686">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="510144318"/>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">2.000000e+00</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSMatrix" id="1032624817">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{18, 96}, {77, 40}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <int key="NSNumRows">2</int>
-                                                                                       <int key="NSNumCols">1</int>
-                                                                                       <object class="NSMutableArray" key="NSCells">
-                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                               <object class="NSButtonCell" id="660067650">
-                                                                                                       <int key="NSCellFlags">-2080244224</int>
-                                                                                                       <int key="NSCellFlags2">131072</int>
-                                                                                                       <string key="NSContents">Automatic</string>
-                                                                                                       <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1032624817"/>
-                                                                                                       <int key="NSButtonFlags">1211912703</int>
-                                                                                                       <int key="NSButtonFlags2">0</int>
-                                                                                                       <object class="NSButtonImageSource" key="NSAlternateImage" id="216523553">
-                                                                                                               <string key="NSImageName">NSRadioButton</string>
-                                                                                                       </object>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                               <characters key="NS.bytes"/>
+                                                               <object class="NSTabViewItem" id="184512336">
+                                                                       <string key="NSIdentifier">1</string>
+                                                                       <object class="NSView" key="NSView" id="490590002">
+                                                                               <reference key="NSNextResponder" ref="570027662"/>
+                                                                               <int key="NSvFlags">256</int>
+                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                       <object class="NSBox" id="291242569">
+                                                                                               <reference key="NSNextResponder" ref="490590002"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="93103015">
+                                                                                                               <reference key="NSNextResponder" ref="291242569"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSTextField" id="84657333">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                               <string key="NSFrame">{{203, 93}, {82, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="752977354">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">Display Width:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="84657333"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="924352608">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{289, 93}, {61, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="617679053">
+                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="924352608"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <object class="NSColor" key="NSBackgroundColor">
+                                                                                                                                               <int key="NSColorSpace">1</int>
+                                                                                                                                               <bytes key="NSRGB">MC4yIDAuMiAwLjIAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="998049160">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{446, 94}, {37, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="564975975">
+                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="998049160"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <object class="NSColor" key="NSBackgroundColor">
+                                                                                                                                               <int key="NSColorSpace">1</int>
+                                                                                                                                               <bytes key="NSRGB">MC4yIDAuMiAwLjIAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="601215307">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{446, 52}, {37, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="119145016">
+                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="601215307"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <object class="NSColor" key="NSBackgroundColor">
+                                                                                                                                               <int key="NSColorSpace">1</int>
+                                                                                                                                               <bytes key="NSRGB">MC4yIDAuMiAwLjIAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="122509689">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                               <string key="NSFrame">{{375, 94}, {67, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="486553162">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">PAR Width:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="122509689"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="810439401">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                               <string key="NSFrame">{{370, 52}, {71, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="134407475">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">PAR Height:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="810439401"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSStepper" id="221469578">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{155, 90}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="714433793">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="221469578"/>
+                                                                                                                                       <double key="NSValue">6.400000e+01</double>
+                                                                                                                                       <double key="NSMinValue">6.400000e+01</double>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">1.600000e+01</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSPopUpButton" id="387637584">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{91, 9}, {46, 15}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <real value="1.000000e+00" key="CI_inputIntensity" id="484376035"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="800808932">
+                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="387637584"/>
+                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="588147075">
+                                                                                                                                               <reference key="NSMenu" ref="246883325"/>
+                                                                                                                                               <string key="NSTitle">16</string>
+                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                               <object class="NSCustomResource" key="NSOnImage" id="279874594">
+                                                                                                                                                       <string key="NSClassName">NSImage</string>
+                                                                                                                                                       <string key="NSResourceName">NSMenuCheckmark</string>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSCustomResource" key="NSMixedImage" id="300720659">
+                                                                                                                                                       <string key="NSClassName">NSImage</string>
+                                                                                                                                                       <string key="NSResourceName">NSMenuMixedState</string>
+                                                                                                                                               </object>
+                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                               <reference key="NSTarget" ref="800808932"/>
+                                                                                                                                       </object>
+                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                       <object class="NSMenu" key="NSMenu" id="246883325">
+                                                                                                                                               <string key="NSTitle">OtherViews</string>
+                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <reference ref="588147075"/>
+                                                                                                                                                       <object class="NSMenuItem" id="940982828">
+                                                                                                                                                               <reference key="NSMenu" ref="246883325"/>
+                                                                                                                                                               <string key="NSTitle">8</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="800808932"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSMenuItem" id="765075061">
+                                                                                                                                                               <reference key="NSMenu" ref="246883325"/>
+                                                                                                                                                               <string key="NSTitle">4</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="800808932"/>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPreferredEdge">1</int>
+                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                       <int key="NSArrowPosition">2</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="232869468">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{91, 95}, {62, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="96315080">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="232869468"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <object class="NSColor" key="NSBackgroundColor" id="501609908">
+                                                                                                                                               <int key="NSColorSpace">1</int>
+                                                                                                                                               <bytes key="NSRGB">MC4yIDAuMiAwLjIAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSStepper" id="667015191">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{155, 49}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="634499157">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="667015191"/>
+                                                                                                                                       <double key="NSValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSMinValue">6.400000e+01</double>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">1.600000e+01</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="301555397">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{10, 31}, {73, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="926890760">
+                                                                                                                                       <int key="NSCellFlags">67239488</int>
+                                                                                                                                       <int key="NSCellFlags2">71435264</int>
+                                                                                                                                       <string key="NSContents">Anamorphic:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="301555397"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="513894170">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{28, 55}, {55, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="863668536">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">Height:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="513894170"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSPopUpButton" id="147098438">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{90, 30}, {80, 15}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="261514411">
+                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="147098438"/>
+                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="85032843">
+                                                                                                                                               <reference key="NSMenu" ref="577969360"/>
+                                                                                                                                               <string key="NSTitle">Item 1</string>
+                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                               <reference key="NSTarget" ref="261514411"/>
+                                                                                                                                       </object>
+                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                       <object class="NSMenu" key="NSMenu" id="577969360">
+                                                                                                                                               <string key="NSTitle">OtherViews</string>
+                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <reference ref="85032843"/>
+                                                                                                                                                       <object class="NSMenuItem" id="804424712">
+                                                                                                                                                               <reference key="NSMenu" ref="577969360"/>
+                                                                                                                                                               <string key="NSTitle">Item 2</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="261514411"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSMenuItem" id="1018195923">
+                                                                                                                                                               <reference key="NSMenu" ref="577969360"/>
+                                                                                                                                                               <string key="NSTitle">Item 3</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="261514411"/>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPreferredEdge">1</int>
+                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                       <int key="NSArrowPosition">2</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="902766107">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{10, 10}, {73, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="377264474">
+                                                                                                                                       <int key="NSCellFlags">67239488</int>
+                                                                                                                                       <int key="NSCellFlags2">71435264</int>
+                                                                                                                                       <string key="NSContents">Modulus:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="902766107"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="569671425">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{0, 95}, {82, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="412868245">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">Width:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="569671425"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="443002022">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{91, 52}, {62, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="649389918">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="443002022"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="501609908"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSButton" id="302614967">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{153, 71}, {18, 18}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSButtonCell" key="NSCell" id="595088069">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">67239936</int>
+                                                                                                                                       <string key="NSContents">Keep aspect ratio:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="302614967"/>
+                                                                                                                                       <int key="NSButtonFlags">1210864127</int>
+                                                                                                                                       <int key="NSButtonFlags2">2</int>
+                                                                                                                                       <object class="NSButtonImageSource" key="NSAlternateImage" id="998385597">
+                                                                                                                                               <string key="NSImageName">NSSwitch</string>
+                                                                                                                                       </object>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                                                       <int key="NSPeriodicInterval">25</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="973216726">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{32, 73}, {123, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="910777593">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">Keep Aspect Ratio:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="973216726"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="231562326">
+                                                                                                                               <reference key="NSNextResponder" ref="93103015"/>
+                                                                                                                               <int key="NSvFlags">292</int>
+                                                                                                                               <string key="NSFrame">{{173, 53}, {112, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="93103015"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="87951024">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71434240</int>
+                                                                                                                                       <string key="NSContents">Keep Aspect Ratio:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="231562326"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <string key="NSFrame">{{1, 1}, {511, 124}}</string>
+                                                                                                               <reference key="NSSuperview" ref="291242569"/>
                                                                                                        </object>
-                                                                                                       <int key="NSPeriodicDelay">200</int>
-                                                                                                       <int key="NSPeriodicInterval">25</int>
                                                                                                </object>
-                                                                                               <object class="NSButtonCell" id="288116155">
+                                                                                               <string key="NSFrame">{{0, 202}, {513, 126}}</string>
+                                                                                               <reference key="NSSuperview" ref="490590002"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
                                                                                                        <int key="NSCellFlags">67239424</int>
-                                                                                                       <int key="NSCellFlags2">131072</int>
-                                                                                                       <string key="NSContents">Custom:</string>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents">Box</string>
                                                                                                        <reference key="NSSupport" ref="26"/>
-                                                                                                       <reference key="NSControlView" ref="1032624817"/>
-                                                                                                       <int key="NSButtonFlags">1211912703</int>
-                                                                                                       <int key="NSButtonFlags2">0</int>
-                                                                                                       <reference key="NSAlternateImage" ref="216523553"/>
-                                                                                                       <string key="NSAlternateContents"/>
-                                                                                                       <string key="NSKeyEquivalent"/>
-                                                                                                       <int key="NSPeriodicDelay">400</int>
-                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                       <object class="NSColor" key="NSBackgroundColor" id="406287577">
+                                                                                                               <int key="NSColorSpace">6</int>
+                                                                                                               <string key="NSCatalogName">System</string>
+                                                                                                               <string key="NSColorName">textBackgroundColor</string>
+                                                                                                               <object class="NSColor" key="NSColor" id="45357611">
+                                                                                                                       <int key="NSColorSpace">3</int>
+                                                                                                                       <bytes key="NSWhite">MQA</bytes>
+                                                                                                               </object>
+                                                                                                       </object>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                       </object>
                                                                                                </object>
+                                                                                               <reference key="NSContentView" ref="93103015"/>
+                                                                                               <int key="NSBorderType">1</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
-                                                                                       <string key="NSCellSize">{77, 18}</string>
-                                                                                       <string key="NSIntercellSpacing">{4, 4}</string>
-                                                                                       <int key="NSMatrixFlags">1143472128</int>
-                                                                                       <string key="NSCellClass">NSActionCell</string>
-                                                                                       <object class="NSButtonCell" key="NSProtoCell" id="643930266">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <string key="NSContents">Radio</string>
-                                                                                               <reference key="NSSupport" ref="1003998324"/>
-                                                                                               <int key="NSButtonFlags">1211912703</int>
-                                                                                               <int key="NSButtonFlags2">0</int>
-                                                                                               <object class="NSImage" key="NSNormalImage">
-                                                                                                       <int key="NSImageFlags">549453824</int>
-                                                                                                       <string key="NSSize">{18, 18}</string>
-                                                                                                       <object class="NSMutableArray" key="NSReps">
-                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                               <object class="NSArray">
+                                                                                       <object class="NSBox" id="1064912113">
+                                                                                               <reference key="NSNextResponder" ref="490590002"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="114416973">
+                                                                                                               <reference key="NSNextResponder" ref="1064912113"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
                                                                                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                                       <integer value="0" id="8"/>
-                                                                                                                       <object class="NSBitmapImageRep">
-                                                                                                                               <object class="NSData" key="NSTIFFRepresentation">
-                                                                                                                                       <bytes key="NS.bytes">TU0AKgAABRgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAA
+                                                                                                                       <object class="NSStepper" id="580805308">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{165, 53}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <object class="NSArray" key="NSViewBackgroundFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">6.000000e-01</float>
+                                                                                                                                                       <float key="green">4.500000e-01</float>
+                                                                                                                                                       <float key="blue">3.000000e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="44321990">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="580805308"/>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">2.000000e+00</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSStepper" id="510144318">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{251, 41}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="759792686">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="510144318"/>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">2.000000e+00</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSMatrix" id="1032624817">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{76, 88}, {20, 24}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <int key="NSNumRows">2</int>
+                                                                                                                               <int key="NSNumCols">1</int>
+                                                                                                                               <object class="NSMutableArray" key="NSCells">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="NSButtonCell" id="660067650">
+                                                                                                                                               <int key="NSCellFlags">-2080244224</int>
+                                                                                                                                               <int key="NSCellFlags2">262144</int>
+                                                                                                                                               <string key="NSContents">Automatic</string>
+                                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                                               <reference key="NSControlView" ref="1032624817"/>
+                                                                                                                                               <int key="NSButtonFlags">1211912703</int>
+                                                                                                                                               <int key="NSButtonFlags2">0</int>
+                                                                                                                                               <object class="NSButtonImageSource" key="NSAlternateImage" id="216523553">
+                                                                                                                                                       <string key="NSImageName">NSRadioButton</string>
+                                                                                                                                               </object>
+                                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                                               <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                                                                                                       <characters key="NS.bytes"/>
+                                                                                                                                               </object>
+                                                                                                                                               <int key="NSPeriodicDelay">200</int>
+                                                                                                                                               <int key="NSPeriodicInterval">25</int>
+                                                                                                                                       </object>
+                                                                                                                                       <object class="NSButtonCell" id="288116155">
+                                                                                                                                               <int key="NSCellFlags">67239424</int>
+                                                                                                                                               <int key="NSCellFlags2">262144</int>
+                                                                                                                                               <string key="NSContents">Custom:</string>
+                                                                                                                                               <reference key="NSSupport" ref="22"/>
+                                                                                                                                               <reference key="NSControlView" ref="1032624817"/>
+                                                                                                                                               <int key="NSButtonFlags">1211912703</int>
+                                                                                                                                               <int key="NSButtonFlags2">0</int>
+                                                                                                                                               <reference key="NSAlternateImage" ref="216523553"/>
+                                                                                                                                               <string key="NSAlternateContents"/>
+                                                                                                                                               <string key="NSKeyEquivalent"/>
+                                                                                                                                               <int key="NSPeriodicDelay">400</int>
+                                                                                                                                               <int key="NSPeriodicInterval">75</int>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <string key="NSCellSize">{20, 11}</string>
+                                                                                                                               <string key="NSIntercellSpacing">{4, 2}</string>
+                                                                                                                               <int key="NSMatrixFlags">1143480320</int>
+                                                                                                                               <string key="NSCellClass">NSActionCell</string>
+                                                                                                                               <object class="NSButtonCell" key="NSProtoCell" id="643930266">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">262144</int>
+                                                                                                                                       <string key="NSContents">Radio</string>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <int key="NSButtonFlags">1211912703</int>
+                                                                                                                                       <int key="NSButtonFlags2">0</int>
+                                                                                                                                       <object class="NSImage" key="NSNormalImage">
+                                                                                                                                               <int key="NSImageFlags">549453824</int>
+                                                                                                                                               <string key="NSSize">{18, 18}</string>
+                                                                                                                                               <object class="NSMutableArray" key="NSReps">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <object class="NSArray">
+                                                                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                               <integer value="0" id="8"/>
+                                                                                                                                                               <object class="NSBitmapImageRep">
+                                                                                                                                                                       <object class="NSData" key="NSTIFFRepresentation">
+                                                                                                                                                                               <bytes key="NS.bytes">TU0AKgAABRgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAA
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAADwRERGLJycnySsrK/A1NTXw
 IyMjyRwcHIsJCQk8AAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFFRUVdVBQUOCoqKj/
 29vb//n5+f/6+vr/2tra/6qqqv9UVFTgHx8fdQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUZGRl5
@@ -377,839 +952,1212 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 AABtbHVjAAAAAAAAAAIAAAAMZW5VUwAAABIAAAAoaXRJVAAAABQAAAA6AEMAbwBsAG8AcgAgAEwAQwBE
 AEwAQwBEACAAYwBvAGwAbwByAGkAAG1tb2QAAAAAAAAGEAAAnGgAAAAAwhEOAAAAAAAAAAAAAAAAAAAA
 AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
+                                                                                                                                                                       </object>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSColor" key="NSColor">
+                                                                                                                                                       <int key="NSColorSpace">3</int>
+                                                                                                                                                       <bytes key="NSWhite">MCAwAA</bytes>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSAlternateImage" ref="216523553"/>
+                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSSelectedCell" ref="660067650"/>
+                                                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                               <reference key="NSCellBackgroundColor" ref="45357611"/>
+                                                                                                                               <object class="NSFont" key="NSFont">
+                                                                                                                                       <string key="NSName">LucidaGrande</string>
+                                                                                                                                       <double key="NSSize">1.300000e+01</double>
+                                                                                                                                       <int key="NSfFlags">1044</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="897162141">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{107, 54}, {56, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="936113070">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="897162141"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="501609908"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="773085513">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{107, 27}, {56, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="634956024">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="773085513"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="501609908"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSStepper" id="1067684983">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{79, 38}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="996643427">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="1067684983"/>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">2.000000e+00</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="411931143">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{189, 44}, {56, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="1050606643">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="411931143"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="501609908"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="842452881">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{18, 41}, {56, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="904241294">
+                                                                                                                                       <int key="NSCellFlags">-2075001280</int>
+                                                                                                                                       <int key="NSCellFlags2">4457472</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="842452881"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="501609908"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSStepper" id="133033963">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{166, 25}, {15, 22}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="559925184"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSStepperCell" key="NSCell" id="71578223">
+                                                                                                                                       <int key="NSCellFlags">68025888</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="133033963"/>
+                                                                                                                                       <double key="NSMaxValue">5.900000e+01</double>
+                                                                                                                                       <double key="NSIncrement">2.000000e+00</double>
+                                                                                                                                       <bool key="NSAutorepeat">YES</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="1021399174">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{97, 102}, {68, 11}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="215687429">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">4456448</int>
+                                                                                                                                       <string key="NSContents">Automatic</string>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="1021399174"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="194145642">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{97, 88}, {68, 11}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="664940567">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">4456448</int>
+                                                                                                                                       <string key="NSContents">Custom</string>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="194145642"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="294892452">
+                                                                                                                               <reference key="NSNextResponder" ref="114416973"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{12, 98}, {59, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="114416973"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="511041238">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Cropping:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="294892452"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
                                                                                                                                </object>
                                                                                                                        </object>
                                                                                                                </object>
+                                                                                                               <string key="NSFrame">{{1, 1}, {282, 124}}</string>
+                                                                                                               <reference key="NSSuperview" ref="1064912113"/>
                                                                                                        </object>
-                                                                                                       <object class="NSColor" key="NSColor">
+                                                                                               </object>
+                                                                                               <string key="NSFrame">{{515, 202}, {284, 126}}</string>
+                                                                                               <reference key="NSSuperview" ref="490590002"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents"/>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
                                                                                                                <int key="NSColorSpace">3</int>
-                                                                                                               <bytes key="NSWhite">MCAwAA</bytes>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <reference key="NSAlternateImage" ref="216523553"/>
-                                                                                               <int key="NSPeriodicDelay">400</int>
-                                                                                               <int key="NSPeriodicInterval">75</int>
-                                                                                       </object>
-                                                                                       <reference key="NSSelectedCell" ref="660067650"/>
-                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                       <reference key="NSCellBackgroundColor" ref="45357611"/>
-                                                                                       <reference key="NSFont" ref="1003998324"/>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="897162141">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{54, 69}, {56, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="936113070">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="897162141"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <object class="NSColor" key="NSTextColor" id="446986434">
-                                                                                                       <int key="NSColorSpace">6</int>
-                                                                                                       <string key="NSCatalogName">System</string>
-                                                                                                       <string key="NSColorName">textColor</string>
-                                                                                                       <reference key="NSColor" ref="590886446"/>
-                                                                                               </object>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="773085513">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{54, 10}, {56, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="634956024">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="773085513"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <reference key="NSTextColor" ref="446986434"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSStepper" id="1067684983">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{76, 35}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="996643427">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="1067684983"/>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">2.000000e+00</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="411931143">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{97, 40}, {56, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="1050606643">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="411931143"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <reference key="NSTextColor" ref="446986434"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="842452881">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{18, 40}, {56, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="904241294">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="842452881"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <reference key="NSTextColor" ref="446986434"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSStepper" id="133033963">
-                                                                                       <reference key="NSNextResponder" ref="114416973"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{113, 5}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="114416973"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="71578223">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="133033963"/>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">2.000000e+00</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
+                                                                                               <reference key="NSContentView" ref="114416973"/>
+                                                                                               <int key="NSBorderType">1</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
                                                                                </object>
+                                                                               <string key="NSFrame">{{10, 19}, {801, 330}}</string>
+                                                                               <reference key="NSSuperview" ref="570027662"/>
                                                                        </object>
-                                                                       <string key="NSFrame">{{2, 2}, {189, 146}}</string>
-                                                                       <reference key="NSSuperview" ref="1064912113"/>
-                                                               </object>
-                                                       </object>
-                                                       <string key="NSFrame">{{243, 235}, {193, 163}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <string key="NSOffsets">{0, 0}</string>
-                                                       <object class="NSTextFieldCell" key="NSTitleCell">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">0</int>
-                                                               <string key="NSContents">Crop</string>
-                                                               <reference key="NSSupport" ref="26"/>
-                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                               <object class="NSColor" key="NSTextColor">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                       <string key="NSLabel">Size</string>
+                                                                       <reference key="NSColor" ref="407686733"/>
+                                                                       <reference key="NSTabView" ref="570027662"/>
                                                                </object>
-                                                       </object>
-                                                       <reference key="NSContentView" ref="114416973"/>
-                                                       <int key="NSBorderType">3</int>
-                                                       <int key="NSBoxType">0</int>
-                                                       <int key="NSTitlePosition">2</int>
-                                                       <bool key="NSTransparent">NO</bool>
-                                               </object>
-                                               <object class="NSBox" id="1011917013">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">265</int>
-                                                       <object class="NSMutableArray" key="NSSubviews">
-                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <object class="NSView" id="278260513">
-                                                                       <reference key="NSNextResponder" ref="1011917013"/>
-                                                                       <int key="NSvFlags">256</int>
-                                                                       <object class="NSMutableArray" key="NSSubviews">
-                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                               <object class="NSTextField" id="513894170">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{14, 64}, {55, 14}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="863668536">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Height:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="513894170"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="443002022">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{77, 62}, {62, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="649389918">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="443002022"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <reference key="NSTextColor" ref="446986434"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSButton" id="302614967">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{7, 36}, {152, 18}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSButtonCell" key="NSCell" id="595088069">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">67239936</int>
-                                                                                               <string key="NSContents">Keep aspect ratio:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="302614967"/>
-                                                                                               <int key="NSButtonFlags">1210864127</int>
-                                                                                               <int key="NSButtonFlags2">2</int>
-                                                                                               <object class="NSButtonImageSource" key="NSAlternateImage" id="931738615">
-                                                                                                       <string key="NSImageName">NSSwitch</string>
-                                                                                               </object>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <string key="NSKeyEquivalent"/>
-                                                                                               <int key="NSPeriodicDelay">200</int>
-                                                                                               <int key="NSPeriodicInterval">25</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSStepper" id="667015191">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{141, 57}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="634499157">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="667015191"/>
-                                                                                               <double key="NSValue">5.900000e+01</double>
-                                                                                               <double key="NSMinValue">6.400000e+01</double>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">1.600000e+01</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="569671425">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{14, 91}, {55, 14}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="412868245">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Width:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="569671425"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="232869468">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{77, 89}, {62, 19}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="96315080">
-                                                                                               <int key="NSCellFlags">-2075001280</int>
-                                                                                               <int key="NSCellFlags2">4195328</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="232869468"/>
-                                                                                               <bool key="NSDrawsBackground">YES</bool>
-                                                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                                                               <reference key="NSTextColor" ref="446986434"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSStepper" id="221469578">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">292</int>
-                                                                                       <string key="NSFrame">{{141, 84}, {19, 28}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSStepperCell" key="NSCell" id="714433793">
-                                                                                               <int key="NSCellFlags">917024</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSControlView" ref="221469578"/>
-                                                                                               <double key="NSValue">6.400000e+01</double>
-                                                                                               <double key="NSMinValue">6.400000e+01</double>
-                                                                                               <double key="NSMaxValue">5.900000e+01</double>
-                                                                                               <double key="NSIncrement">1.600000e+01</double>
-                                                                                               <bool key="NSAutorepeat">YES</bool>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSPopUpButton" id="147098438">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">268</int>
-                                                                                       <string key="NSFrame">{{82, 16}, {100, 15}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSPopUpButtonCell" key="NSCell" id="261514411">
-                                                                                               <int key="NSCellFlags">-2076049856</int>
-                                                                                               <int key="NSCellFlags2">264192</int>
-                                                                                               <object class="NSFont" key="NSSupport" id="22">
-                                                                                                       <string key="NSName">LucidaGrande</string>
-                                                                                                       <double key="NSSize">9.000000e+00</double>
-                                                                                                       <int key="NSfFlags">3614</int>
-                                                                                               </object>
-                                                                                               <reference key="NSControlView" ref="147098438"/>
-                                                                                               <int key="NSButtonFlags">109199615</int>
-                                                                                               <int key="NSButtonFlags2">1</int>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <string key="NSKeyEquivalent"/>
-                                                                                               <int key="NSPeriodicDelay">400</int>
-                                                                                               <int key="NSPeriodicInterval">75</int>
-                                                                                               <object class="NSMenuItem" key="NSMenuItem" id="85032843">
-                                                                                                       <reference key="NSMenu" ref="577969360"/>
-                                                                                                       <string key="NSTitle">Item 1</string>
-                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                       <int key="NSState">1</int>
-                                                                                                       <object class="NSCustomResource" key="NSOnImage" id="315488983">
-                                                                                                               <string key="NSClassName">NSImage</string>
-                                                                                                               <string key="NSResourceName">NSMenuCheckmark</string>
-                                                                                                       </object>
-                                                                                                       <object class="NSCustomResource" key="NSMixedImage" id="216289096">
-                                                                                                               <string key="NSClassName">NSImage</string>
-                                                                                                               <string key="NSResourceName">NSMenuMixedState</string>
+                                                               <object class="NSTabViewItem" id="1059808840">
+                                                                       <string key="NSIdentifier">2</string>
+                                                                       <object class="NSView" key="NSView" id="49700183">
+                                                                               <nil key="NSNextResponder"/>
+                                                                               <int key="NSvFlags">256</int>
+                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                       <object class="NSBox" id="123709997">
+                                                                                               <reference key="NSNextResponder" ref="49700183"/>
+                                                                                               <int key="NSvFlags">12</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="614431874">
+                                                                                                               <reference key="NSNextResponder" ref="123709997"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSTextField" id="907249437">
+                                                                                                                               <reference key="NSNextResponder" ref="614431874"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{15, 45}, {68, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="614431874"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="20607951">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Detelecine:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="907249437"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="675657376">
+                                                                                                                               <reference key="NSNextResponder" ref="614431874"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{15, 22}, {68, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="614431874"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="42393523">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Custom:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="675657376"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSPopUpButton" id="444006373">
+                                                                                                                               <reference key="NSNextResponder" ref="614431874"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{103, 46}, {110, 15}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="614431874"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <real value="1.000000e+00" key="CI_inputIntensity" id="172944286"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="225659946">
+                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="444006373"/>
+                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                       <object class="NSFont" key="NSAlternateImage" id="254124275">
+                                                                                                                                               <string key="NSName">LucidaGrande</string>
+                                                                                                                                               <double key="NSSize">9.000000e+00</double>
+                                                                                                                                               <int key="NSfFlags">16</int>
+                                                                                                                                       </object>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                                                                                               <characters key="NS.bytes"/>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="237877455">
+                                                                                                                                               <reference key="NSMenu" ref="822312097"/>
+                                                                                                                                               <string key="NSTitle">Item1</string>
+                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                               <reference key="NSTarget" ref="225659946"/>
+                                                                                                                                       </object>
+                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                       <object class="NSMenu" key="NSMenu" id="822312097">
+                                                                                                                                               <object class="NSMutableString" key="NSTitle">
+                                                                                                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <reference ref="237877455"/>
+                                                                                                                                                       <object class="NSMenuItem" id="621985928">
+                                                                                                                                                               <reference key="NSMenu" ref="822312097"/>
+                                                                                                                                                               <string key="NSTitle">Item2</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="225659946"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSMenuItem" id="1040778121">
+                                                                                                                                                               <reference key="NSMenu" ref="822312097"/>
+                                                                                                                                                               <string key="NSTitle">Item3</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="225659946"/>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="1003980650">
+                                                                                                                               <reference key="NSNextResponder" ref="614431874"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{104, 24}, {108, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="614431874"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="673987852">
+                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="1003980650"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                       <object class="NSColor" key="NSTextColor" id="779569028">
+                                                                                                                                               <int key="NSColorSpace">6</int>
+                                                                                                                                               <string key="NSCatalogName">System</string>
+                                                                                                                                               <string key="NSColorName">textColor</string>
+                                                                                                                                               <object class="NSColor" key="NSColor" id="6672969">
+                                                                                                                                                       <int key="NSColorSpace">3</int>
+                                                                                                                                                       <bytes key="NSWhite">MAA</bytes>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                               </object>
+                                                                                                               <string key="NSFrame">{{1, 1}, {230, 71}}</string>
+                                                                                                               <reference key="NSSuperview" ref="123709997"/>
                                                                                                        </object>
-                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                       <reference key="NSTarget" ref="261514411"/>
                                                                                                </object>
-                                                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                               <object class="NSMenu" key="NSMenu" id="577969360">
-                                                                                                       <string key="NSTitle">OtherViews</string>
-                                                                                                       <object class="NSMutableArray" key="NSMenuItems">
-                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                               <reference ref="85032843"/>
-                                                                                                               <object class="NSMenuItem" id="804424712">
-                                                                                                                       <reference key="NSMenu" ref="577969360"/>
-                                                                                                                       <string key="NSTitle">Item 2</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="261514411"/>
-                                                                                                               </object>
-                                                                                                               <object class="NSMenuItem" id="1018195923">
-                                                                                                                       <reference key="NSMenu" ref="577969360"/>
-                                                                                                                       <string key="NSTitle">Item 3</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="261514411"/>
-                                                                                                               </object>
+                                                                                               <string key="NSFrame">{{15, 255}, {232, 73}}</string>
+                                                                                               <reference key="NSSuperview" ref="49700183"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents">Box</string>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <int key="NSPreferredEdge">1</int>
-                                                                                               <bool key="NSUsesItemFromMenu">YES</bool>
-                                                                                               <bool key="NSAltersState">YES</bool>
-                                                                                               <int key="NSArrowPosition">2</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="301555397">
-                                                                                       <reference key="NSNextResponder" ref="278260513"/>
-                                                                                       <int key="NSvFlags">268</int>
-                                                                                       <string key="NSFrame">{{7, 15}, {73, 14}}</string>
-                                                                                       <reference key="NSSuperview" ref="278260513"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="926890760">
-                                                                                               <int key="NSCellFlags">67239488</int>
-                                                                                               <int key="NSCellFlags2">272761856</int>
-                                                                                               <string key="NSContents">Anamorphic:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="301555397"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
+                                                                                               <reference key="NSContentView" ref="614431874"/>
+                                                                                               <int key="NSBorderType">1</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
-                                                                               </object>
-                                                                       </object>
-                                                                       <string key="NSFrame">{{2, 2}, {189, 119}}</string>
-                                                                       <reference key="NSSuperview" ref="1011917013"/>
-                                                               </object>
-                                                       </object>
-                                                       <string key="NSFrame">{{245, 402}, {193, 136}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <string key="NSOffsets">{0, 0}</string>
-                                                       <object class="NSTextFieldCell" key="NSTitleCell">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">0</int>
-                                                               <string key="NSContents">Size</string>
-                                                               <reference key="NSSupport" ref="26"/>
-                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                               <object class="NSColor" key="NSTextColor">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-                                                               </object>
-                                                       </object>
-                                                       <reference key="NSContentView" ref="278260513"/>
-                                                       <int key="NSBorderType">3</int>
-                                                       <int key="NSBoxType">0</int>
-                                                       <int key="NSTitlePosition">2</int>
-                                                       <bool key="NSTransparent">NO</bool>
-                                               </object>
-                                               <object class="NSBox" id="309105014">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">265</int>
-                                                       <object class="NSMutableArray" key="NSSubviews">
-                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <object class="NSView" id="628081139">
-                                                                       <reference key="NSNextResponder" ref="309105014"/>
-                                                                       <int key="NSvFlags">256</int>
-                                                                       <object class="NSMutableArray" key="NSSubviews">
-                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                               <object class="NSPopUpButton" id="346912008">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{73, 79}, {110, 15}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSPopUpButtonCell" key="NSCell" id="1034367716">
-                                                                                               <int key="NSCellFlags">-2076049856</int>
-                                                                                               <int key="NSCellFlags2">264192</int>
-                                                                                               <reference key="NSSupport" ref="22"/>
-                                                                                               <reference key="NSControlView" ref="346912008"/>
-                                                                                               <int key="NSButtonFlags">109199615</int>
-                                                                                               <int key="NSButtonFlags2">1</int>
-                                                                                               <object class="NSFont" key="NSAlternateImage" id="826709342">
-                                                                                                       <string key="NSName">LucidaGrande</string>
-                                                                                                       <double key="NSSize">9.000000e+00</double>
-                                                                                                       <int key="NSfFlags">16</int>
-                                                                                               </object>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                       <characters key="NS.bytes"/>
-                                                                                               </object>
-                                                                                               <int key="NSPeriodicDelay">400</int>
-                                                                                               <int key="NSPeriodicInterval">75</int>
-                                                                                               <object class="NSMenuItem" key="NSMenuItem" id="937797455">
-                                                                                                       <reference key="NSMenu" ref="132523332"/>
-                                                                                                       <string key="NSTitle">Item1</string>
-                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                       <int key="NSState">1</int>
-                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                       <reference key="NSTarget" ref="1034367716"/>
-                                                                                               </object>
-                                                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                               <object class="NSMenu" key="NSMenu" id="132523332">
-                                                                                                       <object class="NSMutableString" key="NSTitle">
-                                                                                                               <characters key="NS.bytes">OtherViews</characters>
-                                                                                                       </object>
-                                                                                                       <object class="NSMutableArray" key="NSMenuItems">
-                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                               <reference ref="937797455"/>
-                                                                                                               <object class="NSMenuItem" id="71282261">
-                                                                                                                       <reference key="NSMenu" ref="132523332"/>
-                                                                                                                       <string key="NSTitle">Item2</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="1034367716"/>
-                                                                                                               </object>
-                                                                                                               <object class="NSMenuItem" id="542784764">
-                                                                                                                       <reference key="NSMenu" ref="132523332"/>
-                                                                                                                       <string key="NSTitle">Item3</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="1034367716"/>
+                                                                                       <object class="NSBox" id="211309117">
+                                                                                               <reference key="NSNextResponder" ref="49700183"/>
+                                                                                               <int key="NSvFlags">268</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="769476491">
+                                                                                                               <reference key="NSNextResponder" ref="211309117"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSSlider" id="985124611">
+                                                                                                                               <reference key="NSNextResponder" ref="769476491"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{59, 65}, {37, 15}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="769476491"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">1.000000e+00</float>
+                                                                                                                                                       <float key="green">1.000000e+00</float>
+                                                                                                                                                       <float key="blue">1.000000e+00</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSSliderCell" key="NSCell" id="288804516">
+                                                                                                                                       <int key="NSCellFlags">-2080244224</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="985124611"/>
+                                                                                                                                       <double key="NSMaxValue">1.000000e+00</double>
+                                                                                                                                       <double key="NSMinValue">0.000000e+00</double>
+                                                                                                                                       <double key="NSValue">0.000000e+00</double>
+                                                                                                                                       <double key="NSAltIncValue">0.000000e+00</double>
+                                                                                                                                       <int key="NSNumberOfTickMarks">0</int>
+                                                                                                                                       <int key="NSTickMarkPosition">1</int>
+                                                                                                                                       <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
+                                                                                                                                       <bool key="NSVertical">NO</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="873921736">
+                                                                                                                               <reference key="NSNextResponder" ref="769476491"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{1, 64}, {56, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="769476491"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="475982274">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Decomb</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="873921736"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="478887050">
+                                                                                                                               <reference key="NSNextResponder" ref="769476491"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{97, 63}, {89, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="769476491"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="940230908">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">4194304</int>
+                                                                                                                                       <string key="NSContents">Deinterlace</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="478887050"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSBox" id="889994612">
+                                                                                                                               <reference key="NSNextResponder" ref="769476491"/>
+                                                                                                                               <int key="NSvFlags">12</int>
+                                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="NSView" id="277740026">
+                                                                                                                                               <reference key="NSNextResponder" ref="889994612"/>
+                                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <object class="NSTextField" id="7173206">
+                                                                                                                                                               <reference key="NSNextResponder" ref="277740026"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{5, 33}, {68, 17}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="277740026"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="695838500">
+                                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                                                       <string key="NSContents">Decomb:</string>
+                                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="7173206"/>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSTextField" id="652411918">
+                                                                                                                                                               <reference key="NSNextResponder" ref="277740026"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{5, 10}, {68, 17}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="277740026"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="908484803">
+                                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                                                       <string key="NSContents">Custom:</string>
+                                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="652411918"/>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSPopUpButton" id="356573645">
+                                                                                                                                                               <reference key="NSNextResponder" ref="277740026"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{93, 34}, {110, 15}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="277740026"/>
+                                                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                                                               </object>
+                                                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                                                       </object>
+                                                                                                                                                               </object>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="454070103">
+                                                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="356573645"/>
+                                                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                                                       <reference key="NSAlternateImage" ref="254124275"/>
+                                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                                                                                                                               <characters key="NS.bytes"/>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="720143866">
+                                                                                                                                                                               <reference key="NSMenu" ref="259868564"/>
+                                                                                                                                                                               <string key="NSTitle">Item1</string>
+                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                               <reference key="NSTarget" ref="454070103"/>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                                                       <object class="NSMenu" key="NSMenu" id="259868564">
+                                                                                                                                                                               <object class="NSMutableString" key="NSTitle">
+                                                                                                                                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                                                                                                                                               </object>
+                                                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                                       <reference ref="720143866"/>
+                                                                                                                                                                                       <object class="NSMenuItem" id="414039981">
+                                                                                                                                                                                               <reference key="NSMenu" ref="259868564"/>
+                                                                                                                                                                                               <string key="NSTitle">Item2</string>
+                                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                                               <reference key="NSTarget" ref="454070103"/>
+                                                                                                                                                                                       </object>
+                                                                                                                                                                                       <object class="NSMenuItem" id="197481337">
+                                                                                                                                                                                               <reference key="NSMenu" ref="259868564"/>
+                                                                                                                                                                                               <string key="NSTitle">Item3</string>
+                                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                                               <reference key="NSTarget" ref="454070103"/>
+                                                                                                                                                                                       </object>
+                                                                                                                                                                               </object>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSTextField" id="103870225">
+                                                                                                                                                               <reference key="NSNextResponder" ref="277740026"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{94, 12}, {108, 16}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="277740026"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="558197217">
+                                                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="103870225"/>
+                                                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="779569028"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                               <string key="NSFrameSize">{215, 60}</string>
+                                                                                                                                               <reference key="NSSuperview" ref="889994612"/>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <string key="NSFrame">{{5, -3}, {215, 60}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="769476491"/>
+                                                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                                                       <string key="NSContents">Box</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSContentView" ref="277740026"/>
+                                                                                                                               <int key="NSBorderType">0</int>
+                                                                                                                               <int key="NSBoxType">4</int>
+                                                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                                                               <bool key="NSTransparent">NO</bool>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSBox" id="136990045">
+                                                                                                                               <reference key="NSNextResponder" ref="769476491"/>
+                                                                                                                               <int key="NSvFlags">12</int>
+                                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="NSView" id="800728459">
+                                                                                                                                               <reference key="NSNextResponder" ref="136990045"/>
+                                                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <object class="NSTextField" id="455753488">
+                                                                                                                                                               <reference key="NSNextResponder" ref="800728459"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{8, 33}, {68, 17}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="800728459"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="733163980">
+                                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                                                       <string key="NSContents">Deinterlace:</string>
+                                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="455753488"/>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSTextField" id="707016708">
+                                                                                                                                                               <reference key="NSNextResponder" ref="800728459"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{8, 10}, {68, 17}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="800728459"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="1039358237">
+                                                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                                                       <string key="NSContents">Custom:</string>
+                                                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="707016708"/>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSPopUpButton" id="850427642">
+                                                                                                                                                               <reference key="NSNextResponder" ref="800728459"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{96, 34}, {110, 15}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="800728459"/>
+                                                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                                                               </object>
+                                                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                                                       </object>
+                                                                                                                                                               </object>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="247704759">
+                                                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="850427642"/>
+                                                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                                                       <reference key="NSAlternateImage" ref="254124275"/>
+                                                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                                                                                                                               <characters key="NS.bytes"/>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="683933257">
+                                                                                                                                                                               <reference key="NSMenu" ref="579462485"/>
+                                                                                                                                                                               <string key="NSTitle">Item1</string>
+                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                               <reference key="NSTarget" ref="247704759"/>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                                                       <object class="NSMenu" key="NSMenu" id="579462485">
+                                                                                                                                                                               <object class="NSMutableString" key="NSTitle">
+                                                                                                                                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                                                                                                                                               </object>
+                                                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                                                       <reference ref="683933257"/>
+                                                                                                                                                                                       <object class="NSMenuItem" id="770160669">
+                                                                                                                                                                                               <reference key="NSMenu" ref="579462485"/>
+                                                                                                                                                                                               <string key="NSTitle">Item2</string>
+                                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                                               <reference key="NSTarget" ref="247704759"/>
+                                                                                                                                                                                       </object>
+                                                                                                                                                                                       <object class="NSMenuItem" id="391113581">
+                                                                                                                                                                                               <reference key="NSMenu" ref="579462485"/>
+                                                                                                                                                                                               <string key="NSTitle">Item3</string>
+                                                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                                                               <reference key="NSTarget" ref="247704759"/>
+                                                                                                                                                                                       </object>
+                                                                                                                                                                               </object>
+                                                                                                                                                                       </object>
+                                                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSTextField" id="181376038">
+                                                                                                                                                               <reference key="NSNextResponder" ref="800728459"/>
+                                                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                                                               <string key="NSFrame">{{97, 11}, {108, 16}}</string>
+                                                                                                                                                               <reference key="NSSuperview" ref="800728459"/>
+                                                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="240437779">
+                                                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                                                       <reference key="NSControlView" ref="181376038"/>
+                                                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                                                       <reference key="NSTextColor" ref="779569028"/>
+                                                                                                                                                               </object>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                               <string key="NSFrameSize">{221, 60}</string>
+                                                                                                                                               <reference key="NSSuperview" ref="136990045"/>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <string key="NSFrame">{{2, -3}, {221, 60}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="769476491"/>
+                                                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                                                       <string key="NSContents">Box</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <reference key="NSContentView" ref="800728459"/>
+                                                                                                                               <int key="NSBorderType">0</int>
+                                                                                                                               <int key="NSBoxType">0</int>
+                                                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                                                               <bool key="NSTransparent">NO</bool>
+                                                                                                                       </object>
                                                                                                                </object>
+                                                                                                               <string key="NSFrame">{{2, 18}, {228, 92}}</string>
+                                                                                                               <reference key="NSSuperview" ref="211309117"/>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <int key="NSPreferredEdge">3</int>
-                                                                                               <bool key="NSUsesItemFromMenu">YES</bool>
-                                                                                               <bool key="NSAltersState">YES</bool>
-                                                                                               <int key="NSArrowPosition">1</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="905607845">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{2, 77}, {68, 17}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="522867811">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Deinterlace:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="905607845"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
+                                                                                               <string key="NSFrame">{{15, 140}, {232, 112}}</string>
+                                                                                               <reference key="NSSuperview" ref="49700183"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents"/>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                       </object>
+                                                                                               </object>
+                                                                                               <reference key="NSContentView" ref="769476491"/>
+                                                                                               <int key="NSBorderType">3</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">4</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
-                                                                               </object>
-                                                                               <object class="NSButton" id="407610327">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{6, 100}, {82, 18}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSButtonCell" key="NSCell" id="832714893">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">67239936</int>
-                                                                                               <string key="NSContents">Detelecine:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="407610327"/>
-                                                                                               <int key="NSButtonFlags">1210864127</int>
-                                                                                               <int key="NSButtonFlags2">2</int>
-                                                                                               <reference key="NSAlternateImage" ref="931738615"/>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <string key="NSKeyEquivalent"/>
-                                                                                               <int key="NSPeriodicDelay">200</int>
-                                                                                               <int key="NSPeriodicInterval">25</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSPopUpButton" id="243795165">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{74, 54}, {109, 15}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSPopUpButtonCell" key="NSCell" id="708528272">
-                                                                                               <int key="NSCellFlags">-2076049856</int>
-                                                                                               <int key="NSCellFlags2">264192</int>
-                                                                                               <reference key="NSSupport" ref="22"/>
-                                                                                               <reference key="NSControlView" ref="243795165"/>
-                                                                                               <int key="NSButtonFlags">109199615</int>
-                                                                                               <int key="NSButtonFlags2">1</int>
-                                                                                               <reference key="NSAlternateImage" ref="826709342"/>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                       <characters key="NS.bytes"/>
-                                                                                               </object>
-                                                                                               <int key="NSPeriodicDelay">400</int>
-                                                                                               <int key="NSPeriodicInterval">75</int>
-                                                                                               <object class="NSMenuItem" key="NSMenuItem" id="114494573">
-                                                                                                       <reference key="NSMenu" ref="176321383"/>
-                                                                                                       <string key="NSTitle">Item1</string>
-                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                       <int key="NSState">1</int>
-                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                       <reference key="NSTarget" ref="708528272"/>
-                                                                                               </object>
-                                                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                               <object class="NSMenu" key="NSMenu" id="176321383">
-                                                                                                       <object class="NSMutableString" key="NSTitle">
-                                                                                                               <characters key="NS.bytes">OtherViews</characters>
-                                                                                                       </object>
-                                                                                                       <object class="NSMutableArray" key="NSMenuItems">
-                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                               <reference ref="114494573"/>
-                                                                                                               <object class="NSMenuItem" id="750998660">
-                                                                                                                       <reference key="NSMenu" ref="176321383"/>
-                                                                                                                       <string key="NSTitle">Item2</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="708528272"/>
-                                                                                                               </object>
-                                                                                                               <object class="NSMenuItem" id="133285043">
-                                                                                                                       <reference key="NSMenu" ref="176321383"/>
-                                                                                                                       <string key="NSTitle">Item3</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="708528272"/>
+                                                                                       <object class="NSBox" id="691710132">
+                                                                                               <reference key="NSNextResponder" ref="49700183"/>
+                                                                                               <int key="NSvFlags">12</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="432503529">
+                                                                                                               <reference key="NSNextResponder" ref="691710132"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSTextField" id="407034984">
+                                                                                                                               <reference key="NSNextResponder" ref="432503529"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{15, 37}, {68, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="432503529"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="15366198">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Denoise:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="407034984"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="929586587">
+                                                                                                                               <reference key="NSNextResponder" ref="432503529"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{15, 14}, {68, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="432503529"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="601710816">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Custom:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="929586587"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSPopUpButton" id="362740356">
+                                                                                                                               <reference key="NSNextResponder" ref="432503529"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{103, 38}, {110, 15}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="432503529"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSPopUpButtonCell" key="NSCell" id="625319255">
+                                                                                                                                       <int key="NSCellFlags">-2076049856</int>
+                                                                                                                                       <int key="NSCellFlags2">264192</int>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="362740356"/>
+                                                                                                                                       <int key="NSButtonFlags">109199615</int>
+                                                                                                                                       <int key="NSButtonFlags2">1</int>
+                                                                                                                                       <reference key="NSAlternateImage" ref="254124275"/>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                                                                                                               <characters key="NS.bytes"/>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPeriodicDelay">400</int>
+                                                                                                                                       <int key="NSPeriodicInterval">75</int>
+                                                                                                                                       <object class="NSMenuItem" key="NSMenuItem" id="535683643">
+                                                                                                                                               <reference key="NSMenu" ref="618343102"/>
+                                                                                                                                               <string key="NSTitle">Item1</string>
+                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                               <int key="NSState">1</int>
+                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                               <reference key="NSTarget" ref="625319255"/>
+                                                                                                                                       </object>
+                                                                                                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                                                                                                       <object class="NSMenu" key="NSMenu" id="618343102">
+                                                                                                                                               <object class="NSMutableString" key="NSTitle">
+                                                                                                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                                                                                                               </object>
+                                                                                                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                                       <reference ref="535683643"/>
+                                                                                                                                                       <object class="NSMenuItem" id="107429478">
+                                                                                                                                                               <reference key="NSMenu" ref="618343102"/>
+                                                                                                                                                               <string key="NSTitle">Item2</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="625319255"/>
+                                                                                                                                                       </object>
+                                                                                                                                                       <object class="NSMenuItem" id="865792840">
+                                                                                                                                                               <reference key="NSMenu" ref="618343102"/>
+                                                                                                                                                               <string key="NSTitle">Item3</string>
+                                                                                                                                                               <string key="NSKeyEquiv"/>
+                                                                                                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                                                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                                                                                                               <reference key="NSOnImage" ref="279874594"/>
+                                                                                                                                                               <reference key="NSMixedImage" ref="300720659"/>
+                                                                                                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                                                                                                               <reference key="NSTarget" ref="625319255"/>
+                                                                                                                                                       </object>
+                                                                                                                                               </object>
+                                                                                                                                       </object>
+                                                                                                                                       <int key="NSPreferredEdge">3</int>
+                                                                                                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                                                                                                       <bool key="NSAltersState">YES</bool>
+                                                                                                                                       <int key="NSArrowPosition">1</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="529723890">
+                                                                                                                               <reference key="NSNextResponder" ref="432503529"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{104, 16}, {108, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="432503529"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="692527149">
+                                                                                                                                       <int key="NSCellFlags">-1804468671</int>
+                                                                                                                                       <int key="NSCellFlags2">272892928</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="529723890"/>
+                                                                                                                                       <bool key="NSDrawsBackground">YES</bool>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                                                       <reference key="NSTextColor" ref="779569028"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
                                                                                                                </object>
+                                                                                                               <string key="NSFrame">{{1, 1}, {230, 63}}</string>
+                                                                                                               <reference key="NSSuperview" ref="691710132"/>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <int key="NSPreferredEdge">3</int>
-                                                                                               <bool key="NSUsesItemFromMenu">YES</bool>
-                                                                                               <bool key="NSAltersState">YES</bool>
-                                                                                               <int key="NSArrowPosition">1</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="94419441">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{19, 53}, {51, 17}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="741873280">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Denoise:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="94419441"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="1069536323">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{10, 31}, {51, 17}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="728722104">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Deblock:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="1069536323"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="314638156">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{56, 33}, {31, 14}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="350598908">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">138543104</int>
-                                                                                               <string key="NSContents">Off</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="314638156"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSPopUpButton" id="878291110">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{75, 9}, {110, 15}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSPopUpButtonCell" key="NSCell" id="162356603">
-                                                                                               <int key="NSCellFlags">-2076049856</int>
-                                                                                               <int key="NSCellFlags2">264192</int>
-                                                                                               <reference key="NSSupport" ref="22"/>
-                                                                                               <reference key="NSControlView" ref="878291110"/>
-                                                                                               <int key="NSButtonFlags">109199615</int>
-                                                                                               <int key="NSButtonFlags2">1</int>
-                                                                                               <reference key="NSAlternateImage" ref="826709342"/>
-                                                                                               <string key="NSAlternateContents"/>
-                                                                                               <object class="NSMutableString" key="NSKeyEquivalent">
-                                                                                                       <characters key="NS.bytes"/>
-                                                                                               </object>
-                                                                                               <int key="NSPeriodicDelay">400</int>
-                                                                                               <int key="NSPeriodicInterval">75</int>
-                                                                                               <object class="NSMenuItem" key="NSMenuItem" id="170535567">
-                                                                                                       <reference key="NSMenu" ref="146867052"/>
-                                                                                                       <string key="NSTitle">Item1</string>
-                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                       <int key="NSState">1</int>
-                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                       <reference key="NSTarget" ref="162356603"/>
-                                                                                               </object>
-                                                                                               <bool key="NSMenuItemRespectAlignment">YES</bool>
-                                                                                               <object class="NSMenu" key="NSMenu" id="146867052">
-                                                                                                       <object class="NSMutableString" key="NSTitle">
-                                                                                                               <characters key="NS.bytes">OtherViews</characters>
+                                                                                               <string key="NSFrame">{{14, 73}, {232, 65}}</string>
+                                                                                               <reference key="NSSuperview" ref="49700183"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents">Box</string>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
                                                                                                        </object>
-                                                                                                       <object class="NSMutableArray" key="NSMenuItems">
-                                                                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                                                               <reference ref="170535567"/>
-                                                                                                               <object class="NSMenuItem" id="226508779">
-                                                                                                                       <reference key="NSMenu" ref="146867052"/>
-                                                                                                                       <string key="NSTitle">Item2</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="162356603"/>
-                                                                                                               </object>
-                                                                                                               <object class="NSMenuItem" id="43352374">
-                                                                                                                       <reference key="NSMenu" ref="146867052"/>
-                                                                                                                       <string key="NSTitle">Item3</string>
-                                                                                                                       <string key="NSKeyEquiv"/>
-                                                                                                                       <int key="NSKeyEquivModMask">1048576</int>
-                                                                                                                       <int key="NSMnemonicLoc">2147483647</int>
-                                                                                                                       <reference key="NSOnImage" ref="315488983"/>
-                                                                                                                       <reference key="NSMixedImage" ref="216289096"/>
-                                                                                                                       <string key="NSAction">_popUpItemAction:</string>
-                                                                                                                       <reference key="NSTarget" ref="162356603"/>
+                                                                                               </object>
+                                                                                               <reference key="NSContentView" ref="432503529"/>
+                                                                                               <int key="NSBorderType">1</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
+                                                                                       </object>
+                                                                                       <object class="NSBox" id="825796162">
+                                                                                               <reference key="NSNextResponder" ref="49700183"/>
+                                                                                               <int key="NSvFlags">12</int>
+                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                       <object class="NSView" id="487196162">
+                                                                                                               <reference key="NSNextResponder" ref="825796162"/>
+                                                                                                               <int key="NSvFlags">256</int>
+                                                                                                               <object class="NSMutableArray" key="NSSubviews">
+                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                       <object class="NSTextField" id="425499167">
+                                                                                                                               <reference key="NSNextResponder" ref="487196162"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{29, 39}, {51, 17}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="487196162"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="440135121">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Deblock:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="425499167"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="1014567695">
+                                                                                                                               <reference key="NSNextResponder" ref="487196162"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{17, 8}, {63, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="487196162"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="922265218">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">71303168</int>
+                                                                                                                                       <string key="NSContents">Grayscale:</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="1014567695"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSTextField" id="345974679">
+                                                                                                                               <reference key="NSNextResponder" ref="487196162"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{79, 41}, {31, 14}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="487196162"/>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSTextFieldCell" key="NSCell" id="288379564">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">138543104</int>
+                                                                                                                                       <string key="NSContents">Off</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="345974679"/>
+                                                                                                                                       <reference key="NSBackgroundColor" ref="407686733"/>
+                                                                                                                                       <reference key="NSTextColor" ref="852384715"/>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSSlider" id="703236195">
+                                                                                                                               <reference key="NSNextResponder" ref="487196162"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{108, 40}, {104, 16}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="487196162"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSSliderCell" key="NSCell" id="145960326">
+                                                                                                                                       <int key="NSCellFlags">-2079981824</int>
+                                                                                                                                       <int key="NSCellFlags2">262144</int>
+                                                                                                                                       <string key="NSContents"/>
+                                                                                                                                       <reference key="NSSupport" ref="22"/>
+                                                                                                                                       <reference key="NSControlView" ref="703236195"/>
+                                                                                                                                       <double key="NSMaxValue">1.500000e+01</double>
+                                                                                                                                       <double key="NSMinValue">4.000000e+00</double>
+                                                                                                                                       <double key="NSValue">4.000000e+00</double>
+                                                                                                                                       <double key="NSAltIncValue">0.000000e+00</double>
+                                                                                                                                       <int key="NSNumberOfTickMarks">12</int>
+                                                                                                                                       <int key="NSTickMarkPosition">0</int>
+                                                                                                                                       <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
+                                                                                                                                       <bool key="NSVertical">NO</bool>
+                                                                                                                               </object>
+                                                                                                                       </object>
+                                                                                                                       <object class="NSButton" id="1021739901">
+                                                                                                                               <reference key="NSNextResponder" ref="487196162"/>
+                                                                                                                               <int key="NSvFlags">268</int>
+                                                                                                                               <string key="NSFrame">{{84, 6}, {19, 18}}</string>
+                                                                                                                               <reference key="NSSuperview" ref="487196162"/>
+                                                                                                                               <bool key="NSViewIsLayerTreeHost">YES</bool>
+                                                                                                                               <object class="NSArray" key="NSViewContentFilters">
+                                                                                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                                                                                       <object class="CIColorMonochrome">
+                                                                                                                                               <object class="CIColor" key="CI_inputColor">
+                                                                                                                                                       <float key="red">7.019608e-01</float>
+                                                                                                                                                       <float key="green">7.019608e-01</float>
+                                                                                                                                                       <float key="blue">7.019608e-01</float>
+                                                                                                                                                       <float key="alpha">1.000000e+00</float>
+                                                                                                                                               </object>
+                                                                                                                                               <reference key="CI_inputIntensity" ref="172944286"/>
+                                                                                                                                               <bool key="CIEnabled">YES</bool>
+                                                                                                                                       </object>
+                                                                                                                               </object>
+                                                                                                                               <bool key="NSEnabled">YES</bool>
+                                                                                                                               <object class="NSButtonCell" key="NSCell" id="1059254264">
+                                                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                                                       <int key="NSCellFlags2">131072</int>
+                                                                                                                                       <string key="NSContents">Check</string>
+                                                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                                                       <reference key="NSControlView" ref="1021739901"/>
+                                                                                                                                       <int key="NSButtonFlags">1211912703</int>
+                                                                                                                                       <int key="NSButtonFlags2">130</int>
+                                                                                                                                       <object class="NSCustomResource" key="NSNormalImage">
+                                                                                                                                               <string key="NSClassName">NSImage</string>
+                                                                                                                                               <string key="NSResourceName">NSSwitch</string>
+                                                                                                                                       </object>
+                                                                                                                                       <reference key="NSAlternateImage" ref="998385597"/>
+                                                                                                                                       <string key="NSAlternateContents"/>
+                                                                                                                                       <string key="NSKeyEquivalent"/>
+                                                                                                                                       <int key="NSPeriodicDelay">200</int>
+                                                                                                                                       <int key="NSPeriodicInterval">25</int>
+                                                                                                                               </object>
+                                                                                                                       </object>
                                                                                                                </object>
+                                                                                                               <string key="NSFrame">{{1, 1}, {230, 63}}</string>
+                                                                                                               <reference key="NSSuperview" ref="825796162"/>
                                                                                                        </object>
                                                                                                </object>
-                                                                                               <int key="NSPreferredEdge">3</int>
-                                                                                               <bool key="NSUsesItemFromMenu">YES</bool>
-                                                                                               <bool key="NSAltersState">YES</bool>
-                                                                                               <int key="NSArrowPosition">1</int>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSTextField" id="742513844">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">256</int>
-                                                                                       <string key="NSFrame">{{18, 7}, {52, 17}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSTextFieldCell" key="NSCell" id="604349861">
-                                                                                               <int key="NSCellFlags">67239424</int>
-                                                                                               <int key="NSCellFlags2">71303168</int>
-                                                                                               <string key="NSContents">Decomb:</string>
-                                                                                               <reference key="NSSupport" ref="26"/>
-                                                                                               <reference key="NSControlView" ref="742513844"/>
-                                                                                               <reference key="NSBackgroundColor" ref="407686733"/>
-                                                                                               <reference key="NSTextColor" ref="1053668690"/>
-                                                                                       </object>
-                                                                               </object>
-                                                                               <object class="NSSlider" id="581126685">
-                                                                                       <reference key="NSNextResponder" ref="628081139"/>
-                                                                                       <int key="NSvFlags">268</int>
-                                                                                       <string key="NSFrame">{{88, 31}, {96, 16}}</string>
-                                                                                       <reference key="NSSuperview" ref="628081139"/>
-                                                                                       <bool key="NSEnabled">YES</bool>
-                                                                                       <object class="NSSliderCell" key="NSCell" id="257047106">
-                                                                                               <int key="NSCellFlags">-2079981824</int>
-                                                                                               <int key="NSCellFlags2">262144</int>
-                                                                                               <string key="NSContents"/>
-                                                                                               <reference key="NSSupport" ref="22"/>
-                                                                                               <reference key="NSControlView" ref="581126685"/>
-                                                                                               <double key="NSMaxValue">1.500000e+01</double>
-                                                                                               <double key="NSMinValue">4.000000e+00</double>
-                                                                                               <double key="NSValue">4.000000e+00</double>
-                                                                                               <double key="NSAltIncValue">0.000000e+00</double>
-                                                                                               <int key="NSNumberOfTickMarks">12</int>
-                                                                                               <int key="NSTickMarkPosition">0</int>
-                                                                                               <bool key="NSAllowsTickMarkValuesOnly">YES</bool>
-                                                                                               <bool key="NSVertical">NO</bool>
+                                                                                               <string key="NSFrame">{{15, 5}, {232, 65}}</string>
+                                                                                               <reference key="NSSuperview" ref="49700183"/>
+                                                                                               <string key="NSOffsets">{0, 0}</string>
+                                                                                               <object class="NSTextFieldCell" key="NSTitleCell">
+                                                                                                       <int key="NSCellFlags">67239424</int>
+                                                                                                       <int key="NSCellFlags2">0</int>
+                                                                                                       <string key="NSContents">Box</string>
+                                                                                                       <reference key="NSSupport" ref="26"/>
+                                                                                                       <reference key="NSBackgroundColor" ref="406287577"/>
+                                                                                                       <object class="NSColor" key="NSTextColor">
+                                                                                                               <int key="NSColorSpace">3</int>
+                                                                                                               <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                                                       </object>
+                                                                                               </object>
+                                                                                               <reference key="NSContentView" ref="487196162"/>
+                                                                                               <int key="NSBorderType">1</int>
+                                                                                               <int key="NSBoxType">0</int>
+                                                                                               <int key="NSTitlePosition">0</int>
+                                                                                               <bool key="NSTransparent">NO</bool>
                                                                                        </object>
                                                                                </object>
+                                                                               <string key="NSFrame">{{10, 19}, {801, 330}}</string>
                                                                        </object>
-                                                                       <string key="NSFrame">{{2, 2}, {189, 127}}</string>
-                                                                       <reference key="NSSuperview" ref="309105014"/>
-                                                               </object>
-                                                       </object>
-                                                       <string key="NSFrame">{{243, 87}, {193, 144}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <string key="NSOffsets">{0, 0}</string>
-                                                       <object class="NSTextFieldCell" key="NSTitleCell">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">0</int>
-                                                               <string key="NSContents">Filters</string>
-                                                               <reference key="NSSupport" ref="26"/>
-                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                               <object class="NSColor" key="NSTextColor">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
+                                                                       <string key="NSLabel">Filters</string>
+                                                                       <reference key="NSColor" ref="407686733"/>
+                                                                       <reference key="NSTabView" ref="570027662"/>
                                                                </object>
                                                        </object>
-                                                       <reference key="NSContentView" ref="628081139"/>
-                                                       <int key="NSBorderType">3</int>
-                                                       <int key="NSBoxType">0</int>
-                                                       <int key="NSTitlePosition">2</int>
-                                                       <bool key="NSTransparent">NO</bool>
-                                               </object>
-                                               <object class="NSBox" id="208214895">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">-2147483374</int>
+                                                       <reference key="NSSelectedTabViewItem" ref="184512336"/>
+                                                       <reference key="NSFont" ref="22"/>
+                                                       <int key="NSTvFlags">268435456</int>
+                                                       <bool key="NSAllowTruncatedLabels">YES</bool>
+                                                       <bool key="NSDrawsBackground">YES</bool>
                                                        <object class="NSMutableArray" key="NSSubviews">
                                                                <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <object class="NSView" id="982902210">
-                                                                       <reference key="NSNextResponder" ref="208214895"/>
-                                                                       <int key="NSvFlags">256</int>
-                                                                       <string key="NSFrameSize">{208, 451}</string>
-                                                                       <reference key="NSSuperview" ref="208214895"/>
-                                                               </object>
-                                                       </object>
-                                                       <string key="NSFrame">{{20, 75}, {208, 451}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <string key="NSOffsets">{0, 0}</string>
-                                                       <object class="NSTextFieldCell" key="NSTitleCell">
-                                                               <int key="NSCellFlags">67239424</int>
-                                                               <int key="NSCellFlags2">0</int>
-                                                               <string key="NSContents">Box</string>
-                                                               <reference key="NSSupport" ref="26"/>
-                                                               <reference key="NSBackgroundColor" ref="406287577"/>
-                                                               <object class="NSColor" key="NSTextColor">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-                                                               </object>
-                                                       </object>
-                                                       <reference key="NSContentView" ref="982902210"/>
-                                                       <int key="NSBorderType">0</int>
-                                                       <int key="NSBoxType">3</int>
-                                                       <int key="NSTitlePosition">0</int>
-                                                       <bool key="NSTransparent">NO</bool>
-                                               </object>
-                                               <object class="NSImageView" id="844127024">
-                                                       <reference key="NSNextResponder" ref="49161063"/>
-                                                       <int key="NSvFlags">274</int>
-                                                       <object class="NSMutableSet" key="NSDragTypes">
-                                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                                               <object class="NSMutableArray" key="set.sortedObjects">
-                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                                       <string>Apple PDF pasteboard type</string>
-                                                                       <string>Apple PICT pasteboard type</string>
-                                                                       <string>Apple PNG pasteboard type</string>
-                                                                       <string>NSFilenamesPboardType</string>
-                                                                       <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
-                                                                       <string>NeXT TIFF v4.0 pasteboard type</string>
-                                                               </object>
+                                                               <reference ref="490590002"/>
                                                        </object>
-                                                       <string key="NSFrame">{{20, 66}, {208, 460}}</string>
-                                                       <reference key="NSSuperview" ref="49161063"/>
-                                                       <bool key="NSEnabled">YES</bool>
-                                                       <object class="NSImageCell" key="NSCell" id="955430771">
-                                                               <int key="NSCellFlags">130560</int>
-                                                               <int key="NSCellFlags2">33554432</int>
-                                                               <int key="NSAlign">0</int>
-                                                               <int key="NSScale">1</int>
-                                                               <int key="NSStyle">0</int>
-                                                               <bool key="NSAnimates">NO</bool>
-                                                       </object>
-                                                       <bool key="NSEditable">YES</bool>
                                                </object>
                                        </object>
-                                       <string key="NSFrameSize">{453, 558}</string>
+                                       <string key="NSFrameSize">{849, 399}</string>
                                        <reference key="NSSuperview"/>
                                </object>
                                <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
-                               <string key="NSMinSize">{453, 580}</string>
                                <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
                        </object>
                </object>
@@ -1290,30 +2238,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fDeinterlacePopUp</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="346912008"/>
-                                       </object>
-                                       <int key="connectionID">62</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fDenoisePopUp</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="243795165"/>
-                                       </object>
-                                       <int key="connectionID">63</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fDetelecineCheck</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="407610327"/>
-                                       </object>
-                                       <int key="connectionID">64</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
                                                <string key="label">fHeightField</string>
                                                <reference key="source" ref="355312334"/>
                                                <reference key="destination" ref="443002022"/>
@@ -1346,30 +2270,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fNextButton</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="41752677"/>
-                                       </object>
-                                       <int key="connectionID">71</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPrevButton</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="862464620"/>
-                                       </object>
-                                       <int key="connectionID">72</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fInfoField</string>
-                                               <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="628196212"/>
-                                       </object>
-                                       <int key="connectionID">73</int>
-                               </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
                                                <string key="label">fRatioCheck</string>
                                                <reference key="source" ref="355312334"/>
                                                <reference key="destination" ref="302614967"/>
@@ -1386,189 +2286,469 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">ClosePanel:</string>
+                                               <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="345100891"/>
+                                               <reference key="destination" ref="133033963"/>
                                        </object>
-                                       <int key="connectionID">77</int>
+                                       <int key="connectionID">83</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">NextPicture:</string>
+                                               <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="41752677"/>
+                                               <reference key="destination" ref="510144318"/>
                                        </object>
-                                       <int key="connectionID">78</int>
+                                       <int key="connectionID">84</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">PreviousPicture:</string>
+                                               <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="862464620"/>
+                                               <reference key="destination" ref="1067684983"/>
                                        </object>
-                                       <int key="connectionID">79</int>
+                                       <int key="connectionID">85</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="243795165"/>
+                                               <reference key="destination" ref="580805308"/>
                                        </object>
-                                       <int key="connectionID">80</int>
+                                       <int key="connectionID">86</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="346912008"/>
+                                               <reference key="destination" ref="1032624817"/>
                                        </object>
-                                       <int key="connectionID">81</int>
+                                       <int key="connectionID">87</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="407610327"/>
+                                               <reference key="destination" ref="302614967"/>
                                        </object>
-                                       <int key="connectionID">82</int>
+                                       <int key="connectionID">89</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="133033963"/>
+                                               <reference key="destination" ref="667015191"/>
                                        </object>
-                                       <int key="connectionID">83</int>
+                                       <int key="connectionID">90</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fAnamorphicPopUp</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="510144318"/>
+                                               <reference key="destination" ref="147098438"/>
                                        </object>
-                                       <int key="connectionID">84</int>
+                                       <int key="connectionID">140</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">SettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="1067684983"/>
+                                               <reference key="destination" ref="147098438"/>
                                        </object>
-                                       <int key="connectionID">85</int>
+                                       <int key="connectionID">142</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">window</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="580805308"/>
+                                               <reference key="destination" ref="616825745"/>
                                        </object>
-                                       <int key="connectionID">86</int>
+                                       <int key="connectionID">184</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureWindow</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="1032624817"/>
+                                               <reference key="destination" ref="616825745"/>
                                        </object>
-                                       <int key="connectionID">87</int>
+                                       <int key="connectionID">240</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureCropBox</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="302614967"/>
+                                               <reference key="destination" ref="1064912113"/>
                                        </object>
-                                       <int key="connectionID">89</int>
+                                       <int key="connectionID">242</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPreviewOpenButton</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="892118626"/>
+                                       </object>
+                                       <int key="connectionID">272</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                               <string key="label">showPreviewWindow:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="667015191"/>
+                                               <reference key="destination" ref="892118626"/>
                                        </object>
-                                       <int key="connectionID">90</int>
+                                       <int key="connectionID">273</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fAnamorphicPopUp</string>
+                                               <string key="label">fSizeInfoField</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="147098438"/>
+                                               <reference key="destination" ref="154029488"/>
                                        </object>
-                                       <int key="connectionID">140</int>
+                                       <int key="connectionID">280</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDetelecineBox</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="147098438"/>
+                                               <reference key="destination" ref="123709997"/>
                                        </object>
-                                       <int key="connectionID">142</int>
+                                       <int key="connectionID">356</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPictureView</string>
+                                               <string key="label">fDetelecinePopUp</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="844127024"/>
+                                               <reference key="destination" ref="444006373"/>
                                        </object>
-                                       <int key="connectionID">181</int>
+                                       <int key="connectionID">358</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fPictureViewArea</string>
+                                               <string key="label">fDetelecineField</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="208214895"/>
+                                               <reference key="destination" ref="1003980650"/>
                                        </object>
-                                       <int key="connectionID">183</int>
+                                       <int key="connectionID">359</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">window</string>
+                                               <string key="label">fDecombDeinterlaceBox</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="616825745"/>
+                                               <reference key="destination" ref="211309117"/>
                                        </object>
-                                       <int key="connectionID">184</int>
+                                       <int key="connectionID">360</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDecombDeinterlaceSlider</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="985124611"/>
+                                       </object>
+                                       <int key="connectionID">361</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">fDecombPopUp</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="878291110"/>
+                                               <reference key="destination" ref="356573645"/>
                                        </object>
-                                       <int key="connectionID">193</int>
+                                       <int key="connectionID">362</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBActionConnection" key="connection">
-                                               <string key="label">SettingsChanged:</string>
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDecombField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="103870225"/>
+                                       </object>
+                                       <int key="connectionID">363</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDecombBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="889994612"/>
+                                       </object>
+                                       <int key="connectionID">364</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDeinterlaceBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="136990045"/>
+                                       </object>
+                                       <int key="connectionID">365</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDeinterlacePopUp</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="850427642"/>
+                                       </object>
+                                       <int key="connectionID">366</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDeinterlaceField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="181376038"/>
+                                       </object>
+                                       <int key="connectionID">367</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDenoiseBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="691710132"/>
+                                       </object>
+                                       <int key="connectionID">368</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDenoisePopUp</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="878291110"/>
+                                               <reference key="destination" ref="362740356"/>
                                        </object>
-                                       <int key="connectionID">194</int>
+                                       <int key="connectionID">369</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDenoiseField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="529723890"/>
+                                       </object>
+                                       <int key="connectionID">370</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">fDeblockSlider</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="581126685"/>
+                                               <reference key="destination" ref="703236195"/>
+                                       </object>
+                                       <int key="connectionID">371</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDeblockField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="345974679"/>
+                                       </object>
+                                       <int key="connectionID">372</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fGrayscaleCheck</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="1021739901"/>
+                                       </object>
+                                       <int key="connectionID">373</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">FilterSettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="444006373"/>
+                                       </object>
+                                       <int key="connectionID">374</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">FilterSettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="356573645"/>
+                                       </object>
+                                       <int key="connectionID">375</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">FilterSettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="850427642"/>
+                                       </object>
+                                       <int key="connectionID">377</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">FilterSettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="362740356"/>
                                        </object>
-                                       <int key="connectionID">202</int>
+                                       <int key="connectionID">378</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">deblockSliderChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="581126685"/>
+                                               <reference key="destination" ref="703236195"/>
                                        </object>
-                                       <int key="connectionID">203</int>
+                                       <int key="connectionID">379</int>
                                </object>
                                <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">fDeblockField</string>
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">FilterSettingsChanged:</string>
                                                <reference key="source" ref="355312334"/>
-                                               <reference key="destination" ref="314638156"/>
+                                               <reference key="destination" ref="1021739901"/>
                                        </object>
-                                       <int key="connectionID">206</int>
+                                       <int key="connectionID">380</int>
                                </object>
-                       </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">modeDecombDeinterlaceSliderChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="985124611"/>
+                                       </object>
+                                       <int key="connectionID">381</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fModulusPopUp</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="387637584"/>
+                                       </object>
+                                       <int key="connectionID">392</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">SettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="387637584"/>
+                                       </object>
+                                       <int key="connectionID">393</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDisplayWidthField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="924352608"/>
+                                       </object>
+                                       <int key="connectionID">407</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fSizeFilterView</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="570027662"/>
+                                       </object>
+                                       <int key="connectionID">419</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">delegate</string>
+                                               <reference key="source" ref="570027662"/>
+                                               <reference key="destination" ref="355312334"/>
+                                       </object>
+                                       <int key="connectionID">420</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDeblockBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="825796162"/>
+                                       </object>
+                                       <int key="connectionID">434</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fPictureSizeBox</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="291242569"/>
+                                       </object>
+                                       <int key="connectionID">437</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fParWidthField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="998049160"/>
+                                       </object>
+                                       <int key="connectionID">448</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fParHeightField</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="601215307"/>
+                                       </object>
+                                       <int key="connectionID">449</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">SettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="998049160"/>
+                                       </object>
+                                       <int key="connectionID">453</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">SettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="924352608"/>
+                                       </object>
+                                       <int key="connectionID">454</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">SettingsChanged:</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="601215307"/>
+                                       </object>
+                                       <int key="connectionID">456</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fRatioLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="973216726"/>
+                                       </object>
+                                       <int key="connectionID">522</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fParWidthLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="122509689"/>
+                                       </object>
+                                       <int key="connectionID">524</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fParHeightLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="810439401"/>
+                                       </object>
+                                       <int key="connectionID">525</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fDisplayWidthLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="84657333"/>
+                                       </object>
+                                       <int key="connectionID">526</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fRatioLabel2</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="231562326"/>
+                                       </object>
+                                       <int key="connectionID">531</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fModulusLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="902766107"/>
+                                       </object>
+                                       <int key="connectionID">532</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">fWidthLabel</string>
+                                               <reference key="source" ref="355312334"/>
+                                               <reference key="destination" ref="569671425"/>
+                                       </object>
+                                       <int key="connectionID">533</int>
+                               </object>
+                       </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                <object class="NSArray" key="orderedObjects">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -1581,494 +2761,965 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                <nil key="parent"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">-2</int>
-                                               <reference key="object" ref="355312334"/>
-                                               <reference key="parent" ref="48079043"/>
-                                               <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+                                               <int key="objectID">-2</int>
+                                               <reference key="object" ref="355312334"/>
+                                               <reference key="parent" ref="48079043"/>
+                                               <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">-1</int>
+                                               <reference key="object" ref="844574444"/>
+                                               <reference key="parent" ref="48079043"/>
+                                               <string key="objectName">First Responder</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">-3</int>
+                                               <reference key="object" ref="837220151"/>
+                                               <reference key="parent" ref="48079043"/>
+                                               <string key="objectName">Application</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">5</int>
+                                               <reference key="object" ref="616825745"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="49161063"/>
+                                               </object>
+                                               <reference key="parent" ref="48079043"/>
+                                               <string key="objectName">PicturePanel</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">6</int>
+                                               <reference key="object" ref="49161063"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="922381307"/>
+                                                       <reference ref="892118626"/>
+                                                       <reference ref="154029488"/>
+                                                       <reference ref="570027662"/>
+                                               </object>
+                                               <reference key="parent" ref="616825745"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">262</int>
+                                               <reference key="object" ref="922381307"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1037100053"/>
+                                               </object>
+                                               <reference key="parent" ref="49161063"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">263</int>
+                                               <reference key="object" ref="1037100053"/>
+                                               <reference key="parent" ref="922381307"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">270</int>
+                                               <reference key="object" ref="892118626"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="533593716"/>
+                                               </object>
+                                               <reference key="parent" ref="49161063"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">271</int>
+                                               <reference key="object" ref="533593716"/>
+                                               <reference key="parent" ref="892118626"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">278</int>
+                                               <reference key="object" ref="154029488"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="63504302"/>
+                                               </object>
+                                               <reference key="parent" ref="49161063"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">279</int>
+                                               <reference key="object" ref="63504302"/>
+                                               <reference key="parent" ref="154029488"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">281</int>
+                                               <reference key="object" ref="570027662"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="184512336"/>
+                                                       <reference ref="1059808840"/>
+                                               </object>
+                                               <reference key="parent" ref="49161063"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">282</int>
+                                               <reference key="object" ref="184512336"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="490590002"/>
+                                               </object>
+                                               <reference key="parent" ref="570027662"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">283</int>
+                                               <reference key="object" ref="1059808840"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="49700183"/>
+                                               </object>
+                                               <reference key="parent" ref="570027662"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">284</int>
+                                               <reference key="object" ref="49700183"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="123709997"/>
+                                                       <reference ref="691710132"/>
+                                                       <reference ref="211309117"/>
+                                                       <reference ref="825796162"/>
+                                               </object>
+                                               <reference key="parent" ref="1059808840"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">285</int>
+                                               <reference key="object" ref="490590002"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="291242569"/>
+                                                       <reference ref="1064912113"/>
+                                               </object>
+                                               <reference key="parent" ref="184512336"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">7</int>
+                                               <reference key="object" ref="1064912113"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="194145642"/>
+                                                       <reference ref="133033963"/>
+                                                       <reference ref="842452881"/>
+                                                       <reference ref="1067684983"/>
+                                                       <reference ref="773085513"/>
+                                                       <reference ref="897162141"/>
+                                                       <reference ref="1032624817"/>
+                                                       <reference ref="510144318"/>
+                                                       <reference ref="580805308"/>
+                                                       <reference ref="411931143"/>
+                                                       <reference ref="294892452"/>
+                                                       <reference ref="1021399174"/>
+                                               </object>
+                                               <reference key="parent" ref="490590002"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">252</int>
+                                               <reference key="object" ref="194145642"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="664940567"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">250</int>
+                                               <reference key="object" ref="1021399174"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="215687429"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">14</int>
+                                               <reference key="object" ref="133033963"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="71578223"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">11</int>
+                                               <reference key="object" ref="842452881"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="904241294"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">9</int>
+                                               <reference key="object" ref="411931143"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1050606643"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">19</int>
+                                               <reference key="object" ref="1067684983"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="996643427"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">10</int>
+                                               <reference key="object" ref="773085513"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="634956024"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">13</int>
+                                               <reference key="object" ref="897162141"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="936113070"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">16</int>
+                                               <reference key="object" ref="1032624817"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="660067650"/>
+                                                       <reference ref="288116155"/>
+                                                       <reference ref="643930266"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">15</int>
+                                               <reference key="object" ref="510144318"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="759792686"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">12</int>
+                                               <reference key="object" ref="580805308"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="44321990"/>
+                                               </object>
+                                               <reference key="parent" ref="1064912113"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">152</int>
+                                               <reference key="object" ref="44321990"/>
+                                               <reference key="parent" ref="580805308"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">155</int>
+                                               <reference key="object" ref="759792686"/>
+                                               <reference key="parent" ref="510144318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">17</int>
+                                               <reference key="object" ref="660067650"/>
+                                               <reference key="parent" ref="1032624817"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">18</int>
+                                               <reference key="object" ref="288116155"/>
+                                               <reference key="parent" ref="1032624817"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">178</int>
+                                               <reference key="object" ref="643930266"/>
+                                               <reference key="parent" ref="1032624817"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">153</int>
+                                               <reference key="object" ref="936113070"/>
+                                               <reference key="parent" ref="897162141"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">150</int>
+                                               <reference key="object" ref="634956024"/>
+                                               <reference key="parent" ref="773085513"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">156</int>
+                                               <reference key="object" ref="996643427"/>
+                                               <reference key="parent" ref="1067684983"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">149</int>
+                                               <reference key="object" ref="1050606643"/>
+                                               <reference key="parent" ref="411931143"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">151</int>
+                                               <reference key="object" ref="904241294"/>
+                                               <reference key="parent" ref="842452881"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">-1</int>
-                                               <reference key="object" ref="844574444"/>
-                                               <reference key="parent" ref="48079043"/>
-                                               <string key="objectName">First Responder</string>
+                                               <int key="objectID">154</int>
+                                               <reference key="object" ref="71578223"/>
+                                               <reference key="parent" ref="133033963"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">-3</int>
-                                               <reference key="object" ref="837220151"/>
-                                               <reference key="parent" ref="48079043"/>
-                                               <string key="objectName">Application</string>
+                                               <int key="objectID">251</int>
+                                               <reference key="object" ref="215687429"/>
+                                               <reference key="parent" ref="1021399174"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">5</int>
-                                               <reference key="object" ref="616825745"/>
+                                               <int key="objectID">253</int>
+                                               <reference key="object" ref="664940567"/>
+                                               <reference key="parent" ref="194145642"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">286</int>
+                                               <reference key="object" ref="123709997"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="49161063"/>
+                                                       <reference ref="1003980650"/>
+                                                       <reference ref="675657376"/>
+                                                       <reference ref="444006373"/>
+                                                       <reference ref="907249437"/>
                                                </object>
-                                               <reference key="parent" ref="48079043"/>
-                                               <string key="objectName">PicturePanel</string>
+                                               <reference key="parent" ref="49700183"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">6</int>
-                                               <reference key="object" ref="49161063"/>
+                                               <int key="objectID">287</int>
+                                               <reference key="object" ref="211309117"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1064912113"/>
-                                                       <reference ref="309105014"/>
-                                                       <reference ref="208214895"/>
-                                                       <reference ref="844127024"/>
-                                                       <reference ref="41752677"/>
-                                                       <reference ref="862464620"/>
-                                                       <reference ref="574970834"/>
-                                                       <reference ref="628196212"/>
-                                                       <reference ref="345100891"/>
-                                                       <reference ref="1011917013"/>
+                                                       <reference ref="478887050"/>
+                                                       <reference ref="873921736"/>
+                                                       <reference ref="985124611"/>
+                                                       <reference ref="889994612"/>
+                                                       <reference ref="136990045"/>
                                                </object>
-                                               <reference key="parent" ref="616825745"/>
+                                               <reference key="parent" ref="49700183"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">7</int>
-                                               <reference key="object" ref="1064912113"/>
+                                               <int key="objectID">288</int>
+                                               <reference key="object" ref="691710132"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="580805308"/>
-                                                       <reference ref="510144318"/>
-                                                       <reference ref="1032624817"/>
-                                                       <reference ref="897162141"/>
-                                                       <reference ref="773085513"/>
-                                                       <reference ref="1067684983"/>
-                                                       <reference ref="411931143"/>
-                                                       <reference ref="842452881"/>
-                                                       <reference ref="133033963"/>
+                                                       <reference ref="407034984"/>
+                                                       <reference ref="929586587"/>
+                                                       <reference ref="529723890"/>
+                                                       <reference ref="362740356"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="49700183"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">21</int>
-                                               <reference key="object" ref="574970834"/>
+                                               <int key="objectID">299</int>
+                                               <reference key="object" ref="407034984"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <object class="NSView" id="391559465">
-                                                               <nil key="NSNextResponder"/>
-                                                               <int key="NSvFlags">256</int>
-                                                               <string key="NSFrame">{{2, 2}, {734, 1}}</string>
-                                                       </object>
+                                                       <reference ref="15366198"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="691710132"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">22</int>
-                                               <reference key="object" ref="391559465"/>
-                                               <reference key="parent" ref="574970834"/>
+                                               <int key="objectID">300</int>
+                                               <reference key="object" ref="362740356"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="625319255"/>
+                                               </object>
+                                               <reference key="parent" ref="691710132"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">23</int>
-                                               <reference key="object" ref="309105014"/>
+                                               <int key="objectID">301</int>
+                                               <reference key="object" ref="929586587"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="407610327"/>
-                                                       <reference ref="243795165"/>
-                                                       <reference ref="346912008"/>
-                                                       <reference ref="905607845"/>
-                                                       <reference ref="94419441"/>
-                                                       <reference ref="878291110"/>
-                                                       <reference ref="742513844"/>
-                                                       <reference ref="581126685"/>
-                                                       <reference ref="1069536323"/>
-                                                       <reference ref="314638156"/>
+                                                       <reference ref="601710816"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="691710132"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">38</int>
-                                               <reference key="object" ref="628196212"/>
+                                               <int key="objectID">302</int>
+                                               <reference key="object" ref="529723890"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="921881842"/>
+                                                       <reference ref="692527149"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="691710132"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">303</int>
+                                               <reference key="object" ref="692527149"/>
+                                               <reference key="parent" ref="529723890"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">304</int>
+                                               <reference key="object" ref="601710816"/>
+                                               <reference key="parent" ref="929586587"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">39</int>
-                                               <reference key="object" ref="1011917013"/>
+                                               <int key="objectID">305</int>
+                                               <reference key="object" ref="625319255"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="513894170"/>
-                                                       <reference ref="443002022"/>
-                                                       <reference ref="302614967"/>
-                                                       <reference ref="667015191"/>
-                                                       <reference ref="569671425"/>
-                                                       <reference ref="232869468"/>
-                                                       <reference ref="221469578"/>
-                                                       <reference ref="147098438"/>
-                                                       <reference ref="301555397"/>
+                                                       <reference ref="618343102"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="362740356"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">49</int>
-                                               <reference key="object" ref="862464620"/>
+                                               <int key="objectID">306</int>
+                                               <reference key="object" ref="618343102"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="212457967"/>
+                                                       <reference ref="865792840"/>
+                                                       <reference ref="107429478"/>
+                                                       <reference ref="535683643"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="625319255"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">307</int>
+                                               <reference key="object" ref="865792840"/>
+                                               <reference key="parent" ref="618343102"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">308</int>
+                                               <reference key="object" ref="107429478"/>
+                                               <reference key="parent" ref="618343102"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">309</int>
+                                               <reference key="object" ref="535683643"/>
+                                               <reference key="parent" ref="618343102"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">50</int>
-                                               <reference key="object" ref="345100891"/>
+                                               <int key="objectID">310</int>
+                                               <reference key="object" ref="15366198"/>
+                                               <reference key="parent" ref="407034984"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">311</int>
+                                               <reference key="object" ref="478887050"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="352183359"/>
+                                                       <reference ref="940230908"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="211309117"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">52</int>
-                                               <reference key="object" ref="41752677"/>
+                                               <int key="objectID">312</int>
+                                               <reference key="object" ref="873921736"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="785935474"/>
+                                                       <reference ref="475982274"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="211309117"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">92</int>
-                                               <reference key="object" ref="208214895"/>
+                                               <int key="objectID">313</int>
+                                               <reference key="object" ref="985124611"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="288804516"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="211309117"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">165</int>
-                                               <reference key="object" ref="921881842"/>
-                                               <reference key="parent" ref="628196212"/>
+                                               <int key="objectID">315</int>
+                                               <reference key="object" ref="889994612"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="103870225"/>
+                                                       <reference ref="652411918"/>
+                                                       <reference ref="356573645"/>
+                                                       <reference ref="7173206"/>
+                                               </object>
+                                               <reference key="parent" ref="211309117"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">175</int>
-                                               <reference key="object" ref="212457967"/>
-                                               <reference key="parent" ref="862464620"/>
+                                               <int key="objectID">316</int>
+                                               <reference key="object" ref="103870225"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="558197217"/>
+                                               </object>
+                                               <reference key="parent" ref="889994612"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">176</int>
-                                               <reference key="object" ref="352183359"/>
-                                               <reference key="parent" ref="345100891"/>
+                                               <int key="objectID">317</int>
+                                               <reference key="object" ref="652411918"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="908484803"/>
+                                               </object>
+                                               <reference key="parent" ref="889994612"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">177</int>
-                                               <reference key="object" ref="785935474"/>
-                                               <reference key="parent" ref="41752677"/>
+                                               <int key="objectID">318</int>
+                                               <reference key="object" ref="356573645"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="454070103"/>
+                                               </object>
+                                               <reference key="parent" ref="889994612"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">12</int>
-                                               <reference key="object" ref="580805308"/>
+                                               <int key="objectID">319</int>
+                                               <reference key="object" ref="7173206"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="44321990"/>
+                                                       <reference ref="695838500"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="889994612"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">152</int>
-                                               <reference key="object" ref="44321990"/>
-                                               <reference key="parent" ref="580805308"/>
+                                               <int key="objectID">320</int>
+                                               <reference key="object" ref="695838500"/>
+                                               <reference key="parent" ref="7173206"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">15</int>
-                                               <reference key="object" ref="510144318"/>
+                                               <int key="objectID">321</int>
+                                               <reference key="object" ref="454070103"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="759792686"/>
+                                                       <reference ref="259868564"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">155</int>
-                                               <reference key="object" ref="759792686"/>
-                                               <reference key="parent" ref="510144318"/>
+                                               <reference key="parent" ref="356573645"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">16</int>
-                                               <reference key="object" ref="1032624817"/>
+                                               <int key="objectID">322</int>
+                                               <reference key="object" ref="259868564"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="643930266"/>
-                                                       <reference ref="288116155"/>
-                                                       <reference ref="660067650"/>
+                                                       <reference ref="720143866"/>
+                                                       <reference ref="414039981"/>
+                                                       <reference ref="197481337"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="454070103"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">178</int>
-                                               <reference key="object" ref="643930266"/>
-                                               <reference key="parent" ref="1032624817"/>
+                                               <int key="objectID">323</int>
+                                               <reference key="object" ref="720143866"/>
+                                               <reference key="parent" ref="259868564"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">18</int>
-                                               <reference key="object" ref="288116155"/>
-                                               <reference key="parent" ref="1032624817"/>
+                                               <int key="objectID">324</int>
+                                               <reference key="object" ref="414039981"/>
+                                               <reference key="parent" ref="259868564"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">17</int>
-                                               <reference key="object" ref="660067650"/>
-                                               <reference key="parent" ref="1032624817"/>
+                                               <int key="objectID">325</int>
+                                               <reference key="object" ref="197481337"/>
+                                               <reference key="parent" ref="259868564"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">13</int>
-                                               <reference key="object" ref="897162141"/>
+                                               <int key="objectID">326</int>
+                                               <reference key="object" ref="908484803"/>
+                                               <reference key="parent" ref="652411918"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">327</int>
+                                               <reference key="object" ref="558197217"/>
+                                               <reference key="parent" ref="103870225"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">340</int>
+                                               <reference key="object" ref="288804516"/>
+                                               <reference key="parent" ref="985124611"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">341</int>
+                                               <reference key="object" ref="475982274"/>
+                                               <reference key="parent" ref="873921736"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">342</int>
+                                               <reference key="object" ref="940230908"/>
+                                               <reference key="parent" ref="478887050"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">343</int>
+                                               <reference key="object" ref="1003980650"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="936113070"/>
+                                                       <reference ref="673987852"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="123709997"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">153</int>
-                                               <reference key="object" ref="936113070"/>
-                                               <reference key="parent" ref="897162141"/>
+                                               <int key="objectID">344</int>
+                                               <reference key="object" ref="675657376"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="42393523"/>
+                                               </object>
+                                               <reference key="parent" ref="123709997"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">10</int>
-                                               <reference key="object" ref="773085513"/>
+                                               <int key="objectID">345</int>
+                                               <reference key="object" ref="444006373"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="634956024"/>
+                                                       <reference ref="225659946"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="123709997"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">150</int>
-                                               <reference key="object" ref="634956024"/>
-                                               <reference key="parent" ref="773085513"/>
+                                               <int key="objectID">346</int>
+                                               <reference key="object" ref="907249437"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="20607951"/>
+                                               </object>
+                                               <reference key="parent" ref="123709997"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">19</int>
-                                               <reference key="object" ref="1067684983"/>
+                                               <int key="objectID">347</int>
+                                               <reference key="object" ref="20607951"/>
+                                               <reference key="parent" ref="907249437"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">348</int>
+                                               <reference key="object" ref="225659946"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="996643427"/>
+                                                       <reference ref="822312097"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="444006373"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">156</int>
-                                               <reference key="object" ref="996643427"/>
-                                               <reference key="parent" ref="1067684983"/>
+                                               <int key="objectID">349</int>
+                                               <reference key="object" ref="822312097"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="237877455"/>
+                                                       <reference ref="621985928"/>
+                                                       <reference ref="1040778121"/>
+                                               </object>
+                                               <reference key="parent" ref="225659946"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">9</int>
-                                               <reference key="object" ref="411931143"/>
+                                               <int key="objectID">350</int>
+                                               <reference key="object" ref="237877455"/>
+                                               <reference key="parent" ref="822312097"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">351</int>
+                                               <reference key="object" ref="621985928"/>
+                                               <reference key="parent" ref="822312097"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">352</int>
+                                               <reference key="object" ref="1040778121"/>
+                                               <reference key="parent" ref="822312097"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">353</int>
+                                               <reference key="object" ref="42393523"/>
+                                               <reference key="parent" ref="675657376"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">354</int>
+                                               <reference key="object" ref="673987852"/>
+                                               <reference key="parent" ref="1003980650"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">382</int>
+                                               <reference key="object" ref="294892452"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1050606643"/>
+                                                       <reference ref="511041238"/>
                                                </object>
                                                <reference key="parent" ref="1064912113"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">149</int>
-                                               <reference key="object" ref="1050606643"/>
-                                               <reference key="parent" ref="411931143"/>
+                                               <int key="objectID">383</int>
+                                               <reference key="object" ref="511041238"/>
+                                               <reference key="parent" ref="294892452"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">11</int>
-                                               <reference key="object" ref="842452881"/>
+                                               <int key="objectID">314</int>
+                                               <reference key="object" ref="136990045"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="904241294"/>
+                                                       <reference ref="181376038"/>
+                                                       <reference ref="455753488"/>
+                                                       <reference ref="707016708"/>
+                                                       <reference ref="850427642"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="211309117"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">151</int>
-                                               <reference key="object" ref="904241294"/>
-                                               <reference key="parent" ref="842452881"/>
+                                               <int key="objectID">329</int>
+                                               <reference key="object" ref="181376038"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="240437779"/>
+                                               </object>
+                                               <reference key="parent" ref="136990045"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">14</int>
-                                               <reference key="object" ref="133033963"/>
+                                               <int key="objectID">331</int>
+                                               <reference key="object" ref="455753488"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="71578223"/>
+                                                       <reference ref="733163980"/>
                                                </object>
-                                               <reference key="parent" ref="1064912113"/>
+                                               <reference key="parent" ref="136990045"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">154</int>
-                                               <reference key="object" ref="71578223"/>
-                                               <reference key="parent" ref="133033963"/>
+                                               <int key="objectID">330</int>
+                                               <reference key="object" ref="707016708"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1039358237"/>
+                                               </object>
+                                               <reference key="parent" ref="136990045"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">32</int>
-                                               <reference key="object" ref="346912008"/>
+                                               <int key="objectID">328</int>
+                                               <reference key="object" ref="850427642"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1034367716"/>
+                                                       <reference ref="247704759"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="136990045"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">161</int>
-                                               <reference key="object" ref="1034367716"/>
+                                               <int key="objectID">335</int>
+                                               <reference key="object" ref="247704759"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="132523332"/>
+                                                       <reference ref="579462485"/>
                                                </object>
-                                               <reference key="parent" ref="346912008"/>
+                                               <reference key="parent" ref="850427642"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">33</int>
-                                               <reference key="object" ref="132523332"/>
+                                               <int key="objectID">336</int>
+                                               <reference key="object" ref="579462485"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="937797455"/>
-                                                       <reference ref="71282261"/>
-                                                       <reference ref="542784764"/>
+                                                       <reference ref="391113581"/>
+                                                       <reference ref="770160669"/>
+                                                       <reference ref="683933257"/>
                                                </object>
-                                               <reference key="parent" ref="1034367716"/>
+                                               <reference key="parent" ref="247704759"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">339</int>
+                                               <reference key="object" ref="391113581"/>
+                                               <reference key="parent" ref="579462485"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">34</int>
-                                               <reference key="object" ref="937797455"/>
-                                               <reference key="parent" ref="132523332"/>
+                                               <int key="objectID">338</int>
+                                               <reference key="object" ref="770160669"/>
+                                               <reference key="parent" ref="579462485"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">35</int>
-                                               <reference key="object" ref="71282261"/>
-                                               <reference key="parent" ref="132523332"/>
+                                               <int key="objectID">337</int>
+                                               <reference key="object" ref="683933257"/>
+                                               <reference key="parent" ref="579462485"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">36</int>
-                                               <reference key="object" ref="542784764"/>
-                                               <reference key="parent" ref="132523332"/>
+                                               <int key="objectID">333</int>
+                                               <reference key="object" ref="1039358237"/>
+                                               <reference key="parent" ref="707016708"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">30</int>
-                                               <reference key="object" ref="905607845"/>
+                                               <int key="objectID">332</int>
+                                               <reference key="object" ref="733163980"/>
+                                               <reference key="parent" ref="455753488"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">334</int>
+                                               <reference key="object" ref="240437779"/>
+                                               <reference key="parent" ref="181376038"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">421</int>
+                                               <reference key="object" ref="825796162"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="522867811"/>
+                                                       <reference ref="1021739901"/>
+                                                       <reference ref="703236195"/>
+                                                       <reference ref="345974679"/>
+                                                       <reference ref="1014567695"/>
+                                                       <reference ref="425499167"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="49700183"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">159</int>
-                                               <reference key="object" ref="522867811"/>
-                                               <reference key="parent" ref="905607845"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">37</int>
-                                               <reference key="object" ref="407610327"/>
+                                               <int key="objectID">289</int>
+                                               <reference key="object" ref="425499167"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="832714893"/>
+                                                       <reference ref="440135121"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="825796162"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">162</int>
-                                               <reference key="object" ref="832714893"/>
-                                               <reference key="parent" ref="407610327"/>
+                                               <int key="objectID">298</int>
+                                               <reference key="object" ref="440135121"/>
+                                               <reference key="parent" ref="425499167"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">25</int>
-                                               <reference key="object" ref="243795165"/>
+                                               <int key="objectID">290</int>
+                                               <reference key="object" ref="1014567695"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="708528272"/>
+                                                       <reference ref="922265218"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="825796162"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">297</int>
+                                               <reference key="object" ref="922265218"/>
+                                               <reference key="parent" ref="1014567695"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">158</int>
-                                               <reference key="object" ref="708528272"/>
+                                               <int key="objectID">291</int>
+                                               <reference key="object" ref="345974679"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="176321383"/>
+                                                       <reference ref="288379564"/>
                                                </object>
-                                               <reference key="parent" ref="243795165"/>
+                                               <reference key="parent" ref="825796162"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">26</int>
-                                               <reference key="object" ref="176321383"/>
+                                               <int key="objectID">296</int>
+                                               <reference key="object" ref="288379564"/>
+                                               <reference key="parent" ref="345974679"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">292</int>
+                                               <reference key="object" ref="703236195"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="114494573"/>
-                                                       <reference ref="750998660"/>
-                                                       <reference ref="133285043"/>
+                                                       <reference ref="145960326"/>
                                                </object>
-                                               <reference key="parent" ref="708528272"/>
+                                               <reference key="parent" ref="825796162"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">295</int>
+                                               <reference key="object" ref="145960326"/>
+                                               <reference key="parent" ref="703236195"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">27</int>
-                                               <reference key="object" ref="114494573"/>
-                                               <reference key="parent" ref="176321383"/>
+                                               <int key="objectID">293</int>
+                                               <reference key="object" ref="1021739901"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1059254264"/>
+                                               </object>
+                                               <reference key="parent" ref="825796162"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">28</int>
-                                               <reference key="object" ref="750998660"/>
-                                               <reference key="parent" ref="176321383"/>
+                                               <int key="objectID">294</int>
+                                               <reference key="object" ref="1059254264"/>
+                                               <reference key="parent" ref="1021739901"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">29</int>
-                                               <reference key="object" ref="133285043"/>
-                                               <reference key="parent" ref="176321383"/>
+                                               <int key="objectID">436</int>
+                                               <reference key="object" ref="291242569"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="667015191"/>
+                                                       <reference ref="513894170"/>
+                                                       <reference ref="301555397"/>
+                                                       <reference ref="443002022"/>
+                                                       <reference ref="221469578"/>
+                                                       <reference ref="232869468"/>
+                                                       <reference ref="569671425"/>
+                                                       <reference ref="387637584"/>
+                                                       <reference ref="902766107"/>
+                                                       <reference ref="147098438"/>
+                                                       <reference ref="302614967"/>
+                                                       <reference ref="973216726"/>
+                                                       <reference ref="998049160"/>
+                                                       <reference ref="122509689"/>
+                                                       <reference ref="601215307"/>
+                                                       <reference ref="810439401"/>
+                                                       <reference ref="231562326"/>
+                                                       <reference ref="84657333"/>
+                                                       <reference ref="924352608"/>
+                                               </object>
+                                               <reference key="parent" ref="490590002"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">31</int>
-                                               <reference key="object" ref="94419441"/>
+                                               <int key="objectID">44</int>
+                                               <reference key="object" ref="221469578"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="741873280"/>
+                                                       <reference ref="714433793"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">160</int>
-                                               <reference key="object" ref="741873280"/>
-                                               <reference key="parent" ref="94419441"/>
+                                               <int key="objectID">169</int>
+                                               <reference key="object" ref="714433793"/>
+                                               <reference key="parent" ref="221469578"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">41</int>
-                                               <reference key="object" ref="513894170"/>
+                                               <int key="objectID">384</int>
+                                               <reference key="object" ref="387637584"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="863668536"/>
+                                                       <reference ref="800808932"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">166</int>
-                                               <reference key="object" ref="863668536"/>
-                                               <reference key="parent" ref="513894170"/>
+                                               <int key="objectID">385</int>
+                                               <reference key="object" ref="800808932"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="246883325"/>
+                                               </object>
+                                               <reference key="parent" ref="387637584"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">43</int>
-                                               <reference key="object" ref="443002022"/>
+                                               <int key="objectID">386</int>
+                                               <reference key="object" ref="246883325"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="649389918"/>
+                                                       <reference ref="765075061"/>
+                                                       <reference ref="940982828"/>
+                                                       <reference ref="588147075"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="800808932"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">168</int>
-                                               <reference key="object" ref="649389918"/>
-                                               <reference key="parent" ref="443002022"/>
+                                               <int key="objectID">389</int>
+                                               <reference key="object" ref="765075061"/>
+                                               <reference key="parent" ref="246883325"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">45</int>
-                                               <reference key="object" ref="302614967"/>
+                                               <int key="objectID">388</int>
+                                               <reference key="object" ref="940982828"/>
+                                               <reference key="parent" ref="246883325"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">387</int>
+                                               <reference key="object" ref="588147075"/>
+                                               <reference key="parent" ref="246883325"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">42</int>
+                                               <reference key="object" ref="232869468"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="595088069"/>
+                                                       <reference ref="96315080"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">170</int>
-                                               <reference key="object" ref="595088069"/>
-                                               <reference key="parent" ref="302614967"/>
+                                               <int key="objectID">167</int>
+                                               <reference key="object" ref="96315080"/>
+                                               <reference key="parent" ref="232869468"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">46</int>
@@ -2077,7 +3728,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="634499157"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">171</int>
@@ -2085,46 +3736,32 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                <reference key="parent" ref="667015191"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">47</int>
-                                               <reference key="object" ref="569671425"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="412868245"/>
-                                               </object>
-                                               <reference key="parent" ref="1011917013"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">172</int>
-                                               <reference key="object" ref="412868245"/>
-                                               <reference key="parent" ref="569671425"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">42</int>
-                                               <reference key="object" ref="232869468"/>
+                                               <int key="objectID">138</int>
+                                               <reference key="object" ref="301555397"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="96315080"/>
+                                                       <reference ref="926890760"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">167</int>
-                                               <reference key="object" ref="96315080"/>
-                                               <reference key="parent" ref="232869468"/>
+                                               <int key="objectID">174</int>
+                                               <reference key="object" ref="926890760"/>
+                                               <reference key="parent" ref="301555397"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">44</int>
-                                               <reference key="object" ref="221469578"/>
+                                               <int key="objectID">41</int>
+                                               <reference key="object" ref="513894170"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="714433793"/>
+                                                       <reference ref="863668536"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">169</int>
-                                               <reference key="object" ref="714433793"/>
-                                               <reference key="parent" ref="221469578"/>
+                                               <int key="objectID">166</int>
+                                               <reference key="object" ref="863668536"/>
+                                               <reference key="parent" ref="513894170"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">132</int>
@@ -2133,7 +3770,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="261514411"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">173</int>
@@ -2171,132 +3808,172 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                <reference key="parent" ref="577969360"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">138</int>
-                                               <reference key="object" ref="301555397"/>
+                                               <int key="objectID">390</int>
+                                               <reference key="object" ref="902766107"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="926890760"/>
+                                                       <reference ref="377264474"/>
                                                </object>
-                                               <reference key="parent" ref="1011917013"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">174</int>
-                                               <reference key="object" ref="926890760"/>
-                                               <reference key="parent" ref="301555397"/>
+                                               <int key="objectID">391</int>
+                                               <reference key="object" ref="377264474"/>
+                                               <reference key="parent" ref="902766107"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">179</int>
-                                               <reference key="object" ref="844127024"/>
+                                               <int key="objectID">47</int>
+                                               <reference key="object" ref="569671425"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="955430771"/>
+                                                       <reference ref="412868245"/>
                                                </object>
-                                               <reference key="parent" ref="49161063"/>
+                                               <reference key="parent" ref="291242569"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">172</int>
+                                               <reference key="object" ref="412868245"/>
+                                               <reference key="parent" ref="569671425"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">43</int>
+                                               <reference key="object" ref="443002022"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="649389918"/>
+                                               </object>
+                                               <reference key="parent" ref="291242569"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">168</int>
+                                               <reference key="object" ref="649389918"/>
+                                               <reference key="parent" ref="443002022"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">45</int>
+                                               <reference key="object" ref="302614967"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="595088069"/>
+                                               </object>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">180</int>
-                                               <reference key="object" ref="955430771"/>
-                                               <reference key="parent" ref="844127024"/>
+                                               <int key="objectID">170</int>
+                                               <reference key="object" ref="595088069"/>
+                                               <reference key="parent" ref="302614967"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">185</int>
-                                               <reference key="object" ref="878291110"/>
+                                               <int key="objectID">244</int>
+                                               <reference key="object" ref="973216726"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="162356603"/>
+                                                       <reference ref="910777593"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">186</int>
-                                               <reference key="object" ref="742513844"/>
+                                               <int key="objectID">245</int>
+                                               <reference key="object" ref="910777593"/>
+                                               <reference key="parent" ref="973216726"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">402</int>
+                                               <reference key="object" ref="84657333"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="604349861"/>
+                                                       <reference ref="752977354"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">187</int>
-                                               <reference key="object" ref="604349861"/>
-                                               <reference key="parent" ref="742513844"/>
+                                               <int key="objectID">403</int>
+                                               <reference key="object" ref="752977354"/>
+                                               <reference key="parent" ref="84657333"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">188</int>
-                                               <reference key="object" ref="162356603"/>
+                                               <int key="objectID">440</int>
+                                               <reference key="object" ref="998049160"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="146867052"/>
+                                                       <reference ref="564975975"/>
                                                </object>
-                                               <reference key="parent" ref="878291110"/>
+                                               <reference key="parent" ref="291242569"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">441</int>
+                                               <reference key="object" ref="564975975"/>
+                                               <reference key="parent" ref="998049160"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">189</int>
-                                               <reference key="object" ref="146867052"/>
+                                               <int key="objectID">442</int>
+                                               <reference key="object" ref="601215307"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="43352374"/>
-                                                       <reference ref="226508779"/>
-                                                       <reference ref="170535567"/>
+                                                       <reference ref="119145016"/>
                                                </object>
-                                               <reference key="parent" ref="162356603"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">190</int>
-                                               <reference key="object" ref="43352374"/>
-                                               <reference key="parent" ref="146867052"/>
+                                               <int key="objectID">443</int>
+                                               <reference key="object" ref="119145016"/>
+                                               <reference key="parent" ref="601215307"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">191</int>
-                                               <reference key="object" ref="226508779"/>
-                                               <reference key="parent" ref="146867052"/>
+                                               <int key="objectID">444</int>
+                                               <reference key="object" ref="122509689"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="486553162"/>
+                                               </object>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">192</int>
-                                               <reference key="object" ref="170535567"/>
-                                               <reference key="parent" ref="146867052"/>
+                                               <int key="objectID">445</int>
+                                               <reference key="object" ref="486553162"/>
+                                               <reference key="parent" ref="122509689"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">195</int>
-                                               <reference key="object" ref="581126685"/>
+                                               <int key="objectID">446</int>
+                                               <reference key="object" ref="810439401"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="257047106"/>
+                                                       <reference ref="134407475"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">196</int>
-                                               <reference key="object" ref="257047106"/>
-                                               <reference key="parent" ref="581126685"/>
+                                               <int key="objectID">447</int>
+                                               <reference key="object" ref="134407475"/>
+                                               <reference key="parent" ref="810439401"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">197</int>
-                                               <reference key="object" ref="1069536323"/>
+                                               <int key="objectID">529</int>
+                                               <reference key="object" ref="231562326"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="728722104"/>
+                                                       <reference ref="87951024"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">198</int>
-                                               <reference key="object" ref="728722104"/>
-                                               <reference key="parent" ref="1069536323"/>
+                                               <int key="objectID">530</int>
+                                               <reference key="object" ref="87951024"/>
+                                               <reference key="parent" ref="231562326"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">204</int>
-                                               <reference key="object" ref="314638156"/>
+                                               <int key="objectID">396</int>
+                                               <reference key="object" ref="924352608"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="350598908"/>
+                                                       <reference ref="617679053"/>
                                                </object>
-                                               <reference key="parent" ref="309105014"/>
+                                               <reference key="parent" ref="291242569"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">205</int>
-                                               <reference key="object" ref="350598908"/>
-                                               <reference key="parent" ref="314638156"/>
+                                               <int key="objectID">397</int>
+                                               <reference key="object" ref="617679053"/>
+                                               <reference key="parent" ref="924352608"/>
                                        </object>
                                </object>
                        </object>
@@ -2330,90 +4007,224 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                        <string>138.ImportedFromIB2</string>
                                        <string>14.IBPluginDependency</string>
                                        <string>14.ImportedFromIB2</string>
+                                       <string>149.IBPluginDependency</string>
                                        <string>15.IBPluginDependency</string>
                                        <string>15.ImportedFromIB2</string>
+                                       <string>150.IBPluginDependency</string>
+                                       <string>151.IBPluginDependency</string>
+                                       <string>152.IBPluginDependency</string>
+                                       <string>153.IBPluginDependency</string>
+                                       <string>154.IBPluginDependency</string>
+                                       <string>155.IBPluginDependency</string>
+                                       <string>156.IBPluginDependency</string>
                                        <string>16.IBPluginDependency</string>
                                        <string>16.ImportedFromIB2</string>
+                                       <string>166.IBPluginDependency</string>
+                                       <string>167.IBPluginDependency</string>
+                                       <string>168.IBPluginDependency</string>
+                                       <string>169.IBPluginDependency</string>
                                        <string>17.IBPluginDependency</string>
                                        <string>17.ImportedFromIB2</string>
-                                       <string>179.IBPluginDependency</string>
+                                       <string>170.IBPluginDependency</string>
+                                       <string>171.IBPluginDependency</string>
+                                       <string>172.IBPluginDependency</string>
+                                       <string>173.IBPluginDependency</string>
+                                       <string>174.IBPluginDependency</string>
+                                       <string>178.IBPluginDependency</string>
                                        <string>18.IBPluginDependency</string>
                                        <string>18.ImportedFromIB2</string>
-                                       <string>180.IBPluginDependency</string>
-                                       <string>185.IBPluginDependency</string>
-                                       <string>185.ImportedFromIB2</string>
-                                       <string>186.IBPluginDependency</string>
-                                       <string>186.ImportedFromIB2</string>
-                                       <string>189.IBPluginDependency</string>
-                                       <string>189.ImportedFromIB2</string>
                                        <string>19.IBPluginDependency</string>
                                        <string>19.ImportedFromIB2</string>
-                                       <string>190.IBPluginDependency</string>
-                                       <string>190.ImportedFromIB2</string>
-                                       <string>191.IBPluginDependency</string>
-                                       <string>191.ImportedFromIB2</string>
-                                       <string>192.IBPluginDependency</string>
-                                       <string>192.ImportedFromIB2</string>
-                                       <string>195.IBPluginDependency</string>
-                                       <string>196.IBPluginDependency</string>
-                                       <string>197.IBPluginDependency</string>
-                                       <string>197.ImportedFromIB2</string>
-                                       <string>204.IBPluginDependency</string>
-                                       <string>204.ImportedFromIB2</string>
-                                       <string>21.IBPluginDependency</string>
-                                       <string>21.ImportedFromIB2</string>
-                                       <string>22.IBPluginDependency</string>
-                                       <string>22.ImportedFromIB2</string>
-                                       <string>23.IBPluginDependency</string>
-                                       <string>23.ImportedFromIB2</string>
-                                       <string>25.IBPluginDependency</string>
-                                       <string>25.ImportedFromIB2</string>
-                                       <string>26.IBPluginDependency</string>
-                                       <string>26.ImportedFromIB2</string>
-                                       <string>27.IBPluginDependency</string>
-                                       <string>27.ImportedFromIB2</string>
-                                       <string>28.IBPluginDependency</string>
-                                       <string>28.ImportedFromIB2</string>
-                                       <string>29.IBPluginDependency</string>
-                                       <string>29.ImportedFromIB2</string>
-                                       <string>30.IBPluginDependency</string>
-                                       <string>30.ImportedFromIB2</string>
-                                       <string>31.IBPluginDependency</string>
-                                       <string>31.ImportedFromIB2</string>
-                                       <string>32.IBPluginDependency</string>
-                                       <string>32.ImportedFromIB2</string>
-                                       <string>33.IBPluginDependency</string>
-                                       <string>33.ImportedFromIB2</string>
-                                       <string>34.IBPluginDependency</string>
-                                       <string>34.ImportedFromIB2</string>
-                                       <string>35.IBPluginDependency</string>
-                                       <string>35.ImportedFromIB2</string>
-                                       <string>36.IBPluginDependency</string>
-                                       <string>36.ImportedFromIB2</string>
-                                       <string>37.IBPluginDependency</string>
-                                       <string>37.ImportedFromIB2</string>
-                                       <string>38.IBPluginDependency</string>
-                                       <string>38.ImportedFromIB2</string>
-                                       <string>39.IBPluginDependency</string>
-                                       <string>39.ImportedFromIB2</string>
+                                       <string>244.IBPluginDependency</string>
+                                       <string>244.ImportedFromIB2</string>
+                                       <string>245.IBPluginDependency</string>
+                                       <string>250.IBPluginDependency</string>
+                                       <string>250.ImportedFromIB2</string>
+                                       <string>251.IBPluginDependency</string>
+                                       <string>252.IBPluginDependency</string>
+                                       <string>252.ImportedFromIB2</string>
+                                       <string>253.IBPluginDependency</string>
+                                       <string>262.IBPluginDependency</string>
+                                       <string>262.ImportedFromIB2</string>
+                                       <string>263.IBPluginDependency</string>
+                                       <string>270.IBPluginDependency</string>
+                                       <string>271.IBPluginDependency</string>
+                                       <string>278.IBPluginDependency</string>
+                                       <string>278.ImportedFromIB2</string>
+                                       <string>279.IBPluginDependency</string>
+                                       <string>281.IBAttributePlaceholdersKey</string>
+                                       <string>281.IBPluginDependency</string>
+                                       <string>282.IBPluginDependency</string>
+                                       <string>283.IBPluginDependency</string>
+                                       <string>284.IBPluginDependency</string>
+                                       <string>285.IBPluginDependency</string>
+                                       <string>286.IBPluginDependency</string>
+                                       <string>287.IBPluginDependency</string>
+                                       <string>287.ImportedFromIB2</string>
+                                       <string>288.IBPluginDependency</string>
+                                       <string>289.IBPluginDependency</string>
+                                       <string>289.ImportedFromIB2</string>
+                                       <string>290.IBPluginDependency</string>
+                                       <string>290.ImportedFromIB2</string>
+                                       <string>291.IBPluginDependency</string>
+                                       <string>291.ImportedFromIB2</string>
+                                       <string>292.IBPluginDependency</string>
+                                       <string>292.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>292.IBViewIntegration.shadowColor</string>
+                                       <string>292.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>292.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>293.IBPluginDependency</string>
+                                       <string>294.IBPluginDependency</string>
+                                       <string>295.IBPluginDependency</string>
+                                       <string>296.IBPluginDependency</string>
+                                       <string>297.IBPluginDependency</string>
+                                       <string>298.IBPluginDependency</string>
+                                       <string>299.IBPluginDependency</string>
+                                       <string>299.ImportedFromIB2</string>
+                                       <string>300.IBPluginDependency</string>
+                                       <string>300.ImportedFromIB2</string>
+                                       <string>301.IBPluginDependency</string>
+                                       <string>301.ImportedFromIB2</string>
+                                       <string>302.IBPluginDependency</string>
+                                       <string>303.IBPluginDependency</string>
+                                       <string>304.IBPluginDependency</string>
+                                       <string>305.IBPluginDependency</string>
+                                       <string>306.IBPluginDependency</string>
+                                       <string>306.ImportedFromIB2</string>
+                                       <string>307.IBPluginDependency</string>
+                                       <string>307.ImportedFromIB2</string>
+                                       <string>308.IBPluginDependency</string>
+                                       <string>308.ImportedFromIB2</string>
+                                       <string>309.IBPluginDependency</string>
+                                       <string>309.ImportedFromIB2</string>
+                                       <string>310.IBPluginDependency</string>
+                                       <string>311.IBPluginDependency</string>
+                                       <string>311.ImportedFromIB2</string>
+                                       <string>312.IBPluginDependency</string>
+                                       <string>312.ImportedFromIB2</string>
+                                       <string>313.IBPluginDependency</string>
+                                       <string>313.IBViewIntegration.shadowBlurRadius</string>
+                                       <string>313.IBViewIntegration.shadowColor</string>
+                                       <string>313.IBViewIntegration.shadowOffsetHeight</string>
+                                       <string>313.IBViewIntegration.shadowOffsetWidth</string>
+                                       <string>314.IBPluginDependency</string>
+                                       <string>315.IBPluginDependency</string>
+                                       <string>316.IBPluginDependency</string>
+                                       <string>317.IBPluginDependency</string>
+                                       <string>317.ImportedFromIB2</string>
+                                       <string>318.IBPluginDependency</string>
+                                       <string>318.ImportedFromIB2</string>
+                                       <string>319.IBPluginDependency</string>
+                                       <string>319.ImportedFromIB2</string>
+                                       <string>320.IBPluginDependency</string>
+                                       <string>321.IBPluginDependency</string>
+                                       <string>322.IBEditorWindowLastContentRect</string>
+                                       <string>322.IBPluginDependency</string>
+                                       <string>322.ImportedFromIB2</string>
+                                       <string>323.IBPluginDependency</string>
+                                       <string>323.ImportedFromIB2</string>
+                                       <string>324.IBPluginDependency</string>
+                                       <string>324.ImportedFromIB2</string>
+                                       <string>325.IBPluginDependency</string>
+                                       <string>325.ImportedFromIB2</string>
+                                       <string>326.IBPluginDependency</string>
+                                       <string>327.IBPluginDependency</string>
+                                       <string>328.IBPluginDependency</string>
+                                       <string>328.ImportedFromIB2</string>
+                                       <string>329.IBPluginDependency</string>
+                                       <string>330.IBPluginDependency</string>
+                                       <string>330.ImportedFromIB2</string>
+                                       <string>331.IBPluginDependency</string>
+                                       <string>331.ImportedFromIB2</string>
+                                       <string>332.IBPluginDependency</string>
+                                       <string>333.IBPluginDependency</string>
+                                       <string>334.IBPluginDependency</string>
+                                       <string>335.IBPluginDependency</string>
+                                       <string>336.IBEditorWindowLastContentRect</string>
+                                       <string>336.IBPluginDependency</string>
+                                       <string>336.ImportedFromIB2</string>
+                                       <string>337.IBPluginDependency</string>
+                                       <string>337.ImportedFromIB2</string>
+                                       <string>338.IBPluginDependency</string>
+                                       <string>338.ImportedFromIB2</string>
+                                       <string>339.IBPluginDependency</string>
+                                       <string>339.ImportedFromIB2</string>
+                                       <string>340.IBPluginDependency</string>
+                                       <string>341.IBPluginDependency</string>
+                                       <string>342.IBPluginDependency</string>
+                                       <string>343.IBPluginDependency</string>
+                                       <string>344.IBPluginDependency</string>
+                                       <string>344.ImportedFromIB2</string>
+                                       <string>345.IBPluginDependency</string>
+                                       <string>345.ImportedFromIB2</string>
+                                       <string>346.IBPluginDependency</string>
+                                       <string>346.ImportedFromIB2</string>
+                                       <string>347.IBPluginDependency</string>
+                                       <string>348.IBPluginDependency</string>
+                                       <string>349.IBPluginDependency</string>
+                                       <string>349.ImportedFromIB2</string>
+                                       <string>350.IBPluginDependency</string>
+                                       <string>350.ImportedFromIB2</string>
+                                       <string>351.IBPluginDependency</string>
+                                       <string>351.ImportedFromIB2</string>
+                                       <string>352.IBPluginDependency</string>
+                                       <string>352.ImportedFromIB2</string>
+                                       <string>353.IBPluginDependency</string>
+                                       <string>354.IBPluginDependency</string>
+                                       <string>382.IBPluginDependency</string>
+                                       <string>382.ImportedFromIB2</string>
+                                       <string>383.IBPluginDependency</string>
+                                       <string>384.IBPluginDependency</string>
+                                       <string>384.ImportedFromIB2</string>
+                                       <string>385.IBPluginDependency</string>
+                                       <string>386.IBEditorWindowLastContentRect</string>
+                                       <string>386.IBPluginDependency</string>
+                                       <string>386.ImportedFromIB2</string>
+                                       <string>387.IBPluginDependency</string>
+                                       <string>387.ImportedFromIB2</string>
+                                       <string>388.IBPluginDependency</string>
+                                       <string>388.ImportedFromIB2</string>
+                                       <string>389.IBPluginDependency</string>
+                                       <string>389.ImportedFromIB2</string>
+                                       <string>390.IBPluginDependency</string>
+                                       <string>390.ImportedFromIB2</string>
+                                       <string>391.IBPluginDependency</string>
+                                       <string>396.IBPluginDependency</string>
+                                       <string>396.ImportedFromIB2</string>
+                                       <string>397.IBPluginDependency</string>
+                                       <string>402.IBPluginDependency</string>
+                                       <string>402.ImportedFromIB2</string>
+                                       <string>403.IBPluginDependency</string>
                                        <string>41.IBPluginDependency</string>
                                        <string>41.ImportedFromIB2</string>
                                        <string>42.IBPluginDependency</string>
                                        <string>42.ImportedFromIB2</string>
+                                       <string>421.IBPluginDependency</string>
                                        <string>43.IBPluginDependency</string>
                                        <string>43.ImportedFromIB2</string>
+                                       <string>436.IBPluginDependency</string>
                                        <string>44.IBPluginDependency</string>
                                        <string>44.ImportedFromIB2</string>
+                                       <string>440.IBPluginDependency</string>
+                                       <string>440.ImportedFromIB2</string>
+                                       <string>441.IBPluginDependency</string>
+                                       <string>442.IBPluginDependency</string>
+                                       <string>442.ImportedFromIB2</string>
+                                       <string>443.IBPluginDependency</string>
+                                       <string>444.IBPluginDependency</string>
+                                       <string>444.ImportedFromIB2</string>
+                                       <string>445.IBPluginDependency</string>
+                                       <string>446.IBPluginDependency</string>
+                                       <string>446.ImportedFromIB2</string>
+                                       <string>447.IBPluginDependency</string>
                                        <string>45.IBPluginDependency</string>
                                        <string>45.ImportedFromIB2</string>
                                        <string>46.IBPluginDependency</string>
                                        <string>46.ImportedFromIB2</string>
                                        <string>47.IBPluginDependency</string>
                                        <string>47.ImportedFromIB2</string>
-                                       <string>49.IBPluginDependency</string>
-                                       <string>49.ImportedFromIB2</string>
                                        <string>5.IBEditorWindowLastContentRect</string>
-                                       <string>5.IBPluginDependency</string>
+                                       <string>5.IBViewEditorWindowController.showingBoundsRectangles</string>
                                        <string>5.IBViewEditorWindowController.showingLayoutRectangles</string>
                                        <string>5.IBWindowTemplateEditedContentRect</string>
                                        <string>5.ImportedFromIB2</string>
@@ -2422,151 +4233,300 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                        <string>5.windowTemplate.hasMinSize</string>
                                        <string>5.windowTemplate.maxSize</string>
                                        <string>5.windowTemplate.minSize</string>
-                                       <string>50.IBPluginDependency</string>
-                                       <string>50.ImportedFromIB2</string>
-                                       <string>52.IBPluginDependency</string>
-                                       <string>52.ImportedFromIB2</string>
+                                       <string>529.IBPluginDependency</string>
+                                       <string>529.ImportedFromIB2</string>
+                                       <string>530.IBPluginDependency</string>
                                        <string>6.IBPluginDependency</string>
+                                       <string>6.IBUserGuides</string>
                                        <string>6.ImportedFromIB2</string>
                                        <string>7.IBPluginDependency</string>
                                        <string>7.ImportedFromIB2</string>
                                        <string>9.IBPluginDependency</string>
                                        <string>9.ImportedFromIB2</string>
-                                       <string>92.IBPluginDependency</string>
-                                       <string>92.ImportedFromIB2</string>
                                </object>
                                <object class="NSMutableArray" key="dict.values">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <integer value="1" id="9"/>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <real value="1.000000e+00"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <object class="NSMutableDictionary">
+                                               <string key="NS.key.0">InitialTabViewItem</string>
+                                               <object class="IBInitialTabViewItemAttribute" key="NS.object.0">
+                                                       <string key="name">InitialTabViewItem</string>
+                                                       <reference key="object" ref="570027662"/>
+                                                       <reference key="initialTabViewItem" ref="184512336"/>
+                                               </object>
+                                       </object>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="8"/>
+                                       <reference ref="6672969"/>
+                                       <reference ref="8"/>
+                                       <reference ref="8"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>{{462, 298}, {453, 558}}</string>
+                                       <reference ref="172944286"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <reference ref="8"/>
-                                       <string>{{462, 298}, {453, 558}}</string>
-                                       <reference ref="9"/>
+                                       <reference ref="6672969"/>
+                                       <reference ref="8"/>
+                                       <reference ref="8"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{873, 640}, {110, 48}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{873, 640}, {110, 48}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="172944286"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="484376035"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{772, 644}, {100, 48}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="484376035"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="484376035"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="484376035"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="484376035"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <real value="1.000000e+00"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <reference ref="559925184"/>
+                                       <string>{{-1077, 352}, {849, 399}}</string>
+                                       <boolean value="NO" id="6"/>
+                                       <reference ref="559925184"/>
+                                       <string>{{-1077, 352}, {849, 399}}</string>
+                                       <reference ref="559925184"/>
                                        <string>{{221, 276}, {533, 580}}</string>
-                                       <reference ref="9"/>
-                                       <reference ref="9"/>
+                                       <reference ref="8"/>
+                                       <reference ref="6"/>
                                        <string>{3.40282e+38, 3.40282e+38}</string>
-                                       <string>{453, 558}</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <string>{230, 500}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <real value="1.000000e+00"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <object class="NSMutableArray">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="IBUserGuide">
+                                                       <reference key="view" ref="49161063"/>
+                                                       <float key="location">0.000000e+00</float>
+                                                       <int key="affinity">1</int>
+                                               </object>
+                                               <object class="IBUserGuide">
+                                                       <reference key="view" ref="49161063"/>
+                                                       <float key="location">2.420000e+02</float>
+                                                       <int key="affinity">0</int>
+                                               </object>
+                                       </object>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <reference ref="559925184"/>
                                </object>
                        </object>
                        <object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -2589,7 +4549,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                        </object>
                        <nil key="sourceID"/>
-                       <int key="maxID">206</int>
+                       <int key="maxID">533</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2604,13 +4564,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
-                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="251078365">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
-                                       </object>
-                               </object>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBUserSource</string>
                                                <string key="minorKey"/>
@@ -2623,11 +4576,19 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                <bool key="EncodedWithXMLCoder">YES</bool>
                                                <object class="NSMutableArray" key="dict.sortedKeys">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <string>ClosePanel:</string>
-                                                       <string>NextPicture:</string>
-                                                       <string>PreviousPicture:</string>
+                                                       <string>FilterSettingsChanged:</string>
                                                        <string>SettingsChanged:</string>
+                                                       <string>adjustFilterDisplay:</string>
+                                                       <string>adjustSizingDisplay:</string>
                                                        <string>deblockSliderChanged:</string>
+                                                       <string>displayLinkChanged:</string>
+                                                       <string>modeDecombDeinterlaceSliderChanged:</string>
+                                                       <string>parLinkChanged:</string>
+                                                       <string>previewGoWindowed:</string>
+                                                       <string>resizeInspectorForTab:</string>
+                                                       <string>showPictureWindow:</string>
+                                                       <string>showPreviewWindow:</string>
+                                                       <string>storageLinkChanged:</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
@@ -2636,13 +4597,20 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>id</string>
                                                        <string>id</string>
                                                        <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
+                                                       <string>id</string>
                                                </object>
                                        </object>
                                        <object class="NSMutableDictionary" key="outlets">
                                                <bool key="EncodedWithXMLCoder">YES</bool>
                                                <object class="NSMutableArray" key="dict.sortedKeys">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <string>delegate</string>
                                                        <string>fAnamorphicPopUp</string>
                                                        <string>fCropBottomField</string>
                                                        <string>fCropBottomStepper</string>
@@ -2653,27 +4621,66 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>fCropRightStepper</string>
                                                        <string>fCropTopField</string>
                                                        <string>fCropTopStepper</string>
+                                                       <string>fDeblockBox</string>
                                                        <string>fDeblockCheck</string>
                                                        <string>fDeblockField</string>
                                                        <string>fDeblockSlider</string>
+                                                       <string>fDecombBox</string>
+                                                       <string>fDecombDeinterlaceBox</string>
+                                                       <string>fDecombDeinterlaceSlider</string>
+                                                       <string>fDecombField</string>
                                                        <string>fDecombPopUp</string>
+                                                       <string>fDeinterlaceBox</string>
+                                                       <string>fDeinterlaceField</string>
                                                        <string>fDeinterlacePopUp</string>
+                                                       <string>fDenoiseBox</string>
+                                                       <string>fDenoiseField</string>
                                                        <string>fDenoisePopUp</string>
-                                                       <string>fDetelecineCheck</string>
+                                                       <string>fDetelecineBox</string>
+                                                       <string>fDetelecineField</string>
+                                                       <string>fDetelecinePopUp</string>
+                                                       <string>fDisplayLinkParLabel</string>
+                                                       <string>fDisplayLinkSlider</string>
+                                                       <string>fDisplayLinkStorageLabel</string>
+                                                       <string>fDisplayWidthField</string>
+                                                       <string>fDisplayWidthLabel</string>
+                                                       <string>fFilterTabView</string>
+                                                       <string>fGrayscaleCheck</string>
                                                        <string>fHeightField</string>
                                                        <string>fHeightStepper</string>
                                                        <string>fInfoField</string>
-                                                       <string>fNextButton</string>
-                                                       <string>fPictureView</string>
-                                                       <string>fPictureViewArea</string>
-                                                       <string>fPrevButton</string>
+                                                       <string>fModulusLabel</string>
+                                                       <string>fModulusPopUp</string>
+                                                       <string>fParHeightField</string>
+                                                       <string>fParHeightLabel</string>
+                                                       <string>fParLinkDisplayLabel</string>
+                                                       <string>fParLinkSlider</string>
+                                                       <string>fParLinkStorageLabel</string>
+                                                       <string>fParWidthField</string>
+                                                       <string>fParWidthLabel</string>
+                                                       <string>fPictureCropBox</string>
+                                                       <string>fPictureFilterBox</string>
+                                                       <string>fPictureFiltersOpenButton</string>
+                                                       <string>fPictureSizeBox</string>
+                                                       <string>fPictureWindow</string>
+                                                       <string>fPreviewOpenButton</string>
                                                        <string>fRatioCheck</string>
+                                                       <string>fRatioLabel</string>
+                                                       <string>fRatioLabel2</string>
+                                                       <string>fResetParDarButton</string>
+                                                       <string>fSizeFilterView</string>
+                                                       <string>fSizeInfoField</string>
+                                                       <string>fSizeTabView</string>
+                                                       <string>fStorageLinkBox</string>
+                                                       <string>fStorageLinkDisplayLabel</string>
+                                                       <string>fStorageLinkParLabel</string>
+                                                       <string>fStorageLinkSlider</string>
                                                        <string>fWidthField</string>
+                                                       <string>fWidthLabel</string>
                                                        <string>fWidthStepper</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <string>id</string>
                                                        <string>NSPopUpButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSStepper</string>
@@ -2684,26 +4691,69 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA</bytes>
                                                        <string>NSStepper</string>
                                                        <string>NSTextField</string>
                                                        <string>NSStepper</string>
+                                                       <string>NSBox</string>
                                                        <string>NSButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSSlider</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSPopUpButton</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSPopUpButton</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTabViewItem</string>
                                                        <string>NSButton</string>
                                                        <string>NSTextField</string>
                                                        <string>NSStepper</string>
                                                        <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSPopUpButton</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSBox</string>
                                                        <string>NSButton</string>
-                                                       <string>NSImageView</string>
                                                        <string>NSBox</string>
+                                                       <string>NSWindow</string>
+                                                       <string>NSButton</string>
                                                        <string>NSButton</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSButton</string>
+                                                       <string>NSTabView</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTabViewItem</string>
+                                                       <string>NSBox</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSTextField</string>
+                                                       <string>NSSlider</string>
+                                                       <string>NSTextField</string>
                                                        <string>NSTextField</string>
                                                        <string>NSStepper</string>
                                                </object>
                                        </object>
-                                       <reference key="sourceIdentifier" ref="251078365"/>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBProjectSource</string>
+                                               <string key="minorKey">PictureController.h</string>
+                                       </object>
                                </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">PictureController</string>
index 800d408..85c1e68 100644 (file)
@@ -1,21 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
        <data>
                <int key="IBDocument.SystemTarget">1050</int>
-               <string key="IBDocument.SystemVersion">9F33</string>
-               <string key="IBDocument.InterfaceBuilderVersion">670</string>
-               <string key="IBDocument.AppKitVersion">949.34</string>
-               <string key="IBDocument.HIToolboxVersion">352.00</string>
+               <string key="IBDocument.SystemVersion">10B504</string>
+               <string key="IBDocument.InterfaceBuilderVersion">732</string>
+               <string key="IBDocument.AppKitVersion">1038.2</string>
+               <string key="IBDocument.HIToolboxVersion">437.00</string>
+               <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                       <string key="NS.object.0">732</string>
+               </object>
                <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
                        <bool key="EncodedWithXMLCoder">YES</bool>
-                       <integer value="236"/>
-                       <integer value="234"/>
+                       <integer value="235"/>
                        <integer value="233"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                </object>
+               <object class="NSMutableDictionary" key="IBDocument.Metadata">
+                       <bool key="EncodedWithXMLCoder">YES</bool>
+                       <object class="NSArray" key="dict.sortedKeys" id="0">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+                       <object class="NSMutableArray" key="dict.values">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                       </object>
+               </object>
                <object class="NSMutableArray" key="IBDocument.RootObjects" id="185275739">
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <object class="NSCustomObject" id="169862212">
                                <int key="NSWindowStyleMask">3</int>
                                <int key="NSWindowBacking">2</int>
                                <string key="NSWindowRect">{{136, 318}, {500, 200}}</string>
-                               <int key="NSWTFlags">813170688</int>
+                               <int key="NSWTFlags">813171712</int>
                                <string key="NSWindowTitle">Preferences</string>
                                <string key="NSWindowClass">NSPanel</string>
                                <object class="NSMutableString" key="NSViewClass">
                                        <characters key="NS.bytes">View</characters>
                                </object>
-                               <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+                               <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
                                <string key="NSWindowContentMinSize">{213, 107}</string>
                                <object class="NSView" key="NSWindowView" id="496214002">
                                        <nil key="NSNextResponder"/>
                                        <int key="NSvFlags">256</int>
-                                       <string key="NSFrame">{{1, 1}, {500, 200}}</string>
+                                       <string key="NSFrameSize">{500, 200}</string>
                                </object>
                                <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
                                <string key="NSMinSize">{213, 129}</string>
-                               <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+                               <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
                        </object>
                        <object class="NSUserDefaultsController" id="580534391">
                                <bool key="NSSharedInstance">YES</bool>
                                        <object class="NSButton" id="906899216">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{110, 18}, {364, 18}}</string>
+                                               <string key="NSFrame">{{123, 18}, {311, 18}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="36851657">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
+                                                       <int key="NSCellFlags2">131072</int>
                                                        <string key="NSContents">Use iPod/iTunes friendly (.m4v) file extension for MP4</string>
-                                                       <object class="NSFont" key="NSSupport" id="964910696">
+                                                       <object class="NSFont" key="NSSupport" id="26">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">1.300000e+01</double>
-                                                               <int key="NSfFlags">1044</int>
+                                                               <double key="NSSize">11</double>
+                                                               <int key="NSfFlags">3100</int>
                                                        </object>
                                                        <reference key="NSControlView" ref="906899216"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                        <object class="NSButton" id="636306431">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{110, 131}, {251, 18}}</string>
+                                               <string key="NSFrame">{{123, 200}, {133, 18}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="448858755">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
+                                                       <int key="NSCellFlags2">131072</int>
                                                        <string key="NSContents">Show Presets Drawer</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="636306431"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
                                        <object class="NSButton" id="965044526">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{110, 38}, {354, 18}}</string>
+                                               <string key="NSFrame">{{123, 38}, {303, 18}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="419322096">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
+                                                       <int key="NSCellFlags2">131072</int>
                                                        <string key="NSContents">Use Auto Naming (uses DVD name and title number)</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="965044526"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
                                        <object class="NSTextField" id="315188467">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{26, 95}, {80, 17}}</string>
+                                               <string key="NSFrame">{{52, 97}, {69, 14}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="718672066">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">272629760</int>
+                                                       <int key="NSCellFlags2">272760832</int>
                                                        <string key="NSContents">When Done:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="315188467"/>
                                                        <object class="NSColor" key="NSBackgroundColor" id="525377782">
                                                                <int key="NSColorSpace">6</int>
                                                                <string key="NSColorName">controlColor</string>
                                                                <object class="NSColor" key="NSColor" id="666005350">
                                                                        <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+                                                                       <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
                                                                </object>
                                                        </object>
                                                        <object class="NSColor" key="NSTextColor" id="887152126">
                                                                <int key="NSColorSpace">6</int>
                                                                <string key="NSCatalogName">System</string>
                                                                <string key="NSColorName">controlTextColor</string>
-                                                               <object class="NSColor" key="NSColor" id="104533627">
+                                                               <object class="NSColor" key="NSColor">
                                                                        <int key="NSColorSpace">3</int>
                                                                        <bytes key="NSWhite">MAA</bytes>
                                                                </object>
                                        <object class="NSButton" id="581738572">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{110, 151}, {138, 18}}</string>
+                                               <string key="NSFrame">{{123, 155}, {194, 18}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="824062726">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
-                                                       <string key="NSContents">Check for updates</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <int key="NSCellFlags2">131072</int>
+                                                       <string key="NSContents">Automatically check for updates</string>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="581738572"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
                                        <object class="NSButton" id="597305137">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{110, 70}, {228, 18}}</string>
+                                               <string key="NSFrame">{{123, 70}, {119, 18}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="437495050">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
+                                                       <int key="NSCellFlags2">131072</int>
                                                        <string key="NSContents">Send file to MetaX</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="597305137"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
-                                                       <object class="NSCustomResource" key="NSNormalImage">
+                                                       <object class="NSCustomResource" key="NSNormalImage" id="476074553">
                                                                <string key="NSClassName">NSImage</string>
                                                                <string key="NSResourceName">NSSwitch</string>
                                                        </object>
                                        <object class="NSTextField" id="576686737">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{38, 152}, {68, 17}}</string>
+                                               <string key="NSFrame">{{62, 202}, {59, 14}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="404194395">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">272629760</int>
+                                                       <int key="NSCellFlags2">272760832</int>
                                                        <string key="NSContents">At launch:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="576686737"/>
                                                        <reference key="NSBackgroundColor" ref="525377782"/>
                                                        <reference key="NSTextColor" ref="887152126"/>
                                                </object>
                                        </object>
+                                       <object class="NSTextField" id="280291731">
+                                               <reference key="NSNextResponder" ref="1048779201"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{141, 179}, {95, 14}}</string>
+                                               <reference key="NSSuperview" ref="1048779201"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="1049782015">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">71434240</int>
+                                                       <string key="NSContents">Source selection:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="280291731"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
                                        <object class="NSTextField" id="713240777">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{24, 39}, {83, 17}}</string>
+                                               <string key="NSFrame">{{50, 40}, {71, 14}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="947435557">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">272629760</int>
+                                                       <int key="NSCellFlags2">272760832</int>
                                                        <string key="NSContents">Output files:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="713240777"/>
                                                        <reference key="NSBackgroundColor" ref="525377782"/>
                                                        <reference key="NSTextColor" ref="887152126"/>
                                        <object class="NSPopUpButton" id="317169558">
                                                <reference key="NSNextResponder" ref="1048779201"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{109, 89}, {218, 26}}</string>
+                                               <string key="NSFrame">{{123, 90}, {189, 22}}</string>
                                                <reference key="NSSuperview" ref="1048779201"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSPopUpButtonCell" key="NSCell" id="792374025">
                                                        <int key="NSCellFlags">71433792</int>
-                                                       <int key="NSCellFlags2">2048</int>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="317169558"/>
                                                        <int key="NSButtonFlags">109199615</int>
                                                        <int key="NSButtonFlags2">1</int>
-                                                       <object class="NSFont" key="NSAlternateImage">
+                                                       <object class="NSFont" key="NSAlternateImage" id="44722471">
                                                                <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">1.300000e+01</double>
+                                                               <double key="NSSize">11</double>
                                                                <int key="NSfFlags">16</int>
                                                        </object>
                                                        <string key="NSAlternateContents"/>
                                                        <int key="NSArrowPosition">1</int>
                                                </object>
                                        </object>
+                                       <object class="NSPopUpButton" id="954667708">
+                                               <reference key="NSNextResponder" ref="1048779201"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{141, 128}, {102, 22}}</string>
+                                               <reference key="NSSuperview" ref="1048779201"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="841218599">
+                                                       <int key="NSCellFlags">71433792</int>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="954667708"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">1</int>
+                                                       <reference key="NSAlternateImage" ref="44722471"/>
+                                                       <string key="NSAlternateContents"/>
+                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                               <characters key="NS.bytes"/>
+                                                       </object>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="409508073">
+                                                               <reference key="NSMenu" ref="601170194"/>
+                                                               <string key="NSTitle">Weekly</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <int key="NSTag">604800</int>
+                                                               <reference key="NSTarget" ref="841218599"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="601170194">
+                                                               <object class="NSMutableString" key="NSTitle">
+                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                               </object>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <object class="NSMenuItem" id="356864129">
+                                                                               <reference key="NSMenu" ref="601170194"/>
+                                                                               <string key="NSTitle">Daily</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <int key="NSTag">86400</int>
+                                                                               <reference key="NSTarget" ref="841218599"/>
+                                                                       </object>
+                                                                       <reference ref="409508073"/>
+                                                                       <object class="NSMenuItem" id="1028006448">
+                                                                               <reference key="NSMenu" ref="601170194"/>
+                                                                               <string key="NSTitle">Monthly</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <int key="NSTag">2629800</int>
+                                                                               <reference key="NSTarget" ref="841218599"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSSelectedIndex">1</int>
+                                                       <int key="NSPreferredEdge">3</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">1</int>
+                                               </object>
+                                       </object>
+                                       <object class="NSPopUpButton" id="54712339">
+                                               <reference key="NSNextResponder" ref="1048779201"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{238, 174}, {205, 22}}</string>
+                                               <reference key="NSSuperview" ref="1048779201"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="310956178">
+                                                       <int key="NSCellFlags">71433792</int>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="54712339"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">1</int>
+                                                       <reference key="NSAlternateImage" ref="44722471"/>
+                                                       <string key="NSAlternateContents"/>
+                                                       <object class="NSMutableString" key="NSKeyEquivalent">
+                                                               <characters key="NS.bytes"/>
+                                                       </object>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="420036141">
+                                                               <reference key="NSMenu" ref="374003297"/>
+                                                               <string key="NSTitle">Open Source</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <reference key="NSTarget" ref="310956178"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="374003297">
+                                                               <object class="NSMutableString" key="NSTitle">
+                                                                       <characters key="NS.bytes">OtherViews</characters>
+                                                               </object>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <object class="NSMenuItem" id="951535454">
+                                                                               <reference key="NSMenu" ref="374003297"/>
+                                                                               <string key="NSTitle">Do Nothing</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="310956178"/>
+                                                                       </object>
+                                                                       <reference ref="420036141"/>
+                                                                       <object class="NSMenuItem" id="195310116">
+                                                                               <reference key="NSMenu" ref="374003297"/>
+                                                                               <string key="NSTitle">Open Source (Title Specific)</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="310956178"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSSelectedIndex">1</int>
+                                                       <int key="NSPreferredEdge">3</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">1</int>
+                                               </object>
+                                       </object>
                                </object>
-                               <string key="NSFrameSize">{492, 189}</string>
+                               <string key="NSFrameSize">{492, 236}</string>
                                <reference key="NSSuperview"/>
                                <string key="NSClassName">NSView</string>
                                <string key="NSExtension">NSControl</string>
                        </object>
                        <object class="NSCustomView" id="520288288">
-                               <reference key="NSNextResponder"/>
+                               <nil key="NSNextResponder"/>
                                <int key="NSvFlags">256</int>
                                <object class="NSMutableArray" key="NSSubviews">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                       <object class="NSTextField" id="1062449667">
-                                               <reference key="NSNextResponder" ref="520288288"/>
-                                               <int key="NSvFlags">268</int>
-                                               <string key="NSFrame">{{188, 38}, {113, 22}}</string>
-                                               <reference key="NSSuperview" ref="520288288"/>
-                                               <bool key="NSEnabled">YES</bool>
-                                               <object class="NSTextFieldCell" key="NSCell" id="51555548">
-                                                       <int key="NSCellFlags">-1804468671</int>
-                                                       <int key="NSCellFlags2">272630784</int>
-                                                       <string key="NSContents"/>
-                                                       <reference key="NSSupport" ref="964910696"/>
-                                                       <reference key="NSControlView" ref="1062449667"/>
-                                                       <bool key="NSDrawsBackground">YES</bool>
-                                                       <object class="NSColor" key="NSBackgroundColor" id="686497954">
-                                                               <int key="NSColorSpace">6</int>
-                                                               <string key="NSCatalogName">System</string>
-                                                               <string key="NSColorName">textBackgroundColor</string>
-                                                               <object class="NSColor" key="NSColor" id="993015046">
-                                                                       <int key="NSColorSpace">3</int>
-                                                                       <bytes key="NSWhite">MQA</bytes>
-                                                               </object>
-                                                       </object>
-                                                       <object class="NSColor" key="NSTextColor">
-                                                               <int key="NSColorSpace">6</int>
-                                                               <string key="NSCatalogName">System</string>
-                                                               <string key="NSColorName">textColor</string>
-                                                               <reference key="NSColor" ref="104533627"/>
-                                                       </object>
-                                               </object>
-                                       </object>
                                        <object class="NSTextField" id="539748933">
                                                <reference key="NSNextResponder" ref="520288288"/>
                                                <int key="NSvFlags">268</int>
-                                               <string key="NSFrame">{{27, 40}, {155, 17}}</string>
+                                               <string key="NSFrame">{{34, 42}, {432, 17}}</string>
                                                <reference key="NSSuperview" ref="520288288"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="374363387">
                                                        <int key="NSCellFlags">67239488</int>
-                                                       <int key="NSCellFlags2">71304192</int>
-                                                       <string key="NSContents">Custom Decomb String:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <int key="NSCellFlags2">138413056</int>
+                                                       <string key="NSContents">Nothing here right now, but I am sure we will think of something</string>
+                                                       <object class="NSFont" key="NSSupport" id="964910696">
+                                                               <string key="NSName">LucidaGrande</string>
+                                                               <double key="NSSize">13</double>
+                                                               <int key="NSfFlags">1044</int>
+                                                       </object>
                                                        <reference key="NSControlView" ref="539748933"/>
                                                        <reference key="NSBackgroundColor" ref="525377782"/>
                                                        <reference key="NSTextColor" ref="887152126"/>
                                                </object>
                                        </object>
                                </object>
-                               <string key="NSFrameSize">{496, 80}</string>
-                               <reference key="NSSuperview"/>
+                               <string key="NSFrameSize">{496, 82}</string>
                                <string key="NSClassName">NSView</string>
                                <string key="NSExtension">NSResponder</string>
                        </object>
                        <object class="NSCustomView" id="332598366">
-                               <nil key="NSNextResponder"/>
+                               <reference key="NSNextResponder"/>
                                <int key="NSvFlags">256</int>
                                <object class="NSMutableArray" key="NSSubviews">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <object class="NSTextField" id="389101877">
                                                <reference key="NSNextResponder" ref="332598366"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{76, 43}, {114, 17}}</string>
+                                               <string key="NSFrame">{{30, 56}, {96, 14}}</string>
                                                <reference key="NSSuperview" ref="332598366"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSTextFieldCell" key="NSCell" id="459708758">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">272629760</int>
+                                                       <int key="NSCellFlags2">272760832</int>
                                                        <string key="NSContents">Native Language:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="389101877"/>
                                                        <reference key="NSBackgroundColor" ref="525377782"/>
                                                        <reference key="NSTextColor" ref="887152126"/>
                                                </object>
                                        </object>
+                                       <object class="NSTextField" id="247298122">
+                                               <reference key="NSNextResponder" ref="332598366"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{95, 22}, {31, 14}}</string>
+                                               <reference key="NSSuperview" ref="332598366"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="954547948">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">272760832</int>
+                                                       <string key="NSContents">AAC:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="247298122"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
                                        <object class="NSComboBox" id="172081130">
                                                <reference key="NSNextResponder" ref="332598366"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{195, 39}, {229, 26}}</string>
+                                               <string key="NSFrame">{{131, 50}, {247, 22}}</string>
                                                <reference key="NSSuperview" ref="332598366"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSComboBoxCell" key="NSCell" id="210320026">
                                                        <int key="NSCellFlags">343014976</int>
-                                                       <int key="NSCellFlags2">272630784</int>
+                                                       <int key="NSCellFlags2">272761856</int>
                                                        <string key="NSContents">English</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
+                                                       <reference key="NSSupport" ref="26"/>
                                                        <reference key="NSControlView" ref="172081130"/>
                                                        <bool key="NSDrawsBackground">YES</bool>
-                                                       <reference key="NSBackgroundColor" ref="686497954"/>
+                                                       <object class="NSColor" key="NSBackgroundColor">
+                                                               <int key="NSColorSpace">6</int>
+                                                               <string key="NSCatalogName">System</string>
+                                                               <string key="NSColorName">textBackgroundColor</string>
+                                                               <object class="NSColor" key="NSColor" id="993015046">
+                                                                       <int key="NSColorSpace">3</int>
+                                                                       <bytes key="NSWhite">MQA</bytes>
+                                                               </object>
+                                                       </object>
                                                        <reference key="NSTextColor" ref="887152126"/>
                                                        <int key="NSVisibleItemCount">10</int>
                                                        <bool key="NSHasVerticalScroller">YES</bool>
                                                        <object class="NSComboTableView" key="NSTableView" id="686758712">
                                                                <reference key="NSNextResponder"/>
                                                                <int key="NSvFlags">274</int>
-                                                               <string key="NSFrameSize">{13, 3444}</string>
+                                                               <string key="NSFrameSize">{13, 2952}</string>
                                                                <reference key="NSSuperview"/>
                                                                <reference key="NSWindow"/>
                                                                <bool key="NSEnabled">YES</bool>
                                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                                        <object class="NSTableColumn">
                                                                                <integer value="0" key="NSIdentifier"/>
-                                                                               <double key="NSWidth">1.000000e+01</double>
-                                                                               <double key="NSMinWidth">1.000000e+01</double>
-                                                                               <double key="NSMaxWidth">1.000000e+03</double>
+                                                                               <double key="NSWidth">10</double>
+                                                                               <double key="NSMinWidth">10</double>
+                                                                               <double key="NSMaxWidth">1000</double>
                                                                                <object class="NSTableHeaderCell" key="NSHeaderCell">
                                                                                        <int key="NSCellFlags">75628032</int>
                                                                                        <int key="NSCellFlags2">0</int>
                                                                                        </object>
                                                                                        <object class="NSFont" key="NSSupport">
                                                                                                <string key="NSName">LucidaGrande</string>
-                                                                                               <double key="NSSize">1.200000e+01</double>
+                                                                                               <double key="NSSize">12</double>
                                                                                                <int key="NSfFlags">16</int>
                                                                                        </object>
                                                                                        <object class="NSColor" key="NSBackgroundColor">
                                                                                <object class="NSTextFieldCell" key="NSDataCell">
                                                                                        <int key="NSCellFlags">338820672</int>
                                                                                        <int key="NSCellFlags2">1024</int>
-                                                                                       <reference key="NSSupport" ref="964910696"/>
+                                                                                       <reference key="NSSupport" ref="26"/>
                                                                                        <reference key="NSControlView" ref="686758712"/>
                                                                                        <bool key="NSDrawsBackground">YES</bool>
                                                                                        <object class="NSColor" key="NSBackgroundColor" id="501011794">
                                                                                <reference key="NSTableView" ref="686758712"/>
                                                                        </object>
                                                                </object>
-                                                               <double key="NSIntercellSpacingWidth">3.000000e+00</double>
-                                                               <double key="NSIntercellSpacingHeight">2.000000e+00</double>
+                                                               <double key="NSIntercellSpacingWidth">3</double>
+                                                               <double key="NSIntercellSpacingHeight">2</double>
                                                                <reference key="NSBackgroundColor" ref="501011794"/>
                                                                <object class="NSColor" key="NSGridColor">
                                                                        <int key="NSColorSpace">6</int>
                                                                                <bytes key="NSWhite">MC41AA</bytes>
                                                                        </object>
                                                                </object>
-                                                               <double key="NSRowHeight">1.900000e+01</double>
+                                                               <double key="NSRowHeight">16</double>
                                                                <string key="NSAction">tableViewAction:</string>
                                                                <int key="NSTvFlags">-765427712</int>
                                                                <reference key="NSDelegate" ref="210320026"/>
                                                                <int key="NSDraggingSourceMaskForLocal">15</int>
                                                                <int key="NSDraggingSourceMaskForNonLocal">0</int>
                                                                <bool key="NSAllowsTypeSelect">YES</bool>
+                                                               <int key="NSTableViewDraggingDestinationStyle">0</int>
                                                        </object>
                                                </object>
                                        </object>
                                        <object class="NSButton" id="168948265">
                                                <reference key="NSNextResponder" ref="332598366"/>
                                                <int key="NSvFlags">-2147483392</int>
-                                               <string key="NSFrame">{{18, 18}, {472, 18}}</string>
+                                               <string key="NSFrame">{{18, -4}, {472, 18}}</string>
                                                <reference key="NSSuperview" ref="332598366"/>
                                                <bool key="NSEnabled">YES</bool>
                                                <object class="NSButtonCell" key="NSCell" id="686321393">
                                                        <int key="NSPeriodicInterval">25</int>
                                                </object>
                                        </object>
+                                       <object class="NSButton" id="1054432492">
+                                               <reference key="NSNextResponder" ref="332598366"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{128, 20}, {333, 18}}</string>
+                                               <reference key="NSSuperview" ref="332598366"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSButtonCell" key="NSCell" id="787274685">
+                                                       <int key="NSCellFlags">-2080244224</int>
+                                                       <int key="NSCellFlags2">131072</int>
+                                                       <string key="NSContents">Use CoreAudio instead of FAAC for preset default encoder</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="1054432492"/>
+                                                       <int key="NSButtonFlags">1211912703</int>
+                                                       <int key="NSButtonFlags2">130</int>
+                                                       <reference key="NSNormalImage" ref="476074553"/>
+                                                       <reference key="NSAlternateImage" ref="1056213191"/>
+                                                       <string key="NSAlternateContents"/>
+                                                       <string key="NSKeyEquivalent"/>
+                                                       <int key="NSPeriodicDelay">200</int>
+                                                       <int key="NSPeriodicInterval">25</int>
+                                               </object>
+                                       </object>
                                </object>
-                               <string key="NSFrameSize">{500, 83}</string>
+                               <string key="NSFrameSize">{492, 91}</string>
+                               <reference key="NSSuperview"/>
                                <object class="NSMutableString" key="NSClassName">
                                        <characters key="NS.bytes">NSView</characters>
                                </object>
                                <int key="NSvFlags">256</int>
                                <object class="NSMutableArray" key="NSSubviews">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                       <object class="NSButton" id="882188042">
+                                       <object class="NSTextField" id="226601760">
                                                <reference key="NSNextResponder" ref="23728330"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{83, 146}, {367, 18}}</string>
+                                               <string key="NSFrame">{{17, 203}, {280, 14}}</string>
                                                <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
                                                <bool key="NSEnabled">YES</bool>
-                                               <object class="NSButtonCell" key="NSCell" id="197383193">
+                                               <object class="NSTextFieldCell" key="NSCell" id="1064438472">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
-                                                       <string key="NSContents">Use CRF (instead of CQP) for Constant Quality encodes</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
-                                                       <reference key="NSControlView" ref="882188042"/>
+                                                       <int key="NSCellFlags2">71434240</int>
+                                                       <string key="NSContents">x264 Constant Quality fractional granularity:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="226601760"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="701867067">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{99, 169}, {198, 14}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="978611587">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">71434240</int>
+                                                       <string key="NSContents">Number of picture previews to scan:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="701867067"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="173328305">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{137, 78}, {150, 14}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="271531935">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">4325376</int>
+                                                       <string key="NSContents">Activity Log Vebosity Level:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="173328305"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="899831697">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{108, 100}, {27, 14}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="483848741">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">272760832</int>
+                                                       <string key="NSContents">Log:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="899831697"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="898312631">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{70, 134}, {65, 14}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="1062716368">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">272760832</int>
+                                                       <string key="NSContents">Dvd-Video:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="898312631"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
+                                       <object class="NSButton" id="907177043">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{137, 98}, {304, 18}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSButtonCell" key="NSCell" id="869757541">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">131072</int>
+                                                       <string key="NSContents">Put individual encode logs in same location as movie</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="907177043"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
                                                        <reference key="NSAlternateImage" ref="1056213191"/>
                                                        <int key="NSPeriodicInterval">25</int>
                                                </object>
                                        </object>
-                                       <object class="NSTextField" id="759266151">
+                                       <object class="NSButton" id="745324926">
                                                <reference key="NSNextResponder" ref="23728330"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{39, 147}, {41, 17}}</string>
+                                               <string key="NSFrame">{{137, 132}, {220, 18}}</string>
                                                <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
                                                <bool key="NSEnabled">YES</bool>
-                                               <object class="NSTextFieldCell" key="NSCell" id="488653412">
+                                               <object class="NSButtonCell" key="NSCell" id="884409108">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">272629760</int>
-                                                       <string key="NSContents">x264:</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
-                                                       <reference key="NSControlView" ref="759266151"/>
-                                                       <reference key="NSBackgroundColor" ref="525377782"/>
-                                                       <reference key="NSTextColor" ref="887152126"/>
+                                                       <int key="NSCellFlags2">131072</int>
+                                                       <string key="NSContents">Use libdvdnav (instead of libdvdread)</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="745324926"/>
+                                                       <int key="NSButtonFlags">1211912703</int>
+                                                       <int key="NSButtonFlags2">2</int>
+                                                       <reference key="NSAlternateImage" ref="1056213191"/>
+                                                       <string key="NSAlternateContents"/>
+                                                       <string key="NSKeyEquivalent"/>
+                                                       <int key="NSPeriodicDelay">200</int>
+                                                       <int key="NSPeriodicInterval">25</int>
                                                </object>
                                        </object>
-                                       <object class="NSButton" id="907177043">
+                                       <object class="NSButton" id="712613872">
                                                <reference key="NSNextResponder" ref="23728330"/>
                                                <int key="NSvFlags">256</int>
-                                               <string key="NSFrame">{{83, 108}, {367, 18}}</string>
+                                               <string key="NSFrame">{{137, 42}, {217, 18}}</string>
                                                <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
                                                <bool key="NSEnabled">YES</bool>
-                                               <object class="NSButtonCell" key="NSCell" id="869757541">
+                                               <object class="NSButtonCell" key="NSCell" id="562265695">
                                                        <int key="NSCellFlags">67239424</int>
-                                                       <int key="NSCellFlags2">0</int>
-                                                       <string key="NSContents">Put individual encode logs in same location as movie</string>
-                                                       <reference key="NSSupport" ref="964910696"/>
-                                                       <reference key="NSControlView" ref="907177043"/>
+                                                       <int key="NSCellFlags2">131072</int>
+                                                       <string key="NSContents">Alert when updating built-in presets</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="712613872"/>
                                                        <int key="NSButtonFlags">1211912703</int>
                                                        <int key="NSButtonFlags2">2</int>
                                                        <reference key="NSAlternateImage" ref="1056213191"/>
                                                        <int key="NSPeriodicInterval">25</int>
                                                </object>
                                        </object>
+                                       <object class="NSPopUpButton" id="772611942">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{299, 164}, {73, 22}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="413609467">
+                                                       <int key="NSCellFlags">-2076049856</int>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="772611942"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">129</int>
+                                                       <string key="NSAlternateContents"/>
+                                                       <string key="NSKeyEquivalent"/>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="165310533">
+                                                               <reference key="NSMenu" ref="743346318"/>
+                                                               <string key="NSTitle">10</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <reference key="NSTarget" ref="413609467"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="743346318">
+                                                               <string key="NSTitle">OtherViews</string>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <reference ref="165310533"/>
+                                                                       <object class="NSMenuItem" id="477590220">
+                                                                               <reference key="NSMenu" ref="743346318"/>
+                                                                               <string key="NSTitle">15</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="413609467"/>
+                                                                       </object>
+                                                                       <object class="NSMenuItem" id="444551526">
+                                                                               <reference key="NSMenu" ref="743346318"/>
+                                                                               <string key="NSTitle">20</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="413609467"/>
+                                                                       </object>
+                                                                       <object class="NSMenuItem" id="498458317">
+                                                                               <reference key="NSMenu" ref="743346318"/>
+                                                                               <string key="NSTitle">25</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="413609467"/>
+                                                                       </object>
+                                                                       <object class="NSMenuItem" id="327639789">
+                                                                               <reference key="NSMenu" ref="743346318"/>
+                                                                               <string key="NSTitle">30</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="413609467"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSPreferredEdge">1</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">2</int>
+                                               </object>
+                                       </object>
+                                       <object class="NSPopUpButton" id="822080053">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{299, 198}, {76, 22}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="434430620">
+                                                       <int key="NSCellFlags">-2076049856</int>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="822080053"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">129</int>
+                                                       <string key="NSAlternateContents"/>
+                                                       <string key="NSKeyEquivalent"/>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="731921194">
+                                                               <reference key="NSMenu" ref="841477386"/>
+                                                               <string key="NSTitle">0.25</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <reference key="NSTarget" ref="434430620"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="841477386">
+                                                               <string key="NSTitle">OtherViews</string>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <object class="NSMenuItem" id="835010135">
+                                                                               <reference key="NSMenu" ref="841477386"/>
+                                                                               <string key="NSTitle">1.0</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="434430620"/>
+                                                                       </object>
+                                                                       <object class="NSMenuItem" id="642215596">
+                                                                               <reference key="NSMenu" ref="841477386"/>
+                                                                               <string key="NSTitle">0.50</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="434430620"/>
+                                                                       </object>
+                                                                       <reference ref="731921194"/>
+                                                                       <object class="NSMenuItem" id="226776327">
+                                                                               <reference key="NSMenu" ref="841477386"/>
+                                                                               <string key="NSTitle">0.20</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="434430620"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSSelectedIndex">2</int>
+                                                       <int key="NSPreferredEdge">1</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">2</int>
+                                               </object>
+                                       </object>
+                                       <object class="NSPopUpButton" id="895206300">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">268</int>
+                                               <string key="NSFrame">{{289, 73}, {66, 22}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSPopUpButtonCell" key="NSCell" id="290473288">
+                                                       <int key="NSCellFlags">-2076049856</int>
+                                                       <int key="NSCellFlags2">133120</int>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="895206300"/>
+                                                       <int key="NSButtonFlags">109199615</int>
+                                                       <int key="NSButtonFlags2">129</int>
+                                                       <string key="NSAlternateContents"/>
+                                                       <string key="NSKeyEquivalent"/>
+                                                       <int key="NSPeriodicDelay">400</int>
+                                                       <int key="NSPeriodicInterval">75</int>
+                                                       <object class="NSMenuItem" key="NSMenuItem" id="769184887">
+                                                               <reference key="NSMenu" ref="898961390"/>
+                                                               <string key="NSTitle">1</string>
+                                                               <string key="NSKeyEquiv"/>
+                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                               <int key="NSState">1</int>
+                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                               <reference key="NSTarget" ref="290473288"/>
+                                                       </object>
+                                                       <bool key="NSMenuItemRespectAlignment">YES</bool>
+                                                       <object class="NSMenu" key="NSMenu" id="898961390">
+                                                               <string key="NSTitle">OtherViews</string>
+                                                               <object class="NSMutableArray" key="NSMenuItems">
+                                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                                       <object class="NSMenuItem" id="546193261">
+                                                                               <reference key="NSMenu" ref="898961390"/>
+                                                                               <string key="NSTitle">0</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="290473288"/>
+                                                                       </object>
+                                                                       <reference ref="769184887"/>
+                                                                       <object class="NSMenuItem" id="544981908">
+                                                                               <reference key="NSMenu" ref="898961390"/>
+                                                                               <string key="NSTitle">2</string>
+                                                                               <string key="NSKeyEquiv"/>
+                                                                               <int key="NSKeyEquivModMask">1048576</int>
+                                                                               <int key="NSMnemonicLoc">2147483647</int>
+                                                                               <reference key="NSOnImage" ref="201515479"/>
+                                                                               <reference key="NSMixedImage" ref="944085027"/>
+                                                                               <string key="NSAction">_popUpItemAction:</string>
+                                                                               <reference key="NSTarget" ref="290473288"/>
+                                                                       </object>
+                                                               </object>
+                                                       </object>
+                                                       <int key="NSSelectedIndex">1</int>
+                                                       <int key="NSPreferredEdge">1</int>
+                                                       <bool key="NSUsesItemFromMenu">YES</bool>
+                                                       <bool key="NSAltersState">YES</bool>
+                                                       <int key="NSArrowPosition">2</int>
+                                               </object>
+                                       </object>
+                                       <object class="NSTextField" id="200780219">
+                                               <reference key="NSNextResponder" ref="23728330"/>
+                                               <int key="NSvFlags">256</int>
+                                               <string key="NSFrame">{{89, 44}, {46, 14}}</string>
+                                               <reference key="NSSuperview" ref="23728330"/>
+                                               <reference key="NSWindow"/>
+                                               <bool key="NSEnabled">YES</bool>
+                                               <object class="NSTextFieldCell" key="NSCell" id="221545613">
+                                                       <int key="NSCellFlags">67239424</int>
+                                                       <int key="NSCellFlags2">272760832</int>
+                                                       <string key="NSContents">Presets:</string>
+                                                       <reference key="NSSupport" ref="26"/>
+                                                       <reference key="NSControlView" ref="200780219"/>
+                                                       <reference key="NSBackgroundColor" ref="525377782"/>
+                                                       <reference key="NSTextColor" ref="887152126"/>
+                                               </object>
+                                       </object>
                                </object>
-                               <string key="NSFrameSize">{500, 184}</string>
+                               <string key="NSFrameSize">{492, 237}</string>
                                <reference key="NSSuperview"/>
+                               <reference key="NSWindow"/>
                                <object class="NSMutableString" key="NSClassName">
                                        <characters key="NS.bytes">NSView</characters>
                                </object>
                                <string key="NSExtension">NSResponder</string>
                        </object>
+                       <object class="NSCustomObject" id="413269307">
+                               <string key="NSClassName">SUUpdater</string>
+                       </object>
                </object>
                <object class="IBObjectContainer" key="IBDocument.Objects">
                        <object class="NSMutableArray" key="connectionRecords">
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBBindingConnection" key="connection">
-                                               <string key="label">value: values.DefaultCrf</string>
-                                               <reference key="source" ref="882188042"/>
+                                               <string key="label">selectedValue: values.AlertWhenDone</string>
+                                               <reference key="source" ref="317169558"/>
+                                               <reference key="destination" ref="580534391"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="317169558"/>
+                                                       <reference key="NSDestination" ref="580534391"/>
+                                                       <string key="NSLabel">selectedValue: values.AlertWhenDone</string>
+                                                       <string key="NSBinding">selectedValue</string>
+                                                       <string key="NSKeyPath">values.AlertWhenDone</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">298</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">value: values.EncodeLogLocation</string>
+                                               <reference key="source" ref="907177043"/>
                                                <reference key="destination" ref="580534391"/>
                                                <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="882188042"/>
+                                                       <reference key="NSSource" ref="907177043"/>
                                                        <reference key="NSDestination" ref="580534391"/>
-                                                       <string key="NSLabel">value: values.DefaultCrf</string>
+                                                       <string key="NSLabel">value: values.EncodeLogLocation</string>
                                                        <string key="NSBinding">value</string>
-                                                       <string key="NSKeyPath">values.DefaultCrf</string>
+                                                       <string key="NSKeyPath">values.EncodeLogLocation</string>
                                                        <int key="NSNibBindingConnectorVersion">2</int>
                                                </object>
                                        </object>
-                                       <int key="connectionID">272</int>
+                                       <int key="connectionID">349</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBBindingConnection" key="connection">
-                                               <string key="label">selectedValue: values.AlertWhenDone</string>
-                                               <reference key="source" ref="317169558"/>
+                                               <string key="label">selectedValue: values.PreviewsNumber</string>
+                                               <reference key="source" ref="772611942"/>
                                                <reference key="destination" ref="580534391"/>
                                                <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="317169558"/>
+                                                       <reference key="NSSource" ref="772611942"/>
                                                        <reference key="NSDestination" ref="580534391"/>
-                                                       <string key="NSLabel">selectedValue: values.AlertWhenDone</string>
+                                                       <string key="NSLabel">selectedValue: values.PreviewsNumber</string>
                                                        <string key="NSBinding">selectedValue</string>
-                                                       <string key="NSKeyPath">values.AlertWhenDone</string>
+                                                       <string key="NSKeyPath">values.PreviewsNumber</string>
                                                        <int key="NSNibBindingConnectorVersion">2</int>
                                                </object>
                                        </object>
-                                       <int key="connectionID">298</int>
+                                       <int key="connectionID">358</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBBindingConnection" key="connection">
-                                               <string key="label">value: values.SUCheckAtStartup</string>
-                                               <reference key="source" ref="581738572"/>
+                                               <string key="label">selectedValue: values.LoggingLevel</string>
+                                               <reference key="source" ref="895206300"/>
                                                <reference key="destination" ref="580534391"/>
                                                <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="581738572"/>
+                                                       <reference key="NSSource" ref="895206300"/>
+                                                       <reference key="NSDestination" ref="580534391"/>
+                                                       <string key="NSLabel">selectedValue: values.LoggingLevel</string>
+                                                       <string key="NSBinding">selectedValue</string>
+                                                       <string key="NSKeyPath">values.LoggingLevel</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">373</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">selectedValue: values.LaunchSourceBehavior</string>
+                                               <reference key="source" ref="54712339"/>
+                                               <reference key="destination" ref="580534391"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="54712339"/>
+                                                       <reference key="NSDestination" ref="580534391"/>
+                                                       <string key="NSLabel">selectedValue: values.LaunchSourceBehavior</string>
+                                                       <string key="NSBinding">selectedValue</string>
+                                                       <string key="NSKeyPath">values.LaunchSourceBehavior</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">386</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">selectedValue: values.x264CqSliderFractional</string>
+                                               <reference key="source" ref="822080053"/>
+                                               <reference key="destination" ref="580534391"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="822080053"/>
                                                        <reference key="NSDestination" ref="580534391"/>
-                                                       <string key="NSLabel">value: values.SUCheckAtStartup</string>
+                                                       <string key="NSLabel">selectedValue: values.x264CqSliderFractional</string>
+                                                       <string key="NSBinding">selectedValue</string>
+                                                       <string key="NSKeyPath">values.x264CqSliderFractional</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">397</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">value: values.UseDvdNav</string>
+                                               <reference key="source" ref="745324926"/>
+                                               <reference key="destination" ref="580534391"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="745324926"/>
+                                                       <reference key="NSDestination" ref="580534391"/>
+                                                       <string key="NSLabel">value: values.UseDvdNav</string>
                                                        <string key="NSBinding">value</string>
-                                                       <string key="NSKeyPath">values.SUCheckAtStartup</string>
+                                                       <string key="NSKeyPath">values.UseDvdNav</string>
                                                        <int key="NSNibBindingConnectorVersion">2</int>
                                                </object>
                                        </object>
-                                       <int key="connectionID">323</int>
+                                       <int key="connectionID">400</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBBindingConnection" key="connection">
-                                               <string key="label">value: values.DecombCustomString</string>
-                                               <reference key="source" ref="1062449667"/>
+                                               <string key="label">value: values.AlertBuiltInPresetUpdate</string>
+                                               <reference key="source" ref="712613872"/>
                                                <reference key="destination" ref="580534391"/>
                                                <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="1062449667"/>
+                                                       <reference key="NSSource" ref="712613872"/>
                                                        <reference key="NSDestination" ref="580534391"/>
-                                                       <string key="NSLabel">value: values.DecombCustomString</string>
+                                                       <string key="NSLabel">value: values.AlertBuiltInPresetUpdate</string>
                                                        <string key="NSBinding">value</string>
-                                                       <string key="NSKeyPath">values.DecombCustomString</string>
-                                                       <object class="NSDictionary" key="NSOptions">
-                                                               <string key="NS.key.0">NSContinuouslyUpdatesValue</string>
-                                                               <integer value="1" key="NS.object.0" id="9"/>
-                                                       </object>
+                                                       <string key="NSKeyPath">values.AlertBuiltInPresetUpdate</string>
                                                        <int key="NSNibBindingConnectorVersion">2</int>
                                                </object>
                                        </object>
-                                       <int key="connectionID">330</int>
+                                       <int key="connectionID">403</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBBindingConnection" key="connection">
-                                               <string key="label">value: values.EncodeLogLocation</string>
-                                               <reference key="source" ref="907177043"/>
+                                               <string key="label">value: values.UseCoreAudio</string>
+                                               <reference key="source" ref="1054432492"/>
                                                <reference key="destination" ref="580534391"/>
                                                <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="907177043"/>
+                                                       <reference key="NSSource" ref="1054432492"/>
                                                        <reference key="NSDestination" ref="580534391"/>
-                                                       <string key="NSLabel">value: values.EncodeLogLocation</string>
+                                                       <string key="NSLabel">value: values.UseCoreAudio</string>
                                                        <string key="NSBinding">value</string>
-                                                       <string key="NSKeyPath">values.EncodeLogLocation</string>
+                                                       <string key="NSKeyPath">values.UseCoreAudio</string>
                                                        <int key="NSNibBindingConnectorVersion">2</int>
                                                </object>
                                        </object>
-                                       <int key="connectionID">349</int>
+                                       <int key="connectionID">409</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">value: automaticallyChecksForUpdates</string>
+                                               <reference key="source" ref="581738572"/>
+                                               <reference key="destination" ref="413269307"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="581738572"/>
+                                                       <reference key="NSDestination" ref="413269307"/>
+                                                       <string key="NSLabel">value: automaticallyChecksForUpdates</string>
+                                                       <string key="NSBinding">value</string>
+                                                       <string key="NSKeyPath">automaticallyChecksForUpdates</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">429</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">enabled: automaticallyChecksForUpdates</string>
+                                               <reference key="source" ref="954667708"/>
+                                               <reference key="destination" ref="413269307"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="954667708"/>
+                                                       <reference key="NSDestination" ref="413269307"/>
+                                                       <string key="NSLabel">enabled: automaticallyChecksForUpdates</string>
+                                                       <string key="NSBinding">enabled</string>
+                                                       <string key="NSKeyPath">automaticallyChecksForUpdates</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">433</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBBindingConnection" key="connection">
+                                               <string key="label">selectedTag: updateCheckInterval</string>
+                                               <reference key="source" ref="954667708"/>
+                                               <reference key="destination" ref="413269307"/>
+                                               <object class="NSNibBindingConnector" key="connector">
+                                                       <reference key="NSSource" ref="954667708"/>
+                                                       <reference key="NSDestination" ref="413269307"/>
+                                                       <string key="NSLabel">selectedTag: updateCheckInterval</string>
+                                                       <string key="NSBinding">selectedTag</string>
+                                                       <string key="NSKeyPath">updateCheckInterval</string>
+                                                       <int key="NSNibBindingConnectorVersion">2</int>
+                                               </object>
+                                       </object>
+                                       <int key="connectionID">434</int>
                                </object>
                        </object>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">0</int>
-                                               <object class="NSArray" key="object" id="510204080">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                               </object>
+                                               <reference key="object" ref="0"/>
                                                <reference key="children" ref="185275739"/>
                                                <nil key="parent"/>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-2</int>
                                                <reference key="object" ref="169862212"/>
-                                               <reference key="parent" ref="510204080"/>
-                                               <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">File's Owner</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-1</int>
                                                <reference key="object" ref="941647215"/>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">First Responder</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="496214002"/>
                                                </object>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Preferences</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                        <object class="IBObjectRecord">
                                                <int key="objectID">61</int>
                                                <reference key="object" ref="580534391"/>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Shared Defaults</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                        <reference ref="581738572"/>
                                                        <reference ref="597305137"/>
                                                        <reference ref="576686737"/>
+                                                       <reference ref="280291731"/>
                                                        <reference ref="713240777"/>
                                                        <reference ref="317169558"/>
+                                                       <reference ref="954667708"/>
+                                                       <reference ref="54712339"/>
                                                </object>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">General</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <reference key="object" ref="520288288"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="1062449667"/>
                                                        <reference ref="539748933"/>
                                                </object>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Picture</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                                        <reference ref="389101877"/>
-                                                       <reference ref="172081130"/>
                                                        <reference ref="168948265"/>
+                                                       <reference ref="172081130"/>
+                                                       <reference ref="247298122"/>
+                                                       <reference ref="1054432492"/>
                                                </object>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Audio</string>
                                        </object>
                                        <object class="IBObjectRecord">
                                                <reference key="object" ref="23728330"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="882188042"/>
-                                                       <reference ref="759266151"/>
+                                                       <reference ref="701867067"/>
+                                                       <reference ref="772611942"/>
+                                                       <reference ref="173328305"/>
+                                                       <reference ref="895206300"/>
+                                                       <reference ref="745324926"/>
+                                                       <reference ref="899831697"/>
+                                                       <reference ref="898312631"/>
                                                        <reference ref="907177043"/>
+                                                       <reference ref="200780219"/>
+                                                       <reference ref="712613872"/>
+                                                       <reference ref="226601760"/>
+                                                       <reference ref="822080053"/>
                                                </object>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Advanced</string>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">255</int>
-                                               <reference key="object" ref="882188042"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="197383193"/>
-                                               </object>
-                                               <reference key="parent" ref="23728330"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">280</int>
-                                               <reference key="object" ref="759266151"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="488653412"/>
-                                               </object>
-                                               <reference key="parent" ref="23728330"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">300</int>
                                                <reference key="object" ref="36851657"/>
                                                <reference key="parent" ref="906899216"/>
                                                <reference key="parent" ref="168948265"/>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">318</int>
-                                               <reference key="object" ref="197383193"/>
-                                               <reference key="parent" ref="882188042"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">322</int>
-                                               <reference key="object" ref="488653412"/>
-                                               <reference key="parent" ref="759266151"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
                                                <int key="objectID">290</int>
                                                <reference key="object" ref="783755954"/>
                                                <object class="NSMutableArray" key="children">
                                        <object class="IBObjectRecord">
                                                <int key="objectID">-3</int>
                                                <reference key="object" ref="559784606"/>
-                                               <reference key="parent" ref="510204080"/>
+                                               <reference key="parent" ref="0"/>
                                                <string key="objectName">Application</string>
                                        </object>
                                        <object class="IBObjectRecord">
-                                               <int key="objectID">324</int>
-                                               <reference key="object" ref="1062449667"/>
+                                               <int key="objectID">326</int>
+                                               <reference key="object" ref="539748933"/>
                                                <object class="NSMutableArray" key="children">
                                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="51555548"/>
-                                               </object>
-                                               <reference key="parent" ref="520288288"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">325</int>
-                                               <reference key="object" ref="51555548"/>
-                                               <reference key="parent" ref="1062449667"/>
-                                       </object>
-                                       <object class="IBObjectRecord">
-                                               <int key="objectID">326</int>
-                                               <reference key="object" ref="539748933"/>
-                                               <object class="NSMutableArray" key="children">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <reference ref="374363387"/>
+                                                       <reference ref="374363387"/>
                                                </object>
                                                <reference key="parent" ref="520288288"/>
                                        </object>
                                                <reference key="object" ref="869757541"/>
                                                <reference key="parent" ref="907177043"/>
                                        </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">350</int>
+                                               <reference key="object" ref="899831697"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="483848741"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">351</int>
+                                               <reference key="object" ref="483848741"/>
+                                               <reference key="parent" ref="899831697"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">352</int>
+                                               <reference key="object" ref="772611942"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="413609467"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">353</int>
+                                               <reference key="object" ref="413609467"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="743346318"/>
+                                               </object>
+                                               <reference key="parent" ref="772611942"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">354</int>
+                                               <reference key="object" ref="743346318"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="165310533"/>
+                                                       <reference ref="477590220"/>
+                                                       <reference ref="444551526"/>
+                                                       <reference ref="498458317"/>
+                                                       <reference ref="327639789"/>
+                                               </object>
+                                               <reference key="parent" ref="413609467"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">355</int>
+                                               <reference key="object" ref="165310533"/>
+                                               <reference key="parent" ref="743346318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">356</int>
+                                               <reference key="object" ref="477590220"/>
+                                               <reference key="parent" ref="743346318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">357</int>
+                                               <reference key="object" ref="444551526"/>
+                                               <reference key="parent" ref="743346318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">359</int>
+                                               <reference key="object" ref="701867067"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="978611587"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">360</int>
+                                               <reference key="object" ref="978611587"/>
+                                               <reference key="parent" ref="701867067"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">361</int>
+                                               <reference key="object" ref="498458317"/>
+                                               <reference key="parent" ref="743346318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">362</int>
+                                               <reference key="object" ref="327639789"/>
+                                               <reference key="parent" ref="743346318"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">363</int>
+                                               <reference key="object" ref="895206300"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="290473288"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">364</int>
+                                               <reference key="object" ref="290473288"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="898961390"/>
+                                               </object>
+                                               <reference key="parent" ref="895206300"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">365</int>
+                                               <reference key="object" ref="898961390"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="544981908"/>
+                                                       <reference ref="769184887"/>
+                                                       <reference ref="546193261"/>
+                                               </object>
+                                               <reference key="parent" ref="290473288"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">368</int>
+                                               <reference key="object" ref="544981908"/>
+                                               <reference key="parent" ref="898961390"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">369</int>
+                                               <reference key="object" ref="769184887"/>
+                                               <reference key="parent" ref="898961390"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">370</int>
+                                               <reference key="object" ref="546193261"/>
+                                               <reference key="parent" ref="898961390"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">371</int>
+                                               <reference key="object" ref="173328305"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="271531935"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">372</int>
+                                               <reference key="object" ref="271531935"/>
+                                               <reference key="parent" ref="173328305"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">374</int>
+                                               <reference key="object" ref="54712339"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="310956178"/>
+                                               </object>
+                                               <reference key="parent" ref="1048779201"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">375</int>
+                                               <reference key="object" ref="310956178"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="374003297"/>
+                                               </object>
+                                               <reference key="parent" ref="54712339"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">376</int>
+                                               <reference key="object" ref="374003297"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="195310116"/>
+                                                       <reference ref="951535454"/>
+                                                       <reference ref="420036141"/>
+                                               </object>
+                                               <reference key="parent" ref="310956178"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">377</int>
+                                               <reference key="object" ref="195310116"/>
+                                               <reference key="parent" ref="374003297"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">378</int>
+                                               <reference key="object" ref="951535454"/>
+                                               <reference key="parent" ref="374003297"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">379</int>
+                                               <reference key="object" ref="420036141"/>
+                                               <reference key="parent" ref="374003297"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">383</int>
+                                               <reference key="object" ref="280291731"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1049782015"/>
+                                               </object>
+                                               <reference key="parent" ref="1048779201"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">384</int>
+                                               <reference key="object" ref="1049782015"/>
+                                               <reference key="parent" ref="280291731"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">387</int>
+                                               <reference key="object" ref="822080053"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="434430620"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">388</int>
+                                               <reference key="object" ref="434430620"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="841477386"/>
+                                               </object>
+                                               <reference key="parent" ref="822080053"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">389</int>
+                                               <reference key="object" ref="841477386"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="226776327"/>
+                                                       <reference ref="731921194"/>
+                                                       <reference ref="642215596"/>
+                                                       <reference ref="835010135"/>
+                                               </object>
+                                               <reference key="parent" ref="434430620"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">390</int>
+                                               <reference key="object" ref="226776327"/>
+                                               <reference key="parent" ref="841477386"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">391</int>
+                                               <reference key="object" ref="731921194"/>
+                                               <reference key="parent" ref="841477386"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">393</int>
+                                               <reference key="object" ref="642215596"/>
+                                               <reference key="parent" ref="841477386"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">394</int>
+                                               <reference key="object" ref="835010135"/>
+                                               <reference key="parent" ref="841477386"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">395</int>
+                                               <reference key="object" ref="226601760"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1064438472"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">396</int>
+                                               <reference key="object" ref="1064438472"/>
+                                               <reference key="parent" ref="226601760"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">398</int>
+                                               <reference key="object" ref="745324926"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="884409108"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">399</int>
+                                               <reference key="object" ref="884409108"/>
+                                               <reference key="parent" ref="745324926"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">401</int>
+                                               <reference key="object" ref="712613872"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="562265695"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">402</int>
+                                               <reference key="object" ref="562265695"/>
+                                               <reference key="parent" ref="712613872"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">406</int>
+                                               <reference key="object" ref="1054432492"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="787274685"/>
+                                               </object>
+                                               <reference key="parent" ref="332598366"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">407</int>
+                                               <reference key="object" ref="787274685"/>
+                                               <reference key="parent" ref="1054432492"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">410</int>
+                                               <reference key="object" ref="413269307"/>
+                                               <reference key="parent" ref="0"/>
+                                               <string key="objectName">Updater</string>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">414</int>
+                                               <reference key="object" ref="954667708"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="841218599"/>
+                                               </object>
+                                               <reference key="parent" ref="1048779201"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">415</int>
+                                               <reference key="object" ref="841218599"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="601170194"/>
+                                               </object>
+                                               <reference key="parent" ref="954667708"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">416</int>
+                                               <reference key="object" ref="601170194"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="409508073"/>
+                                                       <reference ref="356864129"/>
+                                                       <reference ref="1028006448"/>
+                                               </object>
+                                               <reference key="parent" ref="841218599"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">417</int>
+                                               <reference key="object" ref="409508073"/>
+                                               <reference key="parent" ref="601170194"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">419</int>
+                                               <reference key="object" ref="356864129"/>
+                                               <reference key="parent" ref="601170194"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">420</int>
+                                               <reference key="object" ref="1028006448"/>
+                                               <reference key="parent" ref="601170194"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">442</int>
+                                               <reference key="object" ref="898312631"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="1062716368"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">443</int>
+                                               <reference key="object" ref="1062716368"/>
+                                               <reference key="parent" ref="898312631"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">444</int>
+                                               <reference key="object" ref="200780219"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="221545613"/>
+                                               </object>
+                                               <reference key="parent" ref="23728330"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">445</int>
+                                               <reference key="object" ref="221545613"/>
+                                               <reference key="parent" ref="200780219"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">446</int>
+                                               <reference key="object" ref="247298122"/>
+                                               <object class="NSMutableArray" key="children">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <reference ref="954547948"/>
+                                               </object>
+                                               <reference key="parent" ref="332598366"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">447</int>
+                                               <reference key="object" ref="954547948"/>
+                                               <reference key="parent" ref="247298122"/>
+                                       </object>
                                </object>
                        </object>
                        <object class="NSMutableDictionary" key="flattenedProperties">
                                <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSMutableArray" key="dict.sortedKeys">
+                               <object class="NSArray" key="dict.sortedKeys">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
-                                       <string>-1.IBPluginDependency</string>
-                                       <string>-2.IBPluginDependency</string>
+                                       <string>-3.IBPluginDependency</string>
                                        <string>233.IBEditorWindowLastContentRect</string>
                                        <string>233.IBPluginDependency</string>
                                        <string>233.ImportedFromIB2</string>
                                        <string>234.IBPluginDependency</string>
                                        <string>234.ImportedFromIB2</string>
                                        <string>234.editorWindowContentRectSynchronizationRect</string>
+                                       <string>235.IBEditorWindowLastContentRect</string>
                                        <string>235.IBPluginDependency</string>
                                        <string>235.ImportedFromIB2</string>
                                        <string>236.IBEditorWindowLastContentRect</string>
                                        <string>253.ImportedFromIB2</string>
                                        <string>254.IBPluginDependency</string>
                                        <string>254.ImportedFromIB2</string>
-                                       <string>255.IBPluginDependency</string>
-                                       <string>255.ImportedFromIB2</string>
                                        <string>275.IBPluginDependency</string>
                                        <string>275.ImportedFromIB2</string>
                                        <string>276.IBPluginDependency</string>
                                        <string>276.ImportedFromIB2</string>
-                                       <string>280.IBPluginDependency</string>
-                                       <string>280.ImportedFromIB2</string>
                                        <string>289.IBPluginDependency</string>
                                        <string>289.ImportedFromIB2</string>
+                                       <string>290.IBEditorWindowLastContentRect</string>
                                        <string>290.IBPluginDependency</string>
                                        <string>290.ImportedFromIB2</string>
                                        <string>291.IBPluginDependency</string>
                                        <string>295.ImportedFromIB2</string>
                                        <string>296.IBPluginDependency</string>
                                        <string>296.ImportedFromIB2</string>
-                                       <string>324.IBPluginDependency</string>
-                                       <string>325.IBPluginDependency</string>
+                                       <string>300.IBPluginDependency</string>
+                                       <string>301.IBPluginDependency</string>
+                                       <string>302.IBPluginDependency</string>
+                                       <string>304.IBPluginDependency</string>
+                                       <string>305.IBPluginDependency</string>
+                                       <string>306.IBPluginDependency</string>
+                                       <string>307.IBPluginDependency</string>
+                                       <string>308.IBPluginDependency</string>
+                                       <string>309.IBPluginDependency</string>
+                                       <string>315.IBPluginDependency</string>
+                                       <string>316.IBPluginDependency</string>
+                                       <string>317.IBPluginDependency</string>
                                        <string>326.IBPluginDependency</string>
                                        <string>327.IBPluginDependency</string>
                                        <string>347.IBPluginDependency</string>
                                        <string>347.ImportedFromIB2</string>
+                                       <string>348.IBPluginDependency</string>
+                                       <string>350.IBPluginDependency</string>
+                                       <string>350.ImportedFromIB2</string>
+                                       <string>351.IBPluginDependency</string>
+                                       <string>352.IBPluginDependency</string>
+                                       <string>353.IBPluginDependency</string>
+                                       <string>354.IBEditorWindowLastContentRect</string>
+                                       <string>354.IBPluginDependency</string>
+                                       <string>355.IBPluginDependency</string>
+                                       <string>356.IBPluginDependency</string>
+                                       <string>357.IBPluginDependency</string>
+                                       <string>359.IBPluginDependency</string>
+                                       <string>359.ImportedFromIB2</string>
+                                       <string>360.IBPluginDependency</string>
+                                       <string>361.IBPluginDependency</string>
+                                       <string>362.IBPluginDependency</string>
+                                       <string>363.IBPluginDependency</string>
+                                       <string>364.IBPluginDependency</string>
+                                       <string>365.IBEditorWindowLastContentRect</string>
+                                       <string>365.IBPluginDependency</string>
+                                       <string>368.IBPluginDependency</string>
+                                       <string>369.IBPluginDependency</string>
+                                       <string>370.IBPluginDependency</string>
+                                       <string>371.IBPluginDependency</string>
+                                       <string>371.ImportedFromIB2</string>
+                                       <string>372.IBPluginDependency</string>
+                                       <string>374.IBPluginDependency</string>
+                                       <string>374.ImportedFromIB2</string>
+                                       <string>375.IBPluginDependency</string>
+                                       <string>376.IBEditorWindowLastContentRect</string>
+                                       <string>376.IBPluginDependency</string>
+                                       <string>376.ImportedFromIB2</string>
+                                       <string>377.IBPluginDependency</string>
+                                       <string>377.ImportedFromIB2</string>
+                                       <string>378.IBPluginDependency</string>
+                                       <string>378.ImportedFromIB2</string>
+                                       <string>379.IBPluginDependency</string>
+                                       <string>379.ImportedFromIB2</string>
+                                       <string>383.IBPluginDependency</string>
+                                       <string>383.ImportedFromIB2</string>
+                                       <string>384.IBPluginDependency</string>
+                                       <string>387.IBPluginDependency</string>
+                                       <string>388.IBPluginDependency</string>
+                                       <string>389.IBEditorWindowLastContentRect</string>
+                                       <string>389.IBPluginDependency</string>
+                                       <string>390.IBPluginDependency</string>
+                                       <string>391.IBPluginDependency</string>
+                                       <string>393.IBPluginDependency</string>
+                                       <string>394.IBPluginDependency</string>
+                                       <string>395.IBPluginDependency</string>
+                                       <string>395.ImportedFromIB2</string>
+                                       <string>396.IBPluginDependency</string>
+                                       <string>398.IBPluginDependency</string>
+                                       <string>398.ImportedFromIB2</string>
+                                       <string>399.IBPluginDependency</string>
+                                       <string>401.IBPluginDependency</string>
+                                       <string>401.ImportedFromIB2</string>
+                                       <string>402.IBPluginDependency</string>
+                                       <string>406.IBPluginDependency</string>
+                                       <string>407.IBPluginDependency</string>
+                                       <string>414.IBPluginDependency</string>
+                                       <string>414.ImportedFromIB2</string>
+                                       <string>415.IBPluginDependency</string>
+                                       <string>416.IBEditorWindowLastContentRect</string>
+                                       <string>416.IBPluginDependency</string>
+                                       <string>416.ImportedFromIB2</string>
+                                       <string>417.IBPluginDependency</string>
+                                       <string>417.ImportedFromIB2</string>
+                                       <string>419.IBPluginDependency</string>
+                                       <string>419.ImportedFromIB2</string>
+                                       <string>420.IBPluginDependency</string>
+                                       <string>420.ImportedFromIB2</string>
+                                       <string>442.IBPluginDependency</string>
+                                       <string>442.ImportedFromIB2</string>
+                                       <string>443.IBPluginDependency</string>
+                                       <string>444.IBPluginDependency</string>
+                                       <string>444.ImportedFromIB2</string>
+                                       <string>445.IBPluginDependency</string>
+                                       <string>446.IBPluginDependency</string>
+                                       <string>446.ImportedFromIB2</string>
+                                       <string>447.IBPluginDependency</string>
+                                       <string>5.IBEditorWindowLastContentRect</string>
                                        <string>5.IBPluginDependency</string>
+                                       <string>5.IBWindowTemplateEditedContentRect</string>
                                        <string>5.ImportedFromIB2</string>
                                        <string>5.windowTemplate.hasMaxSize</string>
                                        <string>5.windowTemplate.hasMinSize</string>
                                <object class="NSMutableArray" key="dict.values">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{198, 532}, {492, 236}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <string>{{28, 401}, {492, 189}}</string>
-                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>{{0, 636}, {500, 209}}</string>
-                                       <string>{{27, 609}, {496, 80}}</string>
+                                       <string>{{144, 376}, {496, 82}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>{{0, 726}, {500, 108}}</string>
+                                       <string>{{73, 765}, {492, 91}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <string>{{110, 672}, {500, 184}}</string>
+                                       <integer value="1"/>
+                                       <string>{{451, 407}, {492, 237}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>{{0, 650}, {500, 184}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
+                                       <string>{{314, 193}, {234, 123}}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
+                                       <integer value="1"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                                       <reference ref="9"/>
-                                       <reference ref="9"/>
-                                       <string>{3.40282e+38, 3.40282e+38}</string>
-                                       <string>{213, 107}</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-                                       <reference ref="9"/>
-                               </object>
-                       </object>
-                       <object class="NSMutableDictionary" key="unlocalizedProperties">
-                               <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSArray" key="dict.sortedKeys">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
-                               <object class="NSMutableArray" key="dict.values">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
-                       </object>
-                       <nil key="activeLocalization"/>
-                       <object class="NSMutableDictionary" key="localizations">
-                               <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="NSArray" key="dict.sortedKeys">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
-                               <object class="NSMutableArray" key="dict.values">
-                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                               </object>
-                       </object>
-                       <nil key="sourceID"/>
-                       <int key="maxID">349</int>
-               </object>
-               <object class="IBClassDescriber" key="IBDocument.Classes">
-                       <object class="NSMutableArray" key="referencedPartialClassDescriptions">
-                               <bool key="EncodedWithXMLCoder">YES</bool>
-                               <object class="IBPartialClassDescription">
-                                       <string key="className">HBPreferencesController</string>
-                                       <string key="superclassName">NSWindowController</string>
-                                       <object class="NSMutableDictionary" key="outlets">
-                                               <bool key="EncodedWithXMLCoder">YES</bool>
-                                               <object class="NSMutableArray" key="dict.sortedKeys">
-                                                       <bool key="EncodedWithXMLCoder">YES</bool>
-                                                       <string>fAdvancedView</string>
-                                                       <string>fAudioView</string>
-                                                       <string>fGeneralView</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{612, 486}, {77, 88}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{614, 495}, {77, 54}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{535, 648}, {255, 63}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{828, 530}, {88, 71}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{317, 613}, {218, 54}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{69, 656}, {500, 200}}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <string>{{69, 656}, {500, 200}}</string>
+                                       <integer value="1"/>
+                                       <integer value="0"/>
+                                       <integer value="1"/>
+                                       <string>{3.40282e+38, 3.40282e+38}</string>
+                                       <string>{213, 107}</string>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                                       <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+                                       <integer value="1"/>
+                               </object>
+                       </object>
+                       <object class="NSMutableDictionary" key="unlocalizedProperties">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <reference key="dict.sortedKeys" ref="0"/>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                               </object>
+                       </object>
+                       <nil key="activeLocalization"/>
+                       <object class="NSMutableDictionary" key="localizations">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <reference key="dict.sortedKeys" ref="0"/>
+                               <object class="NSMutableArray" key="dict.values">
+                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                               </object>
+                       </object>
+                       <nil key="sourceID"/>
+                       <int key="maxID">447</int>
+               </object>
+               <object class="IBClassDescriber" key="IBDocument.Classes">
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">HBPreferencesController</string>
+                                       <string key="superclassName">NSWindowController</string>
+                                       <object class="NSMutableDictionary" key="outlets">
+                                               <bool key="EncodedWithXMLCoder">YES</bool>
+                                               <object class="NSArray" key="dict.sortedKeys">
+                                                       <bool key="EncodedWithXMLCoder">YES</bool>
+                                                       <string>fAdvancedView</string>
+                                                       <string>fAudioView</string>
+                                                       <string>fGeneralView</string>
                                                        <string>fPictureView</string>
                                                </object>
                                                <object class="NSMutableArray" key="dict.values">
                                                <string key="minorKey"/>
                                        </object>
                                </object>
+                       </object>
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSObject</string>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
-                                               <string key="majorKey">IBProjectSource</string>
-                                               <string key="minorKey">PictureController.h</string>
+                                               <string key="majorKey">IBDocumentRelativeSource</string>
+                                               <string key="minorKey">../Sparkle.framework/Versions/A/Headers/SUAppcast.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="606901004">
+                                               <string key="majorKey">IBDocumentRelativeSource</string>
+                                               <string key="minorKey">../Sparkle.framework/Versions/A/Headers/SUUpdater.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">SUUpdater</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <string key="NS.key.0">checkForUpdates:</string>
+                                               <string key="NS.object.0">id</string>
+                                       </object>
+                                       <object class="NSMutableDictionary" key="outlets">
+                                               <string key="NS.key.0">delegate</string>
+                                               <string key="NS.object.0">id</string>
                                        </object>
+                                       <reference key="sourceIdentifier" ref="606901004"/>
                                </object>
                        </object>
-               </object>
-               <int key="IBDocument.localizationMode">0</int>
+                       <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+                               <bool key="EncodedWithXMLCoder">YES</bool>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSActionCell</string>
+                                       <string key="superclassName">NSCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="272496638">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="414101932">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="517511271">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSApplication</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButton</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButtonCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSCell</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSComboBox</string>
+                                       <string key="superclassName">NSTextField</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSComboBox.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSComboBoxCell</string>
+                                       <string key="superclassName">NSTextFieldCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSComboBoxCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSControl</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="555780892">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSControl.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSController</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSFormatter</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenu</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="209938787">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItem</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="428742070">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSMenuItemCell</string>
+                                       <string key="superclassName">NSButtonCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSMenuItemCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="272496638"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="414101932"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="517511271"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="555780892"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <reference key="sourceIdentifier" ref="209938787"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="824086037">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Growl.framework/Headers/GrowlApplicationBridge.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKImageBrowserView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/IKSaveOptions.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">ImageKit.framework/Headers/ImageKitDeprecated.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFDocument.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">PDFKit.framework/Headers/PDFView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedAudioOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureDecompressedVideoOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureFileOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureVideoPreviewOutput.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTCaptureView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovie.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QTKit.framework/Headers/QTMovieView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionParameterView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionPickerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuartzFilters.framework/Headers/QuartzFilterManager.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">QuickLookUI.framework/Headers/QLPreviewPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUAppcast.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier" id="568667533">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">Sparkle.framework/Headers/SUUpdater.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPanel</string>
+                                       <string key="superclassName">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPanel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButton</string>
+                                       <string key="superclassName">NSButton</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButton.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSPopUpButtonCell</string>
+                                       <string key="superclassName">NSMenuItemCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSPopUpButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSResponder</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextField</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSTextFieldCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSUserDefaultsController</string>
+                                       <string key="superclassName">NSController</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSUserDefaultsController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <reference key="sourceIdentifier" ref="428742070"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSView</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <reference key="sourceIdentifier" ref="824086037"/>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindow</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSWindowController</string>
+                                       <string key="superclassName">NSResponder</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <string key="NS.key.0">showWindow:</string>
+                                               <string key="NS.object.0">id</string>
+                                       </object>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">SUUpdater</string>
+                                       <string key="superclassName">NSObject</string>
+                                       <object class="NSMutableDictionary" key="actions">
+                                               <string key="NS.key.0">checkForUpdates:</string>
+                                               <string key="NS.object.0">id</string>
+                                       </object>
+                                       <object class="NSMutableDictionary" key="outlets">
+                                               <string key="NS.key.0">delegate</string>
+                                               <string key="NS.object.0">id</string>
+                                       </object>
+                                       <reference key="sourceIdentifier" ref="568667533"/>
+                               </object>
+                       </object>
+               </object>
+               <int key="IBDocument.localizationMode">0</int>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+                       <integer value="1050" key="NS.object.0"/>
+               </object>
+               <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+                       <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
+                       <integer value="3000" key="NS.object.0"/>
+               </object>
+               <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
                <string key="IBDocument.LastKnownRelativeProjectPath">../HandBrake.xcodeproj</string>
                <int key="IBDocument.defaultPropertyAccessControl">3</int>
        </data>
index a0572a3..aacc25f 100755 (executable)
Binary files a/macosx/Growl.framework/Versions/A/Growl and b/macosx/Growl.framework/Versions/A/Growl differ
index fb70509..e35663f 100644 (file)
 #include <sys/cdefs.h>
 #include <Carbon/Carbon.h>
 
+#ifndef GROWL_EXPORT
+#define GROWL_EXPORT __attribute__((visibility("default")))
+#endif
+
 /*!    @header GrowlApplicationBridge-Carbon.h
  *     @abstract       Declares an API that Carbon applications can use to interact with Growl.
  *     @discussion     GrowlApplicationBridge uses a delegate to provide information //XXX
@@ -323,6 +327,8 @@ struct Growl_Notification {
         *       0.7.
         */
        void (*clickCallback)(CFPropertyListRef clickContext);
+
+       CFStringRef identifier;
 };
 
 #pragma mark -
@@ -374,6 +380,8 @@ struct Growl_Notification {
                        (notification)->reserved = 0U; \
                        (notification)->isSticky = false; \
                        (notification)->clickContext = NULL; \
+                       (notification)->clickCallback = NULL; \
+                       (notification)->identifier = NULL; \
                } \
        } while(0)
 
@@ -417,7 +425,7 @@ struct Growl_Notification {
  *      structure, except possibly the referenceCount by calling the retain and
  *      release members.
  */
-Boolean Growl_SetDelegate(struct Growl_Delegate *newDelegate);
+GROWL_EXPORT Boolean Growl_SetDelegate(struct Growl_Delegate *newDelegate);
 
 /*!    @function       Growl_GetDelegate
  *     @abstract       Returns the current Growl delegate, if any.
@@ -430,7 +438,7 @@ Boolean Growl_SetDelegate(struct Growl_Delegate *newDelegate);
  *      delegate on your behalf. You are responsible for retaining and releasing
  *      the delegate as needed.
  */
-struct Growl_Delegate *Growl_GetDelegate(void);
+GROWL_EXPORT struct Growl_Delegate *Growl_GetDelegate(void);
 
 #pragma mark -
 
@@ -452,7 +460,7 @@ struct Growl_Delegate *Growl_GetDelegate(void);
  *      If the user does choose to install Growl, the requested notification will
  *      be displayed once Growl is installed and running.
  */
-void Growl_PostNotification(const struct Growl_Notification *notification);
+GROWL_EXPORT void Growl_PostNotification(const struct Growl_Notification *notification);
 
 /*!    @function Growl_PostNotificationWithDictionary
 *      @abstract       Notifies using a userInfo dictionary suitable for passing to
@@ -468,7 +476,7 @@ void Growl_PostNotification(const struct Growl_Notification *notification);
 *       to using CFDistributedNotificationCenter. The keys for this dictionary
  *      can be found in GrowlDefines.h.
 */
-void Growl_PostNotificationWithDictionary(CFDictionaryRef userInfo);
+GROWL_EXPORT void Growl_PostNotificationWithDictionary(CFDictionaryRef userInfo);
 
 /*!    @function       Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext
  *     @abstract       Posts a Growl notification using parameter values.
@@ -491,7 +499,7 @@ void Growl_PostNotificationWithDictionary(CFDictionaryRef userInfo);
  *      The icon data can be in any format supported by NSImage. As of Mac OS X
  *      10.3, this includes the .icns, TIFF, JPEG, GIF, PNG, PDF, and PICT formats.
  */
-void Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext(
+GROWL_EXPORT void Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext(
  /*inhale*/
        CFStringRef title,
        CFStringRef description,
@@ -525,7 +533,7 @@ void Growl_NotifyWithTitleDescriptionNameIconPriorityStickyClickContext(
  *      This function was introduced in Growl.framework 0.7.
  *     @result <code>false</code> if registration failed (e.g. if Growl isn't installed).
  */
-Boolean Growl_RegisterWithDictionary(CFDictionaryRef regDict);
+GROWL_EXPORT Boolean Growl_RegisterWithDictionary(CFDictionaryRef regDict);
 
 /*!    @function       Growl_Reregister
  *     @abstract       Updates your registration with Growl.
@@ -543,7 +551,7 @@ Boolean Growl_RegisterWithDictionary(CFDictionaryRef regDict);
  *      This function is now implemented using
  *      <code>Growl_RegisterWithDictionary</code>.
  */
-void Growl_Reregister(void);
+GROWL_EXPORT void Growl_Reregister(void);
 
 #pragma mark -
 
@@ -563,14 +571,14 @@ void Growl_Reregister(void);
  *     @param  flag    <code>true</code> if you want GrowlApplicationBridge to register with
  *      Growl when next it is ready; <code>false</code> if not.
  */
-void Growl_SetWillRegisterWhenGrowlIsReady(Boolean flag);
+GROWL_EXPORT void Growl_SetWillRegisterWhenGrowlIsReady(Boolean flag);
 /*!    @function       Growl_WillRegisterWhenGrowlIsReady
  *     @abstract       Reports whether GrowlApplicationBridge will register with Growl
  *      when Growl next launches.
  *     @result <code>true</code> if GrowlApplicationBridge will register with
  *      Growl when next it posts GROWL_IS_READY; <code>false</code> if not.
  */
-Boolean Growl_WillRegisterWhenGrowlIsReady(void);
+GROWL_EXPORT Boolean Growl_WillRegisterWhenGrowlIsReady(void);
 
 #pragma mark -
 
@@ -585,14 +593,14 @@ Boolean Growl_WillRegisterWhenGrowlIsReady(void);
  *      This function does not attempt to clean up the dictionary in any way - for
  *      example, if it is missing the <code>GROWL_APP_NAME</code> key, the result
  *      will be missing it too. Use
- *      <code>Growl_CreateRegistrationDictionaryByFillingInDictionary:</code> or
+ *      <code>Growl_CreateRegistrationDictionaryByFillingInDictionary</code> or
  *      <code>Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys</code>
  *      to try to fill in missing keys.
  *
  *      This function was introduced in Growl.framework 0.7.
  *     @result A registration dictionary.
  */
-CFDictionaryRef Growl_CopyRegistrationDictionaryFromDelegate(void);
+GROWL_EXPORT CFDictionaryRef Growl_CopyRegistrationDictionaryFromDelegate(void);
 
 /*!    @function       Growl_CopyRegistrationDictionaryFromBundle
  *     @abstract       Looks in a bundle for a registration dictionary.
@@ -613,7 +621,7 @@ CFDictionaryRef Growl_CopyRegistrationDictionaryFromDelegate(void);
  *      This function was introduced in Growl.framework 0.7.
  *     @result A registration dictionary.
  */
-CFDictionaryRef Growl_CopyRegistrationDictionaryFromBundle(CFBundleRef bundle);
+GROWL_EXPORT CFDictionaryRef Growl_CopyRegistrationDictionaryFromBundle(CFBundleRef bundle);
 
 /*!    @function       Growl_CreateBestRegistrationDictionary
  *     @abstract       Obtains a registration dictionary, filled out to the best of
@@ -639,7 +647,7 @@ CFDictionaryRef Growl_CopyRegistrationDictionaryFromBundle(CFBundleRef bundle);
  *      This function was introduced in Growl.framework 0.7.
  *     @result A registration dictionary.
  */
-CFDictionaryRef Growl_CreateBestRegistrationDictionary(void);
+GROWL_EXPORT CFDictionaryRef Growl_CreateBestRegistrationDictionary(void);
 
 #pragma mark -
 
@@ -664,7 +672,7 @@ CFDictionaryRef Growl_CreateBestRegistrationDictionary(void);
  *
  *      This function was introduced in Growl.framework 0.7.
  */
-CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionary(CFDictionaryRef regDict);
+GROWL_EXPORT CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionary(CFDictionaryRef regDict);
 /*!    @function       Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys
  *     @abstract       Tries to fill in missing keys in a registration dictionary.
  *     @param  regDict The dictionary to fill in.
@@ -686,7 +694,21 @@ CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionary(CFDictio
  *
  *      This function was introduced in Growl.framework 0.7.
  */
-CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys(CFDictionaryRef regDict, CFSetRef keys);
+GROWL_EXPORT CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionaryRestrictedToKeys(CFDictionaryRef regDict, CFSetRef keys);
+
+/*!    @brief  Tries to fill in missing keys in a notification dictionary.
+ *     @param  notifDict       The dictionary to fill in.
+ *     @return The dictionary with the keys filled in. This will be a separate instance from \a notifDict.
+ *     @discussion     This function examines the \a notifDict for missing keys, and 
+ *      tries to get them from the last known registration dictionary. As of 1.1, 
+ *      the keys that it will look for are:
+ *
+ *      \li <code>GROWL_APP_NAME</code>
+ *      \li <code>GROWL_APP_ICON</code>
+ *
+ *     @since Growl.framework 1.1
+ */
+GROWL_EXPORT CFDictionaryRef Growl_CreateNotificationDictionaryByFillingInDictionary(CFDictionaryRef notifDict);
 
 #pragma mark -
 
@@ -697,14 +719,14 @@ CFDictionaryRef Growl_CreateRegistrationDictionaryByFillingInDictionaryRestricte
  *      installed.
  *     @result Returns true if Growl is installed, false otherwise.
  */
-Boolean Growl_IsInstalled(void);
+GROWL_EXPORT Boolean Growl_IsInstalled(void);
 
 /*!    @function       Growl_IsRunning
  *     @abstract       Cycles through the process list to find whether GrowlHelperApp
  *      is running.
  *     @result Returns true if Growl is running, false otherwise.
  */
-Boolean Growl_IsRunning(void);
+GROWL_EXPORT Boolean Growl_IsRunning(void);
 
 #pragma mark -
 
@@ -738,7 +760,7 @@ typedef void (*GrowlLaunchCallback)(void *context);
  *      acceptable for context to be <code>NULL</code>. The callback itself can be
  *      <code>NULL</code> if you don't want one.
  */
-Boolean Growl_LaunchIfInstalled(GrowlLaunchCallback callback, void *context);
+GROWL_EXPORT Boolean Growl_LaunchIfInstalled(GrowlLaunchCallback callback, void *context);
 
 #pragma mark -
 #pragma mark Constants
index 7ac315a..4341f3f 100644 (file)
@@ -3,7 +3,7 @@
 //  Growl
 //
 //  Created by Evan Schoenberg on Wed Jun 16 2004.
-//  Copyright 2004-2005 The Growl Project. All rights reserved.
+//  Copyright 2004-2006 The Growl Project. All rights reserved.
 //
 
 /*!
 #define __GrowlApplicationBridge_h__
 
 #import <Foundation/Foundation.h>
+#import <AppKit/AppKit.h>
 #import "GrowlDefines.h"
 
 //Forward declarations
 @protocol GrowlApplicationBridgeDelegate;
 
-/*!
- *     @defined    GROWL_PREFPANE_BUNDLE_IDENTIFIER
- *     @discussion The bundle identifier for the Growl prefpane.
- */
-#define GROWL_PREFPANE_BUNDLE_IDENTIFIER       @"com.growl.prefpanel"
-
-/*!
- *     @defined    GROWL_PREFPANE_NAME
- *     @discussion The file name of the Growl prefpane.
- */
-#define GROWL_PREFPANE_NAME                                    @"Growl.prefPane"
-
 //Internal notification when the user chooses not to install (to avoid continuing to cache notifications awaiting installation)
 #define GROWL_USER_CHOSE_NOT_TO_INSTALL_NOTIFICATION @"User chose not to install"
 
                        clickContext:(id)clickContext
                          identifier:(NSString *)identifier;
 
+/*!
+ *     @method notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:identifier:
+ *     @abstract Send a Growl notification.
+ *     @discussion This is the preferred means for sending a Growl notification.
+ *      The notification name and at least one of the title and description are
+ *      required (all three are preferred).  All other parameters may be
+ *      <code>nil</code> (or 0 or NO as appropriate) to accept default values.
+ *
+ *      If using the Growl-WithInstaller framework, if Growl is not installed the
+ *      user will be prompted to install Growl. If the user cancels, this method
+ *      will have no effect until the next application session, at which time when
+ *      it is called the user will be prompted again. The user is also given the
+ *      option to not be prompted again.  If the user does choose to install Growl,
+ *      the requested notification will be displayed once Growl is installed and
+ *      running.
+ *
+ *     @param title            The title of the notification displayed to the user.
+ *     @param description      The full description of the notification displayed to the user.
+ *     @param notifName        The internal name of the notification. Should be human-readable, as it will be displayed in the Growl preference pane.
+ *     @param iconData         <code>NSData</code> object to show with the notification as its icon. If <code>nil</code>, the application's icon will be used instead.
+ *     @param priority         The priority of the notification. The default value is 0; positive values are higher priority and negative values are lower priority. Not all Growl displays support priority.
+ *     @param isSticky         If YES, the notification will remain on screen until clicked. Not all Growl displays support sticky notifications.
+ *     @param clickContext     A context passed back to the Growl delegate if it implements -(void)growlNotificationWasClicked: and the notification is clicked. Not all display plugins support clicking. The clickContext must be plist-encodable (completely of <code>NSString</code>, <code>NSArray</code>, <code>NSNumber</code>, <code>NSDictionary</code>, and <code>NSData</code> types).
+ *     @param identifier       An identifier for this notification. Notifications with equal identifiers are coalesced.
+ */
++ (void) notifyWithTitle:(NSString *)title
+                        description:(NSString *)description
+               notificationName:(NSString *)notifName
+                               iconData:(NSData *)iconData
+                               priority:(signed int)priority
+                               isSticky:(BOOL)isSticky
+                       clickContext:(id)clickContext
+                         identifier:(NSString *)identifier;
+
 /*!    @method notifyWithDictionary:
  *     @abstract       Notifies using a userInfo dictionary suitable for passing to
  *      <code>NSDistributedNotificationCenter</code>.
  */
 + (NSDictionary *) registrationDictionaryByFillingInDictionary:(NSDictionary *)regDict restrictToKeys:(NSSet *)keys;
 
+/*!    @brief  Tries to fill in missing keys in a notification dictionary.
+ *     @param  notifDict       The dictionary to fill in.
+ *     @return The dictionary with the keys filled in. This will be a separate instance from \a notifDict.
+ *     @discussion     This function examines the \a notifDict for missing keys, and 
+ *      tries to get them from the last known registration dictionary. As of 1.1, 
+ *      the keys that it will look for are:
+ *
+ *      \li <code>GROWL_APP_NAME</code>
+ *      \li <code>GROWL_APP_ICON</code>
+ *
+ *     @since Growl.framework 1.1
+ */
++ (NSDictionary *) notificationDictionaryByFillingInDictionary:(NSDictionary *)regDict;
+
++ (NSDictionary *) frameworkInfoDictionary;
 @end
 
 //------------------------------------------------------------------------------
  *      <code>+[GrowlApplicationBridge
  *      notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:]</code> calls.
  *
- *      The dictionary should have 2 key object pairs:
+ *      The dictionary should have the required key object pairs:
  *      key: GROWL_NOTIFICATIONS_ALL           object: <code>NSArray</code> of <code>NSString</code> objects
  *      key: GROWL_NOTIFICATIONS_DEFAULT       object: <code>NSArray</code> of <code>NSString</code> objects
  *
+ *   The dictionary may have the following key object pairs:
+ *   key: GROWL_NOTIFICATIONS_HUMAN_READABLE_NAMES     object: <code>NSDictionary</code> of key: notification name             object: human-readable notification name
+ *
  *      You do not need to implement this method if you have an auto-discoverable
  *      plist file in your app bundle. (XXX refer to more information on that)
  *
 - (NSString *) applicationNameForGrowl;
 
 /*!
+ *     @method applicationIconForGrowl
+ *     @abstract Return the <code>NSImage</code> to treat as the application icon.
+ *     @discussion The delegate may optionally return an <code>NSImage</code>
+ *      object to use as the application icon. If this method is not implemented,
+ *      {{{-applicationIconDataForGrowl}}} is tried. If that method is not
+ *      implemented, the application's own icon is used. Neither method is
+ *      generally needed.
+ *     @result The <code>NSImage</code> to treat as the application icon.
+ */
+- (NSImage *) applicationIconForGrowl;
+
+/*!
  *     @method applicationIconDataForGrowl
  *     @abstract Return the <code>NSData</code> to treat as the application icon.
  *     @discussion The delegate may optionally return an <code>NSData</code>
  *      object to use as the application icon; if this is not implemented, the
  *      application's own icon is used.  This is not generally needed.
  *     @result The <code>NSData</code> to treat as the application icon.
+ *     @deprecated In version 1.1, in favor of {{{-applicationIconForGrowl}}}.
  */
 - (NSData *) applicationIconDataForGrowl;
 
  *     @method growlIsReady
  *     @abstract Informs the delegate that Growl has launched.
  *     @discussion Informs the delegate that Growl (specifically, the
- *      GrowlHelperApp) was launched successfully or was already running.  The
- *      application can take actions with the knowledge that Growl is installed and
- *      functional.
+ *      GrowlHelperApp) was launched successfully. The application can take actions
+ *   with the knowledge that Growl is installed and functional.
  */
 - (void) growlIsReady;
 
index 6ff6ee3..2b971cf 100644 (file)
@@ -7,10 +7,10 @@
 
 #ifdef __OBJC__
 #define XSTR(x) (@x)
-#define STRING NSString *
+#define STRING_TYPE NSString *
 #else
 #define XSTR CFSTR
-#define STRING CFStringRef
+#define STRING_TYPE CFStringRef
 #endif
 
 /*!    @header GrowlDefines.h
  *      "SurfWriter Lite" are not.
  */
 #define GROWL_APP_NAME                                 XSTR("ApplicationName")
+/*!    @defined GROWL_APP_ID
+ *     @abstract The bundle identifier of your application.
+ *     @discussion The bundle identifier of your application. This key should
+ *   be unique for your application while there may be several applications
+ *   with the same GROWL_APP_NAME.
+ *   This key is optional.
+ */
+#define GROWL_APP_ID                                   XSTR("ApplicationId")
 /*!    @defined GROWL_APP_ICON
  *     @abstract The image data for your application's icon.
  *     @discussion Image data representing your application's icon. This may be
  *      notification names.
  */
 #define GROWL_NOTIFICATIONS_ALL                        XSTR("AllNotifications")
+/*! @defined GROWL_NOTIFICATIONS_HUMAN_READABLE_DESCRIPTIONS
+ *  @abstract A dictionary of human-readable names for your notifications.
+ *  @discussion By default, the Growl UI will display notifications by the names given in GROWL_NOTIFICATIONS_ALL
+ *  which correspond to the GROWL_NOTIFICATION_NAME. This dictionary specifies the human-readable name to display.
+ *  The keys of the dictionary are GROWL_NOTIFICATION_NAME strings; the objects are the human-readable versions.
+ *  For any GROWL_NOTIFICATION_NAME not specific in this dictionary, the GROWL_NOTIFICATION_NAME will be displayed.
+ *
+ *  This key is optional.
+ */
+#define GROWL_NOTIFICATIONS_HUMAN_READABLE_NAMES               XSTR("HumanReadableNames")
+/*! @defined GROWL_NOTIFICATIONS_DESCRIPTIONS
+*  @abstract A dictionary of descriptions of _when_ each notification occurs
+*  @discussion This is an NSDictionary whose keys are GROWL_NOTIFICATION_NAME strings and whose objects are
+*  descriptions of _when_ each notification occurs, such as "You received a new mail message" or
+*  "A file finished downloading".
+*
+*  This key is optional.
+*/
+#define GROWL_NOTIFICATIONS_DESCRIPTIONS               XSTR("NotificationDescriptions")
+
 /*!    @defined        GROWL_TICKET_VERSION
  *     @abstract       The version of your registration ticket.
  *     @discussion     Include this key in a ticket plist file that you put in your
 
 /*!    @defined GROWL_NOTIFICATION_NAME
  *     @abstract The name of the notification.
- *     @discussion The name of the notification. This should be human-readable, as
- *      it's shown in the prefpane, in the list of notifications your application
- *      supports. */
+ *     @discussion The name of the notification. Note that if you do not define
+ *  GROWL_NOTIFICATIONS_HUMAN_READABLE_NAMES when registering your ticket originally this name
+ *  will the one displayed within the Growl preference pane and should be human-readable.
+ */
 #define GROWL_NOTIFICATION_NAME                        XSTR("NotificationName")
 /*!    @defined GROWL_NOTIFICATION_TITLE
  *     @abstract The title to display in the notification.
  */
 #define GROWL_APP_PID                                  XSTR("ApplicationPID")
 
+/*!    @defined GROWL_NOTIFICATION_PROGRESS
+*      @abstract If this key is set, it should contain a double value wrapped
+*     in a NSNumber which describes some sort of progress (from 0.0 to 100.0).
+*     If this is key is not set, no progress bar is shown.
+*
+*       Optional. Not supported by all display plugins.
+*/
+#define GROWL_NOTIFICATION_PROGRESS            XSTR("NotificationProgress")
+
 // Notifications
 #pragma mark Notifications
 
  */
 #define GROWL_REG_DICT_EXTENSION               XSTR("growlRegDict")
 
+
+#define GROWL_POSITION_PREFERENCE_KEY                  @"GrowlSelectedPosition"
+
 #endif //ndef _GROWLDEFINES_H
index 6530bd2..ab7194d 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
        <key>CFBundleShortVersionString</key>
-       <string>0.7.6</string>
+       <string>1.1.2</string>
        <key>CFBundleSignature</key>
        <string>GRRR</string>
        <key>CFBundleVersion</key>
-       <string>0.7.6</string>
+       <string>1.1.2</string>
        <key>NSPrincipalClass</key>
        <string>GrowlApplicationBridge</string>
 </dict>
index 3af5b5b..a58b2f8 100644 (file)
     IBOutlet NSButton           * fX264opt8x8dctSwitch;
     IBOutlet NSTextField        * fX264optCabacLabel;
     IBOutlet NSButton           * fX264optCabacSwitch;
+    IBOutlet NSSlider           * fX264optPsyRDSlider;
+    IBOutlet NSTextField        * fX264optPsyRDLabel;
+    IBOutlet NSSlider           * fX264optPsyTrellisSlider;
+    IBOutlet NSTextField        * fX264optPsyTrellisLabel;
+    IBOutlet NSPopUpButton      * fX264optBAdaptPopUp;
+    IBOutlet NSTextField        * fX264optBAdaptLabel;
 }
 
 // x264 Advanced Panel Methods
@@ -63,6 +69,9 @@
 - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender;
 - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender;
 - (NSString *)  X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString;
+- (NSString *)  X264AdvancedOptionsOptIDToString: (id) sender;
+- (NSString *)  X264AdvancedOptionsWidgetToString: (NSString *) optName withID: (id) sender;
+- (BOOL) X264AdvancedOptionsIsOpt: (NSString *) optNameToChange inString: (NSString *) currentOptString;
 - (IBAction) X264AdvancedOptionsChanged: (id) sender;
 
 @end
index b3ddeb0..e08cf4f 100644 (file)
@@ -71,7 +71,7 @@
         fX264optWeightBLabel,fX264optWeightBSwitch, fX264optBPyramidLabel,fX264optBPyramidSwitch,
         fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel,
         fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch,
-        fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp};
+        fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp, fX264optPsyRDSlider, fX264optPsyRDLabel, fX264optPsyTrellisSlider, fX264optPsyTrellisLabel, fX264optBAdaptPopUp, fX264optBAdaptLabel };
 
     for( i = 0; i < sizeof( controls ) / sizeof( NSControl * ); i++ )
     {
 {
     /*Set opt widget values here*/
     
+    NSString * toolTip = @"";
+    
     /*B-Frames fX264optBframesPopUp*/
     int i;
     [fX264optBframesPopUp removeAllItems];
-    [fX264optBframesPopUp addItemWithTitle:@"Default (0)"];
+    [fX264optBframesPopUp addItemWithTitle:@"Default (3)"];
     for (i=0; i<17;i++)
     {
         [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    toolTip =
+        @"Sane values are 1-6. B-Frames are smaller than other frames, so they let you pack in more quality at the same bitrate. Use more of them with animated material.";
+    [fX264optBframesPopUp setToolTip: toolTip];
+    [fX264optBframesLabel setToolTip: toolTip];
     
     /*Reference Frames fX264optRefPopUp*/
     [fX264optRefPopUp removeAllItems];
-    [fX264optRefPopUp addItemWithTitle:@"Default (1)"];
+    [fX264optRefPopUp addItemWithTitle:@"Default (3)"];
     for (i=0; i<17;i++)
     {
         [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    toolTip =
+        @"Sane values are 1-6. The more you add, the higher the quality â€” but the slower the encode. Be careful...too many and QuickTime struggle to play the video back.";
+    [fX264optRefPopUp setToolTip: toolTip];
+    [fX264optRefLabel setToolTip: toolTip];
     
     /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/
     [fX264optNfpskipSwitch setState:0];
+    toolTip =
+        @"This can help with blocking on solid colors like blue skies, but it also slows down the encode.";
+    [fX264optNfpskipSwitch setToolTip: toolTip];
+    [fX264optNfpskipLabel setToolTip: toolTip];
     
     /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/
     [fX264optNodctdcmtSwitch setState:0];    
+    toolTip =
+        @"To save space, x264 will \"zero out\" blocks when it thinks they won't be perceptible by the viewer. This negligibly reduces quality, but in rare cases it can mess up and produce visible artifacts. This situation can be alleviated by telling x264 not to decimate DCT blocks.\n\nIt increases quality but also bitrate/file size, so if you use it when you've specified a target bitrate you will end up with a worse picture than without it. However, when used with constant quality encoding, or if you boost the average bitrate to compensate, you might get a better result.";
+    [fX264optNodctdcmtSwitch setToolTip: toolTip];
+    [fX264optNodctdcmtLabel setToolTip: toolTip];
     
     /*Sub Me fX264optSubmePopUp*/
     [fX264optSubmePopUp removeAllItems];
-    [fX264optSubmePopUp addItemWithTitle:@"Default (6)"];
+    [fX264optSubmePopUp addItemWithTitle:@"Default (7)"];
     for (i=0; i<10;i++)
     {
         [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    toolTip =
+        @"This setting is finer-grained than the motion estimation settings above. Instead of dealing with whole pixels, it deals with 4 fractional pixels, or quarter pixels (qpel). Higher levels increase quality by further refining the motion prediction for these quarter pixels, but take longer to encode.\n\nLevel 6, turns on a feature called rate distortion optimization, including psychovisual enhancements. 7, the default, enables that rate distortion for B-frames. 8 refines those decisions for I and P frames, and 9 adds on refinement for B-frames as well.";
+    [fX264optSubmePopUp setToolTip: toolTip];
+    [fX264optSubmeLabel setToolTip: toolTip];
     
     /*Trellis fX264optTrellisPopUp*/
     [fX264optTrellisPopUp removeAllItems];
-    [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"];
+    [fX264optTrellisPopUp addItemWithTitle:@"Default (1)"];
     for (i=0; i<3;i++)
     {
         [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
     [fX264optTrellisPopUp setWantsLayer:YES];
+    toolTip =
+        @"Trellis fine-tunes how bitrate is doled out, so it can reduce file size/bitrate or increase quality. A value of 1 means it only fine-tunes the final encode of a block of pixels, while 2 means it is considered during earlier phases of the decision-making process as well.";
+    [fX264optTrellisPopUp setToolTip: toolTip];
+    [fX264optTrellisLabel setToolTip: toolTip];
     
     /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/
-    [fX264optMixedRefsSwitch setState:0];
+    [fX264optMixedRefsSwitch setState:1];
     [fX264optMixedRefsSwitch setWantsLayer:YES];
+    toolTip =
+        @"With this on, different references can be used for different parts of each 16x16 pixel macroblock, increasing quality.";
+    [fX264optMixedRefsSwitch setToolTip: toolTip];
+    [fX264optMixedRefsLabel setToolTip: toolTip];
     
     /*Motion Estimation fX264optMotionEstPopUp*/
     [fX264optMotionEstPopUp removeAllItems];
     [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"];
     [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"];
     [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"];
+    [fX264optMotionEstPopUp addItemWithTitle:@"Transformed Exhaustive"];
+    toolTip =
+        @"Controls the motion estimation method. Motion estimation is how the encoder decides how each block of pixels in a frame has moved, compared to most similar blocks in the other frames it references. There are many ways of finding the most similar blocks, with varying speeds and accuracy.\n\nAt the most basic setting, dia, x264 will only consider a diamond-shaped region around each pixel.\n\nThe default setting, hex, is similar to dia but uses a hexagon shape.\n\nUneven multi-hexagon, umh, searches a number of different patterns across a wider area and thus is slower than hex and dia but further increases compression efficiency and quality.\n\nesa, an exhaustive search of a square around each pixel (whose size is controlled by the me-range parameter), is much slower and offers only minimal quality gains.\n\ntesa, transformed exhaustive search, which performs just as thorough a search, is slower still but offers further slight improvements to quality.";
+    [fX264optMotionEstPopUp setToolTip: toolTip];
+    [fX264optMotionEstLabel setToolTip: toolTip];
     
     /*Motion Estimation range fX264optMERangePopUp*/
     [fX264optMERangePopUp removeAllItems];
     {
         [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    toolTip =
+        @"This range is the radius, in pixels, x264 should use for motion estimation searches. It only has an effect when you use Uneven Multi-Hexagonal, Exhaustive, or Transformed Exhaustive searching. 24, 32, and 64 are good values, with each being progressively smaller for progressively less improvement to picture quality.";
+    [fX264optMERangePopUp setToolTip: toolTip];
+    [fX264optMERangeLabel setToolTip: toolTip];
     
     /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/
-    [fX264optWeightBSwitch setState:0];
+    [fX264optWeightBSwitch setState:1];
     [fX264optWeightBSwitch setWantsLayer:YES];
+    toolTip =
+        @"Sometimes x264 will base a B-frame's motion compensation on frames both before and after. With weighted B-frames, the amount of influence each frame has is related to its distance from the frame being encoded, instead of both having equal influence. The AppleTV can have issues with this.";
+    [fX264optWeightBSwitch setToolTip: toolTip];
+    [fX264optWeightBLabel setToolTip: toolTip];
     
     /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/
     [fX264optBPyramidSwitch setState:0];
     [fX264optBPyramidSwitch setWantsLayer:YES];
+    toolTip =
+        @"B-frame pyramids are a High Profile feature. Pyramidal B-frames mean that B-frames don't just reference surrounding reference frames â€” instead, it also treats a previous B-frame as a reference, improving quality/lowering bitrate at the expense of complexity. Logically, to reference an earlier B-frame, you must tell x264 to use at least 2 B-frames.";
+    [fX264optBPyramidSwitch setToolTip: toolTip];
+    [fX264optBPyramidLabel setToolTip: toolTip];
     
     /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/
     [fX264optDirectPredPopUp removeAllItems];
     [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];
     [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];
     [fX264optDirectPredPopUp setWantsLayer:YES];
+    toolTip =
+        @"Direct prediction tells x264 what method to use when guessing motion for certain parts of a B-frame. It can either look at other parts of the current frame (spatial) or compare against the following P-frameframe (temporal). You're best off setting this to automatic, so x264 decides which method is best on its own. Don't select none assuming it will be faster; instead it will take longer and look worse. If you're going to choose between spatial and temporal, spatial is usually better.";
+    [fX264optDirectPredPopUp setToolTip: toolTip];
+    [fX264optDirectPredLabel setToolTip: toolTip];
+    
+    /* Adaptive B-Frames Mode fX264optBAdaptPopUp */
+    [fX264optBAdaptPopUp removeAllItems];
+    [fX264optBAdaptPopUp addItemWithTitle:@"Default (Fast)"];
+    [fX264optBAdaptPopUp addItemWithTitle:@"Off"];
+    [fX264optBAdaptPopUp addItemWithTitle:@"Fast"];
+    [fX264optBAdaptPopUp addItemWithTitle:@"Optimal"];
+    [fX264optBAdaptPopUp setWantsLayer:YES];
+    toolTip =
+        @"When adaptive B-Frames are disabled, the number of B-Frames you specify is the constant length of every B-Frame sequence. When one of the adaptive modes is enabled, the number of B-Frames is treated as a maximum, with the length of each sequence varying, but never exceeding the max.\n\nFast mode takes the same amount of time no matter how many B-frames you specify. However, it doesn't always make the best decisions on how many B-Frames to use in a sequence.\n\nOptimal mode gets slower as the maximum number of B-Frames increases, but does a much better job at deciding sequence length, which can mean smaller file sizes and better quality.";
+    [fX264optBAdaptPopUp setToolTip: toolTip];
+    [fX264optBAdaptLabel setToolTip: toolTip];
     
     /*Alpha Deblock*/
     [fX264optAlphaDeblockPopUp removeAllItems];
     {
         [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    toolTip =
+        @"x264 includes an in-loop deblocking filter. What this means is that blocky compression artifacts are smoothed away when you play back the video. It has two settings: strength and threshold, just like a simple filter in Photoshop.\n\nStrength controls the amount of deblocking applied to the whole frame. If you drop down below 0, you reduce the amount of blurring. Go too negative, and you'll get an effect somewhat like oversharpening an image. Go into positive values, and the image may become too soft.\n\nThreshold controls how sensitive the filter is to whether something in a block is detail that needs to be preserved: lower numbers blur details less.\n\nThe default deblocking values are 0 and 0. This does not mean zero deblocking. It means x264 will apply the regular deblocking strength and thresholds the codec authors have selected as working the best in most cases.\n\nWhile many, many people stick with the default deblocking values of 0,0, and you should never change the deblocking without disabling adaptive quantization, other people disagree. Some prefer a slightly less blurred image for live action material, and use values like -2,-1 or -2,-2. Others will raise it to 1,1 or even 3,3 for animation. While the values for each setting extend from -6 to 6, the consensus is that going below -3 or above 3 is worthless.";
+    [fX264optAlphaDeblockPopUp setToolTip: toolTip];
+    [fX264optDeblockLabel setToolTip: toolTip];
 
     /*Beta Deblock*/
     [fX264optBetaDeblockPopUp removeAllItems];
     {
         [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
     }
+    [fX264optBetaDeblockPopUp setToolTip: toolTip];
+    [fX264optDeblockLabel setToolTip: toolTip];
 
     /* Analysis fX264optAnalysePopUp */
     [fX264optAnalysePopUp removeAllItems];
     [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */
     [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */
     [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */
+    toolTip =
+        @"Analysis controls how finely x264 divides up a frame to capture detail. Full macroblocks are 16x16 pixels, but x264 can go down all the way to 4x4 blocks if it judges it necessary. By default it only breaks up key frames that much. To give x264 the freedom to make the best decisions for all frames, use \"all\" analysis. If you want to create a high profile H.264 video (which is less compatible with the world at large than main profile), also check the \"8x8 DCT blocks\" box to add yet another block size for analysis.";
+    [fX264optAnalysePopUp setToolTip: toolTip];
+    [fX264optAnalyseLabel setToolTip: toolTip];
 
     /* 8x8 DCT fX264op8x8dctSwitch */
-    [fX264opt8x8dctSwitch setState:0];
+    [fX264opt8x8dctSwitch setState:1];
     [fX264opt8x8dctSwitch setWantsLayer:YES];
+    toolTip =
+        @"Checking this box lets x264 break key frames down into 8x8 blocks of pixels for analysis. This is a high profile feature of H.264, which makes it less compatible. It should slightly decrease bitrate or improve quality. Turn it on whenever possible.";
+    [fX264opt8x8dctSwitch setToolTip: toolTip];
+    [fX264opt8x8dctLabel setToolTip: toolTip];
 
     /* CABAC fX264opCabacSwitch */
     [fX264optCabacSwitch setState:1];
+    toolTip =
+        @"CABAC, or context adaptive binary arithmetic coding, is used by x264 to reduce the bitrate needed for a given quality by 15\%. This makes it very cool and very useful, and it should be left on whenever possible. However, it is incompatible with the iPod, and makes the AppleTV struggle. So turn it off for those.\n\nCABAC is a kind of entropy coding, which means that it compresses data by making shorthand symbols to represent long streams of data. The \"entropy\" part means that the symbols it uses the most often are the smallest. When you disable CABAC, another entropy coding scheme gets enabled, called CAVLC (context adaptive variable-length coding). CAVLC is a lot less efficient, which is why it needs 15\% more bitrate to achieve the same quality as CABAC.";
+    [fX264optCabacSwitch setToolTip: toolTip];
+    [fX264optCabacLabel setToolTip: toolTip];
+    
+    /* PsyRDO fX264optPsyRDSlider */
+    [fX264optPsyRDSlider setMinValue:0.0];
+    [fX264optPsyRDSlider setMaxValue:1.0];
+    [fX264optPsyRDSlider setTickMarkPosition:NSTickMarkBelow];
+    [fX264optPsyRDSlider setNumberOfTickMarks:11];
+    [fX264optPsyRDSlider setAllowsTickMarkValuesOnly:YES];
+    [fX264optPsyRDSlider setFloatValue:1.0];
+    toolTip =
+        @"Psychovisual Rate Distortion Optimization sure is a mouthful, isn't it? Basically, it means x264 tries to retain detail, for better quality to the human eye, as opposed to trying to maximize quality the way a computer understands it, through signal-to-noise ratios that have trouble telling apart fine detail and noise.";
+    [fX264optPsyRDSlider setToolTip: toolTip];
+    [fX264optPsyRDLabel setToolTip: toolTip];
+
+    /* PsyTrellis fX264optPsyRDSlider */
+    [fX264optPsyTrellisSlider setMinValue:0.0];
+    [fX264optPsyTrellisSlider setMaxValue:1.0];
+    [fX264optPsyTrellisSlider setTickMarkPosition:NSTickMarkBelow];
+    [fX264optPsyTrellisSlider setNumberOfTickMarks:11];
+    [fX264optPsyTrellisSlider setAllowsTickMarkValuesOnly:YES];
+    [fX264optPsyTrellisSlider setFloatValue:0.0];
+    toolTip =
+        @"Psychovisual Trellis tries to retain more sharpness and detail, but can cause artifacting. It is considered experimental, which is why it's off by default. Good values are 0.1 to 0.2.";
+    [fX264optPsyTrellisSlider setToolTip: toolTip];
+    [fX264optPsyTrellisLabel setToolTip: toolTip];
 
     /* Standardize the option string */
     [self X264AdvancedOptionsStandardizeOptString:nil];
 
     /* Set Current GUI Settings based on newly standardized string */
-    [self X264AdvancedOptionsSetCurrentSettings:nil];
+    [self X264AdvancedOptionsSetCurrentSettings:sender];
 
     /* Fade out options that don't apply */
     [self X264AdvancedOptionsAnimate: sender];
     }
     
     /* Change the option string to reflect the new standardized option string */
-    [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
+    [fDisplayX264Options setStringValue:changedOptString];
 }
 
 /**
        - CABAC (when 0 turn off trellis)
        - analysis (if none, turn off 8x8dct)
        - refs (under 2, disable mixed-refs)
+       - subme (if under 6, turn off psy-rd and psy-trel)
+       - trellis (if 0, turn off psy-trel)
     */
     
-    if ( [fX264optBframesPopUp indexOfSelectedItem ] < 2)
+    if( sender == fX264optBframesPopUp || sender == nil || sender == fDisplayX264Options )
     {
-        /* If the b-frame widget is at 0 or 1, the user has chosen
-           not to use b-frames at all. So disable the options
-           that can only be used when b-frames are enabled.        */
-        [[fX264optWeightBSwitch animator] setHidden:YES];
-        [[fX264optWeightBLabel animator] setHidden:YES];
-        if ( [fX264optWeightBSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
-            [fX264optWeightBSwitch performClick:self];
-        
-        [[fX264optBPyramidSwitch animator] setHidden:YES];
-        [[fX264optBPyramidLabel animator] setHidden:YES];
-        if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
-            [fX264optBPyramidSwitch performClick:self];
-
-        [[fX264optDirectPredPopUp animator] setHidden:YES];
-        [[fX264optDirectPredLabel animator] setHidden:YES];
-        if ( [fX264optDirectPredPopUp indexOfSelectedItem] > 0 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
+        if ( [fX264optBframesPopUp indexOfSelectedItem ] > 0 &&
+             [fX264optBframesPopUp indexOfSelectedItem ] < 2)
         {
-            [fX264optDirectPredPopUp selectItemAtIndex: 0];
-            [[fX264optDirectPredPopUp cell] performClick:self];
+            /* If the b-frame widget is at 0 or 1, the user has chosen
+               not to use b-frames at all. So disable the options
+               that can only be used when b-frames are enabled.        */
             
-        }
-    }
-    else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2)
-    {
-        /* Only 1 b-frame? Disable b-pyramid. */
-        [[fX264optBPyramidSwitch animator] setHidden:YES];
-        [[fX264optBPyramidLabel animator] setHidden:YES];
-        if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optBPyramidSwitch)
-            [fX264optBPyramidSwitch performClick:self];
+            if( [fX264optWeightBSwitch isHidden] == false)
+            {
+                [[fX264optWeightBSwitch animator] setHidden:YES];
+                [[fX264optWeightBLabel animator] setHidden:YES];
+                if ( [fX264optWeightBSwitch state] == 1 )
+                    [fX264optWeightBSwitch performClick:self];
+            }
 
-        [[fX264optWeightBSwitch animator] setHidden:NO];
-        [[fX264optWeightBLabel animator] setHidden:NO];
+            if( [fX264optBPyramidSwitch isHidden] == false )
+            {
+                [[fX264optBPyramidSwitch animator] setHidden:YES];
+                [[fX264optBPyramidLabel animator] setHidden:YES];
+                if ( [fX264optBPyramidSwitch state] == 1 )
+                    [fX264optBPyramidSwitch performClick:self];
+            }
 
-        [[fX264optDirectPredPopUp animator] setHidden:NO];
-        [[fX264optDirectPredLabel animator] setHidden:NO];
-    }
-    else
-    {
-        [[fX264optWeightBSwitch animator] setHidden:NO];
-        [[fX264optWeightBLabel animator] setHidden:NO];
+            if( [fX264optDirectPredPopUp isHidden] == false )
+            {
+                [[fX264optDirectPredPopUp animator] setHidden:YES];
+                [[fX264optDirectPredLabel animator] setHidden:YES];
+                if ( [fX264optDirectPredPopUp indexOfSelectedItem] > 0 )
+                {
+                    [fX264optDirectPredPopUp selectItemAtIndex: 0];
+                    [[fX264optDirectPredPopUp cell] performClick:self];
+                }
+            }
 
-        [[fX264optBPyramidSwitch animator] setHidden:NO];
-        [[fX264optBPyramidLabel animator] setHidden:NO];
+            if( [fX264optBAdaptPopUp isHidden] == false )
+            {
+                [[fX264optBAdaptPopUp animator] setHidden:YES];
+                [[fX264optBAdaptLabel animator] setHidden:YES];
+                if ( [fX264optBAdaptPopUp indexOfSelectedItem] > 0 )
+                {
+                    [fX264optBAdaptPopUp selectItemAtIndex: 0];
+                    [[fX264optBAdaptPopUp cell] performClick:self];
+                }
+            }
+        }
+        else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2)
+        {
+            /* Only 1 b-frame? Disable b-pyramid. */
+            if( [fX264optBPyramidSwitch isHidden] == false )
+            {
+                [[fX264optBPyramidSwitch animator] setHidden:YES];
+                [[fX264optBPyramidLabel animator] setHidden:YES];
+                if ( [fX264optBPyramidSwitch state] == 1 )
+                    [fX264optBPyramidSwitch performClick:self];
+            }
+
+            if( [fX264optWeightBSwitch isHidden] == true )
+            {
+                [[fX264optWeightBSwitch animator] setHidden:NO];
+                [[fX264optWeightBLabel animator] setHidden:NO];
+            }
+            
+            if( [fX264optDirectPredPopUp isHidden] == true )
+            {
+                [[fX264optDirectPredPopUp animator] setHidden:NO];
+                [[fX264optDirectPredLabel animator] setHidden:NO];
+            }
+            
+            if( [fX264optBAdaptPopUp isHidden] == true )
+            {
+                [[fX264optBAdaptPopUp animator] setHidden:NO];
+                [[fX264optBAdaptLabel animator] setHidden:NO];
+            }
+        }
+        else
+        {
+            if( [fX264optBPyramidSwitch isHidden] == true )
+            {
+                [[fX264optBPyramidSwitch animator] setHidden:NO];
+                [[fX264optBPyramidLabel animator] setHidden:NO];
+            }
 
-        [[fX264optDirectPredPopUp animator] setHidden:NO];
-        [[fX264optDirectPredLabel animator] setHidden:NO];
+            if( [fX264optWeightBSwitch isHidden] == true )
+            {
+                [[fX264optWeightBSwitch animator] setHidden:NO];
+                [[fX264optWeightBLabel animator] setHidden:NO];
+            }
+            
+            if( [fX264optDirectPredPopUp isHidden] == true )
+            {
+                [[fX264optDirectPredPopUp animator] setHidden:NO];
+                [[fX264optDirectPredLabel animator] setHidden:NO];
+            }
+            
+            if( [fX264optBAdaptPopUp isHidden] == true )
+            {
+                [[fX264optBAdaptPopUp animator] setHidden:NO];
+                [[fX264optBAdaptLabel animator] setHidden:NO];
+            }
+        }
     }
     
-    if ( [fX264optCabacSwitch state] == false)
+    if( sender == fX264optCabacSwitch || sender == nil || sender == fDisplayX264Options )
     {
-        /* Without CABAC entropy coding, trellis doesn't run. */
-        
-        [[fX264optTrellisPopUp animator] setHidden:YES];
-        [[fX264optTrellisLabel animator] setHidden:YES];
-        [fX264optTrellisPopUp selectItemAtIndex:0];
-        if (sender != fX264optTrellisPopUp)
-            [[fX264optTrellisPopUp cell] performClick:self];
+        if ( [fX264optCabacSwitch state] == false)
+        {
+            if( [fX264optTrellisPopUp isHidden] == false )
+            {
+                /* Without CABAC entropy coding, trellis doesn't run. */
+                [[fX264optTrellisPopUp animator] setHidden:YES];
+                [[fX264optTrellisLabel animator] setHidden:YES];
+                [fX264optTrellisPopUp selectItemAtIndex:0];
+                [[fX264optTrellisPopUp cell] performClick:self];
+            }
+        }
+        else if( [fX264optTrellisPopUp isHidden] == true)
+        {
+            [[fX264optTrellisPopUp animator] setHidden:NO];
+            [[fX264optTrellisLabel animator] setHidden:NO];
+        }
     }
-    else
+    
+    if( sender == fX264optAnalysePopUp || sender == nil || sender == fDisplayX264Options )
     {
-        [[fX264optTrellisPopUp animator] setHidden:NO];
-        [[fX264optTrellisLabel animator] setHidden:NO];
+        if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1)
+        {
+            /* No analysis? Disable 8x8dct */
+            if( [fX264opt8x8dctSwitch isHidden] == false )
+            {
+                [[fX264opt8x8dctSwitch animator] setHidden:YES];
+                [[fX264opt8x8dctLabel animator] setHidden:YES];
+                if ( [fX264opt8x8dctSwitch state] == 1 )
+                    [fX264opt8x8dctSwitch performClick:self];
+            }
+        }
+        else
+        {
+            if( [fX264opt8x8dctSwitch isHidden] == true )
+            {
+                [[fX264opt8x8dctSwitch animator] setHidden:NO];
+                [[fX264opt8x8dctLabel animator] setHidden:NO];
+            }
+        }
     }
     
-    if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1)
+    if( sender == fX264optRefPopUp || sender == nil || sender == fDisplayX264Options )
     {
-        /* No analysis? Disable 8x8dct */
-        [[fX264opt8x8dctSwitch animator] setHidden:YES];
-        [[fX264opt8x8dctLabel animator] setHidden:YES];
-        if ( [fX264opt8x8dctSwitch state] == 1 && sender != fX264opt8x8dctSwitch )
-            [fX264opt8x8dctSwitch performClick:self];
+        if ( [fX264optRefPopUp indexOfSelectedItem] > 0 &&
+             [fX264optRefPopUp indexOfSelectedItem] < 3 )
+        {
+            if( [fX264optMixedRefsSwitch isHidden] == false )
+            {
+                /* Only do mixed-refs when there are at least 2 refs to mix. */
+                [[fX264optMixedRefsSwitch animator] setHidden:YES];
+                [[fX264optMixedRefsLabel animator] setHidden:YES];
+                if( [fX264optMixedRefsSwitch state] == 1 )
+                    [fX264optMixedRefsSwitch performClick:self];
+            }
+        }
+        else
+        {
+            if( [fX264optMixedRefsSwitch isHidden] == true )
+            {
+                [[fX264optMixedRefsSwitch animator] setHidden:NO];
+                [[fX264optMixedRefsLabel animator] setHidden:NO];
+            }
+        }
     }
-    else
+    
+    if( sender == fX264optMotionEstPopUp || sender == nil || sender == fDisplayX264Options )
     {
-        [[fX264opt8x8dctSwitch animator] setHidden:NO];
-        [[fX264opt8x8dctLabel animator] setHidden:NO];
+        if ( [fX264optMotionEstPopUp indexOfSelectedItem] < 3 )
+        {
+            /* ME-range can only be above 16 if me >= umh
+              and changing it to < 16 is idiotic so hide it . */
+            if( [fX264optMERangePopUp isHidden] == false )
+            {
+                [[fX264optMERangePopUp animator] setHidden:YES];
+                [[fX264optMERangeLabel animator] setHidden:YES];
+                if ( [fX264optMERangePopUp indexOfSelectedItem] > 0 )
+                {
+                    [fX264optMERangePopUp selectItemAtIndex:0];
+                    [[fX264optMERangePopUp cell] performClick:self];
+                }
+            }
+        }
+        else
+        {
+            if( [fX264optMERangePopUp isHidden] == true )
+            {
+                [[fX264optMERangePopUp animator] setHidden:NO];
+                [[fX264optMERangeLabel animator] setHidden:NO];
+            }
+        }
     }
     
-    if ( [fX264optRefPopUp indexOfSelectedItem] < 3)
+    if( sender == fX264optSubmePopUp || sender == nil || sender == fDisplayX264Options )
     {
-        /* Only do mixed-refs when there are at least 2 refs to mix. */
-        [[fX264optMixedRefsSwitch animator] setHidden:YES];
-        [[fX264optMixedRefsLabel animator] setHidden:YES];
-        if ( [fX264optMixedRefsSwitch state] == 1 && sender != fX264optMixedRefsSwitch )
-            [fX264optMixedRefsSwitch performClick:self];
+        if( [fX264optSubmePopUp indexOfSelectedItem] != 0 && [fX264optSubmePopUp indexOfSelectedItem] < 7 )
+        {
+            /* No Psy-RDO or Psy=trel if subme < 6. */
+            if( [fX264optPsyRDSlider isHidden] == false )
+            {
+                [[fX264optPsyRDSlider animator] setHidden:YES];
+                [[fX264optPsyRDLabel animator] setHidden:YES];
+                [[fX264optPsyRDSlider animator] setFloatValue:1];
+                if ( [fX264optPsyRDSlider floatValue] < 1.0 )
+                {
+                    [fX264optPsyRDSlider setFloatValue:1.0];
+                    [[fX264optPsyRDSlider cell] performClick:self];            
+                }
+            }
+
+            if( [fX264optPsyTrellisSlider isHidden] == false)
+            {
+                [[fX264optPsyTrellisSlider animator] setHidden:YES];
+                [[fX264optPsyTrellisLabel animator] setHidden:YES];
+                [[fX264optPsyTrellisSlider animator] setFloatValue:0];
+                if ( [fX264optPsyTrellisSlider floatValue] > 0.0 )
+                {
+                    [fX264optPsyTrellisSlider setFloatValue:0.0];
+                    [[fX264optPsyTrellisSlider cell] performClick:self];
+                }
+            }
+        }
+        else
+        {
+            if( [fX264optPsyRDSlider isHidden] == true )
+            {
+                [[fX264optPsyRDSlider animator] setHidden:NO];
+                [[fX264optPsyRDLabel animator] setHidden:NO];
+            }
+
+            if( ( [fX264optTrellisPopUp indexOfSelectedItem] == 0 || [fX264optTrellisPopUp indexOfSelectedItem] >= 2 ) && [fX264optCabacSwitch state] == true && [fX264optPsyTrellisSlider isHidden] == true )
+            {
+                [[fX264optPsyTrellisSlider animator] setHidden:NO];
+                [[fX264optPsyTrellisLabel animator] setHidden:NO];
+            }
+        }
     }
-    else
+    
+    if( sender == fX264optTrellisPopUp || sender == nil || sender == fDisplayX264Options )
     {
-        [[fX264optMixedRefsSwitch animator] setHidden:NO];
-        [[fX264optMixedRefsLabel animator] setHidden:NO];
+        if( [fX264optTrellisPopUp indexOfSelectedItem] > 0 && [fX264optTrellisPopUp indexOfSelectedItem] < 2 )
+        {
+            if( [fX264optPsyTrellisSlider isHidden] == false )
+            {
+                /* No Psy-trellis without trellis. */
+                [[fX264optPsyTrellisSlider animator] setHidden:YES];
+                [[fX264optPsyTrellisLabel animator] setHidden:YES];
+                [[fX264optPsyTrellisSlider animator] setFloatValue:0.0];
+                [[fX264optPsyTrellisSlider cell] performClick:self];
+            }
+        }
+        else
+        {
+            if( ( [fX264optSubmePopUp indexOfSelectedItem] == 0 || [fX264optSubmePopUp indexOfSelectedItem] >= 7 ) && [fX264optCabacSwitch state] == true  && [fX264optPsyTrellisSlider isHidden] == true )
+            {
+                [[fX264optPsyTrellisSlider animator] setHidden:NO];
+                [[fX264optPsyTrellisLabel animator] setHidden:NO];
+            }
+        }
     }
 }
 
                     else if ([optValue isEqualToString:@"umh"])
                         [fX264optMotionEstPopUp selectItemAtIndex:3];
                     else if ([optValue isEqualToString:@"esa"])
-                        [fX264optMotionEstPopUp selectItemAtIndex:4];                        
+                        [fX264optMotionEstPopUp selectItemAtIndex:4];
+                    else if ([optValue isEqualToString:@"tesa"])
+                        [fX264optMotionEstPopUp selectItemAtIndex:5];
                 }
                 /*ME Range NSPopUpButton*/
                 if ([optName isEqualToString:@"merange"])
                 {
                     [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3];
                 }
+                /* Adaptive B-Frames NSPopUpButton*/
+                if ([optName isEqualToString:@"b-adapt"])
+                {
+                    [fX264optBAdaptPopUp selectItemAtIndex:[optValue intValue]+1];
+                }
                 /*Weighted B-Frames NSButton*/
                 if ([optName isEqualToString:@"weightb"])
                 {
                 if ([optName isEqualToString:@"cabac"])
                 {
                     [fX264optCabacSwitch setState:[optValue intValue]];
-                }                                                                 
+                }
+                /* Psy-RD and Psy-Trellis NSSliders */
+                if ([optName isEqualToString:@"psy-rd"])
+                {
+                    NSString * rdOpt = @"";
+                    NSString * trellisOpt = @"";
+                    
+                    NSRange splitRD = [optValue rangeOfString:@","];
+                    rdOpt = [optValue substringToIndex:splitRD.location];
+                    trellisOpt = [optValue substringFromIndex:splitRD.location + 1];
+                    
+                    [fX264optPsyRDSlider setFloatValue:[rdOpt floatValue]];
+                    [fX264optPsyTrellisSlider setFloatValue:[trellisOpt floatValue]];
+                }                                                              
             }
         }
     }
 }
 
-/**
- * Resets the option string to mirror the GUI widgets.
- */
-- (IBAction) X264AdvancedOptionsChanged: (id) sender
+- (NSString *) X264AdvancedOptionsOptIDToString: (id) widget
 {
     /*Determine which outlet is being used and set optName to process accordingly */
     NSString * optNameToChange = @""; // The option name such as "bframes"
     
-    if (sender == fX264optBframesPopUp)
+    if (widget == fX264optBframesPopUp)
     {
         optNameToChange = @"bframes";
     }
-    if (sender == fX264optRefPopUp)
+    if (widget == fX264optRefPopUp)
     {
         optNameToChange = @"ref";
     }
-    if (sender == fX264optNfpskipSwitch)
+    if (widget == fX264optNfpskipSwitch)
     {
         optNameToChange = @"no-fast-pskip";
     }
-    if (sender == fX264optNodctdcmtSwitch)
+    if (widget == fX264optNodctdcmtSwitch)
     {
         optNameToChange = @"no-dct-decimate";
     }
-    if (sender == fX264optSubmePopUp)
+    if (widget == fX264optSubmePopUp)
     {
         optNameToChange = @"subq";
     }
-    if (sender == fX264optTrellisPopUp)
+    if (widget == fX264optTrellisPopUp)
     {
         optNameToChange = @"trellis";
     }
-    if (sender == fX264optMixedRefsSwitch)
+    if (widget == fX264optMixedRefsSwitch)
     {
         optNameToChange = @"mixed-refs";
     }
-    if (sender == fX264optMotionEstPopUp)
+    if (widget == fX264optMotionEstPopUp)
     {
         optNameToChange = @"me";
     }
-    if (sender == fX264optMERangePopUp)
+    if (widget == fX264optMERangePopUp)
     {
         optNameToChange = @"merange";
     }
-    if (sender == fX264optWeightBSwitch)
+    if (widget == fX264optBAdaptPopUp)
+    {
+        optNameToChange = @"b-adapt";
+    }
+    if (widget == fX264optWeightBSwitch)
     {
         optNameToChange = @"weightb";
     }
-    if (sender == fX264optBPyramidSwitch)
+    if (widget == fX264optBPyramidSwitch)
     {
         optNameToChange = @"b-pyramid";
     }
-    if (sender == fX264optDirectPredPopUp)
+    if (widget == fX264optDirectPredPopUp)
     {
         optNameToChange = @"direct";
     }
-    if (sender == fX264optAlphaDeblockPopUp)
+    if (widget == fX264optAlphaDeblockPopUp)
     {
         optNameToChange = @"deblock";
     }
-    if (sender == fX264optBetaDeblockPopUp)
+    if (widget == fX264optBetaDeblockPopUp)
     {
         optNameToChange = @"deblock";
     }        
-    if (sender == fX264optAnalysePopUp)
+    if (widget == fX264optAnalysePopUp)
     {
         optNameToChange = @"analyse";
     }
-    if (sender == fX264opt8x8dctSwitch)
+    if (widget == fX264opt8x8dctSwitch)
     {
         optNameToChange = @"8x8dct";
     }
-    if (sender == fX264optCabacSwitch)
+    if (widget == fX264optCabacSwitch)
     {
         optNameToChange = @"cabac";
     }
+    if( widget == fX264optPsyRDSlider)
+    {
+        optNameToChange = @"psy-rd";
+    }
+    if( widget == fX264optPsyTrellisSlider)
+    {
+        optNameToChange = @"psy-rd";
+    }
     
-    /* Set widgets depending on the opt string in field */
-    NSString * thisOpt; // The separated option such as "bframes=3"
-    NSString * optName = @""; // The option name such as "bframes"
-    NSString * optValue = @"";// The option value such as "3"
-    NSArray *currentOptsArray;
+    return optNameToChange;
+}
+
+- (NSString *) X264AdvancedOptionsWidgetToString: (NSString *) optName withID: (id) sender
+{
+    NSString * thisOpt = @""; // The option=value string the method will return
     
-    /*First, we get an opt string to process */
-    NSString *currentOptString = [fDisplayX264Options stringValue];
+    if ([optName isEqualToString:@"deblock"])
+    {
+        if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
+        {
+            /* When both deblock widgets are 0 or default or a mix of the two,
+               use a blank string, since deblocking defaults to 0,0.           */
+            thisOpt = @"";                                
+        }
+        else
+        {
+            /* Otherwise the format is deblock=a,b, where a and b both have an array
+               offset of 7 because deblocking values start at -6 instead of at zero. */
+            thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
+        }
+    }
     
-    /* There are going to be a few possibilities.
-       - The option might start off the string.
-       - The option might be in the middle of the string.
-       - The option might not be in the string at all yet.
-       - The string itself might not yet exist.
-       
-       Because each of these possibilities means constructing a different kind of string,
-       they're all handled separately in a sea of messy, somewhat redundant code. =(     */
-       
-    /* If the option is in the string but not the beginning of it, it will be in the form of ":optName=value"
-       so we really want to be looking for ":optNameToChange=" rather than "optNameToChange".                 */
+    else if ([optName isEqualToString:@"psy-rd"])
+    {
+        if( [fX264optPsyRDSlider floatValue] == 1.0 && [fX264optPsyTrellisSlider floatValue] == 0.0 ) 
+        {
+            /* When  PsyRD is 1 and PsyTrel is 0 they're default values and can be ignored. */
+            thisOpt = @"";                                
+        }
+        else
+        {
+            /* Otherwise the format is deblock=a,b, where a and b both have an array
+               offset of 7 because deblocking values start at -6 instead of at zero. */
+            thisOpt = [NSString stringWithFormat:@"%@=%0.1f,%0.1f", optName, [fX264optPsyRDSlider floatValue], [fX264optPsyTrellisSlider floatValue] ];
+        }
+    }
+    
+    else if /*Boolean Switches*/ ( [optName isEqualToString:@"b-pyramid"] || [optName isEqualToString:@"no-fast-pskip"] || [optName isEqualToString:@"no-dct-decimate"] )
+    {
+        /* Here is where we take care of the boolean options that work overtly:
+           no-dct-decimate being on means no-dct-decimate=1, etc. Some options
+           require the inverse, but those will be handled a couple lines down. */
+        if ([sender state] == 0)
+        {
+            /* When these options are false, don't include them. They all default
+               to being set off, so they don't need to be mentioned at all.       */
+            thisOpt = @"";
+        }
+        else
+        {
+            /* Otherwise, include them as optioname=1 */
+            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
+        }
+    }
+    
+    else if ( [optName isEqualToString:@"8x8dct"] || [optName isEqualToString:@"weightb"] || [optName isEqualToString:@"mixed-refs"] || [optName isEqualToString:@"cabac"] )
+    {
+        /* These options default to being on. That means they
+           only need to be included in the string when turned off. */
+        if ([sender state] == 1)
+        {
+            /* It's true so don't include it. */
+            thisOpt = @"";
+        }
+        else
+        {
+            /* Otherwise, include cabac=0, etc, in the string. */
+            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
+        }
+    }
+                                            
+    else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
+    {
+        /* When a widget is at index 0, it's default. Default means don't add to the string.
+           The exception for deblocking is because for those, *both* need to at index 0
+           for it to default, so it's handled separately, above this section.                */
+        thisOpt = @"";
+    }
+    
+    else if ([optName isEqualToString:@"me"])
+    {
+        /* Motion estimation uses string values, so this switch
+           pairs the widget index with the right value string.  */
+        switch ([sender indexOfSelectedItem])
+        {   
+            case 1:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
+                break;
+                
+            case 2:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
+                break;
+                
+            case 3:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
+                break;
+                
+            case 4:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
+                break;
+            
+            case 5:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"tesa"];
+            
+            default:
+                break;
+        }
+    }
+    
+    else if ([optName isEqualToString:@"direct"])
+    {
+        /* Direct prediction uses string values, so this switch
+           pairs the right string value with the right widget index. */
+        switch ([sender indexOfSelectedItem])
+        {   
+            case 1:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
+                break;
+                
+            case 2:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
+                break;
+                
+            case 3:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
+                break;
+                
+            case 4:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
+                break;
+                
+            default:
+                break;
+        }
+    }
+    
+    else if ([optName isEqualToString:@"analyse"])
+    {
+        /* Analysis uses string values as well. */
+        switch ([sender indexOfSelectedItem])
+        {   
+            case 1:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
+                break;
+                
+            case 2:
+                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
+                break;
+                
+            default:
+                break;
+        }
+    }
+    
+    else if ([optName isEqualToString:@"merange"])
+    {
+        /* Motion estimation range uses an odd array offset because in addition
+           to starting with index 0 as default, index 1 starts at 4 instead of 1,
+           because merange can't go below 4. So it has to be handled separately.  */
+        thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
+    }
+    
+    else if ([optName isEqualToString:@"b-adapt"])
+    {
+        /* B-adapt starts at index 0 with default then goes 0, 1, 2)*/
+        thisOpt = [NSString stringWithFormat:@"%@=%d", optName, [sender indexOfSelectedItem]-1];
+    }
+    
+    else // we have a valid value to change, so change it
+    {
+        if ( [sender indexOfSelectedItem] != 0 )
+        /* Here's our general case, that catches things like ref frames and b-frames.
+           Basically, any options that are PopUp menus with index 0 as default and
+           index 1 as 1, with numerical values, are all handled right here. All of
+           the above stuff is for the exceptions to the general case.              */
+            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
+    }
+    
+    return thisOpt;
+}
+
+- (BOOL) X264AdvancedOptionsIsOpt: (NSString *) optNameToChange inString: (NSString *) currentOptString
+{
+    /* If the option is in the string but not the beginning of it,
+       it will be in the form of ":optName=value" so we really want
+       to be looking for ":optNameToChange=" rather than "optNameToChange". */
     NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange];
     
     /* Now we store the part of the string up through the option name in currentOptRange. */
         If the range is 0, it's the first option listed in the string.       */        
     NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange];
     NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning];
-    
+
     if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0)
+        return true;
+    else
+        return false;
+} 
+
+/**
+ * Resets the option string to mirror the GUI widgets.
+ */
+- (IBAction) X264AdvancedOptionsChanged: (id) sender
+{
+    /* Look up the equivalent string option name of the calling widget. */
+    NSString * optNameToChange = [self X264AdvancedOptionsOptIDToString: sender];
+    
+    NSString * thisOpt = @"";  // The separated option such as "bframes=3"
+    NSString * optName = @"";  // The option name such as "bframes"
+    NSString * optValue = @""; // The option value such as "3"
+    NSArray *currentOptsArray;
+    
+    /* Get the current opt string being displayed. */
+    NSString *currentOptString = [fDisplayX264Options stringValue];
+    
+    /* There are going to be a few possibilities.
+       - The option might start off the string.
+       - The option might be in the middle of the string.
+       - The option might not be in the string at all yet.
+       - The string itself might not yet exist.             */
+    
+    if( [self X264AdvancedOptionsIsOpt: optNameToChange inString: currentOptString] )
     {
         /* If the option is in the string wth a semicolon, or starts the string, it's time to edit.
            This means parsing the whole string into an array of options and values. From there,
         /* Create new empty opt string*/
         NSString *changedOptString = @"";
         
-        /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+        /* Put individual options into an array based on the ":"
+           separator for processing, result is "<opt>=<value>"   */
         currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
         
-        /*iterate through the array and get <opts> and <values*/
+        /* Iterate through the array and get <opts> and <values*/
         int loopcounter;
         int currentOptsArrayCount = [currentOptsArray count];
         for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
                    
                 optName = [thisOpt substringToIndex:splitOptRange.location];
                 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
-                
-                /*Run through the available widgets for x264 opts and set them, as you add widgets, 
-                    they need to be added here. This should be moved to its own method probably*/
-                
+
                 /*If the optNameToChange is found, appropriately change the value or delete it if
                     "Unspecified" is set.*/
                 if ([optName isEqualToString:optNameToChange])
                 {
-                    if ([optNameToChange isEqualToString:@"deblock"])
-                    {
-                        if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
-                        {
-                            /* When both deblock widgets are 0 or default or a mix of the two,
-                               use a blank string, since deblocking defaults to 0,0.           */
-                            thisOpt = @"";                                
-                        }
-                        else
-                        {
-                            /* Otherwise the format is deblock=a,b, where a and b both have an array
-                               offset of 7 because deblocking values start at -6 instead of at zero. */
-                            thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
-                        }
-                    }
-                    else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] ||  [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
-                    {
-                        /* Here is where we take care of the boolean options that work overtly:
-                           no-dct-decimate being on means no-dct-decimate=1, etc. Some options
-                           require the inverse, but those will be handled a couple lines down. */
-                        if ([sender state] == 0)
-                        {
-                            /* When these options are false, don't include them. They all default
-                               to being set off, so they don't need to be mentioned at all.       */
-                            thisOpt = @"";
-                        }
-                        else
-                        {
-                            /* Otherwise, include them as optioname=1 */
-                            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
-                        }
-                    }
-                    else if ([optNameToChange isEqualToString:@"cabac"])
-                    {
-                        /* CABAC is odd, in that it defaults to being on. That means
-                           it only needs to be included in the string when turned off. */
-                        if ([sender state] == 1)
-                        {
-                            /* It's true so don't include it. */
-                            thisOpt = @"";
-                        }
-                        else
-                        {
-                            /* Otherwise, include cabac=0 in the string to enable CAVLC. */
-                            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
-                        }
-                    }                                        
-                    else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
-                    {
-                        /* When a widget is at index 0, it's default. Default means don't add to the string.
-                           The exception for deblocking is because for those, *both* need to at index 0
-                           for it to default, so it's handled separately, above this section.                */
-                        thisOpt = @"";
-                    }
-                    else if ([optNameToChange isEqualToString:@"me"])
-                    {
-                        /* Motion estimation uses string values, so this switch
-                           pairs the widget index with the right value string.  */
-                        switch ([sender indexOfSelectedItem])
-                        {   
-                            case 1:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
-                                break;
-                                
-                            case 2:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
-                                break;
-                                
-                            case 3:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
-                                break;
-                                
-                            case 4:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
-                                break;
-                                
-                            default:
-                                break;
-                        }
-                    }
-                    else if ([optNameToChange isEqualToString:@"direct"])
-                    {
-                        /* Direct prediction uses string values, so this switch
-                           pairs the right string value with the right widget index. */
-                        switch ([sender indexOfSelectedItem])
-                        {   
-                            case 1:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
-                                break;
-                                
-                            case 2:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
-                                break;
-                                
-                            case 3:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
-                                break;
-                                
-                            case 4:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
-                                break;
-                                
-                            default:
-                                break;
-                        }
-                    }
-                    else if ([optNameToChange isEqualToString:@"analyse"])
-                    {
-                        /* Analysis uses string values as well. */
-                        switch ([sender indexOfSelectedItem])
-                        {   
-                            case 1:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
-                                break;
-                                
-                            case 2:
-                                thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
-                                break;
-                                
-                            default:
-                                break;
-                        }
-                    }
-                    else if ([optNameToChange isEqualToString:@"merange"])
-                    {
-                        /* Motion estimation range uses an odd array offset because in addition
-                           to starting with index 0 as default, index 1 starts at 4 instead of 1,
-                           because merange can't go below 4. So it has to be handled separately.  */
-                        thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
-                    }
-                    else // we have a valid value to change, so change it
-                    {
-                        if ( [sender indexOfSelectedItem] != 0 )
-                        /* Here's our general case, that catches things like ref frames and b-frames.
-                           Basically, any options that are PopUp menus with index 0 as default and
-                           index 1 as 1, with numerical values, are all handled right here. All of
-                           the above stuff is for the exceptions to the general case.              */
-                            thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
-                    }
+                    thisOpt = [self X264AdvancedOptionsWidgetToString: optName withID: sender];
                 }
             }
             
         }
         
         /* Change the dislayed option string to reflect the new modified settings */
-        [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];    
+        [fDisplayX264Options setStringValue:changedOptString];    
     }
     else // if none exists, add it to the string
     {
         /* This is where options that aren't already in the string are handled. */
         if ([[fDisplayX264Options stringValue] isEqualToString: @""])
         {
-            /* The option might not be in the string because the
-               string is empty. Handle this possibility first.   */
-            if ([optNameToChange isEqualToString:@"me"])
-            {
-                /* Special case for motion estimation, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
-                        break;
-                        
-                    case 3:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
-                        break;
-                        
-                    case 4:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"direct"])
-            {
-                /* Special case for direct prediction, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
-                        break;
-                        
-                    case 3:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
-                        break;
-                        
-                    case 4:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"analyse"])
-            {
-                /* Special case for partition analysis, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
             
-            else if ([optNameToChange isEqualToString:@"merange"])
-            {
-                /* Special case for motion estimation range, which uses
-                   a widget index offset of 3. This is because the
-                   first valid value after default is four, not zero.   */
-                [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                    [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
-            }
-            else if ([optNameToChange isEqualToString:@"deblock"])
-            {
-                /* Very special case for deblock. Uses a weird widget index offset
-                   of 7, because the first value after default is -6, rather than 0.
-                   As well, deblock only goes to default when *both* alpha and beta
-                   are zero. If only one is zero, you can't mark it down as default.
-                   Instead, mark that one down as literally 0. This is because when
-                   widgets are at default values, they aren't included in the string.
-                   If only one filter is at 0, both need to be overtly specified.    */
-                [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]];                
-            }
-            else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
-            {
-                /* This covers all the boolean options that need to be specified only when true. */
-                if ([sender state] == 0)
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];                    
-                }
-                else
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                        [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"cabac"])
-            {
-                /* CABAC is weird in that you need the inverse. Only include in the string
-                   when cabac=0, because cabac=1 is the default. Turning it off means CAVLC. */
-                if ([sender state] == 1)
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];                                        
-                }
-                else
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                        [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];                    
-                }
-            }            
-            else
-            {
-                if ( [sender indexOfSelectedItem] != 0 )
-                /* General case to cover all the normal PopUp widgets, like ref and b-frames. */
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", 
-                    [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
-            }
+            [fDisplayX264Options setStringValue:
+                [self X264AdvancedOptionsWidgetToString: optNameToChange withID: sender]];
         }
         else
         {
-            /* The string isn't empty, and the option isn't already in it,
-               so it will need to be appended to the string with a colon.  */
-            if ([optNameToChange isEqualToString:@"me"])
-            {
-                /* Special case for motion estimation, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
-                        break;
-                        
-                    case 3:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
-                        break;
-                        
-                    case 4:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"direct"])
-            {
-                /* Special case for direct prediction, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
-                        break;
-                        
-                    case 3:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
-                        break;
-                        
-                    case 4:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"analyse"])
-            {
-                /* Special case for partition analysis, which uses string values
-                   that need to be paired up with the equivalent widget index.  */
-                switch ([sender indexOfSelectedItem])
-                {   
-                    case 1:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
-                        break;
-                        
-                    case 2:
-                        [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", 
-                            [NSString stringWithFormat:[fDisplayX264Options stringValue]],
-                            [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
-                        break;
-                        
-                    default:
-                        break;
-                }
-            }
-            
-            else if ([optNameToChange isEqualToString:@"merange"])
-            {
-                /* Motion estimation range uses a weird offset since its index goes
-                   0: default, 1: 4, because the first valid value is 4, not 1.     */
-                [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], 
-                    [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
-            }
-            else if ([optNameToChange isEqualToString:@"deblock"])
-            {
-                /* Deblock is really weird because it has two values, and if only one is default, both
-                   still need to be specified directly. with the default one at zero. To make deblock
-                   just a little more fun, values start at -6 instead of at zero.                       */
-                [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", [NSString stringWithFormat:[fDisplayX264Options stringValue]], [NSString stringWithFormat:optNameToChange], [NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]];                
-            }
-            else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
-            {
-                /* Covers all the normal booleans, that only need to be included in the string when they're true. */
-                if ([sender state] == 0)
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];                    
-                }
-                else
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], 
-                        [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];                
-                }
-            }
-            else if ([optNameToChange isEqualToString:@"cabac"])
-            {
-                /* CABAC is weird, in that it's an inverse. Only include it in the string when it's false. */
-                if ([sender state] == 1)
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];                    
-                }
-                else
-                {
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], 
-                        [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
-                }
-            }
-            else
+            /* The string isn't empty, and the option isn't already in it, so
+               it will need to be appended to the current string with a colon,
+               as long as the string to be appended isn't just blank (default). */
+            if( [[self X264AdvancedOptionsWidgetToString: optNameToChange withID: sender] isEqualToString: @""] == false )
             {
-                /* General case to handle the normal PopUp widgets like ref and b-frames. */
-                if ( [sender indexOfSelectedItem] != 0 )
-                    [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], 
-                    [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
+                [fDisplayX264Options setStringValue:
+                    [NSString stringWithFormat:@"%@:%@",
+                        currentOptString,
+                        [self X264AdvancedOptionsWidgetToString: optNameToChange withID: sender] ]];                
             }
         }
     }
index 588d32d..81a8545 100644 (file)
         return nil;
     }
 
-    return [NSString stringWithCString:(const char *)volumeParms.vMDeviceID];
+    return [NSString stringWithUTF8String:(const char *)volumeParms.vMDeviceID];
 }
 
 
index 2fe1ea9..ff860c6 100644 (file)
@@ -9,25 +9,25 @@
 #import "HBImageAndTextCell.h"
 
 
-static inline float
+static inline CGFloat
 xLeftInRect(NSSize innerSize, NSRect outerRect)
 {
   return NSMinX(outerRect);
 }
 
-static inline float
+static inline CGFloat
 xCenterInRect(NSSize innerSize, NSRect outerRect)
 {
   return MAX(NSMidX(outerRect) - (innerSize.width/2.0), 0.0);
 }
 
-static inline float
+static inline CGFloat
 xRightInRect(NSSize innerSize, NSRect outerRect)
 {
   return MAX(NSMaxX(outerRect) - innerSize.width, 0.0);
 }
 
-static inline float
+static inline CGFloat
 yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
 {
   if (flipped)
@@ -36,13 +36,13 @@ yTopInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
     return MAX(NSMaxY(outerRect) - innerSize.height, 0.0);
 }
 
-static inline float
+static inline CGFloat
 yCenterInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
 {
   return MAX(NSMidY(outerRect) - innerSize.height/2.0, 0.0);
 }
 
-static inline float
+static inline CGFloat
 yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
 {
   if (flipped)
@@ -54,7 +54,7 @@ yBottomInRect(NSSize innerSize, NSRect outerRect, BOOL flipped)
 static inline NSSize
 scaleProportionally(NSSize imageSize, NSRect canvasRect)
 {
-  float ratio;
+  CGFloat ratio;
 
   // get the smaller ratio and scale the image size by it
   ratio = MIN(NSWidth(canvasRect) / imageSize.width,
@@ -145,7 +145,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
     [super editWithFrame: textFrame inView: controlView editor:textObj delegate:anObject event: theEvent];
 }
 
-- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength
+- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
 {
     NSRect textFrame, imageFrame;
     NSDivideRect (aRect, &imageFrame, &textFrame, (imageSpacing.width * 2) + [image size].width, NSMinXEdge);
index e504a5f..5ce02ad 100644 (file)
  */
 - (IBAction)showOutputPanel:(id)sender
 {
+    if ([[self window] isVisible])
+    {
+        [[self window] close];
+    }
+    else
+    {
     [textView scrollRangeToVisible:NSMakeRange([outputTextStorage length], 0)];
     [self showWindow:sender];
 
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"OutputPanelIsOpen"];
+    }
 }
 
 - (void) startEncodeLog:(NSString *) logPath
     /* We need to get the current time in YY-MM-DD HH-MM-SS format to put at the beginning of the name of the log file */
     time_t _now = time( NULL );
     struct tm * now  = localtime( &_now );
-    NSString *dateForLogTitle = [NSString stringWithFormat:@"%02d-%02d-%02d %02d-%02d-%02d",now->tm_year + 1900, now->tm_mon, now->tm_mday,now->tm_hour, now->tm_min, now->tm_sec]; 
+    NSString *dateForLogTitle = [NSString stringWithFormat:@"%02d-%02d-%02d %02d-%02d-%02d",now->tm_year + 1900, now->tm_mon + 1, now->tm_mday,now->tm_hour, now->tm_min, now->tm_sec]; 
     
     /* Assemble the new log file name as YY-MM-DD HH-MM-SS mymoviename.txt */
-    NSString *outputDateFileName = [NSString stringWithFormat:@"%@ %@.txt",dateForLogTitle,[[outputFileForEncode lastPathComponent] stringByDeletingPathExtension]];
+    NSString *outputDateFileName = [NSString stringWithFormat:@"%@ %@.txt",[[outputFileForEncode lastPathComponent] stringByDeletingPathExtension],dateForLogTitle];
     if ([[NSUserDefaults standardUserDefaults] boolForKey:@"EncodeLogLocation"]) // if we are putting it in the same directory with the movie
     {
         
         if( ![[NSFileManager defaultManager] fileExistsAtPath:encodeLogDirectory] )
         {
             [[NSFileManager defaultManager] createDirectoryAtPath:encodeLogDirectory
-                                                       attributes:nil];
+                                            withIntermediateDirectories:NO
+                                            attributes:nil
+                                            error:nil];
         }
         outputLogFileForEncode = [[NSString stringWithFormat:@"%@/%@",encodeLogDirectory,outputDateFileName] retain];   
     }
     [fileManager createFileAtPath:outputLogFileForEncode contents:nil attributes:nil];
     
     /* Similar to the regular activity log, we print a header containing the date and time of the encode as well as what directory it was encoded to */
-    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGetInfoString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)\n\n", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)\n\n", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
     NSString *startOutputLogString = [NSString stringWithFormat: @"HandBrake Activity Log for %@: %@\n%@",outputFileForEncode, [[NSDate  date] descriptionWithCalendarFormat:nil timeZone:nil locale:nil],versionStringFull];
     [startOutputLogString writeToFile:outputLogFileForEncode atomically:YES encoding:NSUTF8StringEncoding error:NULL];
 
 {
        [outputTextStorage deleteCharactersInRange:NSMakeRange(0, [outputTextStorage length])];
     /* We want to rewrite the app version info to the top of the activity window so it is always present */
-    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGetInfoString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)\n\n", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
     time_t _now = time( NULL );
     struct tm * now  = localtime( &_now );
     fprintf(stderr, "[%02d:%02d:%02d] macgui: %s\n", now->tm_hour, now->tm_min, now->tm_sec, [versionStringFull UTF8String]);
-    
+
 }
 
 /**
     if( ![[NSFileManager defaultManager] fileExistsAtPath:encodeLogDirectory] )
     {
         [[NSFileManager defaultManager] createDirectoryAtPath:encodeLogDirectory
-                                                   attributes:nil];
+                                            withIntermediateDirectories:NO
+                                            attributes:nil
+                                            error:nil];
     }
     
     NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"Finder\" to open (POSIX file \"", encodeLogDirectory, @"\")"]];
         [startOutputLogString writeToFile:outputLogFile atomically:NO encoding:NSUTF8StringEncoding error:NULL];
         
         /* We want to rewrite the app version info to the top of the activity window so it is always present */
-        NSString *versionStringFull = [[NSString stringWithFormat: @"macgui: Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGetInfoString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+        NSString *versionStringFull = [[NSString stringWithFormat: @"macgui: Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)\n\n", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
         [versionStringFull writeToFile:outputLogFile atomically:NO encoding:NSUTF8StringEncoding error:NULL];
         
 }
index 701b95f..943cf3b 100644 (file)
 @interface HBPreferencesController (Private)
 
 - (void) setPrefView: (id) sender;
+- (NSToolbarItem *)toolbarItemWithIdentifier: (NSString *)identifier
+                                       label: (NSString *)label
+                                       image: (NSImage *)image;
 
 @end
 
 @implementation HBPreferencesController
 
 /**
+ * +[HBPreferencesController registerUserDefaults]
+ *
  * Registers default values to user defaults. This is called immediately
  * when HandBrake starts, from [HBController init].
  */
 
     [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
         @"YES",             @"CheckForUpdates",
+        @"Open Source",     @"LaunchSourceBehavior",
         @"English",         @"DefaultLanguage",
+        @"YES",              @"UseCoreAudio",
         @"NO",              @"DefaultMpegName",
-        @"YES",             @"DefaultCrf",
+        @"YES",              @"UseDvdNav",
         @"",                @"DefAdvancedx264Flags",
         @"YES",             @"DefaultPresetsDrawerShow",
         desktopDirectory,   @"LastDestinationDirectory",
         @"NO",              @"DisableDvdAutoDetect",
         @"Alert Window",    @"AlertWhenDone",
         @"1",               @"LoggingLevel",
-        @"4:10:15:9:10:35:9",    @"DecombCustomString",
-        @"NO",    @"EncodeLogLocation",
+        @"NO",              @"EncodeLogLocation",
+        @"10",              @"PreviewsNumber",
+        @"",                @"Drawer Size",
+        @"0.25",            @"x264CqSliderFractional",
+        @"YES",              @"AlertBuiltInPresetUpdate",
         nil]];
 }
 
 /**
+ * -[HBPreferencesController init]
+ *
  * Initializes the preferences controller by loading Preferences.nib file.
+ *
  */
 - (id)init
 {
     return self;
 }
 
+/**
+ * -[HBPreferencesController awakeFromNib]
+ *
+ * Called after all the outlets in the nib file have been attached. Sets up the
+ * toolbar and shows the "General" pane.
+ *
+ */
 - (void) awakeFromNib
 {
     NSToolbar * toolbar = [[[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"] autorelease];
     [self setPrefView:nil];
 }
 
-- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident
-                    willBeInsertedIntoToolbar: (BOOL) flag
+- (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
+     itemForItemIdentifier: (NSString *)ident
+ willBeInsertedIntoToolbar: (BOOL)flag
 {
-    NSToolbarItem * item;
-    item = [[[NSToolbarItem alloc] initWithItemIdentifier: ident] autorelease];
-
-    if ([ident isEqualToString: TOOLBAR_GENERAL])
-    {
-        [item setLabel: NSLocalizedString(@"General", "General")];
-        [item setImage: [NSImage imageNamed: @"NSPreferencesGeneral"]];
-        [item setTarget: self];
-        [item setAction: @selector(setPrefView:)];
-        [item setAutovalidates: NO];
-    }
-    else if ([ident isEqualToString: TOOLBAR_PICTURE])
+    if ( [ident isEqualToString:TOOLBAR_GENERAL] )
     {
-        [item setLabel: NSLocalizedString(@"Picture", "Picture")];
-        [item setImage: [NSImage imageNamed: @"pref-picture"]];
-        [item setTarget: self];
-        [item setAction: @selector(setPrefView:)];
-        [item setAutovalidates: NO];
+        return [self toolbarItemWithIdentifier:ident
+                                         label:NSLocalizedString(@"General", @"Preferences General Toolbar Item")
+                                         image:[NSImage imageNamed:NSImageNamePreferencesGeneral]];
     }
-    else if ([ident isEqualToString: TOOLBAR_AUDIO])
+    else if ( [ident isEqualToString:TOOLBAR_PICTURE] )
     {
-        [item setLabel: NSLocalizedString(@"Audio", "Audio")];
-        [item setImage: [NSImage imageNamed: @"pref-audio"]];
-        [item setTarget: self];
-        [item setAction: @selector(setPrefView:)];
-        [item setAutovalidates: NO];
+        return [self toolbarItemWithIdentifier:ident
+                                         label:NSLocalizedString(@"Picture", @"Preferences Picture Toolbar Item")
+                                         image:[NSImage imageNamed:@"pref-picture"]];
     }
-    else if ([ident isEqualToString: TOOLBAR_ADVANCED])
+    else if ( [ident isEqualToString:TOOLBAR_AUDIO] )
     {
-        [item setLabel: NSLocalizedString(@"Advanced", "Advanced")];
-        [item setImage: [NSImage imageNamed: @"NSAdvanced"]];
-        [item setTarget: self];
-        [item setAction: @selector(setPrefView:)];
-        [item setAutovalidates: NO];
+        return [self toolbarItemWithIdentifier:ident
+                                         label:NSLocalizedString(@"Audio", @"Preferences Audio Toolbar Item")
+                                         image:[NSImage imageNamed:@"pref-audio"]];
     }
-    else
+    else if ( [ident isEqualToString:TOOLBAR_ADVANCED] )
     {
-        return nil;
+        return [self toolbarItemWithIdentifier:ident
+                                         label:NSLocalizedString(@"Advanced", @"Preferences Advanced Toolbar Item")
+                                         image:[NSImage imageNamed:NSImageNameAdvanced]];
     }
 
-    return item;
+    return nil;
 }
 
 - (NSArray *) toolbarSelectableItemIdentifiers: (NSToolbar *) toolbar
 
 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
 {
-    return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_PICTURE,
+    return [NSArray arrayWithObjects: TOOLBAR_GENERAL, /*TOOLBAR_PICTURE, */
                                         TOOLBAR_AUDIO, TOOLBAR_ADVANCED, nil];
 }
 
     }
 }
 
+/**
+ * -[HBPreferencesController(Private) toolbarItemWithIdentifier:label:image:]
+ *
+ * Shared code for creating the NSToolbarItems for the Preferences toolbar.
+ *
+ */
+- (NSToolbarItem *)toolbarItemWithIdentifier: (NSString *)identifier
+                                       label: (NSString *)label
+                                       image: (NSImage *)image
+{
+    NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:identifier];
+    [item setLabel:label];
+    [item setImage:image];
+    [item setAction:@selector(setPrefView:)];
+    [item setAutovalidates:NO];
+    return [item autorelease];
+}
+
 @end
index 71a5160..d8ea61a 100644 (file)
 
 /* Built-In Preset Dictionaries (one for each built in preset) */
 - (NSDictionary *)createApplePresetFolder;
-- (NSDictionary *)createBasicPresetFolder;
-- (NSDictionary *)createGamingConsolesPresetFolder;
-- (NSDictionary *)createHiProfilePresetFolder;
+- (NSDictionary *)createRegularPresetFolder;
 - (NSDictionary *)createLegacyPresetFolder;
 
-- (NSDictionary *)create360Preset;
-- (NSDictionary *)createAnimationPreset;
 - (NSDictionary *)createAppleTVPreset;
 - (NSDictionary *)createAppleTVLegacyPreset;
 - (NSDictionary *)createAppleUniversalPreset;
 - (NSDictionary *)createClassicPreset;
-- (NSDictionary *)createCRFPreset;
-- (NSDictionary *)createFilmPreset;
 - (NSDictionary *)createiPhonePreset;
 - (NSDictionary *)createiPhoneLegacyPreset;
 - (NSDictionary *)createIpodHighPreset;
 - (NSDictionary *)createIpodLowPreset;
 - (NSDictionary *)createNormalPreset;
-- (NSDictionary *)createPSPPreset;
-- (NSDictionary *)createPSThreePreset;  
-- (NSDictionary *)createQuickTimePreset;
-- (NSDictionary *)createTelevisionPreset;
+- (NSDictionary *)createHighProfilePreset;
 
 @end
index a9911a3..9ccd15e 100644 (file)
@@ -24,9 +24,8 @@
      */
     /* Built in preset folders at the root of the hierarchy */
     [UserPresets addObject:[self createApplePresetFolder]];
-    [UserPresets addObject:[self createBasicPresetFolder]];
-    [UserPresets addObject:[self createHiProfilePresetFolder]];
-    [UserPresets addObject:[self createGamingConsolesPresetFolder]];
+    [UserPresets addObject:[self createRegularPresetFolder]];
+    [UserPresets addObject:[self createLegacyPresetFolder]];
     
     /* Independent presets at the root hierarchy level would go here */
     
@@ -63,8 +62,6 @@
     [childrenArray addObject:[self createIpodLowPreset]];
     [childrenArray addObject:[self createiPhonePreset]];
     [childrenArray addObject:[self createAppleTVPreset]];
-    [childrenArray addObject:[self createQuickTimePreset]];
-    [childrenArray addObject:[self createLegacyPresetFolder]];
 
     [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
     
@@ -76,7 +73,7 @@
     return preset;
 }
 
-- (NSDictionary *)createGamingConsolesPresetFolder
+- (NSDictionary *)createRegularPresetFolder
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 /*Set whether or not this is a folder, 1 is bool for folder*/
 
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Gaming Consoles" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-    
-    /* Lets initalize the child array of dictionaries for folders, this
-     is an array of dictionaries much like the root level of presets and
-     may contain folders and presets alike, etc.*/
-    NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
-    /* we actually call the methods for the nests here */
-    [childrenArray addObject:[self createPSPPreset]];
-    [childrenArray addObject:[self createPSThreePreset]];
-    [childrenArray addObject:[self create360Preset]];
-    [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
-    
-    [childrenArray autorelease];
-
-
-
-    [preset autorelease];
-    return preset;
-}
-
-
-- (NSDictionary *)createBasicPresetFolder
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-/*Set whether or not this is a folder, 1 is bool for folder*/
-    [preset setObject:[NSNumber numberWithBool: YES] forKey:@"Folder"];
-
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Basic" forKey:@"PresetName"];
+    [preset setObject:@"Regular" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
     NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
     /* we actually call the methods for the nests here */
     [childrenArray addObject:[self createNormalPreset]];
-    [childrenArray addObject:[self createClassicPreset]];
+    [childrenArray addObject:[self createHighProfilePreset]];
     [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
     
     [childrenArray autorelease];
     return preset;
 }
 
-- (NSDictionary *)createHiProfilePresetFolder
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-/*Set whether or not this is a folder, 1 is bool for folder*/
-    [preset setObject:[NSNumber numberWithBool: YES] forKey:@"Folder"];
-
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"High Profile" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-    
-    /* Lets initalize the child array of dictionaries for folders, this
-     is an array of dictionaries much like the root level of presets and
-     may contain folders and presets alike, etc.*/
-    NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
-    /* we actually call the methods for the nests here */
-    [childrenArray addObject:[self createAnimationPreset]];
-    [childrenArray addObject:[self createCRFPreset]];
-    [childrenArray addObject:[self createFilmPreset]];
-    [childrenArray addObject:[self createTelevisionPreset]];
-    [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
-    
-    [childrenArray autorelease];
-    [preset autorelease];
-    return preset;
-}
-
 - (NSDictionary *)createLegacyPresetFolder
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
      may contain folders and presets alike, etc.*/
     NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
     /* we actually call the methods for the nests here */
+    [childrenArray addObject:[self createClassicPreset]];
     [childrenArray addObject:[self createAppleTVLegacyPreset]];
     [childrenArray addObject:[self createiPhoneLegacyPreset]];
     [childrenArray addObject:[self createIpodHighPreset]];
 /* These NSDictionary Buit-In Preset definitions contain all of the settings for one built in preset */
 /* Note: For now, you can no longer have reference to any main window fields in your key values */
 
-- (NSDictionary *)create360Preset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Xbox 360" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for the Microsoft Xbox 360." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MP4 file" forKey:@"FileFormat"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-    
-    /* x264 Option String */
-    [preset setObject:@"level=40:ref=2:mixed-refs:bframes=3:weightb:subme=9:direct=auto:b-pyramid:me=umh:analyse=all:no-fast-pskip:filter=-2,-1" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-
-    /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-    
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createAnimationPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Animation" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for cartoons, anime, and CGI." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MKV file" forKey:@"FileFormat"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String */
-    [preset setObject:@"ref=5:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2:psy-rd=1,1:subme=9" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
-
-    /*Picture Settings*/
-    /* Basic Picture Settings */
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
-
-    /* Filters. For animation, use slower deinterlacing. */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDecomb"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-    
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
 - (NSDictionary *)createAppleTVPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's settings for the AppleTV and 2009's iPhone and iPod Touch lineup. Provides a good balance between quality and file size, and pushes the devices to their limits. Includes Dolby Digital 5.1 AC3 sound for the AppleTV." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* 64-bit MP4 file */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4LargeFile"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String (We can use this to tweak the appleTV output)*/
-    [preset setObject:@"level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.59] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-
-    /* Basic Picture Settings */
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:960] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];    
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-
-    /* Track 2 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio2Track"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Encoder"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio2Samplerate"];
-    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
-     * the sources bitrate, however we need to initially set the value to something so
-     * the macgui doesnt barf, so 160 seems as good as anything */
-    [preset setObject:@"160" forKey:@"Audio2Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio2TrackDRCSlider"];
-
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createAppleTVLegacyPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"AppleTV Legacy" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's deprecated settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance. This is the AppleTV preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MP4 file" forKey:@"FileFormat"];
-
-    /* 64-bit MP4 file */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4LargeFile"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String (We can use this to tweak the appleTV output)*/
-    [preset setObject:@"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-
-    /* Basic Picture Settings */
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-   
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-
-    /* Track 2 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio2Track"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Encoder"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio2Samplerate"];
-    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
-     * the sources bitrate, however we need to initially set the value to something so
-     * the macgui doesnt barf, so 160 seems as good as anything */
-    [preset setObject:@"160" forKey:@"Audio2Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio2TrackDRCSlider"];
-
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createAppleUniversalPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Universal" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-    /*Set whether or not this is a folder, 1 is bool for folder*/
-    [preset setObject:[NSNumber numberWithBool: NO] forKey:@"Folder"];
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's universally compatible, full resolution settings for all current Apple devices: iPod, iPhone, AppleTV, and Macs" forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MP4 file" forKey:@"FileFormat"];
-
-    /* 64-bit MP4 file */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4LargeFile"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String (We can use this to tweak the appleTV output)*/
-    [preset setObject:@"level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.59] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-
-    /* Basic Picture Settings */
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:720] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];    
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-
-    /* Track 2 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio2Track"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Encoder"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio2Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio2Samplerate"];
-    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
-     * the sources bitrate, however we need to initially set the value to something so
-     * the macgui doesnt barf, so 160 seems as good as anything */
-    [preset setObject:@"160" forKey:@"Audio2Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio2TrackDRCSlider"];
-
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createClassicPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Classic" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MP4 file" forKey:@"FileFormat"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"MPEG-4 (FFmpeg)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String */
-    [preset setObject:@"" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
-    [preset setObject:@"700"  forKey:@"VideoTargetSize"];
-    [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-
-    /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-    
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createCRFPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Constant Quality Rate" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MKV file" forKey:@"FileFormat"];
-
-    /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
-
-    /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String */
-    [preset setObject:@"ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all:8x8dct:me=umh:subme=9:psy-rd=1,1" forKey:@"x264Option"];
-
-    /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.60] forKey:@"VideoQualitySlider"];
-
-    /* Video framerate */
-    [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-
-    /* GrayScale */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
-
-    /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
-
-    /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
-
-    /* Explicitly set the filters for built-in presets */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
-
-    /* Set crop settings here */
-    /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
-    /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
-     * not listed will be set to "None" and not encoded */
-    
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio1Encoder"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
-     * the sources bitrate, however we need to initially set the value to something so
-     * the macgui doesnt barf, so 160 seems as good as anything */
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
-
-    /* Subtitles*/
-    [preset setObject:@"None" forKey:@"Subtitles"];
-
-    [preset autorelease];
-    return preset;
-}
-
-- (NSDictionary *)createFilmPreset
-{
-    NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
-
-    /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Film" forKey:@"PresetName"];
-
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
-    /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-
-    /*Get the whether or not to apply pic settings in the AddPresetPanel*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
-
-    /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's preset for feature films." forKey:@"PresetDescription"];
-
-    /* File Format */
-    [preset setObject:@"MKV file" forKey:@"FileFormat"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4LargeFile"];
 
     /* Chapter Markers*/
      [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
 
-    /* x264 Option String */
-    [preset setObject:@"ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1" forKey:@"x264Option"];
+    /* x264 Option String (We can use this to tweak the appleTV output)*/
+    [preset setObject:@"cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:20.0] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
 
     /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
-    /*Picture Settings*/
+    /* Basic Picture Settings */
     /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:960] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];    
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio1Encoder"];
-    [preset setObject:@"AC3 Passthru" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    /* Track 2 */
+    NSMutableDictionary *audioTrack2Array = [[NSMutableDictionary alloc] init];
+    [audioTrack2Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioEncoder"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioMixdown"];
+    [audioTrack2Array setObject:@"Auto" forKey:@"AudioSamplerate"];
+    [audioTrack2Array setObject:@"160" forKey:@"AudioBitrate"];
     /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
      * the sources bitrate, however we need to initially set the value to something so
      * the macgui doesnt barf, so 160 seems as good as anything */
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    [audioTrack2Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack2Array autorelease];
+    [audioListArray addObject:audioTrack2Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createiPhonePreset
+- (NSDictionary *)createAppleTVLegacyPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"iPhone & iPod Touch" forKey:@"PresetName"];
+    [preset setObject:@"AppleTV Legacy" forKey:@"PresetName"];
 
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
+    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
 
     /*Set whether or not this is default, at creation set to 0*/
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for the iPhone and iPod Touch." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's deprecated settings for the AppleTV, including Dolby Digital 5.1 AC3 sound. Provides a good balance between quality and file size, and optimizes performance. This is the AppleTV preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
+    /* 64-bit MP4 file */
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4LargeFile"];
+
     /* Chapter Markers*/
      [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4iPodCompatible"];
-    /* x264 Option String */
-    [preset setObject:@"level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1" forKey:@"x264Option"];
+
+    /* x264 Option String (We can use this to tweak the appleTV output)*/
+    [preset setObject:@"ref=1:subme=5:me=umh:no-fast-pskip=1:cabac=0:weightb=0:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.59] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
     /* 2 Pass Encoding */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
-    /*Picture Settings*/
-    /* Use a width of 480 for the iPhone*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
+    /* Basic Picture Settings */
+    /* Use Max Picture settings for whatever the dvd is.*/
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"128" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    /* Track 2 */
+    NSMutableDictionary *audioTrack2Array = [[NSMutableDictionary alloc] init];
+    [audioTrack2Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioEncoder"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioMixdown"];
+    [audioTrack2Array setObject:@"Auto" forKey:@"AudioSamplerate"];
+    [audioTrack2Array setObject:@"160" forKey:@"AudioBitrate"];
+    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
+     * the sources bitrate, however we need to initially set the value to something so
+     * the macgui doesnt barf, so 160 seems as good as anything */
+    [audioTrack2Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack2Array autorelease];
+    [audioListArray addObject:audioTrack2Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createiPhoneLegacyPreset
+- (NSDictionary *)createAppleUniversalPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"iPhone Legacy" forKey:@"PresetName"];
+    [preset setObject:@"Universal" forKey:@"PresetName"];
 
-    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
+    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
-
+    /*Set whether or not this is a folder, 1 is bool for folder*/
+    [preset setObject:[NSNumber numberWithBool: NO] forKey:@"Folder"];
     /*Set whether or not this is default, at creation set to 0*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
 
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's deprecated settings for the iPhone and iPod Touch. This is the iPhone preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's universally compatible, full resolution settings for all current Apple devices: iPod (6G and up), iPhone, AppleTV, and Macs" forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
+    /* 64-bit MP4 file */
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4LargeFile"];
+
     /* Chapter Markers*/
      [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
-    /* x264 Option String */
-    [preset setObject:@"level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:trellis=1" forKey:@"x264Option"];
+
+    /* x264 Option String (We can use this to tweak the appleTV output)*/
+    [preset setObject:@"cabac=0:ref=2:me=umh:bframes=0:8x8dct=0:trellis=0:subme=6" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:20.0] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
     /* 2 Pass Encoding */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
-    /*Picture Settings*/
-    /* Use a width of 480 for the iPhone*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
+    /* Basic Picture Settings */
+    /* Use Max Picture settings for whatever the dvd is.*/
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:720] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];    
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"128" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    /* Track 2 */
+    NSMutableDictionary *audioTrack2Array = [[NSMutableDictionary alloc] init];
+    [audioTrack2Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioEncoder"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioMixdown"];
+    [audioTrack2Array setObject:@"Auto" forKey:@"AudioSamplerate"];
+    [audioTrack2Array setObject:@"160" forKey:@"AudioBitrate"];
+    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
+     * the sources bitrate, however we need to initially set the value to something so
+     * the macgui doesnt barf, so 160 seems as good as anything */
+    [audioTrack2Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack2Array autorelease];
+    [audioListArray addObject:audioTrack2Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createIpodHighPreset
+- (NSDictionary *)createClassicPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"iPod Legacy" forKey:@"PresetName"];
+    [preset setObject:@"Classic" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's high resolution settings for older 5 and 5.5G iPods. Good video quality, great for viewing on a TV using your iPod. This is the iPod High-Rez preset from 0.9.2." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
+     [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
 
     /* Video encoder */
-    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
+    [preset setObject:@"MPEG-4 (FFmpeg)" forKey:@"VideoEncoder"];
+
     /* x264 Option String */
-    [preset setObject:@"level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1" forKey:@"x264Option"];
+    [preset setObject:@"" forKey:@"x264Option"];
 
     /* Video quality */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
-    [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:@"700"  forKey:@"VideoTargetSize"];
+    [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
     [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
     /*Picture Settings*/
-    /* Use a width of 640 for iPod TV-out */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
+    /* Use Max Picture settings for whatever the dvd is.*/
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
-
+    
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createIpodLowPreset
+- (NSDictionary *)createHighProfilePreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"iPod" forKey:@"PresetName"];
+    [preset setObject:@"High Profile" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's general-purpose preset for High Profile H.264 video, with all the bells and whistles." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
+
     /* x264 Option String */
-    [preset setObject:@"level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1" forKey:@"x264Option"];
+    [preset setObject:@"b-adapt=2:rc-lookahead=50" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:20.0] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
 
     /* 2 Pass Encoding */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
 
     /*Picture Settings*/
-    /* Use a width of 320 for the iPod screen */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+    /* Use Max Picture settings for whatever the dvd is.*/
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDecombDeinterlace"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PictureDetelecine"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"PictureDecomb"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    /* Track 2 */
+    NSMutableDictionary *audioTrack2Array = [[NSMutableDictionary alloc] init];
+    [audioTrack2Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioEncoder"];
+    [audioTrack2Array setObject:@"AC3 Passthru" forKey:@"AudioMixdown"];
+    [audioTrack2Array setObject:@"Auto" forKey:@"AudioSamplerate"];
+    [audioTrack2Array setObject:@"160" forKey:@"AudioBitrate"];
+    /* Note: we ignore specified bitrate for AC3 Passthru in libhb and use
+     * the sources bitrate, however we need to initially set the value to something so
+     * the macgui doesnt barf, so 160 seems as good as anything */
+    [audioTrack2Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack2Array autorelease];
+    [audioListArray addObject:audioTrack2Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createNormalPreset
+- (NSDictionary *)createiPhonePreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Normal" forKey:@"PresetName"];
+    [preset setObject:@"iPhone & iPod Touch" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
 
     /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
 
     /*Get the whether or not to apply pic settings in the AddPresetPanel*/
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's settings for all iPhones and iPod Touches going back to the original iPhone 2G." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Mp4iPodCompatible"];
     /* x264 Option String */
-    [preset setObject:@"ref=2:bframes=2:me=umh" forKey:@"x264Option"];
+    [preset setObject:@"cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:20.0] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
 
     /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
     /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
+    /* Use a width of 480 for the iPhone*/
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"128" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createPSPPreset
+- (NSDictionary *)createiPhoneLegacyPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"PSP" forKey:@"PresetName"];
+    [preset setObject:@"iPhone Legacy" forKey:@"PresetName"];
 
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
+    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
 
     /*Set whether or not this is default, at creation set to 0*/
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for the Sony PlayStation Portable." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's deprecated settings for the iPhone and iPod Touch. This is the iPhone preset from HandBrake 0.9.2, and while it is offered as a service to legacy users, it is no longer supported." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
      [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
 
     /* Video encoder */
-    [preset setObject:@"MPEG-4 (FFmpeg)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String (We can use this to tweak the appleTV output)*/
-    [preset setObject:@"" forKey:@"x264Option"];
+    [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
+    /* x264 Option String */
+    [preset setObject:@"level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:subme=6:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1024" forKey:@"VideoAvgBitrate"];
+    [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
     [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
     /*Picture Settings*/
-    /* Use dimensions of 368*208 for robust PSP compatibility */
+    /* Use a width of 480 for the iPhone*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:@"368" forKey:@"PictureWidth"];
-    [preset setObject:@"208" forKey:@"PictureHeight"];
+    [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
 
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"128" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"128" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createPSThreePreset
+- (NSDictionary *)createIpodHighPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"PS3" forKey:@"PresetName"];
+    [preset setObject:@"iPod Legacy" forKey:@"PresetName"];
 
-    /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
+    /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
 
     /*Set whether or not this is default, at creation set to 0*/
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for the Sony PlayStation 3." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's high resolution settings for older 5 and 5.5G iPods. Good video quality, great for viewing on a TV using your iPod. This is the iPod High-Rez preset from 0.9.2." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Chapter Markers*/
-     [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
+     [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
-    /* x264 Option String (We can use this to tweak the appleTV output)*/
-    [preset setObject:@"level=41:me=umh" forKey:@"x264Option"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
+    /* x264 Option String */
+    [preset setObject:@"level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:subme=6:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
     [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
     /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
+    /* Use a width of 640 for iPod TV-out */
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+    [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureAutoCrop"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"48" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createQuickTimePreset
+- (NSDictionary *)createIpodLowPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"QuickTime" forKey:@"PresetName"];
+    [preset setObject:@"iPod" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's high profile settings for use with QuickTime. It can be slow, so use it when the Normal preset doesn't look good enough." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's low resolution settings for the iPod (5G and up). Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
 
     /* File Format */
     [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Video encoder */
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
-
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Mp4iPodCompatible"];
     /* x264 Option String */
-    [preset setObject:@"ref=3:mixed-refs:bframes=3:weightb:direct=auto:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip=1:psy-rd=1,1" forKey:@"x264Option"];
+    [preset setObject:@"level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
+    [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
     [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
 
     /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
 
     /*Picture Settings*/
-    /* Use Max Picture settings for whatever the dvd is.*/
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
+    /* Use a width of 320 for the iPod screen */
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
+    [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
 
     /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
-- (NSDictionary *)createTelevisionPreset
+- (NSDictionary *)createNormalPreset
 {
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
 
     /* Get the New Preset Name from the field in the AddPresetPanel */
-    [preset setObject:@"Television" forKey:@"PresetName"];
+    [preset setObject:@"Normal" forKey:@"PresetName"];
 
     /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
 
     /*Set whether or not this is default, at creation set to 0*/
-    [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
+    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
 
     /*Get the whether or not to apply pic settings in the AddPresetPanel*/
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
 
     /* Get the New Preset Description from the field in the AddPresetPanel */
-    [preset setObject:@"HandBrake's settings for video from television." forKey:@"PresetDescription"];
+    [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
 
     /* File Format */
-    [preset setObject:@"MKV file" forKey:@"FileFormat"];
+    [preset setObject:@"MP4 file" forKey:@"FileFormat"];
 
     /* Chapter Markers*/
      [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
     [preset setObject:@"H.264 (x264)" forKey:@"VideoEncoder"];
 
     /* x264 Option String */
-    [preset setObject:@"ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip=1:psy-rd=1,1" forKey:@"x264Option"];
+    [preset setObject:@"ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0" forKey:@"x264Option"];
 
     /* Video quality */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
+    [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
     [preset setObject:@"700" forKey:@"VideoTargetSize"];
-    [preset setObject:@"1300" forKey:@"VideoAvgBitrate"];
-    [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
+    [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
+    [preset setObject:[NSNumber numberWithFloat:20.0] forKey:@"VideoQualitySlider"];
 
     /* Video framerate */
     [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
 
     /* 2 Pass Encoding */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
 
     /*Picture Settings*/
     /* Use Max Picture settings for whatever the dvd is.*/
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
 
+    /* Explicitly set the filters for built-in presets */
     [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureFilters"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDecomb"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDenoise"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"VFR"];
     [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeblock"];
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDetelecine"];
+    [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDetelecine"];
 
     /* Set crop settings here */
     /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
 
     /* Audio - Is done on a track by track basis, ONLY specifiy the tracks we want set as any track
      * not listed will be set to "None" and not encoded */
+    NSMutableArray *audioListArray = [[NSMutableArray alloc] init];
     
-    /* Track 1 */
-    [preset setObject:[NSNumber numberWithInt:1] forKey:@"Audio1Track"];
-    [preset setObject:@"AAC (faac)" forKey:@"Audio1Encoder"];
-    [preset setObject:@"Dolby Pro Logic II" forKey:@"Audio1Mixdown"];
-    [preset setObject:@"Auto" forKey:@"Audio1Samplerate"];
-    [preset setObject:@"160" forKey:@"Audio1Bitrate"];
-    [preset setObject:[NSNumber numberWithFloat:1.0] forKey:@"Audio1TrackDRCSlider"];
+    /* Track 1 */        
+    NSMutableDictionary *audioTrack1Array = [[NSMutableDictionary alloc] init];
+    [audioTrack1Array setObject:[NSNumber numberWithInt:1] forKey:@"AudioTrack"];
+    [audioTrack1Array setObject:@"AAC (faac)" forKey:@"AudioEncoder"];
+    [audioTrack1Array setObject:@"Dolby Pro Logic II"  forKey:@"AudioMixdown"];
+    [audioTrack1Array setObject:@"48" forKey:@"AudioSamplerate"];
+    [audioTrack1Array setObject:@"160" forKey:@"AudioBitrate"];
+    [audioTrack1Array setObject:[NSNumber numberWithFloat:0.0] forKey:@"AudioTrackDRCSlider"];
+    [audioTrack1Array autorelease];
+    [audioListArray addObject:audioTrack1Array];
+
+    [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"];
 
     /* Subtitles*/
     [preset setObject:@"None" forKey:@"Subtitles"];
     return preset;
 }
 
+
 @end
diff --git a/macosx/HBPreviewController.h b/macosx/HBPreviewController.h
new file mode 100644 (file)
index 0000000..df5cf2b
--- /dev/null
@@ -0,0 +1,112 @@
+/* $Id: HBPreviewController.h,v 1.6 2005/04/14 20:40:05 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+
+#include "hb.h"
+/* Needed for Quicktime movie previews */
+#import <QTKit/QTKit.h> 
+
+@class HBController;
+
+#define HB_NUM_HBLIB_PICTURES      20   // # of preview pictures libhb should generate
+
+@interface PreviewController : NSWindowController
+{
+    hb_handle_t              * fHandle;
+    hb_title_t               * fTitle;
+
+    HBController             *fHBController;        // reference to HBController
+    
+    IBOutlet NSWindow        * fPreviewWindow;
+    NSWindow                 * fFullScreenWindow; // Full Screen window
+    NSMutableDictionary      * fPicturePreviews;  // NSImages, one for each preview libhb creates, created lazily
+    int                        fPicture;
+
+    IBOutlet NSImageView     * fPictureView;
+    IBOutlet NSBox           * fPictureViewArea;
+    IBOutlet NSBox           * fPictureControlBox;
+    IBOutlet NSBox           * fEncodingControlBox;
+
+    IBOutlet NSSlider        * fPictureSlider;
+    IBOutlet NSTextField     * fInfoField;
+    IBOutlet NSTextField     * fscaleInfoField;
+    
+    BOOL                     isEncoding;
+
+       
+    int                      MaxOutputWidth;
+    int                      MaxOutputHeight;
+
+    int output_width, output_height, output_par_width, output_par_height;
+    int display_width;
+    
+    /* Hud Control Overlay */
+    NSTimer                         * fHudTimer;
+    int                               hudTimerSeconds;
+    
+    /* Full Screen Mode Toggle */
+    IBOutlet NSButton               * fFullScreenToggleButton;
+    IBOutlet NSButton               * fScaleToScreenToggleButton;
+    IBOutlet NSButton               * fPictureSettingsToggleButton;
+    BOOL                              isFullScreen;
+    BOOL                              scaleToScreen;
+    /* Movie Previews */
+    IBOutlet NSButton               * fCreatePreviewMovieButton;
+    IBOutlet NSButton               * fCancelPreviewMovieButton;
+    IBOutlet NSButton               * fShowPreviewMovieButton;
+    NSString                        * fPreviewMoviePath;
+    IBOutlet NSProgressIndicator    * fMovieCreationProgressIndicator;
+    hb_handle_t                     * fPreviewLibhb;           // private libhb for creating previews
+    NSTimer                         * fLibhbTimer;             // timer for retrieving state from libhb
+    IBOutlet NSTextField            * fPreviewMovieStatusField; 
+    IBOutlet QTMovieView            * fMovieView;
+    IBOutlet NSPopUpButton          * fPreviewMovieLengthPopUp; // popup of choices for length of preview in seconds
+}
+- (id)init;
+
+- (void) SetHandle: (hb_handle_t *) handle;
+- (void) SetTitle:  (hb_title_t *)  title;
+- (void)setHBController: (HBController *)controller;
+- (IBAction) showPreviewWindow: (id)sender;
+- (BOOL)acceptsMouseMovedEvents;
+- (void) displayPreview;
+
+- (IBAction) SettingsChanged: (id) sender;
+- (IBAction) pictureSliderChanged: (id) sender;
+- (IBAction)showPictureSettings:(id)sender;
+- (NSString*) pictureSizeInfoString;
+
+/* Full Screen */
+- (IBAction)toggleScreenMode:(id)sender;
+- (IBAction)toggleScaleToScreen:(id)sender;
+- (BOOL)fullScreen;
+- (IBAction)goFullScreen:(id)sender;
+- (IBAction)goWindowedScreen:(id)sender;
+
+/* HUD overlay */
+- (void) startHudTimer;
+- (void) stopHudTimer;
+
+/* Movie Previews */
+- (void) startReceivingLibhbNotifications;
+- (void) stopReceivingLibhbNotifications;
+
+- (IBAction) createMoviePreview: (id) sender;
+- (void) libhbStateChanged: (hb_state_t ) state;
+- (IBAction) showMoviePreview: (NSString *) path;
+- (IBAction) previewDurationPopUpChanged: (id) sender;
+
+
+- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title;
+
++ (NSImage *) makeImageForPicture: (int)pictureIndex
+                libhb:(hb_handle_t*)handle
+                title:(hb_title_t*)title;
+- (NSImage *) imageForPicture: (int) pictureIndex;
+- (void) purgeImageCache;
+@end
+
diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m
new file mode 100644 (file)
index 0000000..5397fe5
--- /dev/null
@@ -0,0 +1,1325 @@
+/* $Id: HBPreviewController.mm,v 1.11 2005/08/01 15:10:44 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#import "HBPreviewController.h"
+#import "Controller.h"
+
+@implementation QTMovieView ( HBQTkitExt )
+- (void) mouseMoved:(NSEvent *)theEvent
+{
+    [super mouseMoved:theEvent];
+}
+@end
+
+@interface PreviewController (Private)
+
+- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize;
+- (void)resizeSheetForViewSize: (NSSize)viewSize;
+- (void)setViewSize: (NSSize)viewSize;
+- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize;
+
+@end
+
+@implementation PreviewController
+
+- (id)init
+{
+       if (self = [super initWithWindowNibName:@"PicturePreview"])
+       {
+        // NSWindowController likes to lazily load its window. However since
+        // this controller tries to set all sorts of outlets before the window
+        // is displayed, we need it to load immediately. The correct way to do
+        // this, according to the documentation, is simply to invoke the window
+        // getter once.
+        //
+        // If/when we switch a lot of this stuff to bindings, this can probably
+        // go away.
+        [self window];
+        
+               fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain];
+        /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */
+        int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue];
+        fPreviewLibhb = hb_init(loggingLevel, 0);
+        
+       }
+       return self;
+}
+
+
+
+//------------------------------------------------------------------------------------
+// Displays and brings the picture window to the front
+//------------------------------------------------------------------------------------
+- (IBAction) showPreviewWindow: (id)sender
+{
+    [self showWindow:sender];
+    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"];
+    
+    /* lets set the preview window to accept mouse moved events */
+    [fPreviewWindow setAcceptsMouseMovedEvents:YES];
+    hudTimerSeconds = 0;
+    [self pictureSliderChanged:nil];
+    [self startReceivingLibhbNotifications];
+}
+
+- (void)setHBController: (HBController *)controller
+{
+    fHBController = controller;
+}
+
+- (void)awakeFromNib
+{
+    [fPreviewWindow setDelegate:self];
+    if( ![[self window] setFrameUsingName:@"Preview"] )
+        [[self window] center];
+    [self setWindowFrameAutosaveName:@"Preview"];
+    [[self window] setExcludedFromWindowsMenu:YES];
+    
+    /* lets set the preview window to accept mouse moved events */
+    [fPreviewWindow setAcceptsMouseMovedEvents:YES];
+    //[self pictureSliderChanged:nil];
+    [self startReceivingLibhbNotifications];
+    
+    isFullScreen = NO;
+    hudTimerSeconds = 0;
+    /* we set the progress indicator to not use threaded animation
+     * as it causes a conflict with the qtmovieview's controllerbar
+    */
+    [fMovieCreationProgressIndicator setUsesThreadedAnimation:NO];
+    
+    /* Setup our layers for core animation */
+    [fPictureViewArea setWantsLayer:YES];
+    [fPictureView setWantsLayer:YES];
+
+    [fCancelPreviewMovieButton setWantsLayer:YES];
+    [fMovieCreationProgressIndicator setWantsLayer:YES];
+
+    [fPictureControlBox setWantsLayer:YES];
+    [fEncodingControlBox setWantsLayer:YES];
+       [fMovieView setWantsLayer:YES];
+       [fMovieView setHidden:YES];
+    [fMovieView setDelegate:self];
+
+    /* Since the xib has everything off center for easy acess
+     * we align our views and windows here we an align to anything
+     * since it will actually change later upon source load, but
+     * for convenience we will use the fPictureViewArea
+     */
+     
+     /* Align the still preview image view to the picture box */
+     [fPictureView setFrameSize:[fPictureViewArea frame].size];
+     [fMovieView setFrameSize:[fPictureViewArea frame].size];
+     //[fPreviewWindow setFrameSize:[fPictureViewArea frame].size];
+    
+    
+}
+- (BOOL)acceptsMouseMovedEvents
+{
+    return YES;
+}
+
+- (void)windowWillClose:(NSNotification *)aNotification
+{
+    /* Upon Closing the picture window, we make sure we clean up any
+     * preview movie that might be playing
+     */
+    hb_stop( fPreviewLibhb );
+    isEncoding = NO;
+    // Show the picture view
+    [fPictureView setHidden:NO];
+    [fMovieView pause:nil];
+    [fMovieView setHidden:YES];
+       [fMovieView setMovie:nil];
+
+    isFullScreen = NO;
+    hudTimerSeconds = 0;
+    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PreviewWindowIsOpen"];
+}
+
+- (BOOL)windowShouldClose:(id)fPictureWindow
+{
+     return YES;
+}
+
+- (void) dealloc
+{
+    hb_stop(fPreviewLibhb);
+    if (fPreviewMoviePath)
+    {
+        [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath handler:nil];
+        [fPreviewMoviePath release];
+    }    
+    
+    [fLibhbTimer invalidate];
+    [fLibhbTimer release];
+    
+    [fHudTimer invalidate];
+    [fHudTimer release];
+    
+    [fPicturePreviews release];
+    [fFullScreenWindow release];
+
+    [super dealloc];
+}
+
+- (void) SetHandle: (hb_handle_t *) handle
+{
+    fHandle = handle;
+    
+
+    
+    /* we set the preview length popup in seconds */
+    [fPreviewMovieLengthPopUp removeAllItems];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"5"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"10"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"15"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"20"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"25"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"30"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"35"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"40"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"45"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"50"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"55"];
+    [fPreviewMovieLengthPopUp addItemWithTitle: @"60"];
+    
+    /* adjust the preview slider length */
+    /* We use our advance pref to determine how many previews we scanned */
+    int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+    [fPictureSlider setMaxValue: hb_num_previews - 1.0];
+    [fPictureSlider setNumberOfTickMarks: hb_num_previews];
+    
+    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"])
+    {
+        [fPreviewMovieLengthPopUp selectItemWithTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"]];
+    }
+    else
+    {
+        /* currently hard set default to 10 seconds */
+        [fPreviewMovieLengthPopUp selectItemAtIndex: 1];
+    }
+}
+
+- (void) SetTitle: (hb_title_t *) title
+{
+    hb_job_t * job = title->job;
+    
+    fTitle = title;
+    fPicture = 0;
+    MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
+    MaxOutputHeight = title->height - job->crop[0] - job->crop[1];
+    [self SettingsChanged: nil];
+}
+
+
+
+// Adjusts the window to draw the current picture (fPicture) adjusting its size as
+// necessary to display as much of the picture as possible.
+- (void) displayPreview
+{
+    hb_job_t * job = fTitle->job;
+    /* lets make sure that the still picture view is not hidden and that 
+     * the movie preview is 
+     */
+    [fMovieView pause:nil];
+    [fMovieView setHidden:YES];
+       [fMovieView setMovie:nil];
+    [fMovieCreationProgressIndicator stopAnimation: nil];
+    [fMovieCreationProgressIndicator setHidden: YES];
+    
+    [fPictureView setHidden:NO];
+    
+    //[fHBController writeToActivityLog: "displayPreview called"];
+    
+    NSImage *fPreviewImage = [self imageForPicture: fPicture];
+    NSSize imageScaledSize = [fPreviewImage size];
+    [fPictureView setImage: fPreviewImage];
+    
+    NSSize displaySize = NSMakeSize( ( CGFloat )fTitle->width, ( CGFloat )fTitle->height );
+    NSString *sizeInfoString;
+    /* Set the picture size display fields below the Preview Picture*/
+    if( fTitle->job->anamorphic.mode == 1 ) // Original PAR Implementation
+    {
+        output_width = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
+        output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
+        display_width = output_width * fTitle->job->anamorphic.par_width / fTitle->job->anamorphic.par_height;
+        sizeInfoString = [NSString stringWithFormat:
+                          @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict",
+                          fTitle->width, fTitle->height, output_width, output_height, display_width, output_height];
+        
+        displaySize.width = display_width;
+        displaySize.height = fTitle->height;
+        imageScaledSize.width = display_width;
+        imageScaledSize.height = output_height;   
+    }
+    else if (fTitle->job->anamorphic.mode == 2) // Loose Anamorphic
+    {
+        hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
+        display_width = output_width * output_par_width / output_par_height;
+        sizeInfoString = [NSString stringWithFormat:
+                          @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose",
+                          fTitle->width, fTitle->height, output_width, output_height, display_width, output_height];
+        
+        displaySize.width = display_width;
+        displaySize.height = fTitle->height;
+        imageScaledSize.width = display_width;
+        imageScaledSize.height = output_height;
+    }
+    else if (fTitle->job->anamorphic.mode == 3) // Custom Anamorphic
+    {
+        hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
+        display_width = output_width * output_par_width / output_par_height;
+        sizeInfoString = [NSString stringWithFormat:
+                          @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Custom",
+                          fTitle->width, fTitle->height, output_width, output_height, fTitle->job->anamorphic.dar_width, fTitle->job->anamorphic.dar_height];
+        
+        displaySize.width = fTitle->job->anamorphic.dar_width + fTitle->job->crop[2] + fTitle->job->crop[3];
+        displaySize.height = fTitle->job->anamorphic.dar_height + fTitle->job->crop[0] + fTitle->job->crop[1];
+        imageScaledSize.width = (int)fTitle->job->anamorphic.dar_width;
+        imageScaledSize.height = (int)fTitle->job->height;   
+    } 
+    else // No Anamorphic
+    {
+        sizeInfoString = [NSString stringWithFormat:
+                          @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height,
+                          fTitle->job->width, fTitle->job->height];
+        
+        displaySize.width = fTitle->width;
+        displaySize.height = fTitle->height;
+        imageScaledSize.width = fTitle->job->width;
+        imageScaledSize.height = fTitle->job->height;
+    }
+    
+    NSSize viewSize = [self optimalViewSizeForImageSize:displaySize];
+    
+    /* Initially set our preview image here */
+    /*
+    if (scaleToScreen == YES)
+    {
+        viewSize.width = viewSize.width - (viewSize.width - imageScaledSize.width);
+        viewSize.height = viewSize.height - (viewSize.height - imageScaledSize.height);
+        [fPreviewImage setSize: viewSize];
+        //[fPictureView setFrameSize: viewSize];
+    }
+    
+    else
+    {
+        [fPreviewImage setSize: imageScaledSize];
+        [fPictureView setFrameSize: imageScaledSize];
+    }
+    [fPictureView setImage: fPreviewImage];
+    // center it vertically and horizontally
+    NSPoint origin = [fPictureViewArea frame].origin;
+    origin.y += ([fPictureViewArea frame].size.height -
+                 [fPictureView frame].size.height) / 2.0;
+    
+    origin.x += ([fPictureViewArea frame].size.width -
+                 [fPictureView frame].size.width) / 2.0;
+    [fPictureView setFrameOrigin:origin]; 
+    */
+    /* we also need to take into account scaling to full screen to activate switching the view size */
+    if( [self viewNeedsToResizeToSize:viewSize])
+    {
+        if (fTitle->job->anamorphic.mode != 2 || (fTitle->job->anamorphic.mode == 2 && fTitle->width == fTitle->job->width))
+        {
+            [self resizeSheetForViewSize:viewSize];
+            //[self setViewSize:viewSize];
+            
+        }
+    }   
+    
+    viewSize.width = viewSize.width - (viewSize.width - imageScaledSize.width);
+    viewSize.height = viewSize.height - (viewSize.height - imageScaledSize.height);
+    [self setViewSize:viewSize];
+    
+    /* special case for scaleToScreen */
+    if (scaleToScreen == YES)
+    {
+        [fPreviewImage setSize: viewSize];
+        [fPictureView setImage: fPreviewImage];
+    }
+    
+    NSString *scaleString;
+    
+    if( imageScaledSize.height > [fPictureView frame].size.height)
+    {
+        CGFloat scale = ( ( CGFloat )[fPictureView frame].size.width) / ( ( CGFloat )imageScaledSize.width);        
+        scaleString = [NSString stringWithFormat:
+                       NSLocalizedString( @" (Scaled to %.0f%% actual size)",
+                                         @"String shown when a preview is scaled" ), scale * 100.0];
+    }
+    else
+    {
+        scaleString = @"";
+    }
+    /* Set the info fields in the hud controller */
+    [fInfoField setStringValue: [NSString stringWithFormat:
+                                 @"%@", sizeInfoString]];
+    
+    [fscaleInfoField setStringValue: [NSString stringWithFormat:
+                                      @"%@", scaleString]];
+    /* Set the info field in the window title bar */
+    [[self window] setTitle:[NSString stringWithFormat: @"Preview - %@ %@",sizeInfoString, scaleString]];
+}
+
+- (IBAction) previewDurationPopUpChanged: (id) sender
+{
+    
+    [[NSUserDefaults standardUserDefaults] setObject:[fPreviewMovieLengthPopUp titleOfSelectedItem] forKey:@"PreviewLength"];
+    
+}    
+    
+- (IBAction) SettingsChanged: (id) sender
+{
+         // Purge the existing picture previews so they get recreated the next time
+        // they are needed.
+        [self purgeImageCache];
+        [self pictureSliderChanged:nil];
+}
+
+- (IBAction) pictureSliderChanged: (id) sender
+{
+    // Show the picture view
+    [fPictureView setHidden:NO];
+    [fMovieView pause:nil];
+    [fMovieView setHidden:YES];
+       [fMovieView setMovie:nil];
+    [fEncodingControlBox setHidden: YES];
+    
+    int newPicture = [fPictureSlider intValue];
+    if (newPicture != fPicture)
+    {
+        fPicture = newPicture;
+    }
+    [self displayPreview];
+    
+}
+
+- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title
+{
+    if ([fPreviewWindow isVisible])
+    {
+        [fPreviewWindow close];
+    }
+    else
+    {
+        [self showWindow:sender];
+        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"];
+        [fPreviewWindow setAcceptsMouseMovedEvents:YES];
+        isFullScreen = NO;
+        scaleToScreen = NO;
+        [self pictureSliderChanged:nil];
+    }
+    
+}
+
+- (NSString*) pictureSizeInfoString
+{
+    return [fInfoField stringValue];
+}
+
+- (IBAction)showPictureSettings:(id)sender
+{
+    [fHBController showPicturePanel:self];
+}
+
+#pragma mark Hud Control Overlay
+- (void) mouseMoved:(NSEvent *)theEvent
+{
+    [super mouseMoved:theEvent];
+    NSPoint mouseLoc = [theEvent locationInWindow];
+    
+    /* Test for mouse location to show/hide hud controls */
+    if( isEncoding == NO ) {
+        if( NSPointInRect( mouseLoc, [fPictureControlBox frame] ) )
+        {
+            [[fPictureControlBox animator] setHidden: NO];
+            [self stopHudTimer];
+        }
+               else if( NSPointInRect( mouseLoc, [fPictureViewArea frame] ) )
+        {
+            [[fPictureControlBox animator] setHidden: NO];
+            [self startHudTimer];
+        }
+        else
+            [[fPictureControlBox animator] setHidden: YES];
+       }
+}
+
+- (void) startHudTimer
+{
+       if( fHudTimer ) {
+               [fHudTimer invalidate];
+               [fHudTimer release];
+       }
+    fHudTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(hudTimerFired:) userInfo:nil repeats:YES];
+    [fHudTimer retain];
+}
+
+- (void) stopHudTimer
+{
+    if( fHudTimer )
+    {
+        [fHudTimer invalidate];
+        [fHudTimer release];
+        fHudTimer = nil;
+        hudTimerSeconds = 0;
+    }
+}
+
+- (void) hudTimerFired: (NSTimer*)theTimer
+{
+    hudTimerSeconds++;
+    if( hudTimerSeconds >= 10 ) {
+        [[fPictureControlBox animator] setHidden: YES];
+        [self stopHudTimer];
+    }
+}
+
+#pragma mark Fullscreen Mode
+
+- (IBAction)toggleScreenMode:(id)sender
+{
+    if (!isFullScreen)
+    {
+        [self goFullScreen:nil];
+    }
+    else
+    {
+        [self goWindowedScreen:nil];
+    }
+}
+
+- (IBAction)toggleScaleToScreen:(id)sender
+{
+    if (scaleToScreen == YES)
+    {
+        scaleToScreen = NO;
+        /* make sure we are set to a still preview */
+        [self pictureSliderChanged:nil];
+        [fScaleToScreenToggleButton setTitle:@"<->"];
+    }
+    else
+    {
+        scaleToScreen = YES;
+        /* make sure we are set to a still preview */
+        [self pictureSliderChanged:nil];
+        [fScaleToScreenToggleButton setTitle:@">-<"];
+    }
+}
+
+- (BOOL)fullScreen
+{
+    return isFullScreen;
+}
+
+- (IBAction)goFullScreen:(id)sender 
+{ 
+    // Get the screen information. 
+    NSScreen* mainScreen = [fPreviewWindow screen];
+    NSDictionary* screenInfo = [mainScreen deviceDescription]; 
+    NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"]; 
+    // Capture the screen. 
+    CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue]; 
+    CGDisplayErr err = CGDisplayCapture(displayID); 
+    
+    if (err == CGDisplayNoErr) 
+    { 
+        
+        /* make sure we are set to a still preview and not scaled to screen */
+        scaleToScreen = NO;
+        [self pictureSliderChanged:nil];
+        
+        // Create the full-screen window. 
+        //NSRect winRect = [mainScreen frame];
+        //fPictureViewArea
+        NSRect winRect = [fPictureViewArea frame];
+          
+        fFullScreenWindow = [[NSWindow alloc] initWithContentRect:winRect 
+                                                        styleMask:NSBorderlessWindowMask 
+                                                          backing:NSBackingStoreBuffered 
+                                                            defer:NO 
+                                                           screen:mainScreen]; 
+        
+        // Establish the window attributes. 
+        [fFullScreenWindow setReleasedWhenClosed:NO]; 
+        [fFullScreenWindow setDisplaysWhenScreenProfileChanges:YES]; 
+        [fFullScreenWindow setDelegate:self]; 
+        
+        /* insert a view into the new window */
+        [fFullScreenWindow setContentView:fPictureViewArea]; 
+        [fPictureViewArea setNeedsDisplay:YES];
+        
+        /* Better to center the window using the screen's frame
+         * and the windows origin. Note that we should take into
+         * account the auto sizing and alignment that occurs in 
+         * setViewSize each time the preview changes.
+         * Note: by using [fFullScreenWindow screen] (instead of
+         * [NSScreen mainScreen]) in referencing the screen
+         * coordinates, the full screen window will show up on
+         * whichever display was being used in windowed mode
+         * on multi-display systems
+         */
+        
+        NSSize screenSize = [[fFullScreenWindow screen] frame].size;
+        NSSize windowSize = [fFullScreenWindow frame].size;
+        NSPoint windowOrigin = [fFullScreenWindow frame].origin;
+        
+        /* Adjust our origin y (vertical) based on the screen height */
+        windowOrigin.y += (screenSize.height - windowSize.height) / 2.0;
+        windowOrigin.x += (screenSize.width - windowSize.width) / 2.0;
+        
+        [fFullScreenWindow setFrameOrigin:windowOrigin];
+        
+        /* lets kill the timer for now */
+        [self stopReceivingLibhbNotifications];
+        
+        /* We need to retain the fPreviewWindow */
+        [fPreviewWindow retain];
+        
+        [self setWindow:fFullScreenWindow];
+        
+        // The window has to be above the level of the shield window.
+        int32_t shieldLevel = CGShieldingWindowLevel(); 
+        
+        [fFullScreenWindow setLevel:shieldLevel]; 
+        
+        // Show the window. 
+        [fFullScreenWindow makeKeyAndOrderFront:self];
+        
+        
+        /* Change the name of fFullScreenToggleButton appropriately */
+        [fFullScreenToggleButton setTitle: @"Windowed"];
+        
+        /* Lets fire the timer back up for the hud controls, etc. */
+        [self startReceivingLibhbNotifications];
+        
+        isFullScreen = YES;
+        [fScaleToScreenToggleButton setHidden:NO];
+        
+        /* make sure we are set to a still preview */
+        [self pictureSliderChanged:nil];
+        
+        [fFullScreenWindow setAcceptsMouseMovedEvents:YES];
+        
+        
+        hudTimerSeconds = 0;
+        [self startHudTimer];
+    } 
+} 
+
+// Title-less windows normally don't receive key presses, override this
+- (BOOL)canBecomeKeyWindow
+{
+    return YES;
+}
+
+// Title-less windows normally can't become main which means that another
+// non-fullscreen window will have the "active" titlebar in expose. Bad, fix it.
+- (BOOL)canBecomeMainWindow
+{
+    return YES;
+}
+
+
+- (IBAction)goWindowedScreen:(id)sender
+{
+    
+    /* Get the screen info to release the display but don't actually do
+     * it until the windowed screen is setup.
+     */
+    scaleToScreen = NO;
+    [self pictureSliderChanged:nil];
+    [fScaleToScreenToggleButton setTitle:@"<->"];
+        
+    NSScreen* mainScreen = [NSScreen mainScreen]; 
+    NSDictionary* screenInfo = [mainScreen deviceDescription]; 
+    NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"];
+    CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue]; 
+    
+    [fFullScreenWindow dealloc];
+    [fFullScreenWindow release];
+    
+    
+    [fPreviewWindow setContentView:fPictureViewArea]; 
+    [fPictureViewArea setNeedsDisplay:YES];
+    [self setWindow:fPreviewWindow];
+    
+    // Show the window. 
+    [fPreviewWindow makeKeyAndOrderFront:self];
+    
+    /* Set the window back to regular level */
+    [fPreviewWindow setLevel:NSNormalWindowLevel];
+    
+    /* Set the isFullScreen flag back to NO */
+    isFullScreen = NO;
+    scaleToScreen = NO;
+    /* make sure we are set to a still preview */
+    [self pictureSliderChanged:nil];
+    [self showPreviewWindow:nil];
+    
+    /* Change the name of fFullScreenToggleButton appropriately */
+    [fFullScreenToggleButton setTitle: @"Full Screen"];
+    // [fScaleToScreenToggleButton setHidden:YES];
+    /* set the picture settings pallete back to normal level */
+    [fHBController picturePanelWindowed];
+    
+    /* Release the display now that the we are back in windowed mode */
+    CGDisplayRelease(displayID);
+    
+    [fPreviewWindow setAcceptsMouseMovedEvents:YES];
+    //[fFullScreenWindow setAcceptsMouseMovedEvents:NO];
+    
+    hudTimerSeconds = 0;
+    [self startHudTimer];
+    
+}
+
+
+#pragma mark Still Preview Image Processing
+
+
+// This function converts an image created by libhb (specified via pictureIndex) into
+// an NSImage suitable for the GUI code to use. If removeBorders is YES,
+// makeImageForPicture crops the image generated by libhb stripping off the gray
+// border around the content. This is the low-level method that generates the image.
+// -imageForPicture calls this function whenever it can't find an image in its cache.
++ (NSImage *) makeImageForPicture: (int)pictureIndex
+                libhb:(hb_handle_t*)handle
+                title:(hb_title_t*)title
+{
+    static uint8_t * buffer;
+    static int bufferSize;
+
+    // Make sure we have a big enough buffer to receive the image from libhb. libhb
+    int dstWidth = title->job->width;
+    int dstHeight = title->job->height;
+        
+    int newSize;
+    newSize = dstWidth * dstHeight * 4;
+    if( bufferSize < newSize )
+    {
+        bufferSize = newSize;
+        buffer     = (uint8_t *) realloc( buffer, bufferSize );
+    }
+
+    hb_get_preview( handle, title, pictureIndex, buffer );
+
+    // Create an NSBitmapImageRep and copy the libhb image into it, converting it from
+    // libhb's format to one suitable for NSImage. Along the way, we'll strip off the
+    // border around libhb's image.
+        
+    // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
+    // Alpha is ignored.
+        
+    NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat;
+    NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc]
+            initWithBitmapDataPlanes:nil
+            pixelsWide:dstWidth
+            pixelsHigh:dstHeight
+            bitsPerSample:8
+            samplesPerPixel:3   // ignore alpha
+            hasAlpha:NO
+            isPlanar:NO
+            colorSpaceName:NSCalibratedRGBColorSpace
+            bitmapFormat:bitmapFormat
+            bytesPerRow:dstWidth * 4
+            bitsPerPixel:32] autorelease];
+
+    UInt32 * src = (UInt32 *)buffer;
+    UInt32 * dst = (UInt32 *)[imgrep bitmapData];
+    int r, c;
+    for (r = 0; r < dstHeight; r++)
+    {
+        for (c = 0; c < dstWidth; c++)
+#if TARGET_RT_LITTLE_ENDIAN
+            *dst++ = Endian32_Swap(*src++);
+#else
+            *dst++ = *src++;
+#endif
+    }
+
+    NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(dstWidth, dstHeight)] autorelease];
+    [img addRepresentation:imgrep];
+
+    return img;
+}
+
+// Returns the preview image for the specified index, retrieving it from its internal
+// cache or by calling makeImageForPicture if it is not cached. Generally, you should
+// use imageForPicture so that images are cached. Calling makeImageForPicture will
+// always generate a new copy of the image.
+- (NSImage *) imageForPicture: (int) pictureIndex
+{
+    // The preview for the specified index may not currently exist, so this method
+    // generates it if necessary.
+    NSString * key = [NSString stringWithFormat:@"%d", pictureIndex];
+    NSImage * theImage = [fPicturePreviews objectForKey:key];
+    if (!theImage)
+    {
+        theImage = [PreviewController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle];
+        [fPicturePreviews setObject:theImage forKey:key];
+    }
+    return theImage;
+}
+
+// Purges all images from the cache. The next call to imageForPicture will cause a new
+// image to be generated.
+- (void) purgeImageCache
+{
+    [fPicturePreviews removeAllObjects];
+}
+
+
+#pragma mark Movie Preview
+- (IBAction) createMoviePreview: (id) sender
+{
+    
+    
+    /* Lets make sure the still picture previews are showing in case
+     * there is currently a movie showing */
+    [self pictureSliderChanged:nil];
+    
+    /* Rip or Cancel ? */
+    hb_state_t s;
+    hb_get_state2( fPreviewLibhb, &s );
+    
+    if(sender == fCancelPreviewMovieButton && (s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED))
+       {
+        hb_stop( fPreviewLibhb );
+        [fPictureView setHidden:NO];
+        [fMovieView pause:nil];
+        [fMovieView setHidden:YES];
+               [fMovieView setMovie:nil];
+        [fPictureSlider setHidden:NO];
+        isEncoding = NO;
+        
+        return;
+    }
+    
+    
+    /* we use controller.mm's prepareJobForPreview to go ahead and set all of our settings
+     * however, we want to use a temporary destination field of course
+     * so that we do not put our temp preview in the users chosen
+     * directory */
+    
+    hb_job_t * job = fTitle->job;
+    
+    /* We run our current setting through prepeareJob in Controller.mm
+     * just as if it were a regular encode */
+    
+    [fHBController prepareJobForPreview];
+    
+    /* Destination file. We set this to our preview directory
+     * changing the extension appropriately.*/
+    if (fTitle->job->mux == HB_MUX_MP4) // MP4 file
+    {
+        /* we use .m4v for our mp4 files so that ac3 and chapters in mp4 will play properly */
+        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.m4v";
+    }
+    else if (fTitle->job->mux == HB_MUX_MKV) // MKV file
+    {
+        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.mkv";
+    }
+    else if (fTitle->job->mux == HB_MUX_AVI) // AVI file
+    {
+        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.avi";
+    }
+    else if (fTitle->job->mux == HB_MUX_OGM) // OGM file
+    {
+        fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.ogm";
+    }
+    
+    fPreviewMoviePath = [[fPreviewMoviePath stringByExpandingTildeInPath]retain];
+    
+    /* See if there is an existing preview file, if so, delete it */
+    if( ![[NSFileManager defaultManager] fileExistsAtPath:fPreviewMoviePath] )
+    {
+        [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath
+                                                 handler:nil];
+    }
+    
+    /* We now direct our preview encode to fPreviewMoviePath */
+    fTitle->job->file = [fPreviewMoviePath UTF8String];
+    
+    /* We use our advance pref to determine how many previews to scan */
+    int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+    job->start_at_preview = fPicture + 1;
+    job->seek_points = hb_num_previews;
+    
+    /* we use the preview duration popup to get the specified
+     * number of seconds for the preview encode.
+     */
+    
+    job->pts_to_stop = [[fPreviewMovieLengthPopUp titleOfSelectedItem] intValue] * 90000LL;
+    
+    /* lets go ahead and send it off to libhb
+     * Note: unlike a full encode, we only send 1 pass regardless if the final encode calls for 2 passes.
+     * this should suffice for a fairly accurate short preview and cuts our preview generation time in half.
+     * However we also need to take into account the indepth scan for subtitles.
+     */
+    /*
+     * If scanning we need to do some extra setup of the job.
+     */
+    if( job->indepth_scan == 1 )
+    {
+        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->indepth_scan = 1;  
+        /*
+         * Add the pre-scan job
+         */
+        hb_add( fPreviewLibhb, job );
+        job->x264opts = x264opts_tmp;
+    }                  
+    /* Go ahead and perform the actual encoding preview scan */
+    job->indepth_scan = 0;
+    job->pass = 0;
+    hb_add( fPreviewLibhb, job );
+    
+    [fEncodingControlBox setHidden: NO];
+    [fPictureControlBox setHidden: YES];
+    
+    [fMovieCreationProgressIndicator setHidden: NO];
+    [fPreviewMovieStatusField setHidden: NO];
+    
+    isEncoding = YES;
+
+    /* Let fPreviewLibhb do the job */
+    hb_start( fPreviewLibhb );
+       
+}
+
+- (void) startReceivingLibhbNotifications
+{
+    if (!fLibhbTimer)
+    {
+        fLibhbTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(libhbTimerFired:) userInfo:nil repeats:YES];
+        [fLibhbTimer retain];
+    }
+}
+
+- (void) stopReceivingLibhbNotifications
+{
+    if (fLibhbTimer)
+    {
+        [fLibhbTimer invalidate];
+        [fLibhbTimer release];
+        fLibhbTimer = nil;
+    }
+}
+- (void) libhbTimerFired: (NSTimer*)theTimer
+{
+    hb_state_t s;
+    hb_get_state( fPreviewLibhb, &s );
+    [self libhbStateChanged: s];
+    
+}
+
+- (void) libhbStateChanged: (hb_state_t)state
+{
+    switch( state.state )
+    {
+        case HB_STATE_IDLE:
+        case HB_STATE_SCANNING:
+        case HB_STATE_SCANDONE:
+            break;
+            
+        case HB_STATE_WORKING:
+        {
+#define p state.param.working
+            
+            NSMutableString * string;
+                       /* Update text field */
+                       string = [NSMutableString stringWithFormat: NSLocalizedString( @"Encoding preview:  %.2f %%", @"" ), 100.0 * p.progress];
+            
+                       if( p.seconds > -1 )
+            {
+                [string appendFormat:
+                 NSLocalizedString( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", @"" ),
+                 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
+            }
+            [fPreviewMovieStatusField setStringValue: string];
+            
+            [fMovieCreationProgressIndicator setIndeterminate: NO];
+            /* Update slider */
+                       [fMovieCreationProgressIndicator setDoubleValue: 100.0 * p.progress];
+            
+            [fCreatePreviewMovieButton setTitle: @"Cancel Preview"];
+            
+            break;
+            
+        }
+#undef p
+            
+#define p state.param.muxing            
+        case HB_STATE_MUXING:
+        {
+            // Update fMovieCreationProgressIndicator
+            [fMovieCreationProgressIndicator setIndeterminate: YES];
+            [fMovieCreationProgressIndicator startAnimation: nil];
+            [fPreviewMovieStatusField setStringValue: [NSString stringWithFormat:
+                                         NSLocalizedString( @"Muxing Preview ...", @"" )]];
+            break;
+        }
+#undef p                       
+        case HB_STATE_PAUSED:
+            [fMovieCreationProgressIndicator stopAnimation: nil];
+            break;
+                       
+        case HB_STATE_WORKDONE:
+        {
+            // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fPreviewLibhb, 0) ) )
+                hb_rem( fHandle, job );
+            
+            [fPreviewMovieStatusField setStringValue: @""];
+            [fPreviewMovieStatusField setHidden: YES];
+            
+            [fMovieCreationProgressIndicator stopAnimation: nil];
+            [fMovieCreationProgressIndicator setHidden: YES];
+            [fEncodingControlBox setHidden: YES];
+            isEncoding = NO;
+            /* we make sure the picture slider and preview match */
+            [self pictureSliderChanged:nil];
+
+            // Show the movie view
+            [self showMoviePreview:fPreviewMoviePath];
+            [fCreatePreviewMovieButton setTitle: @"Live Preview"];
+
+            break;
+        }
+    }
+}
+
+- (IBAction) showMoviePreview: (NSString *) path
+{
+    /* Since the gray background for the still images is part of
+     * fPictureView, lets leave the picture view visible and postion
+     * the fMovieView over the image portion of fPictureView so
+     * we retain the gray cropping border  we have already established
+     * with the still previews
+     */
+
+    /* Load the new movie into fMovieView */
+    if (path) {
+               QTMovie * aMovie;
+               NSError  *outError;
+               NSURL *movieUrl = [NSURL fileURLWithPath:path];
+               NSDictionary *movieAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
+                                                                                movieUrl, QTMovieURLAttribute,
+                                                                                [NSNumber numberWithBool:NO], QTMovieAskUnresolvedDataRefsAttribute,
+                                                                                [NSNumber numberWithBool:YES], @"QTMovieOpenForPlaybackAttribute",
+                                                                                [NSNumber numberWithBool:NO], @"QTMovieOpenAsyncRequiredAttribute",                                                            
+                                                                                [NSNumber numberWithBool:NO], @"QTMovieOpenAsyncOKAttribute",
+                                                                                QTMovieApertureModeClean, QTMovieApertureModeAttribute,
+                                                                                nil];
+
+        aMovie = [[[QTMovie alloc] initWithAttributes:movieAttributes error:&outError] autorelease];
+
+               if (!aMovie) {
+                       NSLog(@"Unable to open movie");
+               }
+        else {
+            NSRect movieBounds;
+            /* we get some size information from the preview movie */
+            NSSize movieSize= [[aMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
+            movieBounds = [fMovieView movieBounds];
+            movieBounds.size.height = movieSize.height;
+            
+            if ([fMovieView isControllerVisible]) {
+                CGFloat controllerBarHeight = [fMovieView controllerBarHeight];
+                if ( controllerBarHeight != 0 ) //Check if QTKit return a real value or not.
+                    movieBounds.size.height += controllerBarHeight;
+                else
+                    movieBounds.size.height += 15;
+            }
+            
+            movieBounds.size.width = movieSize.width;
+            
+            /* We need to find out if the preview movie needs to be scaled down so
+             * that it doesn't overflow our available viewing container (just like for image
+             * in -displayPreview) for HD sources, etc. [fPictureViewArea frame].size.height*/
+            if( (movieBounds.size.height) > [fPictureViewArea frame].size.height || scaleToScreen == YES )
+            {
+                /* The preview movie would be larger than the available viewing area
+                 * in the preview movie, so we go ahead and scale it down to the same size
+                 * as the still preview  or we readjust our window to allow for the added height if need be
+                 */
+                NSSize displaySize = NSMakeSize( ( CGFloat ) movieBounds.size.width, ( CGFloat ) movieBounds.size.height );
+                NSSize viewSize = [self optimalViewSizeForImageSize:displaySize];
+                if( [self viewNeedsToResizeToSize:viewSize] ) {
+                    [self resizeSheetForViewSize:viewSize];
+                    [self setViewSize:viewSize];
+                }
+                [fMovieView setFrameSize:viewSize];
+            }
+            else
+            {
+                /* Since the preview movie is smaller than the available viewing area
+                 * we can go ahead and use the preview movies native size */
+                [fMovieView setFrameSize:movieBounds.size];
+            }
+            
+            //lets reposition the movie if need be
+            
+            NSPoint origin = [fPictureViewArea frame].origin;
+            origin.x += trunc( ( [fPictureViewArea frame].size.width -
+                                [fMovieView frame].size.width ) / 2.0 );
+            /* We need to detect whether or not we are currently less than the available height.*/
+            if( movieBounds.size.height < [fPictureView frame].size.height )
+            {
+                /* If we are, we are adding 15 to the height to allow for the controller bar so
+                 * we need to subtract half of that for the origin.y to get the controller bar
+                 * below the movie to it lines up vertically with where our still preview was
+                 */
+                origin.y += trunc( ( ( [fPictureViewArea frame].size.height -
+                                      [fMovieView frame].size.height ) / 2.0 ) - 7.5 );
+            }
+            else
+            {
+                /* if we are >= to the height of the picture view area, the controller bar
+                 * gets taken care of with picture resizing, so we do not want to offset the height
+                 */
+                origin.y += trunc( ( [fPictureViewArea frame].size.height -
+                                    [fMovieView frame].size.height ) / 2.0 );
+            }
+            [fMovieView setFrameOrigin:origin];
+            [fMovieView setMovie:aMovie];
+            [fMovieView setHidden:NO];
+            // to actually play the movie
+            [fMovieView play:aMovie];
+        }
+    }
+    isEncoding = NO;
+}
+
+@end
+
+@implementation PreviewController (Private)
+
+//
+// -[PictureController(Private) optimalViewSizeForImageSize:]
+//
+// Given the size of the preview image to be shown, returns the best possible
+// size for the view.
+//
+- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize
+{
+    // The min size is 320x240
+    CGFloat minWidth = 480.0;
+    CGFloat minHeight = 360.0;
+
+    NSSize screenSize = [[NSScreen mainScreen] frame].size;
+    NSSize sheetSize = [[self window] frame].size;
+    NSSize viewAreaSize = [fPictureViewArea frame].size;
+    CGFloat paddingX = sheetSize.width - viewAreaSize.width;
+    CGFloat paddingY = sheetSize.height - viewAreaSize.height;
+    CGFloat maxWidth;
+    CGFloat maxHeight;
+    
+    if (isFullScreen)
+    {
+        /* We are in full screen mode so lets use the full screen if we need to */
+        maxWidth =  screenSize.width - paddingX;
+        maxHeight = screenSize.height - paddingY;
+    }
+    else
+    {
+        // The max size of the view is when the sheet is taking up 85% of the screen.
+        maxWidth = (0.85 * screenSize.width) - paddingX;
+        maxHeight = (0.85 * screenSize.height) - paddingY;
+    }
+    
+    NSSize resultSize = imageSize;
+    
+    // Its better to have a view that's too small than a view that's too big, so
+    // apply the maximum constraints last.
+    if( resultSize.width < minWidth )
+    {
+        resultSize.height *= (minWidth / resultSize.width);
+        resultSize.width = minWidth;
+    }
+    if( resultSize.height < minHeight )
+    {
+        resultSize.width *= (minHeight / resultSize.height);
+        resultSize.height = minHeight;
+    }
+    if( resultSize.width > maxWidth )
+    {
+        resultSize.height *= (maxWidth / resultSize.width);
+        resultSize.width = maxWidth;
+    }
+    if( resultSize.height > maxHeight )
+    {
+        resultSize.width *= (maxHeight / resultSize.height);
+        resultSize.height = maxHeight;
+    }
+    
+    if (scaleToScreen == YES)
+    {
+        CGFloat screenAspect;
+        CGFloat viewAreaAspect; 
+        //note, a mbp 15" at 1440 x 900 is a 1.6 ar
+        screenAspect = screenSize.width / screenSize.height;
+        
+        // Note, a standard dvd will use 720 x 480 which is a 1.5
+        viewAreaAspect = viewAreaSize.width / viewAreaSize.height;
+        
+        if (screenAspect < viewAreaAspect)
+        {
+            resultSize.width = screenSize.width;
+            resultSize.height = (screenSize.width / viewAreaAspect);
+        }
+        else
+        {
+            resultSize.height = screenSize.height;
+            resultSize.width = resultSize.height * viewAreaAspect;
+        }
+        
+    }
+
+      return resultSize;
+
+    
+}
+
+//
+// -[PictureController(Private) resizePanelForViewSize:animate:]
+//
+// Resizes the entire window to accomodate a view of a particular size.
+//
+- (void)resizeSheetForViewSize: (NSSize)viewSize
+{
+    // Figure out the deltas for the new frame area
+    NSSize currentSize = [fPictureViewArea frame].size;
+    CGFloat deltaX = viewSize.width - currentSize.width;
+    CGFloat deltaY = viewSize.height - currentSize.height;
+    
+    // Now resize the whole panel by those same deltas, but don't exceed the min
+    NSRect frame = [[self window] frame];
+    NSSize maxSize = [[self window] maxSize];
+    NSSize minSize = [[self window] minSize];
+    frame.size.width += deltaX;
+    frame.size.height += deltaY;
+    if( frame.size.width < minSize.width )
+    {
+        frame.size.width = minSize.width;
+    }
+    
+    if( frame.size.height < minSize.height )
+    {
+        frame.size.height = minSize.height;
+    }
+    
+    
+    // But now the sheet is off-center, so also shift the origin to center it and
+    // keep the top aligned.
+    if( frame.size.width != [[self window] frame].size.width )
+        frame.origin.x -= (deltaX / 2.0);
+    
+    if (isFullScreen)
+    {
+        if( frame.size.height != [[self window] frame].size.height )
+        {
+            frame.origin.y -= (deltaY / 2.0);
+        }
+        else
+        {
+            if( frame.size.height != [[self window] frame].size.height )
+                frame.origin.y -= deltaY;
+        }
+        
+        [[self window] setFrame:frame display:YES animate:NO];
+    }
+    else
+    {
+        /* Since upon launch we can open up the preview window if it was open
+         * the last time we quit (and at the size it was) we want to make
+         * sure that upon resize we do not have the window off the screen
+         * So check the origin against the screen origin and adjust if
+         * necessary.
+         */
+        NSSize screenSize = [[[self window] screen] frame].size;
+        NSPoint screenOrigin = [[[self window] screen] frame].origin;
+        /* our origin is off the screen to the left*/
+        if (frame.origin.x < screenOrigin.x)
+        {
+            /* so shift our origin to the right */
+            frame.origin.x = screenOrigin.x;
+        }
+        else if ((frame.origin.x + frame.size.width) > (screenOrigin.x + screenSize.width))
+        {
+            /* the right side of the preview is off the screen, so shift to the left */
+            frame.origin.x = (screenOrigin.x + screenSize.width) - frame.size.width;
+        }
+        
+        [[self window] setFrame:frame display:YES animate:YES];
+    }
+    
+}
+
+//
+// -[PictureController(Private) setViewSize:]
+//
+// Changes the view's size and centers it vertically inside of its area.
+// Assumes resizeSheetForViewSize: has already been called.
+//
+- (void)setViewSize: (NSSize)viewSize
+{   
+    /* special case for scaleToScreen */
+    if (scaleToScreen == YES)
+    {
+        /* for scaleToScreen, we expand the fPictureView to fit the entire screen */
+        NSSize areaSize = [fPictureViewArea frame].size;
+        CGFloat viewSizeAspect = viewSize.width / viewSize.height;
+        if (viewSizeAspect > 1.0) // we are wider than taller, so expand the width to fill the area and scale the height
+        {
+            viewSize.width = areaSize.width;
+            viewSize.height = viewSize.width / viewSizeAspect;
+        }
+        else
+        {
+            viewSize.height = areaSize.height;
+            viewSize.width = viewSize.height * viewSizeAspect;
+        }
+        
+    }
+
+    [fPictureView setFrameSize:viewSize];
+
+    // center it vertically and horizontally
+    NSPoint origin = [fPictureViewArea frame].origin;
+    origin.y += ([fPictureViewArea frame].size.height -
+                 [fPictureView frame].size.height) / 2.0;
+    
+    origin.x += ([fPictureViewArea frame].size.width -
+                 [fPictureView frame].size.width) / 2.0; 
+
+    origin.x = floor( origin.x );
+    origin.y = floor( origin.y );
+    
+    [fPictureView setFrameOrigin:origin];
+}
+
+
+- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize
+{
+    NSSize viewSize = [fPictureViewArea frame].size;
+    return (newSize.width != viewSize.width || newSize.height != viewSize.height);
+}
+
+@end
index 45d2f83..580c9e6 100644 (file)
@@ -142,9 +142,7 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
      */
     
        int i = 0;
-    NSEnumerator *enumerator = [fJobGroups objectEnumerator];
-       id tempObject;
-       while (tempObject = [enumerator nextObject])
+       for(id tempObject in fJobGroups)
        {
                NSDictionary *thisQueueDict = tempObject;
                if ([[thisQueueDict objectForKey:@"Status"] intValue] == 0) // Completed
@@ -478,12 +476,14 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
 - (IBAction)removeSelectedQueueItem: (id)sender
 {
     NSIndexSet * selectedRows = [fOutlineView selectedRowIndexes];
-    int row = [selectedRows firstIndex];
+    NSUInteger row = [selectedRows firstIndex];
+    if( row == NSNotFound )
+        return;
     /* if this is a currently encoding job, we need to be sure to alert the user,
      * to let them decide to cancel it first, then if they do, we can come back and
      * remove it */
     
-    if ([[[fJobGroups objectAtIndex:row] objectForKey:@"Status"] intValue] == 1)
+    if ([[[fJobGroups objectAtIndex:row] objectForKey:@"Status"] integerValue] == 1)
     {
        /* We pause the encode here so that it doesn't finish right after and then
         * screw up the sync while the window is open
@@ -491,7 +491,7 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
        [fHBController Pause:NULL];
          NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Stop This Encode and Remove It ?", nil)];
         // Which window to attach the sheet to?
-        NSWindow * docWindow;
+        NSWindow * docWindow = nil;
         if ([sender respondsToSelector: @selector(window)])
             docWindow = [sender window];
         
@@ -582,14 +582,20 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
 - (IBAction)togglePauseResume: (id)sender
 {
     if (!fQueueEncodeLibhb) return;
-
+    
     hb_state_t s;
     hb_get_state2 (fQueueEncodeLibhb, &s);
-
+    
     if (s.state == HB_STATE_PAUSED)
+    {
         hb_resume (fQueueEncodeLibhb);
+        [self startAnimatingCurrentWorkingEncodeInQueue];
+    }
     else if ((s.state == HB_STATE_WORKING) || (s.state == HB_STATE_MUXING))
+    {
         hb_pause (fQueueEncodeLibhb);
+        [self stopAnimatingCurrentJobGroupInQueue];
+    }
 }
 
 #pragma mark -
@@ -743,6 +749,12 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
 {
     if ([outlineView isItemExpanded: item])
     {
+        /* Below is the original code to accommodate a live resize,
+         * however as stated in travistex's comments it's very buggy.
+         * For now I will leave it here ... commented out and use
+         * the code below to determine the row height based on each
+         * encodes optional parameters and how they are displayed. */
+        
         // Short-circuit here if in a live resize primarily to fix a bug but also to
         // increase resposivness during a resize. There's a bug in NSTableView that
         // causes row heights to get messed up if you try to change them during a live
@@ -750,8 +762,8 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         // height. The row heights will get fixed up after the resize because we have
         // implemented viewDidEndLiveResize to force all of them to be recalculated.
         // if ([outlineView inLiveResize] && [item lastDescriptionHeight] > 0)
-         //   return [item lastDescriptionHeight];
-
+        //   return [item lastDescriptionHeight];
+        
         // CGFloat width = [[outlineView tableColumnWithIdentifier: @"desc"] width];
         // Column width is NOT what is ultimately used. I can't quite figure out what
         // width to use for calculating text metrics. No matter how I tweak this value,
@@ -759,14 +771,114 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         // of the row cell. In previous versions, which ran under Tiger, I was
         // reducing width by 47 pixles.
         // width -= 2;     // (?) for intercell spacing
-
+        
         // CGFloat height = [item heightOfDescriptionForWidth: width];
         // return height;
         
-        return HB_ROW_HEIGHT_FULL_DESCRIPTION;
+        /* So, we know several rows of text that are in all queue items for display.
+         * These are the title line, Preset, Format, Destination, Picture, and Video Lines
+         */
+        CGFloat rowHeightNonTitle = 15.0;
+        /* Add the title line height, then the non title line height for Preset, Format, Destination
+         * Picture and Video
+         */
+        CGFloat itemHeightForDisplay = HB_ROW_HEIGHT_TITLE_ONLY + (rowHeightNonTitle * 5);
+        
+        /* get our item row number so we an use it to calc how many lines we have to display based
+         * on MP4 Options, Filter Options, X264 Options, Audio Tracks and Subtitles from our queue array */
+        int itemRowNum = [outlineView rowForItem: item];
+        NSMutableDictionary *queueItemToCheck = [outlineView itemAtRow: itemRowNum];
+        
+        /* Check to see if we need to allow for mp4 opts */
+        BOOL mp4OptsPresent = NO;
+        if ([[queueItemToCheck objectForKey:@"FileFormat"] isEqualToString: @"MP4 file"])
+        {
+            
+            if( [[queueItemToCheck objectForKey:@"Mp4LargeFile"] intValue] == 1)
+            {
+                mp4OptsPresent = YES;
+            }
+            if( [[queueItemToCheck objectForKey:@"Mp4HttpOptimize"] intValue] == 1)
+            {
+                mp4OptsPresent = YES;
+            }
+            if( [[queueItemToCheck objectForKey:@"Mp4iPodCompatible"] intValue] == 1)
+            {
+                mp4OptsPresent = YES;
+            }
+        }
+        
+        if (mp4OptsPresent == YES)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle;   
+        }
+        
+        /* check to see if we need to allow for the Picture Filters row */
+        BOOL pictureFiltersPresent = NO;
+        if( [[queueItemToCheck objectForKey:@"PictureDetelecine"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        if( [[queueItemToCheck objectForKey:@"PictureDecomb"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        if( [[queueItemToCheck objectForKey:@"PictureDeinterlace"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        if( [[queueItemToCheck objectForKey:@"PictureDenoise"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        if( [[queueItemToCheck objectForKey:@"PictureDeblock"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        if( [[queueItemToCheck objectForKey:@"VideoGrayScale"] intValue] > 0)
+        {
+            pictureFiltersPresent = YES;
+        }
+        
+        if (pictureFiltersPresent == YES)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle;
+        }
+        
+        /* check to see if we need a line to display x264 options */
+        if ([[queueItemToCheck objectForKey:@"VideoEncoder"] isEqualToString: @"H.264 (x264)"])
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle;
+        }
+        
+        /* check to see how many audio track lines to allow for */
+        if ([[queueItemToCheck objectForKey:@"Audio1Track"] intValue] > 0)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle; 
+        }
+        if ([[queueItemToCheck objectForKey:@"Audio2Track"] intValue] > 0)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle; 
+        }
+        if ([[queueItemToCheck objectForKey:@"Audio3Track"] intValue] > 0)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle; 
+        }
+        if ([[queueItemToCheck objectForKey:@"Audio4Track"] intValue] > 0)
+        {
+            itemHeightForDisplay +=  rowHeightNonTitle; 
+        }
+        
+        /* add in subtitle lines for each subtitle in the SubtitleList array */
+        itemHeightForDisplay +=  rowHeightNonTitle * [[queueItemToCheck objectForKey:@"SubtitleList"] count];
+        
+        return itemHeightForDisplay;
+        
     }
     else
+    {
         return HB_ROW_HEIGHT_TITLE_ONLY;
+    }
 }
 
 - (CGFloat) heightOfDescriptionForWidth:(CGFloat)width
@@ -855,20 +967,25 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         [NSString stringWithFormat:@"Chapter %d", [[item objectForKey:@"ChapterStart"] intValue]] :
         [NSString stringWithFormat:@"Chapters %d through %d", [[item objectForKey:@"ChapterStart"] intValue], [[item objectForKey:@"ChapterEnd"] intValue]];
         
-        NSString * passesString;
+        NSString * passesString = @"";
+        /* check to see if our first subtitle track is Foreign Language Search, in which case there is an in depth scan */
+        if ([item objectForKey:@"SubtitleList"] && [[[[item objectForKey:@"SubtitleList"] objectAtIndex:0] objectForKey:@"subtitleSourceTrackNum"] intValue] == 1)
+        {
+          passesString = [passesString stringByAppendingString:@"1 Foreign Language Search Pass - "];
+        }
         if ([[item objectForKey:@"VideoTwoPass"] intValue] == 0)
         {
-            passesString = [NSString stringWithFormat:@"1 Video Pass"];
+            passesString = [passesString stringByAppendingString:@"1 Video Pass"];
         }
         else
         {
             if ([[item objectForKey:@"VideoTurboTwoPass"] intValue] == 1)
             {
-                passesString = [NSString stringWithFormat:@"2 Video Passes Turbo"];
+                passesString = [passesString stringByAppendingString:@"2 Video Passes First Turbo"];
             }
             else
             {
-                passesString = [NSString stringWithFormat:@"2 Video Passes"];
+                passesString = [passesString stringByAppendingString:@"2 Video Passes"];
             }
         }
         
@@ -892,10 +1009,10 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         /* Third Line  (Format Summary) */
         NSString * audioCodecSummary = @"";
         /* Lets also get our audio track detail since we are going through the logic for use later */
-        NSString * audioDetail1 = @"None";
-        NSString * audioDetail2 = @"None";
-        NSString * audioDetail3 = @"None";
-        NSString * audioDetail4 = @"None";
+        NSString * audioDetail1 = @"";
+        NSString * audioDetail2 = @"";
+        NSString * audioDetail3 = @"";
+        NSString * audioDetail4 = @"";
         if ([[item objectForKey:@"Audio1Track"] intValue] > 0)
         {
             audioCodecSummary = [NSString stringWithFormat:@"%@", [item objectForKey:@"Audio1Encoder"]];
@@ -906,7 +1023,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
                             [item objectForKey:@"Audio1Samplerate"],
                             [item objectForKey:@"Audio1Bitrate"]];
             
-            if ([[item objectForKey:@"Audio1TrackDRCSlider"] floatValue] > 1.00)
+            if ([[item objectForKey:@"Audio1TrackDRCSlider"] floatValue] > 0.00)
             {
                 audioDetail1 = [NSString stringWithFormat:@"%@, DRC: %@",audioDetail1,[item objectForKey:@"Audio1TrackDRCSlider"]];
             }
@@ -926,7 +1043,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
                             [item objectForKey:@"Audio2Samplerate"],
                             [item objectForKey:@"Audio2Bitrate"]];
             
-            if ([[item objectForKey:@"Audio2TrackDRCSlider"] floatValue] > 1.00)
+            if ([[item objectForKey:@"Audio2TrackDRCSlider"] floatValue] > 0.00)
             {
                 audioDetail2 = [NSString stringWithFormat:@"%@, DRC: %@",audioDetail2,[item objectForKey:@"Audio2TrackDRCSlider"]];
             }
@@ -946,7 +1063,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
                             [item objectForKey:@"Audio3Samplerate"],
                             [item objectForKey:@"Audio3Bitrate"]];
             
-            if ([[item objectForKey:@"Audio3TrackDRCSlider"] floatValue] > 1.00)
+            if ([[item objectForKey:@"Audio3TrackDRCSlider"] floatValue] > 0.00)
             {
                 audioDetail3 = [NSString stringWithFormat:@"%@, DRC: %@",audioDetail3,[item objectForKey:@"Audio3TrackDRCSlider"]];
             }
@@ -966,7 +1083,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
                             [item objectForKey:@"Audio4Samplerate"],
                             [item objectForKey:@"Audio4Bitrate"]];
             
-            if ([[item objectForKey:@"Audio4TrackDRCSlider"] floatValue] > 1.00)
+            if ([[item objectForKey:@"Audio4TrackDRCSlider"] floatValue] > 0.00)
             {
                 audioDetail4 = [NSString stringWithFormat:@"%@, DRC: %@",audioDetail4,[item objectForKey:@"Audio4TrackDRCSlider"]];
             }
@@ -1039,62 +1156,92 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         
         NSString * pictureFilters = @"";
         BOOL pictureFiltersPresent = NO;
-        if( [[item objectForKey:@"VFR"] intValue] == 1)
-        {
-            pictureFiltersPresent = YES;
-            pictureFilters = [pictureFilters stringByAppendingString:@" - VFR"];
-        }
-        if( [[item objectForKey:@"PictureDetelecine"] intValue] == 1 )
+        
+        if( [[item objectForKey:@"PictureDetelecine"] intValue] == 1)
         {
             pictureFiltersPresent = YES;
-            pictureFilters = [pictureFilters stringByAppendingString:@" - Detelecine"];
+            pictureFilters = [pictureFilters stringByAppendingString:[NSString stringWithFormat:@" - Detelecine (%@)",[item objectForKey:@"PictureDetelecineCustom"]]];
         }
-        
-        if( [[item objectForKey:@"PictureDecomb"] intValue] == 1)
+        else if( [[item objectForKey:@"PictureDetelecine"] intValue] == 2)
         {
             pictureFiltersPresent = YES;
-            pictureFilters = [pictureFilters stringByAppendingString:@" - Decomb "];
+            pictureFilters = [pictureFilters stringByAppendingString:@" - Detelecine (Default)"];
         }
         
-        if ([[item objectForKey:@"PictureDeinterlace"] intValue] != 0)
+        if( [[item objectForKey:@"PictureDecombDeinterlace"] intValue] == 1)
         {
-            pictureFiltersPresent = YES;
-            if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 1)
+            if ([[item objectForKey:@"PictureDecomb"] intValue] != 0)
             {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace: Fast "];
+                pictureFiltersPresent = YES;
+                if( [[item objectForKey:@"PictureDecomb"] intValue] == 1)
+                {
+                    pictureFiltersPresent = YES;
+                    pictureFilters = [pictureFilters stringByAppendingString:[NSString stringWithFormat:@" - Decomb (%@)",[item objectForKey:@"PictureDecombCustom"]]];
+                }
+                else if( [[item objectForKey:@"PictureDecomb"] intValue] == 2)
+                {
+                    pictureFiltersPresent = YES;
+                    pictureFilters = [pictureFilters stringByAppendingString:@" - Decomb (Default)"];
+                }
             }
-            else if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 2)
-            {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace: Slow "];           
-            }
-            else if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 3)
+        }
+        else
+        {
+            if ([[item objectForKey:@"PictureDeinterlace"] intValue] != 0)
             {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace: Slower "];            
+                pictureFiltersPresent = YES;
+                if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 1)
+                {
+                    pictureFilters = [pictureFilters stringByAppendingString:[NSString stringWithFormat:@" - Deinterlace (%@)",[item objectForKey:@"PictureDeinterlaceCustom"]]];            
+                }
+                else if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 2)
+                {
+                    pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace (Fast)"];
+                }
+                else if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 3)
+                {
+                    pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace (Slow)"];           
+                }
+                else if ([[item objectForKey:@"PictureDeinterlace"] intValue] == 4)
+                {
+                    pictureFilters = [pictureFilters stringByAppendingString:@" - Deinterlace (Slower)"];            
+                }
+                
             }
-            
         }
         if ([[item objectForKey:@"PictureDenoise"] intValue] != 0)
         {
             pictureFiltersPresent = YES;
             if ([[item objectForKey:@"PictureDenoise"] intValue] == 1)
             {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise: Weak "];
+                pictureFilters = [pictureFilters stringByAppendingString:[NSString stringWithFormat:@" - Denoise (%@)",[item objectForKey:@"PictureDenoiseCustom"]]];            
             }
             else if ([[item objectForKey:@"PictureDenoise"] intValue] == 2)
             {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise: Medium "];           
+                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise (Weak)"];
             }
             else if ([[item objectForKey:@"PictureDenoise"] intValue] == 3)
             {
-                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise: Strong "];            
+                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise (Medium)"];           
+            }
+            else if ([[item objectForKey:@"PictureDenoise"] intValue] == 4)
+            {
+                pictureFilters = [pictureFilters stringByAppendingString:@" - Denoise (Strong)"];            
             }
             
         }
         if ([[item objectForKey:@"PictureDeblock"] intValue] != 0)
         {
             pictureFiltersPresent = YES;
-            pictureFilters = [pictureFilters stringByAppendingString: [NSString stringWithFormat:@" - Deblock (pp7) (%d) ",[[item objectForKey:@"PictureDeblock"] intValue]]];
+            pictureFilters = [pictureFilters stringByAppendingString: [NSString stringWithFormat:@" - Deblock (pp7) (%d)",[[item objectForKey:@"PictureDeblock"] intValue]]];
+        }
+        
+        if ([[item objectForKey:@"VideoGrayScale"] intValue] == 1)
+        {
+            pictureFiltersPresent = YES;
+            pictureFilters = [pictureFilters stringByAppendingString:@" - Grayscale"];
         }
+        
         if (pictureFiltersPresent == YES)
         {
             [finalString appendString: @"Filters: " withAttributes:detailBoldAttr];
@@ -1136,7 +1283,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         }
         else // CRF
         {
-            videoInfo = [NSString stringWithFormat:@"%@ Constant Quality: %.0f %%", videoInfo ,[[item objectForKey:@"VideoQualitySlider"] floatValue] * 100];
+            videoInfo = [NSString stringWithFormat:@"%@ Constant Quality: %.2f", videoInfo ,[[item objectForKey:@"VideoQualitySlider"] floatValue]];
         }
         
         [finalString appendString: @"Video: " withAttributes:detailBoldAttr];
@@ -1151,21 +1298,66 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
         }
         
         
+        
         /* Seventh Line Audio Details*/
-        [finalString appendString: @"Audio Track 1: " withAttributes:detailBoldAttr];
-        [finalString appendString: audioDetail1 withAttributes:detailAttr];
-        [finalString appendString:@"\n" withAttributes:detailAttr];
+        if ([audioDetail1 length] != 0)
+        {
+            [finalString appendString: @"Audio Track 1: " withAttributes:detailBoldAttr];
+            [finalString appendString: audioDetail1 withAttributes:detailAttr];
+            [finalString appendString:@"\n" withAttributes:detailAttr];
+        }
         
-        [finalString appendString: @"Audio Track 2: " withAttributes:detailBoldAttr];
-        [finalString appendString: audioDetail2 withAttributes:detailAttr];
-        [finalString appendString:@"\n" withAttributes:detailAttr];
+        if ([audioDetail2 length] != 0)
+        {
+            [finalString appendString: @"Audio Track 2: " withAttributes:detailBoldAttr];
+            [finalString appendString: audioDetail2 withAttributes:detailAttr];
+            [finalString appendString:@"\n" withAttributes:detailAttr];
+        }
         
-        [finalString appendString: @"Audio Track 3: " withAttributes:detailBoldAttr];
-        [finalString appendString: audioDetail3 withAttributes:detailAttr];
-        [finalString appendString:@"\n" withAttributes:detailAttr];
+        if ([audioDetail3 length] != 0)
+        {
+            [finalString appendString: @"Audio Track 3: " withAttributes:detailBoldAttr];
+            [finalString appendString: audioDetail3 withAttributes:detailAttr];
+            [finalString appendString:@"\n" withAttributes:detailAttr];
+        }
+        
+        if ([audioDetail4 length] != 0)
+        {
+            [finalString appendString: @"Audio Track 4: " withAttributes:detailBoldAttr];
+            [finalString appendString: audioDetail4 withAttributes:detailAttr];
+            [finalString appendString:@"\n" withAttributes:detailAttr];
+        }
+        /* Eighth Line Subtitle Details */
         
-        [finalString appendString: @"Audio Track 4: " withAttributes:detailBoldAttr];
-        [finalString appendString: audioDetail4 withAttributes:detailAttr];
+        int i = 0;
+        NSEnumerator *enumerator = [[item objectForKey:@"SubtitleList"] objectEnumerator];
+        id tempObject;
+        while (tempObject = [enumerator nextObject])
+        {
+            /* since the subtitleSourceTrackNum 0 is "None" in our array of the subtitle popups,
+             * we want to ignore it for display as well as encoding.
+             */
+            if ([[tempObject objectForKey:@"subtitleSourceTrackNum"] intValue] > 0)
+            { 
+                /* remember that index 0 of Subtitles can contain "Foreign Audio Search*/
+                [finalString appendString: @"Subtitle: " withAttributes:detailBoldAttr];
+                [finalString appendString: [tempObject objectForKey:@"subtitleSourceTrackName"] withAttributes:detailAttr];
+                if ([[tempObject objectForKey:@"subtitleTrackForced"] intValue] == 1)
+                {
+                    [finalString appendString: @" - Forced Only" withAttributes:detailAttr];
+                }
+                if ([[tempObject objectForKey:@"subtitleTrackBurned"] intValue] == 1)
+                {
+                    [finalString appendString: @" - Burned In" withAttributes:detailAttr];
+                }
+                if ([[tempObject objectForKey:@"subtitleTrackDefault"] intValue] == 1)
+                {
+                    [finalString appendString: @" - Default" withAttributes:detailAttr];
+                }
+                [finalString appendString:@"\n" withAttributes:detailAttr];
+            }
+            i++;
+        }      
         
         return finalString;
     }
@@ -1257,7 +1449,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
 {
     // Dragging is only allowed of the pending items.
-    if ([[[fJobGroups objectAtIndex:[outlineView selectedRow]] objectForKey:@"Status"] intValue] != 2) // 2 is pending
+    if ([[[items objectAtIndex:0] objectForKey:@"Status"] integerValue] != 2) // 2 is pending
     {
         return NO;
     }
@@ -1307,18 +1499,13 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
     return NSDragOperationGeneric;
 }
 
-
-
 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
 {
-        NSMutableIndexSet *moveItems = [NSMutableIndexSet indexSet];
-    
-    id obj;
-    NSEnumerator *enumerator = [fDraggedNodes objectEnumerator];
-    while (obj = [enumerator nextObject])
-    {
+    NSMutableIndexSet *moveItems = [NSMutableIndexSet indexSet];
+
+    for( id obj in fDraggedNodes )
         [moveItems addIndex:[fJobGroups indexOfObject:obj]];
-    }
+
     // Successful drop, we use moveObjectsInQueueArray:... in fHBController
     // to properly rearrange the queue array, save it to plist and then send it back here.
     // since Controller.mm is handling all queue array manipulation.
diff --git a/macosx/HBSubtitles.h b/macosx/HBSubtitles.h
new file mode 100644 (file)
index 0000000..6cc5535
--- /dev/null
@@ -0,0 +1,55 @@
+/* $Id: HBSubtitles.h,v 1.35 2005/08/01 14:29:50 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+#include "hb.h"
+
+
+
+
+@interface HBSubtitles : NSObject {
+hb_title_t                   *fTitle;
+
+NSMutableArray               *subtitleArray; // contains the output subtitle track info
+NSMutableArray               *subtitleSourceArray;// contains the source subtitle track info
+NSMutableArray               *languagesArray; // array of languages taken from lang.c
+int                           languagesArrayDefIndex;
+NSMutableArray               *charCodeArray; // array of character codes
+int                           charCodeArrayDefIndex;
+int                           container;
+
+}
+
+// Trigger a refresh of data
+- (void)resetWithTitle:(hb_title_t *)title;
+
+// Create new subtitle track
+- (void)addSubtitleTrack;
+- (NSDictionary *)createSubtitleTrack;
+- (NSMutableArray*) getSubtitleArray: (NSMutableArray *) subtitlesArray ;
+// Add an srt file
+- (void)createSubtitleSrtTrack:(NSString *)filePath;
+
+- (void)containerChanged:(int) newContainer;
+
+// Table View Delegates
+- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
+
+- (id)tableView:(NSTableView *)aTableView
+      objectValueForTableColumn:(NSTableColumn *)aTableColumn
+      row:(NSInteger)rowIndex;
+      
+- (void)tableView:(NSTableView *)aTableView
+        setObjectValue:(id)anObject
+        forTableColumn:(NSTableColumn *)aTableColumn
+        row:(NSInteger)rowIndex;
+
+- (void)tableView:(NSTableView *)aTableView
+        willDisplayCell:(id)aCell
+        forTableColumn:(NSTableColumn *)aTableColumn
+        row:(NSInteger)rowIndex;
+
+@end
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m
new file mode 100644 (file)
index 0000000..95ffad0
--- /dev/null
@@ -0,0 +1,919 @@
+/* $Id: HBSubtitles.m,v 1.35 2005/08/01 14:29:50 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+//
+
+#import "HBSubtitles.h"
+#include "hb.h"
+
+
+
+
+
+
+
+
+@implementation HBSubtitles
+- (id)init 
+{
+    self = [super init];
+    if( self != nil )
+    {
+        fTitle = NULL;
+    }
+    
+    /* setup our array of languages */
+    languagesArray = [[NSMutableArray alloc] init];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Any",@"und",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Afar",@"aar",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Abkhazian",@"abk",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Afrikaans",@"afr",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Akan",@"ak",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Albanian",@"sqi",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Amharic",@"amh",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Arabic",@"ara",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Aragonese",@"arg",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Armenian",@"hye",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Assamese",@"asm",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Avaric",@"ava",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Avestan",@"ave",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Aymara",@"aym",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Azerbaijani",@"aze",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bashkir",@"bak",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bambara",@"bam",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Basque",@"eus",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Belarusian",@"bel",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bengali",@"ben",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bihari",@"bih",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bislama",@"bis",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bosnian",@"bos",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Breton",@"bre",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Bulgarian",@"bul",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Burmese",@"mya",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Catalan",@"cat",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Chamorro",@"cha",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Chechen",@"che",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Chinese",@"zho",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Church Slavic",@"chu",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Chuvash",@"chv",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Cornish",@"cor",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Corsican",@"cos",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Cree",@"cre",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Czech",@"ces",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Danish",@"dan",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Divehi",@"div",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Dutch",@"nld",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Dzongkha",@"dzo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"English",@"eng",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Esperanto",@"epo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Estonian",@"est",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ewe",@"ewe",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Faroese",@"fao",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Fijian",@"fij",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Finnish",@"fin",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"French",@"fra",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Western Frisian",@"fry",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Fulah",@"ful",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Georgian",@"kat",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"German",@"deu",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Gaelic (Scots)",@"gla",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Irish",@"gle",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Galician",@"glg",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Manx",@"glv",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Greek, Modern",@"ell",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Guarani",@"grn",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Gujarati",@"guj",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Haitian",@"hat",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Hausa",@"hau",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Hebrew",@"heb",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Herero",@"her",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Hindi",@"hin",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Hiri Motu",@"hmo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Hungarian",@"hun",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Igbo",@"ibo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Icelandic",@"isl",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ido",@"ido",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sichuan Yi",@"iii",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Inuktitut",@"iku",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Interlingue",@"ile",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Interlingua",@"ina",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Indonesian",@"ind",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Inupiaq",@"ipk",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Italian",@"ita",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Javanese",@"jav",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Japanese",@"jpn",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kalaallisut (Greenlandic)",@"kal",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kannada",@"kan",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kashmiri",@"kas",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kanuri",@"kau",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kazakh",@"kaz",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Central Khmer",@"khm",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kikuyu",@"kik",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kinyarwanda",@"kin",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kirghiz",@"kir",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Komi",@"kom",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kongo",@"kon",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Korean",@"kor",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kuanyama",@"kua",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Kurdish",@"kur",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Lao",@"lao",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Latin",@"lat",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Latvian",@"lav",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Limburgan",@"lim",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Lingala",@"lin",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Lithuanian",@"lit",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Luxembourgish",@"ltz",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Luba-Katanga",@"lub",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ganda",@"lug",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Macedonian",@"mkd",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Marshallese",@"mah",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Malayalam",@"mal",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Maori",@"mri",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Marathi",@"mar",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Malay",@"msa",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Malagasy",@"mlg",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Maltese",@"mlt",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Moldavian",@"mol",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Mongolian",@"mon",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Nauru",@"nau",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Navajo",@"nav",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ndebele, South",@"nbl",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ndebele, North",@"nde",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ndonga",@"ndo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Nepali",@"nep",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Norwegian Nynorsk",@"nno",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Norwegian BokmÃ¥l",@"nob",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Norwegian",@"nor",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Chichewa; Nyanja",@"nya",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Occitan (post 1500); Provençal",@"oci",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ojibwa",@"oji",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Oriya",@"ori",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Oromo",@"orm",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ossetian; Ossetic",@"und",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Panjabi",@"pan",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Persian",@"fas",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Pali",@"pli",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Portuguese",@"por",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Pushto",@"pus",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Quechua",@"que",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Romansh",@"roh",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Romanian",@"ron",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Rundi",@"run",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Russian",@"rus",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sango",@"sag",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sanskrit",@"san",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Serbian",@"srp",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Croatian",@"hrv",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sinhala",@"sin",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Slovak",@"slk",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Slovenian",@"slv",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Northern Sami",@"sme",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Samoan",@"smo",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Shona",@"sna",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sindhi",@"snd",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Somali",@"som",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sotho, Southern",@"sot",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Spanish",@"spa",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sardinian",@"srd",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Swati",@"ssw",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Sundanese",@"sun",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Swahili",@"swa",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Swedish",@"swe",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tahitian",@"tah",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tamil",@"tam",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tatar",@"tat",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Telugu",@"tel",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tajik",@"tgk",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tagalog",@"tgl",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Thai",@"tha",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tibetan",@"bod",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tigrinya",@"tir",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tonga (Tonga Islands)",@"ton",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tswana",@"tsn",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Tsonga",@"tso",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Turkmen",@"tuk",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Turkish",@"tur",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Twi",@"twi",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Uighur",@"uig",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Ukrainian",@"ukr",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Urdu",@"urd",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Uzbek",@"uzb",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Venda",@"ven",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Vietnamese",@"vie",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Volapük",@"vol",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Welsh",@"cym",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Walloon",@"wln",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Wolof",@"wol",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Xhosa",@"xho",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Yiddish",@"yid",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Yoruba",@"yor",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"ZhuangZhuang",@"zha",nil]];
+    [languagesArray addObject:[NSArray arrayWithObjects:@"Zulu",@"zul",nil]];
+   
+    languagesArrayDefIndex = 40;
+   
+    /* populate the charCodeArray */
+    charCodeArray = [[NSMutableArray alloc] init];
+    [charCodeArray addObject:@"ANSI_X3.4-1968"];
+    [charCodeArray addObject:@"ANSI_X3.4-1986"];
+    [charCodeArray addObject:@"ANSI_X3.4"];
+    [charCodeArray addObject:@"ANSI_X3.110-1983"];
+    [charCodeArray addObject:@"ANSI_X3.110"];
+    [charCodeArray addObject:@"ASCII"];
+    [charCodeArray addObject:@"ECMA-114"];
+    [charCodeArray addObject:@"ECMA-118"];
+    [charCodeArray addObject:@"ECMA-128"];
+    [charCodeArray addObject:@"ECMA-CYRILLIC"];
+    [charCodeArray addObject:@"IEC_P27-1"];
+    [charCodeArray addObject:@"ISO-8859-1"];
+    [charCodeArray addObject:@"ISO-8859-2"];
+    [charCodeArray addObject:@"ISO-8859-3"];
+    [charCodeArray addObject:@"ISO-8859-4"];
+    [charCodeArray addObject:@"ISO-8859-5"];
+    [charCodeArray addObject:@"ISO-8859-6"];
+    [charCodeArray addObject:@"ISO-8859-7"];
+    [charCodeArray addObject:@"ISO-8859-8"];
+    [charCodeArray addObject:@"ISO-8859-9"];
+    [charCodeArray addObject:@"ISO-8859-9E"];
+    [charCodeArray addObject:@"ISO-8859-10"];
+    [charCodeArray addObject:@"ISO-8859-11"];
+    [charCodeArray addObject:@"ISO-8859-13"];
+    [charCodeArray addObject:@"ISO-8859-14"];
+    [charCodeArray addObject:@"ISO-8859-15"];
+    [charCodeArray addObject:@"ISO-8859-16"];
+    [charCodeArray addObject:@"UTF-7"];
+    [charCodeArray addObject:@"UTF-8"];
+    [charCodeArray addObject:@"UTF-16"];
+    [charCodeArray addObject:@"UTF-16LE"];
+    [charCodeArray addObject:@"UTF-16BE"];
+    [charCodeArray addObject:@"UTF-32"];
+    [charCodeArray addObject:@"UTF-32LE"];
+    [charCodeArray addObject:@"UTF-32BE"];
+    
+    charCodeArrayDefIndex = 11;
+    
+    return self;
+}
+
+
+- (void)resetWithTitle:(hb_title_t *)title
+{
+    fTitle = title;
+    
+    if (!title)
+    {
+        return;
+    }
+    
+    /* reset the subtitle source array */
+    if (subtitleSourceArray)
+    {
+        [subtitleSourceArray release];
+    }
+    subtitleSourceArray = [[NSMutableArray alloc] init];
+    
+    /* now populate the array with the source subtitle track info */
+    if (fTitle)
+        {
+            hb_subtitle_t *subtitle;
+            hb_subtitle_config_t sub_config;
+            int i;
+            for(i = 0; i < hb_list_count( fTitle->list_subtitle ); i++ )
+            {
+                NSString * trackTypeString = @"";
+                int isPictureSub = 0;
+                subtitle = (hb_subtitle_t *) hb_list_item( fTitle->list_subtitle, i );
+                sub_config = subtitle->config;
+                
+                if (subtitle->format == PICTURESUB)
+                {
+                    trackTypeString = @"- (Bitmap)";
+                    isPictureSub = 1;
+                }
+                else
+                {
+                    trackTypeString = @"- (Text)";
+                }
+                
+                /* create a dictionary of source subtitle information to store in our array */
+                NSString *popupName = [NSString stringWithFormat:@"%d - %@ %@",i,[NSString stringWithUTF8String:subtitle->lang],trackTypeString];
+                NSMutableDictionary *newSubtitleSourceTrack = [[NSMutableDictionary alloc] init];
+                /* Subtitle Source track popup index */
+                [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:i] forKey:@"sourceTrackNum"];
+                /* Subtitle Source track type */
+                [newSubtitleSourceTrack setObject:popupName forKey:@"sourceTrackName"];
+                /* Subtitle Source track type (Source, Srt, etc.) */
+                [newSubtitleSourceTrack setObject:@"Source" forKey:@"sourceTrackType"];
+                /* Subtitle Source track popup isPictureSub */ 
+                [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:isPictureSub] forKey:@"sourceTrackisPictureSub"];
+                
+                [subtitleSourceArray addObject:newSubtitleSourceTrack];
+                [newSubtitleSourceTrack autorelease];
+            }
+        }
+    
+    
+    
+    /* reset the subtitle output array */
+    if (subtitleArray)
+    {
+        [subtitleArray release];
+    }
+    subtitleArray = [[NSMutableArray alloc] init];
+    [self addSubtitleTrack];
+}
+
+#pragma mark -
+#pragma mark Create new Subtitles
+
+- (void)addSubtitleTrack
+{
+    [subtitleArray addObject:[self createSubtitleTrack]];
+}
+
+/* Creates a new subtitle track and stores it in an NSMutableDictionary */
+- (NSDictionary *)createSubtitleTrack
+{
+    NSMutableDictionary *newSubtitleTrack = [[NSMutableDictionary alloc] init];
+    /* Subtitle Source track popup index */
+    [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackNum"];
+    /* Subtitle Source track popup language */
+    [newSubtitleTrack setObject:@"None" forKey:@"subtitleSourceTrackName"];
+    /* Subtitle Source track popup isPictureSub */
+    [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackisPictureSub"];
+    /* Subtitle track forced state */
+    [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
+    /* Subtitle track burned state */
+    [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+    /* Subtitle track default state */
+    [newSubtitleTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
+
+    [newSubtitleTrack autorelease];
+    return newSubtitleTrack;
+}
+
+- (void)createSubtitleSrtTrack:(NSString *)filePath
+{
+    /* Create a new entry for the subtitle source array so it shows up in our subtitle source list */
+    NSString *displayname = [filePath lastPathComponent];// grok an appropriate display name from the srt subtitle */
+    /* create a dictionary of source subtitle information to store in our array */
+    NSMutableDictionary *newSubtitleSourceTrack = [[NSMutableDictionary alloc] init];
+    /* Subtitle Source track popup index */
+    [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count]+1] forKey:@"sourceTrackNum"];
+    /* Subtitle Source track type */
+    [newSubtitleSourceTrack setObject:displayname forKey:@"sourceTrackName"];
+    /* Subtitle Source track type (Source, Srt, etc.) */
+    [newSubtitleSourceTrack setObject:@"SRT" forKey:@"sourceTrackType"];
+    [newSubtitleSourceTrack setObject:@"SRT" forKey:@"subtitleSourceTrackType"];
+    /* Subtitle Source track type */
+    [newSubtitleSourceTrack setObject:filePath forKey:@"sourceSrtFilePath"];
+    /* Subtitle Source track popup isPictureSub */ 
+    [newSubtitleSourceTrack setObject:[NSNumber numberWithInt:0] forKey:@"sourceTrackisPictureSub"];
+    
+    [subtitleSourceArray addObject:newSubtitleSourceTrack];
+    [newSubtitleSourceTrack autorelease];
+    
+    /* Now create a new srt subtitle dictionary assuming the user wants to add it to their list 
+     * Note: the subtitle array always has last entry for "None", so we need to replace its
+     * position in the array and tack a "None" track back on the end of the list */
+    [subtitleArray removeObjectAtIndex:[subtitleArray count] - 1];
+    
+    
+    NSMutableDictionary *newSubtitleSrtTrack = [[NSMutableDictionary alloc] init];
+    /* Subtitle Source track popup index */
+    if ([subtitleArray count] == 0) // we now have an empty array so this will be our first track
+    {
+        [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count] + 1] forKey:@"subtitleSourceTrackNum"];
+    }
+    else
+    {
+        [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count]] forKey:@"subtitleSourceTrackNum"];
+    }
+    
+    [newSubtitleSrtTrack setObject:@"SRT" forKey:@"sourceTrackType"];
+    [newSubtitleSrtTrack setObject:@"SRT" forKey:@"subtitleSourceTrackType"];
+    /* Subtitle Source track popup language */
+    [newSubtitleSrtTrack setObject:displayname forKey:@"subtitleSourceTrackName"];
+    /* Subtitle Source track popup isPictureSub */
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackisPictureSub"];
+    /* Subtitle track forced state */
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackForced"];
+    /* Subtitle track burned state */
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+    /* Subtitle track default state */
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
+    
+    /* now the srt only info, Language, Chart Code and offset */
+    [newSubtitleSrtTrack setObject:filePath forKey:@"subtitleSourceSrtFilePath"];
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
+    [newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
+    [newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
+    
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:charCodeArrayDefIndex] forKey:@"subtitleTrackSrtCharCodeIndex"];
+    [newSubtitleSrtTrack setObject:[charCodeArray objectAtIndex:charCodeArrayDefIndex] forKey:@"subtitleTrackSrtCharCode"];
+                    
+    [newSubtitleSrtTrack setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackSrtOffset"];
+    
+    
+    [subtitleArray addObject:newSubtitleSrtTrack];
+    [newSubtitleSrtTrack release];
+    
+    /* now add back the none track to the end of the array */
+    [self addSubtitleTrack];
+    
+    
+}
+
+- (NSMutableArray*) getSubtitleArray: (NSMutableArray *) subtitlesArray 
+{
+    return subtitleArray;
+}
+
+- (void)containerChanged:(int) newContainer
+{
+container = newContainer;
+}
+   
+#pragma mark -
+#pragma mark Subtitle Table Delegate Methods
+/* Table View delegate methods */
+/* Returns the number of tracks displayed
+ * NOTE: we return one more than the actual number of tracks
+ * specified as we always keep one track set to "None" which is ignored
+ * for setting up tracks, but is used to add tracks.
+ */
+- (int)numberOfRowsInTableView:(NSTableView *)aTableView
+{
+    if( fTitle == NULL || ![subtitleArray count])
+    {
+        return 0;
+    }
+    else
+    {
+        return [subtitleArray count];
+    }
+}
+
+/* Used to tell the Table view which information is to be displayed per item */
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+    NSString *cellEntry = @"__DATA ERROR__";
+    
+    /* we setup whats displayed given the column identifier */
+    if ([[aTableColumn identifier] isEqualToString:@"track"])
+    {
+        /* 'track' is a popup of all available source subtitle tracks for the given title */
+        NSPopUpButtonCell *cellTrackPopup = [[NSPopUpButtonCell alloc] init];
+        [cellTrackPopup autorelease];
+        /* Set the Popups properties */
+        [cellTrackPopup setControlSize:NSSmallControlSize];
+        [cellTrackPopup setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
+        
+        
+        /* Add our initial "None" track which we use to add source tracks or remove tracks.
+         * "None" is always index 0.
+         */
+        [[cellTrackPopup menu] addItemWithTitle: @"None" action: NULL keyEquivalent: @""];
+        
+        /* Foreign Audio Search (index 1 in the popup) is only available for the first track */
+        if (rowIndex == 0)
+        {
+            [[cellTrackPopup menu] addItemWithTitle: @"Foreign Audio Search - (Bitmap)" action: NULL keyEquivalent: @""];
+        }
+        
+        int i;
+        for(i = 0; i < [subtitleSourceArray count]; i++ )
+        {
+            [[cellTrackPopup menu] addItemWithTitle: [[subtitleSourceArray objectAtIndex:i] objectForKey: @"sourceTrackName"] action: NULL keyEquivalent: @""]; 
+        }
+        
+        
+        [aTableColumn setDataCell:cellTrackPopup];
+        
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"forced"])
+    {
+        /* 'forced' is a checkbox to determine if a given source track is only to be forced */
+        NSButtonCell *cellForcedCheckBox = [[NSButtonCell alloc] init];
+        [cellForcedCheckBox autorelease];
+        [cellForcedCheckBox setButtonType:NSSwitchButton];
+        [cellForcedCheckBox setImagePosition:NSImageOnly];
+        [cellForcedCheckBox setAllowsMixedState:NO];
+        [aTableColumn setDataCell:cellForcedCheckBox];
+        
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"burned"])
+    {
+        /* 'burned' is a checkbox to determine if a given source track is only to be burned */
+        NSButtonCell *cellBurnedCheckBox = [[NSButtonCell alloc] init];
+        [cellBurnedCheckBox autorelease];
+        [cellBurnedCheckBox setButtonType:NSSwitchButton];
+        [cellBurnedCheckBox setImagePosition:NSImageOnly];
+        [cellBurnedCheckBox setAllowsMixedState:NO];
+        [aTableColumn setDataCell:cellBurnedCheckBox];
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"default"])
+    {
+        NSButtonCell *cellDefaultCheckBox = [[NSButtonCell alloc] init];
+        [cellDefaultCheckBox autorelease];
+        [cellDefaultCheckBox setButtonType:NSSwitchButton];
+        [cellDefaultCheckBox setImagePosition:NSImageOnly];
+        [cellDefaultCheckBox setAllowsMixedState:NO];
+        [aTableColumn setDataCell:cellDefaultCheckBox];
+    }
+    /* These next three columns only apply to srt's. they are disabled for source subs */
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_lang"])
+    {
+        /* 'srt_lang' is a popup of commonly used languages to be matched to the source srt file */
+        NSPopUpButtonCell *cellSrtLangPopup = [[NSPopUpButtonCell alloc] init];
+        [cellSrtLangPopup autorelease];
+        /* Set the Popups properties */
+        [cellSrtLangPopup setControlSize:NSSmallControlSize];
+        [cellSrtLangPopup setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
+        /* list our languages as per the languagesArray */
+        int i;
+        for(i = 0; i < [languagesArray count]; i++ )
+        {
+            [[cellSrtLangPopup menu] addItemWithTitle: [[languagesArray objectAtIndex:i] objectAtIndex:0] action: NULL keyEquivalent: @""]; 
+        }
+        [aTableColumn setDataCell:cellSrtLangPopup]; 
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_charcode"])
+    {
+        /* 'srt_charcode' is a popup of commonly used character codes to be matched to the source srt file */
+        NSPopUpButtonCell *cellSrtCharCodePopup = [[NSPopUpButtonCell alloc] init];
+        [cellSrtCharCodePopup autorelease];
+        /* Set the Popups properties */
+        [cellSrtCharCodePopup setControlSize:NSSmallControlSize];
+        [cellSrtCharCodePopup setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
+        /* list our character codes, as per charCodeArray */
+        
+        int i;
+        for(i = 0; i < [charCodeArray count]; i++ )
+        {
+            [[cellSrtCharCodePopup menu] addItemWithTitle: [charCodeArray objectAtIndex:i] action: NULL keyEquivalent: @""]; 
+        }
+        [aTableColumn setDataCell:cellSrtCharCodePopup];
+        
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_offset"])
+    {
+        if ([[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtOffset"])
+        {
+            cellEntry = [NSString stringWithFormat:@"%d",[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtOffset"] intValue]];
+        }
+        else
+        {
+            cellEntry = [NSString stringWithFormat:@"%d",0];
+        }
+    }
+    else
+    {
+        cellEntry = nil;    
+    }
+    
+    return cellEntry;
+}
+
+/* Called whenever a widget in the table is edited or changed, we use it to record the change in the controlling array 
+ * including removing and adding new tracks via the "None" ("track" index of 0) */
+- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+    
+    if ([[aTableColumn identifier] isEqualToString:@"track"])
+    {
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleSourceTrackNum"];
+        /* Set the array to track if we are vobsub (picture sub) */
+        if ([anObject intValue] != 0)
+        {
+            int sourceSubtitleIndex;
+            bool isPictureSub = FALSE;
+            
+            if (rowIndex == 0)
+            {
+                sourceSubtitleIndex = [anObject intValue] - 2;
+            }
+            else
+            {
+                sourceSubtitleIndex = [anObject intValue] - 1;
+            }
+            
+            if (rowIndex == 0 && [anObject intValue] == 1)// we are Foreign Launguage Search, which is inherently bitmap
+            {
+                isPictureSub = TRUE;
+            }
+            else
+            {
+                if ([[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackisPictureSub"] intValue] ==1)
+                {
+                    isPictureSub = TRUE;
+                }
+            }
+            if (isPictureSub == TRUE)
+            {
+                [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleSourceTrackisPictureSub"];
+            }
+            else
+            {
+                [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleSourceTrackisPictureSub"];
+                /* if we are not picture sub, then we must be a text sub, handbrake does not support burning in text subs */
+                [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+            }
+            
+            /* check to see if we are an srt, in which case set our file path and source track type kvp's*/
+            
+            if (rowIndex == 0 && [anObject intValue] == 1) // we are foreign lang search
+            {
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:@"Source" forKey:@"subtitleSourceTrackType"];  
+            }
+            else
+            {
+                if ([[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceTrackType"] isEqualToString:@"SRT"])
+                {
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:@"SRT" forKey:@"subtitleSourceTrackType"];
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[[subtitleSourceArray objectAtIndex:sourceSubtitleIndex] objectForKey:@"sourceSrtFilePath"] forKey:@"subtitleSourceSrtFilePath"];
+                }
+                else
+                {
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:@"Source" forKey:@"subtitleSourceTrackType"];
+                }
+            } 
+            
+        }
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"forced"])
+    {
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleTrackForced"];   
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"burned"])
+    {
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleTrackBurned"];   
+        /* now we need to make sure no other tracks are set to burned if we have set burned*/
+        if ([anObject intValue] == 1)
+        {
+            int i = 0;
+            NSEnumerator *enumerator = [subtitleArray objectEnumerator];
+            id tempObject;
+            while ( tempObject = [enumerator nextObject] )  
+            {
+                if (i != rowIndex )
+                {
+                    [tempObject setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackBurned"];
+                }
+                i++;
+            }
+        }
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"default"])
+    {
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleTrackDefault"];   
+        /* now we need to make sure no other tracks are set to default */
+        if ([anObject intValue] == 1)
+        {
+            int i = 0;
+            NSEnumerator *enumerator = [subtitleArray objectEnumerator];
+            id tempObject;
+            while ( tempObject = [enumerator nextObject] )  
+            {
+                if (i != rowIndex)
+                {
+                    [tempObject setObject:[NSNumber numberWithInt:0] forKey:@"subtitleTrackDefault"];
+                }
+                i++;
+            }
+        }
+        
+    }
+    /* These next three columns only apply to srt's. they are disabled for source subs */
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_lang"])
+    {
+        
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleTrackSrtLanguageIndex"];
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:[anObject intValue]] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:[anObject intValue]] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
+        
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_charcode"])
+    {
+        /* charCodeArray */
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[anObject intValue]] forKey:@"subtitleTrackSrtCharCodeIndex"];
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[charCodeArray objectAtIndex:[anObject intValue]] forKey:@"subtitleTrackSrtCharCode"];
+    }
+    else if ([[aTableColumn identifier] isEqualToString:@"srt_offset"])
+    {
+        [[subtitleArray objectAtIndex:rowIndex] setObject:anObject forKey:@"subtitleTrackSrtOffset"];  
+    } 
+    
+    
+    /* now lets do a bit of logic to add / remove tracks as necessary via the "None" track (index 0) */
+    if ([[aTableColumn identifier] isEqualToString:@"track"])
+    {
+        
+        /* since mp4 only supports burned in vobsubs (bitmap) we need to make sure burned in is specified */
+        if (container == HB_MUX_MP4 && [anObject intValue] != 0)
+        {
+            /* so, if isPictureSub = TRUE and we are mp4, we now have to A) set burned-in to 1 and b) remove any other
+             * tracks specified that are burned in */
+            if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackisPictureSub"] intValue] == 1)
+            {
+                [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:1] forKey:@"subtitleTrackBurned"];
+            }
+        }
+        
+        
+        /* We use the track popup index number (presumes index 0 is "None" which is ignored and only used to remove tracks if need be)
+         * to determine whether to 1 modify an existing track, 2. add a new empty "None" track or 3. remove an existing track.
+         */
+        
+        if ([anObject intValue] != 0 && rowIndex == [subtitleArray count] - 1) // if we have a last track which != "None"
+        {
+            /* add a new empty None track */
+            [self addSubtitleTrack];
+            
+        }
+        else if ([anObject intValue] == 0 && rowIndex != ([subtitleArray count] -1))// if this track is set to "None" and not the last track displayed
+        {
+            /* we know the user chose to remove this track by setting it to None, so remove it from the array */
+            /* However,if this is the first track we have to reset the selected index of the next track by + 1, since it will now become
+             * the first track, which has to account for the extra "Foreign Language Search" index. */
+            if (rowIndex == 0 && [[[subtitleArray objectAtIndex: 1] objectForKey: @"subtitleSourceTrackNum"] intValue] != 0)
+            {
+                /* get the index of the selection in row one (which is track two) */
+                int trackOneSelectedIndex = [[[subtitleArray objectAtIndex: 1] objectForKey: @"subtitleSourceTrackNum"] intValue];
+                /* increment the index of the subtitle menu item by one, to account for Foreign Language Search which is unique to the first track */
+                [[subtitleArray objectAtIndex: 1] setObject:[NSNumber numberWithInt:trackOneSelectedIndex + 1] forKey:@"subtitleSourceTrackNum"];
+            }
+            /* now that we have made the adjustment for track one (index 0) go ahead and delete the track */
+            [subtitleArray removeObjectAtIndex: rowIndex]; 
+        }
+        
+        
+        
+    }
+    
+    [aTableView reloadData];
+}
+
+
+/* Gives fine grained control over the final drawing of the widget, including widget status via the controlling array */
+- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+    /* we setup whats displayed given the column identifier */
+    if ([[aTableColumn identifier] isEqualToString:@"track"])
+    {
+        /* Set the index of the recorded source track here */
+        [aCell selectItemAtIndex:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue]];
+        /* now that we have actually selected our track, we can grok the titleOfSelectedItem for that track */
+        [[subtitleArray objectAtIndex:rowIndex] setObject:[[aTableColumn dataCellForRow:rowIndex] titleOfSelectedItem] forKey:@"subtitleSourceTrackName"];
+        
+    }
+    else
+    {
+        
+        [aCell setAlignment:NSCenterTextAlignment];
+        /* If the Track is None, we disable the other cells as None is an empty track */
+        if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] == 0)
+        {
+            [aCell setState:0];
+            [aCell setEnabled:NO];
+        }
+        else
+        {
+            /* Since we have a valid track, we go ahead and enable the rest of the widgets and set them according to the controlling array */
+            [aCell setEnabled:YES];
+        }
+        
+        if ([[aTableColumn identifier] isEqualToString:@"forced"])
+        {
+            [aCell setState:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackForced"] intValue]];
+        }
+        else if ([[aTableColumn identifier] isEqualToString:@"burned"])
+        {
+            [aCell setState:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackBurned"] intValue]];
+            /* Disable the "Burned-In" checkbox if a) the track is "None", b) the subtitle track is text (we do not support burning in
+             * text subs, or c) we are mp4 and the track is a vobsub (picture sub) */
+            if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackNum"] intValue] == 0 ||
+                [[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackisPictureSub"] intValue] == 0 ||
+                (container == HB_MUX_MP4 && [[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackisPictureSub"] intValue] == 1))
+            {
+                [aCell setEnabled:NO];
+            }
+            else
+            {
+                [aCell setEnabled:YES];
+            }
+        }
+        else if ([[aTableColumn identifier] isEqualToString:@"default"])
+        {
+            [aCell setState:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackDefault"] intValue]];   
+        }
+        /* These next three columns only apply to srt's. they are disabled for source subs */
+        else if ([[aTableColumn identifier] isEqualToString:@"srt_lang"])
+        {
+            /* We have an srt file so set the track type (Source or SRT, and the srt file path ) kvp's*/
+            if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"])
+            {
+                [aCell setEnabled:YES];
+                if([[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtLanguageIndex"])
+                {
+                    [aCell selectItemAtIndex:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtLanguageIndex"] intValue]];
+                }
+                else
+                {
+                    [aCell selectItemAtIndex:languagesArrayDefIndex]; // English
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
+                    
+                }
+            }
+            else
+            {
+                [aCell setEnabled:NO];
+            }  
+        }
+        else if ([[aTableColumn identifier] isEqualToString:@"srt_charcode"])
+        {
+            /* We have an srt file so set the track type (Source or SRT, and the srt file path ) kvp's*/
+            if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"])
+            {
+                [aCell setEnabled:YES];
+                if ([[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtCharCodeIndex"])
+                {
+                    [aCell selectItemAtIndex:[[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleTrackSrtCharCodeIndex"] intValue]];
+                }
+                else
+                {
+                    [aCell selectItemAtIndex:charCodeArrayDefIndex]; // ISO-8859-1
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:charCodeArrayDefIndex] forKey:@"subtitleTrackSrtCharCodeIndex"];
+                    [[subtitleArray objectAtIndex:rowIndex] setObject:[charCodeArray objectAtIndex:charCodeArrayDefIndex] forKey:@"subtitleTrackSrtCharCode"];
+                }
+            }
+            else
+            {
+                [aCell setEnabled:NO];
+            }   
+        }
+        else if ([[aTableColumn identifier] isEqualToString:@"srt_offset"])
+        {
+            if ([[[subtitleArray objectAtIndex:rowIndex] objectForKey:@"subtitleSourceTrackType"] isEqualToString:@"SRT"])
+            {
+                [aCell setEnabled:YES];
+            }
+            else
+            {
+                [aCell setEnabled:NO];
+            }
+        }
+        
+    }
+    
+    
+    if (container == HB_MUX_MP4)
+    {
+        /* now remove any other tracks that are set as burned and are picturesubs */
+        int i = 0;
+        int removedTracks = 0;
+        NSEnumerator *enumerator = [subtitleArray objectEnumerator];
+        id tempObject;
+        NSMutableArray *tempArrayToDelete = [NSMutableArray array];
+        BOOL removeTrack = NO; 
+        while ( tempObject = [enumerator nextObject] )  
+        {
+            
+            if ([[tempObject objectForKey:@"subtitleSourceTrackisPictureSub"] intValue] == 1)
+            {
+                /* if this is the first vobsub mark it. if not, remove it */
+                if (removeTrack == NO)
+                {
+                    /* make sure that this is set to be burned in */
+                    [tempObject setObject:[NSNumber numberWithInt:1] forKey:@"subtitleTrackBurned"];
+                    removeTrack = YES;
+                }
+                else
+                {
+                    [tempArrayToDelete addObject:tempObject];
+                    removedTracks ++;
+                }
+            }
+            
+            i++;
+        }
+        /* check to see if there are tracks to remove from the array */
+        if ([tempArrayToDelete count] > 0)
+        {
+            /* Popup a warning that hb only support one pic sub being burned in with mp4 */
+            int status;
+            status = NSRunAlertPanel(@"More than one vobsub is not supported in an mp4...",@"Your first vobsub track will now be used.", @"OK", nil, nil);
+            [NSApp requestUserAttention:NSCriticalRequest];
+            
+            [subtitleArray removeObjectsInArray:tempArrayToDelete];
+            [aTableView reloadData];
+        }
+    }
+}
+
+
+@end
diff --git a/macosx/HandBrake-64.icns b/macosx/HandBrake-64.icns
new file mode 100644 (file)
index 0000000..df6aa4e
Binary files /dev/null and b/macosx/HandBrake-64.icns differ
index f864f75..17ee305 100644 (file)
@@ -3,67 +3,11 @@
        archiveVersion = 1;
        classes = {
        };
-       objectVersion = 42;
+       objectVersion = 45;
        objects = {
 
 /* Begin PBXBuildFile section */
-               0D096E010B707D3400A845D4 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9B0B4CAB100064E04C /* common.c */; };
-               0D096E020B707D3400A845D4 /* deca52.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9D0B4CAB100064E04C /* deca52.c */; };
-               0D096E030B707D3400A845D4 /* decavcodec.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9E0B4CAB100064E04C /* decavcodec.c */; };
-               0D096EA30B70884A00A845D4 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1125D709D72FD200E0657B /* libz.dylib */; };
-               0DF377980B7BF99A00115CB0 /* fakexcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DF377970B7BF99A00115CB0 /* fakexcode.cpp */; };
                0DFA5C7B0B8DD1E90020BC09 /* HandBrake.icns in Resources */ = {isa = PBXBuildFile; fileRef = 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */; };
-               0DFA5CC00B8DD3FE0020BC09 /* declpcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */; };
-               0DFA5CC10B8DD3FE0020BC09 /* decmpeg2.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C7F0B8DD3B60020BC09 /* decmpeg2.c */; };
-               0DFA5CC20B8DD3FE0020BC09 /* decsub.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C800B8DD3B60020BC09 /* decsub.c */; };
-               0DFA5CC30B8DD3FE0020BC09 /* demuxmpeg.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C810B8DD3B60020BC09 /* demuxmpeg.c */; };
-               0DFA5CC40B8DD3FE0020BC09 /* dvd.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C820B8DD3B60020BC09 /* dvd.c */; };
-               0DFA5CC50B8DD3FE0020BC09 /* encavcodec.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C830B8DD3B60020BC09 /* encavcodec.c */; };
-               0DFA5CC60B8DD3FE0020BC09 /* encfaac.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C840B8DD3B60020BC09 /* encfaac.c */; };
-               0DFA5CC70B8DD3FE0020BC09 /* enclame.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C850B8DD3B60020BC09 /* enclame.c */; };
-               0DFA5CC80B8DD3FE0020BC09 /* encvorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C860B8DD3B60020BC09 /* encvorbis.c */; };
-               0DFA5CC90B8DD3FE0020BC09 /* encx264.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C870B8DD3B60020BC09 /* encx264.c */; };
-               0DFA5CCA0B8DD3FE0020BC09 /* encxvid.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C880B8DD3B60020BC09 /* encxvid.c */; };
-               0DFA5CCB0B8DD3FE0020BC09 /* fifo.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C890B8DD3B60020BC09 /* fifo.c */; };
-               0DFA5CCC0B8DD3FE0020BC09 /* hb.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C8A0B8DD3B60020BC09 /* hb.c */; };
-               0DFA5CCE0B8DD3FE0020BC09 /* muxavi.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C910B8DD3B60020BC09 /* muxavi.c */; };
-               0DFA5CCF0B8DD3FE0020BC09 /* muxcommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C920B8DD3B60020BC09 /* muxcommon.c */; };
-               0DFA5CD00B8DD3FE0020BC09 /* muxmp4.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C930B8DD3B60020BC09 /* muxmp4.c */; };
-               0DFA5CD10B8DD3FE0020BC09 /* muxogm.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C940B8DD3B60020BC09 /* muxogm.c */; };
-               0DFA5CD20B8DD3FE0020BC09 /* ports.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C950B8DD3B60020BC09 /* ports.c */; };
-               0DFA5CD30B8DD3FE0020BC09 /* reader.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C970B8DD3B60020BC09 /* reader.c */; };
-               0DFA5CD40B8DD3FE0020BC09 /* render.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C980B8DD3B60020BC09 /* render.c */; };
-               0DFA5CD50B8DD3FE0020BC09 /* scan.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C990B8DD3B60020BC09 /* scan.c */; };
-               0DFA5CD60B8DD3FE0020BC09 /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9A0B8DD3B60020BC09 /* sync.c */; };
-               0DFA5CD70B8DD3FE0020BC09 /* update.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9B0B8DD3B60020BC09 /* update.c */; };
-               0DFA5CD80B8DD3FE0020BC09 /* work.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9C0B8DD3B60020BC09 /* work.c */; };
-               0DFA5CD90B8DD4210020BC09 /* declpcm.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */; };
-               0DFA5CDA0B8DD4210020BC09 /* decmpeg2.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C7F0B8DD3B60020BC09 /* decmpeg2.c */; };
-               0DFA5CDB0B8DD4210020BC09 /* decsub.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C800B8DD3B60020BC09 /* decsub.c */; };
-               0DFA5CDC0B8DD4210020BC09 /* demuxmpeg.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C810B8DD3B60020BC09 /* demuxmpeg.c */; };
-               0DFA5CDD0B8DD4210020BC09 /* dvd.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C820B8DD3B60020BC09 /* dvd.c */; };
-               0DFA5CDE0B8DD4210020BC09 /* encavcodec.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C830B8DD3B60020BC09 /* encavcodec.c */; };
-               0DFA5CDF0B8DD4210020BC09 /* encfaac.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C840B8DD3B60020BC09 /* encfaac.c */; };
-               0DFA5CE00B8DD4210020BC09 /* enclame.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C850B8DD3B60020BC09 /* enclame.c */; };
-               0DFA5CE10B8DD4210020BC09 /* encvorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C860B8DD3B60020BC09 /* encvorbis.c */; };
-               0DFA5CE20B8DD4210020BC09 /* encx264.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C870B8DD3B60020BC09 /* encx264.c */; };
-               0DFA5CE30B8DD4210020BC09 /* encxvid.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C880B8DD3B60020BC09 /* encxvid.c */; };
-               0DFA5CE40B8DD4210020BC09 /* fifo.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C890B8DD3B60020BC09 /* fifo.c */; };
-               0DFA5CE50B8DD4210020BC09 /* hb.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C8A0B8DD3B60020BC09 /* hb.c */; };
-               0DFA5CE70B8DD4210020BC09 /* muxavi.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C910B8DD3B60020BC09 /* muxavi.c */; };
-               0DFA5CE80B8DD4210020BC09 /* muxcommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C920B8DD3B60020BC09 /* muxcommon.c */; };
-               0DFA5CE90B8DD4210020BC09 /* muxmp4.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C930B8DD3B60020BC09 /* muxmp4.c */; };
-               0DFA5CEA0B8DD4210020BC09 /* muxogm.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C940B8DD3B60020BC09 /* muxogm.c */; };
-               0DFA5CEB0B8DD4210020BC09 /* ports.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C950B8DD3B60020BC09 /* ports.c */; };
-               0DFA5CEC0B8DD4210020BC09 /* reader.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C970B8DD3B60020BC09 /* reader.c */; };
-               0DFA5CED0B8DD4210020BC09 /* render.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C980B8DD3B60020BC09 /* render.c */; };
-               0DFA5CEE0B8DD4210020BC09 /* scan.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C990B8DD3B60020BC09 /* scan.c */; };
-               0DFA5CEF0B8DD4210020BC09 /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9A0B8DD3B60020BC09 /* sync.c */; };
-               0DFA5CF00B8DD4210020BC09 /* update.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9B0B8DD3B60020BC09 /* update.c */; };
-               0DFA5CF10B8DD4210020BC09 /* work.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DFA5C9C0B8DD3B60020BC09 /* work.c */; };
-               0DFF0B770B6BC72A00549488 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9B0B4CAB100064E04C /* common.c */; };
-               0DFF0B790B6BC72A00549488 /* deca52.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9D0B4CAB100064E04C /* deca52.c */; };
-               0DFF0B7A0B6BC72A00549488 /* decavcodec.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC9E0B4CAB100064E04C /* decavcodec.c */; };
                0DFF0C100B6BCEE800549488 /* test.c in Sources */ = {isa = PBXBuildFile; fileRef = 526FBC760B4CA8F40064E04C /* test.c */; };
                253886010BFE0A5B0064E995 /* HBOutputRedirect.h in Headers */ = {isa = PBXBuildFile; fileRef = 253885FF0BFE0A5B0064E995 /* HBOutputRedirect.h */; };
                253886020BFE0A5B0064E995 /* HBOutputRedirect.m in Sources */ = {isa = PBXBuildFile; fileRef = 253886000BFE0A5B0064E995 /* HBOutputRedirect.m */; };
                253886180BFE0C160064E995 /* HBOutputPanelController.m in Sources */ = {isa = PBXBuildFile; fileRef = 253886160BFE0C160064E995 /* HBOutputPanelController.m */; };
                25DE1FB60C169A0C00F01FC8 /* HBPreferencesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 25DE1FB40C169A0C00F01FC8 /* HBPreferencesController.h */; };
                25DE1FB70C169A0C00F01FC8 /* HBPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE1FB50C169A0C00F01FC8 /* HBPreferencesController.m */; };
-               4D1125D809D72FD200E0657B /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1125D709D72FD200E0657B /* libz.dylib */; };
+               2713E6300F676510002E0A01 /* libhb.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2713E50C0F675F32002E0A01 /* libhb.a */; };
+               2713E6420F676526002E0A01 /* libhb.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2713E50C0F675F32002E0A01 /* libhb.a */; };
+               2728D25B0FE8419900758EC9 /* HandBrake-64.icns in Resources */ = {isa = PBXBuildFile; fileRef = 2728D25A0FE8419900758EC9 /* HandBrake-64.icns */; };
+               274DD1E40FEF109900881E69 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 274DD1E30FEF109900881E69 /* libiconv.dylib */; };
+               274DD20B0FEF10FD00881E69 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 274DD1E30FEF109900881E69 /* libiconv.dylib */; };
+               2774BE900F66F47100B65FC6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2774BE8F0F66F47100B65FC6 /* libbz2.dylib */; };
+               2774BE920F66F48200B65FC6 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2774BE910F66F48200B65FC6 /* libz.dylib */; };
+               2774BEC70F66F61A00B65FC6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2774BE8F0F66F47100B65FC6 /* libbz2.dylib */; };
+               2774BEC80F66F61A00B65FC6 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2774BE910F66F48200B65FC6 /* libz.dylib */; };
+               278070240F5C261300699207 /* ChapterTitles.h in Headers */ = {isa = PBXBuildFile; fileRef = 593034E90BBA39A100172349 /* ChapterTitles.h */; };
+               27AC71850F5A0AF600053B83 /* fakexcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27AC71840F5A0AF600053B83 /* fakexcode.cpp */; };
                4DD93F8F082036E8008E1322 /* Controller.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF3C8CB052889CD00A80101 /* Controller.h */; };
-               4DD93F92082036E8008E1322 /* PictureController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1FD381073D19CE00E46515 /* PictureController.h */; };
+               4DD93F92082036E8008E1322 /* HBPreviewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1FD381073D19CE00E46515 /* HBPreviewController.h */; };
                4DD93F97082036E8008E1322 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
                4DD93F9A082036E8008E1322 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.mm */; settings = {ATTRIBUTES = (); }; };
-               4DD93F9B082036E8008E1322 /* Controller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4DF3C8CC052889CD00A80101 /* Controller.mm */; };
-               4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FD382073D19CE00E46515 /* PictureController.mm */; };
+               4DD93F9B082036E8008E1322 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF3C8CC052889CD00A80101 /* Controller.m */; };
+               4DD93F9E082036E8008E1322 /* HBPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FD382073D19CE00E46515 /* HBPreviewController.m */; };
                4DD93FA2082036E8008E1322 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
                4DD93FA3082036E8008E1322 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DEB2024052B055F00C39CA9 /* IOKit.framework */; };
                4DD93FA4082036E8008E1322 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */; };
-               5558B5690BE3BADF00E15E27 /* decdca.c in Sources */ = {isa = PBXBuildFile; fileRef = 5558B5680BE3BADF00E15E27 /* decdca.c */; };
-               5558B56A0BE3BADF00E15E27 /* decdca.c in Sources */ = {isa = PBXBuildFile; fileRef = 5558B5680BE3BADF00E15E27 /* decdca.c */; };
-               593034EB0BBA39A100172349 /* ChapterTitles.h in Headers */ = {isa = PBXBuildFile; fileRef = 593034E90BBA39A100172349 /* ChapterTitles.h */; };
-               593034EC0BBA39A100172349 /* ChapterTitles.m in Sources */ = {isa = PBXBuildFile; fileRef = 593034EA0BBA39A100172349 /* ChapterTitles.m */; };
                59CBD2370BBB44DA004A3BE3 /* parsecsv.c in Sources */ = {isa = PBXBuildFile; fileRef = 59CBD2360BBB44DA004A3BE3 /* parsecsv.c */; };
                59CBD2650BBB4D1B004A3BE3 /* ChapterTitles.m in Sources */ = {isa = PBXBuildFile; fileRef = 593034EA0BBA39A100172349 /* ChapterTitles.m */; };
-               7497010F0DC281BB009200D8 /* decomb.c in Sources */ = {isa = PBXBuildFile; fileRef = 7497010E0DC281BB009200D8 /* decomb.c */; };
-               749701100DC281BB009200D8 /* decomb.c in Sources */ = {isa = PBXBuildFile; fileRef = 7497010E0DC281BB009200D8 /* decomb.c */; };
+               A20F47010EBB5EC2005B861B /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A20F47000EBB5EC2005B861B /* QTKit.framework */; };
                A22C85EC0D05D35000C10E36 /* HBPresets.h in Headers */ = {isa = PBXBuildFile; fileRef = A22C85EA0D05D35000C10E36 /* HBPresets.h */; };
                A22C85ED0D05D35100C10E36 /* HBPresets.m in Sources */ = {isa = PBXBuildFile; fileRef = A22C85EB0D05D35000C10E36 /* HBPresets.m */; };
-               A25289E60D87A27D00461D5B /* enctheora.c in Sources */ = {isa = PBXBuildFile; fileRef = A25289E50D87A27D00461D5B /* enctheora.c */; };
-               A25289E70D87A2CB00461D5B /* enctheora.c in Sources */ = {isa = PBXBuildFile; fileRef = A25289E50D87A27D00461D5B /* enctheora.c */; };
+               A256080C0FD06720006A4277 /* Brushed_Window.png in Resources */ = {isa = PBXBuildFile; fileRef = A256080B0FD06720006A4277 /* Brushed_Window.png */; };
+               A25962E10F15077500B3BF4E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A25962E00F15077500B3BF4E /* Quartz.framework */; };
                A273E0510C57B39A00493A45 /* Pause.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04A0C57B39A00493A45 /* Pause.tiff */; };
                A273E0520C57B39A00493A45 /* Play.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04B0C57B39A00493A45 /* Play.tiff */; };
                A273E0530C57B39A00493A45 /* Stop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04C0C57B39A00493A45 /* Stop.tiff */; };
-               A273E09A0C57C1CC00493A45 /* muxmkv.c in Sources */ = {isa = PBXBuildFile; fileRef = A273E0950C57C19500493A45 /* muxmkv.c */; };
-               A273E09B0C57C1CD00493A45 /* muxmkv.c in Sources */ = {isa = PBXBuildFile; fileRef = A273E0950C57C19500493A45 /* muxmkv.c */; };
+               A27BB4EA0EFAB9310027CDF9 /* PicturePreview.xib in Resources */ = {isa = PBXBuildFile; fileRef = A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */; };
                A29E05800BE1283E000533F5 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; };
                A29E058B0BE12889000533F5 /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; };
                A2A1EC310C76C35E00827E0D /* HBDVDDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */; };
                A2A1EC3A0C76C58400827E0D /* HBDVDDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1EC390C76C58400827E0D /* HBDVDDetector.m */; };
+               A2BEA5FB0F2A1ED1001CE7A1 /* PictureController.h in Headers */ = {isa = PBXBuildFile; fileRef = A2BEA5F90F2A1ED1001CE7A1 /* PictureController.h */; };
+               A2BEA5FC0F2A1ED1001CE7A1 /* PictureController.m in Sources */ = {isa = PBXBuildFile; fileRef = A2BEA5FA0F2A1ED1001CE7A1 /* PictureController.m */; };
                A2D0A0AB0D3E5929002D57CB /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */; };
                A2D0A0BF0D3E596F002D57CB /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */; };
+               A2D18AA70FD81C50003C997B /* HBSubtitles.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D18AA50FD81C50003C997B /* HBSubtitles.h */; };
+               A2D18AA80FD81C50003C997B /* HBSubtitles.m in Sources */ = {isa = PBXBuildFile; fileRef = A2D18AA60FD81C50003C997B /* HBSubtitles.m */; };
                A2D7AD670C998AD30082CA33 /* ActivityWindow.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD5E0C998AD30082CA33 /* ActivityWindow.tiff */; };
                A2D7AD680C998AD30082CA33 /* AddToQueue.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD5F0C998AD30082CA33 /* AddToQueue.tiff */; };
                A2D7AD690C998AD30082CA33 /* Drawer.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD600C998AD30082CA33 /* Drawer.tiff */; };
                A2D7AD6D0C998AD30082CA33 /* pref-picture.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD640C998AD30082CA33 /* pref-picture.tiff */; };
                A2D7AD6E0C998AD30082CA33 /* Queue.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD650C998AD30082CA33 /* Queue.tiff */; };
                A2D7AD6F0C998AD30082CA33 /* Source.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD660C998AD30082CA33 /* Source.tiff */; };
+               A906A0510F7A7B210007A827 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A906A0500F7A7B210007A827 /* AudioToolbox.framework */; };
+               A906A0520F7A7B210007A827 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A906A0500F7A7B210007A827 /* AudioToolbox.framework */; };
                A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */; };
                A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */ = {isa = PBXBuildFile; fileRef = A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */; };
-               B48359A80C82960500E04440 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; };
                D289A9F30DBBE7AC00CE614B /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D289A9F20DBBE7AC00CE614B /* CoreServices.framework */; };
                D289AAC40DBBF3F100CE614B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DEB2024052B055F00C39CA9 /* IOKit.framework */; };
-               D4D49FED0C83355600F01215 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; };
                E3003C7F0C88505D0072F2A8 /* DeleteHighlightPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */; };
                E3003CB50C8852B70072F2A8 /* DeletePressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E3003CB40C8852B70072F2A8 /* DeletePressed.png */; };
                E37167890C92F6180072B384 /* JobPassSecondSmall.png in Resources */ = {isa = PBXBuildFile; fileRef = E37167830C92F6180072B384 /* JobPassSecondSmall.png */; };
                E3C844F90CA6B3F90013B683 /* Reveal.png in Resources */ = {isa = PBXBuildFile; fileRef = E3C844F50CA6B3F90013B683 /* Reveal.png */; };
                E3C845870CA6E9080013B683 /* EncodeComplete.png in Resources */ = {isa = PBXBuildFile; fileRef = E3C845860CA6E9080013B683 /* EncodeComplete.png */; };
                E3FC10910D1611EC00470E7B /* EncodeCanceled.png in Resources */ = {isa = PBXBuildFile; fileRef = E3FC10900D1611EC00470E7B /* EncodeCanceled.png */; };
-               EAA526930C3B25D200944FF2 /* stream.c in Sources */ = {isa = PBXBuildFile; fileRef = EAA526920C3B25D200944FF2 /* stream.c */; };
-               EAA526940C3B25D200944FF2 /* stream.c in Sources */ = {isa = PBXBuildFile; fileRef = EAA526920C3B25D200944FF2 /* stream.c */; };
-               FC8519500C59A02C0073812C /* denoise.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194C0C59A02C0073812C /* denoise.c */; };
-               FC8519510C59A02C0073812C /* deinterlace.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194D0C59A02C0073812C /* deinterlace.c */; };
-               FC8519520C59A02C0073812C /* deblock.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194E0C59A02C0073812C /* deblock.c */; };
-               FC8519530C59A02C0073812C /* detelecine.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194F0C59A02C0073812C /* detelecine.c */; };
-               FC8519540C59A02C0073812C /* denoise.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194C0C59A02C0073812C /* denoise.c */; };
-               FC8519550C59A02C0073812C /* deinterlace.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194D0C59A02C0073812C /* deinterlace.c */; };
-               FC8519560C59A02C0073812C /* deblock.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194E0C59A02C0073812C /* deblock.c */; };
-               FC8519570C59A02C0073812C /* detelecine.c in Sources */ = {isa = PBXBuildFile; fileRef = FC85194F0C59A02C0073812C /* detelecine.c */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
-               0D6E35900B6BD5FA005AABB3 /* PBXContainerItemProxy */ = {
+               277C2E530F5DFF400067D708 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 0DFF0B710B6BC6E600549488;
-                       remoteInfo = libmediafork;
+                       remoteGlobalIDString = 27F143770F5DF34F00A684FF;
+                       remoteInfo = external;
                };
-               0DFF0BF30B6BCCB900549488 /* PBXContainerItemProxy */ = {
+               277C2E550F5DFF450067D708 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
                        proxyType = 1;
-                       remoteGlobalIDString = 0DFF0B710B6BC6E600549488;
-                       remoteInfo = libmediafork;
+                       remoteGlobalIDString = 27F143770F5DF34F00A684FF;
+                       remoteInfo = external;
                };
 /* End PBXContainerItemProxy section */
 
                        dstPath = "";
                        dstSubfolderSpec = 10;
                        files = (
-                               A2D0A0BF0D3E596F002D57CB /* Sparkle.framework in CopyFiles */,
                                A29E058B0BE12889000533F5 /* Growl.framework in CopyFiles */,
+                               A2D0A0BF0D3E596F002D57CB /* Sparkle.framework in CopyFiles */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
 
 /* Begin PBXFileReference section */
                089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
-               0D096DFF0B707D1200A845D4 /* libhb.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libhb.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
                0D6E35760B6BD4F0005AABB3 /* HandBrake.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HandBrake.app; sourceTree = BUILT_PRODUCTS_DIR; };
-               0DF377970B7BF99A00115CB0 /* fakexcode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fakexcode.cpp; path = ../test/fakexcode.cpp; sourceTree = SOURCE_ROOT; };
                0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = HandBrake.icns; sourceTree = "<group>"; };
-               0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = declpcm.c; path = ../libhb/declpcm.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C7F0B8DD3B60020BC09 /* decmpeg2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = decmpeg2.c; path = ../libhb/decmpeg2.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C800B8DD3B60020BC09 /* decsub.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = decsub.c; path = ../libhb/decsub.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C810B8DD3B60020BC09 /* demuxmpeg.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = demuxmpeg.c; path = ../libhb/demuxmpeg.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C820B8DD3B60020BC09 /* dvd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dvd.c; path = ../libhb/dvd.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C830B8DD3B60020BC09 /* encavcodec.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = encavcodec.c; path = ../libhb/encavcodec.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C840B8DD3B60020BC09 /* encfaac.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = encfaac.c; path = ../libhb/encfaac.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C850B8DD3B60020BC09 /* enclame.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = enclame.c; path = ../libhb/enclame.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C860B8DD3B60020BC09 /* encvorbis.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = encvorbis.c; path = ../libhb/encvorbis.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C870B8DD3B60020BC09 /* encx264.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = encx264.c; path = ../libhb/encx264.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C880B8DD3B60020BC09 /* encxvid.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = encxvid.c; path = ../libhb/encxvid.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C890B8DD3B60020BC09 /* fifo.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = fifo.c; path = ../libhb/fifo.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C8A0B8DD3B60020BC09 /* hb.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hb.c; path = ../libhb/hb.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C910B8DD3B60020BC09 /* muxavi.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxavi.c; path = ../libhb/muxavi.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C920B8DD3B60020BC09 /* muxcommon.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxcommon.c; path = ../libhb/muxcommon.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C930B8DD3B60020BC09 /* muxmp4.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxmp4.c; path = ../libhb/muxmp4.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C940B8DD3B60020BC09 /* muxogm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxogm.c; path = ../libhb/muxogm.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C950B8DD3B60020BC09 /* ports.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = ports.c; path = ../libhb/ports.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C970B8DD3B60020BC09 /* reader.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = reader.c; path = ../libhb/reader.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C980B8DD3B60020BC09 /* render.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = render.c; path = ../libhb/render.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C990B8DD3B60020BC09 /* scan.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = scan.c; path = ../libhb/scan.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C9A0B8DD3B60020BC09 /* sync.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = sync.c; path = ../libhb/sync.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C9B0B8DD3B60020BC09 /* update.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = update.c; path = ../libhb/update.c; sourceTree = SOURCE_ROOT; };
-               0DFA5C9C0B8DD3B60020BC09 /* work.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = work.c; path = ../libhb/work.c; sourceTree = SOURCE_ROOT; };
-               0DFA5D060B8DD9040020BC09 /* HandBrake.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = HandBrake.plist; sourceTree = "<group>"; };
-               0DFF0B720B6BC6E600549488 /* libhb.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libhb.a; sourceTree = BUILT_PRODUCTS_DIR; };
                0DFF0C0A0B6BCEC200549488 /* HandBrakeCLI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = HandBrakeCLI; sourceTree = BUILT_PRODUCTS_DIR; };
                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
                253885FF0BFE0A5B0064E995 /* HBOutputRedirect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBOutputRedirect.h; sourceTree = "<group>"; };
                253886160BFE0C160064E995 /* HBOutputPanelController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBOutputPanelController.m; sourceTree = "<group>"; };
                25DE1FB40C169A0C00F01FC8 /* HBPreferencesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPreferencesController.h; sourceTree = "<group>"; };
                25DE1FB50C169A0C00F01FC8 /* HBPreferencesController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPreferencesController.m; sourceTree = "<group>"; };
+               2713E50C0F675F32002E0A01 /* libhb.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libhb.a; path = libhb/libhb.a; sourceTree = BUILT_PRODUCTS_DIR; };
+               2728D25A0FE8419900758EC9 /* HandBrake-64.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "HandBrake-64.icns"; sourceTree = "<group>"; };
+               274DD1E30FEF109900881E69 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = /usr/lib/libiconv.dylib; sourceTree = "<absolute>"; };
+               2774BE8F0F66F47100B65FC6 /* libbz2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbz2.dylib; path = usr/lib/libbz2.dylib; sourceTree = SDKROOT; };
+               2774BE910F66F48200B65FC6 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
+               27AC71840F5A0AF600053B83 /* fakexcode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fakexcode.cpp; path = ../test/fakexcode.cpp; sourceTree = SOURCE_ROOT; };
                29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
                29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
-               4D1125D709D72FD200E0657B /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
-               4D1FD381073D19CE00E46515 /* PictureController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PictureController.h; sourceTree = "<group>"; };
-               4D1FD382073D19CE00E46515 /* PictureController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureController.mm; sourceTree = "<group>"; };
+               4D1FD381073D19CE00E46515 /* HBPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBPreviewController.h; sourceTree = "<group>"; };
+               4D1FD382073D19CE00E46515 /* HBPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBPreviewController.m; sourceTree = "<group>"; };
                4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
                4DEB2024052B055F00C39CA9 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
                4DF3C8CB052889CD00A80101 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = "<group>"; };
-               4DF3C8CC052889CD00A80101 /* Controller.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = Controller.mm; sourceTree = "<group>"; };
+               4DF3C8CC052889CD00A80101 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = "<group>"; };
                526FBC760B4CA8F40064E04C /* test.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 30; name = test.c; path = ../test/test.c; sourceTree = SOURCE_ROOT; };
-               526FBC9B0B4CAB100064E04C /* common.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../libhb/common.c; sourceTree = SOURCE_ROOT; };
-               526FBC9D0B4CAB100064E04C /* deca52.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = deca52.c; path = ../libhb/deca52.c; sourceTree = SOURCE_ROOT; };
-               526FBC9E0B4CAB100064E04C /* decavcodec.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = decavcodec.c; path = ../libhb/decavcodec.c; sourceTree = SOURCE_ROOT; };
-               5558B5680BE3BADF00E15E27 /* decdca.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = decdca.c; path = ../libhb/decdca.c; sourceTree = SOURCE_ROOT; };
                593034E90BBA39A100172349 /* ChapterTitles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChapterTitles.h; sourceTree = "<group>"; };
                593034EA0BBA39A100172349 /* ChapterTitles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChapterTitles.m; sourceTree = "<group>"; };
                59CBD2360BBB44DA004A3BE3 /* parsecsv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = parsecsv.c; path = ../test/parsecsv.c; sourceTree = SOURCE_ROOT; };
-               7497010E0DC281BB009200D8 /* decomb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = decomb.c; path = ../libhb/decomb.c; sourceTree = SOURCE_ROOT; };
+               A20F46DB0EBB5E7A005B861B /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; };
+               A20F47000EBB5EC2005B861B /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
                A22C85EA0D05D35000C10E36 /* HBPresets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPresets.h; sourceTree = "<group>"; };
                A22C85EB0D05D35000C10E36 /* HBPresets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPresets.m; sourceTree = "<group>"; };
-               A25289E50D87A27D00461D5B /* enctheora.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = enctheora.c; path = ../libhb/enctheora.c; sourceTree = SOURCE_ROOT; };
+               A256080B0FD06720006A4277 /* Brushed_Window.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Brushed_Window.png; path = icons/Brushed_Window.png; sourceTree = "<group>"; };
+               A25962E00F15077500B3BF4E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = "<absolute>"; };
                A273E04A0C57B39A00493A45 /* Pause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Pause.tiff; sourceTree = "<group>"; };
                A273E04B0C57B39A00493A45 /* Play.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Play.tiff; sourceTree = "<group>"; };
                A273E04C0C57B39A00493A45 /* Stop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Stop.tiff; sourceTree = "<group>"; };
-               A273E0950C57C19500493A45 /* muxmkv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxmkv.c; path = ../libhb/muxmkv.c; sourceTree = SOURCE_ROOT; };
+               A27BB4E90EFAB9310027CDF9 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PicturePreview.xib; sourceTree = "<group>"; };
                A29E057F0BE1283E000533F5 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Growl.framework; sourceTree = "<group>"; };
                A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBDVDDetector.h; sourceTree = "<group>"; };
                A2A1EC390C76C58400827E0D /* HBDVDDetector.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBDVDDetector.m; sourceTree = "<group>"; };
+               A2BEA5F90F2A1ED1001CE7A1 /* PictureController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PictureController.h; sourceTree = "<group>"; };
+               A2BEA5FA0F2A1ED1001CE7A1 /* PictureController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PictureController.m; sourceTree = "<group>"; };
                A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
+               A2D18AA50FD81C50003C997B /* HBSubtitles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBSubtitles.h; sourceTree = "<group>"; };
+               A2D18AA60FD81C50003C997B /* HBSubtitles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBSubtitles.m; sourceTree = "<group>"; };
                A2D7AD5E0C998AD30082CA33 /* ActivityWindow.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ActivityWindow.tiff; sourceTree = "<group>"; };
                A2D7AD5F0C998AD30082CA33 /* AddToQueue.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = AddToQueue.tiff; sourceTree = "<group>"; };
                A2D7AD600C998AD30082CA33 /* Drawer.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Drawer.tiff; sourceTree = "<group>"; };
                A2D7AD640C998AD30082CA33 /* pref-picture.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "pref-picture.tiff"; sourceTree = "<group>"; };
                A2D7AD650C998AD30082CA33 /* Queue.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Queue.tiff; sourceTree = "<group>"; };
                A2D7AD660C998AD30082CA33 /* Source.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Source.tiff; sourceTree = "<group>"; };
+               A906A0500F7A7B210007A827 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
                A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBAdvancedController.m; sourceTree = "<group>"; };
                A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBAdvancedController.h; sourceTree = "<group>"; };
-               B48359A70C82960500E04440 /* lang.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lang.c; path = ../libhb/lang.c; sourceTree = SOURCE_ROOT; };
                D289A9F20DBBE7AC00CE614B /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
                E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeleteHighlightPressed.png; sourceTree = "<group>"; };
                E3003CB40C8852B70072F2A8 /* DeletePressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeletePressed.png; sourceTree = "<group>"; };
                E3C844F50CA6B3F90013B683 /* Reveal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Reveal.png; sourceTree = "<group>"; };
                E3C845860CA6E9080013B683 /* EncodeComplete.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EncodeComplete.png; sourceTree = "<group>"; };
                E3FC10900D1611EC00470E7B /* EncodeCanceled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EncodeCanceled.png; sourceTree = "<group>"; };
-               EAA526920C3B25D200944FF2 /* stream.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = stream.c; path = ../libhb/stream.c; sourceTree = SOURCE_ROOT; };
-               FC85194C0C59A02C0073812C /* denoise.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = denoise.c; path = ../libhb/denoise.c; sourceTree = SOURCE_ROOT; };
-               FC85194D0C59A02C0073812C /* deinterlace.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = deinterlace.c; path = ../libhb/deinterlace.c; sourceTree = SOURCE_ROOT; };
-               FC85194E0C59A02C0073812C /* deblock.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = deblock.c; path = ../libhb/deblock.c; sourceTree = SOURCE_ROOT; };
-               FC85194F0C59A02C0073812C /* detelecine.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = detelecine.c; path = ../libhb/detelecine.c; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
-               0D096DFD0B707D1200A845D4 /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               0D096EA30B70884A00A845D4 /* libz.dylib in Frameworks */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               0DFF0B700B6BC6E600549488 /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
                0DFF0C080B6BCEC200549488 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               D289AAC40DBBF3F100CE614B /* IOKit.framework in Frameworks */,
                                D289A9F30DBBE7AC00CE614B /* CoreServices.framework in Frameworks */,
+                               A906A0520F7A7B210007A827 /* AudioToolbox.framework in Frameworks */,
+                               D289AAC40DBBF3F100CE614B /* IOKit.framework in Frameworks */,
+                               2713E6300F676510002E0A01 /* libhb.a in Frameworks */,
+                               274DD1E40FEF109900881E69 /* libiconv.dylib in Frameworks */,
+                               2774BE900F66F47100B65FC6 /* libbz2.dylib in Frameworks */,
+                               2774BE920F66F48200B65FC6 /* libz.dylib in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        buildActionMask = 2147483647;
                        files = (
                                4DD93FA2082036E8008E1322 /* Cocoa.framework in Frameworks */,
-                               4DD93FA3082036E8008E1322 /* IOKit.framework in Frameworks */,
+                               A25962E10F15077500B3BF4E /* Quartz.framework in Frameworks */,
+                               A20F47010EBB5EC2005B861B /* QTKit.framework in Frameworks */,
                                4DD93FA4082036E8008E1322 /* OpenGL.framework in Frameworks */,
-                               4D1125D809D72FD200E0657B /* libz.dylib in Frameworks */,
+                               A906A0510F7A7B210007A827 /* AudioToolbox.framework in Frameworks */,
+                               4DD93FA3082036E8008E1322 /* IOKit.framework in Frameworks */,
                                A29E05800BE1283E000533F5 /* Growl.framework in Frameworks */,
                                A2D0A0AB0D3E5929002D57CB /* Sparkle.framework in Frameworks */,
+                               2713E6420F676526002E0A01 /* libhb.a in Frameworks */,
+                               274DD20B0FEF10FD00881E69 /* libiconv.dylib in Frameworks */,
+                               2774BEC70F66F61A00B65FC6 /* libbz2.dylib in Frameworks */,
+                               2774BEC80F66F61A00B65FC6 /* libz.dylib in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                19C28FACFE9D520D11CA2CBB /* Products */ = {
                        isa = PBXGroup;
                        children = (
-                               0DFF0B720B6BC6E600549488 /* libhb.a */,
                                0DFF0C0A0B6BCEC200549488 /* HandBrakeCLI */,
                                0D6E35760B6BD4F0005AABB3 /* HandBrake.app */,
-                               0D096DFF0B707D1200A845D4 /* libhb.dylib */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                        children = (
                                526FBC930B4CAA260064E04C /* HandBrake Sources */,
                                526FBC920B4CAA120064E04C /* HandBrakeCLI Sources */,
-                               526FBC8D0B4CA9F90064E04C /* libhb Sources */,
-                               29B97315FDCFA39411CA2CEA /* Other Sources */,
                                29B97317FDCFA39411CA2CEA /* Resources */,
                                089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
                                29B97323FDCFA39411CA2CEA /* Frameworks */,
                                19C28FACFE9D520D11CA2CBB /* Products */,
+                               274DD1E30FEF109900881E69 /* libiconv.dylib */,
                        );
                        name = HandBrake;
                        sourceTree = "<group>";
                };
-               29B97315FDCFA39411CA2CEA /* Other Sources */ = {
-                       isa = PBXGroup;
-                       children = (
-                               29B97316FDCFA39411CA2CEA /* main.mm */,
-                       );
-                       name = "Other Sources";
-                       sourceTree = "<group>";
-               };
                29B97317FDCFA39411CA2CEA /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               A256080B0FD06720006A4277 /* Brushed_Window.png */,
+                               A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */,
                                A273E0460C57B39A00493A45 /* icons */,
                                0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */,
+                               2728D25A0FE8419900758EC9 /* HandBrake-64.icns */,
                                E39AA4DA0D32DC0B0007A415 /* MainMenu.xib */,
                                E39AA4E20D32DC0B0007A415 /* AdvancedView.xib */,
                                E39AA4E40D32DC0B0007A415 /* OutputPanel.xib */,
                29B97323FDCFA39411CA2CEA /* Frameworks */ = {
                        isa = PBXGroup;
                        children = (
+                               A906A0500F7A7B210007A827 /* AudioToolbox.framework */,
+                               A25962E00F15077500B3BF4E /* Quartz.framework */,
+                               A20F47000EBB5EC2005B861B /* QTKit.framework */,
+                               A20F46DB0EBB5E7A005B861B /* QuickTime.framework */,
                                D289A9F20DBBE7AC00CE614B /* CoreServices.framework */,
                                A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */,
                                A29E057F0BE1283E000533F5 /* Growl.framework */,
-                               4D1125D709D72FD200E0657B /* libz.dylib */,
                                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
                                4DEB2024052B055F00C39CA9 /* IOKit.framework */,
                                4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */,
                                29B97325FDCFA39411CA2CEA /* Foundation.framework */,
                                29B97324FDCFA39411CA2CEA /* AppKit.framework */,
+                               2713E50C0F675F32002E0A01 /* libhb.a */,
+                               2774BE8F0F66F47100B65FC6 /* libbz2.dylib */,
+                               2774BE910F66F48200B65FC6 /* libz.dylib */,
                        );
                        name = Frameworks;
                        sourceTree = "<group>";
                };
-               526FBC8D0B4CA9F90064E04C /* libhb Sources */ = {
-                       isa = PBXGroup;
-                       children = (
-                               A25289E50D87A27D00461D5B /* enctheora.c */,
-                               7497010E0DC281BB009200D8 /* decomb.c */,
-                               B48359A70C82960500E04440 /* lang.c */,
-                               EAA526920C3B25D200944FF2 /* stream.c */,
-                               0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */,
-                               0DFA5C7F0B8DD3B60020BC09 /* decmpeg2.c */,
-                               0DFA5C800B8DD3B60020BC09 /* decsub.c */,
-                               0DFA5C810B8DD3B60020BC09 /* demuxmpeg.c */,
-                               0DFA5C820B8DD3B60020BC09 /* dvd.c */,
-                               0DFA5C830B8DD3B60020BC09 /* encavcodec.c */,
-                               0DFA5C840B8DD3B60020BC09 /* encfaac.c */,
-                               0DFA5C850B8DD3B60020BC09 /* enclame.c */,
-                               0DFA5C860B8DD3B60020BC09 /* encvorbis.c */,
-                               FC85194C0C59A02C0073812C /* denoise.c */,
-                               FC85194D0C59A02C0073812C /* deinterlace.c */,
-                               FC85194E0C59A02C0073812C /* deblock.c */,
-                               FC85194F0C59A02C0073812C /* detelecine.c */,
-                               0DFA5C870B8DD3B60020BC09 /* encx264.c */,
-                               0DFA5C880B8DD3B60020BC09 /* encxvid.c */,
-                               0DFA5C890B8DD3B60020BC09 /* fifo.c */,
-                               0DFA5C8A0B8DD3B60020BC09 /* hb.c */,
-                               0DFA5C920B8DD3B60020BC09 /* muxcommon.c */,
-                               A273E0950C57C19500493A45 /* muxmkv.c */,
-                               0DFA5C930B8DD3B60020BC09 /* muxmp4.c */,
-                               0DFA5C910B8DD3B60020BC09 /* muxavi.c */,
-                               0DFA5C940B8DD3B60020BC09 /* muxogm.c */,
-                               0DFA5C950B8DD3B60020BC09 /* ports.c */,
-                               0DFA5C970B8DD3B60020BC09 /* reader.c */,
-                               0DFA5C980B8DD3B60020BC09 /* render.c */,
-                               0DFA5C990B8DD3B60020BC09 /* scan.c */,
-                               0DFA5C9A0B8DD3B60020BC09 /* sync.c */,
-                               0DFA5C9B0B8DD3B60020BC09 /* update.c */,
-                               0DFA5C9C0B8DD3B60020BC09 /* work.c */,
-                               526FBC9B0B4CAB100064E04C /* common.c */,
-                               526FBC9D0B4CAB100064E04C /* deca52.c */,
-                               5558B5680BE3BADF00E15E27 /* decdca.c */,
-                               526FBC9E0B4CAB100064E04C /* decavcodec.c */,
-                       );
-                       name = "libhb Sources";
-                       sourceTree = "<group>";
-               };
                526FBC920B4CAA120064E04C /* HandBrakeCLI Sources */ = {
                        isa = PBXGroup;
                        children = (
-                               0DF377970B7BF99A00115CB0 /* fakexcode.cpp */,
+                               27AC71840F5A0AF600053B83 /* fakexcode.cpp */,
                                526FBC760B4CA8F40064E04C /* test.c */,
                                59CBD2360BBB44DA004A3BE3 /* parsecsv.c */,
                        );
                526FBC930B4CAA260064E04C /* HandBrake Sources */ = {
                        isa = PBXGroup;
                        children = (
+                               A2D18AA50FD81C50003C997B /* HBSubtitles.h */,
+                               A2D18AA60FD81C50003C997B /* HBSubtitles.m */,
+                               4DF3C8CB052889CD00A80101 /* Controller.h */,
+                               4DF3C8CC052889CD00A80101 /* Controller.m */,
+                               A2BEA5F90F2A1ED1001CE7A1 /* PictureController.h */,
+                               A2BEA5FA0F2A1ED1001CE7A1 /* PictureController.m */,
                                A22C85EA0D05D35000C10E36 /* HBPresets.h */,
                                A22C85EB0D05D35000C10E36 /* HBPresets.m */,
-                               0DFA5D060B8DD9040020BC09 /* HandBrake.plist */,
-                               4D1FD381073D19CE00E46515 /* PictureController.h */,
-                               4D1FD382073D19CE00E46515 /* PictureController.mm */,
-                               4DF3C8CB052889CD00A80101 /* Controller.h */,
-                               4DF3C8CC052889CD00A80101 /* Controller.mm */,
+                               4D1FD381073D19CE00E46515 /* HBPreviewController.h */,
+                               4D1FD382073D19CE00E46515 /* HBPreviewController.m */,
                                593034E90BBA39A100172349 /* ChapterTitles.h */,
                                593034EA0BBA39A100172349 /* ChapterTitles.m */,
                                A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */,
                                A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */,
                                E37172660C977D340072B384 /* HBImageAndTextCell.h */,
                                E37172650C977D340072B384 /* HBImageAndTextCell.m */,
+                               29B97316FDCFA39411CA2CEA /* main.mm */,
                        );
                        name = "HandBrake Sources";
                        sourceTree = "<group>";
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
-               0D096DFB0B707D1200A845D4 /* Headers */ = {
-                       isa = PBXHeadersBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               0DFF0B6E0B6BC6E600549488 /* Headers */ = {
-                       isa = PBXHeadersBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               593034EB0BBA39A100172349 /* ChapterTitles.h in Headers */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
                4DD93F8E082036E8008E1322 /* Headers */ = {
                        isa = PBXHeadersBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                                4DD93F8F082036E8008E1322 /* Controller.h in Headers */,
-                               4DD93F92082036E8008E1322 /* PictureController.h in Headers */,
+                               4DD93F92082036E8008E1322 /* HBPreviewController.h in Headers */,
                                A2A1EC310C76C35E00827E0D /* HBDVDDetector.h in Headers */,
                                253886010BFE0A5B0064E995 /* HBOutputRedirect.h in Headers */,
                                253886170BFE0C160064E995 /* HBOutputPanelController.h in Headers */,
                                A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */,
                                E37172680C977D340072B384 /* HBImageAndTextCell.h in Headers */,
                                A22C85EC0D05D35000C10E36 /* HBPresets.h in Headers */,
+                               A2BEA5FB0F2A1ED1001CE7A1 /* PictureController.h in Headers */,
+                               278070240F5C261300699207 /* ChapterTitles.h in Headers */,
+                               A2D18AA70FD81C50003C997B /* HBSubtitles.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
 /* End PBXHeadersBuildPhase section */
 
-/* Begin PBXNativeTarget section */
-               0D096DFE0B707D1200A845D4 /* libhb dlib */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = 0D096E650B707D5800A845D4 /* Build configuration list for PBXNativeTarget "libhb dlib" */;
+/* Begin PBXLegacyTarget section */
+               27F143770F5DF34F00A684FF /* external */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "\"$EXTERNAL_SRC/make/xcodemake";
+                       buildConfigurationList = 27F1438E0F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "external" */;
                        buildPhases = (
-                               0D096DFB0B707D1200A845D4 /* Headers */,
-                               0D096DFC0B707D1200A845D4 /* Sources */,
-                               0D096DFD0B707D1200A845D4 /* Frameworks */,
-                       );
-                       buildRules = (
                        );
+                       buildToolPath = /bin/sh;
                        dependencies = (
                        );
-                       name = "libhb dlib";
-                       productName = "libmediafork dlib";
-                       productReference = 0D096DFF0B707D1200A845D4 /* libhb.dylib */;
-                       productType = "com.apple.product-type.library.dynamic";
+                       name = external;
+                       passBuildSettingsInEnvironment = 1;
+                       productName = external;
                };
-               0DFF0B710B6BC6E600549488 /* libhb */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = 0DFF0B730B6BC70400549488 /* Build configuration list for PBXNativeTarget "libhb" */;
+               27F1437E0F5DF36000A684FF /* contrib */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "\"$EXTERNAL_SRC/make/xcodemake";
+                       buildConfigurationList = 27F1438F0F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "contrib" */;
                        buildPhases = (
-                               0DFF0B6E0B6BC6E600549488 /* Headers */,
-                               0DFF0B6F0B6BC6E600549488 /* Sources */,
-                               0DFF0B700B6BC6E600549488 /* Frameworks */,
                        );
-                       buildRules = (
+                       buildToolPath = /bin/sh;
+                       dependencies = (
                        );
+                       name = contrib;
+                       passBuildSettingsInEnvironment = 1;
+                       productName = contrib;
+               };
+               27F143850F5DF37600A684FF /* libhb */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "\"$EXTERNAL_SRC/make/xcodemake";
+                       buildConfigurationList = 27F143900F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "libhb" */;
+                       buildPhases = (
+                       );
+                       buildToolPath = /bin/sh;
                        dependencies = (
                        );
                        name = libhb;
-                       productName = libmediafork;
-                       productReference = 0DFF0B720B6BC6E600549488 /* libhb.a */;
-                       productType = "com.apple.product-type.library.static";
+                       passBuildSettingsInEnvironment = 1;
+                       productName = libhb;
                };
+/* End PBXLegacyTarget section */
+
+/* Begin PBXNativeTarget section */
                0DFF0C090B6BCEC200549488 /* HandBrakeCLI */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 0DFF0C0C0B6BCEE000549488 /* Build configuration list for PBXNativeTarget "HandBrakeCLI" */;
                        buildRules = (
                        );
                        dependencies = (
-                               0D6E35910B6BD5FA005AABB3 /* PBXTargetDependency */,
+                               277C2E560F5DFF450067D708 /* PBXTargetDependency */,
                        );
                        name = HandBrakeCLI;
                        productName = HandBrakeCLI;
                        buildRules = (
                        );
                        dependencies = (
-                               0DFF0BF40B6BCCB900549488 /* PBXTargetDependency */,
+                               277C2E540F5DFF400067D708 /* PBXTargetDependency */,
                        );
                        name = HandBrake;
                        productName = HandBrake;
 /* Begin PBXProject section */
                29B97313FDCFA39411CA2CEA /* Project object */ = {
                        isa = PBXProject;
+                       attributes = {
+                               BuildIndependentTargetsInParallel = YES;
+                       };
                        buildConfigurationList = 4D4E7BC4087804870051572B /* Build configuration list for PBXProject "HandBrake" */;
-                       compatibilityVersion = "Xcode 2.4";
+                       compatibilityVersion = "Xcode 3.1";
                        hasScannedForEncodings = 1;
                        mainGroup = 29B97314FDCFA39411CA2CEA /* HandBrake */;
                        projectDirPath = "";
                        projectRoot = "";
                        targets = (
                                4DD93F8D082036E8008E1322 /* HandBrake */,
-                               0DFF0B710B6BC6E600549488 /* libhb */,
                                0DFF0C090B6BCEC200549488 /* HandBrakeCLI */,
-                               0D096DFE0B707D1200A845D4 /* libhb dlib */,
+                               27F143770F5DF34F00A684FF /* external */,
+                               27F143850F5DF37600A684FF /* libhb */,
+                               27F1437E0F5DF36000A684FF /* contrib */,
                        );
                };
 /* End PBXProject section */
                                E39AA4E90D32DC0B0007A415 /* PictureSettings.xib in Resources */,
                                E39AA4EA0D32DC0B0007A415 /* AdvancedView.xib in Resources */,
                                E39AA4EB0D32DC0B0007A415 /* OutputPanel.xib in Resources */,
+                               A27BB4EA0EFAB9310027CDF9 /* PicturePreview.xib in Resources */,
+                               A256080C0FD06720006A4277 /* Brushed_Window.png in Resources */,
+                               2728D25B0FE8419900758EC9 /* HandBrake-64.icns in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
-               0D096DFC0B707D1200A845D4 /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               A25289E70D87A2CB00461D5B /* enctheora.c in Sources */,
-                               D4D49FED0C83355600F01215 /* lang.c in Sources */,
-                               0DFA5CD90B8DD4210020BC09 /* declpcm.c in Sources */,
-                               0DFA5CDA0B8DD4210020BC09 /* decmpeg2.c in Sources */,
-                               0DFA5CDB0B8DD4210020BC09 /* decsub.c in Sources */,
-                               0DFA5CDC0B8DD4210020BC09 /* demuxmpeg.c in Sources */,
-                               0DFA5CDD0B8DD4210020BC09 /* dvd.c in Sources */,
-                               0DFA5CDE0B8DD4210020BC09 /* encavcodec.c in Sources */,
-                               0DFA5CDF0B8DD4210020BC09 /* encfaac.c in Sources */,
-                               0DFA5CE00B8DD4210020BC09 /* enclame.c in Sources */,
-                               0DFA5CE10B8DD4210020BC09 /* encvorbis.c in Sources */,
-                               0DFA5CE20B8DD4210020BC09 /* encx264.c in Sources */,
-                               0DFA5CE30B8DD4210020BC09 /* encxvid.c in Sources */,
-                               0DFA5CE40B8DD4210020BC09 /* fifo.c in Sources */,
-                               0DFA5CE50B8DD4210020BC09 /* hb.c in Sources */,
-                               0DFA5CE70B8DD4210020BC09 /* muxavi.c in Sources */,
-                               0DFA5CE80B8DD4210020BC09 /* muxcommon.c in Sources */,
-                               0DFA5CE90B8DD4210020BC09 /* muxmp4.c in Sources */,
-                               0DFA5CEA0B8DD4210020BC09 /* muxogm.c in Sources */,
-                               0DFA5CEB0B8DD4210020BC09 /* ports.c in Sources */,
-                               0DFA5CEC0B8DD4210020BC09 /* reader.c in Sources */,
-                               0DFA5CED0B8DD4210020BC09 /* render.c in Sources */,
-                               0DFA5CEE0B8DD4210020BC09 /* scan.c in Sources */,
-                               0DFA5CEF0B8DD4210020BC09 /* sync.c in Sources */,
-                               0DFA5CF00B8DD4210020BC09 /* update.c in Sources */,
-                               0DFA5CF10B8DD4210020BC09 /* work.c in Sources */,
-                               0D096E010B707D3400A845D4 /* common.c in Sources */,
-                               0D096E020B707D3400A845D4 /* deca52.c in Sources */,
-                               0D096E030B707D3400A845D4 /* decavcodec.c in Sources */,
-                               5558B56A0BE3BADF00E15E27 /* decdca.c in Sources */,
-                               EAA526940C3B25D200944FF2 /* stream.c in Sources */,
-                               A273E09B0C57C1CD00493A45 /* muxmkv.c in Sources */,
-                               FC8519540C59A02C0073812C /* denoise.c in Sources */,
-                               FC8519550C59A02C0073812C /* deinterlace.c in Sources */,
-                               FC8519560C59A02C0073812C /* deblock.c in Sources */,
-                               FC8519570C59A02C0073812C /* detelecine.c in Sources */,
-                               749701100DC281BB009200D8 /* decomb.c in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
-               0DFF0B6F0B6BC6E600549488 /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               0DFA5CC00B8DD3FE0020BC09 /* declpcm.c in Sources */,
-                               0DFA5CC10B8DD3FE0020BC09 /* decmpeg2.c in Sources */,
-                               0DFA5CC20B8DD3FE0020BC09 /* decsub.c in Sources */,
-                               0DFA5CC30B8DD3FE0020BC09 /* demuxmpeg.c in Sources */,
-                               0DFA5CC40B8DD3FE0020BC09 /* dvd.c in Sources */,
-                               0DFA5CC50B8DD3FE0020BC09 /* encavcodec.c in Sources */,
-                               0DFA5CC60B8DD3FE0020BC09 /* encfaac.c in Sources */,
-                               0DFA5CC70B8DD3FE0020BC09 /* enclame.c in Sources */,
-                               0DFA5CC80B8DD3FE0020BC09 /* encvorbis.c in Sources */,
-                               0DFA5CC90B8DD3FE0020BC09 /* encx264.c in Sources */,
-                               0DFA5CCA0B8DD3FE0020BC09 /* encxvid.c in Sources */,
-                               0DFA5CCB0B8DD3FE0020BC09 /* fifo.c in Sources */,
-                               0DFA5CCC0B8DD3FE0020BC09 /* hb.c in Sources */,
-                               0DFA5CCE0B8DD3FE0020BC09 /* muxavi.c in Sources */,
-                               0DFA5CCF0B8DD3FE0020BC09 /* muxcommon.c in Sources */,
-                               0DFA5CD00B8DD3FE0020BC09 /* muxmp4.c in Sources */,
-                               0DFA5CD10B8DD3FE0020BC09 /* muxogm.c in Sources */,
-                               0DFA5CD20B8DD3FE0020BC09 /* ports.c in Sources */,
-                               0DFA5CD30B8DD3FE0020BC09 /* reader.c in Sources */,
-                               0DFA5CD40B8DD3FE0020BC09 /* render.c in Sources */,
-                               0DFA5CD50B8DD3FE0020BC09 /* scan.c in Sources */,
-                               0DFA5CD60B8DD3FE0020BC09 /* sync.c in Sources */,
-                               0DFA5CD70B8DD3FE0020BC09 /* update.c in Sources */,
-                               0DFA5CD80B8DD3FE0020BC09 /* work.c in Sources */,
-                               0DFF0B770B6BC72A00549488 /* common.c in Sources */,
-                               0DFF0B790B6BC72A00549488 /* deca52.c in Sources */,
-                               0DFF0B7A0B6BC72A00549488 /* decavcodec.c in Sources */,
-                               593034EC0BBA39A100172349 /* ChapterTitles.m in Sources */,
-                               5558B5690BE3BADF00E15E27 /* decdca.c in Sources */,
-                               EAA526930C3B25D200944FF2 /* stream.c in Sources */,
-                               A273E09A0C57C1CC00493A45 /* muxmkv.c in Sources */,
-                               FC8519500C59A02C0073812C /* denoise.c in Sources */,
-                               FC8519510C59A02C0073812C /* deinterlace.c in Sources */,
-                               FC8519520C59A02C0073812C /* deblock.c in Sources */,
-                               FC8519530C59A02C0073812C /* detelecine.c in Sources */,
-                               B48359A80C82960500E04440 /* lang.c in Sources */,
-                               A25289E60D87A27D00461D5B /* enctheora.c in Sources */,
-                               7497010F0DC281BB009200D8 /* decomb.c in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
                0DFF0C070B6BCEC200549488 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                                0DFF0C100B6BCEE800549488 /* test.c in Sources */,
-                               0DF377980B7BF99A00115CB0 /* fakexcode.cpp in Sources */,
                                59CBD2370BBB44DA004A3BE3 /* parsecsv.c in Sources */,
+                               27AC71850F5A0AF600053B83 /* fakexcode.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        files = (
                                59CBD2650BBB4D1B004A3BE3 /* ChapterTitles.m in Sources */,
                                4DD93F9A082036E8008E1322 /* main.mm in Sources */,
-                               4DD93F9B082036E8008E1322 /* Controller.mm in Sources */,
-                               4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */,
+                               4DD93F9B082036E8008E1322 /* Controller.m in Sources */,
+                               4DD93F9E082036E8008E1322 /* HBPreviewController.m in Sources */,
                                A2A1EC3A0C76C58400827E0D /* HBDVDDetector.m in Sources */,
                                253886020BFE0A5B0064E995 /* HBOutputRedirect.m in Sources */,
                                253886180BFE0C160064E995 /* HBOutputPanelController.m in Sources */,
                                A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */,
                                E37172670C977D340072B384 /* HBImageAndTextCell.m in Sources */,
                                A22C85ED0D05D35100C10E36 /* HBPresets.m in Sources */,
+                               A2BEA5FC0F2A1ED1001CE7A1 /* PictureController.m in Sources */,
+                               A2D18AA80FD81C50003C997B /* HBSubtitles.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
-               0D6E35910B6BD5FA005AABB3 /* PBXTargetDependency */ = {
+               277C2E540F5DFF400067D708 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
-                       target = 0DFF0B710B6BC6E600549488 /* libhb */;
-                       targetProxy = 0D6E35900B6BD5FA005AABB3 /* PBXContainerItemProxy */;
+                       target = 27F143770F5DF34F00A684FF /* external */;
+                       targetProxy = 277C2E530F5DFF400067D708 /* PBXContainerItemProxy */;
                };
-               0DFF0BF40B6BCCB900549488 /* PBXTargetDependency */ = {
+               277C2E560F5DFF450067D708 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
-                       target = 0DFF0B710B6BC6E600549488 /* libhb */;
-                       targetProxy = 0DFF0BF30B6BCCB900549488 /* PBXContainerItemProxy */;
+                       target = 27F143770F5DF34F00A684FF /* external */;
+                       targetProxy = 277C2E550F5DFF450067D708 /* PBXContainerItemProxy */;
                };
 /* End PBXTargetDependency section */
 
                        name = InfoPlist.strings;
                        sourceTree = "<group>";
                };
+               A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */ = {
+                       isa = PBXVariantGroup;
+                       children = (
+                               A27BB4E90EFAB9310027CDF9 /* English */,
+                       );
+                       name = PicturePreview.xib;
+                       sourceTree = "<group>";
+               };
                E39AA4DA0D32DC0B0007A415 /* MainMenu.xib */ = {
                        isa = PBXVariantGroup;
                        children = (
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
-               0D096E660B707D5800A845D4 /* Development */ = {
+               0DFF0C0D0B6BCEE000549488 /* debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
-                               COPY_PHASE_STRIP = NO;
-                               DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 1;
-                               EXECUTABLE_PREFIX = lib;
-                               GCC_DYNAMIC_NO_PIC = NO;
-                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-                               GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
+                               PRODUCT_NAME = HandBrakeCLI;
+                       };
+                       name = debug;
+               };
+               0DFF0C0E0B6BCEE000549488 /* standard */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
                                OTHER_LDFLAGS = (
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
-                                       "-ldl",
-                                       "-flat_namespace",
-                                       "-read_only_relocs",
-                                       suppress,
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
-                               PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SEPARATE_STRIP = YES;
-                               ZERO_LINK = NO;
+                               PRODUCT_NAME = HandBrakeCLI;
                        };
-                       name = Development;
+                       name = standard;
                };
-               0D096E670B707D5800A845D4 /* Deployment */ = {
+               27B4DEB20F65BAB600098046 /* standard.i386 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
-                               COPY_PHASE_STRIP = YES;
-                               DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 1;
-                               EXECUTABLE_PREFIX = lib;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
+                               ARCHS = i386;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
                                GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
-                               GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
-                               );
-                               OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
-                               OTHER_LDFLAGS = (
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
-                                       "-ldl",
-                                       "-flat_namespace",
-                                       "-read_only_relocs",
-                                       suppress,
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
                                );
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
                                PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SEPARATE_STRIP = YES;
-                               ZERO_LINK = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = Deployment;
+                       name = standard.i386;
                };
-               0D096E690B707D5800A845D4 /* UB */ = {
+               27B4DEB30F65BAB600098046 /* standard.i386 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
-                               DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 1;
-                               EXECUTABLE_PREFIX = lib;
-                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
                                );
-                               OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = standard.i386;
+               };
+               27B4DEB40F65BAB600098046 /* standard.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
                                OTHER_LDFLAGS = (
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
-                                       "-ldl",
-                                       "-flat_namespace",
-                                       "-read_only_relocs",
-                                       suppress,
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
-                               PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SEPARATE_STRIP = YES;
-                               ZERO_LINK = NO;
+                               PRODUCT_NAME = HandBrakeCLI;
                        };
-                       name = UB;
+                       name = standard.i386;
                };
-               0D88F56B0B6CDCD400F81F26 /* UB */ = {
+               27B4DEB50F65BAB600098046 /* standard.i386 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
-                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
+                               PRODUCT_NAME = external;
+                       };
+                       name = standard.i386;
+               };
+               27B4DEB60F65BAB600098046 /* standard.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = standard.i386;
+               };
+               27B4DEB70F65BAB600098046 /* standard.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = standard.i386;
+               };
+               27B4DEB80F65BAB700098046 /* standard.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = x86_64;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
+                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
                                GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               MACOSX_DEPLOYMENT_TARGET = 10.3;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
                                );
-                               OTHER_LDFLAGS = "";
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
                                PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = UB;
+                       name = standard.x86_64;
                };
-               0D88F56C0B6CDCD400F81F26 /* UB */ = {
+               27B4DEB90F65BAB700098046 /* standard.x86_64 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               APPCAST_URL = "";
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/..";
-                               CURRENT_PROJECT_VERSION = "";
-                               FRAMEWORK_SEARCH_PATHS = (
-                                       "$(inherited)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_2)",
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\"";
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)\"";
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_TREAT_WARNINGS_AS_ERRORS = NO;
-                               HEADER_SEARCH_PATHS = (
-                                       ../libhb,
-                                       ../contrib/include,
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
+                               );
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = standard.x86_64;
+               };
+               27B4DEBA0F65BAB700098046 /* standard.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrakeCLI;
+                       };
+                       name = standard.x86_64;
+               };
+               27B4DEBB0F65BAB700098046 /* standard.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = standard.x86_64;
+               };
+               27B4DEBC0F65BAB700098046 /* standard.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = standard.x86_64;
+               };
+               27B4DEBD0F65BAB700098046 /* standard.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = standard.x86_64;
+               };
+               27B4DEBE0F65BAB800098046 /* standard.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = ppc;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
+                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+                               GCC_MODEL_TUNING = G5;
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
                                );
-                               INFOPLIST_FILE = HandBrake.plist;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
+                       };
+                       name = standard.ppc;
+               };
+               27B4DEBF0F65BAB800098046 /* standard.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
                                PRODUCT_NAME = HandBrake;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SECTORDER_FLAGS = "";
                                WARNING_CFLAGS = (
                                        "-Wmost",
                                        "-Wno-four-char-constants",
                                );
                                WRAPPER_EXTENSION = app;
                        };
-                       name = UB;
+                       name = standard.ppc;
                };
-               0D88F56E0B6CDCD400F81F26 /* UB */ = {
+               27B4DEC00F65BAB800098046 /* standard.ppc */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = ..;
-                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               HEADER_SEARCH_PATHS = ../libhb;
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
                                INSTALL_PATH = /usr/local/bin;
-                               LIBRARY_SEARCH_PATHS = "";
-                               OTHER_CFLAGS = "";
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       "-lz",
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               PREBINDING = NO;
                                PRODUCT_NAME = HandBrakeCLI;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
                        };
-                       name = UB;
+                       name = standard.ppc;
                };
-               0D88F56F0B6CDCD400F81F26 /* UB */ = {
+               27B4DEC10F65BAB800098046 /* standard.ppc */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               ARCHS = (
-                                       ppc,
-                                       i386,
-                               );
+                               PRODUCT_NAME = external;
+                       };
+                       name = standard.ppc;
+               };
+               27B4DEC20F65BAB800098046 /* standard.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = standard.ppc;
+               };
+               27B4DEC30F65BAB800098046 /* standard.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = standard.ppc;
+               };
+               27B4DEC40F65BAB900098046 /* standard.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = ppc64;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
+                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
                                GCC_MODEL_TUNING = G5;
-                               GCC_PREPROCESSOR_DEFINITIONS = "JOB_GROUPS=1";
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
                                IBC_NOTICES = NO;
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
+                               );
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = UB;
+                       name = standard.ppc64;
                };
-               0DFF0B740B6BC70400549488 /* Development */ = {
+               27B4DEC50F65BAB900098046 /* standard.ppc64 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
+                               );
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = standard.ppc64;
+               };
+               27B4DEC60F65BAB900098046 /* standard.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrakeCLI;
+                       };
+                       name = standard.ppc64;
+               };
+               27B4DEC70F65BAB900098046 /* standard.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = standard.ppc64;
+               };
+               27B4DEC80F65BAB900098046 /* standard.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = standard.ppc64;
+               };
+               27B4DEC90F65BAB900098046 /* standard.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = standard.ppc64;
+               };
+               27B4DECA0F65BABC00098046 /* debug.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = i386;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
                                COPY_PHASE_STRIP = NO;
-                               GCC_DYNAMIC_NO_PIC = NO;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-                               GCC_MODEL_TUNING = G5;
                                GCC_OPTIMIZATION_LEVEL = 0;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               MACOSX_DEPLOYMENT_TARGET = 10.3;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
                                );
-                               OTHER_LDFLAGS = "";
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
                                PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               STRIP_INSTALLED_PRODUCT = NO;
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = Development;
+                       name = debug.i386;
                };
-               0DFF0B750B6BC70400549488 /* Deployment */ = {
+               27B4DECB0F65BABC00098046 /* debug.i386 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../libhb";
-                               COPY_PHASE_STRIP = YES;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = 3;
-                               GCC_PRECOMPILE_PREFIX_HEADER = YES;
-                               GCC_PREFIX_HEADER = "";
-                               HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../contrib/include";
-                               INSTALL_PATH = /usr/local/lib;
-                               MACOSX_DEPLOYMENT_TARGET = 10.3;
-                               OTHER_CFLAGS = (
-                                       "-D__LIBHB__",
-                                       "-DSYS_DARWIN",
-                                       "-DUSE_PTHREAD",
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               OTHER_LDFLAGS = "";
-                               PER_ARCH_CFLAGS_ppc = "-DWORDS_BIGENDIAN";
-                               PREBINDING = NO;
-                               PRODUCT_NAME = hb;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
+                               );
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = debug.i386;
+               };
+               27B4DECC0F65BABC00098046 /* debug.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrakeCLI;
+                       };
+                       name = debug.i386;
+               };
+               27B4DECD0F65BABC00098046 /* debug.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
                        };
-                       name = Deployment;
+                       name = debug.i386;
                };
-               0DFF0C0D0B6BCEE000549488 /* Development */ = {
+               27B4DECE0F65BABC00098046 /* debug.i386 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = ..;
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = debug.i386;
+               };
+               27B4DECF0F65BABC00098046 /* debug.i386 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = debug.i386;
+               };
+               27B4DED00F65BABD00098046 /* debug.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = x86_64;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
                                COPY_PHASE_STRIP = NO;
-                               GCC_DYNAMIC_NO_PIC = NO;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               HEADER_SEARCH_PATHS = ../libhb;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
+                               );
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               STRIP_INSTALLED_PRODUCT = NO;
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
+                       };
+                       name = debug.x86_64;
+               };
+               27B4DED10F65BABD00098046 /* debug.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
+                               );
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = debug.x86_64;
+               };
+               27B4DED20F65BABD00098046 /* debug.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
                                INSTALL_PATH = /usr/local/bin;
-                               LIBRARY_SEARCH_PATHS = "";
-                               OTHER_CFLAGS = "";
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       "-lz",
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               PREBINDING = NO;
                                PRODUCT_NAME = HandBrakeCLI;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
                        };
-                       name = Development;
+                       name = debug.x86_64;
                };
-               0DFF0C0E0B6BCEE000549488 /* Deployment */ = {
+               27B4DED30F65BABD00098046 /* debug.x86_64 */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CONFIGURATION_BUILD_DIR = ..;
-                               COPY_PHASE_STRIP = YES;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
-                               GCC_MODEL_TUNING = G5;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               HEADER_SEARCH_PATHS = ../libhb;
+                               PRODUCT_NAME = external;
+                       };
+                       name = debug.x86_64;
+               };
+               27B4DED40F65BABD00098046 /* debug.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = debug.x86_64;
+               };
+               27B4DED50F65BABD00098046 /* debug.x86_64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = debug.x86_64;
+               };
+               27B4DED60F65BABD00098046 /* debug.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = ppc;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               COPY_PHASE_STRIP = NO;
+                               DEBUG_INFORMATION_FORMAT = dwarf;
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
+                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
+                               );
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               STRIP_INSTALLED_PRODUCT = NO;
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
+                       };
+                       name = debug.ppc;
+               };
+               27B4DED70F65BABD00098046 /* debug.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
+                               );
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = debug.ppc;
+               };
+               27B4DED80F65BABD00098046 /* debug.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
                                INSTALL_PATH = /usr/local/bin;
-                               LIBRARY_SEARCH_PATHS = "";
-                               OTHER_CFLAGS = "";
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       "-lz",
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               PREBINDING = NO;
                                PRODUCT_NAME = HandBrakeCLI;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
                        };
-                       name = Deployment;
+                       name = debug.ppc;
+               };
+               27B4DED90F65BABD00098046 /* debug.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = debug.ppc;
                };
-               4D4E7BC1087804870051572B /* Development */ = {
+               27B4DEDA0F65BABD00098046 /* debug.ppc */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               APPCAST_URL = "";
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/..";
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = debug.ppc;
+               };
+               27B4DEDB0F65BABD00098046 /* debug.ppc */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = debug.ppc;
+               };
+               27B4DEDC0F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = ppc64;
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
                                COPY_PHASE_STRIP = NO;
-                               CURRENT_PROJECT_VERSION = "";
-                               FRAMEWORK_SEARCH_PATHS = (
-                                       "$(inherited)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
-                               );
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\"";
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)\"";
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
+                               DEBUG_INFORMATION_FORMAT = dwarf;
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
                                GCC_DYNAMIC_NO_PIC = YES;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-                               GCC_TREAT_WARNINGS_AS_ERRORS = NO;
-                               HEADER_SEARCH_PATHS = (
-                                       ../libhb,
-                                       ../contrib/include,
+                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               IBC_NOTICES = NO;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
                                );
-                               INFOPLIST_FILE = HandBrake.plist;
-                               INFOPLIST_PREPROCESS = NO;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               STRIP_INSTALLED_PRODUCT = NO;
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
+                       };
+                       name = debug.ppc64;
+               };
+               27B4DEDD0F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
                                PRODUCT_NAME = HandBrake;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SECTORDER_FLAGS = "";
                                WARNING_CFLAGS = (
                                        "-Wmost",
                                        "-Wno-four-char-constants",
                                        "-Wno-unknown-pragmas",
                                );
                                WRAPPER_EXTENSION = app;
-                               ZERO_LINK = NO;
                        };
-                       name = Development;
+                       name = debug.ppc64;
+               };
+               27B4DEDE0F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               GCC_C_LANGUAGE_STANDARD = "compiler-default";
+                               INSTALL_PATH = /usr/local/bin;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
+                               );
+                               PRODUCT_NAME = HandBrakeCLI;
+                       };
+                       name = debug.ppc64;
+               };
+               27B4DEDF0F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = debug.ppc64;
+               };
+               27B4DEE00F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = debug.ppc64;
+               };
+               27B4DEE10F65BABD00098046 /* debug.ppc64 */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = debug.ppc64;
+               };
+               27F143780F5DF34F00A684FF /* standard */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = standard;
+               };
+               27F143790F5DF34F00A684FF /* debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = external;
+                       };
+                       name = debug;
+               };
+               27F1437F0F5DF36000A684FF /* standard */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = standard;
                };
-               4D4E7BC2087804870051572B /* Deployment */ = {
+               27F143800F5DF36000A684FF /* debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               APPCAST_URL = "";
-                               CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/..";
-                               COPY_PHASE_STRIP = YES;
-                               CURRENT_PROJECT_VERSION = "";
-                               FRAMEWORK_SEARCH_PATHS = (
-                                       "$(inherited)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
-                                       "$(FRAMEWORK_SEARCH_PATHS_QUOTED_2)",
+                               PRODUCT_NAME = contrib;
+                       };
+                       name = debug;
+               };
+               27F143860F5DF37600A684FF /* standard */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = standard;
+               };
+               27F143870F5DF37600A684FF /* debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = libhb;
+                       };
+                       name = debug;
+               };
+               4D4E7BC1087804870051572B /* debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
+                               OTHER_LDFLAGS = (
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\"";
-                               FRAMEWORK_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)\"";
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               GCC_OPTIMIZATION_LEVEL = s;
-                               GCC_TREAT_WARNINGS_AS_ERRORS = NO;
-                               HEADER_SEARCH_PATHS = (
-                                       ../libhb,
-                                       ../contrib/include,
+                               PRODUCT_NAME = HandBrake;
+                               WARNING_CFLAGS = (
+                                       "-Wmost",
+                                       "-Wno-four-char-constants",
+                                       "-Wno-unknown-pragmas",
                                );
-                               INFOPLIST_FILE = HandBrake.plist;
-                               LIBRARY_SEARCH_PATHS = "";
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
+                               WRAPPER_EXTENSION = app;
+                       };
+                       name = debug;
+               };
+               4D4E7BC2087804870051572B /* standard */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               IBC_PLUGINS = /System/Library/Frameworks/QTKit.framework/Resources/QTKitIBPlugin.ibplugin;
+                               IBC_PLUGIN_SEARCH_PATHS = /System/Library/Frameworks/QTKit.framework/Resources;
+                               INFOPLIST_FILE = Info.plist;
+                               INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional -undef";
+                               INFOPLIST_PREFIX_HEADER = "$(EXTERNAL_BUILD)/macosx/Info.h";
+                               INFOPLIST_PREPROCESS = YES;
                                OTHER_LDFLAGS = (
-                                       ../libhb/libhb.a,
-                                       ../contrib/lib/libmp4v2.a,
-                                       ../contrib/lib/liba52.a,
-                                       ../contrib/lib/libavformat.a,
-                                       ../contrib/lib/libavcodec.a,
-                                       ../contrib/lib/libavutil.a,
-                                       ../contrib/lib/libdvdread.a,
-                                       ../contrib/lib/libfaac.a,
-                                       ../contrib/lib/libmp3lame.a,
-                                       ../contrib/lib/libmpeg2.a,
-                                       ../contrib/lib/libvorbis.a,
-                                       ../contrib/lib/libvorbisenc.a,
-                                       ../contrib/lib/libogg.a,
-                                       ../contrib/lib/libsamplerate.a,
-                                       ../contrib/lib/libx264.a,
-                                       ../contrib/lib/libxvidcore.a,
-                                       ../contrib/lib/libdca.a,
-                                       ../contrib/lib/libmkv.a,
-                                       ../contrib/lib/libswscale.a,
-                                       ../contrib/lib/libtheora.a,
-                                       ../contrib/lib/libfaad.a,
-                                       "-lbz2",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/liba52.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavcodec.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavformat.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libavutil.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdca.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdnav.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libdvdread.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaac.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libfaad.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmkv.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp3lame.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmp4v2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libogg.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libmpeg2.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libsamplerate.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libswscale.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libtheora.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbis.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libvorbisenc.a",
+                                       "$(EXTERNAL_BUILD)/contrib/lib/libx264.a",
                                );
                                PRODUCT_NAME = HandBrake;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               SECTORDER_FLAGS = "";
                                WARNING_CFLAGS = (
                                        "-Wmost",
                                        "-Wno-four-char-constants",
                                        "-Wno-unknown-pragmas",
                                );
                                WRAPPER_EXTENSION = app;
-                               ZERO_LINK = NO;
                        };
-                       name = Deployment;
+                       name = standard;
                };
-               4D4E7BC5087804870051572B /* Development */ = {
+               4D4E7BC5087804870051572B /* debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               COPY_PHASE_STRIP = NO;
                                DEBUG_INFORMATION_FORMAT = dwarf;
-                               GCC_DEBUGGING_SYMBOLS = default;
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
                                GCC_ENABLE_FIX_AND_CONTINUE = YES;
-                               GCC_MODEL_TUNING = G5;
                                GCC_OPTIMIZATION_LEVEL = 0;
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
                                IBC_NOTICES = NO;
-                               IBC_WARNINGS = YES;
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
+                               );
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
                                PREBINDING = NO;
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
-                               ZERO_LINK = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               STRIP_INSTALLED_PRODUCT = NO;
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = Development;
+                       name = debug;
                };
-               4D4E7BC6087804870051572B /* Deployment */ = {
+               4D4E7BC6087804870051572B /* standard */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CONFIGURATION_BUILD_DIR = "$(EXTERNAL_BUILD)";
+                               CONFIGURATION_TEMP_DIR = "$(SYMROOT)";
+                               EXTERNAL_BUILD = "$(EXTERNAL_SRC)/build.$(CONFIGURATION)";
+                               EXTERNAL_JOBS = 2;
+                               EXTERNAL_METHOD = xcode;
+                               EXTERNAL_SRC = ..;
+                               FRAMEWORK_SEARCH_PATHS = "$(EXTERNAL_SRC)/macosx";
+                               GCC_C_LANGUAGE_STANDARD = c99;
+                               GCC_DYNAMIC_NO_PIC = YES;
+                               GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
                                GCC_MODEL_TUNING = G5;
-                               GCC_PREPROCESSOR_DEFINITIONS = "JOB_GROUPS=1";
+                               GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
                                IBC_NOTICES = NO;
-                               MACOSX_DEPLOYMENT_TARGET = 10.5;
-                               OTHER_CFLAGS = "";
-                               SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+                               IBC_WARNINGS = NO;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(EXTERNAL_BUILD)/libhb",
+                                       "$(EXTERNAL_BUILD)/contrib/lib",
+                               );
+                               OBJROOT = "$(EXTERNAL_BUILD)/macosx";
+                               PREBINDING = NO;
+                               SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+                               SHARED_PRECOMPS_DIR = "$(SYMROOT)/cache";
+                               SYMROOT = "$(EXTERNAL_BUILD)/macosx";
                        };
-                       name = Deployment;
+                       name = standard;
                };
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-               0D096E650B707D5800A845D4 /* Build configuration list for PBXNativeTarget "libhb dlib" */ = {
+               0DFF0C0C0B6BCEE000549488 /* Build configuration list for PBXNativeTarget "HandBrakeCLI" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
-                               0D096E660B707D5800A845D4 /* Development */,
-                               0D096E670B707D5800A845D4 /* Deployment */,
-                               0D096E690B707D5800A845D4 /* UB */,
+                               0DFF0C0E0B6BCEE000549488 /* standard */,
+                               27B4DEB40F65BAB600098046 /* standard.i386 */,
+                               27B4DEBA0F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEC00F65BAB800098046 /* standard.ppc */,
+                               27B4DEC60F65BAB900098046 /* standard.ppc64 */,
+                               0DFF0C0D0B6BCEE000549488 /* debug */,
+                               27B4DECC0F65BABC00098046 /* debug.i386 */,
+                               27B4DED20F65BABD00098046 /* debug.x86_64 */,
+                               27B4DED80F65BABD00098046 /* debug.ppc */,
+                               27B4DEDE0F65BABD00098046 /* debug.ppc64 */,
                        );
                        defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Deployment;
+                       defaultConfigurationName = standard;
                };
-               0DFF0B730B6BC70400549488 /* Build configuration list for PBXNativeTarget "libhb" */ = {
+               27F1438E0F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "external" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
-                               0DFF0B740B6BC70400549488 /* Development */,
-                               0DFF0B750B6BC70400549488 /* Deployment */,
-                               0D88F56B0B6CDCD400F81F26 /* UB */,
+                               27F143780F5DF34F00A684FF /* standard */,
+                               27B4DEB50F65BAB600098046 /* standard.i386 */,
+                               27B4DEBB0F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEC10F65BAB800098046 /* standard.ppc */,
+                               27B4DEC70F65BAB900098046 /* standard.ppc64 */,
+                               27F143790F5DF34F00A684FF /* debug */,
+                               27B4DECD0F65BABC00098046 /* debug.i386 */,
+                               27B4DED30F65BABD00098046 /* debug.x86_64 */,
+                               27B4DED90F65BABD00098046 /* debug.ppc */,
+                               27B4DEDF0F65BABD00098046 /* debug.ppc64 */,
                        );
                        defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Deployment;
+                       defaultConfigurationName = standard;
                };
-               0DFF0C0C0B6BCEE000549488 /* Build configuration list for PBXNativeTarget "HandBrakeCLI" */ = {
+               27F1438F0F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "contrib" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               27F1437F0F5DF36000A684FF /* standard */,
+                               27B4DEB70F65BAB600098046 /* standard.i386 */,
+                               27B4DEBD0F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEC30F65BAB800098046 /* standard.ppc */,
+                               27B4DEC90F65BAB900098046 /* standard.ppc64 */,
+                               27F143800F5DF36000A684FF /* debug */,
+                               27B4DECF0F65BABC00098046 /* debug.i386 */,
+                               27B4DED50F65BABD00098046 /* debug.x86_64 */,
+                               27B4DEDB0F65BABD00098046 /* debug.ppc */,
+                               27B4DEE10F65BABD00098046 /* debug.ppc64 */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = standard;
+               };
+               27F143900F5DF3EA00A684FF /* Build configuration list for PBXLegacyTarget "libhb" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
-                               0DFF0C0D0B6BCEE000549488 /* Development */,
-                               0DFF0C0E0B6BCEE000549488 /* Deployment */,
-                               0D88F56E0B6CDCD400F81F26 /* UB */,
+                               27F143860F5DF37600A684FF /* standard */,
+                               27B4DEB60F65BAB600098046 /* standard.i386 */,
+                               27B4DEBC0F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEC20F65BAB800098046 /* standard.ppc */,
+                               27B4DEC80F65BAB900098046 /* standard.ppc64 */,
+                               27F143870F5DF37600A684FF /* debug */,
+                               27B4DECE0F65BABC00098046 /* debug.i386 */,
+                               27B4DED40F65BABD00098046 /* debug.x86_64 */,
+                               27B4DEDA0F65BABD00098046 /* debug.ppc */,
+                               27B4DEE00F65BABD00098046 /* debug.ppc64 */,
                        );
                        defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Deployment;
+                       defaultConfigurationName = standard;
                };
                4D4E7BC0087804870051572B /* Build configuration list for PBXNativeTarget "HandBrake" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
-                               4D4E7BC1087804870051572B /* Development */,
-                               4D4E7BC2087804870051572B /* Deployment */,
-                               0D88F56C0B6CDCD400F81F26 /* UB */,
+                               4D4E7BC2087804870051572B /* standard */,
+                               27B4DEB30F65BAB600098046 /* standard.i386 */,
+                               27B4DEB90F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEBF0F65BAB800098046 /* standard.ppc */,
+                               27B4DEC50F65BAB900098046 /* standard.ppc64 */,
+                               4D4E7BC1087804870051572B /* debug */,
+                               27B4DECB0F65BABC00098046 /* debug.i386 */,
+                               27B4DED10F65BABD00098046 /* debug.x86_64 */,
+                               27B4DED70F65BABD00098046 /* debug.ppc */,
+                               27B4DEDD0F65BABD00098046 /* debug.ppc64 */,
                        );
                        defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Deployment;
+                       defaultConfigurationName = standard;
                };
                4D4E7BC4087804870051572B /* Build configuration list for PBXProject "HandBrake" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
-                               4D4E7BC5087804870051572B /* Development */,
-                               4D4E7BC6087804870051572B /* Deployment */,
-                               0D88F56F0B6CDCD400F81F26 /* UB */,
+                               4D4E7BC6087804870051572B /* standard */,
+                               27B4DEB20F65BAB600098046 /* standard.i386 */,
+                               27B4DEB80F65BAB700098046 /* standard.x86_64 */,
+                               27B4DEBE0F65BAB800098046 /* standard.ppc */,
+                               27B4DEC40F65BAB900098046 /* standard.ppc64 */,
+                               4D4E7BC5087804870051572B /* debug */,
+                               27B4DECA0F65BABC00098046 /* debug.i386 */,
+                               27B4DED00F65BABD00098046 /* debug.x86_64 */,
+                               27B4DED60F65BABD00098046 /* debug.ppc */,
+                               27B4DEDC0F65BABD00098046 /* debug.ppc64 */,
                        );
                        defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Deployment;
+                       defaultConfigurationName = standard;
                };
 /* End XCConfigurationList section */
        };
diff --git a/macosx/Info.h.m4 b/macosx/Info.h.m4
new file mode 100644 (file)
index 0000000..39ff7ad
--- /dev/null
@@ -0,0 +1,14 @@
+dnl
+dnl This file is used by Xcode Packaging for Info.plist preprocessing.
+dnl See Info.plist for how the values are used.
+dnl
+changequote(<<, >>)dnl
+include(<<handbrake.m4>>)dnl
+dnl
+dnl
+dnl
+<<#>>define HB_PLIST_BUNDLEVERSION       __HB_build
+<<#>>define HB_PLIST_DISPLAYNAME         __HB_name
+<<#>>define HB_PLIST_GETINFOSTRING       __HB_build
+<<#>>define HB_PLIST_SHORTVERSIONSTRING  __HB_version __BUILD_arch
+<<#>>define HB_PLIST_SUFEEDURL           __HB_url_appcast
diff --git a/macosx/Info.plist b/macosx/Info.plist
new file mode 100644 (file)
index 0000000..011848a
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleGetInfoString</key>
+       <string>HB_PLIST_GETINFOSTRING</string>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleDisplayName</key>
+       <string>HB_PLIST_DISPLAYNAME</string>
+       <key>CFBundleExecutable</key>
+       <string>${EXECUTABLE_NAME}</string>
+       <key>CFBundleIconFile</key>
+       <string>${EXECUTABLE_NAME}</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.m0k.handbrake</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>${PRODUCT_NAME}</string>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleShortVersionString</key>
+       <string>HB_PLIST_SHORTVERSIONSTRING</string>
+       <key>CFBundleSignature</key>
+       <string>HB##</string>
+       <key>CFBundleVersion</key>
+       <string>HB_PLIST_BUNDLEVERSION</string>
+       <key>NSMainNibFile</key>
+       <string>MainMenu</string>
+       <key>NSPrincipalClass</key>
+       <string>NSApplication</string>
+       <key>NSHumanReadableCopyright</key>
+       <string>© 2003-2009, HandBrake Developers</string>
+       <key>SUFeedURL</key>
+       <string>HB_PLIST_SUFEEDURL</string>
+</dict>
+</plist>
index 24631c3..4a1dd61 100644 (file)
@@ -6,24 +6,45 @@
 
 #import <Cocoa/Cocoa.h>
 
-#include "hb.h"
+#include "hb.h" 
 
-#define HB_NUM_HBLIB_PICTURES      10   // hbilb generates 10 preview pictures
+@class HBController;
+@class PreviewController;
+
+
+
+//#define HB_NUM_HBLIB_PICTURES      20   // # of preview pictures libhb should generate
 
 @interface PictureController : NSWindowController
 {
     hb_handle_t              * fHandle;
     hb_title_t               * fTitle;
 
+    HBController             *fHBController;
+    PreviewController        *fPreviewController;        // reference to HBController
+    
+    IBOutlet NSWindow        * fPictureWindow;
+    
+    IBOutlet NSTabView       * fSizeFilterView;
+    IBOutlet NSTabViewItem   * fSizeTabView;
+    IBOutlet NSTabViewItem   * fFilterTabView;
+    
+    /* Picture Sizing */
+    
     NSMutableDictionary      * fPicturePreviews;        // NSImages, one for each preview libhb creates, created lazily
     int                        fPicture;
 
-    IBOutlet NSImageView     * fPictureView;
-    IBOutlet NSBox           * fPictureViewArea;
+
+    IBOutlet NSBox           * fPictureSizeBox;
+    IBOutlet NSBox           * fPictureCropBox;
+    
+    IBOutlet NSTextField     * fWidthLabel;
     IBOutlet NSTextField     * fWidthField;
     IBOutlet NSStepper       * fWidthStepper;
     IBOutlet NSTextField     * fHeightField;
     IBOutlet NSStepper       * fHeightStepper;
+    IBOutlet NSTextField     * fRatioLabel;
+    IBOutlet NSTextField     * fRatioLabel2; // shown for capuj
     IBOutlet NSButton        * fRatioCheck;
     IBOutlet NSMatrix        * fCropMatrix;
     IBOutlet NSTextField     * fCropTopField;
     IBOutlet NSStepper       * fCropLeftStepper;
     IBOutlet NSTextField     * fCropRightField;
     IBOutlet NSStepper       * fCropRightStepper;
-    IBOutlet NSPopUpButton   * fDeinterlacePopUp;
-    IBOutlet NSPopUpButton   * fDecombPopUp;
-       IBOutlet NSButton        * fDetelecineCheck;
-    IBOutlet NSButton        * fDeblockCheck;
-    IBOutlet NSTextField     * fDeblockField;
-    IBOutlet NSSlider        * fDeblockSlider;
-       IBOutlet NSPopUpButton   * fDenoisePopUp;
+    
+    IBOutlet NSTextField     * fModulusLabel;
+    IBOutlet NSPopUpButton   * fModulusPopUp;
+    /* linkers for capuj */
+    IBOutlet NSBox           * fStorageLinkBox;
+    IBOutlet NSSlider        * fStorageLinkSlider;
+    IBOutlet NSTextField     * fStorageLinkParLabel;
+    IBOutlet NSTextField     * fStorageLinkDisplayLabel;
+    
+    IBOutlet NSSlider        * fParLinkSlider;
+    IBOutlet NSTextField     * fParLinkStorageLabel;
+    IBOutlet NSTextField     * fParLinkDisplayLabel;
+    
+    IBOutlet NSSlider        * fDisplayLinkSlider;
+    IBOutlet NSTextField     * fDisplayLinkStorageLabel;
+    IBOutlet NSTextField     * fDisplayLinkParLabel;
+    
+    
+    IBOutlet NSTextField     * fDisplayWidthField;
+    IBOutlet NSTextField     * fDisplayWidthLabel;
+    
+    IBOutlet NSTextField     * fParWidthField;
+    IBOutlet NSTextField     * fParHeightField;
+    IBOutlet NSTextField     * fParWidthLabel;
+    IBOutlet NSTextField     * fParHeightLabel;
+
+    /* for now we setup some values to remember our pars and dars
+     * from scan
+    */
+    float titleDarWidth;
+    float titleDarHeight;
+    
+    int titleParWidth;
+    int titleParHeight;
+    float dar;
+    IBOutlet NSButton        * fResetParDarButton;
+    
        IBOutlet NSPopUpButton   * fAnamorphicPopUp;
-    IBOutlet NSButton        * fPrevButton;
-    IBOutlet NSButton        * fNextButton;
-    IBOutlet NSTextField     * fInfoField;
+    IBOutlet NSTextField     * fSizeInfoField;
        
+    IBOutlet NSButton        * fPreviewOpenButton;
+    IBOutlet NSButton        * fPictureFiltersOpenButton;
+        
     int     MaxOutputWidth;
     int     MaxOutputHeight;
     BOOL    autoCrop;
-    BOOL    allowLooseAnamorphic;
+    
     int output_width, output_height, output_par_width, output_par_height;
     int display_width;
+    
+    int modulus;
+    
     /* used to track the previous state of the keep aspect
     ratio checkbox when turning anamorphic on, so it can be
     returned to the previous state when anamorphic is turned
     off */
-    BOOL    keepAspectRatioPreviousState; 
+    BOOL    keepAspectRatioPreviousState;
+    
+    
+    /* Video Filters */
+    
+    IBOutlet NSBox           * fPictureFilterBox;
+
+    IBOutlet NSBox           * fDetelecineBox;
+    IBOutlet NSPopUpButton   * fDetelecinePopUp;
+    IBOutlet NSTextField     * fDetelecineField;
+    
+    IBOutlet NSBox           * fDecombDeinterlaceBox;
+    IBOutlet NSSlider        * fDecombDeinterlaceSlider;
+    
+    IBOutlet NSBox           * fDecombBox;
+    IBOutlet NSPopUpButton   * fDecombPopUp;
+    IBOutlet NSTextField     * fDecombField;
     
-    struct {
+    IBOutlet NSBox           * fDeinterlaceBox;
+    IBOutlet NSPopUpButton   * fDeinterlacePopUp;
+    IBOutlet NSTextField     * fDeinterlaceField;
+
+    IBOutlet NSBox           * fDenoiseBox;
+    IBOutlet NSPopUpButton   * fDenoisePopUp;
+    IBOutlet NSTextField     * fDenoiseField;
+       
+    
+    IBOutlet NSBox           * fDeblockBox; // also holds the grayscale box
+    IBOutlet NSButton        * fDeblockCheck;
+    IBOutlet NSTextField     * fDeblockField;
+    IBOutlet NSSlider        * fDeblockSlider;
+    
+    IBOutlet NSButton        * fGrayscaleCheck;
+
+    IBOutlet NSTextField     * fInfoField;
+       
+
+    
+        struct {
         int     detelecine;
         int     deinterlace;
         int     decomb;
+        int     usedecomb;
         int     denoise;
         int     deblock;
+        int     grayscale;
     } fPictureFilterSettings;
-
-    id delegate;
+    
 }
-- (id)initWithDelegate:(id)del;
+- (id)init;
 
 - (void) SetHandle: (hb_handle_t *) handle;
 - (void) SetTitle:  (hb_title_t *)  title;
-- (void) setInitialPictureFilters;
-- (void) displayPreview;
+- (void)setHBController: (HBController *)controller;
+- (IBAction) showPictureWindow: (id)sender;
+- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
+- (IBAction) resizeInspectorForTab: (id)sender;
+- (IBAction) showPreviewWindow: (id)sender;
+- (BOOL) previewFullScreenMode;
+- (IBAction) previewGoWindowed: (id)sender;
+
+- (IBAction) adjustSizingDisplay: (id) sender;
+
 
 - (IBAction) SettingsChanged: (id) sender;
-- (IBAction) PreviousPicture: (id) sender;
-- (IBAction) NextPicture: (id) sender;
-- (IBAction) ClosePanel: (id) sender;
+
+- (NSString*) getPictureSizeInfoString;
+- (void)reloadStillPreview;
 
 - (BOOL) autoCrop;
 - (void) setAutoCrop: (BOOL) setting;
 
-- (BOOL) allowLooseAnamorphic;
-- (void) setAllowLooseAnamorphic: (BOOL) setting;
+- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title;
+- (IBAction) storageLinkChanged: (id) sender;
+- (IBAction) parLinkChanged: (id) sender;
+- (IBAction) displayLinkChanged: (id) sender;
+- (void) setToFullScreenMode;
+- (void) setToWindowedMode;
+
+/* Filter Actions */
+- (void) setInitialPictureFilters;
+- (IBAction) FilterSettingsChanged: (id) sender;
+- (IBAction) adjustFilterDisplay: (id) sender;
+- (IBAction) modeDecombDeinterlaceSliderChanged: (id) sender;
 - (IBAction) deblockSliderChanged: (id) sender;
+
 - (int) detelecine;
+- (NSString*) detelecineCustomString;
 - (void) setDetelecine: (int) setting;
-- (int) deinterlace;
-- (void) setDeinterlace: (int) setting;
+- (void) setDetelecineCustomString: (NSString*) string;
+
+- (int) useDecomb;
+- (void) setUseDecomb: (int) setting;
+
 - (int) decomb;
+- (NSString*) decombCustomString;
 - (void) setDecomb: (int) setting;
+- (void) setDecombCustomString: (NSString*) string;
+
+- (int) deinterlace;
+- (NSString*) deinterlaceCustomString;
+- (void) setDeinterlace: (int) setting;
+- (void) setDeinterlaceCustomString: (NSString*) string; 
+
 - (int) denoise;
+- (NSString*) denoiseCustomString;
 - (void) setDenoise: (int) setting;
+- (void) setDenoiseCustomString: (NSString*) string;
+
 - (int) deblock;
 - (void) setDeblock: (int) setting;
 
-- (void)showPanelInWindow: (NSWindow *)fWindow forTitle: (hb_title_t *)title;
+- (int) grayscale;
+- (void) setGrayscale: (int) setting;
+
 
-+ (NSImage *) makeImageForPicture: (int)pictureIndex
-                libhb:(hb_handle_t*)handle
-                title:(hb_title_t*)title
-                removeBorders:(BOOL)removeBorders;
-- (NSImage *) imageForPicture: (int) pictureIndex;
-- (void) purgeImageCache;
-@end
 
-@interface NSObject (PictureControllertDelegateMethod)
-- (void)pictureSettingsDidChange;
 @end
+
diff --git a/macosx/PictureController.m b/macosx/PictureController.m
new file mode 100644 (file)
index 0000000..67fe65f
--- /dev/null
@@ -0,0 +1,1371 @@
+/* $Id: PictureController.mm,v 1.11 2005/08/01 15:10:44 titer Exp $
+
+   This file is part of the HandBrake source code.
+   Homepage: <http://handbrake.fr/>.
+   It may be used under the terms of the GNU General Public License. */
+
+#import "PictureController.h"
+#import "Controller.h"
+#import "HBPreviewController.h"
+
+
+
+@implementation PictureController
+
+- (id)init
+{
+       if (self = [super initWithWindowNibName:@"PictureSettings"])
+       {
+        // NSWindowController likes to lazily load its window. However since
+        // this controller tries to set all sorts of outlets before the window
+        // is displayed, we need it to load immediately. The correct way to do
+        // this, according to the documentation, is simply to invoke the window
+        // getter once.
+        //
+        // If/when we switch a lot of this stuff to bindings, this can probably
+        // go away.
+        [self window];
+        
+       fPreviewController = [[PreviewController alloc] init];
+    }
+       return self;
+}
+
+//------------------------------------------------------------------------------------
+// Displays and brings the picture window to the front
+//------------------------------------------------------------------------------------
+- (IBAction) showPictureWindow: (id)sender
+{
+    if ([fPreviewController fullScreen] == YES)
+    {
+        [self showWindow:sender];
+        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"];
+        [self setToFullScreenMode];
+    }
+    else
+    {
+        if ([[self window] isVisible])
+        {
+            [[self window] close];
+        }
+        else
+        {
+            [self showWindow:sender];
+            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"];
+            [self setToWindowedMode];
+        }
+    }
+    [self adjustFilterDisplay:nil];
+    [self adjustSizingDisplay:nil];
+}
+
+- (BOOL) previewFullScreenMode
+{
+    return [fPreviewController fullScreen];
+}
+
+/* this method is used to detect clicking on a tab in fSizeFilterView */
+- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+
+[self resizeInspectorForTab:nil];
+
+}
+
+#pragma mark -
+
+/* resizeInspectorForTab is called at launch, and each time either the 
+ * Size or Filters tab is clicked. Size gives a horizontally oriented
+ * inspector and Filters is a vertically aligned inspector.
+ */
+- (IBAction) resizeInspectorForTab: (id)sender
+{
+    NSRect frame = [[self window] frame];
+    NSPoint windowOrigin = [[self window] frame].origin;
+    NSSize screenSize = [[[self window] screen] frame].size;
+    NSPoint screenOrigin = [[[self window] screen] frame].origin;
+    
+    /* We base our inspector size/layout on which tab is active for fSizeFilterView */
+    /* we are 1 which is Filters*/
+    if ([fSizeFilterView indexOfTabViewItem: [fSizeFilterView selectedTabViewItem]] == 1)
+    {
+        frame.size.width = 314;
+        /* we glean the height from the size of the boxes plus the extra window space
+         * needed for non boxed display
+         */
+        frame.size.height = 110.0 + [fDetelecineBox frame].size.height + [fDecombDeinterlaceBox frame].size.height + [fDenoiseBox frame].size.height + [fDeblockBox frame].size.height;
+        /* Hide the size readout at the bottom as the vertical inspector is not wide enough */
+        [fSizeInfoField setHidden:YES];
+    }
+    else // we are Tab index 0 which is size
+    {
+        frame.size.width = 50.0 + [fPictureSizeBox frame].size.width + [fPictureCropBox frame].size.width;
+        frame.size.height = [fPictureSizeBox frame].size.height + 85;
+        /* hide the size summary field at the bottom */
+        [fSizeInfoField setHidden:NO];      
+    }
+    /* get delta's for the change in window size */
+    CGFloat deltaX = frame.size.width - [[self window] frame].size.width;
+    CGFloat deltaY = frame.size.height - [[self window] frame].size.height;
+    
+    /* Check to see if we have changed the height from current */
+    //if (frame.size.height != [[self window] frame].size.height)
+    //{
+        /* change the inspector origin via the deltaY */
+        frame.origin.y -= deltaY;
+        /* keep the inspector centered so the tabs stay in place */
+        frame.origin.x -= deltaX / 2.0;
+    //}
+    
+     /* we make sure we are not horizontally off of our screen.
+     * this would be the case if we are on the vertical filter tab
+     * and we hit the size tab and the inspector grows horizontally
+     * off the screen to the right
+    */
+    if ((frame.origin.x + frame.size.width) > (screenOrigin.x + screenSize.width))
+    {
+        /* the right side of the preview is off the screen, so shift to the left */
+        frame.origin.x = (screenOrigin.x + screenSize.width) - frame.size.width;
+    }
+    
+    [[self window] setFrame:frame display:YES animate:YES];
+}
+
+- (IBAction) adjustSizingDisplay: (id) sender
+{
+    NSSize pictureSizingBoxSize = [fPictureSizeBox frame].size;
+    
+    NSPoint fPictureSizeBoxOrigin = [fPictureSizeBox frame].origin;
+    NSSize pictureCropBoxSize = [fPictureCropBox frame].size;
+    NSPoint fPictureCropBoxOrigin = [fPictureCropBox frame].origin;
+    
+    if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree
+    {
+        pictureSizingBoxSize.width = 530;
+        
+        /* Set visibility of capuj widgets */
+        [fParWidthField setHidden: NO];
+        [fParHeightField setHidden: NO];
+        [fParWidthLabel setHidden: NO];
+        [fParHeightLabel setHidden: NO];
+        [fDisplayWidthField setHidden: NO];
+        [fDisplayWidthLabel setHidden: NO];
+        [fModulusLabel setHidden: NO];
+        [fModulusPopUp setHidden: NO];
+        /* adjust/move keep ar checkbox */
+        [fRatioLabel setHidden: YES];
+        [fRatioLabel2 setHidden: NO];
+        
+        /* Optionally swith the Storage and Display width positions*/
+         /*
+         NSPoint fWidthLabelOrigin = [fWidthLabel frame].origin;
+         NSPoint fWidthFieldOrigin = [fWidthField frame].origin;
+         NSPoint fWidthStepperOrigin = [fWidthStepper frame].origin;
+         fWidthFieldOrigin.x = [fRatioLabel2 frame].origin.x + [fRatioLabel2 frame].size.width + 4;
+         [fWidthField setFrameOrigin:fWidthFieldOrigin];
+
+         fWidthStepperOrigin.x = [fWidthField frame].origin.x + [fWidthField frame].size.width + 4;
+         [fWidthStepper setFrameOrigin:fWidthStepperOrigin];
+         
+         fWidthLabelOrigin.x = [fWidthField frame].origin.x - [fWidthLabel frame].size.width - 4;
+         [fWidthLabel setFrameOrigin:fWidthLabelOrigin];
+         [fWidthLabel setStringValue:@"Storage Width:"];
+         */
+        
+        /* set the origin for fRatioCheck so origin.y == fRatioLabel2
+         * and origin.x == fDisplayWidthField
+         */
+         NSPoint fRatioCheckOrigin = [fRatioCheck frame].origin;
+         fRatioCheckOrigin.y = [fRatioLabel2 frame].origin.y - 2;
+         fRatioCheckOrigin.x = [fRatioLabel2 frame].origin.x + [fRatioLabel2 frame].size.width + 4;
+         [fRatioCheck setFrameOrigin:fRatioCheckOrigin];
+         
+    }
+    else
+    {
+        pictureSizingBoxSize.width = 200;
+        
+        /* Set visibility of capuj widgets */
+        [fParWidthField setHidden: YES];
+        [fParHeightField setHidden: YES];
+        [fParWidthLabel setHidden: YES];
+        [fParHeightLabel setHidden: YES];
+        [fDisplayWidthField setHidden: YES];
+        [fDisplayWidthLabel setHidden: YES];
+        [fModulusLabel setHidden: YES];
+        [fModulusPopUp setHidden: YES];
+        /* adjust/move keep ar checkbox */
+        [fRatioLabel setHidden: NO];
+        [fRatioLabel2 setHidden: YES];
+        
+         /* Optionally swith the Storage and Display width positions*/
+         
+         /*
+         NSPoint fWidthLabelOrigin = [fWidthLabel frame].origin;
+         NSPoint fWidthFieldOrigin = [fWidthField frame].origin;
+         NSPoint fWidthStepperOrigin = [fWidthStepper frame].origin;
+         
+         fWidthFieldOrigin.x = [fHeightField frame].origin.x;
+         [fWidthField setFrameOrigin:fWidthFieldOrigin];
+         
+         fWidthStepperOrigin.x = [fHeightStepper frame].origin.x;
+         [fWidthStepper setFrameOrigin:fWidthStepperOrigin];
+         
+         fWidthLabelOrigin.x = [fWidthField frame].origin.x - [fWidthLabel frame].size.width -4;
+         [fWidthLabel setFrameOrigin:fWidthLabelOrigin];
+         [fWidthLabel setStringValue:@"Width:"];
+         */
+        
+        
+        /* set the origin for fRatioCheck so origin.y == fRatioLabel
+         * and origin.x == fWidthStepper
+         */
+         NSPoint fRatioCheckOrigin = [fRatioCheck frame].origin;
+         fRatioCheckOrigin.y = [fRatioLabel frame].origin.y - 2;
+         fRatioCheckOrigin.x = [fWidthStepper frame].origin.x - 2;
+         [fRatioCheck setFrameOrigin:fRatioCheckOrigin];
+        
+    }
+    
+    /* Check to see if we have changed the size from current */
+    if (pictureSizingBoxSize.height != [fPictureSizeBox frame].size.height || pictureSizingBoxSize.width != [fPictureSizeBox frame].size.width)
+    {
+        /* Get our delta for the change in picture size box height */
+        CGFloat deltaYSizeBoxShift = pictureSizingBoxSize.height - [fPictureSizeBox frame].size.height;
+        fPictureSizeBoxOrigin.y -= deltaYSizeBoxShift;
+        /* Get our delta for the change in picture size box width */
+        CGFloat deltaXSizeBoxShift = pictureSizingBoxSize.width - [fPictureSizeBox frame].size.width;
+        //fPictureSizeBoxOrigin.x += deltaXSizeBoxShift;
+        /* set our new Picture size box size */
+        [fPictureSizeBox setFrameSize:pictureSizingBoxSize];
+        [fPictureSizeBox setFrameOrigin:fPictureSizeBoxOrigin];
+        
+        pictureCropBoxSize.height += deltaYSizeBoxShift;
+        fPictureCropBoxOrigin.y -= deltaYSizeBoxShift;
+        fPictureCropBoxOrigin.x += deltaXSizeBoxShift;
+        
+        [fPictureCropBox setFrameSize:pictureCropBoxSize];
+        [[fPictureCropBox animator] setFrameOrigin:fPictureCropBoxOrigin];
+    }
+
+    
+    /* now we call to resize the entire inspector window */
+   [self resizeInspectorForTab:nil];
+}
+
+- (IBAction) adjustFilterDisplay: (id) sender
+{
+    
+    NSBox * filterBox = nil;
+    NSTextField * filterField;
+    if (sender == fDetelecinePopUp)
+    {
+        filterBox = fDetelecineBox;
+        filterField = fDetelecineField;
+    }
+    
+    if (sender == fDecombDeinterlaceSlider)
+    {
+        if ([fDecombDeinterlaceSlider floatValue] == 0.0)
+        {
+            filterBox = fDecombBox;
+            filterField = fDecombField;
+        }
+        else
+        {
+            filterBox = fDeinterlaceBox;
+            filterField = fDeinterlaceField;
+        }
+    }
+    
+    if (sender == fDecombPopUp)
+    {
+        filterBox = fDecombBox;
+        filterField = fDecombField;
+    }
+    if (sender == fDeinterlacePopUp)
+    {
+        filterBox = fDeinterlaceBox;
+        filterField = fDeinterlaceField;
+    }
+    
+    if (sender == fDenoisePopUp)
+    {
+        filterBox = fDenoiseBox;
+        filterField = fDenoiseField;
+    }
+    
+    NSSize currentSize = [filterBox frame].size;
+    NSRect boxFrame = [filterBox frame];
+    
+    if ([sender titleOfSelectedItem] == @"Custom")
+    {
+        
+        currentSize.height = 60;
+        
+    }
+    else
+    {
+        currentSize.height = 30;
+        
+    }
+    /* Check to see if we have changed the size from current */
+    if (currentSize.height != [filterBox frame].size.height)
+    {
+        /* We are changing the size of the box, so recalc the origin */
+        NSPoint boxOrigin = [filterBox frame].origin;
+        /* We get the deltaY here for how much we are expanding/contracting the box vertically */
+        CGFloat deltaYBoxShift = currentSize.height - [filterBox frame].size.height;
+        boxOrigin.y -= deltaYBoxShift;
+        
+        boxFrame.size.height = currentSize.height;
+        boxFrame.origin.y = boxOrigin.y;
+        [filterBox setFrame:boxFrame];
+        
+        /* go ahead and resize the box */
+        //[[filterBox animator] setFrameSize:currentSize];
+        //[[filterBox animator] setFrameOrigin:origin];
+    
+        if (filterBox == fDecombBox || filterBox == fDeinterlaceBox)
+        {
+            /* fDecombDeinterlaceBox*/
+            NSSize decombDeinterlaceBoxSize = [fDecombDeinterlaceBox frame].size;
+            NSPoint decombDeinterlaceBoxOrigin = [fDecombDeinterlaceBox frame].origin;
+            
+            //decombDeinterlaceBoxSize.height = [filterBox frame].size.height + 50;
+            if (sender == fDecombDeinterlaceSlider)
+            {
+                [fHBController writeToActivityLog: "Sender is deinterlace decomb slider"];
+            }
+            
+            if ([fDeinterlaceBox isHidden] == YES)
+            {
+                decombDeinterlaceBoxSize.height = [fDecombBox frame].size.height + 50;
+                [fHBController writeToActivityLog: "Resize by Decomb box"];
+            }
+            else
+            {
+                decombDeinterlaceBoxSize.height = [fDeinterlaceBox frame].size.height + 50;
+                [fHBController writeToActivityLog: "Resize by Deinterlace box"];
+            }
+            /* get delta's for the change in window size */
+            
+            CGFloat deltaYdecombDeinterlace = decombDeinterlaceBoxSize.height - [fDecombDeinterlaceBox frame].size.height;
+            
+            deltaYBoxShift = deltaYdecombDeinterlace;
+            
+            decombDeinterlaceBoxOrigin.y -= deltaYdecombDeinterlace;
+            
+            [fDecombDeinterlaceBox setFrameSize:decombDeinterlaceBoxSize];
+            [fDecombDeinterlaceBox setFrameOrigin:decombDeinterlaceBoxOrigin];
+        }
+
+        /* now we must reset the origin of each box below the adjusted box*/
+        NSPoint decombDeintOrigin = [fDecombDeinterlaceBox frame].origin;
+        NSPoint denoiseOrigin = [fDenoiseBox frame].origin;
+        NSPoint deblockOrigin = [fDeblockBox frame].origin;
+        if (sender == fDetelecinePopUp)
+        {
+            decombDeintOrigin.y -= deltaYBoxShift;
+            [fDecombDeinterlaceBox setFrameOrigin:decombDeintOrigin];
+            
+            denoiseOrigin.y -= deltaYBoxShift;
+            [fDenoiseBox setFrameOrigin:denoiseOrigin];
+            
+            deblockOrigin.y -= deltaYBoxShift;
+            [fDeblockBox setFrameOrigin:deblockOrigin];
+        }
+        if (sender == fDecombPopUp || sender == fDeinterlacePopUp)
+        {
+            denoiseOrigin.y -= deltaYBoxShift;
+            [fDenoiseBox setFrameOrigin:denoiseOrigin];
+            
+            deblockOrigin.y -= deltaYBoxShift;
+            [fDeblockBox setFrameOrigin:deblockOrigin];
+        }
+        
+        if (sender == fDenoisePopUp)
+        {
+            deblockOrigin.y -= deltaYBoxShift;
+            [fDeblockBox setFrameOrigin:deblockOrigin];
+        }
+        
+        /* now we call to resize the entire inspector window */
+        [self resizeInspectorForTab:nil];
+    }
+    
+}
+
+
+#pragma mark -
+
+- (IBAction) previewGoWindowed: (id)sender
+{
+    [fPreviewController goWindowedScreen:self];
+}
+
+- (IBAction) showPreviewWindow: (id)sender
+{
+    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"];
+    [fPreviewController showWindow:sender];
+}
+
+
+
+
+- (void) setToFullScreenMode
+{
+    int32_t shieldLevel = CGShieldingWindowLevel(); 
+    
+    [fPictureWindow setLevel:shieldLevel + 1]; 
+    // Show the window. 
+    [fPictureWindow makeKeyAndOrderFront:self];
+}
+
+- (void) setToWindowedMode
+{
+    /* Set the window back to Floating Window mode 
+     * This will put the window always on top, but
+     * since we have Hide on Deactivate set in our
+     * xib, if other apps are put in focus we will
+     * hide properly to stay out of the way
+     */
+    [[self window] setLevel:NSFloatingWindowLevel];
+}
+
+- (void)setHBController: (HBController *)controller
+{
+    fHBController = controller;
+    [fPreviewController   setHBController: controller];
+    
+}
+
+- (void)awakeFromNib
+{
+    [fPictureWindow setDelegate:self];
+    if( ![[self window] setFrameUsingName:@"PictureSizing"] )
+        [[self window] center];
+    [self setWindowFrameAutosaveName:@"PictureSizing"];
+    [[self window] setExcludedFromWindowsMenu:YES];
+    
+    [self setInitialPictureFilters];
+    
+    /* Setup our layers for core animation */
+    [fSizeFilterView setWantsLayer:YES];
+    [fPictureSizeBox setWantsLayer:YES];
+    [fPictureCropBox setWantsLayer:YES];
+    
+}
+
+
+- (void)windowWillClose:(NSNotification *)aNotification
+{
+[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PictureSizeWindowIsOpen"];
+}
+
+- (BOOL)windowShouldClose:(id)fPictureWindow
+{
+    return YES;
+}
+
+- (void) dealloc
+{
+    [fPreviewController release];
+    [super dealloc];
+}
+
+- (void) SetHandle: (hb_handle_t *) handle
+{
+    fHandle = handle;
+    
+    [fPreviewController SetHandle: fHandle];
+}
+
+- (void) SetTitle: (hb_title_t *) title
+{
+    hb_job_t * job = title->job;
+
+    fTitle = title;
+
+    [fWidthStepper  setValueWraps: NO];
+    [fWidthStepper  setIncrement: 16];
+    [fWidthStepper  setMinValue: 64];
+    [fHeightStepper setValueWraps: NO];
+    [fHeightStepper setIncrement: 16];
+    [fHeightStepper setMinValue: 64];
+    
+    [fCropTopStepper    setIncrement: 2];
+    [fCropTopStepper    setMinValue:  0];
+    [fCropBottomStepper setIncrement: 2];
+    [fCropBottomStepper setMinValue:  0];
+    [fCropLeftStepper   setIncrement: 2];
+    [fCropLeftStepper   setMinValue:  0];
+    [fCropRightStepper  setIncrement: 2];
+    [fCropRightStepper  setMinValue:  0];
+    
+    [fWidthStepper      setMaxValue: title->width];
+    [fWidthStepper      setIntValue: job->width];
+    [fWidthField        setIntValue: job->width];
+    [fHeightStepper     setMaxValue: title->height];
+    [fHeightStepper     setIntValue: job->height];
+    [fHeightField       setIntValue: job->height];
+    [fRatioCheck        setState:    job->keep_ratio ? NSOnState : NSOffState];
+    [fCropTopStepper    setMaxValue: title->height/2-2];
+    [fCropBottomStepper setMaxValue: title->height/2-2];
+    [fCropLeftStepper   setMaxValue: title->width/2-2];
+    [fCropRightStepper  setMaxValue: title->width/2-2];
+
+    /* Populate the Anamorphic NSPopUp button here */
+    [fAnamorphicPopUp removeAllItems];
+    [fAnamorphicPopUp addItemWithTitle: @"None"];
+    [fAnamorphicPopUp addItemWithTitle: @"Strict"];
+    [fAnamorphicPopUp addItemWithTitle: @"Loose"];
+    [fAnamorphicPopUp addItemWithTitle: @"Custom"];
+    [fAnamorphicPopUp selectItemAtIndex: job->anamorphic.mode];
+    
+    //[self adjustSizingDisplay:nil];
+    
+    /* populate the modulus popup here */
+    [fModulusPopUp removeAllItems];
+    [fModulusPopUp addItemWithTitle: @"16"];
+    [fModulusPopUp addItemWithTitle: @"8"];
+    [fModulusPopUp addItemWithTitle: @"4"];
+    [fModulusPopUp addItemWithTitle: @"2"];
+    if (job->anamorphic.mode == 3)
+    {
+        [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->anamorphic.modulus]];
+    }
+    else
+    {
+        [fModulusPopUp selectItemWithTitle: @"16"];
+    }
+    
+    /* We initially set the previous state of keep ar to on */
+    keepAspectRatioPreviousState = 1;
+       if (!autoCrop)
+       {
+        [fCropMatrix  selectCellAtRow: 1 column:0];
+        /* If auto, lets set the crop steppers according to current job->crop values */
+        [fCropTopStepper    setIntValue: job->crop[0]];
+        [fCropTopField      setIntValue: job->crop[0]];
+        [fCropBottomStepper setIntValue: job->crop[1]];
+        [fCropBottomField   setIntValue: job->crop[1]];
+        [fCropLeftStepper   setIntValue: job->crop[2]];
+        [fCropLeftField     setIntValue: job->crop[2]];
+        [fCropRightStepper  setIntValue: job->crop[3]];
+        [fCropRightField    setIntValue: job->crop[3]];
+       }
+       else
+       {
+        [fCropMatrix  selectCellAtRow: 0 column:0];
+       }
+       
+    /* Set filters widgets according to the filters struct */
+    [fDetelecinePopUp selectItemAtIndex:fPictureFilterSettings.detelecine];
+    [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
+    [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
+    [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
+    [fDeblockSlider setFloatValue:fPictureFilterSettings.deblock];
+    [fGrayscaleCheck setState:fPictureFilterSettings.grayscale];
+    
+    [self deblockSliderChanged: nil];
+    
+    fPicture = 0;
+    MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
+    MaxOutputHeight = title->height - job->crop[0] - job->crop[1];
+    
+    titleDarWidth = job->anamorphic.dar_width;
+    titleDarHeight = job->anamorphic.dar_height;
+    
+    titleParWidth = job->anamorphic.par_width;
+    titleParHeight = job->anamorphic.par_height;
+    
+    [self SettingsChanged: nil];
+}
+
+- (IBAction) storageLinkChanged: (id) sender
+{
+    /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
+    if ([fStorageLinkSlider floatValue] < 0.50)
+    {
+        [fStorageLinkSlider setFloatValue:0.0];
+        /* set slider labels to reflect choice */
+        [fStorageLinkParLabel setEnabled:YES];
+        [fStorageLinkDisplayLabel setEnabled:NO];
+
+    }
+    else
+    {
+        [fStorageLinkSlider setFloatValue:1.0];
+        /* set slider labels to reflect choice */
+        [fStorageLinkParLabel setEnabled:NO];
+        [fStorageLinkDisplayLabel setEnabled:YES];
+    }
+    
+}
+
+- (IBAction) parLinkChanged: (id) sender
+{
+    /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
+    if ([fParLinkSlider floatValue] < 0.50)
+    {
+        [fParLinkSlider setFloatValue:0.0];
+        /* set slider labels to reflect choice */
+        [fParLinkStorageLabel setEnabled:YES];
+        [fParLinkDisplayLabel setEnabled:NO];
+    }
+    else
+    {
+        [fParLinkSlider setFloatValue:1.0];
+        /* set slider labels to reflect choice */
+        [fParLinkStorageLabel setEnabled:NO];
+        [fParLinkDisplayLabel setEnabled:YES];
+    }
+    
+}
+
+- (IBAction) displayLinkChanged: (id) sender
+{
+    /* since we have a tickless slider, make sure we are at 0.0 or 1.0 */
+    if ([fDisplayLinkSlider floatValue] < 0.50)
+    {
+        [fDisplayLinkSlider setFloatValue:0.0];
+        /* set slider labels to reflect choice */
+        [fDisplayLinkStorageLabel setEnabled:YES];
+        [fDisplayLinkParLabel setEnabled:NO];
+    }
+    else
+    {
+        [fDisplayLinkSlider setFloatValue:1.0];
+        /* set slider labels to reflect choice */
+        [fDisplayLinkStorageLabel setEnabled:NO];
+        [fDisplayLinkParLabel setEnabled:YES];
+    }
+    
+}    
+
+- (IBAction) SettingsChanged: (id) sender
+{
+    hb_job_t * job = fTitle->job;
+    [fModulusPopUp setEnabled:NO];
+    job->anamorphic.modulus = 16;
+
+    /* Since custom anamorphic allows for a height setting > fTitle->height
+     * check to make sure it is returned to fTitle->height for all other modes
+     */
+     [fHeightStepper setMaxValue: fTitle->height];
+    
+    autoCrop = ( [fCropMatrix selectedRow] == 0 );
+    [fCropTopStepper    setEnabled: !autoCrop];
+    [fCropBottomStepper setEnabled: !autoCrop];
+    [fCropLeftStepper   setEnabled: !autoCrop];
+    [fCropRightStepper  setEnabled: !autoCrop];
+    
+    if( autoCrop )
+    {
+        memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) );
+    }
+    else
+    {
+        job->crop[0] = [fCropTopStepper    intValue];
+        job->crop[1] = [fCropBottomStepper intValue];
+        job->crop[2] = [fCropLeftStepper   intValue];
+        job->crop[3] = [fCropRightStepper  intValue];
+    }
+    
+    [fRatioCheck setEnabled: YES];
+
+    
+    [fParWidthField setEnabled: NO];
+    [fParHeightField setEnabled: NO];
+    [fDisplayWidthField setEnabled: NO];
+    
+    /* If we are not custom anamorphic, make sure we retain the orginal par */
+    if( [fAnamorphicPopUp indexOfSelectedItem] != 3 )
+    {
+        job->anamorphic.par_width = titleParWidth;
+        job->anamorphic.par_height = titleParHeight;
+        [fRatioLabel setHidden: NO];
+        
+        [fWidthStepper  setIncrement: 16];
+        [fHeightStepper setIncrement: 16];
+    }
+    else
+    {
+        [fWidthStepper  setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]];
+        [fHeightStepper setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]];
+    }
+    
+       if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
+       {
+        if ([fAnamorphicPopUp indexOfSelectedItem] == 1) // strict
+        {
+            [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
+            [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
+            
+            /* This will show correct anamorphic height values, but
+             show distorted preview picture ratio */
+            [fHeightStepper      setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
+            [fHeightField        setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
+            job->width       = [fWidthStepper  intValue];
+            job->height      = [fHeightStepper intValue];
+            
+            job->anamorphic.mode = 1;
+            [fWidthStepper setEnabled: NO];
+            [fWidthField setEnabled: NO];
+            [fHeightStepper setEnabled: NO];
+            [fHeightField setEnabled: NO];
+            [fRatioCheck setEnabled: NO];
+        }
+        else if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic
+        {
+            job->anamorphic.mode = 2;
+            [fWidthStepper setEnabled: YES];
+            [fWidthField setEnabled: YES];
+            [fRatioCheck setEnabled: NO];
+            [fHeightStepper setEnabled: NO];
+            [fHeightField setEnabled: NO];
+            /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get
+             * the values to be used by libhb for loose anamorphic
+             */
+            /* if the sender is the anamorphic popup, then we know that loose anamorphic has just
+             * been turned on, so snap the width to full width for the source.
+             */
+            if (sender == fAnamorphicPopUp)
+            {
+                [fWidthStepper      setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
+                [fWidthField        setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
+            }
+            job->width       = [fWidthStepper  intValue];
+            hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
+            [fHeightStepper      setIntValue: output_height];
+            [fHeightField        setIntValue: output_height];
+            job->height      = [fHeightStepper intValue];
+            
+        }
+        else if ([fAnamorphicPopUp indexOfSelectedItem] == 3) // custom / power user jamboree
+        {
+
+#pragma mark - STARTCapuj
+
+            job->anamorphic.mode = 3;
+            
+            /* Set the status of our custom ana only widgets accordingly */
+            /* for mod 3 we can use modulus other than 16 */
+            [fModulusPopUp setEnabled:YES];
+            job->anamorphic.modulus = [[fModulusPopUp titleOfSelectedItem] intValue];
+            
+            [fWidthStepper setEnabled: YES];
+            [fWidthField setEnabled: YES];
+            
+            [fHeightStepper setEnabled: YES];
+            /* for capuj the storage field is immaterial */
+            [fHeightField setEnabled: YES];
+            
+            [fRatioCheck setEnabled: YES];
+            if (sender == fRatioCheck)
+            {
+                if ([fRatioCheck  state] == NSOnState)
+                {
+                    [fParWidthField setEnabled: NO];
+                    [fParHeightField setEnabled: NO];   
+                }
+                else
+                {
+                    [fParWidthField setEnabled: YES];
+                    [fParHeightField setEnabled: YES];
+                }
+            }
+            
+            [fParWidthField setEnabled: YES];
+            [fParHeightField setEnabled: YES];
+            
+            [fDisplayWidthField setEnabled: YES];
+            
+            
+            /* If we are coming into custom anamorphic we reset the par to original
+             * which gives us a way back if things get hosed up.
+             */
+             
+            if (sender == fAnamorphicPopUp)
+            {
+                /* When entering custom anamorphic, we start with keep ar on */
+                [fRatioCheck  setState: NSOnState];
+                /*
+                 KEEPING ASPECT RATIO
+                 Disable editing: PIXEL WIDTH, PIXEL HEIGHT
+                 */
+                [fParWidthField setEnabled: NO];
+                [fParHeightField setEnabled: NO];
+                
+                job->width = [fWidthStepper intValue];
+                job->height = [fHeightStepper intValue];
+
+                /* make sure our par is set back to original */
+                job->anamorphic.par_width = titleParWidth;
+                job->anamorphic.par_height = titleParHeight;
+                
+                [fParWidthField   setIntValue: titleParWidth];
+                [fParHeightField   setIntValue: titleParHeight];
+                
+                /* modify our par dims from our storage dims */
+                hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
+                float par_display_width = (float)output_width * (float)output_par_width / (float)output_par_height;
+                
+                /* go ahead and mod the display dims */
+                [fDisplayWidthField   setStringValue: [NSString stringWithFormat:@"%.2f", par_display_width]];
+                
+                job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                job->anamorphic.dar_height = (float)[fHeightStepper intValue];
+                
+                /* Set our dar here assuming we are just coming into capuj mode */
+                dar = [fDisplayWidthField floatValue] / (float)[fHeightField intValue];
+                
+            }
+
+            /* For capuj we disable these fields if we are keeping the dispay aspect */
+            if ([fRatioCheck  state] == NSOnState)
+            {
+                /*
+                 KEEPING ASPECT RATIO
+                 DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification) */
+                 /*Disable editing: PIXEL WIDTH, PIXEL HEIGHT */
+                
+                [fParWidthField setEnabled: NO];
+                [fParHeightField setEnabled: NO];
+                
+                /* Changing DISPLAY WIDTH: */
+                if (sender == fDisplayWidthField)
+                {
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                    /* Changes HEIGHT to keep DAR */
+                     /* calculate the height to retain the dar  */
+                    int raw_calulated_height = (int)((int)[fDisplayWidthField floatValue] / dar);
+                    /*  now use the modulus to go lower if there is a remainder  */
+                    /* Note to me, raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]
+                     * gives me the remainder we are not mod (whatever our modulus is) subtract that from
+                     * the actual calculated value derived from the dar to round down to the nearest mod value.
+                     * This should be desireable over rounding up to the next mod value
+                     */
+                    int modulus_height = raw_calulated_height - (raw_calulated_height % [[fModulusPopUp titleOfSelectedItem] intValue]);
+                    if (modulus_height > fTitle->height)
+                    {
+                        [fHeightStepper setMaxValue: modulus_height];
+                    }
+                    [fHeightStepper setIntValue: modulus_height];
+                    job->anamorphic.dar_height = (float)[fHeightStepper intValue];
+                    job->height = [fHeightStepper intValue];
+                    
+                    /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
+                    [fParWidthField setIntValue: [fDisplayWidthField intValue]];
+                    job->anamorphic.par_width = [fParWidthField intValue];
+                    /* Changes PIXEL HEIGHT to STORAGE WIDTH */
+                    [fParHeightField  setIntValue: [fWidthField intValue]];
+                    job->anamorphic.par_height = [fParHeightField intValue];
+                    
+                }
+                /* Changing HEIGHT: */
+                if (sender == fHeightStepper)
+                {
+                   job->anamorphic.dar_height = (float)[fHeightStepper intValue];
+                   job->height = [fHeightStepper intValue];
+                   
+                    /* Changes DISPLAY WIDTH to keep DAR*/
+                    [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",[fHeightStepper intValue] * dar]];
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                    /* Changes PIXEL WIDTH to new DISPLAY WIDTH */
+                    [fParWidthField setIntValue: [fDisplayWidthField intValue]];
+                    job->anamorphic.par_width = [fParWidthField intValue];
+                    /* Changes PIXEL HEIGHT to STORAGE WIDTH */
+                    [fParHeightField  setIntValue: [fWidthField intValue]];
+                    job->anamorphic.par_height = [fParHeightField intValue];
+                }
+                /* Changing STORAGE_WIDTH: */
+                if (sender == fWidthStepper)
+                {
+                    job->width = [fWidthStepper intValue];
+                    
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                    job->anamorphic.dar_height = [fHeightStepper floatValue];
+                     
+                    /* Changes PIXEL WIDTH to DISPLAY WIDTH */
+                    [fParWidthField setIntValue: [fDisplayWidthField intValue]];
+                    job->anamorphic.par_width = [fParWidthField intValue];
+                    /* Changes PIXEL HEIGHT to new STORAGE WIDTH */
+                    [fParHeightField  setIntValue: [fWidthStepper intValue]];
+                    job->anamorphic.par_height = [fParHeightField intValue];
+                }
+            }
+            else if ([fRatioCheck  state] == NSOffState)
+            {
+                /* Changing STORAGE_WIDTH: */
+                if (sender == fWidthStepper)
+                {
+                    job->width = [fWidthStepper intValue];
+                    /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
+                    [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                }
+                /* Changing PIXEL dimensions */
+                if (sender == fParWidthField || sender == fParHeightField)
+                {
+                    job->anamorphic.par_width = [fParWidthField intValue];
+                    job->anamorphic.par_height = [fParHeightField intValue];
+                    /* changes DISPLAY WIDTH to STORAGE WIDTH * PIXEL WIDTH / PIXEL HEIGHT */
+                    [fDisplayWidthField setStringValue: [NSString stringWithFormat: @"%.2f",(float)[fWidthStepper intValue] * [fParWidthField intValue] / [fParHeightField intValue]]];
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                }
+                /* Changing DISPLAY WIDTH: */
+                if (sender == fDisplayWidthField)
+                {
+                    job->anamorphic.dar_width = [fDisplayWidthField floatValue];
+                    job->anamorphic.dar_height = (float)[fHeightStepper intValue];
+                    /* changes PIXEL WIDTH to DISPLAY WIDTH and PIXEL HEIGHT to STORAGE WIDTH */
+                    [fParWidthField setIntValue: [fDisplayWidthField intValue]];
+                    job->anamorphic.par_width = [fParWidthField intValue];
+                    
+                    [fParHeightField  setIntValue: [fWidthField intValue]];
+                    job->anamorphic.par_height = [fParHeightField intValue];
+                    hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
+                }
+                /* Changing HEIGHT: */
+                if (sender == fHeightStepper)
+                {
+                    /* just....changes the height.*/
+                    job->anamorphic.dar_height = [fHeightStepper intValue];
+                    job->height = [fHeightStepper intValue];
+                }
+                
+            }
+            
+#pragma mark - END Capuj                       
+        }
+        
+        /* if the sender is the Anamorphic checkbox, record the state
+         of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */
+        if (sender == fAnamorphicPopUp)
+        {
+            keepAspectRatioPreviousState = [fRatioCheck state];
+        }
+        if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
+        {
+            [fRatioCheck setState:NSOffState];
+        }
+        
+    }
+    else
+       {
+        job->width       = [fWidthStepper  intValue];
+        job->height      = [fHeightStepper intValue];
+        job->anamorphic.mode = 0;
+        [fWidthStepper setEnabled: YES];
+        [fWidthField setEnabled: YES];
+        [fHeightStepper setEnabled: YES];
+        [fHeightField setEnabled: YES];
+        [fRatioCheck setEnabled: YES];
+        /* if the sender is the Anamorphic checkbox, we return the
+         keep AR checkbox to its previous state */
+        if (sender == fAnamorphicPopUp)
+        {
+            [fRatioCheck setState:keepAspectRatioPreviousState];
+        }
+        
+       }
+       
+    //job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
+    
+    if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
+    {
+    job->keep_ratio  = ( [fRatioCheck state] == NSOnState );
+            if( job->keep_ratio )
+        {
+            if( sender == fWidthStepper || sender == fRatioCheck ||
+               sender == fCropTopStepper || sender == fCropBottomStepper )
+            {
+                hb_fix_aspect( job, HB_KEEP_WIDTH );
+                if( job->height > fTitle->height )
+                {
+                    job->height = fTitle->height;
+                    hb_fix_aspect( job, HB_KEEP_HEIGHT );
+                }
+            }
+            else
+            {
+                hb_fix_aspect( job, HB_KEEP_HEIGHT );
+                if( job->width > fTitle->width )
+                {
+                    job->width = fTitle->width;
+                    hb_fix_aspect( job, HB_KEEP_WIDTH );
+                }
+            }
+            
+        }
+    }
+    
+    // hb_get_preview can't handle sizes that are larger than the original title
+    if ([fAnamorphicPopUp indexOfSelectedItem] != 3)
+    {
+        // dimensions
+        if( job->width > fTitle->width )
+        {
+            job->width = fTitle->width;
+        }
+        
+        if( job->height > fTitle->height )
+        {
+            job->height = fTitle->height;
+        }
+    }
+    
+    [fWidthStepper      setIntValue: job->width];
+    [fWidthField        setIntValue: job->width];
+    if( [fAnamorphicPopUp indexOfSelectedItem] != 2) // if we are not loose or custom
+    {
+        [fHeightStepper     setIntValue: job->height];
+        [fHeightField       setIntValue: job->height];
+    }
+    
+    [fCropTopStepper    setIntValue: job->crop[0]];
+    [fCropTopField      setIntValue: job->crop[0]];
+    [fCropBottomStepper setIntValue: job->crop[1]];
+    [fCropBottomField   setIntValue: job->crop[1]];
+    [fCropLeftStepper   setIntValue: job->crop[2]];
+    [fCropLeftField     setIntValue: job->crop[2]];
+    [fCropRightStepper  setIntValue: job->crop[3]];
+    [fCropRightField    setIntValue: job->crop[3]];
+    
+    //[fPreviewController SetTitle:fTitle];
+    
+    /* Sanity Check Here for < 16 px preview to avoid
+     crashing hb_get_preview. In fact, just for kicks
+     lets getting previews at a min limit of 32, since
+     no human can see any meaningful detail below that */
+    if (job->width >= 64 && job->height >= 64)
+    {
+        [self reloadStillPreview];
+    }
+    
+    /* we get the sizing info to display from fPreviewController */
+    [fSizeInfoField setStringValue: [fPreviewController pictureSizeInfoString]];
+    
+    if (sender != nil)
+    {
+        [fHBController pictureSettingsDidChange];
+    }   
+    
+    if ([[self window] isVisible])
+    { 
+        [self adjustSizingDisplay:nil];
+    }
+    
+}
+
+- (NSString*) getPictureSizeInfoString
+{
+    return [fSizeInfoField stringValue];
+}
+
+- (void)reloadStillPreview
+{ 
+   hb_job_t * job = fTitle->job; 
+   
+   [fPreviewController SetTitle:fTitle];
+    /* Sanity Check Here for < 16 px preview to avoid
+     crashing hb_get_preview. In fact, just for kicks
+     lets getting previews at a min limit of 32, since
+     no human can see any meaningful detail below that */
+    if (job->width >= 64 && job->height >= 64)
+    {
+       
+         // Purge the existing picture previews so they get recreated the next time
+        // they are needed.
+      //  [fPreviewController purgeImageCache];
+        /* We actually call displayPreview now from pictureSliderChanged which keeps
+         * our picture preview slider in sync with the previews being shown
+         */
+
+    //[fPreviewController pictureSliderChanged:nil];
+    }
+    
+}
+
+
+#pragma mark -
+
+- (BOOL) autoCrop
+{
+    return autoCrop;
+}
+- (void) setAutoCrop: (BOOL) setting
+{
+    autoCrop = setting;
+}
+
+- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title
+{
+    //[self SetTitle:title];
+    [self showWindow:sender];
+    //[self adjustSizingDisplay:nil];
+    //[self adjustFilterDisplay:nil];
+
+}
+
+
+#pragma mark -
+/* we use this to setup the initial picture filters upon first launch, after that their states
+are maintained across different sources */
+- (void) setInitialPictureFilters
+{
+       /* we use a popup to show the detelecine settings */
+       [fDetelecinePopUp removeAllItems];
+    [fDetelecinePopUp addItemWithTitle: @"Off"];
+    [fDetelecinePopUp addItemWithTitle: @"Custom"];
+    [fDetelecinePopUp addItemWithTitle: @"Default"];
+    [fDetelecinePopUp selectItemAtIndex: fPictureFilterSettings.detelecine];
+    
+    [self modeDecombDeinterlaceSliderChanged:nil];
+    /* we use a popup to show the decomb settings */
+       [fDecombPopUp removeAllItems];
+    [fDecombPopUp addItemWithTitle: @"Off"];
+    [fDecombPopUp addItemWithTitle: @"Custom"];
+    [fDecombPopUp addItemWithTitle: @"Default"];
+    
+    [fDecombPopUp selectItemAtIndex: fPictureFilterSettings.decomb];
+    
+    /* we use a popup to show the deinterlace settings */
+       [fDeinterlacePopUp removeAllItems];
+    [fDeinterlacePopUp addItemWithTitle: @"Off"];
+    [fDeinterlacePopUp addItemWithTitle: @"Custom"];
+    [fDeinterlacePopUp addItemWithTitle: @"Fast"];
+    [fDeinterlacePopUp addItemWithTitle: @"Slow"];
+       [fDeinterlacePopUp addItemWithTitle: @"Slower"];
+    
+       /* Set deinterlaces level according to the integer in the main window */
+       [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
+
+       /* we use a popup to show the denoise settings */
+       [fDenoisePopUp removeAllItems];
+    [fDenoisePopUp addItemWithTitle: @"Off"];
+    [fDenoisePopUp addItemWithTitle: @"Custom"];
+    [fDenoisePopUp addItemWithTitle: @"Weak"];
+       [fDenoisePopUp addItemWithTitle: @"Medium"];
+    [fDenoisePopUp addItemWithTitle: @"Strong"];
+       /* Set denoises level according to the integer in the main window */
+       [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
+    
+
+}
+
+
+
+
+- (IBAction) modeDecombDeinterlaceSliderChanged: (id) sender
+{
+    
+    /* since its a tickless slider, we have to  make sure we are on or off */
+    if ([fDecombDeinterlaceSlider floatValue] < 0.50)
+    {
+        [fDecombDeinterlaceSlider setFloatValue:0.0];
+    }
+    else
+    {
+        [fDecombDeinterlaceSlider setFloatValue:1.0];
+    }
+    
+    
+    /* Decomb selected*/
+    if ([fDecombDeinterlaceSlider floatValue] == 0.0)
+    {
+        [fDecombBox setHidden:NO];
+        [fDeinterlaceBox setHidden:YES];
+        fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
+        fPictureFilterSettings.usedecomb = 1;
+        fPictureFilterSettings.deinterlace = 0;
+        [fDecombPopUp selectItemAtIndex:fPictureFilterSettings.decomb];
+        [self adjustFilterDisplay:fDecombPopUp];
+    }
+    else
+    {
+        [fDecombBox setHidden:YES];
+        [fDeinterlaceBox setHidden:NO];
+        fPictureFilterSettings.usedecomb = 0;
+        fPictureFilterSettings.decomb = 0;
+        [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
+        [self adjustFilterDisplay:fDeinterlacePopUp];
+    }
+    [self FilterSettingsChanged: fDecombDeinterlaceSlider];
+}
+
+
+- (IBAction) FilterSettingsChanged: (id) sender
+{
+    
+    fPictureFilterSettings.detelecine  = [fDetelecinePopUp indexOfSelectedItem];
+    [self adjustFilterDisplay:fDetelecinePopUp];
+    
+    fPictureFilterSettings.decomb = [fDecombPopUp indexOfSelectedItem];
+    [self adjustFilterDisplay:fDecombPopUp];
+    
+    fPictureFilterSettings.deinterlace = [fDeinterlacePopUp indexOfSelectedItem];
+    [self adjustFilterDisplay:fDeinterlacePopUp];
+    
+    fPictureFilterSettings.denoise = [fDenoisePopUp indexOfSelectedItem];
+    [self adjustFilterDisplay:fDenoisePopUp];
+    
+    if ([fDeblockField stringValue] == @"Off")
+    {
+        fPictureFilterSettings.deblock  = 0;
+    }
+    else
+    {
+        fPictureFilterSettings.deblock  = [fDeblockField intValue];
+    }
+    
+    fPictureFilterSettings.grayscale = [fGrayscaleCheck state];
+    
+    if (sender != nil)
+    {
+        [fHBController pictureSettingsDidChange];
+        
+    }   
+
+}
+
+
+#pragma mark -
+
+- (IBAction) deblockSliderChanged: (id) sender
+{
+    if ([fDeblockSlider floatValue] == 4.0)
+    {
+    [fDeblockField setStringValue: [NSString stringWithFormat: @"Off"]];
+    }
+    else
+    {
+    [fDeblockField setStringValue: [NSString stringWithFormat: @"%.0f", [fDeblockSlider floatValue]]];
+    }
+       [self FilterSettingsChanged: sender];
+}
+
+
+- (int) detelecine
+{
+    return fPictureFilterSettings.detelecine;
+}
+
+- (NSString*) detelecineCustomString
+{
+    return [fDetelecineField stringValue];
+}
+
+- (void) setDetelecine: (int) setting
+{
+    fPictureFilterSettings.detelecine = setting;
+}
+
+- (void) setDetelecineCustomString: (NSString*) string 
+{
+    [fDetelecineField setStringValue:string];
+}
+
+- (int) deinterlace
+{
+    return fPictureFilterSettings.deinterlace;
+}
+- (NSString*) deinterlaceCustomString
+{
+    return [fDeinterlaceField stringValue];
+}
+
+- (void) setDeinterlaceCustomString: (NSString*) string 
+{
+    [fDeinterlaceField setStringValue:string];
+}
+
+- (void) setDeinterlace: (int) setting 
+{
+    fPictureFilterSettings.deinterlace = setting;
+}
+- (int) decomb
+{
+    return fPictureFilterSettings.decomb;
+}
+
+- (NSString*) decombCustomString
+{
+    return [fDecombField stringValue];
+}
+
+- (int) useDecomb
+{
+    return fPictureFilterSettings.usedecomb;
+}
+
+- (void) setUseDecomb: (int) setting
+{
+    fPictureFilterSettings.usedecomb = setting;
+    if (fPictureFilterSettings.usedecomb == 1)
+    {
+        [fDecombDeinterlaceSlider setFloatValue:0.0];
+    }
+    else
+    {
+        [fDecombDeinterlaceSlider setFloatValue:1.0];
+    }
+    [self modeDecombDeinterlaceSliderChanged:nil];
+}
+
+- (void) setDecomb: (int) setting {
+    fPictureFilterSettings.decomb = setting;
+}
+
+- (void) setDecombCustomString: (NSString*) string 
+{
+    [fDecombField setStringValue:string];
+}
+
+- (int) denoise
+{
+    return fPictureFilterSettings.denoise;
+}
+
+- (NSString*) denoiseCustomString
+{
+    return [fDenoiseField stringValue];
+}
+
+- (void) setDenoiseCustomString: (NSString*) string 
+{
+    [fDenoiseField setStringValue:string];
+}
+
+- (void) setDenoise: (int) setting
+{
+    fPictureFilterSettings.denoise = setting;
+}
+
+- (int) deblock
+{
+    return fPictureFilterSettings.deblock;
+}
+
+- (void) setDeblock: (int) setting
+{
+    fPictureFilterSettings.deblock = setting;
+}
+
+- (int) grayscale
+{
+    return fPictureFilterSettings.grayscale;
+}
+
+- (void) setGrayscale: (int) setting
+{
+    fPictureFilterSettings.grayscale = setting;
+}
+
+
+
+@end
+
diff --git a/macosx/Sparkle.disable.security.patch b/macosx/Sparkle.disable.security.patch
new file mode 100644 (file)
index 0000000..7d3d2d0
--- /dev/null
@@ -0,0 +1,18 @@
+--- SUBasicUpdateDriver.m.orig 2009-06-18 16:23:17.000000000 -0400
++++ SUBasicUpdateDriver.m      2009-06-18 16:23:53.000000000 -0400
+@@ -158,6 +158,7 @@
+ - (void)downloadDidFinish:(NSURLDownload *)d
+ {
++#if 0
+       // New in Sparkle 1.5: we're now checking signatures on all non-secure downloads, where "secure" is defined as both the appcast and the download being transmitted over SSL.
+       NSURL *downloadURL = [[d request] URL];
+       if (![[downloadURL scheme] isEqualToString:@"https"] || ![[appcastURL scheme] isEqualToString:@"https"] || [host publicDSAKey])
+@@ -168,6 +169,7 @@
+                       return;
+               }
+       }
++#endif
+       
+       [self extractUpdate];
+ }
index 209fe20..171148a 100644 (file)
@@ -6,22 +6,28 @@
 //  Copyright 2006 Andy Matuschak. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
+#ifndef SUAPPCAST_H
+#define SUAPPCAST_H
 
-@class RSS, SUAppcastItem;
+@class SUAppcastItem;
 @interface SUAppcast : NSObject {
        NSArray *items;
+       NSString *userAgentString;
        id delegate;
+       NSMutableData *incrementalData;
 }
 
 - (void)fetchAppcastFromURL:(NSURL *)url;
 - (void)setDelegate:delegate;
+- (void)setUserAgentString:(NSString *)userAgentString;
 
-- (SUAppcastItem *)newestItem;
 - (NSArray *)items;
 
 @end
 
 @interface NSObject (SUAppcastDelegate)
-- appcastDidFinishLoading:(SUAppcast *)appcast;
-@end
\ No newline at end of file
+- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
+- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
+@end
+
+#endif
index c0202e3..7f1ca65 100644 (file)
@@ -6,52 +6,42 @@
 //  Copyright 2006 Andy Matuschak. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
-
+#ifndef SUAPPCASTITEM_H
+#define SUAPPCASTITEM_H
 
 @interface SUAppcastItem : NSObject {
        NSString *title;
        NSDate *date;
-       NSString *description;
+       NSString *itemDescription;
        
        NSURL *releaseNotesURL;
        
-       NSString *DSASignature;
-       NSString *MD5Sum;
+       NSString *DSASignature; 
+       NSString *minimumSystemVersion;
        
        NSURL *fileURL;
-       NSString *fileVersion;
        NSString *versionString;
+       NSString *displayVersionString;
+       
+       NSDictionary *propertiesDictionary;
 }
 
 // Initializes with data from a dictionary provided by the RSS class.
 - initWithDictionary:(NSDictionary *)dict;
 
 - (NSString *)title;
-- (void)setTitle:(NSString *)aTitle;
-
+- (NSString *)versionString;
+- (NSString *)displayVersionString;
 - (NSDate *)date;
-- (void)setDate:(NSDate *)aDate;
-
-- (NSString *)description;
-- (void)setDescription:(NSString *)aDescription;
-
+- (NSString *)itemDescription;
 - (NSURL *)releaseNotesURL;
-- (void)setReleaseNotesURL:(NSURL *)aReleaseNotesURL;
-
-- (NSString *)DSASignature;
-- (void)setDSASignature:(NSString *)aDSASignature;
-
-- (NSString *)MD5Sum;
-- (void)setMD5Sum:(NSString *)aMd5Sum;
-
 - (NSURL *)fileURL;
-- (void)setFileURL:(NSURL *)aFileURL;
-
-- (NSString *)fileVersion;
-- (void)setFileVersion:(NSString *)aFileVersion;
+- (NSString *)DSASignature;
+- (NSString *)minimumSystemVersion;
 
-- (NSString *)versionString;
-- (void)setVersionString:(NSString *)versionString;
+// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
+- (NSDictionary *)propertiesDictionary;
 
 @end
+
+#endif
index 5f82914..e78c4d3 100644 (file)
 //  Copyright 2006 Andy Matuschak. All rights reserved.
 //
 
-#import <Cocoa/Cocoa.h>
+#ifndef SUUPDATER_H
+#define SUUPDATER_H
 
-// Before you use Sparkle in your app, you must set SUFeedURL in Info.plist to the
-// address of the appcast on your webserver. If you don't already have an 
-// appcast, please see the Sparkle documentation to learn about how to set one up.
+#import <Sparkle/SUVersionComparisonProtocol.h>
 
-// .zip, .dmg, .tar, .tbz, .tgz archives are supported at this time.
-
-// By default, Sparkle offers to show the user the release notes of the build they'll be
-// getting, which it assumes are in the description (or body) field of the relevant RSS item.
-// Set SUShowReleaseNotes to <false/> in Info.plist to hide the button.
-
-@class SUAppcastItem, SUUpdateAlert, SUStatusController;
+@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
 @interface SUUpdater : NSObject {
-       SUAppcastItem *updateItem;
-       
-       SUStatusController *statusController;
-       SUUpdateAlert *updateAlert;
-       
-       NSURLDownload *downloader;
-       NSString *downloadPath;
-                       
        NSTimer *checkTimer;
-       NSTimeInterval checkInterval;   
+       SUUpdateDriver *driver;
        
-       BOOL verbose;
-       BOOL updateInProgress;
+       SUHost *host;
+       IBOutlet id delegate;
 }
 
++ (SUUpdater *)sharedUpdater;
++ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
+- (NSBundle *)hostBundle;
+
+- (void)setDelegate:(id)delegate;
+- delegate;
+
+- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
+- (BOOL)automaticallyChecksForUpdates;
+
+- (void)setUpdateCheckInterval:(NSTimeInterval)interval;
+- (NSTimeInterval)updateCheckInterval;
+
+- (void)setFeedURL:(NSURL *)feedURL;
+- (NSURL *)feedURL;
+
+- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
+- (BOOL)sendsSystemProfile;
+
+- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
+- (BOOL)automaticallyDownloadsUpdates;
+
 // This IBAction is meant for a main menu item. Hook up any menu item to this action,
 // and Sparkle will check for updates and report back its findings verbosely.
 - (IBAction)checkForUpdates:sender;
 
-// This method is similar to the above, but it's intended for updates initiated by
-// the computer instead of by the user. It does not alert the user when he is up to date,
-// and it remains silent about network errors in fetching the feed. This is what you
-// want to call to update programmatically; only use checkForUpdates: with buttons and menu items.
+// This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
+// in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
+// update is found, it will be downloaded and prepped for installation.
 - (void)checkForUpdatesInBackground;
 
-// This method allows you to schedule a check to run every time interval. You can
-// pass 0 to this method to cancel a previously scheduled timer. You probably don't want
-// to call this directly: if you set a SUScheduledCheckInterval key in Info.plist or
-// the user defaults, Sparkle will set this up for you automatically on startup. You might
-// just want to call this every time the user changes the setting in the preferences.
-- (void)scheduleCheckWithInterval:(NSTimeInterval)interval;
+// Date of last update check. Returns null if no check has been performed.
+- (NSDate*)lastUpdateCheckDate;
+
+// This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
+// (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
+- (void)checkForUpdateInformation;
+
+// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
+- (void)resetUpdateCycle;
+
+- (BOOL)updateInProgress;
+@end
+
+@interface NSObject (SUUpdaterDelegateInformalProtocol)
+// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
+- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
+
+// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
+- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
+
+// Implement this if you want to do some special handling with the appcast once it finishes loading.
+- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
+
+// If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
+// a valid update, if any, in the given appcast.
+- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
+
+// Sent when a valid update is found by the update driver.
+- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
+
+// Sent when a valid update is not found.
+- (void)updaterDidNotFindUpdate:(SUUpdater *)update;
+
+// Sent immediately before installing the specified update.
+- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
+
+// Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
+- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
+
+// Called immediately before relaunching.
+- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
+
+// This method allows you to provide a custom version comparator.
+// If you don't implement this method or return nil, the standard version comparator will be used.
+- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
+
+// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
+- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
+
+@end
+
+// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
+#ifdef DEBUG
+#define SU_MIN_CHECK_INTERVAL 60
+#else
+#define SU_MIN_CHECK_INTERVAL 60*60
+#endif
+
+#ifdef DEBUG
+#define SU_DEFAULT_CHECK_INTERVAL 60
+#else
+#define SU_DEFAULT_CHECK_INTERVAL 60*60*24
+#endif
 
-@end
\ No newline at end of file
+#endif
diff --git a/macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol copy.h b/macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol copy.h
new file mode 100644 (file)
index 0000000..3d11ae8
--- /dev/null
@@ -0,0 +1,27 @@
+//
+//  SUVersionComparisonProtocol.h
+//  Sparkle
+//
+//  Created by Andy Matuschak on 12/21/07.
+//  Copyright 2007 Andy Matuschak. All rights reserved.
+//
+
+#ifndef SUVERSIONCOMPARISONPROTOCOL_H
+#define SUVERSIONCOMPARISONPROTOCOL_H
+
+/*!
+    @protocol
+    @abstract    Implement this protocol to provide version comparison facilities for Sparkle.
+*/
+@protocol SUVersionComparison
+
+/*!
+    @method     
+    @abstract   An abstract method to compare two version strings.
+    @discussion Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a, and NSOrderedSame if they are equivalent.
+*/
+- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
+
+@end
+
+#endif
diff --git a/macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol.h b/macosx/Sparkle.framework/Versions/A/Headers/SUVersionComparisonProtocol.h
new file mode 100644 (file)
index 0000000..3d11ae8
--- /dev/null
@@ -0,0 +1,27 @@
+//
+//  SUVersionComparisonProtocol.h
+//  Sparkle
+//
+//  Created by Andy Matuschak on 12/21/07.
+//  Copyright 2007 Andy Matuschak. All rights reserved.
+//
+
+#ifndef SUVERSIONCOMPARISONPROTOCOL_H
+#define SUVERSIONCOMPARISONPROTOCOL_H
+
+/*!
+    @protocol
+    @abstract    Implement this protocol to provide version comparison facilities for Sparkle.
+*/
+@protocol SUVersionComparison
+
+/*!
+    @method     
+    @abstract   An abstract method to compare two version strings.
+    @discussion Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a, and NSOrderedSame if they are equivalent.
+*/
+- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
+
+@end
+
+#endif
index 13e9b21..08dd577 100644 (file)
@@ -2,21 +2,20 @@
 //  Sparkle.h
 //  Sparkle
 //
-//  Created by Andy Matuschak on 3/16/06.
+//  Created by Andy Matuschak on 3/16/06. (Modified by CDHW on 23/12/07)
 //  Copyright 2006 Andy Matuschak. All rights reserved.
 //
 
-#import "SUUpdater.h"
-#import "SUUtilities.h"
-#import "SUConstants.h"
-#import "SUAppcast.h"
-#import "SUAppcastItem.h"
-#import "SUUpdateAlert.h"
-#import "SUAutomaticUpdateAlert.h"
-#import "SUStatusController.h"
-#import "SUUnarchiver.h"
-#import "SUStatusChecker.h"
+#ifndef SPARKLE_H
+#define SPARKLE_H
 
-#import "NSApplication+AppCopies.h"
-#import "NSFileManager+Authentication.h"
-#import "NSFileManager+Verification.h"
\ No newline at end of file
+// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
+// there are name-space collisions) so we can list all of them to start with:
+
+#import <Sparkle/SUUpdater.h>
+
+#import <Sparkle/SUAppcast.h>
+#import <Sparkle/SUAppcastItem.h>
+#import <Sparkle/SUVersionComparisonProtocol.h>
+
+#endif
index c154cb6..c7f277d 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
+       <string>en</string>
        <key>CFBundleExecutable</key>
        <string>Sparkle</string>
        <key>CFBundleIdentifier</key>
        <string>Sparkle</string>
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.5 Beta 6</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>1.1</string>
+       <string>313</string>
 </dict>
 </plist>
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/License.txt b/macosx/Sparkle.framework/Versions/A/Resources/License.txt
new file mode 100644 (file)
index 0000000..20466c4
--- /dev/null
@@ -0,0 +1,7 @@
+Copyright (c) 2006 Andy Matuschak
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/SUModelTranslation.plist b/macosx/Sparkle.framework/Versions/A/Resources/SUModelTranslation.plist
new file mode 100644 (file)
index 0000000..92ef947
--- /dev/null
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>ADP2,1</key>
+       <string>Developer Transition Kit</string>
+       <key>MacBook1,1</key>
+       <string>MacBook (Core Duo)</string>
+       <key>MacBook2,1</key>
+       <string>MacBook (Core 2 Duo)</string>
+       <key>MacBook4,1</key>
+       <string>MacBook (Core 2 Duo Feb 2008)</string>
+       <key>MacBookAir1,1</key>
+       <string>MacBook Air (January 2008)</string>
+       <key>MacBookPro1,1</key>
+       <string>MacBook Pro Core Duo (15-inch)</string>
+       <key>MacBookPro1,2</key>
+       <string>MacBook Pro Core Duo (17-inch)</string>
+       <key>MacBookPro2,1</key>
+       <string>MacBook Pro Core 2 Duo (17-inch)</string>
+       <key>MacBookPro2,2</key>
+       <string>MacBook Pro Core 2 Duo (15-inch)</string>
+       <key>MacBookPro3,1</key>
+       <string>MacBook Pro Core 2 Duo (15-inch LED, Core 2 Duo)</string>
+       <key>MacBookPro3,2</key>
+       <string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
+       <key>MacBookPro4,1</key>
+       <string>MacBook Pro (Core 2 Duo Feb 2008)</string>
+       <key>MacPro1,1</key>
+       <string>Mac Pro (four-core)</string>
+       <key>MacPro2,1</key>
+       <string>Mac Pro (eight-core)</string>
+       <key>MacPro3,1</key>
+       <string>Mac Pro (January 2008 4- or 8- core "Harpertown")</string>
+       <key>Macmini1,1</key>
+       <string>Mac Mini (Core Solo/Duo)</string>
+       <key>PowerBook1,1</key>
+       <string>PowerBook G3</string>
+       <key>PowerBook2,1</key>
+       <string>iBook G3</string>
+       <key>PowerBook2,2</key>
+       <string>iBook G3 (FireWire)</string>
+       <key>PowerBook2,3</key>
+       <string>iBook G3</string>
+       <key>PowerBook2,4</key>
+       <string>iBook G3</string>
+       <key>PowerBook3,1</key>
+       <string>PowerBook G3 (FireWire)</string>
+       <key>PowerBook3,2</key>
+       <string>PowerBook G4</string>
+       <key>PowerBook3,3</key>
+       <string>PowerBook G4 (Gigabit Ethernet)</string>
+       <key>PowerBook3,4</key>
+       <string>PowerBook G4 (DVI)</string>
+       <key>PowerBook3,5</key>
+       <string>PowerBook G4 (1GHz / 867MHz)</string>
+       <key>PowerBook4,1</key>
+       <string>iBook G3 (Dual USB, Late 2001)</string>
+       <key>PowerBook4,2</key>
+       <string>iBook G3 (16MB VRAM)</string>
+       <key>PowerBook4,3</key>
+       <string>iBook G3 Opaque 16MB VRAM, 32MB VRAM, Early 2003)</string>
+       <key>PowerBook5,1</key>
+       <string>PowerBook G4 (17 inch)</string>
+       <key>PowerBook5,2</key>
+       <string>PowerBook G4 (15 inch FW 800)</string>
+       <key>PowerBook5,3</key>
+       <string>PowerBook G4 (17-inch 1.33GHz)</string>
+       <key>PowerBook5,4</key>
+       <string>PowerBook G4 (15 inch 1.5/1.33GHz)</string>
+       <key>PowerBook5,5</key>
+       <string>PowerBook G4 (17-inch 1.5GHz)</string>
+       <key>PowerBook5,6</key>
+       <string>PowerBook G4 (15 inch 1.67GHz/1.5GHz)</string>
+       <key>PowerBook5,7</key>
+       <string>PowerBook G4 (17-inch 1.67GHz)</string>
+       <key>PowerBook5,8</key>
+       <string>PowerBook G4 (Double layer SD, 15 inch)</string>
+       <key>PowerBook5,9</key>
+       <string>PowerBook G4 (Double layer SD, 17 inch)</string>
+       <key>PowerBook6,1</key>
+       <string>PowerBook G4 (12 inch)</string>
+       <key>PowerBook6,2</key>
+       <string>PowerBook G4 (12 inch, DVI)</string>
+       <key>PowerBook6,3</key>
+       <string>iBook G4</string>
+       <key>PowerBook6,4</key>
+       <string>PowerBook G4 (12 inch 1.33GHz)</string>
+       <key>PowerBook6,5</key>
+       <string>iBook G4 (Early-Late 2004)</string>
+       <key>PowerBook6,7</key>
+       <string>iBook G4 (Mid 2005)</string>
+       <key>PowerBook6,8</key>
+       <string>PowerBook G4 (12 inch 1.5GHz)</string>
+       <key>PowerMac1,1</key>
+       <string>Power Macintosh G3 (Blue &amp; White)</string>
+       <key>PowerMac1,2</key>
+       <string>Power Macintosh G4 (PCI Graphics)</string>
+       <key>PowerMac10,1</key>
+       <string>Mac Mini G4</string>
+       <key>PowerMac10,2</key>
+       <string>Mac Mini (Late 2005)</string>
+       <key>PowerMac11,2</key>
+       <string>Power Macintosh G5 (Late 2005)</string>
+       <key>PowerMac12,1</key>
+       <string>iMac G5 (iSight)</string>
+       <key>PowerMac2,1</key>
+       <string>iMac G3 (Slot-loading CD-ROM)</string>
+       <key>PowerMac2,2</key>
+       <string>iMac G3 (Summer 2000)</string>
+       <key>PowerMac3,1</key>
+       <string>Power Macintosh G4 (AGP Graphics)</string>
+       <key>PowerMac3,2</key>
+       <string>Power Macintosh G4 (AGP Graphics)</string>
+       <key>PowerMac3,3</key>
+       <string>Power Macintosh G4 (Gigabit Ethernet)</string>
+       <key>PowerMac3,4</key>
+       <string>Power Macintosh G4 (Digital Audio)</string>
+       <key>PowerMac3,5</key>
+       <string>Power Macintosh G4 (Quick Silver)</string>
+       <key>PowerMac3,6</key>
+       <string>Power Macintosh G4 (Mirrored Drive Door)</string>
+       <key>PowerMac4,1</key>
+       <string>iMac G3 (Early/Summer 2001)</string>
+       <key>PowerMac4,2</key>
+       <string>iMac G4 (Flat Panel)</string>
+       <key>PowerMac4,4</key>
+       <string>eMac</string>
+       <key>PowerMac4,5</key>
+       <string>iMac G4 (17-inch Flat Panel)</string>
+       <key>PowerMac5,1</key>
+       <string>Power Macintosh G4 Cube</string>
+       <key>PowerMac6,1</key>
+       <string>iMac G4 (USB 2.0)</string>
+       <key>PowerMac6,3</key>
+       <string>iMac G4 (20-inch Flat Panel)</string>
+       <key>PowerMac6,4</key>
+       <string>eMac (USB 2.0, 2005)</string>
+       <key>PowerMac7,2</key>
+       <string>Power Macintosh G5</string>
+       <key>PowerMac7,3</key>
+       <string>Power Macintosh G5</string>
+       <key>PowerMac8,1</key>
+       <string>iMac G5</string>
+       <key>PowerMac8,2</key>
+       <string>iMac G5 (Ambient Light Sensor)</string>
+       <key>PowerMac9,1</key>
+       <string>Power Macintosh G5 (Late 2005)</string>
+       <key>RackMac1,1</key>
+       <string>Xserve G4</string>
+       <key>RackMac1,2</key>
+       <string>Xserve G4 (slot-loading, cluster node)</string>
+       <key>RackMac3,1</key>
+       <string>Xserve G5</string>
+       <key>Xserve1,1</key>
+       <string>Xserve (Intel Xeon)</string>
+       <key>Xserve2,1</key>
+       <string>Xserve (January 2008 quad-core)</string>
+       <key>iMac1,1</key>
+       <string>iMac G3 (Rev A-D)</string>
+       <key>iMac4,1</key>
+       <string>iMac (Core Duo)</string>
+       <key>iMac4,2</key>
+       <string>iMac for Education (17-inch, Core Duo)</string>
+       <key>iMac5,1</key>
+       <string>iMac (Core 2 Duo, 17 or 20 inch, SuperDrive)</string>
+       <key>iMac5,2</key>
+       <string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
+       <key>iMac6,1</key>
+       <string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
+       <key>iMac8,1</key>
+       <string>iMac (April 2008)</string>
+</dict>
+</plist>
index ff40c9d..22f13f8 100644 (file)
@@ -1,12 +1,56 @@
-{
-    IBClasses = (
-        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
-        {
-            CLASS = SUStatusController; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {actionButton = id; }; 
-            SUPERCLASS = NSWindowController; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBClasses</key>
+       <array>
+               <dict>
+                       <key>CLASS</key>
+                       <string>SUWindowController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSApplication</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSResponder</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>FirstResponder</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSObject</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>SUStatusController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>OUTLETS</key>
+                       <dict>
+                               <key>actionButton</key>
+                               <string>NSButton</string>
+                               <key>progressBar</key>
+                               <string>NSProgressIndicator</string>
+                       </dict>
+                       <key>SUPERCLASS</key>
+                       <string>SUWindowController</string>
+               </dict>
+       </array>
+       <key>IBVersion</key>
+       <string>1</string>
+</dict>
+</plist>
index 9918344..a9ac867 100644 (file)
@@ -1,16 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-       <key>IBDocumentLocation</key>
-       <string>69 10 356 240 0 0 1280 832 </string>
        <key>IBFramework Version</key>
-       <string>443.0</string>
+       <string>670</string>
+       <key>IBLastKnownRelativeProjectPath</key>
+       <string>Sparkle.xcodeproj</string>
+       <key>IBOldestOS</key>
+       <integer>5</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>5</integer>
+               <integer>6</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8H14</string>
+       <string>10A96</string>
+       <key>targetFramework</key>
+       <string>IBCocoaFramework</string>
 </dict>
 </plist>
index 378b22f..4f1d598 100644 (file)
Binary files a/macosx/Sparkle.framework/Versions/A/Resources/SUStatus.nib/keyedobjects.nib and b/macosx/Sparkle.framework/Versions/A/Resources/SUStatus.nib/keyedobjects.nib differ
index 3e65b1f..4b1ab30 100644 (file)
@@ -1,12 +1,50 @@
-{
-    IBClasses = (
-        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
-        {
-            ACTIONS = {relaunchLater = id; relaunchNow = id; }; 
-            CLASS = SUAutomaticUpdateAlert; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSWindowController; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBClasses</key>
+       <array>
+               <dict>
+                       <key>CLASS</key>
+                       <string>SUWindowController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSWindowController</string>
+               </dict>
+               <dict>
+                       <key>ACTIONS</key>
+                       <dict>
+                               <key>doNotInstall</key>
+                               <string>id</string>
+                               <key>installLater</key>
+                               <string>id</string>
+                               <key>installNow</key>
+                               <string>id</string>
+                       </dict>
+                       <key>CLASS</key>
+                       <string>SUAutomaticUpdateAlert</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>SUWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>FirstResponder</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSObject</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+               </dict>
+       </array>
+       <key>IBVersion</key>
+       <string>1</string>
+</dict>
+</plist>
index 2f65f2f..ab36d31 100644 (file)
@@ -1,16 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-       <key>IBDocumentLocation</key>
-       <string>188 142 356 240 0 0 1280 1002 </string>
        <key>IBFramework Version</key>
-       <string>443.0</string>
+       <string>658</string>
+       <key>IBLastKnownRelativeProjectPath</key>
+       <string>../Sparkle.xcodeproj</string>
+       <key>IBOldestOS</key>
+       <integer>5</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>5</integer>
+               <integer>6</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8H14</string>
+       <string>9C7010</string>
+       <key>targetFramework</key>
+       <string>IBCocoaFramework</string>
 </dict>
 </plist>
index c4201cf..7630390 100644 (file)
Binary files a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib and b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib differ
index 0071ac0..994d4c3 100644 (file)
@@ -1,21 +1,67 @@
-{
-    IBClasses = (
-        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
-        {CLASS = NSObject; LANGUAGE = ObjC; }, 
-        {
-            ACTIONS = {installUpdate = id; remindMeLater = id; skipThisVersion = id; }; 
-            CLASS = SUUpdateAlert; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {description = NSTextField; releaseNotesView = WebView; }; 
-            SUPERCLASS = NSWindowController; 
-        }, 
-        {
-            ACTIONS = {installUpdate = id; remindMeLater = id; skipThisVersion = id; }; 
-            CLASS = SUUpdateAlertController; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {releaseNotesView = id; }; 
-            SUPERCLASS = NSWindowController; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBClasses</key>
+       <array>
+               <dict>
+                       <key>CLASS</key>
+                       <string>SUWindowController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSApplication</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSResponder</string>
+               </dict>
+               <dict>
+                       <key>ACTIONS</key>
+                       <dict>
+                               <key>installUpdate</key>
+                               <string>id</string>
+                               <key>remindMeLater</key>
+                               <string>id</string>
+                               <key>skipThisVersion</key>
+                               <string>id</string>
+                       </dict>
+                       <key>CLASS</key>
+                       <string>SUUpdateAlert</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>OUTLETS</key>
+                       <dict>
+                               <key>delegate</key>
+                               <string>id</string>
+                               <key>description</key>
+                               <string>NSTextField</string>
+                               <key>releaseNotesView</key>
+                               <string>WebView</string>
+                       </dict>
+                       <key>SUPERCLASS</key>
+                       <string>SUWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>FirstResponder</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSObject</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+               </dict>
+       </array>
+       <key>IBVersion</key>
+       <string>1</string>
+</dict>
+</plist>
index 2b25ad0..2fb8a83 100644 (file)
@@ -1,16 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-       <key>IBDocumentLocation</key>
-       <string>425 40 356 240 0 0 1280 832 </string>
        <key>IBFramework Version</key>
-       <string>446.1</string>
+       <string>670</string>
+       <key>IBLastKnownRelativeProjectPath</key>
+       <string>../Sparkle.xcodeproj</string>
+       <key>IBOldestOS</key>
+       <integer>5</integer>
        <key>IBOpenObjects</key>
        <array>
-               <integer>5</integer>
+               <integer>18</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>8I127</string>
+       <string>10A96</string>
+       <key>targetFramework</key>
+       <string>IBCocoaFramework</string>
 </dict>
 </plist>
index be3dbd9..e7e7497 100644 (file)
Binary files a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/keyedobjects.nib and b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/keyedobjects.nib differ
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/classes.nib b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/classes.nib
new file mode 100644 (file)
index 0000000..5220a22
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBClasses</key>
+       <array>
+               <dict>
+                       <key>CLASS</key>
+                       <string>SUWindowController</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSWindowController</string>
+               </dict>
+               <dict>
+                       <key>ACTIONS</key>
+                       <dict>
+                               <key>finishPrompt</key>
+                               <string>id</string>
+                               <key>toggleMoreInfo</key>
+                               <string>id</string>
+                       </dict>
+                       <key>CLASS</key>
+                       <string>SUUpdatePermissionPrompt</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>OUTLETS</key>
+                       <dict>
+                               <key>delegate</key>
+                               <string>id</string>
+                               <key>descriptionTextField</key>
+                               <string>NSTextField</string>
+                               <key>moreInfoButton</key>
+                               <string>NSButton</string>
+                               <key>moreInfoView</key>
+                               <string>NSView</string>
+                       </dict>
+                       <key>SUPERCLASS</key>
+                       <string>SUWindowController</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>FirstResponder</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+                       <key>SUPERCLASS</key>
+                       <string>NSObject</string>
+               </dict>
+               <dict>
+                       <key>CLASS</key>
+                       <string>NSObject</string>
+                       <key>LANGUAGE</key>
+                       <string>ObjC</string>
+               </dict>
+       </array>
+       <key>IBVersion</key>
+       <string>1</string>
+</dict>
+</plist>
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/info.nib b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/info.nib
new file mode 100644 (file)
index 0000000..b1cd28e
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBFramework Version</key>
+       <string>670</string>
+       <key>IBLastKnownRelativeProjectPath</key>
+       <string>../Sparkle.xcodeproj</string>
+       <key>IBOldestOS</key>
+       <integer>5</integer>
+       <key>IBOpenObjects</key>
+       <array>
+               <integer>6</integer>
+               <integer>41</integer>
+       </array>
+       <key>IBSystem Version</key>
+       <string>10A96</string>
+       <key>targetFramework</key>
+       <string>IBCocoaFramework</string>
+</dict>
+</plist>
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib
new file mode 100644 (file)
index 0000000..e8dc5b8
Binary files /dev/null and b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdatePermissionPrompt.nib/keyedobjects.nib differ
index 6bf42f7..16e0787 100644 (file)
Binary files a/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/Sparkle.strings and b/macosx/Sparkle.framework/Versions/A/Resources/en.lproj/Sparkle.strings differ
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/fr_CA.lproj b/macosx/Sparkle.framework/Versions/A/Resources/fr_CA.lproj
new file mode 120000 (symlink)
index 0000000..88614fe
--- /dev/null
@@ -0,0 +1 @@
+/Users/andym/Development/Build Products/Release/Sparkle.framework/Resources/fr.lproj
\ No newline at end of file
diff --git a/macosx/Sparkle.framework/Versions/A/Resources/relaunch b/macosx/Sparkle.framework/Versions/A/Resources/relaunch
new file mode 100755 (executable)
index 0000000..e7b96d6
Binary files /dev/null and b/macosx/Sparkle.framework/Versions/A/Resources/relaunch differ
index 9dbf9e7..3f82bcb 100755 (executable)
Binary files a/macosx/Sparkle.framework/Versions/A/Sparkle and b/macosx/Sparkle.framework/Versions/A/Sparkle differ
diff --git a/macosx/icons/Brushed_Window.png b/macosx/icons/Brushed_Window.png
new file mode 100644 (file)
index 0000000..17d6ef0
Binary files /dev/null and b/macosx/icons/Brushed_Window.png differ
diff --git a/macosx/module.defs b/macosx/module.defs
new file mode 100644 (file)
index 0000000..d92160f
--- /dev/null
@@ -0,0 +1,58 @@
+$(eval $(call import.MODULE.defs,MACOSX,macosx))
+$(eval $(call import.GCC,MACOSX))
+
+MACOSX.src/   = $(SRC/)macosx/
+MACOSX.build/ = $(BUILD/)macosx/
+
+MACOSX.m4.in  = $(wildcard $(MACOSX.src/)*.m4)
+MACOSX.m4.out = $(MACOSX.m4.in:$(MACOSX.src/)%.m4=$(MACOSX.build/)%)
+
+## optional special command to run post macro processing
+MACOSX.m4.post.Info.h = $(RM.exe) -f $(MACOSX.build/)HandBrake.build/Preprocessed-Info.plist
+
+MACOSX.targs = HandBrakeCLI HandBrake
+
+## configuration pattern: (standard|debug)[.ARCH]
+## eg. for native build, no debug --> standard
+## eg. for x86_64 build with debug of any level --> debug.x86_64
+MACOSX.conf  = $(MACOSX.map.g.$(MACOSX.GCC.g)).$(BUILD.arch)
+
+## this is a mapping to determine which basename config to use in xcodeproj
+MACOSX.map.g.none = standard
+MACOSX.map.g.min  = debug
+MACOSX.map.g.std  = debug
+MACOSX.map.g.max  = debug
+
+###############################################################################
+
+BUILD.out += $(MACOSX.m4.out)
+BUILD.out += $(MACOSX.m4.wc.out)
+
+###############################################################################
+
+MACOSX.XCODE.exe     = xcodebuild
+MACOSX.XCODE.project = HandBrake.xcodeproj
+
+## launch a build thru xcode; which in turn will do a nested make against
+## this build system with normal build rules enabled.
+##
+## $(1) = list of targets
+## $(2) = list of goals to shunt thru xcodebuild->make
+##
+XCODE.sysroot = $(foreach sdk,$(GCC.sysroot),-sdk $(sdk))
+MACOSX.XCODE = $(strip \
+    cd $(MACOSX.src/) && \
+       $(MACOSX.XCODE.exe) \
+        -project $(MACOSX.XCODE.project) \
+        -configuration $(MACOSX.conf) \
+       $(XCODE.sysroot) \
+        $(foreach t,$(1),-target $t) \
+        EXTERNAL_SRC='$(XCODE.external.src)' \
+        EXTERNAL_BUILD='$(XCODE.external.build)' \
+        EXTERNAL_PREFIX='$(XCODE.external.prefix)' \
+        EXTERNAL_JOBS='$(BUILD.jobs)' \
+        EXTERNAL_METHOD='$(CONF.method)' \
+        EXTERNAL_CONFARGS='$(CONF.args)' \
+        EXTERNAL_GOALS='$(3)' \
+        EXTERNAL_VARS='$(-*-command-variables-*-)' \
+        $(2) )
diff --git a/macosx/module.rules b/macosx/module.rules
new file mode 100644 (file)
index 0000000..c662364
--- /dev/null
@@ -0,0 +1,17 @@
+$(eval $(call import.MODULE.rules,MACOSX))
+
+macosx.build: $(MACOSX.m4.out)
+
+macosx.clean:
+       $(RM.exe) -f $(MACOSX.m4.out)
+
+$(MACOSX.m4.out): $(BUILD/)project/handbrake.m4
+$(MACOSX.m4.out): | $(dir $(MACOSX.m4.out))
+$(MACOSX.m4.out): $(MACOSX.build/)%: $(MACOSX.src/)%.m4
+       $(M4.exe) -Iproject $< > $@
+       $(MACOSX.m4.post.$(notdir $@))
+
+###############################################################################
+
+clean: macosx.clean
+build: macosx.build
diff --git a/macosx/module.xcode b/macosx/module.xcode
new file mode 100644 (file)
index 0000000..fc52b36
--- /dev/null
@@ -0,0 +1,29 @@
+## This rules file is processed only when xcode=1 method=terminal
+## which hands-off the build to Xcode which in turn may callback this
+## build system.
+
+.PHONY: macosx.build macosx.clean macosx.install
+
+macosx.build:
+       $(call MACOSX.XCODE,HandBrakeCLI HandBrake,build)
+
+macosx.clean:
+       $(call MACOSX.XCODE,HandBrakeCLI HandBrake,clean)
+
+macosx.install:
+       $(call MACOSX.XCODE,HandBrakeCLI HandBrake,install)
+
+build: macosx.build
+clean: macosx.clean
+install: macosx.install
+xclean: clean
+
+###############################################################################
+
+MACOSX.goals = $(filter-out build clean install,$(MAKECMDGOALS))
+
+$(MACOSX.goals): __goals__
+       @true
+
+__goals__:
+       $(call MACOSX.XCODE,external,build,$(MACOSX.goals))
diff --git a/make/config.guess b/make/config.guess
new file mode 100755 (executable)
index 0000000..e792aac
--- /dev/null
@@ -0,0 +1,1494 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-09-18'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches@gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep -q __ELF__
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[456])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep -q __LP64__
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       case ${UNAME_MACHINE} in
+           pc98)
+               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:[3456]*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           EM64T | authenticamd | genuineintel)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    8664:Windows_NT:*)
+       echo x86_64-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep -q ld.so.1
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       echo ${UNAME_MACHINE}-pc-linux-gnu
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef ${UNAME_MACHINE}
+       #undef ${UNAME_MACHINE}el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=${UNAME_MACHINE}el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=${UNAME_MACHINE}
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^CPU/{
+               s: ::g
+               p
+           }'`"
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    or32:Linux:*:*)
+       echo or32-unknown-linux-gnu
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-gnu
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           i386)
+               eval $set_cc_for_build
+               if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+                     grep IS_64BIT_ARCH >/dev/null
+                 then
+                     UNAME_PROCESSOR="x86_64"
+                 fi
+               fi ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/make/configure.py b/make/configure.py
new file mode 100644 (file)
index 0000000..a12d380
--- /dev/null
@@ -0,0 +1,1409 @@
+###############################################################################
+##
+## This script is coded for minimum version of Python 2.4 .
+## Pyhthon3 is incompatible.
+##
+## Authors: konablend
+##
+###############################################################################
+
+import fnmatch
+import optparse
+import os
+import platform
+import re
+import subprocess
+import sys
+import time
+
+from optparse import OptionGroup
+from optparse import OptionGroup
+from optparse import OptionParser
+from sys import stderr
+from sys import stdout
+
+class AbortError( Exception ):
+    def __init__( self, format, *args ):
+        self.value = format % args
+    def __str__( self ):
+        return self.value
+
+###############################################################################
+##
+## Main configure object.
+##
+## dir = containing this configure script
+## cwd = current working dir at time of script launch
+##
+class Configure( object ):
+    OUT_QUIET   = 0
+    OUT_INFO    = 1
+    OUT_VERBOSE = 2
+
+    def __init__( self, verbose ):
+        self._log_info    = []
+        self._log_verbose = []
+        self._record      = False
+
+        self.verbose = verbose
+        self.dir = os.path.dirname( sys.argv[0] )
+        self.cwd = os.getcwd()
+
+        self.build_dir = '.'
+
+        ## compute src dir which is 2 dirs up from this script
+        self.src_dir = os.path.normpath( sys.argv[0] )
+        for i in range( 2 ):
+            self.src_dir = os.path.dirname( self.src_dir )
+        if len( self.src_dir ) == 0:
+            self.src_dir = os.curdir
+
+    def _final_dir( self, chdir, dir ):
+        dir = os.path.normpath( dir )
+        if not os.path.isabs( dir ):
+            if os.path.isabs( chdir ):
+                dir = os.path.normpath( os.path.abspath(dir ))
+            else:
+                dir = os.path.normpath( self.relpath( dir, chdir ))
+        return dir
+
+    ## output functions
+    def errln( self, format, *args ):
+        s = (format % args)
+        if re.match( '^.*[!?:;.]$', s ):
+            stderr.write( 'ERROR: %s configure stop.\n' % (s) )
+        else:
+            stderr.write( 'ERROR: %s; configure stop.\n' % (s) )
+        self.record_log()
+        sys.exit( 1 )
+    def infof( self, format, *args ):
+        line = format % args
+        self._log_verbose.append( line )
+        if cfg.verbose >= Configure.OUT_INFO:
+            self._log_info.append( line )
+            stdout.write( line )
+    def verbosef( self, format, *args ):
+        line = format % args
+        self._log_verbose.append( line )
+        if cfg.verbose >= Configure.OUT_VERBOSE:
+            stdout.write( line )
+
+    ## doc is ready to be populated
+    def doc_ready( self ):
+        ## compute final paths as they are after chdir into build
+        self.build_final  = os.curdir
+        self.src_final    = self._final_dir( self.build_dir, self.src_dir )
+        self.prefix_final = self._final_dir( self.build_dir, self.prefix_dir )
+
+        cfg.infof( 'compute: makevar SRC/    = %s\n', self.src_final )
+        cfg.infof( 'compute: makevar BUILD/  = %s\n', self.build_final )
+        cfg.infof( 'compute: makevar PREFIX/ = %s\n', self.prefix_final )
+
+        ## xcode does a chdir so we need appropriate values
+        macosx = os.path.join( self.src_dir, 'macosx' )
+        self.xcode_x_src    = self._final_dir( macosx, self.src_dir )
+        self.xcode_x_build  = self._final_dir( macosx, self.build_dir )
+        self.xcode_x_prefix = self._final_dir( macosx, self.prefix_dir )
+
+    ## perform chdir and enable log recording
+    def chdir( self ):
+        if os.path.abspath( self.build_dir ) == os.path.abspath( self.src_dir ):
+            cfg.errln( 'build (scratch) directory must not be the same as top-level source root!' )
+
+        if self.build_dir != os.curdir:
+            if os.path.exists( self.build_dir ):
+                if not options.force:
+                    self.errln( 'build directory already exists: %s (use --force to overwrite)', self.build_dir )
+            else:
+                self.mkdirs( self.build_dir )
+            self.infof( 'chdir: %s\n', self.build_dir )
+            os.chdir( self.build_dir )
+
+        ## enable logging
+        self._record = True
+
+    def mkdirs( self, dir ):
+        if len(dir) and not os.path.exists( dir ):
+            self.infof( 'mkdir: %s\n', dir )
+            os.makedirs( dir )
+
+    def open( self, *args ):
+        dir = os.path.dirname( args[0] )
+        if len(args) > 1 and args[1].find('w') != -1:
+            self.mkdirs( dir )
+        m = re.match( '^(.*)\.tmp$', args[0] )
+        if m:
+            self.infof( 'write: %s\n', m.group(1) )
+        else:
+            self.infof( 'write: %s\n', args[0] )
+
+        try:
+            return open( *args )
+        except Exception, x:
+            cfg.errln( 'open failure: %s', x )
+
+    def record_log( self ):
+        if not self._record:
+            return
+        self._record = False
+        self.verbose = Configure.OUT_QUIET
+        file = cfg.open( 'log/config.info.txt', 'w' )
+        for line in self._log_info:
+            file.write( line )
+        file.close()
+        file = cfg.open( 'log/config.verbose.txt', 'w' )
+        for line in self._log_verbose:
+            file.write( line )
+        file.close()
+
+    ## Find executable by searching path.
+    ## On success, returns full pathname of executable.
+    ## On fail, returns None.
+    def findExecutable( self, name ):
+        if len( os.path.split(name)[0] ):
+            if os.access( name, os.X_OK ):
+                return name
+            return None
+        
+        if not os.environ.has_key( 'PATH' ) or os.environ[ 'PATH' ] == '':
+            path = os.defpath
+        else:
+            path = os.environ['PATH']
+        
+        for dir in path.split( os.pathsep ):
+            f = os.path.join( dir, name )
+            if os.access( f, os.X_OK ):
+                return f
+        return None
+
+    ## taken from python2.6 -- we need it
+    def relpath( self, path, start=os.curdir ):
+        """Return a relative version of a path"""
+
+        if not path:
+            raise ValueError("no path specified")
+
+        start_list = os.path.abspath(start).split(os.sep)
+        path_list = os.path.abspath(path).split(os.sep)
+
+        # Work out how much of the filepath is shared by start and path.
+        i = len(os.path.commonprefix([start_list, path_list]))
+
+        rel_list = [os.pardir] * (len(start_list)-i) + path_list[i:]
+        if not rel_list:
+            return os.curdir
+        return os.path.join(*rel_list)
+
+    ## update with parsed cli options
+    def update_cli( self, options ):
+        self.src_dir    = os.path.normpath( options.src )
+        self.build_dir  = os.path.normpath( options.build )
+        self.prefix_dir = os.path.normpath( options.prefix )
+        if options.sysroot != None:
+                self.sysroot_dir = os.path.normpath( options.sysroot )
+        else:
+                self.sysroot_dir = ""
+
+        if options.minver != None:
+                self.minver = options.minver
+        else:
+                self.minver = ""
+
+        ## special case if src == build: add build subdir
+        if os.path.abspath( self.src_dir ) == os.path.abspath( self.build_dir ):
+            self.build_dir = os.path.join( self.build_dir, 'build' )
+
+###############################################################################
+##
+## abstract action
+##
+## pretext = text which immediately follows 'probe:' output prefix
+## abort   = if true configure will exit on probe fail
+## head    = if true probe session is stripped of all but first line
+## session = output from command, including stderr
+## fail    = true if probe failed
+##
+class Action( object ):
+    actions = []
+
+    def __init__( self, category, pretext='unknown', abort=False, head=False ):
+        if self not in Action.actions:
+            Action.actions.append( self )
+
+        self.category = category
+        self.pretext  = pretext
+        self.abort    = abort
+        self.head     = head
+        self.session  = None
+
+        self.run_done = False
+        self.fail     = True
+        self.msg_fail = 'fail'
+        self.msg_pass = 'pass'
+        self.msg_end  = 'end'
+
+    def _actionBegin( self ):
+        cfg.infof( '%s: %s...', self.category, self.pretext )
+
+    def _actionEnd( self ):
+        if self.fail:
+            cfg.infof( '(%s) %s\n', self.msg_fail, self.msg_end )
+            if self.abort:
+                self._dumpSession( cfg.infof )
+                cfg.errln( 'unable to continue' )
+            self._dumpSession( cfg.verbosef )
+        else:
+            cfg.infof( '(%s) %s\n', self.msg_pass, self.msg_end )
+            self._dumpSession( cfg.verbosef )
+
+    def _dumpSession( self, printf ):
+        if self.session and len(self.session):
+            for line in self.session:
+                printf( '  : %s\n', line )
+        else:
+            printf( '  : <NO-OUTPUT>\n' )
+
+    def _parseSession( self ):
+        pass
+
+    def run( self ):
+        if self.run_done:
+            return
+        self.run_done = True
+        self._actionBegin()
+        self._action()
+        if not self.fail:
+            self._parseSession()
+        self._actionEnd()
+
+###############################################################################
+##
+## base probe: anything which runs in shell.
+##
+## pretext = text which immediately follows 'probe:' output prefix
+## command = full command and arguments to pipe
+## abort   = if true configure will exit on probe fail
+## head    = if true probe session is stripped of all but first line
+## session = output from command, including stderr
+## fail    = true if probe failed
+##
+class ShellProbe( Action ):
+    def __init__( self, pretext, command, abort=False, head=False ):
+        super( ShellProbe, self ).__init__( 'probe', pretext, abort, head )
+        self.command = command
+
+    def _action( self ):
+        ## pipe and redirect stderr to stdout; effects communicate result
+        pipe = subprocess.Popen( self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
+
+        ## read data into memory buffers, only first element (stdout) data is used
+        data = pipe.communicate()
+        self.fail = pipe.returncode != 0
+
+        if data[0]:
+            self.session = data[0].splitlines()
+        else:
+            self.session = []
+
+        if pipe.returncode:
+            self.msg_end = 'code %d' % (pipe.returncode)
+
+    def _dumpSession( self, printf ):
+        printf( '  + %s\n', self.command )
+        super( ShellProbe, self )._dumpSession( printf )
+
+###############################################################################
+##
+## GNU host tuple probe: determine canonical platform type
+##
+## example results from various platforms:
+##
+##   i386-apple-darwin9.6.0     (Mac OS X 10.5.6 Intel)
+##   powerpc-apple-darwin9.6.0  (Mac OS X 10.5.6 PPC)
+##   i686-pc-cygwin             (Cygwin, Microsoft Vista)
+##   x86_64-unknown-linux-gnu   (Linux, Fedora 10 x86_64)
+##
+class HostTupleProbe( ShellProbe, list ):
+    GNU_TUPLE_RE = '([^-]+)-?([^-]*)-([^0-9-]+)([^-]*)-?([^-]*)'
+
+    def __init__( self ):
+        super( HostTupleProbe, self ).__init__( 'host tuple', '%s/config.guess' % (cfg.dir), abort=True, head=True )
+
+    def _parseSession( self ):
+        if len(self.session):
+            self.spec = self.session[0]
+        else:
+            self.spec = ''
+
+        ## grok GNU host tuples
+        m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec )
+        if not m:
+            self.fail = True
+            self.msg_end = 'invalid host tuple: %s' % (self.spec)
+            return
+
+        self.msg_end = self.spec
+
+        ## assign tuple from regex
+        self[:] = m.groups()
+
+        ## for clarity
+        self.machine = self[0]
+        self.vendor  = self[1]
+        self.system  = self[2]
+        self.release = self[3]
+        self.extra   = self[4]
+
+        ## nice formal name for 'system'
+        self.systemf = platform.system()
+
+        if self.match( '*-*-cygwin*' ):
+            self.systemf = self[2][0].upper() + self[2][1:]
+            
+    ## glob-match against spec
+    def match( self, *specs ):
+        for spec in specs:
+            if fnmatch.fnmatch( self.spec, spec ):
+                return True
+        return False
+
+###############################################################################
+
+class BuildAction( Action, list ):
+    def __init__( self ):
+        super( BuildAction, self ).__init__( 'compute', 'build tuple', abort=True )
+
+    def _action( self ):
+        ## check if --cross spec was used; must maintain 5-tuple compatibility with regex
+        if options.cross:
+            self.spec = os.path.basename( options.cross ).rstrip( '-' )
+        else:
+            self.spec = arch.mode[arch.mode.mode]
+
+        ## grok GNU host tuples
+        m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec )
+        if not m:
+            self.msg_end = 'invalid host tuple: %s' % (self.spec)
+            return
+
+        self.msg_end = self.spec
+
+        ## assign tuple from regex
+        self[:] = m.groups()
+
+        ## for clarity
+        self.machine = self[0]
+        self.vendor  = self[1]
+        self.system  = self[2]
+        self.release = self[3]
+        self.extra   = self[4]
+        self.systemf = host.systemf
+
+        ## when cross we need switch for platforms
+        if options.cross:
+            if self.match( '*mingw*' ):
+                self.systemf = 'MinGW'
+            elif self.systemf:
+                self.systemf[0] = self.systemf[0].upper()
+            self.title = '%s %s' % (build.systemf,self.machine)
+        else:
+            self.title = '%s %s' % (build.systemf,arch.mode.mode)
+        self.fail = False
+
+    ## glob-match against spec
+    def match( self, *specs ):
+        for spec in specs:
+            if fnmatch.fnmatch( self.spec, spec ):
+                return True
+        return False
+
+###############################################################################
+##
+## value wrapper; value is accepted only if one of host specs matcheds
+## otherwise it is None (or a keyword-supplied val)
+##
+## result is attribute 'value'
+##
+class IfHost( object ):
+    def __init__( self, value, *specs, **kwargs ):
+        self.value = kwargs.get('none',None)
+        for spec in specs:
+            if host.match( spec ):
+                self.value = value
+                break
+
+    def __nonzero__( self ):
+        return self.value != None
+        
+    def __str__( self ):
+        return self.value
+
+
+###############################################################################
+##
+## platform conditional value; loops through list of tuples comparing
+## to first host match and sets value accordingly; the first value is
+## always default.
+##
+class ForHost( object ):
+    def __init__( self, default, *tuples ):
+        self.value = default
+        for tuple in tuples:
+            if host.match( tuple[1] ):
+                self.value = tuple[0]
+                break
+
+    def __str__( self ):
+        return self.value
+
+###############################################################################
+
+class ArchAction( Action ):
+    def __init__( self ):
+        super( ArchAction, self ).__init__( 'compute', 'available architectures', abort=True )
+        self.mode = SelectMode( 'architecture', (host.machine,host.spec) )
+
+    def _action( self ):
+        self.fail = False
+
+        ## some match on system should be made here; otherwise we signal a warning. 
+        if host.match( '*-*-cygwin*' ):
+            pass
+        elif host.match( '*-*-darwin*' ):
+            self.mode['i386']   = 'i386-apple-darwin%s'      % (host.release)
+            self.mode['x86_64'] = 'x86_64-apple-darwin%s'    % (host.release)
+            self.mode['ppc']    = 'powerpc-apple-darwin%s'   % (host.release)
+            self.mode['ppc64']  = 'powerpc64-apple-darwin%s' % (host.release)
+
+            ## special cases in that powerpc does not match gcc -arch value
+            ## which we like to use; so it has to be removed.
+            ## note: we don't know if apple will release Ssnow Leopad/ppc64 yet; just a guess.
+            if 'powerpc' in self.mode:
+                del self.mode['powerpc']
+                self.mode.mode = 'ppc'
+            elif 'powerpc64' in self.mode:
+                del self.mode['powerpc64']
+                self.mode.mode = 'ppc64'
+        elif host.match( '*-*-linux*' ):
+            pass
+        else:
+            self.msg_pass = 'WARNING'
+
+        self.msg_end = self.mode.toString()
+
+    ## glob-match against spec
+    def match( self, spec ):
+        return fnmatch.fnmatch( self.spec, spec )
+
+###############################################################################
+
+class CoreProbe( Action ):
+    def __init__( self ):
+        super( CoreProbe, self ).__init__( 'probe', 'number of CPU cores' )
+        self.count = 1
+
+    def _action( self ):
+        if self.fail:
+            ## good for darwin9.6.0 and linux
+            try:
+                self.count = os.sysconf( 'SC_NPROCESSORS_ONLN' )
+                if self.count < 1:
+                    self.count = 1
+                self.fail = False
+            except:
+                pass
+
+        if self.fail:
+            ## windows
+            try:
+                self.count = int( os.environ['NUMBER_OF_PROCESSORS'] )
+                if self.count < 1:
+                    self.count = 1
+                self.fail = False
+            except:
+                pass
+
+        ## clamp
+        if self.count < 1:
+            self.count = 1
+        elif self.count > 32:
+            self.count = 32
+
+        if options.launch:
+            if options.launch_jobs == 0:
+                self.jobs = core.count
+            else:
+                self.jobs = options.launch_jobs
+        else:
+            self.jobs = core.count
+
+        self.msg_end = str(self.count)
+
+###############################################################################
+
+class SelectMode( dict ):
+    def __init__( self, descr, *modes, **kwargs ):
+        super( SelectMode, self ).__init__( modes )
+        self.descr    = descr
+        self.modes    = modes
+        self.default  = kwargs.get('default',modes[0][0])
+        self.mode     = self.default
+
+    def cli_add_option( self, parser, option ):
+        parser.add_option( option, default=self.mode, metavar='MODE',
+            help='select %s mode: %s' % (self.descr,self.toString()),
+            action='callback', callback=self.cli_callback, type='str' )
+
+    def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ):
+        if value not in self:
+            raise optparse.OptionValueError( 'invalid %s mode: %s (choose from %s)'
+                % (self.descr,value,self.toString( True )) )
+        self.mode = value
+
+    def toString( self, nodefault=False ):
+        keys = self.keys()
+        keys.sort()
+        if len(self) == 1:
+            value = self.mode
+        elif nodefault:
+            value = ' '.join( keys )
+        else:
+            value = '%s [%s]' % (' '.join( keys ), self.mode )
+        return value
+
+###############################################################################
+##
+## Repository object.
+## Holds information gleaned from subversion working dir.
+##
+## Builds are classed into one of the following types:
+##
+##  release
+##      must be built from official svn with '/tags/' in the url
+##  developer
+##      must be built from official svn but is not a release
+##  unofficial
+##      all other builds
+##
+class RepoProbe( ShellProbe ):
+    def __init__( self ):
+        super( RepoProbe, self ).__init__( 'svn info', 'svn info %s' % (cfg.src_dir) )
+
+        self.url       = 'svn://nowhere.com/project/unknown'
+        self.root      = 'svn://nowhere.com/project'
+        self.branch    = 'unknown'
+        self.uuid      = '00000000-0000-0000-0000-000000000000';
+        self.rev       = 0
+        self.date      = '0000-00-00 00:00:00 -0000'
+        self.official  = 0
+        self.type      = 'unofficial'
+
+    def _parseSession( self ):
+        for line in self.session:
+            ## grok fields
+            m = re.match( '([^:]+):\\s+(.+)', line )
+            if not m:
+                continue
+
+            (name,value) = m.groups()
+            if name == 'URL':
+                self.url = value
+            elif name == 'Repository Root':
+                self.root = value
+            elif name == 'Repository UUID':
+                self.uuid = value
+            elif name == 'Revision':
+                self.rev = int( value )
+            elif name == 'Last Changed Date':
+                # strip chars in parens
+                if value.find( ' (' ):
+                    self.date = value[0:value.find(' (')]
+                else:
+                    self.date = value
+
+        ## grok branch
+        i = self.url.rfind( '/' )
+        if i != -1 and i < len(self.url)-1:
+            self.branch = self.url[i+1:]
+
+        # type-classification via repository UUID
+        if self.uuid == 'b64f7644-9d1e-0410-96f1-a4d463321fa5':
+            self.official = 1
+            m = re.match( '([^:]+)://([^/]+)/(.+)', self.url )
+            if m and re.match( '.*tags/.*', m.group( 3 )):
+                self.type = 'release'
+            else:
+                self.type = 'developer'
+
+        self.msg_end = self.url
+
+###############################################################################
+##
+## project object.
+##
+## Contains manually updated version numbers consistent with HB releases
+## and other project metadata.
+##
+class Project( Action ):
+    def __init__( self ):
+        super( Project, self ).__init__( 'compute', 'project data' )
+
+        self.name          = 'HandBrake'
+        self.acro_lower    = 'hb'
+        self.acro_upper    = 'HB'
+        self.url_website   = 'http://handbrake.fr'
+        self.url_community = 'http://forum.handbrake.fr'
+        self.url_irc       = 'irc://irc.freenode.net/handbrake'
+
+        self.name_lower = self.name.lower()
+        self.name_upper = self.name.upper()
+
+        self.vmajor = 0
+        self.vminor = 9
+        self.vpoint = 4
+
+    def _action( self ):
+        ## add architecture to URL only for Mac
+        if fnmatch.fnmatch( build.spec, '*-*-darwin*' ):
+            url_arch = '.%s' % (arch.mode.mode)
+        else:
+            url_arch = ''
+
+        if repo.type == 'release':
+            self.version = '%d.%d.%d' % (self.vmajor,self.vminor,self.vpoint)
+            url_ctype = ''
+            url_ntype = 'stable'
+            self.build = time.strftime('%Y%m%d') + '00'
+            self.title = '%s %s (%s)' % (self.name,self.version,self.build)
+        elif repo.type == 'developer':
+            self.version = 'svn%d' % (repo.rev)
+            url_ctype = '_unstable'
+            url_ntype = 'unstable'
+            self.build = time.strftime('%Y%m%d') + '01'
+            self.title = '%s svn%d (%s)' % (self.name,repo.rev,self.build)
+        else:
+            self.version = 'rev%d' % (repo.rev)
+            url_ctype = '_unofficial'
+            url_ntype = 'unofficial'
+            self.build = time.strftime('%Y%m%d') + '99'
+            self.title = '%s rev%d (%s)' % (self.name,repo.rev,self.build)
+
+        self.url_appcast = 'http://handbrake.fr/appcast%s%s.xml' % (url_ctype,url_arch)
+        self.url_appnote = 'http://handbrake.fr/appcast/%s.html' % (url_ntype)
+
+        self.msg_end = '%s (%s)' % (self.name,repo.type)
+        self.fail = False
+
+###############################################################################
+
+class ToolProbe( Action ):
+    tools = []
+
+    def __init__( self, var, *names, **kwargs ):
+        super( ToolProbe, self ).__init__( 'find', abort=kwargs.get('abort',True) )
+        if not self in ToolProbe.tools:
+            ToolProbe.tools.append( self )
+        self.var    = var
+        self.names  = []
+        self.kwargs = kwargs
+        for name in names:
+            if name:
+                self.names.append( str(name) )
+        self.name = self.names[0]
+        self.pretext = self.name
+        self.pathname = self.names[0]
+
+    def _action( self ):
+        self.session = []
+        for i,name in enumerate(self.names):
+            self.session.append( 'name[%d] = %s' % (i,name) )
+        for name in self.names:
+            f = cfg.findExecutable( name )
+            if f:
+                self.pathname = f
+                self.fail = False
+                self.msg_end = f
+                break
+        if self.fail:
+            self.msg_end = 'not found'
+
+    def cli_add_option( self, parser ):
+        parser.add_option( '--'+self.name, metavar='PROG',
+            help='[%s]' % (self.pathname),
+            action='callback', callback=self.cli_callback, type='str' )
+
+    def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ):
+        self.__init__( self.var, value, **self.kwargs )
+        self.run()
+
+    def doc_add( self, doc ):
+        doc.add( self.var, self.pathname )
+
+###############################################################################
+
+class SelectTool( Action ):
+    selects = []
+
+    def __init__( self, var, name, *pool, **kwargs ):
+        super( SelectTool, self ).__init__( 'select', abort=kwargs.get('abort',True) )
+        self.pretext = name
+        if not self in SelectTool.selects:
+            SelectTool.selects.append( self )
+        self.var      = var
+        self.name     = name
+        self.pool     = pool
+        self.kwargs   = kwargs
+
+    def _action( self ):
+        self.session = []
+        for i,(name,tool) in enumerate(self.pool):
+            self.session.append( 'tool[%d] = %s (%s)' % (i,name,tool.pathname) )
+        for (name,tool) in self.pool:
+            if not tool.fail:
+                self.selected = name
+                self.fail = False
+                self.msg_end = '%s (%s)' % (name,tool.pathname)
+                break
+        if self.fail:
+            self.msg_end = 'not found'
+
+    def cli_add_option( self, parser ):
+        parser.add_option( '--'+self.name, metavar='MODE',
+            help='select %s mode: %s' % (self.name,self.toString()),
+            action='callback', callback=self.cli_callback, type='str' )
+
+    def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ):
+        found = False
+        for (name,tool) in self.pool:
+            if name == value:
+                found = True
+                self.__init__( self.var, self.name, [name,tool], **kwargs )
+                self.run()
+                break
+        if not found:
+            raise optparse.OptionValueError( 'invalid %s mode: %s (choose from %s)'
+                % (self.name,value,self.toString( True )) )
+
+    def doc_add( self, doc ):
+        doc.add( self.var, self.selected )
+
+    def toString( self, nodefault=False ):
+        if len(self.pool) == 1:
+            value = self.pool[0][0]
+        else:
+            s = ''
+            for key,value in self.pool:
+                s += ' ' + key
+            if nodefault:
+                value = s[1:]
+            else:
+                value = '%s [%s]' % (s[1:], self.selected )
+        return value
+
+###############################################################################
+##
+## config object used to output gnu-make or gnu-m4 output.
+##
+## - add() to add NAME/VALUE pairs suitable for both make/m4.
+## - addBlank() to add a linefeed for both make/m4.
+## - addMake() to add a make-specific line.
+## - addM4() to add a m4-specific line.
+##
+class ConfigDocument:
+    def __init__( self ):
+        self._elements = []
+
+    def _outputMake( self, file, namelen, name, value, append ):
+        if append:
+            if value == None or len(str(value)) == 0:
+                file.write( '%-*s +=\n' % (namelen, name) )
+            else:
+                file.write( '%-*s += %s\n' % (namelen, name, value) )
+        else:
+            if value == None or len(str(value)) == 0:
+                file.write( '%-*s  =\n' % (namelen, name) )
+            else:
+                file.write( '%-*s  = %s\n' % (namelen, name, value) )
+
+    def _outputM4( self, file, namelen, name, value ):
+        namelen += 7
+        name = '<<__%s>>,' % name.replace( '.', '_' )
+        file.write( 'define(%-*s  <<%s>>)dnl\n' % (namelen, name, value ))
+
+    def add( self, name, value, append=False ):
+        self._elements.append( [name,value,append] )
+
+    def addBlank( self ):
+        self._elements.append( None )
+
+    def addComment( self, format, *args ):
+        self.addMake( '## ' + format % args )
+        self.addM4( 'dnl ' + format % args )
+
+    def addMake( self, line ):
+        self._elements.append( ('?make',line) )
+
+    def addM4( self, line ):
+        self._elements.append( ('?m4',line) )
+
+    def output( self, file, type ):
+        namelen = 0
+        for item in self._elements:
+            if item == None or item[0].find( '?' ) == 0:
+                continue
+            if len(item[0]) > namelen:
+                namelen = len(item[0])
+        for item in self._elements:
+            if item == None:
+                if type == 'm4':
+                    file.write( 'dnl\n' )
+                else:
+                    file.write( '\n' )
+                continue
+            if item[0].find( '?' ) == 0:
+                if item[0].find( type, 1 ) == 1:
+                    file.write( '%s\n' % (item[1]) )
+                continue
+
+            if type == 'm4':
+                self._outputM4( file, namelen, item[0], item[1] )
+            else:
+                self._outputMake( file, namelen, item[0], item[1], item[2] )
+
+    def update( self, name, value ):
+        for item in self._elements:
+            if item == None:
+                continue
+            if item[0] == name:
+                item[1] = value
+                return
+        raise ValueError( 'element not found: %s' % (name) )
+
+    def write( self, type ):
+        if type == 'make':
+            fname = 'GNUmakefile'
+        elif type == 'm4':
+            fname = os.path.join( 'project', project.name_lower + '.m4' )
+        else:
+            raise ValueError, 'unknown file type: ' + type
+
+        ftmp  = fname + '.tmp'
+        try:
+            try:
+                file = cfg.open( ftmp, 'w' )
+                self.output( file, type )
+            finally:
+                try:
+                    file.close()
+                except:
+                    pass
+        except Exception, x:
+            try:
+                os.remove( ftmp )
+            except Exception, x:
+                pass
+            cfg.errln( 'failed writing to %s\n%s', ftmp, x )
+
+        try:
+            os.rename( ftmp, fname )
+        except Exception, x:
+            cfg.errln( 'failed writing to %s\n%s', fname, x )
+
+###############################################################################
+##
+## create cli parser
+##
+
+## class to hook options and create CONF.args list
+class Option( optparse.Option ):
+    conf_args = []
+
+    def _conf_record( self, opt, value ):
+        ## skip conf,force,launch
+        if re.match( '^--(conf|force|launch).*$', opt ):
+            return
+
+        ## remove duplicates (last duplicate wins)
+        for i,arg in enumerate( Option.conf_args ):
+            if opt == arg[0]:
+                del Option.conf_args[i]
+                break
+
+        if value:
+            Option.conf_args.append( [opt,'%s=%s' % (opt,value)] )
+        else:
+            Option.conf_args.append( [opt,'%s' % (opt)] )
+
+    def take_action( self, action, dest, opt, value, values, parser ):
+        self._conf_record( opt, value )
+        return optparse.Option.take_action( self, action, dest, opt, value, values, parser )
+
+def createCLI():
+    cli = OptionParser( 'usage: %prog [OPTIONS...] [TARGETS...]' )
+    cli.option_class = Option
+
+    cli.description = ''
+    cli.description += 'Configure %s build system.' % (project.name)
+
+    ## add hidden options
+    cli.add_option( '--conf-method', default='terminal', action='store', help=optparse.SUPPRESS_HELP )
+    cli.add_option( '--force', default=False, action='store_true', help='overwrite existing build config' )
+    cli.add_option( '--verbose', default=False, action='store_true', help='increase verbosity' )
+
+    ## add install options
+    grp = OptionGroup( cli, 'Directory Locations' )
+    h = IfHost( 'specify sysroot (e.g. for Leopard builds from Snow Leapard)', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--sysroot', default=None, action='store', metavar='DIR',
+        help=h )
+    grp.add_option( '--src', default=cfg.src_dir, action='store', metavar='DIR',
+        help='specify top-level source dir [%s]' % (cfg.src_dir) )
+    grp.add_option( '--build', default=cfg.build_dir, action='store', metavar='DIR',
+        help='specify build scratch/output dir [%s]' % (cfg.build_dir) )
+    grp.add_option( '--prefix', default=cfg.prefix_dir, action='store', metavar='DIR',
+        help='specify install dir for products [%s]' % (cfg.prefix_dir) )
+    cli.add_option_group( grp )
+
+    ## add feature options
+    grp = OptionGroup( cli, 'Feature Options' )
+
+    h = IfHost( 'enable assembly code in non-contrib modules', 'NOMATCH*-*-darwin*', 'NOMATCH*-*-linux*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--enable-asm', default=False, action='store_true', help=h )
+
+    h = IfHost( 'disable GTK GUI', '*-*-linux*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--disable-gtk', default=False, action='store_true', help=h )
+    h = IfHost( 'enable GTK GUI (mingw)', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--enable-gtk-mingw', default=False, action='store_true', help=h )
+
+    h = IfHost( 'disable Xcode', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--disable-xcode', default=False, action='store_true', help=h )
+
+    cli.add_option_group( grp )
+
+    ## add launch options
+    grp = OptionGroup( cli, 'Launch Options' )
+    grp.add_option( '--launch', default=False, action='store_true',
+        help='launch build, capture log and wait for completion' )
+    grp.add_option( '--launch-jobs', default=1, action='store', metavar='N', type='int',
+        help='allow N jobs at once; 0 to match CPU count [1]' )
+    grp.add_option( '--launch-args', default=None, action='store', metavar='ARGS',
+        help='specify additional ARGS for launch command' )
+    grp.add_option( '--launch-quiet', default=False, action='store_true',
+        help='do not echo build output while waiting' )
+    cli.add_option_group( grp )
+
+    ## add compile options
+    grp = OptionGroup( cli, 'Compiler Options' )
+    debugMode.cli_add_option( grp, '--debug' )
+    optimizeMode.cli_add_option( grp, '--optimize' )
+    arch.mode.cli_add_option( grp, '--arch' )
+    grp.add_option( '--cross', default=None, action='store', metavar='SPEC',
+        help='specify GCC cross-compilation spec' )
+    h = IfHost( 'Min OS X Version', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value
+    grp.add_option( '--minver', default=None, action='store', metavar='VER',
+        help=h )
+    cli.add_option_group( grp )
+
+    ## add tool locations
+    grp = OptionGroup( cli, 'Tool Basenames and Locations' )
+    for tool in ToolProbe.tools:
+        tool.cli_add_option( grp )
+    cli.add_option_group( grp )
+
+    ## add tool modes
+    grp = OptionGroup( cli, 'Tool Options' )
+    for select in SelectTool.selects:
+        select.cli_add_option( grp )
+    cli.add_option_group( grp )
+    return cli
+
+###############################################################################
+##
+## launcher - used for QuickStart method; launch; build and capture log.
+##
+class Launcher:
+    def __init__( self, targets ):
+        # open build logfile
+        self._file = cfg.open( 'log/build.txt', 'w' )
+
+        cmd = '%s -j%d' % (Tools.gmake.pathname,core.jobs)
+        if options.launch_args:
+            cmd += ' ' + options.launch_args
+        if len(targets):
+            cmd += ' ' + ' '.join(targets)
+
+        ## record begin
+        timeBegin = time.time()
+        self.infof( 'time begin: %s\n', time.asctime() )
+        self.infof( 'launch: %s\n', cmd )
+        if options.launch_quiet:
+            stdout.write( 'building to %s ...\n' % (os.path.abspath( cfg.build_final )))
+        else:
+            stdout.write( '%s\n' % ('-' * 79) )
+
+        ## launch/pipe
+        try:
+            pipe = subprocess.Popen( cmd, shell=True, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
+        except Exception, x:
+            cfg.errln( 'launch failure: %s', x )
+        for line in pipe.stdout:
+            self.echof( '%s', line )
+        pipe.wait()
+
+        ## record end
+        timeEnd = time.time()
+        elapsed = timeEnd - timeBegin
+
+        if pipe.returncode:
+            result = 'FAILURE (code %d)' % pipe.returncode
+        else:
+            result = 'SUCCESS'
+
+        ## present duration in decent format
+        seconds = elapsed
+        hours = int(seconds / 3600)
+        seconds -= hours * 3600
+        minutes = int(seconds / 60)
+        seconds -= minutes * 60
+
+        segs = []
+        duration = ''
+
+        if hours == 1:
+            segs.append( '%d hour' % hours )
+        elif hours > 1:
+            segs.append( '%d hours' % hours )
+
+        if len(segs) or minutes == 1:
+            segs.append( '%d minute' % minutes )
+        elif len(segs) or  minutes > 1:
+            segs.append( '%d minutes' % minutes )
+
+        if seconds == 1:
+            segs.append( '%d second' % seconds )
+        else:
+            segs.append( '%d seconds' % seconds )
+
+        if not options.launch_quiet:
+            stdout.write( '%s\n' % ('-' * 79) )
+        self.infof( 'time end: %s\n', time.asctime() )
+        self.infof( 'duration: %s (%.2fs)\n', ', '.join(segs), elapsed )
+        self.infof( 'result: %s\n', result )
+
+        ## cleanup
+        self._file.close()
+
+    def echof( self, format, *args ):
+        line = format % args
+        self._file.write( line )
+        if not options.launch_quiet:
+            stdout.write( '  : %s' % line )
+            stdout.flush()
+
+    def infof( self, format, *args ):
+        line = format % args
+        self._file.write( line )
+        cfg.infof( '%s', line )
+
+###############################################################################
+##
+## main program
+##
+try:
+    ## we need to pre-check argv for -h or --help or --verbose to deal with
+    ## initializing Configure correctly.
+    verbose = Configure.OUT_INFO
+    for arg in sys.argv:
+        if arg == '-h' or arg == '--help':
+            verbose = Configure.OUT_QUIET
+            break
+        if arg == '--verbose':
+            verbose = Configure.OUT_VERBOSE
+
+    ## create main objects; actions/probes run() is delayed.
+    ## if any actions must be run earlier (eg: for configure --help purposes)
+    ## then run() must be invoked earlier. subequent run() invocations
+    ## are ignored.
+    cfg   = Configure( verbose )
+    host  = HostTupleProbe(); host.run()
+
+    cfg.prefix_dir = ForHost( '/usr/local', ['/Applications','*-*-darwin*'] ).value
+
+    build = BuildAction()
+    arch  = ArchAction(); arch.run()
+
+    ## create remaining main objects
+    core    = CoreProbe()
+    repo    = RepoProbe()
+    project = Project()
+
+    ## create tools in a scope
+    class Tools:
+        ar    = ToolProbe( 'AR.exe',    'ar' )
+        cp    = ToolProbe( 'CP.exe',    'cp' )
+        curl  = ToolProbe( 'CURL.exe',  'curl', abort=False )
+        gcc   = ToolProbe( 'GCC.gcc',   'gcc', IfHost( 'gcc-4', '*-*-cygwin*' ))
+
+        if host.match( '*-*-darwin*' ):
+            gmake = ToolProbe( 'GMAKE.exe', 'make', 'gmake' )
+        else:
+            gmake = ToolProbe( 'GMAKE.exe', 'gmake', 'make' )
+
+        m4     = ToolProbe( 'M4.exe',     'm4' )
+        mkdir  = ToolProbe( 'MKDIR.exe',  'mkdir' )
+        patch  = ToolProbe( 'PATCH.exe',  'gpatch', 'patch' )
+        rm     = ToolProbe( 'RM.exe',     'rm' )
+        ranlib = ToolProbe( 'RANLIB.exe', 'ranlib' )
+        strip  = ToolProbe( 'STRIP.exe',  'strip' )
+        tar    = ToolProbe( 'TAR.exe',    'gtar', 'tar' )
+        wget   = ToolProbe( 'WGET.exe',   'wget', abort=False )
+        yasm   = ToolProbe( 'YASM.exe',   'yasm', abort=False )
+
+        xcodebuild = ToolProbe( 'XCODEBUILD.exe', 'xcodebuild', abort=False )
+        lipo       = ToolProbe( 'LIPO.exe',       'lipo', abort=False )
+
+        fetch = SelectTool( 'FETCH.select', 'fetch', ['wget',wget], ['curl',curl] )
+
+    ## run tool probes
+    for tool in ToolProbe.tools:
+        tool.run()
+    for select in SelectTool.selects:
+        select.run()
+
+    debugMode = SelectMode( 'debug', ('none','none'), ('min','min'), ('std','std'), ('max','max') )
+    optimizeMode = SelectMode( 'optimize', ('none','none'), ('speed','speed'), ('size','size'), default='speed' )
+
+    ## create CLI and parse
+    cli = createCLI()
+    (options,args) = cli.parse_args()
+
+    ## update cfg with cli directory locations
+    cfg.update_cli( options )
+
+    ## prepare list of targets and NAME=VALUE args to pass to make
+    targets = []
+    exports = []
+    rx_exports = re.compile( '([^=]+)=(.*)' )
+    for arg in args:
+        m = rx_exports.match( arg )
+        if m:
+            exports.append( m.groups() )
+        else:
+            targets.append( arg )
+
+    ## re-run tools with cross-compilation needs
+    if options.cross:
+        for tool in ( Tools.ar, Tools.gcc, Tools.ranlib, Tools.strip ):
+            tool.__init__( tool.var, '%s-%s' % (options.cross,tool.name), **tool.kwargs )
+            tool.run()
+
+    ## run delayed actions
+    for action in Action.actions:
+        action.run()
+
+    ## cfg hook before doc prep
+    cfg.doc_ready()
+
+    ## create document object
+    doc = ConfigDocument()
+    doc.addComment( 'generated by configure on %s', time.strftime( '%c' ))
+
+    ## add configure line for reconfigure purposes
+    doc.addBlank()
+    args = []
+    for arg in Option.conf_args:
+        args.append( arg[1] )
+    doc.add( 'CONF.args', ' '.join( args ))
+
+    doc.addBlank()
+    doc.add( 'HB.title',       project.title )
+    doc.add( 'HB.name',        project.name )
+    doc.add( 'HB.name.lower',  project.name_lower )
+    doc.add( 'HB.name.upper',  project.name_upper )
+    doc.add( 'HB.acro.lower',  project.acro_lower )
+    doc.add( 'HB.acro.upper',  project.acro_upper )
+
+    doc.add( 'HB.url.website',    project.url_website )
+    doc.add( 'HB.url.community',  project.url_community )
+    doc.add( 'HB.url.irc',        project.url_irc )
+    doc.add( 'HB.url.appcast',    project.url_appcast )
+    doc.add( 'HB.url.appnote',    project.url_appnote )
+
+    doc.add( 'HB.version.major',  project.vmajor )
+    doc.add( 'HB.version.minor',  project.vminor )
+    doc.add( 'HB.version.point',  project.vpoint )
+    doc.add( 'HB.version',        project.version )
+    doc.add( 'HB.version.hex',    '%04x%02x%02x%08x' % (project.vmajor,project.vminor,project.vpoint,repo.rev) )
+
+    doc.add( 'HB.build', project.build )
+
+    doc.add( 'HB.repo.url',       repo.url )
+    doc.add( 'HB.repo.root',      repo.root )
+    doc.add( 'HB.repo.branch',    repo.branch )
+    doc.add( 'HB.repo.uuid',      repo.uuid )
+    doc.add( 'HB.repo.rev',       repo.rev )
+    doc.add( 'HB.repo.date',      repo.date )
+    doc.add( 'HB.repo.official',  repo.official )
+    doc.add( 'HB.repo.type',      repo.type )
+
+    doc.addBlank()
+    doc.add( 'HOST.spec',    host.spec )
+    doc.add( 'HOST.machine', host.machine )
+    doc.add( 'HOST.vendor',  host.vendor )
+    doc.add( 'HOST.system',  host.system )
+    doc.add( 'HOST.systemf', host.systemf )
+    doc.add( 'HOST.release', host.release )
+    doc.add( 'HOST.extra',   host.extra )
+    doc.add( 'HOST.title',   '%s %s' % (host.systemf,arch.mode.default) )
+    doc.add( 'HOST.ncpu',    core.count )
+
+    doc.addBlank()
+    doc.add( 'BUILD.spec',    build.spec )
+    doc.add( 'BUILD.machine', build.machine )
+    doc.add( 'BUILD.vendor',  build.vendor )
+    doc.add( 'BUILD.system',  build.system )
+    doc.add( 'BUILD.systemf', build.systemf )
+    doc.add( 'BUILD.release', build.release )
+    doc.add( 'BUILD.extra',   build.extra )
+    doc.add( 'BUILD.title',   build.title )
+    doc.add( 'BUILD.ncpu',    core.count )
+    doc.add( 'BUILD.jobs',    core.jobs )
+
+    doc.add( 'BUILD.cross',        int(options.cross != None or arch.mode.mode != arch.mode.default) )
+    if options.cross:
+        doc.add( 'BUILD.cross.prefix', '%s-' % (options.cross) )
+    else:
+        doc.add( 'BUILD.cross.prefix', '' )
+
+    doc.add( 'BUILD.method', 'terminal' )
+    doc.add( 'BUILD.date',   time.strftime('%c') )
+    doc.add( 'BUILD.arch',   arch.mode.mode )
+
+    doc.addBlank()
+    doc.add( 'CONF.method', options.conf_method )
+
+    doc.addBlank()
+    doc.add( 'SRC',     cfg.src_final )
+    doc.add( 'SRC/',    cfg.src_final + os.sep )
+    doc.add( 'BUILD',   cfg.build_final )
+    doc.add( 'BUILD/',  cfg.build_final + os.sep )
+    doc.add( 'PREFIX',  cfg.prefix_final )
+    doc.add( 'PREFIX/', cfg.prefix_final + os.sep )
+    
+    doc.addBlank()
+    doc.add( 'FEATURE.asm',   'disabled' )
+    doc.add( 'FEATURE.gtk',   int( not options.disable_gtk ))
+    doc.add( 'FEATURE.gtk.mingw',   int( options.enable_gtk_mingw ))
+    doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) ))
+
+    if not Tools.xcodebuild.fail and not options.disable_xcode:
+        doc.addBlank()
+        doc.add( 'XCODE.external.src',    cfg.xcode_x_src )
+        doc.add( 'XCODE.external.build',  cfg.xcode_x_build )
+        doc.add( 'XCODE.external.prefix', cfg.xcode_x_prefix )
+
+    doc.addMake( '' )
+    doc.addMake( '## include definitions' )
+    doc.addMake( 'include $(SRC/)make/include/main.defs' )
+
+    doc.addBlank()
+    for tool in ToolProbe.tools:
+        tool.doc_add( doc )
+
+    doc.addBlank()
+    for select in SelectTool.selects:
+        select.doc_add( doc )
+
+    doc.addBlank()
+    if build.match( '*-*-darwin*' ):
+        doc.add( 'GCC.archs', arch.mode.mode )
+        doc.add( 'GCC.sysroot', cfg.sysroot_dir )
+        doc.add( 'GCC.minver', cfg.minver )
+    else:
+        doc.add( 'GCC.archs', '' )
+        doc.add( 'GCC.sysroot', '' )
+        doc.add( 'GCC.minver', '' )
+    doc.add( 'GCC.ldsysroot', '$(GCC.sysroot)' )
+    doc.add( 'GCC.ldminver', '$(GCC.minver)' )
+    doc.add( 'GCC.g', debugMode.mode )
+    doc.add( 'GCC.O', optimizeMode.mode )
+
+    if options.enable_asm and not Tools.yasm.fail:
+        asm = ''
+        if build.match( 'i?86-*' ):
+            asm = 'x86'
+            doc.add( 'LIBHB.GCC.D', 'HAVE_MMX', append=True )
+            doc.add( 'LIBHB.YASM.D', 'ARCH_X86', append=True )
+            if build.match( '*-*-darwin*' ):
+                doc.add( 'LIBHB.YASM.f', 'macho32' )
+            else:
+                doc.add( 'LIBHB.YASM.f', 'elf32' )
+            doc.add( 'LIBHB.YASM.m', 'x86' )
+        elif build.match( 'x86_64-*' ):
+            asm = 'x86'
+            doc.add( 'LIBHB.GCC.D', 'HAVE_MMX ARCH_X86_64', append=True )
+            if build.match( '*-*-darwin*' ):
+                doc.add( 'LIBHB.YASM.D', 'ARCH_X86_64 PIC', append=True )
+                doc.add( 'LIBHB.YASM.f', 'macho64' )
+            else:
+                doc.add( 'LIBHB.YASM.D', 'ARCH_X86_64', append=True )
+                doc.add( 'LIBHB.YASM.f', 'elf64' )
+            doc.add( 'LIBHB.YASM.m', 'amd64' )
+        doc.update( 'FEATURE.asm', asm )
+
+    ## add exports to make
+    if len(exports):
+        doc.addBlank()
+        doc.addComment( 'overrides via VARIABLE=VALUE on command-line' )
+        for nv in exports:
+            doc.add( nv[0], nv[1] )
+
+    doc.addMake( '' )
+    doc.addMake( '## include custom definitions' )
+    doc.addMake( '-include $(SRC/)custom.defs' )
+    doc.addMake( '-include $(BUILD/)GNUmakefile.custom.defs' )
+
+    doc.addMake( '' )
+    doc.addMake( '## include rules' )
+    doc.addMake( 'include $(SRC/)make/include/main.rules' )
+    doc.addMake( '-include $(SRC/)custom.rules' )
+    doc.addMake( '-include $(BUILD/)GNUmakefile.custom.rules' )
+
+    ## chdir
+    cfg.chdir()
+
+    ## perform
+    doc.write( 'make' )
+    doc.write( 'm4' )
+    if options.launch:
+        Launcher( targets )
+
+    cfg.record_log()
+
+    if os.path.normpath( cfg.build_dir ) == os.curdir:
+        nocd = True
+    else:
+        nocd = False
+
+    stdout.write( '%s\n' % ('-' * 79) )
+    if options.launch:
+        stdout.write( 'Build is finished!\n' )
+        if nocd:
+            stdout.write( 'You may now examine the output.\n' )
+        else:
+            stdout.write( 'You may now cd into %s and examine the output.\n' % (cfg.build_dir) )
+    else:
+        stdout.write( 'Build is configured!\n' )
+        if nocd:
+            stdout.write( 'You may now run make (%s).\n' % (Tools.gmake.pathname) )
+        else:
+            stdout.write( 'You may now cd into %s and run make (%s).\n' % (cfg.build_dir,Tools.gmake.pathname) )
+
+except AbortError, x:
+    stderr.write( 'ERROR: %s\n' % (x) )
+    try:
+        cfg.record_log()
+    except:
+        pass        
+    sys.exit( 1 )    
+
+sys.exit( 0 )
diff --git a/make/include/base.defs b/make/include/base.defs
new file mode 100644 (file)
index 0000000..4e6da0e
--- /dev/null
@@ -0,0 +1,35 @@
+## Define module metadata.
+## It is mandatory for every module to use this template.
+##
+## $(1) module name (uppercase)
+## $(2) module name (lowercase)
+## $(3) list of prerequisite modules (uppercase)
+##
+define import.MODULE.defs
+    ## indicates module is defined; useful for conditionals
+    $(1).enabled = 1
+
+    ## module name (lowercase)
+    $(1).name = $(2)
+
+    ## list of prerequisite modules (uppercase)
+    $(1).prerequisites = $(3)
+
+    ## add to global list of modules
+    MODULES.NAMES += $(1)
+    MODULES.names += $(2)
+endef
+
+##
+## $(1) module name (uppercase)
+##
+define import.MODULE.rules
+.PHONY: $($(1).name).build $($(1).name).clean 
+
+$($(1).name).report:
+       @$(MAKE) report.true REPORT=module REPORT.module=$(1)
+
+## aggregate
+report.modules:: $($(1).name).report
+
+endef
diff --git a/make/include/base.rules b/make/include/base.rules
new file mode 100644 (file)
index 0000000..4d9e5ce
--- /dev/null
@@ -0,0 +1,41 @@
+.PHONY: report.main report.gcc report.modules report.var report.true report.help
+.PHONY: shell.run
+
+report.modules::
+
+report.main:
+       @$(MAKE) report.true REPORT=main
+
+report.gcc:
+       @$(MAKE) report.true REPORT=gcc
+
+report.var:
+       @$(MAKE) report.true REPORT=var
+
+## needed for nested make (which drives each report)
+report.true:
+       @true
+
+## linefeed is important
+define REPORT.help.item.global
+       @echo 'report.$(1)' | awk '{ printf("  %-21s  $(REPORT.help.$(1))\n", $$0) }'
+
+endef
+define REPORT.help.item.module
+       @echo '$($(1).name).report' | awk '{ printf("  %-21s  $(1)-scoped vars\n", $$0) }'
+
+endef
+
+REPORT.help.main = global general vars
+REPORT.help.gcc  = global gcc vars (inherited by module GCC)
+REPORT.help.var  = usage: make report.var name=VARNAME
+
+report.help:
+       @echo "  AVAILABLE MAKEFILE VARS REPORTS"
+       @echo "  ----------------------------------------------------------------"
+       $(foreach n,main gcc var,$(call REPORT.help.item.global,$n))
+       $(foreach n,$(MODULES.NAMES),$(call REPORT.help.item.module,$n))
+
+## diagnostic aid when troubleshooting build issues
+shell.run:
+       $(command)
diff --git a/make/include/contrib.defs b/make/include/contrib.defs
new file mode 100644 (file)
index 0000000..fcff273
--- /dev/null
@@ -0,0 +1,312 @@
+CONTRIB.build/    = $(BUILD/)contrib/
+CONTRIB.download/ = $(SRC/)download/
+CONTRIB.host      = $(if $(filter 1,$(BUILD.cross)),$(BUILD.spec))
+
+###############################################################################
+
+##
+## $(1) = module name (uppercase)
+##
+define import.CONTRIB.defs
+    ##
+    ## import gcc/g++ support mainly so we can force contrib choice of
+    ## gcc executable, and debug/optimization flags.
+    ##
+    $$(eval $$(call import.GCC,$(1)))
+
+    ##
+    ## common values useful across targets
+    ##
+    $(1).src/   = $$(SRC/)contrib/$($(1).name)/
+    $(1).build/ = $$(CONTRIB.build/)$($(1).name)/
+    $(1).deps   = $$(foreach n,$($(1).prerequisites),$$($$n.INSTALL.target))
+
+    ##
+    ## target: fetch
+    ##
+    $(1).FETCH.tar    = $$(CONTRIB.download/)$$(notdir $$($(1).FETCH.url))
+    $(1).FETCH.url    = FETCH_IS_UNDEFINED
+    $(1).FETCH.target = $$($(1).FETCH.tar)
+    define $(1).FETCH
+        $$(call FETCH,$$@,$$($(1).FETCH.url))
+    endef
+
+    ##
+    ## target: extract
+    ##
+    $(1).EXTRACT.tarbase = $$(strip $$(foreach x,tar.bz2 tar.gz,$$(patsubst %.$$(x),%,$$(filter %.$$(x),$$(notdir $$($(1).FETCH.url))))))
+    $(1).EXTRACT.dir/    = $$($(1).build/)$$($(1).EXTRACT.tarbase)/
+    $(1).EXTRACT.target  = $$($(1).build/).stamp.extract
+    define $(1).EXTRACT
+        $$(RM.exe) -fr $$($(1).EXTRACT.dir/)
+        $$(TAR.exe) xfC $$($(1).FETCH.tar) $$($(1).build/)
+        $$(TOUCH.exe) $$@
+    endef
+
+    ##
+    ## target: patch
+    ##
+    $(1).PATCH.srcs = $$(wildcard \
+        $$($(1).src/)A??-*.patch \
+        $$($(1).src/)P??-$$(BUILD.system)*.patch )
+
+    # extra line feed is required
+    define $(1).PATCH.item
+        $$(PATCH.exe) -t -N -p1 -d $$(1) < $$(2)
+
+    endef
+
+    $(1).PATCH.target = $$($(1).build/).stamp.patch
+    define $(1).PATCH
+        $$(foreach p,$$($(1).PATCH.srcs),$$(call $(1).PATCH.item,$$($(1).EXTRACT.dir/),$$(p)))
+        $$(TOUCH.exe) $$@
+    endef
+
+    ##
+    ## target: configure
+    ##
+    $(1).CONFIGURE.sete       = set -e;
+    $(1).CONFIGURE.dir        = $$($(1).EXTRACT.dir/)
+    $(1).CONFIGURE.bootstrap  =
+    $(1).CONFIGURE.exe        = ./configure
+    $(1).CONFIGURE.host       = $$(CONTRIB.host)
+    $(1).CONFIGURE.prefix     = $$(call fn.ABSOLUTE,$$(CONTRIB.build/))
+    $(1).CONFIGURE.deps       = --disable-dependency-tracking
+    $(1).CONFIGURE.shared     = --disable-shared
+    $(1).CONFIGURE.static     = --enable-static
+    $(1).CONFIGURE.extra      =
+
+    $(1).CONFIGURE.args.dir    = cd $$(1);
+    $(1).CONFIGURE.args.host   = --host=$$(1)
+    $(1).CONFIGURE.args.prefix = --prefix=$$(1)
+
+    $(1).CONFIGURE.args = !sete @dir !bootstrap !env !exe @host @prefix !deps !shared !static !extra
+
+    $(1).CONFIGURE.env.CC       = CC=$$($(1).GCC.gcc)
+    $(1).CONFIGURE.env.CFLAGS   = CFLAGS="$$(call fn.ARGS,$(1).GCC,*archs *sysroot *minver ?extra)"
+    $(1).CONFIGURE.env.CXX      = CXX=$$($(1).GCC.gxx)
+    $(1).CONFIGURE.env.CXXFLAGS = CXXFLAGS="$$(call fn.ARGS,$(1).GCC,*archs *sysroot *minver ?extra)"
+    $(1).CONFIGURE.env.CPPFLAGS = CPPFLAGS="$$(call fn.ARGS,$(1).GCC,*archs *sysroot *minver ?extra)"
+    $(1).CONFIGURE.env.LDFLAGS  = LDFLAGS="$$(call fn.ARGS,$(1).GCC,*archs *sysroot *minver)"
+
+    $(1).CONFIGURE.env.args = !CC !CFLAGS !CXX !CXXFLAGS !CPPFLAGS !LDFLAGS
+    $(1).CONFIGURE.env = $$(call fn.ARGS,$(1).CONFIGURE.env,$$($(1).CONFIGURE.env.args))
+
+    $(1).CONFIGURE.target = $$($(1).build/).stamp.configure
+    define $(1).CONFIGURE
+        $$(call fn.ARGS,$(1).CONFIGURE,$$($(1).CONFIGURE.args))
+        $$(TOUCH.exe) $$@
+    endef
+
+    ##
+    ## target: build
+    ##
+    $(1).BUILD.make     = $$(MAKE)
+    $(1).BUILD.dir      = $$($(1).EXTRACT.dir/)
+    $(1).BUILD.extra    =
+    $(1).BUILD.ntargets =
+
+    $(1).BUILD.args = !make @dir !extra !ntargets
+    $(1).BUILD.args.dir = -C $$(1)
+
+    $(1).BUILD.target = $$($(1).build/).stamp.build
+    define $(1).BUILD
+        $$(call fn.ARGS,$(1).BUILD,$$($(1).BUILD.args))
+        $$(TOUCH.exe) $$@
+    endef
+
+    ##
+    ## target: install
+    ##
+    $(1).INSTALL.make     = $$(MAKE)
+    $(1).INSTALL.dir      = $$($(1).EXTRACT.dir/)
+    $(1).INSTALL.extra    =
+    $(1).INSTALL.ntargets =
+
+    $(1).INSTALL.args = !make @dir !extra !ntargets
+    $(1).INSTALL.args.dir = -C $$(1) install
+
+    $(1).INSTALL.mkdirs = $$(CONTRIB.build/)lib/ $$(CONTRIB.build/)include/
+    $(1).INSTALL.target = $$($(1).build/).stamp.install
+    define $(1).INSTALL
+        $$(call fn.ARGS,$(1).INSTALL,$$($(1).INSTALL.args))
+        $$(TOUCH.exe) $$@
+    endef
+
+    ##
+    ## target: uninstall
+    ##
+    $(1).UNINSTALL.make     = $$(MAKE)
+    $(1).UNINSTALL.dir      = $$($(1).EXTRACT.dir/)
+    $(1).UNINSTALL.extra    =
+    $(1).UNINSTALL.ntargets = uninstall
+
+    $(1).UNINSTALL.args = !make @dir !extra !ntargets
+    $(1).UNINSTALL.args.dir = -C $$(1)
+
+    define $(1).UNINSTALL
+        $$(call fn.ARGS,$(1).UNINSTALL,$$($(1).UNINSTALL.args))
+        $$(RM.exe) -f $$($(1).INSTALL.target)
+    endef
+
+    ##
+    ## target: clean
+    ##
+    $(1).CLEAN.make     = $$(MAKE)
+    $(1).CLEAN.dir      = $$($(1).EXTRACT.dir/)
+    $(1).CLEAN.extra    =
+    $(1).CLEAN.ntargets = clean
+
+    $(1).CLEAN.args = !make @dir !extra !ntargets
+    $(1).CLEAN.args.dir = -C $$(1)
+
+    define $(1).CLEAN
+        $$(call fn.ARGS,$(1).CLEAN,$$($(1).CLEAN.args))
+        $$(RM.exe) -f $$($(1).BUILD.target)
+    endef
+
+    ##
+    ## other values used to aid prerequisite dirs and cleanup
+    ##
+    $(1).out += $$($(1).build/)
+    $(1).out += $$($(1).FETCH.target)
+    $(1).out += $$($(1).EXTRACT.target)
+    $(1).out += $$($(1).PATCH.target)
+    $(1).out += $$($(1).CONFIGURE.target)
+    $(1).out += $$($(1).BUILD.target)
+    $(1).out += $$($(1).INSTALL.mkdirs)
+    $(1).out += $$($(1).INSTALL.target)
+
+    BUILD.out += $$($(1).out)
+endef
+
+###############################################################################
+
+##
+## $(1) = module name
+##
+define import.CONTRIB.rules
+
+##
+## target: fetch
+##
+$($(1).name).fetch: $$($(1).FETCH.target)
+
+$$($(1).FETCH.target): | $$(dir $$($(1).FETCH.target))
+       $$($(1).FETCH)
+
+##
+## target: extract
+## must touch dir after extraction because old timestamp is restored via tar.
+##
+$($(1).name).extract: $$($(1).EXTRACT.target)
+
+$$($(1).EXTRACT.target): | $$(dir $$($(1).EXTRACT.target))
+$$($(1).EXTRACT.target): $$($(1).FETCH.target)
+       $$($(1).EXTRACT)
+
+$($(1).name).extract.touch:
+       $$(TOUCH.exe) $$($(1).EXTRACT.target)
+
+$($(1).name).extract.untouch:
+       $$(RM.exe) -f $$($(1).EXTRACT.target)
+
+##
+## target: patch
+##
+$($(1).name).patch: $$($(1).PATCH.target)
+
+$$($(1).PATCH.target): | $$(dir $$($(1).PATCH.target))
+$$($(1).PATCH.target): $$($(1).EXTRACT.target)
+       $$($(1).PATCH)
+
+$($(1).name).patch.touch:
+       $$(TOUCH.exe) $$($(1).PATCH.target)
+
+$($(1).name).patch.untouch:
+       $$(RM.exe) -f $$($(1).PATCH.target)
+
+##
+## target: configure
+##
+$($(1).name).configure: $$($(1).CONFIGURE.target)
+
+$$($(1).CONFIGURE.target): | $$(dir $$($(1).CONFIGURE.target))
+$$($(1).CONFIGURE.target): $$($(1).deps)
+$$($(1).CONFIGURE.target): $$($(1).PATCH.target)
+       $$($(1).CONFIGURE)
+
+$($(1).name).configure.touch:
+       $$(TOUCH.exe) $$($(1).CONFIGURE.target)
+
+$($(1).name).configure.untouch:
+       $$(RM.exe) -f $$($(1).CONFIGURE.target)
+
+##
+## target: build
+##
+$($(1).name).build: $$($(1).BUILD.target)
+
+$$($(1).BUILD.target): | $$(dir $$($(1).BUILD.target))
+$$($(1).BUILD.target): $$($(1).CONFIGURE.target)
+       -$$($(1).CLEAN)
+       +$$($(1).BUILD)
+
+$($(1).name).build.touch:
+       $$(TOUCH.exe) $$($(1).BUILD.target)
+
+$($(1).name).build.untouch:
+       $$(RM.exe) -f $$($(1).BUILD.target)
+
+##
+## target: install
+##
+$($(1).name).install: $$($(1).INSTALL.target)
+
+$$($(1).INSTALL.target): | $$(dir $$($(1).INSTALL.target)) $$($(1).INSTALL.mkdirs)
+$$($(1).INSTALL.target): $$($(1).BUILD.target)
+       $$($(1).INSTALL)
+
+$($(1).name).install.touch:
+       $$(TOUCH.exe) $$($(1).INSTALL.target)
+
+$($(1).name).install.untouch:
+       $$(RM.exe) -f $$($(1).INSTALL.target)
+
+##
+## target: uninstall
+##
+$($(1).name).uninstall:
+       -$$($(1).UNINSTALL)
+
+##
+## target: clean
+##
+$($(1).name).clean:
+       -$$($(1).CLEAN)
+
+##
+## target: xclean
+##
+$($(1).name).xclean: $($(1).name).uninstall
+       $$(RM.exe) -fr $$($(1).build/)
+
+##
+## alias: module name is same as build
+##
+$($(1).name): $($(1).name).build
+
+##
+## participate with global convenience targets
+##
+contrib.fetch: $($(1).name).fetch
+contrib.extract: $($(1).name).extract
+contrib.patch: $($(1).name).patch
+contrib.configure: $($(1).name).configure
+contrib.build: $($(1).name).build
+contrib.install: $($(1).name).install
+contrib.uninstall: $($(1).name).uninstall
+contrib.clean: $($(1).name).clean
+contrib.xclean: $($(1).name).xclean
+
+endef
diff --git a/make/include/function.defs b/make/include/function.defs
new file mode 100644 (file)
index 0000000..5bf5aaa
--- /dev/null
@@ -0,0 +1,19 @@
+fn.ERROR1 = ERROR: $(1)
+fn.ERROR2 = ERROR: $(1): $(2)
+
+fn.HEADER = @echo "$(1): $(2)"
+fn.DIVIDER = @echo "======================================================================"
+
+fn.ABSOLUTE = $(if $(filter /%,$(1)),$(1),$(subst /./,/,$(CURDIR)/$(1)))
+
+fn.ARGS = $(strip $(foreach a,$(2), \
+    $($(1).$(patsubst !%,%,$(filter !%,$(a)))) \
+    $(foreach x,$(patsubst ?%,%,$(filter ?%,$(a))),$(if $(filter 1,$($(1).$(x))),$($(1).args.$(x)))) \
+    $(foreach x,$(patsubst .%,%,$(filter .%,$(a))),$($(1).args.$(x).$($(1).$(x)))) \
+    $(foreach x,$(patsubst @%,%,$(filter @%,$(a))),$(if $($(1).$(x)),$(call $(1).args.$(x),$($(1).$(x))))) \
+    $(foreach x,$(patsubst *%,%,$(filter *%,$(a))),$(foreach i,$($(1).$(x)),$(call $(1).args.$(x),$(i)))) \
+    ))
+
+fn.VARS = $(foreach v,$($(1).vars),$(v)="$($(1).vars.$(v))")
+
+fn.TARGET = $(TARGET.$(2).prefix)$(1)$(TARGET.$(2).suffix)$(TARGET.$(2).ext)
diff --git a/make/include/gcc.defs b/make/include/gcc.defs
new file mode 100644 (file)
index 0000000..a9523dd
--- /dev/null
@@ -0,0 +1,202 @@
+GCC.gcc = gcc
+GCC.gxx = $(dir $(GCC.gcc))$(subst gcc,g++,$(notdir $(GCC.gcc)))
+
+GCC.strip   = $$(if $$(filter none,$$(GCC.g)),1)
+GCC.dylib   = 1
+GCC.pipe    = 1
+GCC.ML      = 1
+GCC.H       = 0
+GCC.W       = all
+GCC.archs   =
+GCC.sysroot =
+GCC.ldsysroot =
+GCC.minver  =
+GCC.ldminver=
+GCC.vis     = 0
+GCC.pic     = 0
+GCC.g       = none
+GCC.O       = none
+GCC.D       =
+GCC.I       =
+GCC.muldefs = 0
+GCC.start   = 0
+GCC.a       =
+GCC.F       =
+GCC.f       =
+GCC.L       =
+GCC.l       =
+GCC.end     = 0
+
+GCC.extra         = 1
+GCC.extra.h_o     = 1
+GCC.extra.c_o     = 1
+GCC.extra.dylib   = 1
+GCC.extra.exe     = 1
+GCC.extra.hpp_o   = 1
+GCC.extra.cpp_o   = 1
+GCC.extra.dylib++ = 1
+GCC.extra.exe++   = 1
+
+GCC.args.pipe      = -pipe
+GCC.args.strip     = -Wl,-S
+GCC.args.dylib     = -dynamiclib
+GCC.args.ML        = -fmessage-length=0
+GCC.args.H         = -H
+GCC.args.W         = -W$(1)
+GCC.args.archs     = -arch $(1)
+GCC.args.sysroot   = --sysroot=$(1)
+GCC.args.ldsysroot = -syslibroot $(1)
+GCC.args.minver    = -mmacosx-version-min=$(1)
+GCC.args.ldminver  = -macosx_version_min $(1)
+GCC.args.vis       = -fvisibility=hidden
+GCC.args.pic       = -fPIC
+GCC.args.g.none    = -g0
+GCC.args.g.min     = -gdwarf-2 -g1
+GCC.args.g.std     = -gdwarf-2
+GCC.args.g.max     = -gdwarf-2 -g3
+GCC.args.O.none    = -O0
+GCC.args.O.size    = -Os
+GCC.args.O.speed   = -O3
+GCC.args.D         = -D$(1)
+GCC.args.I         = -I$(1)
+GCC.args.muldefs   = -Wl,--allow-multiple-definition
+GCC.args.start     = -Wl,--start-group
+GCC.args.F         = -F$(1)
+GCC.args.f         = -framework $(1)
+GCC.args.L         = -L$(1)
+GCC.args.l         = -l$(1)
+GCC.args.end       = -Wl,--end-group
+
+GCC.args.extra         =
+GCC.args.extra.h_o     =
+GCC.args.extra.c_o     =
+GCC.args.extra.dylib   =
+GCC.args.extra.exe     =
+GCC.args.extra.hpp_o   =
+GCC.args.extra.cpp_o   =
+GCC.args.extra.dylib++ =
+GCC.args.extra.exe++   =
+
+###############################################################################
+
+define import.GCC
+    $(1).GCC.gcc = $$(GCC.gcc)
+    $(1).GCC.gxx = $$(dir $$($(1).GCC.gcc))$$(subst gcc,g++,$$(notdir $$($(1).GCC.gcc)))
+
+    $(1).GCC.pipe    = $$(GCC.pipe)
+    $(1).GCC.strip   = $$(if $$(filter none,$$($(1).GCC.g)),1)
+    $(1).GCC.dylib   = $$(GCC.dylib)
+    $(1).GCC.ML      = $$(GCC.ML) 
+    $(1).GCC.H       = $$(GCC.H) 
+    $(1).GCC.W       = $$(GCC.W)
+    $(1).GCC.archs   = $$(GCC.archs)
+    $(1).GCC.sysroot = $$(GCC.sysroot)
+    $(1).GCC.ldsysroot = $$(GCC.ldsysroot)
+    $(1).GCC.minver  = $$(GCC.minver)
+    $(1).GCC.ldminver = $$(GCC.ldminver)
+    $(1).GCC.vis     = $$(GCC.vis)
+    $(1).GCC.pic     = $$(GCC.pic)
+    $(1).GCC.g       = $$(GCC.g)
+    $(1).GCC.O       = $$(GCC.O)
+    $(1).GCC.D       = $$(GCC.D)
+    $(1).GCC.I       = $$(GCC.I)
+    $(1).GCC.muldefs = $$(GCC.muldefs)
+    $(1).GCC.start   = $$(GCC.start)
+    $(1).GCC.a       = $$(GCC.a)
+    $(1).GCC.F       = $$(GCC.F)
+    $(1).GCC.f       = $$(GCC.f)
+    $(1).GCC.L       = $$(GCC.L)
+    $(1).GCC.l       = $$(GCC.l)
+    $(1).GCC.end     = $$(GCC.end)
+
+    $(1).GCC.extra         = $$(GCC.extra)
+    $(1).GCC.extra.h_o     = $$(GCC.extra.h_o)
+    $(1).GCC.extra.c_o     = $$(GCC.extra.c_o)
+    $(1).GCC.extra.dylib   = $$(GCC.extra.dylib)
+    $(1).GCC.extra.exe     = $$(GCC.extra.exe)
+    $(1).GCC.extra.hpp_o   = $$(GCC.extra.hpp_o)
+    $(1).GCC.extra.cpp_o   = $$(GCC.extra.cpp_o)
+    $(1).GCC.extra.dylib++ = $$(GCC.extra.dylib++)
+    $(1).GCC.extra.exe++   = $$(GCC.extra.exe++)
+
+    $(1).GCC.args.pipe      = $$(GCC.args.pipe)
+    $(1).GCC.args.strip     = $$(GCC.args.strip)
+    $(1).GCC.args.dylib     = $$(GCC.args.dylib)
+    $(1).GCC.args.ML        = $$(GCC.args.ML)
+    $(1).GCC.args.H         = $$(GCC.args.H)
+    $(1).GCC.args.W         = $$(GCC.args.W)
+    $(1).GCC.args.archs     = $$(GCC.args.archs)
+    $(1).GCC.args.sysroot   = $$(GCC.args.sysroot)
+    $(1).GCC.args.ldsysroot = $$(GCC.args.ldsysroot)
+    $(1).GCC.args.minver    = $$(GCC.args.minver)
+    $(1).GCC.args.ldminver  = $$(GCC.args.ldminver)
+    $(1).GCC.args.vis       = $$(GCC.args.vis)
+    $(1).GCC.args.pic       = $$(GCC.args.pic)
+    $(1).GCC.args.g.none    = $$(GCC.args.g.none)
+    $(1).GCC.args.g.min     = $$(GCC.args.g.min)
+    $(1).GCC.args.g.std     = $$(GCC.args.g.std)
+    $(1).GCC.args.g.max     = $$(GCC.args.g.max)
+    $(1).GCC.args.O.none    = $$(GCC.args.O.none)
+    $(1).GCC.args.O.size    = $$(GCC.args.O.size)
+    $(1).GCC.args.O.speed   = $$(GCC.args.O.speed)
+    $(1).GCC.args.D         = $$(GCC.args.D)
+    $(1).GCC.args.I         = $$(GCC.args.I)
+    $(1).GCC.args.muldefs   = $$(GCC.args.muldefs)
+    $(1).GCC.args.start     = $$(GCC.args.start)
+    $(1).GCC.args.F         = $$(GCC.args.F)
+    $(1).GCC.args.f         = $$(GCC.args.f)
+    $(1).GCC.args.L         = $$(GCC.args.L)
+    $(1).GCC.args.l         = $$(GCC.args.l)
+    $(1).GCC.args.end       = $$(GCC.args.end)
+
+    $(1).GCC.args.extra         = $$(GCC.args.extra)
+    $(1).GCC.args.extra.h_o     = $$(GCC.args.extra.h_o)
+    $(1).GCC.args.extra.c_o     = $$(GCC.args.extra.c_o)
+    $(1).GCC.args.extra.dylib   = $$(GCC.args.extra.dylib)
+    $(1).GCC.args.extra.exe     = $$(GCC.args.extra.exe)
+    $(1).GCC.args.extra.hpp_o   = $$(GCC.args.extra.hpp_o)
+    $(1).GCC.args.extra.cpp_o   = $$(GCC.args.extra.cpp_o)
+    $(1).GCC.args.extra.dylib++ = $$(GCC.args.extra.dylib++)
+    $(1).GCC.args.extra.exe++   = $$(GCC.args.extra.exe++)
+
+    ###########################################################################
+
+    $(1).GCC.c = -c $$(4)
+    $(1).GCC.o = -o $$(3)
+
+    # FUNCTION: C precompiled headers
+    $(1).GCC.H_O.args = !gcc ?pipe ?ML ?H *W *archs *sysroot *minver ?vis ?pic .g .O ?extra ?extra.h_o *D *I !c !o
+    $(1).GCC.H_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.H_O.args),$$(1),$$(2))
+
+    # FUNCTION: C compile source
+    $(1).GCC.C_O.args = !gcc ?pipe ?ML ?H *W *archs *sysroot *minver ?vis ?pic .g .O ?extra ?extra.c_o *D *I !c !o
+    $(1).GCC.C_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.C_O.args),$$(1),$$(2))
+
+    # FUNCTION: C++ precompile headers
+    $(1).GCC.HPP_O.args = !gxx ?pipe ?ML ?H *W *archs *sysroot *minver ?vis ?pic .g .O ?extra ?extra.hpp_o *D *I !c !o
+    $(1).GCC.HPP_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.HPP_O.args),$$(1),$$(2))
+
+    # FUNCTION: C++ compile source
+    $(1).GCC.CPP_O.args = !gxx ?pipe ?ML ?H *W *archs *sysroot *minver ?vis ?pic .g .O ?extra ?extra.cpp_o *D *I !c !o
+    $(1).GCC.CPP_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.CPP_O.args),$$(1),$$(2))
+
+    ###########################################################################
+
+    $(1).GCC.i = $$(4)
+
+    # FUNCTION: C link dynamic-lib
+    $(1).GCC.DYLIB.args = !gcc ?pipe ?strip ?dylib ?extra.dylib ?ML *W *archs *sysroot *minver ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+    $(1).GCC.DYLIB = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.DYLIB.args),$$(1),$$(2))
+
+    # FUNCTION: C link executable
+    $(1).GCC.EXE.args = !gcc ?pipe ?strip ?extra.exe ?ML *W *archs *sysroot *minver ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+    $(1).GCC.EXE = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.EXE.args),$$(1),$$(2))
+
+    # FUNCTION: C++ link dynamic-lib
+    $(1).GCC.DYLIB++.args = !gxx ?pipe ?strip ?dylib ?extra.dylib++ ?ML *W *arch *sysroot *minvers ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+    $(1).GCC.DYLIB++ = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.DYLIB++.args),$$(1),$$(2))
+
+    # FUNCTION: C++ link executable
+    $(1).GCC.EXE++.args = !gxx ?pipe ?strip ?extra.exe++ ?ML *W *archs *sysroot *minver ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+    $(1).GCC.EXE++ = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.EXE++.args),$$(1),$$(2))
+endef
diff --git a/make/include/main.defs b/make/include/main.defs
new file mode 100644 (file)
index 0000000..3228593
--- /dev/null
@@ -0,0 +1,78 @@
+include $(SRC/)make/include/base.defs
+include $(SRC/)make/include/contrib.defs
+include $(SRC/)make/include/function.defs
+include $(SRC/)make/include/gcc.defs
+include $(SRC/)make/include/select.defs
+include $(SRC/)make/include/target.defs
+include $(SRC/)make/include/tool.defs
+
+###############################################################################
+
+MODULES += contrib/a52dec
+
+ifneq (,$(filter $(BUILD.system),cygwin mingw))
+    MODULES += contrib/bzip2
+endif
+
+MODULES += contrib/faac
+MODULES += contrib/faad2
+MODULES += contrib/ffmpeg
+MODULES += contrib/lame
+MODULES += contrib/libdca
+MODULES += contrib/libdvdread
+MODULES += contrib/libdvdnav
+MODULES += contrib/libmkv
+MODULES += contrib/libogg
+MODULES += contrib/libsamplerate
+MODULES += contrib/libtheora
+MODULES += contrib/libvorbis
+MODULES += contrib/mp4v2
+MODULES += contrib/mpeg2dec
+
+ifneq (,$(filter $(BUILD.system),mingw))
+    MODULES += contrib/pthreadw32
+endif
+
+MODULES += contrib/x264
+
+ifneq (,$(filter $(BUILD.system),cygwin mingw))
+    MODULES += contrib/libiconv
+    MODULES += contrib/zlib
+endif
+
+ifneq (,$(filter $(BUILD.system),solaris))
+    MODULES += contrib/libiconv
+endif
+
+## these must come after contrib since some contrib modules are optional
+MODULES += libhb
+
+###############################################################################
+
+ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
+    ## use macosx module when xcode+darwin
+    MODULES += macosx
+else
+    ## default is to build CLI
+    MODULES += test
+endif
+
+ifeq (1-mingw,$(FEATURE.gtk.mingw)-$(BUILD.system))
+    MODULES += gtk
+endif
+
+ifeq (1-linux,$(FEATURE.gtk)-$(BUILD.system))
+    ## build gtk when gtk+linux
+    MODULES += gtk
+endif
+
+###############################################################################
+
+MODULES += doc
+MODULES += pkg
+
+###############################################################################
+
+include $(MODULES:%=$(SRC/)%/module.defs)
+include $(SRC/)make/variant/$(BUILD.system).defs
+-include $(SRC/)make/variant/$(BUILD.system).$(BUILD.machine).defs
diff --git a/make/include/main.rules b/make/include/main.rules
new file mode 100644 (file)
index 0000000..132567c
--- /dev/null
@@ -0,0 +1,57 @@
+.DELETE_ON_ERROR:
+.SUFFIXES:
+
+###############################################################################
+
+## file-wide conditional to use xcode rules if xcode=1 method=terminal
+## xcodemake will set BUILD.method != terminal to prevent infinite recursion
+ifeq (1:terminal,$(FEATURE.xcode):$(BUILD.method))
+    include $(SRC/)macosx/module.xcode
+else
+
+## only included using special report targets
+ifneq (,$(REPORT))
+    include $(SRC/)make/include/report.defs
+endif
+
+###############################################################################
+
+.PHONY: build clean install uninstall xclean doc report
+
+build:
+clean:
+install:
+uninstall:
+xclean: contrib.xclean clean
+doc:
+report:: report.main report.modules
+
+## legacy
+mrproper: xclean
+
+###############################################################################
+
+include $(SRC/)make/include/base.rules
+
+include $(MODULES:%=$(SRC/)%/module.rules)
+-include $(SRC/)make/variant/$(BUILD.system).rules
+-include $(SRC/)make/variant/$(BUILD.system).$(BUILD.machine).rules
+
+###############################################################################
+
+## target which causes re-configure if project-root is svn update'd
+$(BUILD/)GNUmakefile: $(wildcard $(SRC/).svn/entries)
+       $(SRC/)configure --force --conf-method=$(CONF.method) $(CONF.args)
+
+## target useful to force reconfigure; only helpful for build-system development
+.PHONY: reconfigure
+reconfigure:
+       $(SRC/)configure --force --conf-method=$(CONF.method) $(CONF.args)
+
+###############################################################################
+
+## target to build all dependency dirs
+$(sort $(dir $(BUILD.out))):
+       $(MKDIR.exe) -p $@
+
+endif ## xcode=1 method=terminal
diff --git a/make/include/report.defs b/make/include/report.defs
new file mode 100644 (file)
index 0000000..ce9c3e0
--- /dev/null
@@ -0,0 +1,62 @@
+## function: print a var's name, definition and expanded value
+##
+## $(1) = name of variable
+##
+define fn.PRINTVAR
+
+$(1)
+    ORIGIN     = $(origin $(1))
+    FLAVOR     = $(flavor $(1))
+    DEFINITION = $(value $(1)) 
+    EXPANDED   = $($(1))
+endef
+
+## report: module
+##
+## REPORT.module = module name (uppercase)
+##
+ifeq (module,$(REPORT))
+$(info ###############################################################################)
+$(info ##)
+$(info ## MODULE: $(REPORT.module))
+$(info ##)
+$(info ###############################################################################)
+$(info $(foreach v,$(sort $(filter $(REPORT.module).%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info )
+endif
+
+## report: main
+##
+ifeq (main,$(REPORT))
+$(info ###############################################################################)
+$(info ##)
+$(info ## MAIN)
+$(info ##)
+$(info ###############################################################################)
+$(info $(foreach v,$(sort $(filter HB.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info $(foreach v,$(sort $(filter HOST.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info $(foreach v,$(sort $(filter BUILD.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info $(foreach v,$(sort $(filter INSTALL.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info $(foreach v,$(sort $(filter FEATURE.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info $(foreach v,$(sort $(filter CONTRIB.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info )
+endif
+
+## report: gcc
+##
+ifeq (gcc,$(REPORT))
+$(info ###############################################################################)
+$(info ##)
+$(info ## GCC)
+$(info ##)
+$(info ###############################################################################)
+$(info $(foreach v,$(sort $(filter GCC.%,$(.VARIABLES))),$(call fn.PRINTVAR,$v)))
+$(info )
+endif
+
+## report: var
+##
+ifeq (var,$(REPORT))
+$(info $(call fn.PRINTVAR,$(name)))
+$(info )
+endif
diff --git a/make/include/select.defs b/make/include/select.defs
new file mode 100644 (file)
index 0000000..32a6525
--- /dev/null
@@ -0,0 +1,12 @@
+##
+## fetch a file from the web via well-known anonymous protocols such as HTTP.
+##
+## $(1) = output filename
+## $(2) = URL
+##
+FETCH = $(FETCH.$(FETCH.select))
+
+FETCH.select  = MISSING
+FETCH.MISSING = $(error one of the following tools is required: wget, curl)
+FETCH.curl    = $(CURL.exe) -q -L -o $(1) $(2)
+FETCH.wget    = $(WGET.exe) -O $(1) $(2)
diff --git a/make/include/target.defs b/make/include/target.defs
new file mode 100644 (file)
index 0000000..64bdde4
--- /dev/null
@@ -0,0 +1,14 @@
+TARGET.dylib.prefix = lib
+TARGET.dylib.suffix =
+TARGET.dylib.ext    = .dylib
+TARGET.dylib        = $(TARGET.dylib.prefix)$(1)$(TARGET.dylib.suffix)$(TARGET.dylib.ext)
+
+TARGET.archive.prefix = lib
+TARGET.archive.suffix =
+TARGET.archive.ext    = .a
+TARGET.archive        = $(TARGET.archive.prefix)$(1)$(TARGET.archive.suffix)$(TARGET.archive.ext)
+
+TARGET.exe.prefix =
+TARGET.exe.suffix =
+TARGET.exe.ext    =
+TARGET.exe        = $(TARGET.exe.prefix)$(1)$(TARGET.exe.suffix)$(TARGET.exe.ext)
diff --git a/make/include/tool.defs b/make/include/tool.defs
new file mode 100644 (file)
index 0000000..9a5d109
--- /dev/null
@@ -0,0 +1,11 @@
+AR.exe    = ar
+CP.exe    = cp
+CURL.exe  = curl
+M4.exe    = m4
+MKDIR.exe = mkdir
+PATCH.exe = patch
+RM.exe    = rm
+TAR.exe   = tar
+TOUCH.exe = touch
+WGET.exe  = wget
+MV.exe    = mv
diff --git a/make/test/build.matrix.darwin b/make/test/build.matrix.darwin
new file mode 100755 (executable)
index 0000000..7620707
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+
+## This script is used to launch a wide variety of builds for darwin.
+## It is unsupported and is meant for use only with build-system testing.
+
+if [ -z "$1" ]; then
+    echo "usage: $0 BUILDPREFIX"
+    exit 1
+fi
+
+set -e
+buildprefix=$1
+
+term_make() {
+    eval $1="make"
+    eval $2="'--disable-xcode'"
+}
+
+term_xcode() {
+    eval $1="make"
+    eval $2=""
+}
+
+launch_make() {
+    eval $1="launch"
+    eval $2="'--launch --launch-jobs=0 --launch-quiet --disable-xcode'"
+}
+
+launch_xcode() {
+    eval $1="launch"
+    eval $2="'--launch --launch-jobs=0 --launch-quiet'"
+}
+
+for debug in none max; do
+for arch in i386 ppc ppc64 x86_64; do
+    for method in launch_make launch_xcode term_make term_xcode; do
+        dir=$buildprefix.$arch.$debug.$method
+        if [ -d $dir ]; then
+            echo "skipping $dir"
+            continue
+        fi
+
+        $method mode args
+
+        cmd="./configure --arch=$arch --debug=$debug --build=$dir $args"
+        echo $cmd | awk '{ \
+            trail = ""; \
+            for( i = 4; i <= NF; i++ ) \
+                trail = trail " " $i; \
+            printf("%-11s %-13s %-30s%s\n", $1, $2, $3, trail) }'
+
+        $cmd
+        if [ "$mode" = "make" ]; then
+            (set -x; cd $dir && make -j8 >& log/build.txt)
+        fi
+    done
+done
+done
diff --git a/make/variant/cygwin.defs b/make/variant/cygwin.defs
new file mode 100644 (file)
index 0000000..b17166d
--- /dev/null
@@ -0,0 +1,8 @@
+GCC.muldefs = 1
+GCC.start   = 1
+GCC.end     = 1
+
+GCC.args.g.none = -g0
+GCC.args.g.min  = -g1
+GCC.args.g.std  = -g2
+GCC.args.g.max  = -g3
diff --git a/make/variant/darwin.defs b/make/variant/darwin.defs
new file mode 100644 (file)
index 0000000..4c9d06b
--- /dev/null
@@ -0,0 +1,37 @@
+UB.archs  = i386 x86_64 ppc ppc64
+UB.builds = $(wildcard $(foreach n,$(UB.archs),$(SRC/)build.$n))
+UB.first  = $(word 1,$(UB.archs))
+UB.other  = $(wordlist 2,999,$(UB.archs))
+
+UB.BUILD = $(SRC/)configure --force --build=ub.$(1) --arch=$(1) --launch --launch-quiet
+
+## linefeed is important
+define UB.BUILD.item
+       $(call UB.BUILD,$(1)) --launch-jobs=0
+
+endef
+
+define UB.BUILD.SERIAL
+       $(foreach n,$(UB.archs),$(call UB.BUILD.item,$n))
+endef
+
+define UB.BUILD.PARALLEL
+       $(call UB.BUILD,$(1)) >/dev/null 2>&1
+endef
+
+define UB.COMBINE
+       $(RM.exe) -fr ub.combine
+       $(MKDIR.exe) -p ub.combine
+       $(CP.exe) ub.$(UB.first)/HandBrakeCLI ub.combine/.
+       $(LIPO.exe) $(foreach n,$(UB.archs),ub.$n/HandBrakeCLI) -create -output ub.combine/HandBrakeCLI
+       $(CP.exe) -R ub.$(UB.first)/HandBrake.app ub.combine/.
+       $(LIPO.exe) $(foreach n,$(UB.archs),ub.$n/$(1)) -create -output ub.combine/$(1)
+       @lipo -info ub.combine/$(1)
+       @sync
+       @echo ""
+       @echo "$@: { $(UB.archs) } combined -> ub.combine/HandBrakeCLI"
+       @echo "$@: UB executable size: `du -sh ub.combine/HandBrakeCLI | awk '{ print $$1 }'`"
+       @echo ""
+       @echo "$@: { $(UB.archs) } combined -> ub.combine/HandBrake.app"
+       @echo "$@: UB executable size: `du -sh ub.combine/$(1) | awk '{ print $$1 }'`"
+endef
diff --git a/make/variant/darwin.rules b/make/variant/darwin.rules
new file mode 100644 (file)
index 0000000..d59a222
--- /dev/null
@@ -0,0 +1,20 @@
+.PHONY: ub.build ub.combine ub.clean
+
+ub.build.serial:
+       @$(UB.BUILD.SERIAL)
+
+ub.build.parallel:
+       @set -e; \
+       for arch in $(UB.archs); do \
+           $(call UB.BUILD.PARALLEL,$$arch) & \
+           children="$$children $$!"; \
+           echo "pid $$!: $(call UB.BUILD.PARALLEL,$$arch)"; \
+       done; \
+       echo "waiting for background jobs to complete:$$children"; \
+       wait
+
+ub.combine:
+       $(call UB.COMBINE,HandBrake.app/Contents/MacOS/HandBrake)
+
+ub.clean:
+       $(RM.EXE) -fr $(foreach n,$(UB.archs.other),ub.$n)
diff --git a/make/variant/darwin.x86_64.defs b/make/variant/darwin.x86_64.defs
new file mode 100644 (file)
index 0000000..c6e8564
--- /dev/null
@@ -0,0 +1,3 @@
+## can enable asm if we replace .rept pseudo op with standard pre-processor macros
+## since darwin's as doesn't support them. for now just disable.
+LIBTHEORA.CONFIGURE.extra += --disable-asm
diff --git a/make/variant/freebsd.defs b/make/variant/freebsd.defs
new file mode 100644 (file)
index 0000000..251debc
--- /dev/null
@@ -0,0 +1,9 @@
+TARGET.dylib.ext = .so
+
+GCC.args.dylib = -shared
+GCC.args.pic   = 1
+
+GCC.args.g.none = -g0
+GCC.args.g.min  = -g1
+GCC.args.g.std  = -g2
+GCC.args.g.max  = -g3
diff --git a/make/variant/linux.defs b/make/variant/linux.defs
new file mode 100644 (file)
index 0000000..c703272
--- /dev/null
@@ -0,0 +1,11 @@
+TARGET.dylib.ext = .so
+
+GCC.start      = 1
+GCC.end        = 1
+GCC.args.dylib = -shared
+GCC.args.pic   = 1
+
+GCC.args.g.none = -g0
+GCC.args.g.min  = -g1
+GCC.args.g.std  = -g2
+GCC.args.g.max  = -g3
diff --git a/make/variant/mingw.defs b/make/variant/mingw.defs
new file mode 100644 (file)
index 0000000..f521e24
--- /dev/null
@@ -0,0 +1,10 @@
+TARGET.exe.suffix = .exe
+
+GCC.start = 1
+GCC.end   = 1
+
+GCC.args.dylib  = -shared
+GCC.args.g.none = -g0
+GCC.args.g.min  = -g1
+GCC.args.g.std  = -g2
+GCC.args.g.max  = -g3
diff --git a/make/variant/solaris.defs b/make/variant/solaris.defs
new file mode 100644 (file)
index 0000000..e82cead
--- /dev/null
@@ -0,0 +1,11 @@
+TARGET.dylib.ext = .so
+
+GCC.args.dylib = -shared
+GCC.args.strip = -Wl,-s
+GCC.args.extra += -Wl,-z,rescan
+GCC.args.pic   = 1
+
+GCC.args.g.none = -g0
+GCC.args.g.min  = -g1
+GCC.args.g.std  = -g2
+GCC.args.g.max  = -g3
diff --git a/make/xcodemake b/make/xcodemake
new file mode 100755 (executable)
index 0000000..93c927c
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/bash
+#
+
+set -e
+
+## This script is invoked by Xcode external targets.
+##
+## We must guarantee no jobserver is passed through since the file-descriptors
+## have been clobbered by Xcode. If this is not done then make behaves as if
+## it is allowed to run an infinite number of jobs.
+##
+MAKEFLAGS=
+MFLAGS=
+
+## sanity check - the build system only supports 1 arch at a time
+archcount=`echo $ARCHS | awk '{ print NF }'`
+if [ "$archcount" -ne 1 ]; then
+    echo "*********************************************************************"
+    echo "***"
+    echo "*** ERROR: invalid number of architectures: $ARCHS"
+    echo "*** This build system builds one (1) archtecture at a time."
+    echo "***"
+    echo "*********************************************************************"
+    exit 1
+fi
+
+## compute if re/configure necessary
+if [ $EXTERNAL_METHOD != 'xcode' ]; then
+    reconfigure="terminal -> Xcode"
+elif [ ! -f $EXTERNAL_BUILD/GNUmakefile ]; then
+    reconfigure="no configuration present"
+elif [ $EXTERNAL_SRC/make/configure.py -nt $EXTERNAL_BUILD/GNUmakefile ]; then
+    reconfigure="configure script was updated"
+else
+    reconfigure=
+fi
+
+## perform re/configure
+if [ -n "$reconfigure" ]; then
+    echo "reconfiguring ($reconfigure)"
+
+    case "$CONFIGURATION" in
+    debug*)
+        debug="--debug=max --optimize=none"
+        ;;
+    standard*|*)
+        debug=
+        ;;
+    esac
+
+    ## invoke configure with (hidden) option which indicates conf performed by xcode
+    (set -x; $EXTERNAL_SRC/configure --force $EXTERNAL_CONFARGS \
+        --build=$EXTERNAL_BUILD --arch=$ARCHS $debug --conf-method=xcode PATH=$PATH )
+fi
+
+## compute goals; these correlate with TARGET_NAME and ACTION from Xcode
+spec="$TARGET_NAME:$ACTION"
+echo "env specification: $spec"
+case "$spec" in
+    contrib:clean)
+        goals=contrib.xclean
+        ;;
+    contrib:*)
+        goals=contrib.install
+        ;;
+    external:clean)
+        goals=clean
+        ;;
+    external:*)
+        if [ -z "$EXTERNAL_GOALS" ]; then
+            goals=build
+        else
+            goals="$EXTERNAL_GOALS"
+        fi
+        ;;
+    libhb:clean)
+        goals=libhb.clean
+        ;;
+    libhb:*)
+        goals=libhb.build
+        ;;
+    *)
+        echo "ERROR: invalid env specification: $spec"
+        exit 1
+        ;;
+esac
+
+## safeguard against passing blank value which would result in unlimited jobs
+if [ -z "$EXTERNAL_JOBS" ]; then
+    jobs=
+else
+    jobs=--jobs=$EXTERNAL_JOBS
+fi
+
+## log environment as provided by Xcode
+logdir=$EXTERNAL_BUILD/log
+if [ ! -d $logdir ]; then
+    mkdir -p $logdir
+fi
+env | sort > $logdir/xcodemake.env.txt
+
+## pull the trigger
+## must set BUILD.method != terminal to prevent inifinite recursion
+set -x
+exec make -C $EXTERNAL_BUILD BUILD.method=xcode $jobs $goals $EXTERNAL_VARS
diff --git a/pkg/appcast.xml.m4 b/pkg/appcast.xml.m4
new file mode 100644 (file)
index 0000000..3e20171
--- /dev/null
@@ -0,0 +1,33 @@
+dnl
+dnl This file is a template used to generate various appcast.xml files.
+dnl
+changequote(<<, >>)dnl
+include(<<handbrake.m4>>)dnl
+changequote([, ])dnl
+dnl
+dnl
+dnl
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
+    <channel>
+        <title>__HB_name __BUILD_arch Appcast</title>
+        <link>__HB_url_appcast</link>
+        <description></description>
+        <language>en</language>
+        <pubDate>__BUILD_date</pubDate>
+        <lastBuildDate>__BUILD_date</lastBuildDate>
+        <item>
+            <title>__HB_name __HB_version Released</title>
+            <cli>__HB_build "__HB_version __BUILD_arch"</cli>
+            <sparkle:releaseNotesLink>__HB_url_appnote</sparkle:releaseNotesLink>
+            <pubDate>__BUILD_date</pubDate>
+            <enclosure
+                sparkle:version="__HB_build"
+                sparkle:shortVersionString="__HB_version __BUILD_arch"
+                url="http://handbrake.fr/rotation.php?file=__APPCAST_dmg" 
+                length="__APPCAST_dmg_size"
+                type="application/octet-stream"/>
+            <sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion>
+        </item>
+    </channel>
+</rss>
diff --git a/pkg/darwin/module.defs b/pkg/darwin/module.defs
new file mode 100644 (file)
index 0000000..a8e8b7a
--- /dev/null
@@ -0,0 +1,16 @@
+PKG.cli.dmg = $(PKG.out/)$(HB.name)-$(HB.version)-MacOSX.5_CLI_$(BUILD.arch).dmg
+PKG.gui.dmg = $(PKG.out/)$(HB.name)-$(HB.version)-MacOSX.5_GUI_$(BUILD.arch).dmg
+
+PKG.cli.tmp.dmg = $(PKG.out/)$(HB.name)-$(HB.version)-MacOSX.5_CLI_$(BUILD.arch).tmp.dmg
+PKG.gui.tmp.dmg = $(PKG.out/)$(HB.name)-$(HB.version)-MacOSX.5_GUI_$(BUILD.arch).tmp.dmg
+
+STAGE.out.cli/ = $(STAGE.out/)cli/
+STAGE.out.gui/ = $(STAGE.out/)gui/
+
+PKG.appcast = $(PKG.out/)$(notdir $(HB.url.appcast))
+
+###############################################################################
+
+BUILD.out += $(PKG.cli.dmg)
+BUILD.out += $(PKG.gui.dmg)
+BUILD.out += $(PKG.appcast)
diff --git a/pkg/darwin/module.rules b/pkg/darwin/module.rules
new file mode 100644 (file)
index 0000000..9091c07
--- /dev/null
@@ -0,0 +1,54 @@
+pkg.create:: $(PKG.appcast) $(PKG.cli.dmg) $(PKG.gui.dmg)
+
+
+$(PKG.appcast): | $(dir $(PKG.appcast))
+$(PKG.appcast): $(PKG.gui.dmg)
+$(PKG.appcast): $(BUILD/)project/handbrake.m4
+$(PKG.appcast): $(PKG.in/)appcast.xml.m4
+       $(M4.exe) -I$(BUILD/)project \
+           -D__APPCAST_dmg="$(notdir $(PKG.gui.dmg))" \
+           -D__APPCAST_dmg_size="$(shell stat -f '%z' $(PKG.gui.dmg))" \
+           $(PKG.in/)appcast.xml.m4 > $@
+
+$(PKG.cli.dmg): | $(dir $(PKG.cli.dmg))
+$(PKG.cli.dmg): | $(STAGE.out.cli/)
+       hdiutil create -srcfolder $(STAGE.out.cli/) -format UDRO -mode 755 \
+           -volname $(basename $(notdir $@)) \
+           -ov $(PKG.cli.tmp.dmg)
+       hdiutil convert -format UDBZ -o $@ $(PKG.cli.tmp.dmg)
+       $(RM.exe) $(PKG.cli.tmp.dmg)
+
+$(PKG.gui.dmg): | $(dir $(PKG.gui.dmg))
+$(PKG.gui.dmg): | $(STAGE.out.gui/)
+ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
+       hdiutil create -srcfolder $(STAGE.out.gui/) -format UDRO -mode 755 \
+           -volname $(basename $(notdir $@)) \
+           -ov $(PKG.gui.tmp.dmg)
+       hdiutil convert -format UDBZ -o $@ $(PKG.gui.tmp.dmg)
+       $(RM.exe) $(PKG.gui.tmp.dmg)
+else
+       $(TOUCH.exe) $@
+endif
+
+$(STAGE.out.cli/):
+       $(MKDIR.exe) -p $@
+ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
+       $(CP.exe) $(BUILD/)HandBrakeCLI $(STAGE.out.cli/)
+       $(call STAGE.doc,$(STAGE.out.cli/))
+else
+       $(CP.exe) $(TEST.exe) $(STAGE.cli/)
+       $(call STAGE.doc,$(STAGE.out.cli/))
+endif
+
+$(STAGE.out.gui/):
+       $(MKDIR.exe) -p $@
+ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
+       $(CP.exe) -R $(BUILD/)HandBrake.app $(STAGE.out.gui/)
+       $(LIPO.exe) -thin $(BUILD.arch) \
+           $(SRC/)macosx/Growl.framework/Versions/A/Growl \
+           -output $(STAGE.out.gui/)HandBrake.app/Contents/Frameworks/Growl.framework/Versions/A/Growl
+       $(LIPO.exe) -thin $(BUILD.arch) \
+           $(SRC/)macosx/Sparkle.framework/Versions/A/Sparkle \
+           -output $(STAGE.out.gui/)HandBrake.app/Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle
+       $(call STAGE.doc,$(STAGE.out.gui/))
+endif
diff --git a/pkg/linux/debian/README.Debian b/pkg/linux/debian/README.Debian
new file mode 100644 (file)
index 0000000..541ccc6
--- /dev/null
@@ -0,0 +1,74 @@
+handbrake for Debian
+--------------------
+
+HandBrake bundles its own copies of ffmpeg and related media libraries. This is
+an upstream decision that the Ubuntu maintainers will respect.
+
+This is done by running contrib/getcontrib.sh which wgets each library from
+HandBrake's website.
+
+
+Upstream has asked us to do this because they have modified their libraries to
+address the finickiness of the platforms that they support, along with
+prerelease patches that add support for advanced HandBrake functionality such as
+surround-sound downmixing.
+
+HandBrake then statically links against these libraries, and they are not
+installed to the system so it doesn't interfere with other parts of the system.
+Different or older versions of these packages are included in the Ubuntu
+distribution already, and have passed our guidelines for Multiverse inclusion.
+
+
+=== Detailed Breakdown of Bundled Libraries and Reasons ===
+
+a52dec - 0.7.4
+patch to allow downmix to dolby prologic ii
+
+faad2 2.6.1
+patch to configure.ac so it will build with libtool 2.2.x
+
+ffmpeg svn 15462
+patch for building on beos
+patch that adds aac-latm codec
+patch fixes memory leak provoked by h264 streams with lots of errors
+patch for cygwin
+patch for solaris
+
+libdca svn 81
+newer than released version
+
+libdvdread 0.9.7
+patch for os x, changes path to dvdcss
+patch for cygwin, configure fixes
+
+faac
+patch for cygwin configure
+
+lame version 3.98
+
+libmp4v2 svn 45
+project was stagnant. using a fork that has picked up development
+
+libmkv 0.6.3
+
+mpeg2dec 0.5.1
+
+libogg 1.1.3
+
+libsamplerate 0.1.4
+
+libvorbis aotuv fork b5
+
+libtheora 1.0
+
+libx264 git 1028
+patch for cygwin configure
+patch for solaris build scripts
+patch to allow forcing an IDR frame
+
+xvidcore 1.1.3
+patch for os x configure
+patch for cygwin configure
+patch configure to recognize nasm 2.0
+
+ -- John Dong <jdong@ubuntu.com>  Fri, 28 Nov 2008 14:17:16 -0500
diff --git a/pkg/linux/debian/changelog b/pkg/linux/debian/changelog
new file mode 100644 (file)
index 0000000..d90ee39
--- /dev/null
@@ -0,0 +1,100 @@
+handbrake (svn2573) jaunty; urgency=low
+  * CORE
+   - Allows sources with no audio to be encoded
+   - TrueHD and DTS-HD demuxing
+   - Transport stream improvements
+   - Better reading of audio source parameters
+   - Support for 8-bit audio sources
+   - Fixed 5.1 Vorbis channel maps
+   - Better DTS handling
+   - Better VC1 handling
+   - Better frame synchronization validation
+   - Better identification of valid tracks in streams
+   - Better handle of New Zealand FreeView broadcasts
+   - Avoids a crash when a user tries to encode the same audio multiple times with file inputs, a big problem with the Universal and AppleTV presets
+   - Preserves metadata when encoding MP4 sources
+   - Avoids libavcodec threading issue by better locking
+   - Fixes aspect ratio rounding bug
+   - ffmpeg libraries update, libmp4v2 update, libx264 update
+   - Other assorted improvements
+       
+  * MAC
+   - Live preview encoding
+   - Picture settings split off to its own window instead of a sheet, with a button in the toolbar
+   - Variable number of preview images, default is now 30 not 10
+   - Logging level preference
+   - On launch preference for whether or not to show Open Source window
+   - Autocrop re-enabled for AppleTV Legacy preset
+   - Support dropped for user presets generated in 0.9.2 or earlier
+   - Correct dates for single-serving activity logs
+   - Fixes issue where changing format reset video codec selection
+   - Other assorted interface enhancements and bug fixes
+       
+  * WIN
+   - XML-based queue system
+   - Removed RAM limitation
+   - Better memory alignment in Cygwin
+   - Other assorted interface enhancements and bug fixes
+   
+  * LIN
+   - Live preview encoding
+   - Picture settings split off to its own window with a button in the toolbar
+   - Variable number of preview images, default is now 30 not 10
+   - Interface improvements
+   - Logging level preference
+   - Other assorted interface enhancements and bug fixes
+   
+  * CLI
+   - Added a --previews option to control how many preview images are scanned and whether or not they're written to disk (now defaults to not storing them) 
+
+ -- John Stebbins <jstebbins.hb@gmail.com>  Sun, 21 Dec 2008 9:51:07 -0800
+
+handbrake (0.9.3+repack1-0ubuntu0~8.04jdong4) hardy; urgency=low
+
+  * Incorporate fixes suggested by John Stebbins:
+   - Don't have the buildsys override HB's optimized CFLAGS
+   - Do an official build (not a snapshot)
+   - dh_icons/dh_desktop to correctly install menu icon
+
+ -- John Dong <jdong@ubuntu.com>  Wed, 17 Dec 2008 21:15:07 -0500
+
+handbrake (0.9.3+repack1-0ubuntu0~8.04jdong3) hardy; urgency=low
+
+  *  Switch to bzip2 compression
+
+ -- John Dong <jdong@ubuntu.com>  Mon, 01 Dec 2008 14:19:06 -0500
+
+handbrake (0.9.3+repack1-0ubuntu0~8.04jdong2) hardy; urgency=low
+
+  * Split the GUI from the CLI:
+   - handbrake-gtk: GUI frontend
+   - handbrake-cli: CLI frontend
+   - handbrake-common: README files and documentations common to both.
+
+ -- John Dong <jdong@ubuntu.com>  Mon, 01 Dec 2008 12:39:22 -0500
+
+handbrake (0.9.3+repack1-0ubuntu0~8.10jdong1) intrepid; urgency=low
+
+  * Repacked orig.tar.gz:
+    - Bundled contribs/ libraries so they don't get fetched as a part of the 
+      build process.
+    - Documented this process in README.Debian
+  * TODO:
+    - Document debian/copyright for contrib libraries
+    - Split handbrake-cli and handbrake-gtk
+
+ -- John Dong <jdong@ubuntu.com>  Sat, 29 Nov 2008 00:31:50 -0500
+
+handbrake (0.9.3-0ubuntu0~8.10jdong2) jaunty; urgency=low
+
+  * UNRELEASED:
+   - Work-in-progress documenting debian/copyright
+
+ -- John Dong <jdong@ubuntu.com>  Sat, 29 Nov 2008 00:26:56 -0500
+
+handbrake (0.9.3-0ubuntu0~8.10jdong1) jaunty; urgency=low
+
+  * Initial attempt at packaging
+
+ -- John Dong <jdong@ubuntu.com>  Fri, 28 Nov 2008 14:17:16 -0500
+
diff --git a/pkg/linux/debian/compat b/pkg/linux/debian/compat
new file mode 100644 (file)
index 0000000..1e8b314
--- /dev/null
@@ -0,0 +1 @@
+6
diff --git a/pkg/linux/debian/control b/pkg/linux/debian/control
new file mode 100644 (file)
index 0000000..e6b9552
--- /dev/null
@@ -0,0 +1,30 @@
+Source: handbrake
+Section: graphics
+Priority: optional
+Maintainer: John Stebbins <jstebbins.hb@gmail.com>
+Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgtkhtml3.14-dev, libhal-storage-dev, intltool, autoconf, yasm (>= 0.7.0), libbz2-dev, zlib1g-dev
+Standards-Version: 3.7.3
+Homepage: http://www.handbrake.fr/
+
+Package: handbrake-cli
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Conflicts: handbrake
+Description: versatile DVD ripper and video transcoder - command line
+ HandBrake is a versatile, easy-to-use tool for converting DVDs and other videos
+ into H.264, MPEG-4, or OGG formatted media. It's particularly useful for making
+ videos that are compatible with portable video devices such as the Apple
+ iPod/iPhone. This package contains the command-line variant,
+ HandBrakeCLI
+
+Package: handbrake-gtk
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Conflicts: handbrake
+Description: versatile DVD ripper and video transcoder - GTK GUI
+ HandBrake is a versatile, easy-to-use tool for converting DVDs and other videos
+ into H.264, MPEG-4, or OGG formatted media. It's particularly useful for making
+ videos that are compatible with portable video devices such as the Apple
+ iPod/iPhone. This package contains the graphical variant, ghb.
+
+
diff --git a/pkg/linux/debian/copyright b/pkg/linux/debian/copyright
new file mode 100644 (file)
index 0000000..30c423a
--- /dev/null
@@ -0,0 +1,897 @@
+This package was debianized by John Dong <jdong@ubuntu.com> on
+Fri, 28 Nov 2008 14:17:16 -0500.
+
+It was downloaded from http://handbrake.fr/
+
+Upstream Author(s): See AUTHORS file for details
+
+    Eric Petit <titer@m0k.org>
+    Laurent Aimar <fenrir@via.ecp.fr>
+    John Allen (?) <johnallenemail@gmail.com> (johnallen)
+    Joe Crain <joe@dynaflashtech.net> (dynaflash)
+    Damiano Galassi <damiog@gmail.com> (ritsuka)
+    Edward Groenendaal <eddyg.hb@myreflection.org> (eddyg)
+    Rodney Hester <rhester@multics.dynalias.com> (rhester)
+    Andrew Kimpton <awk@awkward.org> (awk)
+    Chris Lee <clee@kde.org>
+    Chris Long <chris.long@mac.com> (chrislong)
+    Brian Mario <Unknown> (brianmario)
+    Maurj <handbrake@maurj.com> (maurj)
+    Mirkwood <mirkwood07@gmail.com> (mirkwood)
+    Nyx <unknown> (Nyx)
+    Philippe Rigaux <pri@nopapers.org> (prigaux)
+    Jonathon Rubin <jb.rubin@gmail.com> (jbrjake)
+    Scott <sr55ww@googlemail.com> (sr55)
+    Chris Thoman <cthoman@gmail.com> (huevos_rancheros)
+    Mark Krenek <markkrenek@mac.com> (travistex)
+    Van Jacobson <vanj.hb@gmail.com> (van)
+
+Copyright:
+  
+    Copyright (C) 2008 by the HandBrake team (See AUTHORS)
+
+License:
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+The full text of this license is at `/usr/share/common-licenses/GPL'.
+
+---
+
+The Debian packaging is (C) 2008, John Dong <jdong@ubuntu.com> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+
+
+==== Contrib Libraries ====
+
+HandBrake also includes and statically links against several open source
+supporting libraries. The source code for these libraries may be found in the
+`contribs/' directory. The projects and authors are listed in the
+CREDITS file of the source. A copy is installed to
+`/usr/share/doc/handbrake-common/CREDITS' when HandBrake is installed. The
+source for each library is found in a .txt in the contribs directory. For
+example, `contribs/a52dec.tar.gz' is downloaded from the URL in
+`contribs/version_a52dec.txt'.
+
+--- a52dec ---
+
+License:
+
+  Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+  Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in /usr/share/common-licenses/GPL file.
+
+--- faad2 ---
+Upstream Authors: menno     <menno@audiocoding.com>
+      Alexander Kurpiers  <a.kurpiers@nt.tu-darmstadt.de>
+      M. Bakker   <mbakker@nero.com>
+      Ahead Software AG
+      Nero AG
+Copyright:    2002-2005   M. Bakker
+      2003-2005   Ahead Software AG
+      2003-2005   Nero AG
+
+Other Authors:    John Edwards
+      Bill May    <wmay@cisco.com>
+      Quinnware
+      VideoLAN
+Copyright:    2002      John Edwards
+      2003      Bill May
+      1997-2002   Quinnware
+      2004      VideoLAN
+
+License Declaration:
+
+The GPL may be found in the file /usr/share/common-licenses/GPL.
+
+The upstream source has the follwing license declaration:
+---
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Any non-GPL usage of this software or parts of this software is strictly
+forbidden.
+
+The "appropriate copyright message" mentioned in section 2c of the GPLv2 must
+read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+---
+
+The aacDECdrop module has the following license declaration:
+---
+This program is distributed under the GNU General Public License, version 2. A
+copy of this license is included with this source.
+---
+
+Some files (extra components and plugins) and the Debian packaging have the
+following license declaration:
+---
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+---
+
+--- ffmpeg ---
+
+Upstream Authors: Fabrice Bellard
+                  Alex Beregszaszi
+                  BERO
+                  Mario Brito
+                  Ronald Bultje
+                  Tim Ferguson
+                  Brian Foley
+                  Arpad Gereoffy
+                  Philip Gladstone
+                  Vladimir Gneushev
+                  Wolfgang Hesseler
+                  Falk Hueffner
+                  Zdenek Kabelac
+                  Robin Kay
+                  Todd Kirby
+                  Nick Kurshev
+                  Mike Melanson
+                  Michael Niedermayer
+                  François Revol
+                  Roman Shaposhnik
+                  Dieter Shirley
+                  Juan J. Sierralta
+                  Ewald Snel
+                  Leon van Stuivenberg
+                  Roberto Togni
+                  Lionel Ulmer
+
+Copyright (c) 2000-2004 Fabrice Bellard et al.
+
+The following files are licensed under the GNU GPL, as clarified below:
+
+ * ffmpeg.c
+ * libavcodec:
+   + dtsdec.c
+   + i386/idct_mmx.c
+   + liba52/*.[ch]
+ * libavformat:
+   + x11grab.c
+   + gxfenc.c
+ * libpostproc:
+   + postprocess_internal.h
+   + postprocess_altivec_template.c
+   + postprocess.h
+   + postprocess_template.c
+   + postprocess.c
+   + mangle.h
+ * libswscale:
+   + swscale.c
+   + swscale-example.c
+   + yuv2rgb_template.c
+   + swscale_altivec_template.c
+   + yuv2rgb_altivec.c
+   + swscale_template.c
+   + rgb2rgb_template.c
+   + rgb2rgb.c
+   + cs_test.c
+   + yuv2rgb_mlib.c
+   + yuv2rgb.c
+
+ | This library is free software; you can redistribute it and/or
+ | modify it under the terms of the GNU General Public License as
+ | published by the Free Software Foundation; either version 2 of
+ | the License, or (at your option) any later version.
+ |
+ | This library is distributed in the hope that it will be useful,
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ | Lesser General Public License for more details.
+ |
+ | You should have received a copy of the GNU General Public License
+ | along with this program; if not, write to the Free Software
+ | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+The debian/libfaad directory contains header from the libfaad-dev package.
+
+ | Upstream Authors: menno      <menno@audiocoding.com>
+ |      Alexander Kurpiers  <a.kurpiers@nt.tu-darmstadt.de>
+ |        M. Bakker   <mbakker@nero.com>
+ |      Ahead Software AG
+ |      Nero AG
+ | Copyright:   2002-2005   M. Bakker
+ |      2003-2005   Ahead Software AG
+ |      2003-2005   Nero AG
+ | 
+ | Other Authors:   John Edwards
+ |      Bill May    <wmay@cisco.com>
+ |      Quinnware
+ |      VideoLAN
+ | Copyright:   2002      John Edwards
+ |      2003      Bill May
+ |      1997-2002   Quinnware
+ |      2004      VideoLAN
+ | 
+ | License Declaration:
+ | 
+ | The GPL may be found in the file /usr/share/common-licenses/GPL.
+ | 
+ | The upstream source has the follwing license declaration:
+ | ---
+ | This program is free software; you can redistribute it and/or modify it under
+ | the terms of the GNU General Public License as published by the Free Software
+ | Foundation; either version 2 of the License, or (at your option) any later
+ | version.
+ | 
+ | This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ | PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ | 
+ | You should have received a copy of the GNU General Public License along with
+ | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ | Place - Suite 330, Boston, MA 02111-1307, USA.
+
+The debian/liba52 directory contains a copy of the header file from the
+liba52-0.7.4-dev package.
+
+ | License:
+ | 
+ |  Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ |  Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+ | 
+ |  This program is free software; you can redistribute it and/or modify
+ |  it under the terms of the GNU General Public License as published by
+ |  the Free Software Foundation; either version 2 of the License, or
+ |  (at your option) any later version.
+ | 
+ |  This program is distributed in the hope that it will be useful,
+ |  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ |  GNU General Public License for more details.
+ | 
+ |  You should have received a copy of the GNU General Public License
+ |  along with this program; if not, write to the Free Software
+ |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+The rest of the code is licensed under the GNU LGPL:
+
+ | This library is free software; you can redistribute it and/or
+ | modify it under the terms of the GNU Lesser General Public License as
+ | published by the Free Software Foundation; either version 2.1 of
+ | the License, or (at your option) any later version.
+ |
+ | This library is distributed in the hope that it will be useful,
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ | Lesser General Public License for more details.
+ |
+ | You should have received a copy of the GNU General Public License
+ | along with this program; if not, write to the Free Software
+ | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian GNU/Linux systems, the complete text of the GNU General Public
+License can be found in `/usr/share/common-licenses/GPL' and the text of the
+GNU Lesser General Public License is in `/usr/share/common-licenses/LGPL'.
+
+--- libdca ---
+
+Authors:
+Gildas Bazin <gbazin@videolan.org> implementation of the
+DTS Coherent Acoustics decoder and current maintainer of libdts.
+
+Other libdts contributors include:
+        Sam Hocevar <sam@zoy.org> - build system improvements and debian package
+
+While the libdts part of the source code was mostly written from scratch, this
+project was started from the a52dec code base so the original credits for
+a52dec are preserved:
+
+Aaron Holtzman <aholtzma@ess.engr.uvic.ca> started the project and
+made the initial working implementation.
+
+Michel Lespinasse <walken@zoy.org> did major changes for speed and
+conformance and is the current maintainer.
+
+Other contributors include:
+  Gildas Bazin <gbazin@netcourrier.com> - mingw32 port
+  Billy Biggs <vektor@div8.net> - most of liba52.txt
+  Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com> - fixed point version
+  Eduard Hasenleithner <eduardh@aon.at> - gcc 3.0 fixes
+  H�kan Hjort <d95hjort@dtek.chalmers.se> - Solaris output, mlib code
+  Charles M. Hannum <root@ihack.net> - fixes
+  Chris Hodges <hodges@stradis.com> - made the library reentrant
+  Michael Holzt <kju@flummi.de> - OSS output.c and misc errata
+  Angelos Keromytis <angelos@dsl.cis.upenn.edu> - OpenBSD fixes
+  David I. Lehn <dlehn@vt.edu> - API cleanup suggestion
+  Don Mahurin <dmahurin@dma.org> - stdin support for extract_a52
+  Jim Miller <jmiller@heli.engr.sgi.com> - IRIX output.c
+  Takefumi Sayo <stake@niagara.shiojiri.ne.jp> - FreeBSD tweak
+  Shoji Tokunaga <toku@mac.com> - aif file output
+
+Copyright:
+
+    <Copyright Â© 2004-2008 Gildas Bazin <gbazin@videolan.org>
+
+License:
+
+    You should have received a copy of the GNU General Public License with the
+    Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; if
+    not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
+    Floor, Boston, MA 02110-1301, USA.
+
+--- libdvdread ---
+
+Author: Bjorn Englund <d4bjorn@dtek.chalmers.se>
+
+Copyright:
+ (C) 2000-2001 Bjorn Englund <d4bjorn@dtek.chalmers.se>
+ (C) 2000-2001 Hakan Hjort <d95hjort@dtek.chalmers.se>
+ (C) 2000-2001 Billy Biggs <vektor@dumbterm.net>
+ (C) 2000-2001 Christian Wolff <scarabaeus@convergence.de>
+License: GPL-2+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ can be found in /usr/share/common-licenses/GPL-2 file.
+
+
+--- faac ---
+
+Authors: (see AUTHORS in contrib/faac.tar.gz for more information)
+  lenox (Tony Lenox)
+  menno
+  oxygene2000/oxygene (?)
+  thebard (wmilas@rarcoa.com)
+  prkoat (?)
+  xfhobbes (?)
+  flyingfox (?)
+  eraser (?)
+  knik (Krzysztof Nikiel)
+  stux (Stuart Espey)
+  ca5e (Janne Hyvärinen)
+  danchr (Dan Christiansen)
+  corrados (Volker Fischer)
+
+
+Copyright: 2001 M. Bakker
+  You should have received a copy of the GNU General Public License with the
+  Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL; if
+  not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
+  Floor, Boston, MA 02110-1301, USA.
+
+--- LAME ---
+
+Authors: 
+  The following people contributed to the LAME development:
+
+  Lauri Ahonen
+  Sakari Ailus
+  Tero Auvinen
+  Michal Bacik
+  Alex Ballegooy
+  Wilfried Behne
+  Bob Bell
+  Simon Blandford
+  Segher Boessenkool
+  Florian Bome
+  Lionel Bonnet
+  Gabriel Bouvigne
+  Rogério Theodoro de Brito
+  Erik de Castro Lopo
+  David Chandler
+  Michael Cheng
+  John Dahlstrom
+  Goran Dokic
+  James Droppo
+  Sergey Dubov
+  Dominique Duvivier
+  John Edwards
+  Alvaro Martinez Echevarria
+  Joakim Enerstam
+  Albert Faber
+  Nils Faerber
+  Sami Farin
+  Mikhail M. Fedotov
+  Joseph Fourier
+  Jani Frilander
+  Richard Gorton
+  Casper Gripenberg
+  Steffan Haeuser
+  Jeremy Hall
+  Paul Hartman
+  John Hayward-Warburton
+  Peder Hedlund
+  Robert Hegemann
+  Mathew Hendry
+  Magnus Holmgren
+  Vitaly Ivanov
+  Ben "Jacobs"
+  Tamito Kajiyama
+  Ti Kan
+  Mo Katz
+  Iwasa Kazmi
+  Ralf Kempkens
+  Frank Klemm
+  Aleksander Korzynski
+  Joachim Kuebart
+  Leonid Kulakov
+  Dmitry Kutsanov
+  Jarmo Laakkonen
+  An van Lam
+  Dennis Lambe Jr
+  Juha Laukala
+  Greg Lehey
+  Felix von Leitner
+  Rafael Luebbert
+  Macik
+  Lars Magne Ingebrigtsen
+  Scott Manley
+  Vladimir Marek
+  Goran Markovic
+  Sergey A. Maslyakov
+  Chris Matrakidis
+  Greg Maxwell
+  Chris Miller
+  Scott Miller
+  Darin Morrison
+  Tomasz Motylewski
+  Kimmo Mustonen
+  Dan Nelson
+  Nyaochi
+  Anton Oleynikov
+  Mike Oliphant
+  André Osterhues
+  Johannes Overmann
+  Gian-Carlo Pascutto
+  Jan Peman
+  Jan Rafaj
+  Gertjan van Ratingen
+  Miguel Revilla Rodriguez
+  Shawn Riley
+  Tim Ruddick
+  Ingo Saitz
+  Conrad Sanderson
+  Sergey Sapelin
+  William Schelter
+  Justin Schoeman
+  Anton Sergunov
+  Naoki Shibata
+  Sigbjørn Skjæret
+  Nathan Slingerland
+  Patrick De Smet
+  Acy Stapp
+  Mark Stephens
+  Jonathan Stott
+  Alexander Stumpf
+  Stephane Tavenard
+  Mark Taylor
+  Mikhail Teterin
+  Brad Threatt
+  Takehiro Tominaga
+  Warren Toomey
+  Atro Tossavainen
+  Roel Van Den Berghe
+  Kyle VanderBeek
+  Linus Walleij
+  Martin Weghofer
+  William Welch
+  Gerhard Wesp
+  Alfred Weyers
+  Christopher Wise
+  Ethan Yeo
+  Chuck Zenkus
+
+   
+
+  Original ISO contributors:
+
+  Bill Aspromonte
+  Shaun Astarabadi
+  R. Bittner
+  Karlheinz Brandenburg
+  W. Joseph Carter
+  Jack Chang
+  Mike Coleman
+  Johnathan Devine
+  Ernst Eberlein
+  Dan Ellis
+  Peter Farrett
+  Jean-Georges Fritsch
+  Vlad Fruchter
+  Hendrik Fuchs
+  Bernhard Grill
+  Amit Gulati
+  Munsi Haque
+  Chuck Hsiao
+  Toshiyuki Ishino
+  Masahiro Iwadare
+  Earl Jennings
+  James Johnston
+  Leon v.d. Kerkhof
+  Don Lee
+  Mike Li
+  Yu-Tang Lin
+  Soren Neilsen
+  Simao F. Campos Neto
+  Mark Paley
+  Davis Pan
+  Tan Ah Peng
+  Kevin Peterson
+  Juan Pineda
+  Ernst F. Schroeder
+  Peter Siebert
+  Jens Spille
+  John Stewart
+  Sam Stewart
+  Al Tabayoyon
+  Kathy Wang
+  Franz-Otto Witte
+  Douglas Wong
+
+
+Copyright: 1999-2008 by LAME authors
+
+    LAME is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    LAME is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth  Floor, Boston, MA 02110-1301, USA.
+
+On Debian systems, the complete text of the GNU Library
+General Public License can be found in `/usr/share/common-licenses/LGPL'.
+
+
+--- libmp4v2 (mpeg4ip) ---
+
+libmp4v2 is a subset of the mpeg4ip project.
+Upstream Authors: menno (menno@audiocoding.com) Alexander Kurpiers
+                   (a.kurpiers@nt.tu-darmstadt.de)
+
+The mpeg4ip subset in libmp4v2.tar.gz is original code by menno
+and Alexander Kurpiers. It is licensed under the terms of the Mozilla Public
+License (MPL) version 1.1. The complete text of the license is reproduced at the
+end of this section.
+
+
+
+                          MOZILLA PUBLIC LICENSE
+                                Version 1.1
+
+                              ---------------
+
+1. Definitions.
+
+     1.0.1. "Commercial Use" means distribution or otherwise making the
+     Covered Code available to a third party.
+
+     1.1. "Contributor" means each entity that creates or contributes to
+     the creation of Modifications.
+
+     1.2. "Contributor Version" means the combination of the Original
+     Code, prior Modifications used by a Contributor, and the Modifications
+     made by that particular Contributor.
+
+     1.3. "Covered Code" means the Original Code or Modifications or the
+     combination of the Original Code and Modifications, in each case
+     including portions thereof.
+
+     1.4. "Electronic Distribution Mechanism" means a mechanism generally
+     accepted in the software development community for the electronic
+     transfer of data.
+
+     1.5. "Executable" means Covered Code in any form other than Source
+     Code.
+
+     1.6. "Initial Developer" means the individual or entity identified
+     as the Initial Developer in the Source Code notice required by Exhibit
+     A.
+
+     1.7. "Larger Work" means a work which combines Covered Code or
+     portions thereof with code not governed by the terms of this License.
+
+     1.8. "License" means this document.
+
+     1.8.1. "Licensable" means having the right to grant, to the maximum
+     extent possible, whether at the time of the initial grant or
+     subsequently acquired, any and all of the rights conveyed herein.
+
+     1.9. "Modifications" means any addition to or deletion from the
+     substance or structure of either the Original Code or any previous
+     Modifications. When Covered Code is released as a series of files, a
+     Modification is:
+          A. Any addition to or deletion from the contents of a file
+          containing Original Code or previous Modifications.
+
+          B. Any new file that contains any part of the Original Code or
+          previous Modifications.
+
+     1.10. "Original Code" means Source Code of computer software code
+     which is described in the Source Code notice required by Exhibit A as
+     Original Code, and which, at the time of its release under this
+     License is not already Covered Code governed by this License.
+
+     1.10.1. "Patent Claims" means any patent claim(s), now owned or
+     hereafter acquired, including without limitation,  method, process,
+     and apparatus claims, in any patent Licensable by grantor.
+
+     1.11. "Source Code" means the preferred form of the Covered Code for
+     making modifications to it, including all modules it contains, plus
+     any associated interface definition files, scripts used to control
+     compilation and installation of an Executable, or source code
+     differential comparisons against either the Original Code or another
+     well known, available Covered Code of the Contributor's choice. The
+     Source Code can be in a compressed or archival form, provided the
+     appropriate decompression or de-archiving software is widely available
+     for no charge.
+
+     1.12. "You" (or "Your")  means an individual or a legal entity
+     exercising rights under, and complying with all of the terms of, this
+     License or a future version of this License issued under Section 6.1.
+     For legal entities, "You" includes any entity which controls, is
+     controlled by, or is under common control with You. For purposes of
+     this definition, "control" means (a) the power, direct or indirect,
+     to cause the direction or management of such entity, whether by
+     contract or otherwise, or (b) ownership of more than fifty percent
+     (50%) of the outstanding shares or beneficial ownership of such
+     entity.
+
+2. Source Code License.
+
+     2.1. The Initial Developer Grant.
+     The Initial Developer hereby grants You a world-wide, royalty-free,
+     non-exclusive license, subject to third party intellectual property
+     claims:
+          (a)  under intellectual property rights (other than patent or
+          trademark) Licensable by Initial Developer to use, reproduce,
+          modify, display, perform, sublicense and distribute the Original
+          Code (or portions thereof) with or without Modifications, and/or
+          as part of a Larger Work; and
+
+          (b) under Patents Claims infringed by the making, using or
+          selling of Original Code, to make, have made, use, practice,
+          sell, and offer for sale, and/or otherwise dispose of the
+          Original Code (or portions thereof).
+
+          (c) the licenses granted in this Section 2.1(a) and (b) are
+          effective on the date Initial Developer first distributes
+          Original Code under the terms of this License.
+
+          (d) Notwithstanding Section 2.1(b) above, no patent license is
+          granted: 1) for code that You delete from the Original Code; 2)
+          separate from the Original Code;  or 3) for infringements caused
+          by: i) the modification of the Original Code or ii) the
+          combination of the Original Code with other software or devices.
+
+     2.2. Contributor Grant.
+     Subject to third party intellectual property claims, each Contributor
+     hereby grants You a world-wide, royalty-free, non-exclusive license
+
+          (a)  under intellectual property rights (other than patent or
+          trademark) Licensable by Contributor, to use, reproduce, modify,
+          display, perform, sublicense and distribute the Modifications
+          created by such Contributor (or portions thereof) either on an
+          unmodified basis, with other Modifications, as Covered Code
+          and/or as part of a Larger Work; and
+
+          (b) under Patent Claims infringed by the making, using, or
+          selling of  Modifications made by that Contributor either alone
+          and/or in combination with its Contributor Version (or portions
+          of such combination), to make, use, sell, offer for sale, have
+          made, and/or otherwise dispose of: 1) Modifications made by that
+          Contributor (or portions thereof); and 2) the combination of
+          Modifications made by that Contributor with its Contributor
+          Version (or portions of such combination).
+
+          (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+          effective on the date Contributor first makes Commercial Use of
+          the Covered Code.
+
+          (d)    Notwithstanding Section 2.2(b) above, no patent license is
+          granted: 1) for any code that Contributor has deleted from the
+          Contributor Version; 2)  separate from the Contributor Version;
+          3)  for infringements caused by: i) third party modifications of
+          Contributor Version or ii)  the combination of Modifications made
+          by that Contributor with other software  (except as part of the
+          Contributor Version) or other devices; or 4) under Patent Claims
+          infringed by Covered Code in the absence of Modifications made by
+          that Contributor.
+
+3. Distribution Obligations.
+
+     3.1. Application of License.
+     The Modifications which You create or to which You contribute are
+     governed by the terms of this License, including without limitation
+     Section 2.2. The Source Code version of Covered Code may be
+     distributed only under the terms of this License or a future version
+     of this License released under Section 6.1, and You must include a
+     copy of this License with every copy of the Source Code You
+     distribute. You may not offer or impose any terms on any Source Code
+     version that alters or restricts the applicable version of this
+     License or the recipients' rights hereunder. However, You may include
+     an additional document offering the additional rights described in
+     Section 3.5.
+
+     3.2. Availability of Source Code.
+     Any Modification which You create or to which You contribute must be
+     made available in Source Code form under the terms of this License
+     either on the same media as an Executable version or via an accepted
+     Electronic Distribution Mechanism to anyone to whom you made an
+     Executable version available; and if made available via Electronic
+     Distribution Mechanism, must remain available for at least twelve (12)
+     months after the date it initially became available, or at least six
+     (6) months after a subsequent version of that particular Modification
+     has been made available to.
+
+--- libmkv ---
+
+Authors:
+
+  Most of this code was taken from Mike Mastnev's matroska muxer included in
+  x264.
+
+  Glue provided by saintdev@gmail.com
+
+Copyright: 
+    Copyright (C) saintdev@gmail.com
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2, or (at your option)
+    any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+--- mpeg2dec ---
+
+Upstream Authors:
+
+    Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+    Michel Lespinasse <walken@zoy.org>
+
+    Bruno Barreyra <barreyra@ufl.edu> - build fixes
+    Gildas Bazin <gbazin@netcourrier.com> - mingw32 port
+    Alexander W. Chin <alexc@newt.phys.unsw.edu.au> - progressive_seq fix
+    Stephen Crowley <stephenc@dns2.digitalpassage.com> - build fixes
+    Didier Gautheron <dgautheron@magic.fr> - bug fixes
+    Ryan C. Gordon <icculus@lokigames.com> - SDL support
+    Peter Gubanov <peter@elecard.net.ru> - MMX IDCT scheduling
+    HÃ¥kan Hjort <d95hjort@dtek.chalmers.se> - Solaris fixes, mlib code
+    Nicolas Joly <njoly@pasteur.fr> - assorted bug fixes
+    Gerd Knorr <kraxel@goldbach.in-berlin.de> - Xv support
+    David I. Lehn <dlehn@vt.edu> - motion_comp mmx code
+    Olie Lho <ollie@sis.com.tw> - MMX yuv2rgb routine
+    David S. Miller <davem@redhat.com> - sparc VIS optimizations
+    Rick Niles <niles@scyld.com> - build fixes
+    Real Ouellet <realo@sympatico.ca> - g200 fixes
+    Bajusz Peter <hyp-x@inf.bme.hu> - motion comp fixes
+    Franck Sicard <Franck.Sicard@miniruth.solsoft.fr> - x11 fixes
+    Brion Vibber <brion@gizmo.usc.edu> - x11 fixes
+    Martin Vogt <mvogt@rhrk.uni-kl.de> - reentrancy fixes
+    Fredrik Vraalsen <vraalsen@cs.uiuc.edu> - general hackage and stuff
+
+mpeg2dec is Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
+            Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
+            Copyright (C) 2000-2003 Silicon Integrated System Corp.
+            Copyright (C) 2000-2003 Ryan C. Gordon <icculus@lokigames.com>
+            Copyright (C) 2000-2003 Dominik Schnitzer <aeneas@linuxvideo.org>
+            Copyright (C) 2003      Regis Duchesne <hpreg@zoy.org>
+            Copyright (C) 2003      David S. Miller <davem@redhat.com>
+            Copyright (C) 2003      Peter Gubanov <peter@elecard.net.ru>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2, or (at your option)
+    any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+    General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian systems, the complete text of the GNU General Public License can
+be found in `/usr/share/common-licenses/GPL'.
+
+--- libogg ---
+
+
+Upstream Author: Christopher Montgomery <monty@xiph.org>
+
+Copyright:
+Copyright (c) 2002-2004, Xiph.org Foundation
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+- Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+- Neither the name of the Xiph.Org Foundation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
diff --git a/pkg/linux/debian/docs b/pkg/linux/debian/docs
new file mode 100644 (file)
index 0000000..d65e594
--- /dev/null
@@ -0,0 +1,4 @@
+NEWS
+AUTHORS
+CREDITS
+THANKS
diff --git a/pkg/linux/debian/handbrake-cli.dirs b/pkg/linux/debian/handbrake-cli.dirs
new file mode 100644 (file)
index 0000000..415f082
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin
diff --git a/pkg/linux/debian/handbrake-cli.install b/pkg/linux/debian/handbrake-cli.install
new file mode 100644 (file)
index 0000000..0c81f0e
--- /dev/null
@@ -0,0 +1 @@
+usr/bin/HandBrakeCLI
diff --git a/pkg/linux/debian/handbrake-gtk.dirs b/pkg/linux/debian/handbrake-gtk.dirs
new file mode 100644 (file)
index 0000000..b2a3fb9
--- /dev/null
@@ -0,0 +1,4 @@
+/usr/share/icons
+/usr/bin/
+/usr/share/applications
+
diff --git a/pkg/linux/debian/handbrake-gtk.docs b/pkg/linux/debian/handbrake-gtk.docs
new file mode 100644 (file)
index 0000000..d4f4542
--- /dev/null
@@ -0,0 +1 @@
+#DOCS#
diff --git a/pkg/linux/debian/handbrake-gtk.install b/pkg/linux/debian/handbrake-gtk.install
new file mode 100644 (file)
index 0000000..21f11a3
--- /dev/null
@@ -0,0 +1,4 @@
+usr/bin/ghb
+usr/share/applications/*
+usr/share/icons/*
+#DOCS#
diff --git a/pkg/linux/debian/rules b/pkg/linux/debian/rules
new file mode 100755 (executable)
index 0000000..036aa3b
--- /dev/null
@@ -0,0 +1,87 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+else
+CROSS= --build $(DEB_BUILD_GNU_TYPE)
+endif
+
+PKGDESTDIR   = ../
+CONFIGURE    = ./configure
+BUILDDIR     = build
+FORCEVERSION = 
+
+$(BUILDDIR)/GNUmakefile: $(CONFIGURE)
+       dh_testdir
+       unset CFLAGS; unset CPPLAGS; unset CXXLAGS; $(CONFIGURE) --prefix=/usr
+
+build:  $(BUILDDIR)/GNUmakefile
+       dh_testdir
+       #We must build both the main project and the GTK project
+       unset CFLAGS ; unset CPPLAGS ; unset CXXLAGS; $(MAKE) -C $(BUILDDIR)
+
+clean: 
+       dh_testdir
+       dh_testroot
+
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_installdirs
+       $(MAKE) -C $(BUILDDIR) DESTDIR=$(CURDIR)/debian/tmp install
+
+# Build architecture-independent files here.
+binary-indep: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs -i
+       dh_installdocs -i
+       dh_install --sourcedir=debian/tmp -i
+       dh_icons -i
+       dh_desktop -i
+       dh_link -i
+       dh_compress -i
+       dh_fixperms -i
+       dh_installdeb -i
+       dh_gencontrol -i $(FORCEVERSION)
+       dh_md5sums -i
+       dh_builddeb --destdir=$(PKGDESTDIR) -i
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_install --sourcedir=debian/tmp -a
+       dh_installchangelogs -a
+       dh_installdocs -a
+       dh_installexamples -a
+       dh_installman -a
+       dh_link -a
+       dh_icons -a
+       dh_desktop -a
+       dh_strip -a
+       dh_compress -a
+       dh_fixperms -a
+       dh_installdeb -a
+       dh_shlibdeps -a
+       dh_gencontrol -a $(FORCEVERSION)
+       dh_md5sums -a
+       dh_builddeb -a --destdir=$(PKGDESTDIR) -- -Zbzip2
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install 
diff --git a/pkg/linux/module.defs b/pkg/linux/module.defs
new file mode 100644 (file)
index 0000000..8b91f2d
--- /dev/null
@@ -0,0 +1,22 @@
+PKG.deb.machine = `dpkg --print-architecture`
+PKG.rpm.machine = `rpm -E "%_target_cpu"`
+PKG.debian  = $(PKG.in/)linux/debian
+PKG.cli.deb = $(PKG.out/)$(HB.name)-$(HB.version)-Ubuntu_CLI_$(BUILD.machine).deb
+PKG.gui.deb = $(PKG.out/)$(HB.name)-$(HB.version)-Ubuntu_GUI_$(BUILD.machine).deb
+
+PKG.cli.tmp.deb = $(PKG.out/)handbrake-cli_$(HB.version)_$(PKG.deb.machine).deb
+PKG.gui.tmp.deb = $(PKG.out/)handbrake-gtk_$(HB.version)_$(PKG.deb.machine).deb
+
+PKG.cli.rpm  = $(PKG.out/)$(HB.name)-$(HB.version)-Fedora_CLI_$(BUILD.machine).rpm
+PKG.gui.rpm  = $(PKG.out/)$(HB.name)-$(HB.version)-Fedora_GUI_$(BUILD.machine).rpm
+RPM.out  = $(STAGE.out/)rpm
+RPM.out/ = $(STAGE.out/)rpm/
+RPMROOT.out  = $(PWD)/$(STAGE.out/)rpmroot
+RPMROOT.out/ = $(PWD)/$(STAGE.out/)rpmroot/
+
+###############################################################################
+
+BUILD.out += $(PKG.cli.deb)
+BUILD.out += $(PKG.gui.deb)
+BUILD.out += $(PKG.cli.rpm)
+BUILD.out += $(PKG.gui.rpm)
diff --git a/pkg/linux/module.rules b/pkg/linux/module.rules
new file mode 100644 (file)
index 0000000..c3346be
--- /dev/null
@@ -0,0 +1,32 @@
+pkg.create.deb:: pkg.create $(PKG.gui.deb) $(PKG.cli.deb)
+pkg.create.rpm:: pkg.create $(PKG.gui.rpm) $(PKG.cli.rpm)
+
+$(PKG.gui.rpm) $(PKG.cli.rpm): | $(dir $(PKG.gui.rpm) $(PKG.cli.rpm))
+$(PKG.gui.rpm) $(PKG.cli.rpm):
+       -$(MKDIR.exe) -p $(RPM.out/)SOURCES
+       -$(MKDIR.exe) -p $(RPM.out/)SPECS
+       -$(MKDIR.exe) -p $(RPM.out/)BUILD
+       -$(MKDIR.exe) -p $(RPM.out/)RPMS
+       -$(MKDIR.exe) -p $(RPM.out/)SRPMS
+       -$(MKDIR.exe) -p $(RPMROOT.out/)
+       $(CP.exe) $(GTK.src/)ghb.spec $(RPM.out/)SPECS
+       $(CP.exe) $(PKG.src.tar.bz2) $(RPM.out/)SOURCES
+       $(TAR.exe) -xf $(PKG.src.tar.bz2) -C $(RPM.out/)BUILD
+       rpmbuild --define="version $(HB.version)" --define="_topdir $(PWD)/$(RPM.out)" --buildroot $(RPMROOT.out) -ba $(GTK.src/)ghb.spec
+       $(CP.exe) $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name)-cli-$(HB.version)*.rpm $(PKG.cli.rpm)
+       $(CP.exe) $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name)-gui-$(HB.version)*.rpm $(PKG.gui.rpm)
+
+$(PKG.gui.deb): | $(dir $(PKG.gui.deb))
+$(PKG.gui.deb):
+       -rm $(SRC/)debian
+       ln -s $(PWD)/$(PKG.debian) $(SRC/)debian
+       fakeroot $(MAKE) -C $(SRC/) -f debian/rules clean
+       $(MAKE) BUILDDIR=$(PWD)/$(BUILD) CONFIGURE=configure -C $(SRC/) -f debian/rules build
+       echo $(PKG.out/)
+       fakeroot $(MAKE) FORCEVERSION="-- -v$(HB.version)" BUILDDIR=$(PWD)/$(BUILD) CONFIGURE=configure PKGDESTDIR=$(PWD)/$(PKG.out/) -C $(SRC/) -f debian/rules binary
+       $(MV.exe) $(PKG.gui.tmp.deb) $(PKG.gui.deb)
+
+$(PKG.cli.deb): | $(dir $(PKG.cli.deb))
+$(PKG.cli.deb): $(PKG.gui.deb)
+       $(MV.exe) $(PKG.cli.tmp.deb) $(PKG.cli.deb)
+
diff --git a/pkg/module.defs b/pkg/module.defs
new file mode 100644 (file)
index 0000000..97020d9
--- /dev/null
@@ -0,0 +1,30 @@
+$(eval $(call import.MODULE.defs,PKG,pkg))
+
+PKG.in/  = $(SRC/)pkg/
+PKG.out/ = $(BUILD/)pkg/
+
+PKG.src.tar.bz2 = $(PKG.out/)$(HB.name)-$(HB.version).tar.bz2
+
+STAGE.out/     = $(BUILD/)stage/
+STAGE.out.src/ = $(STAGE.out/)src/
+
+###############################################################################
+
+define STAGE.doc
+       $(MKDIR.exe) -p $(1)doc
+       $(CP.exe) $(SRC/)AUTHORS $(1)doc
+       $(CP.exe) $(SRC/)COPYING $(1)doc
+       $(CP.exe) $(SRC/)CREDITS $(1)doc
+       $(CP.exe) $(SRC/)NEWS $(1)doc
+       $(CP.exe) $(SRC/)THANKS $(1)doc
+       $(CP.exe) $(SRC/)TRANSLATIONS $(1)doc
+endef
+
+###############################################################################
+
+BUILD.out += $(PKG.src.tar.bz2)
+
+###############################################################################
+
+## include optional platform packaging
+-include $(SRC/)pkg/$(BUILD.system)/module.defs
diff --git a/pkg/module.rules b/pkg/module.rules
new file mode 100644 (file)
index 0000000..60457d2
--- /dev/null
@@ -0,0 +1,26 @@
+$(eval $(call import.MODULE.rules,PKG))
+
+###############################################################################
+
+.PHONY: pkg.create
+
+pkg.create:: $(PKG.src.tar.bz2)
+
+pkg.clean:
+       $(RM.exe) -fr $(STAGE.out/)
+       $(RM.exe) -fr $(PKG.out/)
+
+$(PKG.src.tar.bz2): | $(dir $(PKG.src.tar.bz2))
+$(PKG.src.tar.bz2): | $(STAGE.out.src/)
+       $(TAR.exe) cjf $@ -C $(STAGE.out.src/) .
+
+$(STAGE.out.src/):
+       svn export -r$(HB.repo.rev) $(HB.repo.url) $@/$(HB.name)-$(HB.version)
+       sed 's/\(self.rev.*=.*\)0/\1$(HB.repo.rev)/' \
+           $@/$(HB.name)-$(HB.version)/make/configure.py > $@/$(HB.name)-$(HB.version)/make/configure.py.tmp
+       $(MV.exe) $@/$(HB.name)-$(HB.version)/make/configure.py.tmp $@/$(HB.name)-$(HB.version)/make/configure.py
+
+###############################################################################
+
+## include optional platform packaging
+-include $(SRC/)pkg/$(BUILD.system)/module.rules
index ce5c63f..32ea30e 100755 (executable)
@@ -318,167 +318,74 @@ class Display
     end
     
     #Audio tracks
-    commandString << " -a "
-    commandString << hash["Audio1Track"].to_s
-    if hash["Audio2Track"]
-      commandString << "," << hash["Audio2Track"].to_s
-    end
-    if hash["Audio3Track"]
-      commandString << "," << hash["Audio3Track"].to_s
-    end
-    if hash["Audio4Track"]
-      commandString << "," << hash["Audio4Track"].to_s
-    end
-    
-    #Audio encoders
-    commandString << " -E "
-    case hash["Audio1Encoder"]
-    when /AC3 /
-      commandString << "ac3"
-    when /AAC/
-      commandString << "faac"
-    when /Vorbis/
-      commandString << "vorbis"
-    when /MP3/
-      commandString << "lame"
-    end
-    case hash["Audio2Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio3Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio4Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    
-    #Audio bit rate
-    commandString << " -B "
-    commandString << hash["Audio1Bitrate"]
-    if hash["Audio2Bitrate"]
-      if hash["Audio2Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio2Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio3Bitrate"]
-      if hash["Audio3Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio3Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio4Bitrate"]
-      if hash["Audio4Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio4Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
+    audioBitrates = ""
+    audioEncoders = ""
+    audioMixdowns = ""
+    audioSamplerates = ""
+    audioTracks = ""
+    audioTrackDRCs = ""
+    audioCount = hash["AudioList"].size
+    
+    hash["AudioList"].each do |audioTrack|
+      audioCount = audioCount - 1
 
-    #Audio sample rate
-    commandString << " -R "
-    commandString << hash["Audio1Samplerate"]
-    if hash["Audio2Samplerate"]
-      commandString << "," << hash["Audio2Samplerate"]
-    end
-    if hash["Audio3Samplerate"]
-      commandString << "," << hash["Audio3Samplerate"]
-    end
-    if hash["Audio4Samplerate"]
-      commandString << "," << hash["Audio4Samplerate"]
-    end
-    
-    #Audio Mixdown
-    commandString << " -6 "
-    case hash["Audio1Mixdown"]
-    when /Mono/
-      commandString << "mono"
-    when /Stereo/
-      commandString << "stereo"
-    when /Dolby Surround/
-      commandString << "dpl1"
-    when /Dolby Pro Logic II/
-      commandString << "dpl2"
-    when /discrete/
-      commandString << "6ch"
-    when /Passthru/
-      commandString << "auto"
-    end
-    
-    if hash["Audio2Mixdown"]
-      case hash["Audio2Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      #Bitrates
+      audioBitrates << audioTrack["AudioBitrate"]
+      
+      #Encoders
+      case audioTrack["AudioEncoder"]
+        when /AC3 /
+          audioEncoders << "ac3"
+        when /AAC/
+          audioEncoders << "faac"
+        when /Vorbis/
+          audioEncoders << "vorbis"
+        when /MP3/
+          audioEncoders << "lame"
       end
-    end
-    
-    if hash["Audio3Mixdown"]
-      case hash["Audio3Mixdown"]
+      
+      #Mixdowns
+      case audioTrack["AudioMixdown"]
       when /Mono/
-        commandString << ",mono"
+        audioMixdowns << "mono"
       when /Stereo/
-        commandString << ",stereo"
+        audioMixdowns << "stereo"
       when /Dolby Surround/
-        commandString << ",dpl1"
+        audioMixdowns << "dpl1"
       when /Dolby Pro Logic II/
-        commandString << ",dpl2"
+        audioMixdowns << "dpl2"
       when /discrete/
-        commandString << ",6ch"
+        audioMixdowns << "6ch"
       when /Passthru/
-        commandString << ",auto"
+        audioMixdowns << "auto"
       end
-    end
-    
-    if hash["Audio4Mixdown"]
-      case hash["Audio4Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      
+      #Samplerates
+      audioSamplerates << audioTrack["AudioSamplerate"]
+      
+      #Tracks
+      audioTracks << audioTrack["AudioTrack"].to_s
+      
+      #DRC
+      audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
+      
+      if audioCount > 0
+        audioBitrates << ","
+        audioEncoders << ","
+        audioMixdowns << ","
+        audioSamplerates << ","
+        audioTracks << ","
+        audioTrackDRCs << ","
       end
+      
     end
-    
+    commandString << " -a " << audioTracks
+    commandString << " -E " << audioEncoders
+    commandString << " -B " << audioBitrates
+    commandString << " -6 " << audioMixdowns
+    commandString << " -R " << audioSamplerates
+    commandString << " -D " << audioTrackDRCs
+        
     #Container
     commandString << " -f "
     case hash["FileFormat"]
@@ -566,9 +473,9 @@ class Display
     
     #Anamorphic
     if hash["PicturePAR"] == 1
-      commandString << " -p"
+      commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
-      commandString << " -P"
+      commandString << " --loose-anamorphic"
     end
 
     #Booleans
@@ -657,167 +564,73 @@ class Display
     end
     
     #Audio tracks
-    commandString << " -a "
-    commandString << hash["Audio1Track"].to_s
-    if hash["Audio2Track"]
-      commandString << "," << hash["Audio2Track"].to_s
-    end
-    if hash["Audio3Track"]
-      commandString << "," << hash["Audio3Track"].to_s
-    end
-    if hash["Audio4Track"]
-      commandString << "," << hash["Audio4Track"].to_s
-    end
-    
-    #Audio encoders
-    commandString << " -E "
-    case hash["Audio1Encoder"]
-    when /AC3/
-      commandString << "ac3"
-    when /AAC/
-      commandString << "faac"
-    when /Vorbis/
-      commandString << "vorbis"
-    when /MP3/
-      commandString << "lame"
-    end
-    case hash["Audio2Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio3Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio4Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
+    audioBitrates = ""
+    audioEncoders = ""
+    audioMixdowns = ""
+    audioSamplerates = ""
+    audioTracks = ""
+    audioTrackDRCs = ""
+    audioCount = hash["AudioList"].size
+    
+    hash["AudioList"].each do |audioTrack|
+      audioCount = audioCount - 1
 
-    #Audio bit rate
-    commandString << " -B "
-    commandString << hash["Audio1Bitrate"]
-    if hash["Audio2Bitrate"]
-      if hash["Audio2Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio2Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio3Bitrate"]
-      if hash["Audio3Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio3Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio4Bitrate"]
-      if hash["Audio4Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio4Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-
-    #Audio sample rate
-    commandString << " -R "
-    commandString << hash["Audio1Samplerate"]
-    if hash["Audio2Samplerate"]
-      commandString << "," << hash["Audio2Samplerate"]
-    end
-    if hash["Audio3Samplerate"]
-      commandString << "," << hash["Audio3Samplerate"]
-    end
-    if hash["Audio4Samplerate"]
-      commandString << "," << hash["Audio4Samplerate"]
-    end
-    
-    #Audio Mixdown
-    commandString << " -6 "
-    case hash["Audio1Mixdown"]
-    when /Mono/
-      commandString << "mono"
-    when /Stereo/
-      commandString << "stereo"
-    when /Dolby Surround/
-      commandString << "dpl1"
-    when /Dolby Pro Logic II/
-      commandString << "dpl2"
-    when /discrete/
-      commandString << "6ch"
-    when /Passthru/
-      commandString << "auto"
-    end
-    
-    if hash["Audio2Mixdown"]
-      case hash["Audio2Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      #Bitrates
+      audioBitrates << audioTrack["AudioBitrate"]
+      
+      #Encoders
+      case audioTrack["AudioEncoder"]
+        when /AC3 /
+          audioEncoders << "ac3"
+        when /AAC/
+          audioEncoders << "faac"
+        when /Vorbis/
+          audioEncoders << "vorbis"
+        when /MP3/
+          audioEncoders << "lame"
       end
-    end
-    
-    if hash["Audio3Mixdown"]
-      case hash["Audio3Mixdown"]
+      
+      #Mixdowns
+      case audioTrack["AudioMixdown"]
       when /Mono/
-        commandString << ",mono"
+        audioMixdowns << "mono"
       when /Stereo/
-        commandString << ",stereo"
+        audioMixdowns << "stereo"
       when /Dolby Surround/
-        commandString << ",dpl1"
+        audioMixdowns << "dpl1"
       when /Dolby Pro Logic II/
-        commandString << ",dpl2"
+        audioMixdowns << "dpl2"
       when /discrete/
-        commandString << ",6ch"
+        audioMixdowns << "6ch"
       when /Passthru/
-        commandString << ",auto"
+        audioMixdowns << "auto"
       end
-    end
-    
-    if hash["Audio4Mixdown"]
-      case hash["Audio4Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      
+      #Samplerates
+      audioSamplerates << audioTrack["AudioSamplerate"]
+      
+      #Tracks
+      audioTracks << audioTrack["AudioTrack"].to_s
+      
+      #DRC
+      audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
+      
+      if audioCount > 0
+        audioBitrates << ","
+        audioEncoders << ","
+        audioMixdowns << ","
+        audioSamplerates << ","
+        audioTracks << ","
+        audioTrackDRCs << ","
       end
+      
     end
-
+    commandString << " -a " << audioTracks
+    commandString << " -E " << audioEncoders
+    commandString << " -B " << audioBitrates
+    commandString << " -6 " << audioMixdowns
+    commandString << " -R " << audioSamplerates
+    commandString << " -D " << audioTrackDRCs
     
     #Container
     commandString << " -f "
@@ -905,9 +718,9 @@ class Display
 
     #Anamorphic
     if hash["PicturePAR"] == 1
-      commandString << " -p"
+      commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
-      commandString << " -P"
+      commandString << " --loose-anamorphic"
     end
     
     #Booleans
@@ -935,16 +748,20 @@ class Display
     commandString = "if (!strcmp(preset_name, \"" << hash["PresetName"] << "\"))\n{\n    "
     
     #Filename suffix
+    commandString << "if( !mux )\n    "
+    commandString << "{\n    "
+
     case hash["FileFormat"]
     when /MP4/
-      commandString << "mux = " << "HB_MUX_MP4;\n    "
+      commandString << "    mux = " << "HB_MUX_MP4;\n    "
     when /AVI/
-      commandString << "mux = " << "HB_MUX_AVI;\n    "
+      commandString << "    mux = " << "HB_MUX_AVI;\n    "
     when /OGM/
-      commandString << "mux = " << "HB_MUX_OGM;\n    "
+      commandString << "    mux = " << "HB_MUX_OGM;\n    "
     when /MKV/
-      commandString << "mux = " << "HB_MUX_MKV;\n    "
+      commandString << "    mux = " << "HB_MUX_MKV;\n    "
     end
+    commandString << "}\n    "
     
     #iPod MP4 atom
     if hash["Mp4iPodCompatible"].to_i == 1
@@ -992,185 +809,100 @@ class Display
     end
     
     #Audio tracks
+    audioBitrates = ""
+    audioEncoders = ""
+    audioMixdowns = ""
+    audioSamplerates = ""
+    audioTracks = ""
+    audioTrackDRCs = ""
+    audioCount = hash["AudioList"].size
+
+    hash["AudioList"].each do |audioTrack|
+      audioCount = audioCount - 1
+
+      #Bitrates
+      audioBitrates << audioTrack["AudioBitrate"]
+
+      #Encoders
+      case audioTrack["AudioEncoder"]
+        when /AC3 /
+          audioEncoders << "ac3"
+        when /AAC/
+          audioEncoders << "faac"
+        when /Vorbis/
+          audioEncoders << "vorbis"
+        when /MP3/
+          audioEncoders << "lame"
+      end
+
+      #Mixdowns
+      case audioTrack["AudioMixdown"]
+      when /Mono/
+        audioMixdowns << "mono"
+      when /Stereo/
+        audioMixdowns << "stereo"
+      when /Dolby Surround/
+        audioMixdowns << "dpl1"
+      when /Dolby Pro Logic II/
+        audioMixdowns << "dpl2"
+      when /discrete/
+        audioMixdowns << "6ch"
+      when /Passthru/
+        audioMixdowns << "auto"
+      end
+
+      #Samplerates
+      audioSamplerates << audioTrack["AudioSamplerate"]
+
+      #Tracks
+      audioTracks << audioTrack["AudioTrack"].to_s
+
+      #DRC
+      audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
+
+      if audioCount > 0
+        audioBitrates << ","
+        audioEncoders << ","
+        audioMixdowns << ","
+        audioSamplerates << ","
+        audioTracks << ","
+        audioTrackDRCs << ","
+      end
+
+    end
     commandString << "if( !atracks )\n    "
     commandString << "{\n    "
-    commandString << "    atracks = strdup(\""
-    commandString << hash["Audio1Track"].to_s
-    if hash["Audio2Track"]
-      commandString << "," << hash["Audio2Track"].to_s
-    end
-    if hash["Audio3Track"]
-      commandString << "," << hash["Audio3Track"].to_s
-    end
-    if hash["Audio4Track"]
-      commandString << "," << hash["Audio4Track"].to_s
-    end
+    commandString << "    atracks = strdup(\"" << audioTracks
     commandString << "\");\n    "
     commandString << "}\n    "
-    
-    # Audio bitrate
+
+    commandString << "if( !acodecs )\n    "
+    commandString << "{\n    "
+    commandString << "    acodecs = strdup(\"" << audioEncoders
+    commandString << "\");\n    "
+    commandString << "}\n    "
+
     commandString << "if( !abitrates )\n    "
     commandString << "{\n    "
-    commandString << "    abitrates = strdup(\""
-    if hash["Audio1Encoder"] != "AC3 Passthru"
-      commandString << hash["Audio1Bitrate"]
-    else
-      commandString << "auto"
-    end
-    if hash["Audio2Bitrate"]
-      if hash["Audio2Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio2Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio3Bitrate"]
-      if hash["Audio3Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio3Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio4Bitrate"]
-      if hash["Audio4Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio4Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
+    commandString << "    abitrates = strdup(\"" << audioBitrates
     commandString << "\");\n    "
     commandString << "}\n    "
-        
-    #Audio samplerate
-    commandString << "if( !arates )\n    "
+
+    commandString << "if( !mixdowns )\n    "
     commandString << "{\n    "
-    commandString << "    arates = strdup(\""
-    commandString << hash["Audio1Samplerate"]
-    if hash["Audio2Samplerate"]
-      commandString << "," << hash["Audio2Samplerate"]
-    end
-    if hash["Audio3Samplerate"]
-      commandString << "," << hash["Audio3Samplerate"]
-    end
-    if hash["Audio4Samplerate"]
-      commandString << "," << hash["Audio4Samplerate"]
-    end
+    commandString << "    mixdowns = strdup(\"" << audioMixdowns
     commandString << "\");\n    "
     commandString << "}\n    "
-      
-    #Audio encoder
-    commandString << "if( !acodecs )\n    "
+
+    commandString << "if( !arates )\n    "
     commandString << "{\n    "
-    commandString << "    acodecs = strdup(\""
-    case hash["Audio1Encoder"]
-    when /AC3/
-      commandString << "ac3"
-    when /AAC/
-      commandString << "faac"
-    when /Vorbis/
-      commandString << "vorbis"
-    when /MP3/
-      commandString << "lame"
-    end
-    case hash["Audio2Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio3Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio4Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
+    commandString << "    arates = strdup(\"" << audioSamplerates
     commandString << "\");\n    "
     commandString << "}\n    "
-    
-    #Audio mixdowns
-    commandString << "if( !mixdowns )\n    "
+
+    commandString << "if( !dynamic_range_compression )\n    "
     commandString << "{\n    "
-    commandString << "    mixdowns = strdup(\""
-    case hash["Audio1Mixdown"]
-    when /Mono/
-      commandString << "mono"
-    when /Stereo/
-      commandString << "stereo"
-    when /Dolby Surround/
-      commandString << "dpl1"
-    when /Dolby Pro Logic II/
-      commandString << "dpl2"
-    when /discrete/
-      commandString << "6ch"
-    when /Passthru/
-      commandString << "auto"
-    end
-    if hash["Audio2Mixdown"]
-      case hash["Audio2Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
-      end
-    end
-    if hash["Audio3Mixdown"]
-      case hash["Audio3Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
-      end
-    end
-    if hash["Audio4Mixdown"]
-      case hash["Audio4Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
-      end
-    end
+    commandString << "    dynamic_range_compression = strdup(\"" << audioTrackDRCs
     commandString << "\");\n    "
     commandString << "}\n    "
     
@@ -1250,9 +982,9 @@ class Display
     
     #Anamorphic
     if hash["PicturePAR"] == 1
-      commandString << "pixelratio = 1;\n    "
+      commandString << "anamorphic_mode = 1;\n    "
     elsif hash["PicturePAR"] == 2
-      commandString << "pixelratio = 2;\n    "
+      commandString << "anamorphic_mode = 2;\n    "
     end
     
     #Booleans
@@ -1342,166 +1074,73 @@ class Display
     end
     
     #Audio tracks
-    commandString << " -a "
-    commandString << hash["Audio1Track"].to_s
-    if hash["Audio2Track"]
-      commandString << "," << hash["Audio2Track"].to_s
-    end
-    if hash["Audio3Track"]
-      commandString << "," << hash["Audio3Track"].to_s
-    end
-    if hash["Audio4Track"]
-      commandString << "," << hash["Audio4Track"].to_s
-    end
-    
-    #Audio encoders
-    commandString << " -E "
-    case hash["Audio1Encoder"]
-    when /AC3/
-      commandString << "ac3"
-    when /AAC/
-      commandString << "faac"
-    when /Vorbis/
-      commandString << "vorbis"
-    when /MP3/
-      commandString << "lame"
-    end
-    case hash["Audio2Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio3Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
-    case hash["Audio4Encoder"]
-    when /AC3 /
-      commandString << ",ac3"
-    when /AAC/
-      commandString << ",faac"
-    when /Vorbis/
-      commandString << ",vorbis"
-    when /MP3/
-      commandString << ",lame"
-    end
+    audioBitrates = ""
+    audioEncoders = ""
+    audioMixdowns = ""
+    audioSamplerates = ""
+    audioTracks = ""
+    audioTrackDRCs = ""
+    audioCount = hash["AudioList"].size
+    
+    hash["AudioList"].each do |audioTrack|
+      audioCount = audioCount - 1
 
-    #Audio bit rate
-    commandString << " -B "
-    commandString << hash["Audio1Bitrate"]
-    if hash["Audio2Bitrate"]
-      if hash["Audio2Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio2Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio3Bitrate"]
-      if hash["Audio3Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio3Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-    if hash["Audio4Bitrate"]
-      if hash["Audio4Encoder"] != "AC3 Passthru"
-        commandString << "," << hash["Audio4Bitrate"]
-      else
-        commandString << "," << "auto"
-      end
-    end
-
-    #Audio sample rate
-    commandString << " -R "
-    commandString << hash["Audio1Samplerate"]
-    if hash["Audio2Samplerate"]
-      commandString << "," << hash["Audio2Samplerate"]
-    end
-    if hash["Audio3Samplerate"]
-      commandString << "," << hash["Audio3Samplerate"]
-    end
-    if hash["Audio4Samplerate"]
-      commandString << "," << hash["Audio4Samplerate"]
-    end
-    
-    #Audio Mixdown
-    commandString << " -6 "
-    case hash["Audio1Mixdown"]
-    when /Mono/
-      commandString << "mono"
-    when /Stereo/
-      commandString << "stereo"
-    when /Dolby Surround/
-      commandString << "dpl1"
-    when /Dolby Pro Logic II/
-      commandString << "dpl2"
-    when /discrete/
-      commandString << "6ch"
-    when /Passthru/
-      commandString << "auto"
-    end
-    
-    if hash["Audio2Mixdown"]
-      case hash["Audio2Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      #Bitrates
+      audioBitrates << audioTrack["AudioBitrate"]
+      
+      #Encoders
+      case audioTrack["AudioEncoder"]
+        when /AC3 /
+          audioEncoders << "ac3"
+        when /AAC/
+          audioEncoders << "faac"
+        when /Vorbis/
+          audioEncoders << "vorbis"
+        when /MP3/
+          audioEncoders << "lame"
       end
-    end
-    
-    if hash["Audio3Mixdown"]
-      case hash["Audio3Mixdown"]
+      
+      #Mixdowns
+      case audioTrack["AudioMixdown"]
       when /Mono/
-        commandString << ",mono"
+        audioMixdowns << "mono"
       when /Stereo/
-        commandString << ",stereo"
+        audioMixdowns << "stereo"
       when /Dolby Surround/
-        commandString << ",dpl1"
+        audioMixdowns << "dpl1"
       when /Dolby Pro Logic II/
-        commandString << ",dpl2"
+        audioMixdowns << "dpl2"
       when /discrete/
-        commandString << ",6ch"
+        audioMixdowns << "6ch"
       when /Passthru/
-        commandString << ",auto"
+        audioMixdowns << "auto"
       end
-    end
-    
-    if hash["Audio4Mixdown"]
-      case hash["Audio4Mixdown"]
-      when /Mono/
-        commandString << ",mono"
-      when /Stereo/
-        commandString << ",stereo"
-      when /Dolby Surround/
-        commandString << ",dpl1"
-      when /Dolby Pro Logic II/
-        commandString << ",dpl2"
-      when /discrete/
-        commandString << ",6ch"
-      when /Passthru/
-        commandString << ",auto"
+      
+      #Samplerates
+      audioSamplerates << audioTrack["AudioSamplerate"]
+      
+      #Tracks
+      audioTracks << audioTrack["AudioTrack"].to_s
+      
+      #DRC
+      audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
+      
+      if audioCount > 0
+        audioBitrates << ","
+        audioEncoders << ","
+        audioMixdowns << ","
+        audioSamplerates << ","
+        audioTracks << ","
+        audioTrackDRCs << ","
       end
+      
     end
+    commandString << " -a " << audioTracks
+    commandString << " -E " << audioEncoders
+    commandString << " -B " << audioBitrates
+    commandString << " -6 " << audioMixdowns
+    commandString << " -R " << audioSamplerates
+    commandString << " -D " << audioTrackDRCs
     
     #Container
     commandString << " -f "
@@ -1589,9 +1228,9 @@ class Display
     
     #Anamorphic
     if hash["PicturePAR"] == 1
-      commandString << " -p"
+      commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
-      commandString << " -P"
+      commandString << " --loose-anamorphic"
     end
     
     #Booleans
diff --git a/test/module.defs b/test/module.defs
new file mode 100644 (file)
index 0000000..e9bc7b7
--- /dev/null
@@ -0,0 +1,52 @@
+$(eval $(call import.MODULE.defs,TEST,test,LIBHB))
+$(eval $(call import.GCC,TEST))
+
+TEST.src/   = $(SRC/)test/
+TEST.build/ = $(BUILD/)test/
+
+TEST.c   = $(wildcard $(TEST.src/)*.c)
+TEST.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%.o,$(TEST.c))
+
+TEST.exe = $(BUILD/)$(call TARGET.exe,$(HB.name)CLI)
+
+TEST.libs = $(LIBHB.a) $(foreach n, \
+        a52 avcodec avformat avutil dca dvdnav dvdread faac faad mkv mpeg2 mp3lame mp4v2 \
+        ogg samplerate swscale theora vorbis vorbisenc x264, \
+        $(CONTRIB.build/)lib/lib$(n).a )
+
+TEST.install.exe = $(DESTDIR)$(PREFIX/)bin/$(notdir $(TEST.exe))
+
+ifeq (1,$(LIBICONV.enabled))
+    TEST.libs += $(CONTRIB.build/)lib/libiconv.a
+endif
+ifeq (1,$(BZIP2.enabled))
+    TEST.libs += $(CONTRIB.build/)lib/libbz2.a
+endif
+ifeq (1,$(ZLIB.enabled))
+    TEST.libs += $(CONTRIB.build/)lib/libz.a
+endif
+
+###############################################################################
+
+TEST.out += $(TEST.c.o)
+TEST.out += $(TEST.exe)
+
+BUILD.out += $(TEST.out)
+BUILD.out += $(TEST.install.exe)
+
+###############################################################################
+
+TEST.GCC.I += $(LIBHB.GCC.I)
+
+ifeq ($(BUILD.system),darwin)
+    TEST.GCC.f += IOKit CoreServices AudioToolbox
+    TEST.GCC.l += iconv bz2 z
+else ifeq ($(BUILD.system),linux)
+    TEST.GCC.l += bz2 z pthread dl m
+else ifeq ($(BUILD.system),solaris)
+    TEST.GCC.l += bz2 z pthread nsl socket
+else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+    TEST.libs += $(CONTRIB.build/)lib/libpthreadGC2.a
+    TEST.GCC.D += PTW32_STATIC_LIB
+    TEST.GCC.l += iberty ws2_32
+endif
diff --git a/test/module.rules b/test/module.rules
new file mode 100644 (file)
index 0000000..c510689
--- /dev/null
@@ -0,0 +1,36 @@
+$(eval $(call import.MODULE.rules,TEST))
+
+test.build: $(TEST.exe)
+
+$(TEST.exe): | $(dir $(TEST.exe))
+$(TEST.exe): $(TEST.c.o)
+       $(call TEST.GCC.EXE++,$@,$^ $(TEST.libs))
+
+$(TEST.c.o): $(LIBHB.a)
+$(TEST.c.o): | $(dir $(TEST.c.o))
+$(TEST.c.o): $(BUILD/)%.o: $(SRC/)%.c
+       $(call TEST.GCC.C_O,$@,$<)
+
+test.clean:
+       $(RM.exe) -f $(TEST.out)
+
+###############################################################################
+
+build: test.build
+clean: test.clean
+
+###############################################################################
+
+## skip install/uninstall on darwin
+ifneq ($(BUILD.system),darwin)
+
+test.install: | $(dir $(TEST.install.exe))
+       $(CP.exe) $(TEST.exe) $(TEST.install.exe)
+
+test.uninstall:
+       $(RM.exe) -f $(TEST.install.exe)
+
+install: test.install
+uninstall: test.uninstall
+
+endif
index cc3b6aa..f0c2a1a 100644 (file)
@@ -139,7 +139,7 @@ void hb_dispose_cell( hb_csv_cell_t *cell )
 static uint16_t hb_parse_character( hb_csv_file_t * file )
 {
     int byte;
-    uint16_t c;
+    uint16_t c = 0;
     int need_char = 1;
 
     if( file == NULL )
index 59cf0eb..ad21868 100644 (file)
@@ -9,11 +9,20 @@
 #include <sys/time.h>
 #include <time.h>
 #include <unistd.h>
+#include <inttypes.h>
+
+#if defined( __MINGW32__ )
+#include <conio.h>
+#endif
+
+#if defined( PTW32_STATIC_LIB )
+#include <pthread.h>
+#endif
 
 #include "hb.h"
 #include "parsecsv.h"
 
-#ifdef __APPLE_CC__
+#if defined( __APPLE_CC__ )
 #import <CoreServices/CoreServices.h>
 #include <IOKit/IOKitLib.h>
 #include <IOKit/storage/IOMedia.h>
 #endif
 
 /* Options */
-static int    debug       = HB_DEBUG_NONE;
+static int    debug       = HB_DEBUG_ALL;
 static int    update      = 0;
+static int    dvdnav      = 1;
 static char * input       = NULL;
 static char * output      = NULL;
 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    native_dub  = 0;
 static int    twoPass     = 0;
 static int    deinterlace           = 0;
 static char * deinterlace_opt       = 0;
@@ -57,9 +66,18 @@ static char * abitrates   = NULL;
 static char * acodecs     = NULL;
 static char * anames      = NULL;
 static int    default_acodec = HB_ACODEC_FAAC;
-static int    default_arate = 48000;
 static int    default_abitrate = 160;
-static int    sub         = 0;
+static int    audio_explicit = 0;
+static char ** subtracks   = NULL;
+static char ** subforce    = NULL;
+static char * subburn     = NULL;
+static char * subdefault  = NULL;
+static char ** srtfile     = NULL;
+static char ** srtcodeset  = NULL;
+static char ** srtoffset   = NULL;
+static char ** srtlang     = NULL;
+static int     srtdefault  = -1;
+static int    subtitle_scan = 0;
 static int    width       = 0;
 static int    height      = 0;
 static int    crop[4]     = { -1,-1,-1,-1 };
@@ -69,22 +87,24 @@ static float  vquality    = -1.0;
 static int    vbitrate    = 0;
 static int    size        = 0;
 static int    mux         = 0;
-static int    pixelratio  = 0;
-static int    loosePixelratio = 0;
+static int    anamorphic_mode  = 0;
 static int    modulus       = 0;
 static int    par_height    = 0;
 static int    par_width     = 0;
+static int    display_width = 0;
+static int    keep_display_aspect = 0;
+static int    itu_par       = 0;
+static int    angle = 0;
 static int    chapter_start = 0;
 static int    chapter_end   = 0;
 static int    chapter_markers = 0;
 static char * marker_file   = NULL;
-static int       crf                   = 1;
 static char      *x264opts             = NULL;
 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:weightb=0";
+static char * turbo_opts = "ref=1:subme=2: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;
@@ -92,6 +112,13 @@ static int    cfr           = 0;
 static int    mp4_optimize  = 0;
 static int    ipod_atom     = 0;
 static int    color_matrix  = 0;
+static int    preview_count = 10;
+static int    store_previews = 0;
+static int    start_at_preview = 0;
+static int64_t stop_at_pts    = 0;
+static int    stop_at_frame = 0;
+static char * stop_at_string = NULL;
+static char * stop_at_token = NULL;
 
 /* Exit cleanly on Ctrl-C */
 static volatile int die = 0;
@@ -114,7 +141,7 @@ static char* bsd_name_for_path(char *path);
 static int device_is_dvd(char *device);
 static io_service_t get_iokit_service( char *device );
 static int is_dvd_service( io_service_t service );
-static is_whole_media_service( io_service_t service );
+static int is_whole_media_service( io_service_t service );
 #endif
 
 /* Only print the "Muxing..." message once */
@@ -137,6 +164,14 @@ int main( int argc, char ** argv )
     int           build;
     char        * version;
 
+/* win32 _IOLBF (line-buffering) is the same as _IOFBF (full-buffering).
+ * force it to unbuffered otherwise informative output is not easily parsed.
+ */
+#if defined( _WIN32 ) || defined( __MINGW32__ )
+    setvbuf( stdout, NULL, _IONBF, 0 );
+    setvbuf( stderr, NULL, _IONBF, 0 );
+#endif
+
     audios = hb_list_init();
 
     /* Parse command line */
@@ -146,15 +181,21 @@ int main( int argc, char ** argv )
         return 1;
     }
 
+#if defined( PTW32_STATIC_LIB )
+    pthread_win32_process_attach_np();
+    pthread_win32_thread_attach_np();
+#endif
+
     /* Register our error handler */
     hb_register_error_handler(&hb_cli_error_handler);
 
     /* Init libhb */
     h = hb_init( debug, update );
+    hb_dvd_set_dvdnav( dvdnav );
 
     /* Show version */
-    fprintf( stderr, "HandBrake %s (%d) - http://handbrake.fr/\n",
-             hb_get_version( h ), hb_get_build( h ) );
+    fprintf( stderr, "%s - %s - %s\n",
+             HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
 
     /* Check for update */
     if( update )
@@ -196,12 +237,35 @@ int main( int argc, char ** argv )
          */
         titleindex = 0;
     }
-    hb_scan( h, input, titleindex );
+
+    hb_scan( h, input, titleindex, preview_count, store_previews );
 
     /* Wait... */
     while( !die )
     {
-#if !defined(SYS_BEOS)
+#if defined( __MINGW32__ )
+        if( _kbhit() ) {
+            switch( _getch() )
+            {
+                case 0x03: /* ctrl-c */
+                case 'q':
+                    fprintf( stdout, "\nEncoding Quit by user command\n" );
+                    die = 1;
+                    break;
+                case 'p':
+                    fprintf( stdout, "\nEncoding Paused by user command, 'r' to resume\n" );
+                    hb_pause( h );
+                    break;
+                case 'r':
+                    hb_resume( h );
+                    break;
+                case 'h':
+                    ShowCommands();
+                    break;
+            }
+        }
+        hb_snooze( 200 );
+#elif !defined(SYS_BEOS)
         fd_set         fds;
         struct timeval tv;
         int            ret;
@@ -286,9 +350,15 @@ int main( int argc, char ** argv )
        if( x264opts ) free (x264opts );
        if( x264opts2 ) free (x264opts2 );
     if (preset_name) free (preset_name);
+    if( stop_at_string ) free( stop_at_string );
 
     fprintf( stderr, "HandBrake has exited.\n" );
 
+#if defined( PTW32_STATIC_LIB )
+    pthread_win32_thread_detach_np();
+    pthread_win32_process_detach_np();
+#endif
+
     return 0;
 }
 
@@ -304,7 +374,6 @@ static void ShowCommands()
 static void PrintTitleInfo( hb_title_t * title )
 {
     hb_chapter_t  * chapter;
-    hb_audio_config_t    * audio;
     hb_subtitle_t * subtitle;
     int i;
 
@@ -312,10 +381,14 @@ static void PrintTitleInfo( hb_title_t * title )
     fprintf( stderr, "  + vts %d, ttn %d, cells %d->%d (%d blocks)\n",
              title->vts, title->ttn, title->cell_start, title->cell_end,
              title->block_count );
+    if (dvdnav)
+        fprintf( stderr, "  + angle(s) %d\n", title->angle_count );
     fprintf( stderr, "  + duration: %02d:%02d:%02d\n",
              title->hours, title->minutes, title->seconds );
-    fprintf( stderr, "  + size: %dx%d, aspect: %.2f, %.3f fps\n",
+    fprintf( stderr, "  + size: %dx%d, pixel aspect: %d/%d, display aspect: %.2f, %.3f fps\n",
              title->width, title->height,
+             title->pixel_aspect_width,
+             title->pixel_aspect_height,
              (float) title->aspect,
              (float) title->rate / title->rate_base );
     fprintf( stderr, "  + autocrop: %d/%d/%d/%d\n", title->crop[0],
@@ -336,20 +409,29 @@ static void PrintTitleInfo( hb_title_t * title )
         audio = hb_list_audio_config_item( title->list_audio, i );
         if( ( audio->in.codec == HB_ACODEC_AC3 ) || ( audio->in.codec == HB_ACODEC_DCA) )
         {
-            fprintf( stderr, "    + %d, %s, %dHz, %dbps\n", i + 1,
-                     audio->lang.description, audio->in.samplerate, audio->in.bitrate );
+            fprintf( stderr, "    + %d, %s (iso639-2: %s), %dHz, %dbps\n", 
+                     i + 1,
+                     audio->lang.description, 
+                     audio->lang.iso639_2,
+                     audio->in.samplerate, 
+                     audio->in.bitrate );
         }
         else
         {
-            fprintf( stderr, "    + %d, %s\n", i + 1, audio->lang.description );
+            fprintf( stderr, "    + %d, %s (iso639-2: %s)\n", 
+                     i + 1, 
+                     audio->lang.description,
+                     audio->lang.iso639_2 );
         }
     }
     fprintf( stderr, "  + subtitle tracks:\n" );
     for( i = 0; i < hb_list_count( title->list_subtitle ); i++ )
     {
         subtitle = hb_list_item( title->list_subtitle, i );
-        fprintf( stderr, "    + %d, %s (iso639-2: %s)\n", i + 1, subtitle->lang,
-            subtitle->iso639_2);
+        fprintf( stderr, "    + %d, %s (iso639-2: %s) (%s)\n", 
+                 i + 1, subtitle->lang,
+                 subtitle->iso639_2,
+                 (subtitle->format == TEXTSUB) ? "Text" : "Bitmap");
     }
 
     if(title->detected_interlacing)
@@ -360,6 +442,24 @@ static void PrintTitleInfo( hb_title_t * title )
 
 }
 
+static int test_sub_list( char ** list, char * needle, int pos )
+{
+    int i;
+
+    if ( list == NULL || needle == NULL )
+        return 0;
+
+    if ( list[0] == NULL && pos == 1 )
+        return 1;
+
+    for ( i = 0; list[i] != NULL; i++ )
+    {
+        if ( strcasecmp( list[i], needle ) == 0 )
+            return i + 1;
+    }
+    return 0;
+}
+
 static int HandleEvents( hb_handle_t * h )
 {
     hb_state_t s;
@@ -388,6 +488,7 @@ static int HandleEvents( hb_handle_t * h )
             hb_title_t * title;
             hb_job_t   * job;
             int i;
+            int sub_burned = 0;
 
             /* Audio argument string parsing variables */
             int acodec = 0;
@@ -406,8 +507,8 @@ static int HandleEvents( hb_handle_t * h )
                 die = 1;
                 break;
             }
-           if( longest_title )
-           {
+               if( longest_title )
+               {
                 int i;
                 int longest_title_idx=0;
                 int longest_title_pos=-1;
@@ -462,7 +563,7 @@ static int HandleEvents( hb_handle_t * h )
 
             PrintTitleInfo( title );
 
-            if( chapter_start && chapter_end )
+            if( chapter_start && chapter_end && !stop_at_pts && !start_at_preview && !stop_at_frame )
             {
                 job->chapter_start = MAX( job->chapter_start,
                                           chapter_start );
@@ -472,48 +573,62 @@ static int HandleEvents( hb_handle_t * h )
                                           job->chapter_end );
             }
 
+            if ( angle )
+            {
+                job->angle = angle;
+            }
+
             if (preset)
             {
                 fprintf( stderr, "+ Using preset: %s", preset_name);
 
                 if (!strcmp(preset_name, "Universal"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     vcodec = HB_VCODEC_X264;
-                    job->vquality = 0.589999973773956;
-                    job->crf = 1;
+                    job->vquality = 20.0;
                     if( !atracks )
                     {
                         atracks = strdup("1,1");
                     }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac,ac3");
+                    }
                     if( !abitrates )
                     {
-                        abitrates = strdup("160,auto");
+                        abitrates = strdup("160,160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("48,Auto");
+                        mixdowns = strdup("dpl2,auto");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac,ac3");
+                        arates = strdup("48,Auto");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2,auto");
+                        dynamic_range_compression = strdup("0.0,0.0");
                     }
                     maxWidth = 720;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1");
+                        x264opts = strdup("cabac=0:ref=2:me=umh:bframes=0:8x8dct=0:trellis=0:subme=6");
                     }
-                    pixelratio = 2;
+                    anamorphic_mode = 2;
                     job->chapter_markers = 1;
                 }
 
                 if (!strcmp(preset_name, "iPod"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
                     job->vbitrate = 700;
@@ -521,537 +636,353 @@ static int HandleEvents( hb_handle_t * h )
                     {
                         atracks = strdup("1");
                     }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac");
+                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("48");
+                        mixdowns = strdup("dpl2");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac");
+                        arates = strdup("48");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0");
                     }
                     maxWidth = 320;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1");
+                        x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0");
                     }
                     job->chapter_markers = 1;
                 }
 
                 if (!strcmp(preset_name, "iPhone & iPod Touch"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     vcodec = HB_VCODEC_X264;
-                    job->vquality = 0.589999973773956;
-                    job->crf = 1;
+                    job->vquality = 20.0;
                     if( !atracks )
                     {
                         atracks = strdup("1");
                     }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac");
+                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("128");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("48");
+                        mixdowns = strdup("dpl2");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac");
+                        arates = strdup("48");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0");
                     }
                     maxWidth = 480;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1");
+                        x264opts = strdup("cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0");
                     }
                     job->chapter_markers = 1;
                 }
 
                 if (!strcmp(preset_name, "AppleTV"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     job->largeFileSize = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->vquality = 0.589999973773956;
-                    job->crf = 1;
+                    job->vquality = 20.0;
                     if( !atracks )
                     {
                         atracks = strdup("1,1");
                     }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("160,auto");
-                    }
-                    if( !arates )
-                    {
-                        arates = strdup("48,Auto");
-                    }
                     if( !acodecs )
                     {
                         acodecs = strdup("faac,ac3");
                     }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("dpl2,auto");
-                    }
-                    maxWidth = 960;
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all");
-                    }
-                    pixelratio = 2;
-                    job->chapter_markers = 1;
-                }
-
-                if (!strcmp(preset_name, "QuickTime"))
-                {
-                    mux = HB_MUX_MP4;
-                    vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1800;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
                     if( !abitrates )
                     {
-                        abitrates = strdup("160");
-                    }
-                    if( !arates )
-                    {
-                        arates = strdup("Auto");
-                    }
-                    if( !acodecs )
-                    {
-                        acodecs = strdup("faac");
+                        abitrates = strdup("160,160");
                     }
                     if( !mixdowns )
                     {
-                        mixdowns = strdup("dpl2");
-                    }
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("ref=3:mixed-refs:bframes=3:weightb:direct=auto:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip=1:psy-rd=1,1");
-                    }
-                    pixelratio = 1;
-                    job->chapter_markers = 1;
-                    twoPass = 1;
-                    turbo_opts_enabled = 1;
-                }
-
-                if (!strcmp(preset_name, "AppleTV Legacy"))
-                {
-                    mux = HB_MUX_MP4;
-                    job->largeFileSize = 1;
-                    vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 2500;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1,1");
-                    }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("160,auto");
+                        mixdowns = strdup("dpl2,auto");
                     }
                     if( !arates )
                     {
                         arates = strdup("48,Auto");
                     }
-                    if( !acodecs )
+                    if( !dynamic_range_compression )
                     {
-                        acodecs = strdup("faac,ac3");
-                    }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("dpl2,auto");
+                        dynamic_range_compression = strdup("0.0,0.0");
                     }
+                    maxWidth = 960;
                     if( !x264opts )
                     {
-                        x264opts = strdup("bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0");
+                        x264opts = strdup("cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0");
                     }
-                    pixelratio = 1;
+                    anamorphic_mode = 2;
                     job->chapter_markers = 1;
                 }
 
-                if (!strcmp(preset_name, "iPhone Legacy"))
+                if (!strcmp(preset_name, "Normal"))
                 {
-                    mux = HB_MUX_MP4;
-                    job->ipod_atom = 1;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 960;
+                    job->vquality = 20.0;
                     if( !atracks )
                     {
                         atracks = strdup("1");
                     }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("128");
-                    }
-                    if( !arates )
-                    {
-                        arates = strdup("48");
-                    }
                     if( !acodecs )
                     {
                         acodecs = strdup("faac");
                     }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("dpl2");
-                    }
-                    maxWidth = 480;
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:trellis=1");
-                    }
-                    job->chapter_markers = 1;
-                }
-
-                if (!strcmp(preset_name, "iPod Legacy"))
-                {
-                    mux = HB_MUX_MP4;
-                    job->ipod_atom = 1;
-                    vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1500;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("48");
+                        mixdowns = strdup("dpl2");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac");
+                        arates = strdup("48");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0");
                     }
-                    maxWidth = 640;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1");
+                        x264opts = strdup("ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0");
                     }
+                    anamorphic_mode = 1;
                     job->chapter_markers = 1;
                 }
 
-                if (!strcmp(preset_name, "Normal"))
+                if (!strcmp(preset_name, "High Profile"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1500;
+                    job->vquality = 20.0;
                     if( !atracks )
                     {
-                        atracks = strdup("1");
+                        atracks = strdup("1,1");
+                    }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac,ac3");
                     }
                     if( !abitrates )
                     {
-                        abitrates = strdup("160");
+                        abitrates = strdup("160,160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("Auto");
+                        mixdowns = strdup("dpl2,auto");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac");
+                        arates = strdup("48,Auto");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0,0.0");
                     }
                     if( !x264opts )
                     {
-                        x264opts = strdup("ref=2:bframes=2:me=umh");
+                        x264opts = strdup("b-adapt=2:rc-lookahead=50");
                     }
-                    pixelratio = 1;
+                    detelecine = 1;
+                    decomb = 1;
+                    anamorphic_mode = 2;
                     job->chapter_markers = 1;
-                    twoPass = 1;
-                    turbo_opts_enabled = 1;
                 }
 
                 if (!strcmp(preset_name, "Classic"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
                     job->vbitrate = 1000;
                     if( !atracks )
                     {
                         atracks = strdup("1");
                     }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("160");
-                    }
-                    if( !arates )
-                    {
-                        arates = strdup("Auto");
-                    }
                     if( !acodecs )
                     {
                         acodecs = strdup("faac");
                     }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("dpl2");
-                    }
-                }
-
-                if (!strcmp(preset_name, "Animation"))
-                {
-                    mux = HB_MUX_MKV;
-                    vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1000;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("160");
                     }
-                    if( !arates )
-                    {
-                        arates = strdup("Auto");
-                    }
-                    if( !acodecs )
-                    {
-                        acodecs = strdup("faac");
-                    }
                     if( !mixdowns )
                     {
                         mixdowns = strdup("dpl2");
                     }
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("ref=5:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2:psy-rd=1,1:subme=9");
-                    }
-                    detelecine = 1;
-                    decomb = 1;
-                    pixelratio = 1;
-                    job->chapter_markers = 1;
-                    twoPass = 1;
-                    turbo_opts_enabled = 1;
-                }
-
-                if (!strcmp(preset_name, "Constant Quality Rate"))
-                {
-                    mux = HB_MUX_MKV;
-                    vcodec = HB_VCODEC_X264;
-                    job->vquality = 0.600000023841858;
-                    job->crf = 1;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("auto");
-                    }
                     if( !arates )
                     {
-                        arates = strdup("Auto");
+                        arates = strdup("48");
                     }
-                    if( !acodecs )
+                    if( !dynamic_range_compression )
                     {
-                        acodecs = strdup("ac3");
+                        dynamic_range_compression = strdup("0.0");
                     }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("auto");
-                    }
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all:8x8dct:me=umh:subme=9:psy-rd=1,1");
-                    }
-                    pixelratio = 1;
-                    job->chapter_markers = 1;
                 }
 
-                if (!strcmp(preset_name, "Film"))
+                if (!strcmp(preset_name, "AppleTV Legacy"))
                 {
-                    mux = HB_MUX_MKV;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
+                    job->largeFileSize = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1800;
+                    job->vbitrate = 2500;
                     if( !atracks )
                     {
-                        atracks = strdup("1");
+                        atracks = strdup("1,1");
+                    }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac,ac3");
                     }
                     if( !abitrates )
                     {
-                        abitrates = strdup("auto");
+                        abitrates = strdup("160,160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("Auto");
+                        mixdowns = strdup("dpl2,auto");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("ac3");
+                        arates = strdup("48,Auto");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("auto");
+                        dynamic_range_compression = strdup("0.0,0.0");
                     }
                     if( !x264opts )
                     {
-                        x264opts = strdup("ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1");
+                        x264opts = strdup("ref=1:subme=5:me=umh:no-fast-pskip=1:cabac=0:weightb=0:8x8dct=0:trellis=0");
                     }
-                    pixelratio = 1;
+                    anamorphic_mode = 1;
                     job->chapter_markers = 1;
-                    twoPass = 1;
-                    turbo_opts_enabled = 1;
                 }
 
-                if (!strcmp(preset_name, "Television"))
+                if (!strcmp(preset_name, "iPhone Legacy"))
                 {
-                    mux = HB_MUX_MKV;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
+                    job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 1300;
+                    job->vbitrate = 960;
                     if( !atracks )
                     {
                         atracks = strdup("1");
                     }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("160");
-                    }
-                    if( !arates )
-                    {
-                        arates = strdup("Auto");
-                    }
                     if( !acodecs )
                     {
                         acodecs = strdup("faac");
                     }
-                    if( !mixdowns )
-                    {
-                        mixdowns = strdup("dpl2");
-                    }
-                    if( !x264opts )
-                    {
-                        x264opts = strdup("ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip=1:psy-rd=1,1");
-                    }
-                    detelecine = 1;
-                    decomb = 1;
-                    pixelratio = 1;
-                    job->chapter_markers = 1;
-                    twoPass = 1;
-                    turbo_opts_enabled = 1;
-                }
-
-                if (!strcmp(preset_name, "PSP"))
-                {
-                    mux = HB_MUX_MP4;
-                    job->vbitrate = 1024;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("128");
                     }
-                    if( !arates )
-                    {
-                        arates = strdup("48");
-                    }
-                    if( !acodecs )
-                    {
-                        acodecs = strdup("faac");
-                    }
                     if( !mixdowns )
                     {
                         mixdowns = strdup("dpl2");
                     }
-                    maxWidth = 368;
-                    maxHeight = 208;
-                    job->chapter_markers = 1;
-                }
-
-                if (!strcmp(preset_name, "PS3"))
-                {
-                    mux = HB_MUX_MP4;
-                    vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 2500;
-                    if( !atracks )
-                    {
-                        atracks = strdup("1");
-                    }
-                    if( !abitrates )
-                    {
-                        abitrates = strdup("160");
-                    }
                     if( !arates )
                     {
                         arates = strdup("48");
                     }
-                    if( !acodecs )
-                    {
-                        acodecs = strdup("faac");
-                    }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0");
                     }
-                    job->crop[0] = 0;
-                    job->crop[1] = 0;
-                    job->crop[2] = 0;
-                    job->crop[4] - 0;
+                    maxWidth = 480;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=41:me=umh");
+                        x264opts = strdup("level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:subme=6:8x8dct=0:trellis=0");
                     }
-                    pixelratio = 1;
+                    job->chapter_markers = 1;
                 }
 
-                if (!strcmp(preset_name, "Xbox 360"))
+                if (!strcmp(preset_name, "iPod Legacy"))
                 {
-                    mux = HB_MUX_MP4;
+                    if( !mux )
+                    {
+                        mux = HB_MUX_MP4;
+                    }
+                    job->ipod_atom = 1;
                     vcodec = HB_VCODEC_X264;
-                    job->vbitrate = 2000;
+                    job->vbitrate = 1500;
                     if( !atracks )
                     {
                         atracks = strdup("1");
                     }
+                    if( !acodecs )
+                    {
+                        acodecs = strdup("faac");
+                    }
                     if( !abitrates )
                     {
                         abitrates = strdup("160");
                     }
-                    if( !arates )
+                    if( !mixdowns )
                     {
-                        arates = strdup("48");
+                        mixdowns = strdup("dpl2");
                     }
-                    if( !acodecs )
+                    if( !arates )
                     {
-                        acodecs = strdup("faac");
+                        arates = strdup("48");
                     }
-                    if( !mixdowns )
+                    if( !dynamic_range_compression )
                     {
-                        mixdowns = strdup("dpl2");
+                        dynamic_range_compression = strdup("0.0");
                     }
+                    maxWidth = 640;
                     if( !x264opts )
                     {
-                        x264opts = strdup("level=40:ref=2:mixed-refs:bframes=3:weightb:subme=9:direct=auto:b-pyramid:me=umh:analyse=all:no-fast-pskip:filter=-2,-1");
-                    }
-                    pixelratio = 1;
+                        x264opts = strdup("level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:subme=6:8x8dct=0:trellis=0");
                     }
+                    job->chapter_markers = 1;
+                }
             }
 
                        if ( chapter_markers )
@@ -1129,38 +1060,13 @@ static int HandleEvents( hb_handle_t * h )
 
             job->deinterlace = deinterlace;
             job->grayscale   = grayscale;
-            if (loosePixelratio)
-            {
-                job->pixel_ratio = 2;
-                if (modulus)
-                {
-                    job->modulus = modulus;
-                }
-                if( par_width && par_height )
-                {
-                    job->pixel_ratio = 3;
-                    job->pixel_aspect_width = par_width;
-                    job->pixel_aspect_height = par_height;
-                }
-            }
-            else
-            {
-                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( !vrate )
-                {
-                    /* No framerate specified, so using same as source.
-                       That means VFR, so set detelecine up to drop frames. */
-                           job->vfr = 1;
-                }
             }
             if( decomb )
             {
@@ -1183,31 +1089,151 @@ static int HandleEvents( hb_handle_t * h )
                 hb_list_add( job->filters, &hb_filter_denoise );
             }
 
-            if( width && height )
+            switch( anamorphic_mode )
             {
-                job->width  = width;
-                job->height = height;
-            }
-            else if( width )
-            {
-                job->width = width;
-                hb_fix_aspect( job, HB_KEEP_WIDTH );
-            }
-            else if( height && !loosePixelratio)
-            {
-                job->height = height;
-                hb_fix_aspect( job, HB_KEEP_HEIGHT );
-            }
-            else if( !width && !height && !pixelratio && !loosePixelratio )
-            {
-                hb_fix_aspect( job, HB_KEEP_WIDTH );
-            }
-            else if (!width && loosePixelratio)
-            {
-                /* Default to full width when one isn't specified for loose anamorphic */
-                job->width = title->width - job->crop[2] - job->crop[3];
-                /* The height will be thrown away in hb.c but calculate it anyway */
-                hb_fix_aspect( job, HB_KEEP_WIDTH );
+                case 0: // Non-anamorphic
+                    
+                    if( width && height )
+                    {
+                        job->width  = width;
+                        job->height = height;
+                    }
+                    else if( width )
+                    {
+                        job->width = width;
+                        hb_fix_aspect( job, HB_KEEP_WIDTH );
+                    }
+                    else if( height )
+                    {
+                        job->height = height;
+                        hb_fix_aspect( job, HB_KEEP_HEIGHT );
+                    }
+                    else if( !width && !height )
+                    {
+                        hb_fix_aspect( job, HB_KEEP_WIDTH );
+                    }
+
+                break;
+                
+                case 1: // Strict anammorphic
+                    job->anamorphic.mode = anamorphic_mode;
+                break;
+                
+                case 2: // Loose anamorphic
+                    job->anamorphic.mode = 2;
+                    
+                    if (modulus)
+                    {
+                        job->anamorphic.modulus = modulus;
+                    }
+                    
+                    if( itu_par )
+                    {
+                        job->anamorphic.itu_par = itu_par;
+                    }
+                    
+                    if( width )
+                    {
+                        job->width = width;
+                    }
+                    else if( !width && !height )
+                    {
+                        /* Default to full width when one isn't specified for loose anamorphic */
+                        job->width = title->width - job->crop[2] - job->crop[3];
+                    }
+                    
+                break;
+                
+                case 3: // Custom Anamorphic 3: Power User Jamboree 
+                    job->anamorphic.mode = 3;
+                    
+                    if (modulus)
+                    {
+                        job->anamorphic.modulus = modulus;
+                    }
+                    
+                    if( itu_par )
+                    {
+                        job->anamorphic.itu_par = itu_par;
+                    }
+                    
+                    if( par_width && par_height )
+                    {
+                        job->anamorphic.par_width = par_width;
+                        job->anamorphic.par_height = par_height;
+                    }
+                    
+                    if( keep_display_aspect )
+                    {
+                        job->anamorphic.keep_display_aspect = 1;
+                        
+                        /* First, what *is* the display aspect? */
+                        int cropped_width = title->width - job->crop[2] - job->crop[3];
+                        int cropped_height = title->height - job->crop[0] - job->crop[1];
+                        
+                        /* XXX -- I'm assuming people want to keep the source
+                           display AR even though they might have already
+                           asked for ITU values instead. */
+                        float source_display_width = (float)cropped_width *
+                            (float)title->pixel_aspect_width / (float)title->pixel_aspect_height;
+                        float display_aspect = source_display_width / (float)cropped_height;
+                        /* When keeping display aspect, we have to rank some values
+                           by priority in order to consistently handle situations
+                           when more than one might be specified by default.
+                           
+                           * First off, PAR gets ignored. (err make this reality)
+                           * Height will be respected over all other settings,
+                           * If it isn't set, display_width will be followed.
+                           * If it isn't set, width will be followed.          */
+                        if( height )
+                        {
+                            /* We scale the display width to the new height */
+                            display_width = (int)( (double)height * display_aspect );
+                        }
+                        else if( display_width )
+                        {
+                            /* We scale the height to the new display width */
+                            height = (int)( (double)display_width / display_aspect );
+                        }
+                    }
+                    
+                    if( display_width )
+                    {
+                        /* Adjust the PAR to create the new display width
+                           from the default job width. */
+                        job->anamorphic.dar_width = display_width;
+                        
+                        job->anamorphic.dar_height = height ?
+                                                        height :
+                                                        title->height - job->crop[0] - job->crop[1];
+                    }
+                    
+                    if( width && height )
+                    {
+                        /* Use these storage dimensions */
+                        job->width  = width;
+                        job->height = height;
+                    }
+                    else if( width )
+                    {
+                        /* Use just this storage width */
+                        job->width = width;
+                        job->height = title->height - job->crop[0] - job->crop[1];
+                    }
+                    else if( height )
+                    {
+                        /* Use just this storage height. */
+                        job->height = height;
+                        job->width = title->width - job->crop[2] - job->crop[3];
+                    }
+                    else if( !width && !height )
+                    {
+                        /* Assume source dimensions after cropping. */
+                        job->width = title->width - job->crop[2] - job->crop[3];
+                        job->height = title->height - job->crop[0] - job->crop[1];
+                    }
+                    
+                break;
             }
 
             if( vquality >= 0.0 && ( ( vquality <= 1.0 ) || ( vcodec == HB_VCODEC_X264 ) || (vcodec == HB_VCODEC_FFMPEG) ) )
@@ -1234,10 +1260,18 @@ static int HandleEvents( hb_handle_t * h )
             }
             if( vrate )
             {
-                job->cfr = 1;
+                job->cfr = cfr;
                 job->vrate = 27000000;
                 job->vrate_base = vrate;
             }
+            else if ( cfr )
+            {
+                // cfr or pfr flag with no rate specified implies
+                // use the title rate.
+                job->cfr = cfr;
+                job->vrate = title->rate;
+                job->vrate_base = title->rate_base;
+            }
 
             /* Grab audio tracks */
             if( atracks )
@@ -1292,8 +1326,59 @@ static int HandleEvents( hb_handle_t * h )
             }
 
             /* Parse audio tracks */
-            if( hb_list_count(audios) == 0 )
+            if( native_language && native_dub )
             {
+                if( hb_list_count( audios ) == 0 || !audio_explicit )
+                {
+                    for( i = 0; i < hb_list_count( title->list_audio ); i++ )
+                    {
+                        char audio_lang[4];
+                        int track = i;
+                        
+                        audio = hb_list_audio_config_item( title->list_audio, i );
+                        
+                        strncpy( audio_lang, audio->lang.iso639_2, sizeof( audio_lang ) );
+                        
+                        if( strncasecmp( native_language, audio_lang, 
+                                         sizeof( audio_lang ) ) == 0 &&
+                            audio->lang.type != 3 && // Directors 1
+                            audio->lang.type != 4)   // Directors 2
+                        {
+                            /*
+                             * Matched an audio to our native language - use it.
+                             * Replace any existing audio tracks that a preset may
+                             * have put here.
+                             */
+                            if( hb_list_count(audios) == 0) {
+                                audio = calloc(1, sizeof(*audio));
+                                hb_audio_config_init(audio);
+                                audio->in.track = track;
+                                audio->out.track = num_audio_tracks++;
+                                /* Add it to our audios */
+                                hb_list_add(audios, audio);
+                            } else {
+                                /*
+                                 * Update the track numbers on what is already in
+                                 * there.
+                                 */
+                                for( i=0; i < hb_list_count( audios ); i++ )
+                                {
+                                    audio = hb_list_item( audios, i );
+
+                                    audio->in.track = track;
+                                }
+                            }
+                            break;
+                        }
+                    }
+                } else {
+                    fprintf( stderr, "Warning: Native language (dubbing) selection ignored since an audio track has already been selected\n");
+                }
+            }
+
+            if( hb_list_count(audios) == 0 &&
+                hb_list_count(job->title->list_audio) > 0 )
+            {        
                 /* Create a new audio track with default settings */
                 audio = calloc(1, sizeof(*audio));
                 hb_audio_config_init(audio);
@@ -1607,14 +1692,223 @@ static int HandleEvents( hb_handle_t * h )
                          job->vbitrate );
             }
 
-            if( sub )
+            if( subtracks )
             {
-                job->subtitle = sub - 1;
+                char * token;
+                int    i, pos;
+
+                pos = 0;
+                for ( i = 0; subtracks[i] != NULL; i++ )
+                {
+                    pos++;
+                    token = subtracks[i];
+                    if( strcasecmp(token, "scan" ) == 0 )
+                    {
+                        int burn = 0, force = 0, def = 0;
+
+                        if ( subburn != NULL )
+                        {
+                            burn = ( pos == 1 && subburn[0] == 0 ) ||
+                                   ( strcmp( "scan", subburn ) == 0 );
+                        }
+                        if ( subdefault != NULL )
+                        {
+                            def =  ( pos == 1 && subdefault[0] == 0 ) ||
+                                   ( strcmp( "scan", subdefault ) == 0 );
+                        }
+                        force = test_sub_list( subforce, "scan", pos );
+
+                        if ( !burn && mux == HB_MUX_MKV )
+                        {
+                            job->select_subtitle_config.dest = PASSTHRUSUB;
+                        }
+                        else if ( burn )
+                        {
+                            if ( sub_burned )
+                            {
+                                continue;
+                            }
+                            sub_burned = 1;
+                        }
+                        if ( !( !burn && mux == HB_MUX_MP4 ) )
+                        {
+                            job->select_subtitle_config.force = force;
+                            job->select_subtitle_config.default_track = def;
+                            subtitle_scan = 1;
+                        } else {
+                            fprintf( stderr, "Warning: Subtitle Scan for MP4 requires the '--subtitle-burn' option to be selected\n");
+                        }
+                    }
+                    else
+                    {
+                        hb_subtitle_t        * subtitle;
+                        hb_subtitle_config_t   sub_config;
+                        int                    track;
+                        int                    burn = 0, force = 0, def = 0;
+
+                        track = atoi(token) - 1;
+                        subtitle = hb_list_item(title->list_subtitle, track);
+                        if( subtitle == NULL ) 
+                        {
+                            fprintf( stderr, "Warning: Could not find subtitle track %d, skipped\n", track+1 );
+                            continue;
+                        }
+                        sub_config = subtitle->config;
+
+                        if ( subburn != NULL )
+                        {
+                            burn = ( pos == 1 && subburn[0] == 0 ) ||
+                                   ( strcmp( token, subburn ) == 0 );
+                        }
+                        if ( subdefault != NULL )
+                        {
+                            def =  ( pos == 1 && subdefault[0] == 0 ) ||
+                                   ( strcmp( token, subdefault ) == 0 );
+                        }
+
+                        force = test_sub_list(subforce, token, pos);
+
+                        if ( !burn && mux == HB_MUX_MKV && 
+                             subtitle->format == PICTURESUB)
+                        {
+                            sub_config.dest = PASSTHRUSUB;
+                        }
+                        else if (!burn && mux == HB_MUX_MP4 &&
+                             subtitle->format == PICTURESUB)
+                        {
+                            // Skip any non-burned vobsubs when output is mp4
+                            fprintf( stderr, "Warning: Skipping subtitle track %d, can't pass-through VOBSUBs in an MP4 container,\nadd '--subtitle-burn %d' to the command line\n", track+1, track+1 );
+                            continue;
+                        }
+                        else if ( burn && subtitle->format == PICTURESUB )
+                        {
+                            // Only allow one subtitle to be burned into video
+                            if ( sub_burned )
+                            {
+                                fprintf( stderr, "Warning: Skipping subtitle track %d, can't have more than one track burnt in\n", track+1 );
+                                continue;
+                            }
+                            sub_burned = 1;
+                        }
+                        sub_config.force = force;
+                        sub_config.default_track = def;
+                        hb_subtitle_add( job, &sub_config, track );
+                    }
+                }
+            }
+
+            if( srtfile )
+            {
+                char * token;
+                int i, pos;
+                hb_subtitle_config_t sub_config;
+
+                pos = 0;
+                for( i=0; srtfile[i] != NULL; i++ )
+                {
+                    char *codeset = "L1";
+                    int64_t offset = 0;
+                    char *lang = "und";
+
+                    pos++;
+                    token = srtfile[i];
+                    if( srtcodeset && srtcodeset[i] )
+                    {
+                        codeset = srtcodeset[i];
+                    }
+                    if( srtoffset && srtoffset[i] )
+                    {
+                        offset = strtoll( srtoffset[i], &srtoffset[i], 0 );
+                    }
+                    if ( srtlang && srtlang[i] )
+                    {
+                        lang = srtlang[i];
+                    }
+                    sub_config.default_track = 
+                           ( srtdefault != -1 ) && ( srtdefault == i + 1 );
+                    sub_config.force = 0;
+                    strncpy( sub_config.src_filename, srtfile[i], 128);
+                    strncpy( sub_config.src_codeset, codeset, 40);
+                    sub_config.offset = offset;
+
+                    hb_srt_add( job, &sub_config, lang);
+                }
             }
 
             if( native_language )
             {
-                job->native_language = strdup( native_language );
+                char audio_lang[4];
+                
+                audio = hb_list_audio_config_item(job->list_audio, 0);
+                
+                if( audio ) 
+                {
+                    strncpy( audio_lang, audio->lang.iso639_2, sizeof( audio_lang ) );
+                    
+                    if( strncasecmp( native_language, audio_lang, 
+                                     sizeof( audio_lang ) ) != 0 )
+                    {
+                        /*
+                         * Audio language is not the same as our native language. 
+                         * If we have any subtitles in our native language they
+                         * should be selected here if they haven't already been.
+                         */
+                        hb_subtitle_t *subtitle, *subtitle2 = NULL;
+                        int matched_track = 0;
+
+                        for( i = 0; i < hb_list_count( title->list_subtitle ); i++ )
+                        {
+                            subtitle = hb_list_item( title->list_subtitle, i );
+                            matched_track = i;
+                            if( strcmp( subtitle->iso639_2, native_language ) == 0 )
+                            {  
+                                /*
+                                 * Found the first matching subtitle in our
+                                 * native language. Is it already selected?
+                                 */
+                                for( i = 0; i < hb_list_count( job->list_subtitle ); i++ )
+                                {
+                                    subtitle2 =  hb_list_item( job->list_subtitle, i );
+                                    
+                                    if( subtitle2->track == subtitle->track) {
+                                        /*
+                                         * Already selected
+                                         */
+                                        break;
+                                    }
+                                    subtitle2 = NULL;
+                                }
+                                
+                                if( subtitle2 == NULL ) 
+                                {
+                                    /*
+                                     * Not already selected, so select it.
+                                     */
+                                    hb_subtitle_config_t sub_config;
+
+                                    if( native_dub )
+                                    {
+                                        fprintf( stderr, "Warning: no matching audio for native language - using subtitles instead.\n");
+                                    }
+                                    sub_config = subtitle->config;
+
+                                    if( mux == HB_MUX_MKV || subtitle->format == TEXTSUB)
+                                    {
+                                        sub_config.dest = PASSTHRUSUB;
+                                    }
+
+                                    sub_config.force = 0;
+                                    sub_config.default_track = 1;
+                                    hb_subtitle_add( job, &sub_config, matched_track);
+                                }
+                                /*
+                                 * Stop searching.
+                                 */
+                                break;
+                            }
+                        }
+                    }
+                }
             }
 
             if( job->mux )
@@ -1637,11 +1931,6 @@ static int HandleEvents( hb_handle_t * h )
 
             job->file = strdup( output );
 
-            if( crf )
-            {
-                job->crf = 1;
-            }
-            
             if( color_matrix )
             {
                 job->color_matrix = color_matrix;
@@ -1660,11 +1949,24 @@ static int HandleEvents( hb_handle_t * h )
             if (maxHeight)
                 job->maxHeight = maxHeight;
 
-            if( subtitle_force )
+            if( start_at_preview )
             {
-                job->subtitle_force = subtitle_force;
+                job->start_at_preview = start_at_preview - 1;
+                job->seek_points = preview_count;
             }
-
+            
+            if( stop_at_pts )
+            {
+                job->pts_to_stop = stop_at_pts;
+                subtitle_scan = 0;
+            }
+            
+            if( stop_at_frame )
+            {
+                job->frame_to_stop = stop_at_frame;
+                subtitle_scan = 0;
+            }
+            
             if( subtitle_scan )
             {
                 char *x264opts_tmp;
@@ -1682,8 +1984,6 @@ static int HandleEvents( hb_handle_t * h )
                 job->indepth_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
@@ -1700,10 +2000,6 @@ 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->indepth_scan = 0;
@@ -1745,8 +2041,6 @@ static int HandleEvents( hb_handle_t * h )
                 }
                 hb_add( h, job );
 
-                job->select_subtitle = subtitle_tmp;
-
                 job->pass = 2;
                 /*
                  * On the second pass we turn off subtitle scan so that we
@@ -1850,8 +2144,9 @@ void SigHandler( int i_signal )
 static void ShowHelp()
 {
     int i;
+    FILE* const out = stdout;
 
-    fprintf( stderr,
+    fprintf( out,
     "Syntax: HandBrakeCLI [options] -i <device> -o <file>\n"
     "\n"
     "### General Handbrake Options------------------------------------------------\n\n"
@@ -1863,6 +2158,8 @@ static void ShowHelp()
     "                            if the preset name has spaces, surround it with\n"
     "                            double quotation marks\n"
     "    -z, --preset-list       See a list of available built-in presets\n"
+    "        --no-dvdnav         Do not use dvdnav for reading DVDs\n"
+    "                            (experimental, enabled by default for testing)\n"
     "\n"
 
     "### Source Options-----------------------------------------------------------\n\n"
@@ -1873,11 +2170,18 @@ static void ShowHelp()
     "    -c, --chapters <string> Select chapters (e.g. \"1-3\" for chapters\n"
     "                            1 to 3, or \"3\" for chapter 3 only,\n"
     "                            default: all chapters)\n"
+    "        --angle <number>    Select the DVD angle\n"
+    "        --previews <#:B>    Select how many preview images are generated (max 30),\n"
+    "                            and whether or not they're stored to disk (0 or 1).\n"
+    "                            (default: 10:0)\n"
+    "    --start-at-preview <#>  Start encoding at a given preview.\n"
+    "    --stop-at     <unit:#>  Stop encoding at a given frame, duration (in seconds),\n"
+    "                            or pts (on a 90kHz clock)"
     "\n"
 
     "### Destination Options------------------------------------------------------\n\n"
     "    -o, --output <string>   Set output file name\n"
-    "    -f, --format <string>   Set output format (avi/mp4/ogm/mkv, default:\n"
+    "    -f, --format <string>   Set output format (mp4/mkv, default:\n"
     "                            autodetected from file name)\n"
     "    -m, --markers           Add chapter markers (mp4 and mkv output formats only)\n"
     "    -4, --large-file        Use 64-bit mp4 files that can hold more than\n"
@@ -1888,13 +2192,12 @@ static void ShowHelp()
 
 
     "### Video Options------------------------------------------------------------\n\n"
-    "    -e, --encoder <string>  Set video library encoder (ffmpeg,xvid,\n"
-    "                            x264,theora default: ffmpeg)\n"
+    "    -e, --encoder <string>  Set video library encoder (ffmpeg,x264,theora)\n"
+    "                            (default: ffmpeg)\n"
     "    -x, --x264opts <string> Specify advanced x264 options in the\n"
     "                            same style as mencoder:\n"
     "                            option1=value1:option2=value2\n"
     "    -q, --quality <float>   Set video quality (0.0..1.0)\n"
-    "    -Q, --cqp               Use with -q for CQP instead of CRF\n"
     "    -S, --size <MB>         Set target size\n"
     "    -b, --vb <kb/s>         Set video bitrate (default: 1000)\n"
     "    -2, --two-pass          Use two-pass mode\n"
@@ -1905,14 +2208,24 @@ static void ShowHelp()
     "    -r, --rate              Set video framerate (" );
     for( i = 0; i < hb_video_rates_count; i++ )
     {
-        fprintf( stderr, hb_video_rates[i].string );
+        fprintf( out, hb_video_rates[i].string );
         if( i != hb_video_rates_count - 1 )
-            fprintf( stderr, "/" );
+            fprintf( out, "/" );
     }
-    fprintf( stderr, ")\n"
+    fprintf( out, ")\n"
     "                            Be aware that not specifying a framerate lets\n"
     "                            HandBrake preserve a source's time stamps,\n"
     "                            potentially creating variable framerate video\n"
+    "    --vfr, --cfr, --pfr     Select variable, constant or peak-limited\n"
+    "                            frame rate control. VFR preserves the source\n"
+    "                            timing. CFR makes the output constant rate at\n"
+    "                            the rate given by the -r flag (or the source's\n"
+    "                            average rate if no -r is given). PFR doesn't\n"
+    "                            allow the rate to go over the rate specified\n"
+    "                            with the -r flag but won't change the source\n"
+    "                            timing if it's below that rate.\n"
+    "                            If none of these flags are given, the default\n"
+    "                            is --cfr when -r is given and --vfr otherwise\n"
 
     "\n"
     "### Audio Options-----------------------------------------------------------\n\n"
@@ -1920,11 +2233,22 @@ static void ShowHelp()
     "                            More than one output track can be used for one\n"
     "                            input.\n"
     "                            (\"none\" for no audio, \"1,2,3\" for multiple\n"
-    "                             tracks, default: first one)\n"
-    "    -E, --aencoder <string> Audio encoder(s) (faac/lame/vorbis/ac3) \n"
-    "                            ac3 meaning passthrough\n"
+    "                             tracks, default: first one)\n" );
+
+#ifdef __APPLE_CC__
+    fprintf( out,
+    "    -E, --aencoder <string> Audio encoder(s) (ca_aac/faac/lame/vorbis/ac3/dts) \n"
+    "                            ac3 and dts meaning passthrough\n"
+    "                            Separated by commas for more than one audio track.\n"
+    "                            (default: guessed)\n" );
+#else
+    fprintf( out,
+    "    -E, --aencoder <string> Audio encoder(s) (faac/lame/vorbis/ac3/dts) \n"
+    "                            ac3 and dts meaning passthrough\n"
     "                            Separated by commas for more than one audio track.\n"
-    "                            (default: guessed)\n"
+    "                            (default: guessed)\n" );
+#endif
+    fprintf( out,
     "    -B, --ab <kb/s>         Set audio bitrate(s)  (default: 160)\n"
     "                            Separated by commas for more than one audio track.\n"
     "    -6, --mixdown <string>  Format(s) for surround sound downmixing\n"
@@ -1933,11 +2257,11 @@ static void ShowHelp()
     "    -R, --arate             Set audio samplerate(s) (" );
     for( i = 0; i < hb_audio_rates_count; i++ )
     {
-        fprintf( stderr, hb_audio_rates[i].string );
+        fprintf( out, hb_audio_rates[i].string );
         if( i != hb_audio_rates_count - 1 )
-            fprintf( stderr, "/" );
+            fprintf( out, "/" );
     }
-    fprintf( stderr, " kHz)\n"
+    fprintf( out, " kHz)\n"
     "                            Separated by commas for more than one audio track.\n"
     "    -D, --drc <float>       Apply extra dynamic range compression to the audio,\n"
     "                            making soft sounds louder. Range is 1.0 to 4.0\n"
@@ -1953,11 +2277,23 @@ static void ShowHelp()
     "        --crop <T:B:L:R>    Set cropping values (default: autocrop)\n"
     "    -Y, --maxHeight <#>     Set maximum height\n"
     "    -X, --maxWidth <#>      Set maximum width\n"
-    "    -p, --pixelratio        Store pixel aspect ratio in video stream\n"
-    "    -P, --loosePixelratio   Store pixel aspect ratio with specified width\n"
-    "          <MOD:PARX:PARY>   Takes as optional arguments what number you want\n"
-    "                            the dimensions to divide cleanly by (default 16)\n"
-    "                            and the pixel ratio to use (default autodetected)\n"
+    "    --strict-anamorphic     Store pixel aspect ratio in video stream\n"
+    "    --loose-anamorphic      Store pixel aspect ratio with specified width\n"
+    "    --custom-anamorphic     Store pixel aspect ratio in video stream and\n"
+    "                            directly control all parameters.\n"
+    "    --display-width         Set the width to scale the actual pixels to\n"
+    "      <number>              at playback, for custom anamorphic.\n"
+    "    --keep-display-aspect   Preserve the source's display aspect ratio\n"
+    "                            when using custom anamorphic\n"
+    "    --pixel-aspect          Set a custom pixel aspect for custom anamorphic\n"
+    "      <PARX:PARY>\n"
+    "                            (--display-width and --pixel-aspect are mutually\n"
+    "                             exclusive and the former will override the latter)\n"
+    "    --itu-par               Use wider, ITU pixel aspect values for loose and\n"
+    "                            custom anamorphic, useful with underscanned sources\n"
+    "    --modulus               Set the number you want the scaled pixel dimensions\n"
+    "      <number>              to divide cleanly by, for loose and custom\n"
+    "                            anamorphic modes (default: 16)\n"
     "    -M  --color-matrix      Set the color space signaled by the output\n"
     "          <601 or 709>      (Bt.601 is mostly for SD content, Bt.709 for HD,\n"
     "                             default: set by resolution)\n"
@@ -1970,12 +2306,13 @@ static void ShowHelp()
      "           or\n"
      "          <fast/slow/slower>\n"
      "    -5, --decomb            Selectively deinterlaces when it detects combing\n"
-     "          <MO:ME:MT:ST:BT:BX:BY>     (default: 1:2:6:9:80:16:16)\n"
+     "          <MO:ME:MT:ST:BT:BX:BY:MG:VA:LA:DI:ER:NO:MD:PP:FD>\n"
+     "          (default: 7:2:6:9:80:16:16:10:20:20:4:2:50:24:1:-1)\n"
      "    -9, --detelecine        Detelecine (ivtc) video with pullup filter\n"
      "                            Note: this filter drops duplicate frames to\n"
      "                            restore the pre-telecine framerate, unless you\n"
      "                            specify a constant framerate (--rate 29.97)\n"
-     "          <L:R:T:B:SB:MP>   (default 1:1:4:4:0:0)\n"
+     "          <L:R:T:B:SB:MP:FD>   (default 1:1:4:4:0:0:-1)\n"
      "    -8, --denoise           Denoise video with hqdn3d filter\n"
      "          <SL:SC:TL:TC>     (default 4:3:6:4.5)\n"
      "           or\n"
@@ -1986,21 +2323,59 @@ static void ShowHelp()
     "\n"
 
     "### Subtitle Options------------------------------------------------------------\n\n"
-    "    -s, --subtitle <number> Select subtitle (default: none)\n"
-    "    -U, --subtitle-scan     Scan for subtitles in an extra 1st pass, and choose\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. Best used in conjunction\n"
-    "                            with --subtitle-forced.\n"
+    "    -s, --subtitle <string> Select subtitle track(s), separated by commas\n"
+    "                            More than one output track can be used for one\n"
+    "                            input.\n"
+    "                            (\"1,2,3\" for multiple tracks.\n"
+    "                            A special track name \"scan\" adds an extra 1st pass.\n"
+    "                            This extra pass scans subtitles matching the\n"
+    "                            language of the first audio or the language \n"
+    "                            selected by --native-language.\n"
+    "                            The one that's only used 10 percent of the time\n"
+    "                            or less is selected. This should locate subtitles\n"
+    "                            for short foreign language segments. Best used in\n"
+    "                            conjunction with --subtitle-forced.\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"
+    "          <string>          the subtitle has the forced flag set. May be used in\n"
+    "                            conjunction with \"scan\" track 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"
-
-
+    "                            Separated by commas for more than one audio track.\n"
+    "                            (\"1,2,3\" for multiple tracks.\n"
+    "                            If \"string\" is omitted, the first trac is forced.\n"
+    "        --subtitle-burn     \"Burn\" the selected subtitle into the video track\n"
+    "          <number>          If \"number\" is omitted, the first trac is burned.\n"
+    "        --subtitle-default  Flag the selected subtitle as the default subtitle\n"
+    "          <number>          to be displayed upon playback.  Setting no default\n"
+    "                            means no subtitle will be automatically displayed\n"
+    "                            If \"number\" is omitted, the first trac is default.\n"
+    "    -N, --native-language   Specifiy the your language preference. When the first\n"
+    "          <string>          audio track does not match your native language then\n"
+    "                            select the first subtitle that does. When used in\n"
+    "                            conjunction with --native-dub the audio track is\n"
+    "                            changed in preference to subtitles. Provide the\n"
+    "                            language's iso639-2 code (fre, eng, spa, dut, et cetera)\n"
+    "        --native-dub        Used in conjunction with --native-language\n"
+    "                            requests that if no audio tracks are selected the\n"
+    "                            default selected audio track will be the first one\n"
+    "                            that matches the --native-language. If there are no\n"
+    "                            matching audio tracks then the first matching\n"
+    "                            subtitle track is used instead.\n"
+    "        --srt-file <string> SubRip SRT filename(s), separated by commas.\n"
+    "        --srt-codeset       Character codeset(s) that the SRT file(s) are\n"
+    "          <string>          encoded in, separted by commas.\n"
+    "                            Use 'iconv -l' for a list of valid\n"
+    "                            codesets. If not specified latin1 is assumed\n"
+    "        --srt-offset        Offset in milli-seconds to apply to the SRT file(s)\n"
+    "          <string>          separted by commas. If not specified zero is assumed.\n"
+    "                            Offsets may be negative.\n"
+    "        --srt-lang <string> Language as an iso639-2 code fra, eng, spa et cetera)\n"
+    "                            for the SRT file(s) separated by commas. If not specified\n"
+    "                            then 'und' is used.\n"
+    "        --srt-default       Flag the selected srt as the default subtitle\n"
+    "          <number>          to be displayed upon playback.  Setting no default\n"
+    "                            means no subtitle will be automatically displayed\n"
+    "                            If \"number\" is omitted, the first srt is default.\n"
+    "                            \"number\" is an 1 based index into the srt-file list\n"
     "\n"
 
 
@@ -2014,58 +2389,83 @@ static void ShowPresets()
 {
     printf("\n< Apple\n");
 
-    printf("\n   + Universal:  -e x264  -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1\n");
-
-    printf("\n   + iPod:  -e x264  -b 700 -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 -I -X 320 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1\n");
-
-    printf("\n   + iPhone & iPod Touch:  -e x264  -q 0.589999973773956 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -X 480 -m -x level=30:cabac=0:ref=2:mixed-refs:analyse=all:me=umh:no-fast-pskip=1\n");
+    printf("\n   + Universal:  -e x264  -q 20.0 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 -X 720 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:bframes=0:8x8dct=0:trellis=0:subme=6\n");
 
-    printf("\n   + AppleTV:  -e x264  -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -4 -X 960 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all\n");
+    printf("\n   + iPod:  -e x264  -b 700 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4 -I -X 320 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0\n");
 
-    printf("\n   + QuickTime:  -e x264  -b 1800 -a 1 -E faac -B 160 -R Auto -6 dpl2 -f mp4 -p -m -2 -T -x ref=3:mixed-refs:bframes=3:weightb:direct=auto:me=umh:subme=7:analyse=all:8x8dct:trellis=1:no-fast-pskip=1:psy-rd=1,1\n");
+    printf("\n   + iPhone & iPod Touch:  -e x264  -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R 48 -D 0.0 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0\n");
 
-    printf("\n   << Legacy\n");
-
-    printf("\n      + AppleTV Legacy:  -e x264  -b 2500 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -4 -p -m -x bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=1:cabac=0\n");
-
-    printf("\n      + iPhone Legacy:  -e x264  -b 960 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -I -X 480 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:trellis=1\n");
-
-    printf("\n      + iPod Legacy:  -e x264  -b 1500 -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 -I -X 640 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1\n");
-
-    printf("\n   >>\n");
+    printf("\n   + AppleTV:  -e x264  -q 20.0 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 -4 -X 960 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0\n");
 
     printf("\n>\n");
 
-    printf("\n< Basic\n");
+    printf("\n< Regular\n");
 
-    printf("\n   + Normal:  -e x264  -b 1500 -a 1 -E faac -B 160 -R Auto -6 dpl2 -f mp4 -p -m -2 -T -x ref=2:bframes=2:me=umh\n");
+    printf("\n   + Normal:  -e x264  -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4 --strict-anamorphic -m -x ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0\n");
 
-    printf("\n   + Classic:  -b 1000 -a 1 -E faac -B 160 -R Auto -6 dpl2 -f mp4\n");
+    printf("\n   + High Profile:  -e x264  -q 20.0 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50\n");
 
     printf("\n>\n");
 
-    printf("\n< High Profile\n");
+    printf("\n< Legacy\n");
 
-    printf("\n   + Animation:  -e x264  -b 1000 -a 1 -E faac -B 160 -R Auto -6 dpl2 -f mkv --detelecine --decomb -p -m -2 -T -x ref=5:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2:psy-rd=1,1:subme=9\n");
+    printf("\n   + Classic:  -b 1000 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4\n");
 
-    printf("\n   + Constant Quality Rate:  -e x264  -q 0.600000023841858 -a 1 -E ac3 -B 160 -R Auto -6 auto -f mkv -p -m -x ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all:8x8dct:me=umh:subme=9:psy-rd=1,1\n");
+    printf("\n   + AppleTV Legacy:  -e x264  -b 2500 -a 1,1 -E faac,ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mp4 -4 --strict-anamorphic -m -x ref=1:subme=5:me=umh:no-fast-pskip=1:cabac=0:weightb=0:8x8dct=0:trellis=0\n");
 
-    printf("\n   + Film:  -e x264  -b 1800 -a 1 -E ac3 -B 160 -R Auto -6 auto -f mkv -p -m -2 -T -x ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1\n");
+    printf("\n   + iPhone Legacy:  -e x264  -b 960 -a 1 -E faac -B 128 -6 dpl2 -R 48 -D 0.0 -f mp4 -I -X 480 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:subme=6:8x8dct=0:trellis=0\n");
 
-    printf("\n   + Television:  -e x264  -b 1300 -a 1 -E faac -B 160 -R Auto -6 dpl2 -f mkv --detelecine --decomb -p -m -2 -T -x ref=3:mixed-refs:bframes=6:weightb:direct=auto:b-pyramid:me=umh:subme=9:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip=1:psy-rd=1,1\n");
+    printf("\n   + iPod Legacy:  -e x264  -b 1500 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4 -I -X 640 -m -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:subme=6:8x8dct=0:trellis=0\n");
 
     printf("\n>\n");
+}
+
+static char * hb_strndup( char * str, int len )
+{
+       char * res;
+       int str_len = strlen( str );
+
+       res = malloc( len > str_len ? str_len + 1 : len + 1 );
+       strncpy( res, str, len );
+       res[len] = '\0';
+       return res;
+}
 
-    printf("\n< Gaming Consoles\n");
+static char** str_split( char *str, char delem )
+{
+    char *  pos;
+    char *  end;
+    char ** ret;
+    int     count, i;
 
-    printf("\n   + PSP:  -b 1024 -a 1 -E faac -B 128 -R 48 -6 dpl2 -f mp4 -X 368 -Y 208 -m\n");
+    if ( str == NULL || str[0] == 0 )
+    {
+        ret = malloc( sizeof(char*) );
+        *ret = NULL;
+        return ret;
+    }
 
-    printf("\n   + PS3:  -e x264  -b 2500 -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 --crop 0:0:0:0 -p -x level=41:me=umh\n");
+    // Find number of elements in the string
+    count = 1;
+    pos = str;
+    while ( ( pos = strchr( pos, delem ) ) != NULL )
+    {
+        count++;
+        pos++;
+    }
 
-    printf("\n   + Xbox 360:  -e x264  -b 2000 -a 1 -E faac -B 160 -R 48 -6 dpl2 -f mp4 -p -x level=40:ref=2:mixed-refs:bframes=3:weightb:subme=9:direct=auto:b-pyramid:me=umh:analyse=all:no-fast-pskip:filter=-2,-1\n");
+    ret = calloc( ( count + 1 ), sizeof(char*) );
 
-    printf("\n>\n");
+    pos = str;
+    for ( i = 0; i < count - 1; i++ )
+    {
+        end = strchr( pos, delem );
+        ret[i] = hb_strndup(pos, end - pos);
+        pos = end + 1;
+    }
+    ret[i] = strdup(pos);
 
+    return ret;
 }
 
 /****************************************************************************
@@ -2073,6 +2473,25 @@ static void ShowPresets()
  ****************************************************************************/
 static int ParseOptions( int argc, char ** argv )
 {
+    
+    #define PREVIEWS            257
+    #define START_AT_PREVIEW    258
+    #define STOP_AT             259
+    #define ANGLE               260
+    #define DVDNAV              261
+    #define DISPLAY_WIDTH       262
+    #define PIXEL_ASPECT        263
+    #define MODULUS             264
+    #define KEEP_DISPLAY_ASPECT 265
+    #define SUB_BURNED          266
+    #define SUB_DEFAULT         267
+    #define NATIVE_DUB          268
+    #define SRT_FILE            269
+    #define SRT_CODESET         270
+    #define SRT_OFFSET          271
+    #define SRT_LANG            272
+    #define SRT_DEFAULT         273
+    
     for( ;; )
     {
         static struct option long_options[] =
@@ -2081,6 +2500,7 @@ static int ParseOptions( int argc, char ** argv )
             { "update",      no_argument,       NULL,    'u' },
             { "verbose",     optional_argument, NULL,    'v' },
             { "cpu",         required_argument, NULL,    'C' },
+            { "no-dvdnav",      no_argument,       NULL,    DVDNAV },
 
             { "format",      required_argument, NULL,    'f' },
             { "input",       required_argument, NULL,    'i' },
@@ -2092,15 +2512,22 @@ static int ParseOptions( int argc, char ** argv )
             { "title",       required_argument, NULL,    't' },
             { "longest",     no_argument,       NULL,    'L' },
             { "chapters",    required_argument, NULL,    'c' },
+            { "angle",       required_argument, NULL,    ANGLE },
             { "markers",     optional_argument, NULL,    'm' },
             { "audio",       required_argument, NULL,    'a' },
             { "mixdown",     required_argument, NULL,    '6' },
             { "drc",         required_argument, NULL,    'D' },
             { "subtitle",    required_argument, NULL,    's' },
-            { "subtitle-scan", no_argument,     NULL,    'U' },
-            { "subtitle-forced", no_argument,   NULL,    'F' },
+            { "subtitle-forced", optional_argument,   NULL,    'F' },
+            { "subtitle-burned", optional_argument,   NULL,    SUB_BURNED },
+            { "subtitle-default", optional_argument,   NULL,    SUB_DEFAULT },
+            { "srt-file",    required_argument, NULL, SRT_FILE },
+            { "srt-codeset", required_argument, NULL, SRT_CODESET },
+            { "srt-offset",  required_argument, NULL, SRT_OFFSET },
+            { "srt-lang",    required_argument, NULL, SRT_LANG },
+            { "srt-default",    optional_argument, NULL, SRT_DEFAULT },
             { "native-language", required_argument, NULL,'N' },
-
+            { "native-dub",  no_argument,       NULL,    NATIVE_DUB },
             { "encoder",     required_argument, NULL,    'e' },
             { "aencoder",    required_argument, NULL,    'E' },
             { "two-pass",    no_argument,       NULL,    '2' },
@@ -2110,8 +2537,14 @@ static int ParseOptions( int argc, char ** argv )
             { "detelecine",  optional_argument, NULL,    '9' },
             { "decomb",      optional_argument, NULL,    '5' },
             { "grayscale",   no_argument,       NULL,    'g' },
-            { "pixelratio",  no_argument,       NULL,    'p' },
-            { "loosePixelratio", optional_argument,   NULL,    'P' },
+            { "strict-anamorphic",  no_argument, &anamorphic_mode, 1 },
+            { "loose-anamorphic", no_argument, &anamorphic_mode, 2 },
+            { "custom-anamorphic", no_argument, &anamorphic_mode, 3 },
+            { "display-width", required_argument, NULL, DISPLAY_WIDTH },
+            { "keep-display-aspect", no_argument, &keep_display_aspect, 1 },
+            { "pixel-aspect", required_argument, NULL, PIXEL_ASPECT },
+            { "modulus",     required_argument, NULL, MODULUS },
+            { "itu-par",     no_argument,       &itu_par, 1  },
             { "width",       required_argument, NULL,    'w' },
             { "height",      required_argument, NULL,    'l' },
             { "crop",        required_argument, NULL,    'n' },
@@ -2122,7 +2555,6 @@ static int ParseOptions( int argc, char ** argv )
             { "ab",          required_argument, NULL,    'B' },
             { "rate",        required_argument, NULL,    'r' },
             { "arate",       required_argument, NULL,    'R' },
-            { "cqp",         no_argument,       NULL,    'Q' },
             { "x264opts",    required_argument, NULL,    'x' },
             { "turbo",       no_argument,       NULL,    'T' },
             { "maxHeight",   required_argument, NULL,    'Y' },
@@ -2132,7 +2564,12 @@ static int ParseOptions( int argc, char ** argv )
 
             { "aname",       required_argument, NULL,    'A' },
             { "color-matrix",required_argument, NULL,    'M' },
-
+            { "previews",    required_argument, NULL,    PREVIEWS },
+            { "start-at-preview", required_argument, NULL, START_AT_PREVIEW },
+            { "stop-at",    required_argument, NULL,     STOP_AT },
+            { "vfr",         no_argument,       &cfr,    0 },
+            { "cfr",         no_argument,       &cfr,    1 },
+            { "pfr",         no_argument,       &cfr,    2 },
             { 0, 0, 0, 0 }
           };
 
@@ -2140,7 +2577,7 @@ static int ParseOptions( int argc, char ** argv )
         int c;
 
                c = getopt_long( argc, argv,
-                                                "hv::uC:f:4i:Io:t:Lc:m::M:a:A:6:s:UFN:e:E:2dD:7895gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:Z:z",
+                                                "hv::uC:f:4i:Io:t:Lc:m::M:a:A:6:s:UF::N:e:E:2dD:7895gOw:l:n:b:q:S:B:r:R:x:TY:X:Z:z",
                          long_options, &option_index );
         if( c < 0 )
         {
@@ -2149,6 +2586,9 @@ static int ParseOptions( int argc, char ** argv )
 
         switch( c )
         {
+            case 0:
+                /* option was handled entirely in getopt_long */
+                break;
             case 'h':
                 ShowHelp();
                 exit( 0 );
@@ -2176,26 +2616,28 @@ static int ParseOptions( int argc, char ** argv )
             case 'z':
                 ShowPresets();
                 exit ( 0 );
+            case DVDNAV:
+                dvdnav = 0;
+                break;
 
             case 'f':
                 format = strdup( optarg );
                 break;
             case 'i':
                 input = strdup( optarg );
-                #ifdef __APPLE_CC__
-                char *devName = bsd_name_for_path( input );
-                if( devName == NULL )
-                {
-                    break;
-                }
-                if( device_is_dvd( devName ) )
+#ifdef __APPLE_CC__
+                char *devName = bsd_name_for_path( input ); // alloc
+                if( devName )
                 {
-                    char *newInput = malloc( strlen("/dev/") + strlen( devName ) + 1);
-                    sprintf( newInput, "/dev/%s", devName );
-                    free(input);
-                    input = newInput;
+                    if( device_is_dvd( devName ))
+                    {
+                        free( input );
+                        input = malloc( strlen( "/dev/" ) + strlen( devName ) + 1 );
+                        sprintf( input, "/dev/%s", devName );
+                    }
+                    free( devName );
                 }
-                #endif
+#endif
                 break;
             case 'o':
                 output = strdup( optarg );
@@ -2237,6 +2679,9 @@ static int ParseOptions( int argc, char ** argv )
                 }
                 break;
             }
+            case ANGLE:
+                angle = atoi( optarg );
+                break;
             case 'm':
                 if( optarg != NULL )
                 {
@@ -2248,6 +2693,7 @@ static int ParseOptions( int argc, char ** argv )
                 if( optarg != NULL )
                 {
                     atracks = strdup( optarg );
+                    audio_explicit = 1;
                 }
                 else
                 {
@@ -2267,17 +2713,59 @@ static int ParseOptions( int argc, char ** argv )
                 }
                 break;
             case 's':
-                sub = atoi( optarg );
-                break;
-            case 'U':
-                subtitle_scan = 1;
+                subtracks = str_split( optarg, ',' );
                 break;
             case 'F':
-                subtitle_force = 1;
+                subforce = str_split( optarg, ',' );
+                break;
+            case SUB_BURNED:
+                if( optarg != NULL )
+                {
+                    subburn = strdup( optarg );
+                }
+                else
+                {
+                    subburn = "" ;
+                }
+                break;
+            case SUB_DEFAULT:
+                if( optarg != NULL )
+                {
+                    subdefault = strdup( optarg );
+                }
+                else
+                {
+                    subdefault = "" ;
+                }
                 break;
             case 'N':
                 native_language = strdup( optarg );
                 break;
+            case NATIVE_DUB:
+                native_dub = 1;
+                break;
+            case SRT_FILE:
+                srtfile = str_split( optarg, ',' );
+                break;
+            case SRT_CODESET:
+                srtcodeset = str_split( optarg, ',' );
+                break;
+            case SRT_OFFSET:
+                srtoffset = str_split( optarg, ',' );
+                break;
+            case SRT_LANG:
+                srtlang = str_split( optarg, ',' );
+                break;
+            case SRT_DEFAULT:
+                if( optarg != NULL )
+                {
+                    srtdefault = atoi( optarg );
+                }
+                else
+                {
+                    srtdefault = 1 ;
+                }
+                break;
             case '2':
                 twoPass = 1;
                 break;
@@ -2349,14 +2837,22 @@ static int ParseOptions( int argc, char ** argv )
             case 'g':
                 grayscale = 1;
                 break;
-            case 'p':
-                pixelratio = 1;
+            case DISPLAY_WIDTH:
+                if( optarg != NULL )
+                {
+                    sscanf( optarg, "%i", &display_width );
+                }
+                break;
+            case PIXEL_ASPECT:
+                if( optarg != NULL )
+                {
+                    sscanf( optarg, "%i:%i", &par_width, &par_height );
+                }
                 break;
-            case 'P':
-                loosePixelratio = 1;
+            case MODULUS:
                 if( optarg != NULL )
                 {
-                    sscanf( optarg, "%i:%i:%i", &modulus, &par_width, &par_height );
+                    sscanf( optarg, "%i", &modulus );
                 }
                 break;
             case 'e':
@@ -2364,10 +2860,6 @@ static int ParseOptions( int argc, char ** argv )
                 {
                     vcodec = HB_VCODEC_FFMPEG;
                 }
-                else if( !strcasecmp( optarg, "xvid" ) )
-                {
-                    vcodec = HB_VCODEC_XVID;
-                }
                 else if( !strcasecmp( optarg, "x264" ) )
                 {
                     vcodec = HB_VCODEC_X264;
@@ -2433,6 +2925,10 @@ static int ParseOptions( int argc, char ** argv )
                 {
                     fprintf( stderr, "invalid framerate %s\n", optarg );
                 }
+                else if ( cfr == 0 )
+                {
+                    cfr = 1;
+                }
                 break;
             }
             case 'R':
@@ -2456,9 +2952,6 @@ static int ParseOptions( int argc, char ** argv )
                     abitrates = strdup( optarg );
                 }
                 break;
-            case 'Q':
-                crf = 0;
-                break;
             case 'x':
                 x264opts = strdup( optarg );
                 break;
@@ -2477,6 +2970,32 @@ static int ParseOptions( int argc, char ** argv )
                     anames = strdup( optarg );
                 }
                 break;
+            case PREVIEWS:
+                sscanf( optarg, "%i:%i", &preview_count, &store_previews );
+                break;
+            case START_AT_PREVIEW:
+                start_at_preview = atoi( optarg );
+                break;
+            case STOP_AT:
+                stop_at_string = strdup( optarg );
+                stop_at_token = strtok( stop_at_string, ":");
+                if( !strcmp( stop_at_token, "frame" ) )
+                {
+                    stop_at_token = strtok( NULL, ":");
+                    stop_at_frame = atoi(stop_at_token);
+                }
+                else if( !strcmp( stop_at_token, "pts" ) )
+                {
+                    stop_at_token = strtok( NULL, ":");
+                    sscanf( stop_at_token, "%"SCNd64, &stop_at_pts );
+                }
+                else if( !strcmp( stop_at_token, "duration" ) )
+                {
+                    stop_at_token = strtok( NULL, ":");
+                    sscanf( stop_at_token, "%"SCNd64, &stop_at_pts );
+                    stop_at_pts *= 90000LL;
+                }
+                break;
             case 'M':
                 if( atoi( optarg ) == 601 )
                     color_matrix = 1;
@@ -2521,12 +3040,7 @@ static int CheckOptions( int argc, char ** argv )
             char * p = strrchr( output, '.' );
 
             /* autodetect */
-            if( p && !strcasecmp( p, ".avi" ) )
-            {
-                mux = HB_MUX_AVI;
-                default_acodec = HB_ACODEC_LAME;
-            }
-            else if( p && ( !strcasecmp( p, ".mp4" )  ||
+            if( p && ( !strcasecmp( p, ".mp4" )  ||
                             !strcasecmp( p, ".m4v" ) ) )
             {
                 if ( h264_30 == 1 )
@@ -2535,12 +3049,6 @@ static int CheckOptions( int argc, char ** argv )
                     mux = HB_MUX_MP4;
                 default_acodec = HB_ACODEC_FAAC;
             }
-            else if( p && ( !strcasecmp( p, ".ogm" ) ||
-                            !strcasecmp( p, ".ogg" ) ) )
-            {
-                mux = HB_MUX_OGM;
-                default_acodec = HB_ACODEC_VORBIS;
-            }
             else if( p && !strcasecmp(p, ".mkv" ) )
             {
                 mux = HB_MUX_MKV;
@@ -2553,11 +3061,6 @@ static int CheckOptions( int argc, char ** argv )
                 return 0;
             }
         }
-        else if( !strcasecmp( format, "avi" ) )
-        {
-            mux = HB_MUX_AVI;
-            default_acodec = HB_ACODEC_LAME;
-        }
         else if( !strcasecmp( format, "mp4" ) ||
                  !strcasecmp( format, "m4v" ) )
         {
@@ -2567,12 +3070,6 @@ static int CheckOptions( int argc, char ** argv )
                 mux = HB_MUX_MP4;
             default_acodec = HB_ACODEC_FAAC;
         }
-        else if( !strcasecmp( format, "ogm" ) ||
-                 !strcasecmp( format, "ogg" ) )
-        {
-            mux = HB_MUX_OGM;
-            default_acodec = HB_ACODEC_VORBIS;
-        }
         else if( !strcasecmp( format, "mkv" ) )
         {
             mux = HB_MUX_MKV;
@@ -2581,7 +3078,7 @@ static int CheckOptions( int argc, char ** argv )
         else
         {
             fprintf( stderr, "Invalid output format (%s). Possible "
-                     "choices are avi, mp4, m4v, ogm, ogg and mkv\n.", format );
+                     "choices are mp4, m4v and mkv\n.", format );
             return 1;
         }
     }
@@ -2611,6 +3108,12 @@ static int get_acodec_for_string( char *codec )
     {
         return HB_ACODEC_VORBIS;
     }
+#ifdef __APPLE__
+    else if( !strcasecmp( codec, "ca_aac") )
+    {
+        return HB_ACODEC_CA_AAC;
+    }
+#endif
     else
     {
         return -1;
@@ -2663,10 +3166,20 @@ static char* bsd_name_for_path(char *path)
         return NULL;
     }
 
-    // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the
-    // vMDeviceID field. It is actually a char * value. This is mentioned in the
-    // header CoreServices/CarbonCore/Files.h.
-    return volumeParms.vMDeviceID;
+    // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the vMDeviceID field.
+    // It is actually a char * value. This is mentioned in the header CoreServices/CarbonCore/Files.h.
+    if( volumeParms.vMVersion < 4 )
+    {
+        return NULL;
+    }
+
+    // vMDeviceID might be zero as is reported with experimental ZFS (zfs-119) support in Leopard.
+    if( !volumeParms.vMDeviceID )
+    {
+        return NULL;
+    }
+
+    return strdup( volumeParms.vMDeviceID );
 }
 
 /****************************************************************************
@@ -2763,7 +3276,7 @@ static int is_dvd_service( io_service_t service )
  * The whole media object is indicated in the IORegistry by the presence of a
  * property with the key "Whole" and value "Yes".
  ****************************************************************************/
-static is_whole_media_service( io_service_t service )
+static int is_whole_media_service( io_service_t service )
 {
     int result = 0;
 
diff --git a/win/C#/Changelog.html b/win/C#/Changelog.html
new file mode 100644 (file)
index 0000000..000b945
--- /dev/null
@@ -0,0 +1,107 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml">\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
+<title>ChangeLog</title>\r
+</head>\r
+\r
+<body>\r
+Windows Platform Specific Changlog.<br />\r
+\r
+    <h2>Changes Since Snapshot 2 - SVN2773</h2> <!-- Snapshot 3 (upcoming) -->\r
+    \r
+    <h4>New Features</h4>\r
+    None <br />\r
+    \r
+    <h4>Minor Improvements / Changes</h4>\r
+    - Updated Growl to 2.0.0.20 from 2.0.0.19<br />\r
+    - Added 2 new options. "Growl when queue completes" and "Growl when encode completes"<br />\r
+    - Added 1 new option. "Disable Resolution Calculation for "None" and "Custom" modes."<br />\r
+    - Removed "Enable DVD drive detection..." and "Load my default preset" preferences<br />\r
+    - Set m4v as default enabled.<br />\r
+\r
+    <h4>Fixed</h4>\r
+    - Several issues with Picture Settings panel related to aspect ration and resolution calculation. <br />\r
+    - Issue where file extension could be mp4 when chapters is enabled. Problem in the autoname function.<br />\r
+    - A regex error in the appcast reader and make it more robust to errors.<br />\r
+    - Issue with the destination File box double appending the file extension<br />\r
+    - Issue changing file format causing the audio encoder dropdown to be set to ""<br />\r
+    - An issue with autoName function and format dropdown with regards to AC3 in the audio list. Also, CC or SRT<br />\r
+    - A culture issue with the Video Quality slider. Should now work correctly for systems which represent floats as 1,25 instead of 1.25<br />\r
+    - Issue with SRT filepaths not being quoted.<br />\r
+    - An issue with 8x8dct not saving correctly in presets<br />\r
+    - Activity log window would sometimes not display the CLI query used <br />\r
+    - Couple issues in the Picutre Settings code <br />\r
+\r
+    \r
+    <h4>Backend / Not important changes</h4>\r
+    - Filters dropdowns re-arranged and updated for consistancy (Off, Custom ...)\r
\r
+    <h2>Changes since Snapshot 1 - SVN2592</h2> <!-- Snapshot 2 -->\r
+    \r
+    <h4>New Features</h4>\r
+    - Added support for Growl for Windows.<br />\r
+    - Import MacGUI presets.<br />\r
+    - External SRT supported added.<br />\r
+    - Added new options: preferred language, "Dub Foreign language audio" and "Use Foreign language audio and Subtitles"<br />\r
+    - Import Chapter Markers from csv file <br />\r
+    \r
+    <h4>Minor Improvements / Changes</h4>\r
+    - Some UI layout changes / improvements<br />\r
+    - Remove M4v from format dropdown and add new option "Use iPod/iTunes friendly (.m4v) file extension for MP4<br />\r
+    \r
+    <h4>Fixed</h4>\r
+    - Picture Settings now works correctly (including Custom Anamorphic).<br />\r
+    - Error message when cancelling an encode within 2 seconds of it starting.<br />\r
+    - Quality slider resetting to 0 and other settings lost when a title change occurs.<br />\r
+    - Fixes some scaling / quality issues with QuickTime preview. \r
+    - Possible fix for QT not working on 64bit systems.<br />\r
+    - Chaning the x264 Quality granularity no longer requires a restart to work correctly <br />\r
+    - Chapter Markers tab now resets far less often. It should retain chapter names after being disabled / re-enabled <br />\r
+    \r
+    <h2>Changes since 0.9.3</h2> <!-- Snapshot 1 -->\r
+    \r
+    <h4>Major Changes</h4>\r
+\r
+    - Video Preview window using QuickTime or VLC. (5 to 60 second preview clips) <br />\r
+    - Re-designed audio tab. Now uses a List and allows for >4 audio channels.<br />\r
+    - Improved Picture Settings tab (Uses Numeric Controls and includes Modulus based increments and resolution calculation)<br />\r
+    - Minimise to system tray is now optional with the ability to turn off balloon tip notifications.<br />\r
+    - Picture settings can now be stored in presets. (Optional setting)<br />\r
+    - Built-in Presets now automatically update when a change is detected.<br />\r
+    - Preset XML data files are now stored in the users application data folder which allows for each system account user can have their own presets.<br />\r
+    - Users can "update" their own presets. (Rather than delete & re-create)<br />\r
+    - Improved control over how logs are stored. Logs are now kept in the Application data folder for each user. <br />\r
+    - The Main window and the Queue "Start/Stop" buttons are now linked. Start on the main window starts the Queue. They are no longer separate.<br />\r
+\r
+    <h4>Minor Improvements / Changes</h4>\r
+    - Resizable queue Window<br />\r
+    - Scanning a source no longer uses a separate popup window. Scanning simply disables the main window, and displays the status much like the MacGUI<br />\r
+    - Queue recovery now uses an XML file.<br />\r
+    - Improvements in the Main Window.<br />\r
+       <p style="padding-left:20px; margin:0px;">\r
+               * Source text box no longer editable. Prevents users changing the source without a rescan.<br />\r
+           * Minor changes in the Destination Browse dialog to improve usability.<br />\r
+           * Design improvements. Removed smaller fonts where possible. Fixed a few design inconsistencies.<br />\r
+           * Warn before stopping a job. Cleanly exits the CLI.<br />\r
+           * Selecting a preset which is already selected, will reset all settings to that preset.<br />\r
+           * Option to hide query editor tab.<br />\r
+           * File overwrite alert for destination files<br />\r
+        </p>\r
+    - "Open Individual log file directory" option added to right click menu for Activity log window.<br />\r
+    - Faster reloading of the activity log window log files.<br />\r
+    - Ability to "Re-Add" the currently encoding job back onto the end of the queue (Allows cancellation of job for future encoding)<br />\r
+    - Removed RAM limitation on start-up. Seems next to no-one is trying to run this on Windows 95 anymore.<br />\r
+    - CLI status can now be displayed in-GUI instead of the CLI readout. (Experimental)<br />\r
+    - Misc Typo's<br />\r
+\r
+    <h4>Fixed</h4>\r
+    - Source and Destination fields unpopulated on queue in certain conditions.<br />\r
+    - Several bugs in the way x264 widgets are handled with custom x264 strings.<br />\r
+    - Fixed a null pointer exception after scan if all presets had been deleted.<br />\r
+    - Fixed a few issues with the Chapter Markers tab<br />\r
+    - Fixed HandBrake GUI would Hang if the CLI stopped responding during start-up. Automatically recovers after 10 second time limit.<br />\r
+    - Universal input. (AAC Decoding in Mp4 files, Some WMV files)<br />\r
+    - Many other fixes<br />\r
+</body>\r
+</html>\r
diff --git a/win/C#/Controls/AudioPanel.Designer.cs b/win/C#/Controls/AudioPanel.Designer.cs
new file mode 100644 (file)
index 0000000..0ac76d5
--- /dev/null
@@ -0,0 +1,454 @@
+/*  AudioPanel.Designer.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    partial class AudioPanel\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.components = new System.ComponentModel.Container();\r
+            this.lv_audioList = new System.Windows.Forms.ListView();\r
+            this.col_id = new System.Windows.Forms.ColumnHeader();\r
+            this.col_Source = new System.Windows.Forms.ColumnHeader();\r
+            this.col_codec = new System.Windows.Forms.ColumnHeader();\r
+            this.col_mixdown = new System.Windows.Forms.ColumnHeader();\r
+            this.col_samplerate = new System.Windows.Forms.ColumnHeader();\r
+            this.col_bitrate = new System.Windows.Forms.ColumnHeader();\r
+            this.col_drc = new System.Windows.Forms.ColumnHeader();\r
+            this.audioMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.audioList_moveup = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.audioList_movedown = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.audioList_remove = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.btn_RemoveAudioTrack = new System.Windows.Forms.Button();\r
+            this.btn_addAudioTrack = new System.Windows.Forms.Button();\r
+            this.lbl_drc = new System.Windows.Forms.Label();\r
+            this.label16 = new System.Windows.Forms.Label();\r
+            this.tb_drc = new System.Windows.Forms.TrackBar();\r
+            this.label68 = new System.Windows.Forms.Label();\r
+            this.label67 = new System.Windows.Forms.Label();\r
+            this.label66 = new System.Windows.Forms.Label();\r
+            this.label65 = new System.Windows.Forms.Label();\r
+            this.label14 = new System.Windows.Forms.Label();\r
+            this.drp_audioEncoder = new System.Windows.Forms.ComboBox();\r
+            this.label27 = new System.Windows.Forms.Label();\r
+            this.drp_audioMix = new System.Windows.Forms.ComboBox();\r
+            this.drp_audioTrack = new System.Windows.Forms.ComboBox();\r
+            this.drp_audioBitrate = new System.Windows.Forms.ComboBox();\r
+            this.drp_audioSample = new System.Windows.Forms.ComboBox();\r
+            this.AudioTrackGroup = new System.Windows.Forms.GroupBox();\r
+            this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components);\r
+            this.audioMenu.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.tb_drc)).BeginInit();\r
+            this.AudioTrackGroup.SuspendLayout();\r
+            this.SuspendLayout();\r
+            // \r
+            // lv_audioList\r
+            // \r
+            this.lv_audioList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {\r
+            this.col_id,\r
+            this.col_Source,\r
+            this.col_codec,\r
+            this.col_mixdown,\r
+            this.col_samplerate,\r
+            this.col_bitrate,\r
+            this.col_drc});\r
+            this.lv_audioList.ContextMenuStrip = this.audioMenu;\r
+            this.lv_audioList.FullRowSelect = true;\r
+            this.lv_audioList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;\r
+            this.lv_audioList.HideSelection = false;\r
+            this.lv_audioList.LabelWrap = false;\r
+            this.lv_audioList.Location = new System.Drawing.Point(16, 150);\r
+            this.lv_audioList.MultiSelect = false;\r
+            this.lv_audioList.Name = "lv_audioList";\r
+            this.lv_audioList.Size = new System.Drawing.Size(689, 140);\r
+            this.lv_audioList.TabIndex = 65;\r
+            this.lv_audioList.UseCompatibleStateImageBehavior = false;\r
+            this.lv_audioList.View = System.Windows.Forms.View.Details;\r
+            this.lv_audioList.SelectedIndexChanged += new System.EventHandler(this.lv_audioList_SelectedIndexChanged);\r
+            // \r
+            // col_id\r
+            // \r
+            this.col_id.Text = "Track";\r
+            this.col_id.Width = 47;\r
+            // \r
+            // col_Source\r
+            // \r
+            this.col_Source.Text = "Source";\r
+            this.col_Source.Width = 170;\r
+            // \r
+            // col_codec\r
+            // \r
+            this.col_codec.Text = "Audio Codec";\r
+            this.col_codec.Width = 88;\r
+            // \r
+            // col_mixdown\r
+            // \r
+            this.col_mixdown.Text = "Mixdown";\r
+            this.col_mixdown.Width = 127;\r
+            // \r
+            // col_samplerate\r
+            // \r
+            this.col_samplerate.Text = "Samplerate (kHz)";\r
+            this.col_samplerate.Width = 101;\r
+            // \r
+            // col_bitrate\r
+            // \r
+            this.col_bitrate.Text = "Bitrate (Kbps)";\r
+            this.col_bitrate.Width = 95;\r
+            // \r
+            // col_drc\r
+            // \r
+            this.col_drc.Text = "DRC";\r
+            // \r
+            // audioMenu\r
+            // \r
+            this.audioMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.audioList_moveup,\r
+            this.audioList_movedown,\r
+            this.toolStripSeparator2,\r
+            this.audioList_remove});\r
+            this.audioMenu.Name = "audioMenu";\r
+            this.audioMenu.Size = new System.Drawing.Size(142, 76);\r
+            // \r
+            // audioList_moveup\r
+            // \r
+            this.audioList_moveup.Name = "audioList_moveup";\r
+            this.audioList_moveup.Size = new System.Drawing.Size(141, 22);\r
+            this.audioList_moveup.Text = "Move Up";\r
+            this.audioList_moveup.Click += new System.EventHandler(this.audioList_moveup_Click);\r
+            // \r
+            // audioList_movedown\r
+            // \r
+            this.audioList_movedown.Name = "audioList_movedown";\r
+            this.audioList_movedown.Size = new System.Drawing.Size(141, 22);\r
+            this.audioList_movedown.Text = "Move Down";\r
+            this.audioList_movedown.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.audioList_movedown.Click += new System.EventHandler(this.audioList_movedown_Click);\r
+            // \r
+            // toolStripSeparator2\r
+            // \r
+            this.toolStripSeparator2.Name = "toolStripSeparator2";\r
+            this.toolStripSeparator2.Size = new System.Drawing.Size(138, 6);\r
+            // \r
+            // audioList_remove\r
+            // \r
+            this.audioList_remove.Name = "audioList_remove";\r
+            this.audioList_remove.Size = new System.Drawing.Size(141, 22);\r
+            this.audioList_remove.Text = "Remove";\r
+            this.audioList_remove.Click += new System.EventHandler(this.audioList_remove_Click);\r
+            // \r
+            // btn_RemoveAudioTrack\r
+            // \r
+            this.btn_RemoveAudioTrack.BackColor = System.Drawing.Color.Transparent;\r
+            this.btn_RemoveAudioTrack.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_RemoveAudioTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_RemoveAudioTrack.Location = new System.Drawing.Point(99, 38);\r
+            this.btn_RemoveAudioTrack.Name = "btn_RemoveAudioTrack";\r
+            this.btn_RemoveAudioTrack.Size = new System.Drawing.Size(71, 23);\r
+            this.btn_RemoveAudioTrack.TabIndex = 64;\r
+            this.btn_RemoveAudioTrack.Text = "Remove";\r
+            this.btn_RemoveAudioTrack.UseVisualStyleBackColor = false;\r
+            this.btn_RemoveAudioTrack.Click += new System.EventHandler(this.btn_RemoveAudioTrack_Click);\r
+            // \r
+            // btn_addAudioTrack\r
+            // \r
+            this.btn_addAudioTrack.BackColor = System.Drawing.Color.Transparent;\r
+            this.btn_addAudioTrack.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_addAudioTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_addAudioTrack.Location = new System.Drawing.Point(16, 38);\r
+            this.btn_addAudioTrack.Name = "btn_addAudioTrack";\r
+            this.btn_addAudioTrack.Size = new System.Drawing.Size(77, 23);\r
+            this.btn_addAudioTrack.TabIndex = 63;\r
+            this.btn_addAudioTrack.Text = "Add Track";\r
+            this.btn_addAudioTrack.UseVisualStyleBackColor = false;\r
+            this.btn_addAudioTrack.Click += new System.EventHandler(this.btn_addAudioTrack_Click);\r
+            // \r
+            // lbl_drc\r
+            // \r
+            this.lbl_drc.AutoSize = true;\r
+            this.lbl_drc.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_drc.Location = new System.Drawing.Point(658, 37);\r
+            this.lbl_drc.Name = "lbl_drc";\r
+            this.lbl_drc.Size = new System.Drawing.Size(13, 13);\r
+            this.lbl_drc.TabIndex = 62;\r
+            this.lbl_drc.Text = "0";\r
+            // \r
+            // label16\r
+            // \r
+            this.label16.AutoSize = true;\r
+            this.label16.BackColor = System.Drawing.Color.Transparent;\r
+            this.label16.Location = new System.Drawing.Point(607, 17);\r
+            this.label16.Name = "label16";\r
+            this.label16.Size = new System.Drawing.Size(28, 13);\r
+            this.label16.TabIndex = 61;\r
+            this.label16.Text = "DRC";\r
+            // \r
+            // tb_drc\r
+            // \r
+            this.tb_drc.LargeChange = 0;\r
+            this.tb_drc.Location = new System.Drawing.Point(598, 29);\r
+            this.tb_drc.Margin = new System.Windows.Forms.Padding(0);\r
+            this.tb_drc.Maximum = 31;\r
+            this.tb_drc.Name = "tb_drc";\r
+            this.tb_drc.Size = new System.Drawing.Size(57, 45);\r
+            this.tb_drc.TabIndex = 60;\r
+            this.tb_drc.TickFrequency = 10;\r
+            this.tb_drc.Scroll += new System.EventHandler(this.tb_drc_Scroll);\r
+            // \r
+            // label68\r
+            // \r
+            this.label68.AutoSize = true;\r
+            this.label68.BackColor = System.Drawing.Color.Transparent;\r
+            this.label68.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label68.Location = new System.Drawing.Point(13, 13);\r
+            this.label68.Name = "label68";\r
+            this.label68.Size = new System.Drawing.Size(80, 13);\r
+            this.label68.TabIndex = 49;\r
+            this.label68.Text = "Audio Tracks";\r
+            // \r
+            // label67\r
+            // \r
+            this.label67.AutoSize = true;\r
+            this.label67.BackColor = System.Drawing.Color.Transparent;\r
+            this.label67.Location = new System.Drawing.Point(463, 17);\r
+            this.label67.Name = "label67";\r
+            this.label67.Size = new System.Drawing.Size(61, 13);\r
+            this.label67.TabIndex = 57;\r
+            this.label67.Text = "Samplerate";\r
+            // \r
+            // label66\r
+            // \r
+            this.label66.AutoSize = true;\r
+            this.label66.BackColor = System.Drawing.Color.Transparent;\r
+            this.label66.Location = new System.Drawing.Point(538, 17);\r
+            this.label66.Name = "label66";\r
+            this.label66.Size = new System.Drawing.Size(39, 13);\r
+            this.label66.TabIndex = 59;\r
+            this.label66.Text = "Bitrate";\r
+            // \r
+            // label65\r
+            // \r
+            this.label65.AutoSize = true;\r
+            this.label65.BackColor = System.Drawing.Color.Transparent;\r
+            this.label65.Location = new System.Drawing.Point(234, 17);\r
+            this.label65.Name = "label65";\r
+            this.label65.Size = new System.Drawing.Size(67, 13);\r
+            this.label65.TabIndex = 53;\r
+            this.label65.Text = "Audio Codec";\r
+            // \r
+            // label14\r
+            // \r
+            this.label14.AutoSize = true;\r
+            this.label14.BackColor = System.Drawing.Color.Transparent;\r
+            this.label14.Location = new System.Drawing.Point(368, 17);\r
+            this.label14.Name = "label14";\r
+            this.label14.Size = new System.Drawing.Size(49, 13);\r
+            this.label14.TabIndex = 55;\r
+            this.label14.Text = "Mixdown";\r
+            // \r
+            // drp_audioEncoder\r
+            // \r
+            this.drp_audioEncoder.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_audioEncoder.FormattingEnabled = true;\r
+            this.drp_audioEncoder.Items.AddRange(new object[] {\r
+            "AAC (faac)",\r
+            "MP3 (lame)",\r
+            "Vorbis (vorbis)",\r
+            "AC3 Passthru"});\r
+            this.drp_audioEncoder.Location = new System.Drawing.Point(215, 34);\r
+            this.drp_audioEncoder.Name = "drp_audioEncoder";\r
+            this.drp_audioEncoder.Size = new System.Drawing.Size(111, 21);\r
+            this.drp_audioEncoder.TabIndex = 52;\r
+            this.drp_audioEncoder.SelectedIndexChanged += new System.EventHandler(this.drp_audenc_SelectedIndexChanged);\r
+            // \r
+            // label27\r
+            // \r
+            this.label27.AutoSize = true;\r
+            this.label27.BackColor = System.Drawing.Color.Transparent;\r
+            this.label27.Location = new System.Drawing.Point(86, 17);\r
+            this.label27.Name = "label27";\r
+            this.label27.Size = new System.Drawing.Size(40, 13);\r
+            this.label27.TabIndex = 51;\r
+            this.label27.Text = "Source";\r
+            // \r
+            // drp_audioMix\r
+            // \r
+            this.drp_audioMix.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_audioMix.FormattingEnabled = true;\r
+            this.drp_audioMix.Items.AddRange(new object[] {\r
+            "Automatic",\r
+            "Mono",\r
+            "Stereo",\r
+            "Dolby Surround",\r
+            "Dolby Pro Logic II",\r
+            "6 Channel Discrete"});\r
+            this.drp_audioMix.Location = new System.Drawing.Point(332, 34);\r
+            this.drp_audioMix.Name = "drp_audioMix";\r
+            this.drp_audioMix.Size = new System.Drawing.Size(129, 21);\r
+            this.drp_audioMix.TabIndex = 54;\r
+            this.drp_audioMix.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_SelectedIndexChanged);\r
+            // \r
+            // drp_audioTrack\r
+            // \r
+            this.drp_audioTrack.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_audioTrack.FormattingEnabled = true;\r
+            this.drp_audioTrack.Items.AddRange(new object[] {\r
+            "Automatic"});\r
+            this.drp_audioTrack.Location = new System.Drawing.Point(15, 35);\r
+            this.drp_audioTrack.Name = "drp_audioTrack";\r
+            this.drp_audioTrack.Size = new System.Drawing.Size(194, 21);\r
+            this.drp_audioTrack.TabIndex = 50;\r
+            this.drp_audioTrack.SelectedIndexChanged += new System.EventHandler(this.drp_audioTrack_SelectedIndexChanged);\r
+            // \r
+            // drp_audioBitrate\r
+            // \r
+            this.drp_audioBitrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_audioBitrate.FormattingEnabled = true;\r
+            this.drp_audioBitrate.Items.AddRange(new object[] {\r
+            "32",\r
+            "40",\r
+            "48",\r
+            "56",\r
+            "64",\r
+            "80",\r
+            "96",\r
+            "112",\r
+            "128",\r
+            "160"});\r
+            this.drp_audioBitrate.Location = new System.Drawing.Point(525, 34);\r
+            this.drp_audioBitrate.Name = "drp_audioBitrate";\r
+            this.drp_audioBitrate.Size = new System.Drawing.Size(70, 21);\r
+            this.drp_audioBitrate.TabIndex = 58;\r
+            this.drp_audioBitrate.SelectedIndexChanged += new System.EventHandler(this.drp_audbit_SelectedIndexChanged);\r
+            // \r
+            // drp_audioSample\r
+            // \r
+            this.drp_audioSample.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_audioSample.FormattingEnabled = true;\r
+            this.drp_audioSample.Items.AddRange(new object[] {\r
+            "Auto",\r
+            "48",\r
+            "44.1",\r
+            "32",\r
+            "24",\r
+            "22.05"});\r
+            this.drp_audioSample.Location = new System.Drawing.Point(467, 34);\r
+            this.drp_audioSample.Name = "drp_audioSample";\r
+            this.drp_audioSample.Size = new System.Drawing.Size(55, 21);\r
+            this.drp_audioSample.TabIndex = 56;\r
+            this.drp_audioSample.SelectedIndexChanged += new System.EventHandler(this.drp_audsr_SelectedIndexChanged);\r
+            // \r
+            // AudioTrackGroup\r
+            // \r
+            this.AudioTrackGroup.BackColor = System.Drawing.Color.Transparent;\r
+            this.AudioTrackGroup.Controls.Add(this.drp_audioTrack);\r
+            this.AudioTrackGroup.Controls.Add(this.drp_audioSample);\r
+            this.AudioTrackGroup.Controls.Add(this.drp_audioBitrate);\r
+            this.AudioTrackGroup.Controls.Add(this.drp_audioMix);\r
+            this.AudioTrackGroup.Controls.Add(this.lbl_drc);\r
+            this.AudioTrackGroup.Controls.Add(this.label27);\r
+            this.AudioTrackGroup.Controls.Add(this.label16);\r
+            this.AudioTrackGroup.Controls.Add(this.drp_audioEncoder);\r
+            this.AudioTrackGroup.Controls.Add(this.tb_drc);\r
+            this.AudioTrackGroup.Controls.Add(this.label14);\r
+            this.AudioTrackGroup.Controls.Add(this.label65);\r
+            this.AudioTrackGroup.Controls.Add(this.label67);\r
+            this.AudioTrackGroup.Controls.Add(this.label66);\r
+            this.AudioTrackGroup.Location = new System.Drawing.Point(16, 67);\r
+            this.AudioTrackGroup.Name = "AudioTrackGroup";\r
+            this.AudioTrackGroup.Size = new System.Drawing.Size(689, 77);\r
+            this.AudioTrackGroup.TabIndex = 66;\r
+            this.AudioTrackGroup.TabStop = false;\r
+            this.AudioTrackGroup.Text = "Selected Track: New Track";\r
+            // \r
+            // AudioMenuRowHeightHack\r
+            // \r
+            this.AudioMenuRowHeightHack.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;\r
+            this.AudioMenuRowHeightHack.ImageSize = new System.Drawing.Size(1, 18);\r
+            this.AudioMenuRowHeightHack.TransparentColor = System.Drawing.Color.Transparent;\r
+            // \r
+            // AudioPanel\r
+            // \r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
+            this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.label68);\r
+            this.Controls.Add(this.btn_addAudioTrack);\r
+            this.Controls.Add(this.lv_audioList);\r
+            this.Controls.Add(this.AudioTrackGroup);\r
+            this.Controls.Add(this.btn_RemoveAudioTrack);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Name = "AudioPanel";\r
+            this.Size = new System.Drawing.Size(720, 310);\r
+            this.audioMenu.ResumeLayout(false);\r
+            ((System.ComponentModel.ISupportInitialize)(this.tb_drc)).EndInit();\r
+            this.AudioTrackGroup.ResumeLayout(false);\r
+            this.AudioTrackGroup.PerformLayout();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        internal System.Windows.Forms.ListView lv_audioList;\r
+        private System.Windows.Forms.ColumnHeader col_Source;\r
+        private System.Windows.Forms.ColumnHeader col_codec;\r
+        private System.Windows.Forms.ColumnHeader col_mixdown;\r
+        private System.Windows.Forms.ColumnHeader col_samplerate;\r
+        private System.Windows.Forms.ColumnHeader col_bitrate;\r
+        private System.Windows.Forms.ColumnHeader col_drc;\r
+        private System.Windows.Forms.Button btn_RemoveAudioTrack;\r
+        private System.Windows.Forms.Button btn_addAudioTrack;\r
+        internal System.Windows.Forms.Label lbl_drc;\r
+        internal System.Windows.Forms.Label label16;\r
+        internal System.Windows.Forms.TrackBar tb_drc;\r
+        internal System.Windows.Forms.Label label68;\r
+        internal System.Windows.Forms.Label label67;\r
+        internal System.Windows.Forms.Label label66;\r
+        internal System.Windows.Forms.Label label65;\r
+        internal System.Windows.Forms.Label label14;\r
+        internal System.Windows.Forms.ComboBox drp_audioEncoder;\r
+        internal System.Windows.Forms.Label label27;\r
+        internal System.Windows.Forms.ComboBox drp_audioMix;\r
+        internal System.Windows.Forms.ComboBox drp_audioTrack;\r
+        internal System.Windows.Forms.ComboBox drp_audioSample;\r
+        private System.Windows.Forms.ColumnHeader col_id;\r
+        private System.Windows.Forms.GroupBox AudioTrackGroup;\r
+        private System.Windows.Forms.ImageList AudioMenuRowHeightHack;\r
+        private System.Windows.Forms.ContextMenuStrip audioMenu;\r
+        private System.Windows.Forms.ToolStripMenuItem audioList_moveup;\r
+        private System.Windows.Forms.ToolStripMenuItem audioList_movedown;\r
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;\r
+        private System.Windows.Forms.ToolStripMenuItem audioList_remove;\r
+        internal System.Windows.Forms.ComboBox drp_audioBitrate;\r
+    }\r
+}\r
diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs
new file mode 100644 (file)
index 0000000..b394e3c
--- /dev/null
@@ -0,0 +1,403 @@
+/*  AudioPanel.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    public partial class AudioPanel : UserControl\r
+    {\r
+        public event EventHandler AudioListChanged;\r
+\r
+        public AudioPanel()\r
+        {\r
+            InitializeComponent();\r
+            drp_audioMix.SelectedIndex = 0;\r
+        }\r
+\r
+        // Audio Track Options\r
+        private void drp_audioTrack_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[1].Text = drp_audioTrack.Text;\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+        private void drp_audenc_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            // Setup the widgets with the correct avail options\r
+            if (drp_audioEncoder.Text.Contains("AAC"))\r
+            {\r
+                setMixDown(true);\r
+                setBitrate(160);\r
+            }\r
+            else\r
+            {\r
+                setMixDown(false);\r
+                setBitrate(320);\r
+            }\r
+\r
+            // Configure the widgets with values\r
+            if (drp_audioEncoder.Text.Contains("AC3") || drp_audioEncoder.Text.Contains("DTS"))\r
+            {\r
+                drp_audioMix.Enabled = false;\r
+                drp_audioBitrate.Enabled = false;\r
+                drp_audioSample.Enabled = false;\r
+\r
+                drp_audioMix.SelectedIndex = 0;\r
+                drp_audioBitrate.SelectedIndex = 0;\r
+                drp_audioSample.SelectedIndex = 0;\r
+            }\r
+            else\r
+            {\r
+                drp_audioMix.Enabled = true;\r
+                drp_audioBitrate.Enabled = true;\r
+                drp_audioSample.Enabled = true;\r
+\r
+                drp_audioMix.SelectedIndex = 0;\r
+                drp_audioBitrate.SelectedIndex = 9;\r
+                drp_audioSample.SelectedIndex = 0;\r
+            }\r
+\r
+            // Update an item in the Audio list if required.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[2].Text = drp_audioEncoder.Text;\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+        private void drp_audmix_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            if ((drp_audioEncoder.Text.Contains("AAC")) && (drp_audioMix.Text == "6 Channel Discrete"))\r
+                setBitrate(384);\r
+            else if ((drp_audioEncoder.Text.Contains("AAC")) && (drp_audioMix.Text != "6 Channel Discrete"))\r
+                setBitrate(160);\r
+\r
+            // Update an item in the Audio list if required.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[3].Text = drp_audioMix.Text;\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+        private void drp_audsr_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            // Update an item in the Audio list if required.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text = drp_audioSample.Text;\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+        private void drp_audbit_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            // Update an item in the Audio list if required.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                if (drp_audioEncoder.Text.Contains("AC3"))\r
+                    drp_audioBitrate.SelectedItem = "Auto";\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[5].Text = drp_audioBitrate.Text;\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+        private void tb_drc_Scroll(object sender, EventArgs e)\r
+        {\r
+            double value;\r
+            if (tb_drc.Value == 0) value = 0;\r
+            else\r
+                value = ((tb_drc.Value - 1) / 10.0) + 1;\r
+\r
+            lbl_drc.Text = value.ToString();\r
+\r
+            // Update an item in the Audio list if required.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text = value.ToString();\r
+                lv_audioList.Select();\r
+            }\r
+        }\r
+\r
+        // Track Controls\r
+        private void btn_addAudioTrack_Click(object sender, EventArgs e)\r
+        {\r
+            double value = 0;\r
+            if (tb_drc.Value != 0)\r
+                value = ((tb_drc.Value - 1) / 10.0) + 1;\r
+\r
+            // Create a new row for the Audio list based on the currently selected items in the dropdown.\r
+            ListViewItem newTrack = new ListViewItem(GetNewID().ToString());\r
+            newTrack.SubItems.Add(drp_audioTrack.Text);\r
+            newTrack.SubItems.Add(drp_audioEncoder.Text);\r
+            newTrack.SubItems.Add(drp_audioMix.Text);\r
+            newTrack.SubItems.Add(drp_audioSample.Text);\r
+            newTrack.SubItems.Add(drp_audioBitrate.Text);\r
+            newTrack.SubItems.Add(value.ToString());\r
+            lv_audioList.Items.Add(newTrack);\r
+\r
+            // The Audio List has changed to raise the event.\r
+            if (this.AudioListChanged != null)\r
+                this.AudioListChanged(this, new EventArgs());\r
+\r
+            // Select the newly added track and select the control       \r
+            lv_audioList.Items[lv_audioList.Items.Count - 1].Selected = true;\r
+            lv_audioList.Select();\r
+        }\r
+        private void btn_RemoveAudioTrack_Click(object sender, EventArgs e)\r
+        {\r
+            RemoveAudioTrack();\r
+        }\r
+\r
+        // Audio List Menu\r
+        private void audioList_moveup_Click(object sender, EventArgs e)\r
+        {\r
+            if (lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                ListViewItem item = lv_audioList.SelectedItems[0];\r
+                int index = item.Index;\r
+                index--;\r
+\r
+                if (lv_audioList.Items.Count > index && index >= 0)\r
+                {\r
+                    lv_audioList.Items.Remove(item);\r
+                    lv_audioList.Items.Insert(index, item);\r
+                    item.Selected = true;\r
+                    lv_audioList.Focus();\r
+                }\r
+            }\r
+        }\r
+        private void audioList_movedown_Click(object sender, EventArgs e)\r
+        {\r
+            if (lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                ListViewItem item = lv_audioList.SelectedItems[0];\r
+                int index = item.Index;\r
+                index++;\r
+\r
+                if (index < lv_audioList.Items.Count)\r
+                {\r
+                    lv_audioList.Items.Remove(item);\r
+                    lv_audioList.Items.Insert(index, item);\r
+                    item.Selected = true;\r
+                    lv_audioList.Focus();\r
+                }\r
+            }\r
+        }\r
+        private void audioList_remove_Click(object sender, EventArgs e)\r
+        {\r
+            RemoveAudioTrack();\r
+        }\r
+        private void RemoveAudioTrack()\r
+        {\r
+            // Remove the Item and reselect the control if the following conditions are met.\r
+            if (lv_audioList.SelectedItems.Count != 0)\r
+            {\r
+                // The Audio List is about to change so raise the event.\r
+                if (this.AudioListChanged != null)\r
+                    this.AudioListChanged(this, new EventArgs());\r
+\r
+                // Record the current selected index.\r
+                int currentPosition = lv_audioList.SelectedIndices[0];\r
+\r
+                lv_audioList.Items.RemoveAt(lv_audioList.SelectedIndices[0]);\r
+\r
+                // Now reslect the correct item and give focus to the audio list.\r
+                if (lv_audioList.Items.Count != 0)\r
+                {\r
+                    if (currentPosition <= (lv_audioList.Items.Count - 1))\r
+                        lv_audioList.Items[currentPosition].Selected = true;\r
+                    else if (currentPosition > (lv_audioList.Items.Count - 1))\r
+                        lv_audioList.Items[lv_audioList.Items.Count - 1].Selected = true;\r
+\r
+                    lv_audioList.Select();\r
+                }\r
+                // Regenerate the ID numers\r
+                reGenerateListIDs();\r
+            }\r
+        }\r
+\r
+        // Public Functions\r
+        public void SetTrackList(Parsing.Title selectedTitle)\r
+        {\r
+            drp_audioTrack.Items.Clear();\r
+            drp_audioTrack.Items.Add("Automatic");\r
+            drp_audioTrack.Items.Add("None");\r
+            drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
+\r
+            // Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options\r
+            if (Properties.Settings.Default.NativeLanguage == "Any")\r
+                drp_audioTrack.SelectedIndex = 0;\r
+            else\r
+            {\r
+                if (Properties.Settings.Default.DubAudio) // "Dub Foreign language audio" \r
+                {\r
+                    int i = 0;\r
+                    foreach (object item in drp_audioTrack.Items)\r
+                    {\r
+                        if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage))\r
+                        {\r
+                            drp_audioTrack.SelectedIndex = i;\r
+                            break;\r
+                        }\r
+\r
+                        i++;\r
+                    }\r
+\r
+                    if (drp_audioTrack.SelectedItem != null)\r
+                        foreach (ListViewItem item in lv_audioList.Items)\r
+                            item.SubItems[1].Text = drp_audioTrack.SelectedItem.ToString();\r
+                    else\r
+                    {\r
+                        drp_audioTrack.SelectedIndex = 0;\r
+                        if (drp_audioTrack.SelectedItem != null)\r
+                            foreach (ListViewItem item in lv_audioList.Items)\r
+                                item.SubItems[1].Text = drp_audioTrack.SelectedItem.ToString();\r
+                    }\r
+                }\r
+                else\r
+                    drp_audioTrack.SelectedIndex = 0; // "Use Foreign language audio and Subtitles"\r
+            }\r
+            drp_audioMix.SelectedIndex = 0;\r
+        }\r
+        public ListView GetAudioPanel()\r
+        {\r
+            return lv_audioList;\r
+        }\r
+        public void SetContainer(String path)\r
+        {\r
+            string oldval = drp_audioEncoder.Text;\r
+            if ((path.Contains("MP4")) || (path.Contains("M4V")))\r
+            {\r
+                drp_audioEncoder.Items.Clear();\r
+                drp_audioEncoder.Items.Add("AAC (faac)");\r
+                drp_audioEncoder.Items.Add("AC3 Passthru");\r
+                if ((oldval != "AAC (faac)") && (oldval != "AC3 Passthru"))\r
+                    drp_audioEncoder.SelectedIndex = 0;\r
+                else\r
+                    drp_audioEncoder.SelectedItem = oldval;\r
+\r
+            }\r
+            else if (path.Contains("MKV"))\r
+            {\r
+                drp_audioEncoder.Items.Clear();\r
+                drp_audioEncoder.Items.Add("AAC (faac)");\r
+                drp_audioEncoder.Items.Add("MP3 (lame)");\r
+                drp_audioEncoder.Items.Add("AC3 Passthru");\r
+                drp_audioEncoder.Items.Add("DTS Passthru");\r
+                drp_audioEncoder.Items.Add("Vorbis (vorbis)");\r
+                drp_audioEncoder.SelectedItem = oldval;\r
+\r
+                if (drp_audioEncoder.Text == string.Empty)\r
+                    drp_audioEncoder.SelectedIndex = 0;\r
+            }\r
+\r
+            // Make sure the table is updated with new audio codecs\r
+            foreach (ListViewItem row in lv_audioList.Items)\r
+            {\r
+                if (!drp_audioEncoder.Items.Contains(row.SubItems[2].Text))\r
+                    row.SubItems[2].Text = drp_audioEncoder.Items[0].ToString();\r
+            }\r
+        }\r
+        public void AddTrackForPreset(ListViewItem item)\r
+        {\r
+            lv_audioList.Items.Add(item);\r
+            if (this.AudioListChanged != null)\r
+                this.AudioListChanged(this, new EventArgs());\r
+        }\r
+        public void ClearAudioList()\r
+        {\r
+            lv_audioList.Items.Clear();\r
+            if (this.AudioListChanged != null)\r
+                this.AudioListChanged(this, new EventArgs());\r
+        }\r
+        public int GetNewID()\r
+        {\r
+            return lv_audioList.Items.Count + 1;\r
+        }\r
+        public Boolean RequiresM4V()\r
+        {\r
+            foreach (ListViewItem item in lv_audioList.Items)\r
+            {\r
+                if (item.SubItems[2].Text.Contains("AC3"))\r
+                    return true;\r
+            }\r
+            return false;\r
+        }\r
+\r
+        // Helper Functions \r
+        private void reGenerateListIDs()\r
+        {\r
+            int i = 1;\r
+            foreach (ListViewItem item in lv_audioList.Items)\r
+            {\r
+                item.SubItems[0].Text = i.ToString();\r
+                i++;\r
+            }\r
+        }\r
+        private void setBitrate(int max)\r
+        {\r
+            if (max > 160)\r
+            {\r
+                drp_audioBitrate.Items.Add("192");\r
+                drp_audioBitrate.Items.Add("224");\r
+                drp_audioBitrate.Items.Add("256");\r
+                drp_audioBitrate.Items.Add("320");\r
+                if (max == 384)\r
+                    drp_audioBitrate.Items.Add("384");\r
+                else\r
+                    drp_audioBitrate.Items.Remove("384");\r
+            }\r
+            else\r
+            {\r
+                drp_audioBitrate.Items.Remove("192");\r
+                drp_audioBitrate.Items.Remove("224");\r
+                drp_audioBitrate.Items.Remove("256");\r
+                drp_audioBitrate.Items.Remove("320");\r
+                drp_audioBitrate.Items.Remove("384");\r
+            }\r
+            if (drp_audioBitrate.SelectedItem == null)\r
+                drp_audioBitrate.SelectedIndex = drp_audioBitrate.Items.Count - 1;\r
+        }\r
+        private void setMixDown(Boolean aac)\r
+        {\r
+            drp_audioMix.Items.Clear();\r
+            drp_audioMix.Items.Add("Automatic");\r
+            if (aac)\r
+                drp_audioMix.Items.Add("Mono");\r
+            drp_audioMix.Items.Add("Stereo");\r
+            drp_audioMix.Items.Add("Dolby Surround");\r
+            drp_audioMix.Items.Add("Dolby Pro Logic II");\r
+            if (aac)\r
+                drp_audioMix.Items.Add("6 Channel Discrete");\r
+        }\r
+        private void lv_audioList_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            // Set the dropdown controls based on the selected item in the Audio List.\r
+            if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
+            {\r
+                drp_audioTrack.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[1].Text;\r
+                drp_audioEncoder.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[2].Text;\r
+                drp_audioMix.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[3].Text;\r
+                drp_audioSample.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text;\r
+                drp_audioBitrate.SelectedItem = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[5].Text;\r
+                double drcValue; int drcCalculated;\r
+                double.TryParse(lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text, out drcValue);\r
+                if (drcValue == 0) drcCalculated = 0;\r
+                else\r
+                    drcValue = ((drcValue * 10) + 1) - 10;\r
+                int.TryParse(drcValue.ToString(), out drcCalculated);\r
+                tb_drc.Value = drcCalculated;\r
+                lbl_drc.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text;\r
+\r
+                AudioTrackGroup.Text = "Selected Track: " + lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[0].Text;\r
+            }\r
+            else\r
+                AudioTrackGroup.Text = "Selected Track: None (Click \"Add Track\" to add)";\r
+        }\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/Controls/AudioPanel.resx b/win/C#/Controls/AudioPanel.resx
new file mode 100644 (file)
index 0000000..07fd5e2
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <metadata name="audioMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>216, 16</value>\r
+  </metadata>\r
+  <metadata name="AudioMenuRowHeightHack.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>35, 17</value>\r
+  </metadata>\r
+</root>
\ No newline at end of file
diff --git a/win/C#/Controls/Filters.Designer.cs b/win/C#/Controls/Filters.Designer.cs
new file mode 100644 (file)
index 0000000..cc2346a
--- /dev/null
@@ -0,0 +1,339 @@
+namespace Handbrake.Controls\r
+{\r
+    partial class Filters\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.text_customDT = new System.Windows.Forms.TextBox();\r
+            this.label18 = new System.Windows.Forms.Label();\r
+            this.drop_detelecine = new System.Windows.Forms.ComboBox();\r
+            this.text_customDC = new System.Windows.Forms.TextBox();\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.drop_decomb = new System.Windows.Forms.ComboBox();\r
+            this.text_customDI = new System.Windows.Forms.TextBox();\r
+            this.label2 = new System.Windows.Forms.Label();\r
+            this.drop_deinterlace = new System.Windows.Forms.ComboBox();\r
+            this.text_customDN = new System.Windows.Forms.TextBox();\r
+            this.label3 = new System.Windows.Forms.Label();\r
+            this.drop_denoise = new System.Windows.Forms.ComboBox();\r
+            this.slider_deblock = new System.Windows.Forms.TrackBar();\r
+            this.check_grayscale = new System.Windows.Forms.CheckBox();\r
+            this.label8 = new System.Windows.Forms.Label();\r
+            this.lbl_deblockVal = new System.Windows.Forms.Label();\r
+            this.label68 = new System.Windows.Forms.Label();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_deblock)).BeginInit();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
+            this.SuspendLayout();\r
+            // \r
+            // text_customDT\r
+            // \r
+            this.text_customDT.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_customDT.Location = new System.Drawing.Point(251, 3);\r
+            this.text_customDT.Name = "text_customDT";\r
+            this.text_customDT.Size = new System.Drawing.Size(115, 21);\r
+            this.text_customDT.TabIndex = 47;\r
+            this.text_customDT.Visible = false;\r
+            // \r
+            // label18\r
+            // \r
+            this.label18.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label18.AutoSize = true;\r
+            this.label18.BackColor = System.Drawing.Color.Transparent;\r
+            this.label18.Location = new System.Drawing.Point(0, 7);\r
+            this.label18.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label18.Name = "label18";\r
+            this.label18.Size = new System.Drawing.Size(61, 13);\r
+            this.label18.TabIndex = 46;\r
+            this.label18.Text = "Detelecine:";\r
+            // \r
+            // drop_detelecine\r
+            // \r
+            this.drop_detelecine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.drop_detelecine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_detelecine.FormattingEnabled = true;\r
+            this.drop_detelecine.Items.AddRange(new object[] {\r
+            "Off",\r
+            "Custom",\r
+            "Default"});\r
+            this.drop_detelecine.Location = new System.Drawing.Point(71, 3);\r
+            this.drop_detelecine.Name = "drop_detelecine";\r
+            this.drop_detelecine.Size = new System.Drawing.Size(174, 21);\r
+            this.drop_detelecine.TabIndex = 45;\r
+            this.drop_detelecine.SelectedIndexChanged += new System.EventHandler(this.drop_detelecine_SelectedIndexChanged);\r
+            // \r
+            // text_customDC\r
+            // \r
+            this.text_customDC.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_customDC.Location = new System.Drawing.Point(251, 30);\r
+            this.text_customDC.Name = "text_customDC";\r
+            this.text_customDC.Size = new System.Drawing.Size(115, 21);\r
+            this.text_customDC.TabIndex = 50;\r
+            this.text_customDC.Visible = false;\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label1.AutoSize = true;\r
+            this.label1.BackColor = System.Drawing.Color.Transparent;\r
+            this.label1.Location = new System.Drawing.Point(0, 34);\r
+            this.label1.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(49, 13);\r
+            this.label1.TabIndex = 49;\r
+            this.label1.Text = "Decomb:";\r
+            // \r
+            // drop_decomb\r
+            // \r
+            this.drop_decomb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.drop_decomb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_decomb.FormattingEnabled = true;\r
+            this.drop_decomb.Items.AddRange(new object[] {\r
+            "Off",\r
+            "Custom",\r
+            "Default"});\r
+            this.drop_decomb.Location = new System.Drawing.Point(71, 30);\r
+            this.drop_decomb.Name = "drop_decomb";\r
+            this.drop_decomb.Size = new System.Drawing.Size(174, 21);\r
+            this.drop_decomb.TabIndex = 48;\r
+            this.drop_decomb.SelectedIndexChanged += new System.EventHandler(this.drop_decomb_SelectedIndexChanged);\r
+            // \r
+            // text_customDI\r
+            // \r
+            this.text_customDI.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_customDI.Location = new System.Drawing.Point(251, 57);\r
+            this.text_customDI.Name = "text_customDI";\r
+            this.text_customDI.Size = new System.Drawing.Size(115, 21);\r
+            this.text_customDI.TabIndex = 53;\r
+            this.text_customDI.Visible = false;\r
+            // \r
+            // label2\r
+            // \r
+            this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label2.AutoSize = true;\r
+            this.label2.BackColor = System.Drawing.Color.Transparent;\r
+            this.label2.Location = new System.Drawing.Point(0, 61);\r
+            this.label2.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label2.Name = "label2";\r
+            this.label2.Size = new System.Drawing.Size(65, 13);\r
+            this.label2.TabIndex = 52;\r
+            this.label2.Text = "Deinterlace:";\r
+            // \r
+            // drop_deinterlace\r
+            // \r
+            this.drop_deinterlace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.drop_deinterlace.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_deinterlace.FormattingEnabled = true;\r
+            this.drop_deinterlace.Items.AddRange(new object[] {\r
+            "Off",\r
+            "Custom",\r
+            "Fast",\r
+            "Slow",\r
+            "Slower"});\r
+            this.drop_deinterlace.Location = new System.Drawing.Point(71, 57);\r
+            this.drop_deinterlace.Name = "drop_deinterlace";\r
+            this.drop_deinterlace.Size = new System.Drawing.Size(174, 21);\r
+            this.drop_deinterlace.TabIndex = 51;\r
+            this.drop_deinterlace.SelectedIndexChanged += new System.EventHandler(this.drop_deinterlace_SelectedIndexChanged);\r
+            // \r
+            // text_customDN\r
+            // \r
+            this.text_customDN.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_customDN.Location = new System.Drawing.Point(251, 84);\r
+            this.text_customDN.Name = "text_customDN";\r
+            this.text_customDN.Size = new System.Drawing.Size(115, 21);\r
+            this.text_customDN.TabIndex = 56;\r
+            this.text_customDN.Visible = false;\r
+            // \r
+            // label3\r
+            // \r
+            this.label3.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label3.AutoSize = true;\r
+            this.label3.BackColor = System.Drawing.Color.Transparent;\r
+            this.label3.Location = new System.Drawing.Point(0, 88);\r
+            this.label3.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label3.Name = "label3";\r
+            this.label3.Size = new System.Drawing.Size(49, 13);\r
+            this.label3.TabIndex = 55;\r
+            this.label3.Text = "Denoise:";\r
+            // \r
+            // drop_denoise\r
+            // \r
+            this.drop_denoise.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.drop_denoise.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_denoise.FormattingEnabled = true;\r
+            this.drop_denoise.Items.AddRange(new object[] {\r
+            "Off",\r
+            "Custom",\r
+            "Weak",\r
+            "Medium",\r
+            "Strong"});\r
+            this.drop_denoise.Location = new System.Drawing.Point(71, 84);\r
+            this.drop_denoise.Name = "drop_denoise";\r
+            this.drop_denoise.Size = new System.Drawing.Size(174, 21);\r
+            this.drop_denoise.TabIndex = 54;\r
+            this.drop_denoise.SelectedIndexChanged += new System.EventHandler(this.drop_denoise_SelectedIndexChanged);\r
+            // \r
+            // slider_deblock\r
+            // \r
+            this.slider_deblock.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.slider_deblock.Location = new System.Drawing.Point(71, 111);\r
+            this.slider_deblock.Maximum = 15;\r
+            this.slider_deblock.Minimum = 4;\r
+            this.slider_deblock.Name = "slider_deblock";\r
+            this.slider_deblock.Size = new System.Drawing.Size(174, 45);\r
+            this.slider_deblock.TabIndex = 58;\r
+            this.slider_deblock.Value = 4;\r
+            this.slider_deblock.Scroll += new System.EventHandler(this.slider_deblock_Scroll);\r
+            // \r
+            // check_grayscale\r
+            // \r
+            this.check_grayscale.AutoSize = true;\r
+            this.check_grayscale.BackColor = System.Drawing.Color.Transparent;\r
+            this.check_grayscale.Location = new System.Drawing.Point(71, 162);\r
+            this.check_grayscale.Name = "check_grayscale";\r
+            this.check_grayscale.Size = new System.Drawing.Size(119, 17);\r
+            this.check_grayscale.TabIndex = 57;\r
+            this.check_grayscale.Text = "Grayscale Encoding";\r
+            this.check_grayscale.UseVisualStyleBackColor = false;\r
+            // \r
+            // label8\r
+            // \r
+            this.label8.AutoSize = true;\r
+            this.label8.BackColor = System.Drawing.Color.Transparent;\r
+            this.label8.Location = new System.Drawing.Point(0, 115);\r
+            this.label8.Margin = new System.Windows.Forms.Padding(0, 7, 3, 3);\r
+            this.label8.Name = "label8";\r
+            this.label8.Size = new System.Drawing.Size(48, 13);\r
+            this.label8.TabIndex = 60;\r
+            this.label8.Text = "Deblock:";\r
+            // \r
+            // lbl_deblockVal\r
+            // \r
+            this.lbl_deblockVal.AutoSize = true;\r
+            this.lbl_deblockVal.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_deblockVal.Location = new System.Drawing.Point(251, 115);\r
+            this.lbl_deblockVal.Margin = new System.Windows.Forms.Padding(3, 7, 3, 3);\r
+            this.lbl_deblockVal.Name = "lbl_deblockVal";\r
+            this.lbl_deblockVal.Size = new System.Drawing.Size(23, 13);\r
+            this.lbl_deblockVal.TabIndex = 59;\r
+            this.lbl_deblockVal.Text = "Off";\r
+            // \r
+            // label68\r
+            // \r
+            this.label68.AutoSize = true;\r
+            this.label68.BackColor = System.Drawing.Color.Transparent;\r
+            this.label68.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label68.Location = new System.Drawing.Point(13, 13);\r
+            this.label68.Name = "label68";\r
+            this.label68.Size = new System.Drawing.Size(42, 13);\r
+            this.label68.TabIndex = 61;\r
+            this.label68.Text = "Filters";\r
+            // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.AutoSize = true;\r
+            this.tableLayoutPanel1.ColumnCount = 3;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.label18, 0, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_deblockVal, 2, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.check_grayscale, 1, 5);\r
+            this.tableLayoutPanel1.Controls.Add(this.text_customDN, 2, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.slider_deblock, 1, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.text_customDI, 2, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.label2, 0, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.text_customDC, 2, 1);\r
+            this.tableLayoutPanel1.Controls.Add(this.label3, 0, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.text_customDT, 2, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.label8, 0, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_detelecine, 1, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_denoise, 1, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_decomb, 1, 1);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_deinterlace, 1, 2);\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(19, 29);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 6;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(369, 182);\r
+            this.tableLayoutPanel1.TabIndex = 62;\r
+            // \r
+            // Filters\r
+            // \r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
+            this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.Controls.Add(this.label68);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Name = "Filters";\r
+            this.Size = new System.Drawing.Size(592, 270);\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_deblock)).EndInit();\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.TextBox text_customDT;\r
+        private System.Windows.Forms.Label label18;\r
+        internal System.Windows.Forms.ComboBox drop_detelecine;\r
+        private System.Windows.Forms.TextBox text_customDC;\r
+        internal System.Windows.Forms.Label label1;\r
+        internal System.Windows.Forms.ComboBox drop_decomb;\r
+        private System.Windows.Forms.TextBox text_customDI;\r
+        internal System.Windows.Forms.Label label2;\r
+        internal System.Windows.Forms.ComboBox drop_deinterlace;\r
+        private System.Windows.Forms.TextBox text_customDN;\r
+        internal System.Windows.Forms.Label label3;\r
+        internal System.Windows.Forms.ComboBox drop_denoise;\r
+        internal System.Windows.Forms.TrackBar slider_deblock;\r
+        internal System.Windows.Forms.CheckBox check_grayscale;\r
+        internal System.Windows.Forms.Label label8;\r
+        internal System.Windows.Forms.Label lbl_deblockVal;\r
+        internal System.Windows.Forms.Label label68;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
+    }\r
+}\r
diff --git a/win/C#/Controls/Filters.cs b/win/C#/Controls/Filters.cs
new file mode 100644 (file)
index 0000000..c5c56fc
--- /dev/null
@@ -0,0 +1,267 @@
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    public partial class Filters : UserControl\r
+    {\r
+        public event EventHandler FilterSettingsChanged;\r
+\r
+        public Filters()\r
+        {\r
+            InitializeComponent();\r
+            drop_decomb.SelectedIndex = 0;\r
+            drop_deinterlace.SelectedIndex = 0;\r
+            drop_denoise.SelectedIndex = 0;\r
+            drop_detelecine.SelectedIndex = 0;\r
+        }\r
+\r
+        // Controls\r
+        private void drop_detelecine_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            text_customDT.Visible = drop_detelecine.Text == "Custom";\r
+            // A Filter has changed so raise a FilterSettingsChanged event.\r
+            if (this.FilterSettingsChanged != null)\r
+                this.FilterSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void drop_decomb_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            text_customDC.Visible = drop_decomb.Text == "Custom";\r
+            if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0)\r
+                drop_deinterlace.SelectedIndex = 0;\r
+\r
+            // A Filter has changed so raise a FilterSettingsChanged event.\r
+            if (this.FilterSettingsChanged != null)\r
+                this.FilterSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void drop_deinterlace_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            text_customDI.Visible = drop_deinterlace.Text == "Custom";\r
+            if (drop_decomb.SelectedIndex != 0 && drop_deinterlace.SelectedIndex != 0)\r
+                drop_decomb.SelectedIndex = 0;\r
+\r
+            // A Filter has changed so raise a FilterSettingsChanged event.\r
+            if (this.FilterSettingsChanged != null)\r
+                this.FilterSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void drop_denoise_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            text_customDN.Visible = drop_denoise.Text == "Custom";\r
+\r
+            // A Filter has changed so raise a FilterSettingsChanged event.\r
+            if (this.FilterSettingsChanged != null)\r
+                this.FilterSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void slider_deblock_Scroll(object sender, EventArgs e)\r
+        {\r
+            lbl_deblockVal.Text = slider_deblock.Value == 4 ? "Off" : slider_deblock.Value.ToString();\r
+\r
+            // A Filter has changed so raise a FilterSettingsChanged event.\r
+            if (this.FilterSettingsChanged != null)\r
+                this.FilterSettingsChanged(this, new EventArgs());\r
+        }\r
+\r
+        // Returns the CLI query for the query generator.\r
+        public string getCLIQuery\r
+        {\r
+            get\r
+            {\r
+                string query = "";\r
+\r
+                switch (drop_detelecine.Text)  // DeTelecine\r
+                {\r
+                    case "Off":\r
+                        query += "";\r
+                        break;\r
+                    case "Default":\r
+                        query += " --detelecine";\r
+                        break;\r
+                    case "Custom":\r
+                        query += " --detelecine=\"" + text_customDT.Text + "\"";\r
+                        break;\r
+                    default:\r
+                        query += "";\r
+                        break;\r
+                }\r
+\r
+\r
+                switch (drop_decomb.Text) // Decomb\r
+                {\r
+                    case "Off":\r
+                        query += "";\r
+                        break;\r
+                    case "Default":\r
+                        query += " --decomb";\r
+                        break;\r
+                    case "Custom":\r
+                        query += " --decomb=\"" + text_customDC.Text + "\"";\r
+                        break;\r
+                    default:\r
+                        query += "";\r
+                        break;\r
+                }\r
+\r
+                switch (drop_deinterlace.Text) // DeInterlace\r
+                {\r
+                    case "None":\r
+                        query += "";\r
+                        break;\r
+                    case "Fast":\r
+                        query += " --deinterlace=\"fast\"";\r
+                        break;\r
+                    case "Slow":\r
+                        query += " --deinterlace=\"slow\"";\r
+                        break;\r
+                    case "Slower":\r
+                        query += " --deinterlace=\"slower\"";\r
+                        break;\r
+                    case "Custom":\r
+                        query += " --deinterlace=\"" + text_customDI.Text + "\"";\r
+                        break;\r
+                    default:\r
+                        query += "";\r
+                        break;\r
+                }\r
+\r
+                switch (drop_denoise.Text) // Denoise\r
+                {\r
+                    case "None":\r
+                        query += "";\r
+                        break;\r
+                    case "Weak":\r
+                        query += " --denoise=\"weak\"";\r
+                        break;\r
+                    case "Medium":\r
+                        query += " --denoise=\"medium\"";\r
+                        break;\r
+                    case "Strong":\r
+                        query += " --denoise=\"strong\"";\r
+                        break;\r
+                    case "Custom":\r
+                        query += " --denoise=\"" + text_customDN.Text + "\"";\r
+                        break;\r
+                    default:\r
+                        query += "";\r
+                        break;\r
+                }\r
+\r
+                if (slider_deblock.Value != 4)\r
+                    query += " --deblock=" + slider_deblock.Value;\r
+\r
+                if (check_grayscale.Checked)\r
+                    query += " -g ";\r
+\r
+                return query;\r
+            }\r
+        }\r
+\r
+        // Setup for each component for the preset loader.\r
+        public void setDeTelecine(string value)\r
+        {\r
+            text_customDT.Text = "";\r
+            text_customDT.Visible = false;\r
+            switch (value)\r
+            {\r
+                case "Off":\r
+                    drop_detelecine.SelectedIndex = 0;\r
+                    break;\r
+                case "Default":\r
+                    drop_detelecine.SelectedIndex = 2;\r
+                    break;\r
+                default:\r
+                    drop_detelecine.SelectedIndex = 1;\r
+                    text_customDT.Text = value;\r
+                    text_customDT.Visible = true;\r
+                    break;\r
+            }\r
+        }\r
+        public void setDeNoise(string value)\r
+        {\r
+            text_customDN.Text = "";\r
+            text_customDN.Visible = false;\r
+            switch (value)\r
+            {\r
+                case "Off":\r
+                    drop_denoise.SelectedIndex = 0;\r
+                    break;\r
+                case "Weak":\r
+                    drop_denoise.SelectedIndex = 2;\r
+                    break;\r
+                case "Medium":\r
+                    drop_denoise.SelectedIndex = 3;\r
+                    break;\r
+                case "Strong":\r
+                    drop_denoise.SelectedIndex = 4;\r
+                    break;\r
+                default:\r
+                    drop_denoise.SelectedIndex = 1;\r
+                    text_customDN.Text = value;\r
+                    text_customDN.Visible = true;\r
+                    break;\r
+            }\r
+        }\r
+        public void setDeInterlace(string value)\r
+        {\r
+            text_customDI.Text = "";\r
+            text_customDI.Visible = false;\r
+            switch (value)\r
+            {\r
+\r
+                case "Off":\r
+                    drop_deinterlace.SelectedIndex = 0;\r
+                    break;\r
+                case "Fast":\r
+                    drop_deinterlace.SelectedIndex = 2;\r
+                    break;\r
+                case "Slow":\r
+                    drop_deinterlace.SelectedIndex = 3;\r
+                    break;\r
+                case "Slower":\r
+                    drop_deinterlace.SelectedIndex = 4;\r
+\r
+                    break;\r
+                default:\r
+                    drop_deinterlace.SelectedIndex = 1;\r
+                    text_customDI.Text = value;\r
+                    text_customDI.Visible = true;\r
+                    break;\r
+            }\r
+        }\r
+        public void setDecomb(string value)\r
+        {\r
+            text_customDC.Text = "";\r
+            text_customDC.Visible = false;\r
+            switch (value)\r
+            {\r
+                case "Off":\r
+                    drop_decomb.SelectedIndex = 0;\r
+                    break;\r
+                case "Default":\r
+                    drop_decomb.SelectedIndex = 2;\r
+                    break;\r
+                default:\r
+                    drop_decomb.SelectedIndex = 1;\r
+                    text_customDC.Text = value;\r
+                    text_customDC.Visible = true;\r
+                    break;\r
+            }\r
+        }\r
+        public void setDeBlock(int value)\r
+        {\r
+            if (value != 0)\r
+            {\r
+                slider_deblock.Value = value;\r
+                lbl_deblockVal.Text = value.ToString();\r
+            }\r
+            else\r
+            {\r
+                slider_deblock.Value = 4;\r
+                lbl_deblockVal.Text = "Off";\r
+            }\r
+        }\r
+        public void setGrayScale(bool value)\r
+        {\r
+            check_grayscale.CheckState = value ? CheckState.Checked : CheckState.Unchecked;\r
+        } \r
+    }\r
+}\r
diff --git a/win/C#/Controls/Filters.resx b/win/C#/Controls/Filters.resx
new file mode 100644 (file)
index 0000000..ff31a6d
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
diff --git a/win/C#/Controls/PictureSettings.Designer.cs b/win/C#/Controls/PictureSettings.Designer.cs
new file mode 100644 (file)
index 0000000..30a8933
--- /dev/null
@@ -0,0 +1,723 @@
+namespace Handbrake.Controls\r
+{\r
+    partial class PictureSettings\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.Label15 = new System.Windows.Forms.Label();\r
+            this.crop_left = new System.Windows.Forms.NumericUpDown();\r
+            this.crop_right = new System.Windows.Forms.NumericUpDown();\r
+            this.check_autoCrop = new System.Windows.Forms.RadioButton();\r
+            this.Label51 = new System.Windows.Forms.Label();\r
+            this.crop_top = new System.Windows.Forms.NumericUpDown();\r
+            this.Label53 = new System.Windows.Forms.Label();\r
+            this.Label52 = new System.Windows.Forms.Label();\r
+            this.crop_bottom = new System.Windows.Forms.NumericUpDown();\r
+            this.check_customCrop = new System.Windows.Forms.RadioButton();\r
+            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.label7 = new System.Windows.Forms.Label();\r
+            this.lbl_src_res = new System.Windows.Forms.Label();\r
+            this.Label91 = new System.Windows.Forms.Label();\r
+            this.lbl_Aspect = new System.Windows.Forms.Label();\r
+            this.Label55 = new System.Windows.Forms.Label();\r
+            this.text_width = new System.Windows.Forms.NumericUpDown();\r
+            this.lbl_max = new System.Windows.Forms.Label();\r
+            this.label4 = new System.Windows.Forms.Label();\r
+            this.text_height = new System.Windows.Forms.NumericUpDown();\r
+            this.check_KeepAR = new System.Windows.Forms.CheckBox();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.updownParHeight = new System.Windows.Forms.NumericUpDown();\r
+            this.label6 = new System.Windows.Forms.Label();\r
+            this.labelDisplaySize = new System.Windows.Forms.Label();\r
+            this.lbl_parHeight = new System.Windows.Forms.Label();\r
+            this.labelStaticDisplaySize = new System.Windows.Forms.Label();\r
+            this.updownParWidth = new System.Windows.Forms.NumericUpDown();\r
+            this.drp_anamorphic = new System.Windows.Forms.ComboBox();\r
+            this.lbl_parWidth = new System.Windows.Forms.Label();\r
+            this.updownDisplayWidth = new System.Windows.Forms.NumericUpDown();\r
+            this.lbl_modulus = new System.Windows.Forms.Label();\r
+            this.lbl_displayWidth = new System.Windows.Forms.Label();\r
+            this.drp_modulus = new System.Windows.Forms.ComboBox();\r
+            this.label8 = new System.Windows.Forms.Label();\r
+            this.label26 = new System.Windows.Forms.Label();\r
+            this.tableLayoutPanel3.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_left)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_right)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_top)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_bottom)).BeginInit();\r
+            this.tableLayoutPanel2.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.text_width)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.text_height)).BeginInit();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownParHeight)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownParWidth)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownDisplayWidth)).BeginInit();\r
+            this.SuspendLayout();\r
+            // \r
+            // tableLayoutPanel3\r
+            // \r
+            this.tableLayoutPanel3.AutoSize = true;\r
+            this.tableLayoutPanel3.ColumnCount = 5;\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.Controls.Add(this.Label15, 0, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.crop_left, 1, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.crop_right, 3, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_autoCrop, 0, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.Label51, 4, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.crop_top, 2, 3);\r
+            this.tableLayoutPanel3.Controls.Add(this.Label53, 2, 6);\r
+            this.tableLayoutPanel3.Controls.Add(this.Label52, 2, 2);\r
+            this.tableLayoutPanel3.Controls.Add(this.crop_bottom, 2, 5);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_customCrop, 0, 1);\r
+            this.tableLayoutPanel3.Location = new System.Drawing.Point(419, 35);\r
+            this.tableLayoutPanel3.Name = "tableLayoutPanel3";\r
+            this.tableLayoutPanel3.RowCount = 7;\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.Size = new System.Drawing.Size(217, 165);\r
+            this.tableLayoutPanel3.TabIndex = 117;\r
+            // \r
+            // Label15\r
+            // \r
+            this.Label15.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
+            this.Label15.AutoSize = true;\r
+            this.Label15.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label15.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label15.Location = new System.Drawing.Point(0, 99);\r
+            this.Label15.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.Label15.Name = "Label15";\r
+            this.Label15.Size = new System.Drawing.Size(26, 13);\r
+            this.Label15.TabIndex = 97;\r
+            this.Label15.Text = "Left";\r
+            // \r
+            // crop_left\r
+            // \r
+            this.crop_left.Enabled = false;\r
+            this.crop_left.Increment = new decimal(new int[] {\r
+            2,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_left.Location = new System.Drawing.Point(32, 95);\r
+            this.crop_left.Maximum = new decimal(new int[] {\r
+            1920,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_left.Name = "crop_left";\r
+            this.crop_left.Size = new System.Drawing.Size(44, 21);\r
+            this.crop_left.TabIndex = 98;\r
+            this.crop_left.ValueChanged += new System.EventHandler(this.crop_ValueChanged);\r
+            // \r
+            // crop_right\r
+            // \r
+            this.crop_right.Enabled = false;\r
+            this.crop_right.Increment = new decimal(new int[] {\r
+            2,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_right.Location = new System.Drawing.Point(132, 95);\r
+            this.crop_right.Maximum = new decimal(new int[] {\r
+            1920,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_right.Name = "crop_right";\r
+            this.crop_right.Size = new System.Drawing.Size(44, 21);\r
+            this.crop_right.TabIndex = 101;\r
+            this.crop_right.ValueChanged += new System.EventHandler(this.crop_ValueChanged);\r
+            // \r
+            // check_autoCrop\r
+            // \r
+            this.check_autoCrop.AutoSize = true;\r
+            this.check_autoCrop.Checked = true;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.check_autoCrop, 5);\r
+            this.check_autoCrop.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.check_autoCrop.Location = new System.Drawing.Point(0, 3);\r
+            this.check_autoCrop.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.check_autoCrop.Name = "check_autoCrop";\r
+            this.check_autoCrop.Size = new System.Drawing.Size(73, 17);\r
+            this.check_autoCrop.TabIndex = 105;\r
+            this.check_autoCrop.TabStop = true;\r
+            this.check_autoCrop.Text = "Automatic";\r
+            this.check_autoCrop.UseVisualStyleBackColor = true;\r
+            this.check_autoCrop.CheckedChanged += new System.EventHandler(this.check_autoCrop_CheckedChanged);\r
+            // \r
+            // Label51\r
+            // \r
+            this.Label51.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.Label51.AutoSize = true;\r
+            this.Label51.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label51.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label51.Location = new System.Drawing.Point(182, 99);\r
+            this.Label51.Margin = new System.Windows.Forms.Padding(3);\r
+            this.Label51.Name = "Label51";\r
+            this.Label51.Size = new System.Drawing.Size(32, 13);\r
+            this.Label51.TabIndex = 102;\r
+            this.Label51.Text = "Right";\r
+            // \r
+            // crop_top\r
+            // \r
+            this.crop_top.Enabled = false;\r
+            this.crop_top.Increment = new decimal(new int[] {\r
+            2,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_top.Location = new System.Drawing.Point(82, 68);\r
+            this.crop_top.Maximum = new decimal(new int[] {\r
+            1080,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_top.Name = "crop_top";\r
+            this.crop_top.Size = new System.Drawing.Size(44, 21);\r
+            this.crop_top.TabIndex = 100;\r
+            this.crop_top.ValueChanged += new System.EventHandler(this.crop_ValueChanged);\r
+            // \r
+            // Label53\r
+            // \r
+            this.Label53.Anchor = System.Windows.Forms.AnchorStyles.Top;\r
+            this.Label53.AutoSize = true;\r
+            this.Label53.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label53.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label53.Location = new System.Drawing.Point(83, 149);\r
+            this.Label53.Margin = new System.Windows.Forms.Padding(3);\r
+            this.Label53.Name = "Label53";\r
+            this.Label53.Size = new System.Drawing.Size(41, 13);\r
+            this.Label53.TabIndex = 104;\r
+            this.Label53.Text = "Bottom";\r
+            // \r
+            // Label52\r
+            // \r
+            this.Label52.Anchor = System.Windows.Forms.AnchorStyles.Bottom;\r
+            this.Label52.AutoSize = true;\r
+            this.Label52.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label52.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label52.Location = new System.Drawing.Point(91, 49);\r
+            this.Label52.Margin = new System.Windows.Forms.Padding(3);\r
+            this.Label52.Name = "Label52";\r
+            this.Label52.Size = new System.Drawing.Size(25, 13);\r
+            this.Label52.TabIndex = 99;\r
+            this.Label52.Text = "Top";\r
+            // \r
+            // crop_bottom\r
+            // \r
+            this.crop_bottom.Enabled = false;\r
+            this.crop_bottom.Increment = new decimal(new int[] {\r
+            2,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_bottom.Location = new System.Drawing.Point(82, 122);\r
+            this.crop_bottom.Maximum = new decimal(new int[] {\r
+            1080,\r
+            0,\r
+            0,\r
+            0});\r
+            this.crop_bottom.Name = "crop_bottom";\r
+            this.crop_bottom.Size = new System.Drawing.Size(44, 21);\r
+            this.crop_bottom.TabIndex = 103;\r
+            this.crop_bottom.ValueChanged += new System.EventHandler(this.crop_ValueChanged);\r
+            // \r
+            // check_customCrop\r
+            // \r
+            this.check_customCrop.AutoSize = true;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.check_customCrop, 5);\r
+            this.check_customCrop.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.check_customCrop.Location = new System.Drawing.Point(0, 26);\r
+            this.check_customCrop.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.check_customCrop.Name = "check_customCrop";\r
+            this.check_customCrop.Size = new System.Drawing.Size(61, 17);\r
+            this.check_customCrop.TabIndex = 106;\r
+            this.check_customCrop.Text = "Custom";\r
+            this.check_customCrop.UseVisualStyleBackColor = true;\r
+            // \r
+            // tableLayoutPanel2\r
+            // \r
+            this.tableLayoutPanel2.AutoSize = true;\r
+            this.tableLayoutPanel2.ColumnCount = 5;\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.Controls.Add(this.label7, 0, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.lbl_src_res, 1, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.Label91, 2, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.lbl_Aspect, 3, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.Label55, 0, 1);\r
+            this.tableLayoutPanel2.Controls.Add(this.text_width, 1, 1);\r
+            this.tableLayoutPanel2.Controls.Add(this.lbl_max, 4, 1);\r
+            this.tableLayoutPanel2.Controls.Add(this.label4, 2, 1);\r
+            this.tableLayoutPanel2.Controls.Add(this.text_height, 3, 1);\r
+            this.tableLayoutPanel2.Controls.Add(this.check_KeepAR, 1, 2);\r
+            this.tableLayoutPanel2.Location = new System.Drawing.Point(16, 35);\r
+            this.tableLayoutPanel2.Name = "tableLayoutPanel2";\r
+            this.tableLayoutPanel2.RowCount = 3;\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel2.Size = new System.Drawing.Size(376, 69);\r
+            this.tableLayoutPanel2.TabIndex = 116;\r
+            // \r
+            // label7\r
+            // \r
+            this.label7.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label7.AutoSize = true;\r
+            this.label7.BackColor = System.Drawing.Color.Transparent;\r
+            this.label7.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.label7.Location = new System.Drawing.Point(0, 3);\r
+            this.label7.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label7.Name = "label7";\r
+            this.label7.Size = new System.Drawing.Size(44, 13);\r
+            this.label7.TabIndex = 76;\r
+            this.label7.Text = "Source:";\r
+            // \r
+            // lbl_src_res\r
+            // \r
+            this.lbl_src_res.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_src_res.AutoSize = true;\r
+            this.lbl_src_res.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_src_res.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_src_res.Location = new System.Drawing.Point(50, 3);\r
+            this.lbl_src_res.Margin = new System.Windows.Forms.Padding(3);\r
+            this.lbl_src_res.Name = "lbl_src_res";\r
+            this.lbl_src_res.Size = new System.Drawing.Size(15, 13);\r
+            this.lbl_src_res.TabIndex = 77;\r
+            this.lbl_src_res.Text = "--";\r
+            // \r
+            // Label91\r
+            // \r
+            this.Label91.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.Label91.AutoSize = true;\r
+            this.Label91.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label91.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label91.Location = new System.Drawing.Point(120, 3);\r
+            this.Label91.Margin = new System.Windows.Forms.Padding(3);\r
+            this.Label91.Name = "Label91";\r
+            this.Label91.Size = new System.Drawing.Size(72, 13);\r
+            this.Label91.TabIndex = 78;\r
+            this.Label91.Text = "Aspect Ratio:";\r
+            // \r
+            // lbl_Aspect\r
+            // \r
+            this.lbl_Aspect.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_Aspect.AutoSize = true;\r
+            this.lbl_Aspect.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_Aspect.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_Aspect.Location = new System.Drawing.Point(198, 3);\r
+            this.lbl_Aspect.Margin = new System.Windows.Forms.Padding(3);\r
+            this.lbl_Aspect.Name = "lbl_Aspect";\r
+            this.lbl_Aspect.Size = new System.Drawing.Size(15, 13);\r
+            this.lbl_Aspect.TabIndex = 79;\r
+            this.lbl_Aspect.Text = "--";\r
+            // \r
+            // Label55\r
+            // \r
+            this.Label55.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.Label55.AutoSize = true;\r
+            this.Label55.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label55.ForeColor = System.Drawing.Color.Black;\r
+            this.Label55.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.Label55.Location = new System.Drawing.Point(0, 26);\r
+            this.Label55.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.Label55.Name = "Label55";\r
+            this.Label55.Size = new System.Drawing.Size(39, 13);\r
+            this.Label55.TabIndex = 80;\r
+            this.Label55.Text = "Width:";\r
+            // \r
+            // text_width\r
+            // \r
+            this.text_width.Location = new System.Drawing.Point(50, 22);\r
+            this.text_width.Maximum = new decimal(new int[] {\r
+            2560,\r
+            0,\r
+            0,\r
+            0});\r
+            this.text_width.Name = "text_width";\r
+            this.text_width.Size = new System.Drawing.Size(64, 21);\r
+            this.text_width.TabIndex = 85;\r
+            this.text_width.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);\r
+            // \r
+            // lbl_max\r
+            // \r
+            this.lbl_max.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_max.AutoSize = true;\r
+            this.lbl_max.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_max.Location = new System.Drawing.Point(268, 26);\r
+            this.lbl_max.Margin = new System.Windows.Forms.Padding(3);\r
+            this.lbl_max.Name = "lbl_max";\r
+            this.lbl_max.Size = new System.Drawing.Size(15, 13);\r
+            this.lbl_max.TabIndex = 83;\r
+            this.lbl_max.Text = "--";\r
+            this.lbl_max.DoubleClick += new System.EventHandler(this.lbl_max_DoubleClick);\r
+            // \r
+            // label4\r
+            // \r
+            this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label4.AutoSize = true;\r
+            this.label4.BackColor = System.Drawing.Color.Transparent;\r
+            this.label4.ForeColor = System.Drawing.Color.Black;\r
+            this.label4.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.label4.Location = new System.Drawing.Point(120, 26);\r
+            this.label4.Margin = new System.Windows.Forms.Padding(3);\r
+            this.label4.Name = "label4";\r
+            this.label4.Size = new System.Drawing.Size(42, 13);\r
+            this.label4.TabIndex = 84;\r
+            this.label4.Text = "Height:";\r
+            // \r
+            // text_height\r
+            // \r
+            this.text_height.Location = new System.Drawing.Point(198, 22);\r
+            this.text_height.Maximum = new decimal(new int[] {\r
+            2560,\r
+            0,\r
+            0,\r
+            0});\r
+            this.text_height.Name = "text_height";\r
+            this.text_height.Size = new System.Drawing.Size(64, 21);\r
+            this.text_height.TabIndex = 86;\r
+            this.text_height.ValueChanged += new System.EventHandler(this.text_height_ValueChanged);\r
+            // \r
+            // check_KeepAR\r
+            // \r
+            this.check_KeepAR.AutoSize = true;\r
+            this.check_KeepAR.Checked = true;\r
+            this.check_KeepAR.CheckState = System.Windows.Forms.CheckState.Checked;\r
+            this.tableLayoutPanel2.SetColumnSpan(this.check_KeepAR, 3);\r
+            this.check_KeepAR.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.check_KeepAR.Location = new System.Drawing.Point(50, 49);\r
+            this.check_KeepAR.Name = "check_KeepAR";\r
+            this.check_KeepAR.Size = new System.Drawing.Size(114, 17);\r
+            this.check_KeepAR.TabIndex = 95;\r
+            this.check_KeepAR.Text = "Keep Aspect Ratio";\r
+            this.check_KeepAR.UseVisualStyleBackColor = true;\r
+            this.check_KeepAR.CheckedChanged += new System.EventHandler(this.check_KeepAR_CheckedChanged);\r
+            // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.AutoSize = true;\r
+            this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel1.ColumnCount = 2;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.updownParHeight, 1, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.labelDisplaySize, 1, 5);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_parHeight, 0, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.labelStaticDisplaySize, 0, 5);\r
+            this.tableLayoutPanel1.Controls.Add(this.updownParWidth, 1, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.drp_anamorphic, 1, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_parWidth, 0, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.updownDisplayWidth, 1, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_modulus, 0, 1);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_displayWidth, 0, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.drp_modulus, 1, 1);\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(16, 110);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 6;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(195, 154);\r
+            this.tableLayoutPanel1.TabIndex = 115;\r
+            // \r
+            // updownParHeight\r
+            // \r
+            this.updownParHeight.Location = new System.Drawing.Point(82, 111);\r
+            this.updownParHeight.Maximum = new decimal(new int[] {\r
+            2560,\r
+            0,\r
+            0,\r
+            0});\r
+            this.updownParHeight.Name = "updownParHeight";\r
+            this.updownParHeight.Size = new System.Drawing.Size(53, 21);\r
+            this.updownParHeight.TabIndex = 112;\r
+            this.updownParHeight.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);\r
+            // \r
+            // label6\r
+            // \r
+            this.label6.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label6.AutoSize = true;\r
+            this.label6.BackColor = System.Drawing.Color.Transparent;\r
+            this.label6.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.label6.Location = new System.Drawing.Point(0, 7);\r
+            this.label6.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.label6.Name = "label6";\r
+            this.label6.Size = new System.Drawing.Size(67, 13);\r
+            this.label6.TabIndex = 81;\r
+            this.label6.Text = "Anamorphic:";\r
+            // \r
+            // labelDisplaySize\r
+            // \r
+            this.labelDisplaySize.AutoSize = true;\r
+            this.labelDisplaySize.BackColor = System.Drawing.Color.Transparent;\r
+            this.labelDisplaySize.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.labelDisplaySize.Location = new System.Drawing.Point(82, 138);\r
+            this.labelDisplaySize.Margin = new System.Windows.Forms.Padding(3);\r
+            this.labelDisplaySize.Name = "labelDisplaySize";\r
+            this.labelDisplaySize.Size = new System.Drawing.Size(15, 13);\r
+            this.labelDisplaySize.TabIndex = 108;\r
+            this.labelDisplaySize.Text = "--";\r
+            // \r
+            // lbl_parHeight\r
+            // \r
+            this.lbl_parHeight.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_parHeight.AutoSize = true;\r
+            this.lbl_parHeight.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_parHeight.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_parHeight.Location = new System.Drawing.Point(0, 115);\r
+            this.lbl_parHeight.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.lbl_parHeight.Name = "lbl_parHeight";\r
+            this.lbl_parHeight.Size = new System.Drawing.Size(65, 13);\r
+            this.lbl_parHeight.TabIndex = 94;\r
+            this.lbl_parHeight.Text = "PAR Height:";\r
+            // \r
+            // labelStaticDisplaySize\r
+            // \r
+            this.labelStaticDisplaySize.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.labelStaticDisplaySize.AutoSize = true;\r
+            this.labelStaticDisplaySize.BackColor = System.Drawing.Color.Transparent;\r
+            this.labelStaticDisplaySize.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.labelStaticDisplaySize.Location = new System.Drawing.Point(0, 138);\r
+            this.labelStaticDisplaySize.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.labelStaticDisplaySize.Name = "labelStaticDisplaySize";\r
+            this.labelStaticDisplaySize.Size = new System.Drawing.Size(67, 13);\r
+            this.labelStaticDisplaySize.TabIndex = 107;\r
+            this.labelStaticDisplaySize.Text = "Display Size:";\r
+            // \r
+            // updownParWidth\r
+            // \r
+            this.updownParWidth.Location = new System.Drawing.Point(82, 84);\r
+            this.updownParWidth.Maximum = new decimal(new int[] {\r
+            2560,\r
+            0,\r
+            0,\r
+            0});\r
+            this.updownParWidth.Name = "updownParWidth";\r
+            this.updownParWidth.Size = new System.Drawing.Size(53, 21);\r
+            this.updownParWidth.TabIndex = 111;\r
+            this.updownParWidth.ValueChanged += new System.EventHandler(this.text_width_ValueChanged);\r
+            // \r
+            // drp_anamorphic\r
+            // \r
+            this.drp_anamorphic.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_anamorphic.FormattingEnabled = true;\r
+            this.drp_anamorphic.Items.AddRange(new object[] {\r
+            "None",\r
+            "Strict",\r
+            "Loose",\r
+            "Custom"});\r
+            this.drp_anamorphic.Location = new System.Drawing.Point(82, 3);\r
+            this.drp_anamorphic.Name = "drp_anamorphic";\r
+            this.drp_anamorphic.Size = new System.Drawing.Size(110, 21);\r
+            this.drp_anamorphic.TabIndex = 82;\r
+            this.drp_anamorphic.SelectedIndexChanged += new System.EventHandler(this.drp_anamorphic_SelectedIndexChanged);\r
+            // \r
+            // lbl_parWidth\r
+            // \r
+            this.lbl_parWidth.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_parWidth.AutoSize = true;\r
+            this.lbl_parWidth.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_parWidth.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_parWidth.Location = new System.Drawing.Point(0, 88);\r
+            this.lbl_parWidth.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.lbl_parWidth.Name = "lbl_parWidth";\r
+            this.lbl_parWidth.Size = new System.Drawing.Size(62, 13);\r
+            this.lbl_parWidth.TabIndex = 92;\r
+            this.lbl_parWidth.Text = "PAR Width:";\r
+            // \r
+            // updownDisplayWidth\r
+            // \r
+            this.updownDisplayWidth.Location = new System.Drawing.Point(82, 57);\r
+            this.updownDisplayWidth.Maximum = new decimal(new int[] {\r
+            2560,\r
+            0,\r
+            0,\r
+            0});\r
+            this.updownDisplayWidth.Name = "updownDisplayWidth";\r
+            this.updownDisplayWidth.Size = new System.Drawing.Size(53, 21);\r
+            this.updownDisplayWidth.TabIndex = 110;\r
+            this.updownDisplayWidth.ValueChanged += new System.EventHandler(this.updownDisplayWidth_ValueChanged);\r
+            // \r
+            // lbl_modulus\r
+            // \r
+            this.lbl_modulus.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_modulus.AutoSize = true;\r
+            this.lbl_modulus.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_modulus.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_modulus.Location = new System.Drawing.Point(0, 34);\r
+            this.lbl_modulus.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.lbl_modulus.Name = "lbl_modulus";\r
+            this.lbl_modulus.Size = new System.Drawing.Size(50, 13);\r
+            this.lbl_modulus.TabIndex = 87;\r
+            this.lbl_modulus.Text = "Modulus:";\r
+            // \r
+            // lbl_displayWidth\r
+            // \r
+            this.lbl_displayWidth.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_displayWidth.AutoSize = true;\r
+            this.lbl_displayWidth.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_displayWidth.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.lbl_displayWidth.Location = new System.Drawing.Point(0, 61);\r
+            this.lbl_displayWidth.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);\r
+            this.lbl_displayWidth.Name = "lbl_displayWidth";\r
+            this.lbl_displayWidth.Size = new System.Drawing.Size(76, 13);\r
+            this.lbl_displayWidth.TabIndex = 90;\r
+            this.lbl_displayWidth.Text = "Display Width:";\r
+            // \r
+            // drp_modulus\r
+            // \r
+            this.drp_modulus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_modulus.FormattingEnabled = true;\r
+            this.drp_modulus.Items.AddRange(new object[] {\r
+            "16",\r
+            "8",\r
+            "4",\r
+            "2"});\r
+            this.drp_modulus.Location = new System.Drawing.Point(82, 30);\r
+            this.drp_modulus.Name = "drp_modulus";\r
+            this.drp_modulus.Size = new System.Drawing.Size(110, 21);\r
+            this.drp_modulus.TabIndex = 88;\r
+            this.drp_modulus.SelectedIndexChanged += new System.EventHandler(this.drp_modulus_SelectedIndexChanged);\r
+            // \r
+            // label8\r
+            // \r
+            this.label8.AutoSize = true;\r
+            this.label8.BackColor = System.Drawing.Color.Transparent;\r
+            this.label8.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label8.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.label8.Location = new System.Drawing.Point(416, 13);\r
+            this.label8.Name = "label8";\r
+            this.label8.Size = new System.Drawing.Size(57, 13);\r
+            this.label8.TabIndex = 114;\r
+            this.label8.Text = "Cropping";\r
+            // \r
+            // label26\r
+            // \r
+            this.label26.AutoSize = true;\r
+            this.label26.BackColor = System.Drawing.Color.Transparent;\r
+            this.label26.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label26.ImeMode = System.Windows.Forms.ImeMode.NoControl;\r
+            this.label26.Location = new System.Drawing.Point(13, 13);\r
+            this.label26.Name = "label26";\r
+            this.label26.Size = new System.Drawing.Size(30, 13);\r
+            this.label26.TabIndex = 113;\r
+            this.label26.Text = "Size";\r
+            // \r
+            // PictureSettings\r
+            // \r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
+            this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.tableLayoutPanel3);\r
+            this.Controls.Add(this.tableLayoutPanel2);\r
+            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.Controls.Add(this.label8);\r
+            this.Controls.Add(this.label26);\r
+            this.Enabled = false;\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Name = "PictureSettings";\r
+            this.Size = new System.Drawing.Size(666, 279);\r
+            this.tableLayoutPanel3.ResumeLayout(false);\r
+            this.tableLayoutPanel3.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_left)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_right)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_top)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.crop_bottom)).EndInit();\r
+            this.tableLayoutPanel2.ResumeLayout(false);\r
+            this.tableLayoutPanel2.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.text_width)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.text_height)).EndInit();\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownParHeight)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownParWidth)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.updownDisplayWidth)).EndInit();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;\r
+        internal System.Windows.Forms.Label Label15;\r
+        internal System.Windows.Forms.NumericUpDown crop_left;\r
+        internal System.Windows.Forms.NumericUpDown crop_right;\r
+        internal System.Windows.Forms.RadioButton check_autoCrop;\r
+        internal System.Windows.Forms.Label Label51;\r
+        internal System.Windows.Forms.NumericUpDown crop_top;\r
+        internal System.Windows.Forms.Label Label53;\r
+        internal System.Windows.Forms.Label Label52;\r
+        internal System.Windows.Forms.NumericUpDown crop_bottom;\r
+        internal System.Windows.Forms.RadioButton check_customCrop;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;\r
+        internal System.Windows.Forms.Label label7;\r
+        internal System.Windows.Forms.Label lbl_src_res;\r
+        internal System.Windows.Forms.Label Label91;\r
+        internal System.Windows.Forms.Label lbl_Aspect;\r
+        internal System.Windows.Forms.Label Label55;\r
+        private System.Windows.Forms.Label lbl_max;\r
+        internal System.Windows.Forms.Label label4;\r
+        internal System.Windows.Forms.CheckBox check_KeepAR;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
+        internal System.Windows.Forms.NumericUpDown updownParHeight;\r
+        internal System.Windows.Forms.Label label6;\r
+        internal System.Windows.Forms.Label labelDisplaySize;\r
+        internal System.Windows.Forms.Label lbl_parHeight;\r
+        internal System.Windows.Forms.Label labelStaticDisplaySize;\r
+        internal System.Windows.Forms.NumericUpDown updownParWidth;\r
+        internal System.Windows.Forms.ComboBox drp_anamorphic;\r
+        internal System.Windows.Forms.Label lbl_parWidth;\r
+        internal System.Windows.Forms.NumericUpDown updownDisplayWidth;\r
+        internal System.Windows.Forms.Label lbl_modulus;\r
+        internal System.Windows.Forms.Label lbl_displayWidth;\r
+        internal System.Windows.Forms.ComboBox drp_modulus;\r
+        internal System.Windows.Forms.Label label8;\r
+        internal System.Windows.Forms.Label label26;\r
+        internal System.Windows.Forms.NumericUpDown text_width;\r
+        internal System.Windows.Forms.NumericUpDown text_height;\r
+\r
+\r
+\r
+    }\r
+}\r
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs
new file mode 100644 (file)
index 0000000..bbca24d
--- /dev/null
@@ -0,0 +1,511 @@
+using System;\r
+using System.ComponentModel;\r
+using System.Drawing;\r
+using System.Globalization;\r
+using System.Windows.Forms;\r
+using Handbrake.Parsing;\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    public partial class PictureSettings : UserControl\r
+    {\r
+        private readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
+        public event EventHandler PictureSettingsChanged;\r
+\r
+        private Boolean _preventChangingWidth, _preventChangingHeight, _preventChangingCustom, _preventChangingDisplayWidth;\r
+        private int _presetMaximumWidth, _presetMaximumHeight;\r
+        private double _cachedDar;\r
+        private Title _sourceTitle;\r
+\r
+        public PictureSettings()\r
+        {\r
+            InitializeComponent();\r
+\r
+            drp_anamorphic.SelectedIndex = 1;\r
+            drp_modulus.SelectedIndex = 0;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the source media used by this control.\r
+        /// </summary>\r
+        [Browsable(false)]\r
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
+        public Title Source\r
+        {\r
+            private get { return _sourceTitle; }\r
+            set\r
+            {\r
+                _sourceTitle = value;\r
+                Enabled = _sourceTitle != null;\r
+\r
+                // Set the Aspect Ratio\r
+                lbl_Aspect.Text = _sourceTitle.AspectRatio.ToString(Culture);\r
+                lbl_src_res.Text = _sourceTitle.Resolution.Width + " x " + _sourceTitle.Resolution.Height;\r
+\r
+                // Set the Recommended Cropping values\r
+                crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
+                crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
+                crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
+                crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+\r
+                // Set the Resolution Boxes\r
+                if (drp_anamorphic.SelectedIndex == 0)\r
+                {\r
+                    if (text_width.Value == 0) // Only update the values if the fields don't already have values.\r
+                        text_width.Value = _sourceTitle.Resolution.Width;\r
+\r
+                    check_KeepAR.Checked = true; // Forces Resolution to be correct.\r
+                }\r
+                else\r
+                {\r
+                    if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values.\r
+                    {\r
+                        text_width.Value = _sourceTitle.Resolution.Width;\r
+                        text_height.Value = _sourceTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+                    }\r
+\r
+                    labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
+                }\r
+\r
+                //updownDisplayWidth.Value = CalculateAnamorphicSizes().Width;\r
+                updownParWidth.Value = _sourceTitle.ParVal.Width;\r
+                updownParHeight.Value = _sourceTitle.ParVal.Height;\r
+                //_cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;\r
+\r
+\r
+                Size croppedDar = CalculateAnamorphicSizes();\r
+                _cachedDar = (double) croppedDar.Width/croppedDar.Height;\r
+                updownDisplayWidth.Value = croppedDar.Width;\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the maximum allowable size for the encoded resolution. Set a value to\r
+        /// "0" if the maximum does not matter.\r
+        /// </summary>\r
+        [Browsable(false)]\r
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\r
+        public Size PresetMaximumResolution\r
+        {\r
+            get { return new Size(_presetMaximumWidth, _presetMaximumHeight); }\r
+            set\r
+            {\r
+                _presetMaximumWidth = value.Width;\r
+                _presetMaximumHeight = value.Height;\r
+\r
+                if (value.Width != 0 && value.Height != 0)\r
+                    lbl_max.Text = "Max Width / Height";\r
+                else if (value.Width != 0)\r
+                    lbl_max.Text = "Max Width";\r
+                else if (value.Height != 0)\r
+                    lbl_max.Text = "Max Height";\r
+                else\r
+                    lbl_max.Text = "";\r
+            }\r
+        }\r
+\r
+        // Picture Controls\r
+        private void text_width_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (Properties.Settings.Default.disableResCalc)\r
+                return;\r
+\r
+            if (_preventChangingWidth)\r
+                return;\r
+\r
+            // Make sure the new value doesn't exceed the maximum\r
+            if (Source != null)\r
+                if (text_width.Value > Source.Resolution.Width)\r
+                    text_width.Value = Source.Resolution.Width;\r
+\r
+            switch (drp_anamorphic.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    if (check_KeepAR.Checked && Source != null)\r
+                    {\r
+                        _preventChangingHeight = true;\r
+\r
+                        int width = (int)text_width.Value;\r
+\r
+                        double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;\r
+                        double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+\r
+                        if (SourceAspect.Width == 0 && SourceAspect.Height == 0)\r
+                            break;\r
+\r
+                        double newHeight = ((double)width * Source.Resolution.Width * SourceAspect.Height * crop_height) /\r
+                                           (Source.Resolution.Height * SourceAspect.Width * crop_width);\r
+                        text_height.Value = (decimal)GetModulusValue(newHeight);\r
+\r
+                        _preventChangingHeight = false;\r
+                    }\r
+                    break;\r
+                case 3:\r
+                    if (check_KeepAR.CheckState == CheckState.Unchecked && Source != null)\r
+                    {\r
+                        if (_preventChangingCustom)\r
+                            break;\r
+\r
+                        _preventChangingDisplayWidth = true;\r
+                        updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value;\r
+                        _preventChangingDisplayWidth = false;\r
+\r
+                        labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;\r
+                    }\r
+\r
+                    if (check_KeepAR.CheckState == CheckState.Checked && Source != null)\r
+                    {\r
+                        updownParWidth.Value = updownDisplayWidth.Value;\r
+                        updownParHeight.Value = text_width.Value;\r
+                    }\r
+                    break;\r
+                default:\r
+                    labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
+                    break;\r
+            }\r
+\r
+            _preventChangingWidth = false;\r
+        }\r
+        private void text_height_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (Properties.Settings.Default.disableResCalc)\r
+                return;\r
+\r
+            if (_preventChangingHeight)\r
+                return;\r
+\r
+            if (Source != null)\r
+                if (text_height.Value > Source.Resolution.Height)\r
+                    text_height.Value = Source.Resolution.Height;\r
+\r
+            switch (drp_anamorphic.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    if (check_KeepAR.Checked && Source != null)\r
+                    {\r
+                        _preventChangingWidth = true;\r
+\r
+                        double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;\r
+                        double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+\r
+                        double new_width = ((double)text_height.Value * Source.Resolution.Height * SourceAspect.Width * crop_width) /\r
+                                            (Source.Resolution.Width * SourceAspect.Height * crop_height);\r
+\r
+                        text_width.Value = (decimal)GetModulusValue(new_width);\r
+\r
+                        _preventChangingWidth = false;\r
+                    }\r
+                    break;\r
+                case 3:\r
+                    labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;\r
+\r
+                    if (check_KeepAR.CheckState == CheckState.Checked && Source != null)\r
+                    {\r
+                        // - Changes DISPLAY WIDTH to keep DAR\r
+                        // - Changes PIXEL WIDTH to new DISPLAY WIDTH\r
+                        // - Changes PIXEL HEIGHT to STORAGE WIDTH\r
+                        // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
+\r
+                        double rawCalculatedDisplayWidth = (double)text_height.Value * _cachedDar;\r
+\r
+                        _preventChangingDisplayWidth = true; // Start Guards\r
+                        _preventChangingWidth = true;\r
+\r
+                        updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;\r
+                        updownParWidth.Value = updownDisplayWidth.Value;\r
+                        updownParHeight.Value = text_width.Value;\r
+\r
+                        _preventChangingWidth = false; // Reset Guards\r
+                        _preventChangingDisplayWidth = false;\r
+                    }\r
+\r
+                    break;\r
+                default:\r
+                    labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
+                    break;\r
+            }\r
+\r
+            _preventChangingHeight = false;\r
+        }\r
+        private void check_KeepAR_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (Properties.Settings.Default.disableResCalc)\r
+                return;\r
+\r
+            //Force TextWidth to recalc height\r
+            if (check_KeepAR.Checked)\r
+                text_width_ValueChanged(this, new EventArgs());\r
+\r
+            // Disable the Custom Anamorphic Par Controls if checked.\r
+            if (drp_anamorphic.SelectedIndex == 3)\r
+            {\r
+                updownParWidth.Enabled = !check_KeepAR.Checked;\r
+                updownParHeight.Enabled = !check_KeepAR.Checked;\r
+            }\r
+\r
+            // Raise the Picture Settings Changed Event\r
+            if (PictureSettingsChanged != null)\r
+                PictureSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void updownDisplayWidth_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            if (Properties.Settings.Default.disableResCalc)\r
+                return;\r
+\r
+            if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked)\r
+            {\r
+                _preventChangingCustom = true;\r
+                updownParWidth.Value = updownDisplayWidth.Value;\r
+                updownParHeight.Value = text_width.Value;\r
+                _preventChangingCustom = false;\r
+            }\r
+\r
+            if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked)\r
+            {\r
+                // - Changes HEIGHT to keep DAR\r
+                // - Changes PIXEL WIDTH to new DISPLAY WIDTH\r
+                // - Changes PIXEL HEIGHT to STORAGE WIDTH\r
+                // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)\r
+\r
+                // Calculate new Height Value\r
+                int modulus;\r
+                if(!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))\r
+                    modulus = 16;\r
+\r
+                int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar);\r
+                int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);\r
+\r
+                // Update value\r
+                _preventChangingHeight = true;\r
+                text_height.Value = (decimal)modulusHeight;\r
+                updownParWidth.Value = updownDisplayWidth.Value;\r
+                updownParHeight.Value = text_width.Value;\r
+                _preventChangingHeight = false;\r
+            }\r
+\r
+        }\r
+\r
+        // Anamorphic Controls\r
+        private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            switch (drp_anamorphic.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    text_width.Enabled = true;\r
+                    text_height.Enabled = true;\r
+                    check_KeepAR.Enabled = true;\r
+\r
+                    SetCustomAnamorphicOptionsVisible(false);\r
+                    labelStaticDisplaySize.Visible = false;\r
+                    labelDisplaySize.Visible = false;\r
+\r
+                    check_KeepAR.Checked = true;\r
+                    drp_modulus.SelectedIndex = 0;\r
+\r
+                    if (check_KeepAR.Checked)\r
+                        text_width_ValueChanged(this, new EventArgs());\r
+                    // Don't update display size if we're not using anamorphic\r
+                    return;\r
+                case 1:\r
+                    text_width.Enabled = false;\r
+                    text_height.Enabled = false;\r
+                    check_KeepAR.Enabled = false;\r
+\r
+                    SetCustomAnamorphicOptionsVisible(false);\r
+                    labelStaticDisplaySize.Visible = true;\r
+                    labelDisplaySize.Visible = true;\r
+                    drp_modulus.SelectedIndex = 0;\r
+\r
+                    check_KeepAR.Checked = true;\r
+                    break;\r
+                case 2:\r
+                    text_width.Enabled = true;\r
+                    text_height.Enabled = false;\r
+                    check_KeepAR.Enabled = false;\r
+\r
+                    SetCustomAnamorphicOptionsVisible(false);\r
+                    labelStaticDisplaySize.Visible = true;\r
+                    labelDisplaySize.Visible = true;\r
+                    drp_modulus.SelectedIndex = 0;\r
+\r
+                    check_KeepAR.Checked = true;\r
+                    break;\r
+                case 3:\r
+                    text_width.Enabled = true;\r
+                    text_height.Enabled = true;\r
+                    check_KeepAR.Enabled = true;\r
+\r
+                    SetCustomAnamorphicOptionsVisible(true);\r
+                    labelStaticDisplaySize.Visible = true;\r
+                    labelDisplaySize.Visible = true;\r
+\r
+                    check_KeepAR.Checked = true;\r
+                    updownParWidth.Enabled = !check_KeepAR.Checked;\r
+                    updownParHeight.Enabled = !check_KeepAR.Checked;\r
+                    break;\r
+\r
+            }\r
+\r
+            labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;\r
+\r
+            if (check_KeepAR.Checked)\r
+                text_width_ValueChanged(this, new EventArgs());\r
+\r
+            if (PictureSettingsChanged != null)\r
+                PictureSettingsChanged(this, new EventArgs());\r
+        }\r
+        private void drp_modulus_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            _preventChangingWidth = true;\r
+            _preventChangingHeight = true;\r
+\r
+            text_width.Value = (decimal)GetModulusValue((double)text_width.Value);\r
+            text_height.Value = (decimal)GetModulusValue((double)text_height.Value);\r
+\r
+            _preventChangingWidth = false;\r
+            _preventChangingHeight = false;\r
+\r
+            text_width.Increment = int.Parse(drp_modulus.SelectedItem.ToString());\r
+            text_height.Increment = int.Parse(drp_modulus.SelectedItem.ToString());\r
+\r
+            if (PictureSettingsChanged != null)\r
+                PictureSettingsChanged(this, new EventArgs());\r
+        }\r
+\r
+        // Cropping Controls\r
+        private void check_autoCrop_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            crop_top.Enabled = check_customCrop.Checked;\r
+            crop_bottom.Enabled = check_customCrop.Checked;\r
+            crop_left.Enabled = check_customCrop.Checked;\r
+            crop_right.Enabled = check_customCrop.Checked;\r
+\r
+            crop_top.Value = Source.AutoCropDimensions[0];\r
+            crop_bottom.Value = Source.AutoCropDimensions[1];\r
+            crop_left.Value = Source.AutoCropDimensions[2];\r
+            crop_right.Value = Source.AutoCropDimensions[3];\r
+        }\r
+        private void crop_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            text_width_ValueChanged(this, new EventArgs());\r
+        }\r
+\r
+        // GUI Functions\r
+        private void SetCustomAnamorphicOptionsVisible(bool visible)\r
+        {\r
+            lbl_modulus.Visible = visible;\r
+            lbl_displayWidth.Visible = visible;\r
+            lbl_parWidth.Visible = visible;\r
+            lbl_parHeight.Visible = visible;\r
+\r
+            drp_modulus.Visible = visible;\r
+            updownDisplayWidth.Visible = visible;\r
+            updownParWidth.Visible = visible;\r
+            updownParHeight.Visible = visible;\r
+        }\r
+\r
+        // Calculation Functions\r
+        private Size SourceAspect\r
+        {\r
+            get\r
+            {\r
+                if (Source != null) // display aspect = (width * par_width) / (height * par_height)\r
+                    return new Size((Source.ParVal.Width * Source.Resolution.Width), (Source.ParVal.Height * Source.Resolution.Height));\r
+\r
+                return new Size(0, 0); // Fall over to 16:9 and hope for the best\r
+            }\r
+        }\r
+        private Size CalculateAnamorphicSizes()\r
+        {\r
+            if (Source != null)\r
+            {\r
+                /* Set up some variables to make the math easier to follow. */\r
+                int cropped_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;\r
+                int cropped_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+                double storage_aspect = (double)cropped_width / cropped_height;\r
+\r
+                /* Figure out what width the source would display at. */\r
+                double source_display_width = (double)cropped_width * Source.ParVal.Width / Source.ParVal.Height;\r
+\r
+                /*\r
+                     3 different ways of deciding output dimensions:\r
+                      - 1: Strict anamorphic, preserve source dimensions\r
+                      - 2: Loose anamorphic, round to mod16 and preserve storage aspect ratio\r
+                      - 3: Power user anamorphic, specify everything\r
+                  */\r
+                double width, height;\r
+                switch (drp_anamorphic.SelectedIndex)\r
+                {\r
+                    default:\r
+                    case 1:\r
+                        /* Strict anamorphic */\r
+                        double displayWidth = ((double)cropped_width * Source.ParVal.Width / Source.ParVal.Height);\r
+                        displayWidth = Math.Round(displayWidth, 0);\r
+                        Size output = new Size((int)displayWidth, cropped_height);\r
+                        return output;\r
+                    case 2:\r
+                        /* "Loose" anamorphic.\r
+                            - Uses mod16-compliant dimensions,\r
+                            - Allows users to set the width\r
+                        */\r
+                        width = (int) text_width.Value;\r
+                        width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/\r
+\r
+                        height = (width / storage_aspect) + 0.5;\r
+                        height = GetModulusValue(height); /* Time to get picture height that divide cleanly.*/\r
+\r
+                        /* The film AR is the source's display width / cropped source height.\r
+                           The output display width is the output height * film AR.\r
+                           The output PAR is the output display width / output storage width. */\r
+                        double pixel_aspect_width = height * source_display_width / cropped_height;\r
+                        double pixel_aspect_height = width;\r
+\r
+                        double disWidthLoose = (width * pixel_aspect_width / pixel_aspect_height);\r
+                        if (double.IsNaN(disWidthLoose))\r
+                            disWidthLoose = 0;\r
+                        return new Size((int)disWidthLoose, (int)height);\r
+                    case 3:\r
+\r
+                        // Get the User Interface Values\r
+                        double UIdisplayWidth;\r
+                        double.TryParse(updownDisplayWidth.Text, out UIdisplayWidth);\r
+\r
+                        /* Anamorphic 3: Power User Jamboree - Set everything based on specified values */\r
+                        height = GetModulusValue((double)text_height.Value);\r
+\r
+                        if (check_KeepAR.Checked)\r
+                            return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);\r
+\r
+                        return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);\r
+                }\r
+            }\r
+\r
+            // Return a default value of 0,0 to indicate failure\r
+            return new Size(0, 0);\r
+        }\r
+        private double GetModulusValue(double value)\r
+        {\r
+            int mod = int.Parse(drp_modulus.SelectedItem.ToString());\r
+            double remainder = value % mod;\r
+\r
+            if (remainder == 0)\r
+                return value;\r
+\r
+            return remainder >= ((double)mod / 2) ? value + (mod - remainder) : value - remainder;\r
+        }\r
+        private static int GetCropMod2Clean(int value)\r
+        {\r
+            int remainder = value % 2;\r
+            if (remainder == 0) return value;\r
+            return (value + remainder);\r
+        }\r
+\r
+        // Hidden UI feature to drop the MaxWidth / Height with the MaxWidth/Height label is double clicked\r
+        private void lbl_max_DoubleClick(object sender, EventArgs e)\r
+        {\r
+            PresetMaximumResolution = new Size(0,0);\r
+            if (PictureSettingsChanged != null)\r
+                PictureSettingsChanged(this, new EventArgs());\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/Controls/PictureSettings.resx b/win/C#/Controls/PictureSettings.resx
new file mode 100644 (file)
index 0000000..ff31a6d
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
diff --git a/win/C#/Controls/Subtitles.Designer.cs b/win/C#/Controls/Subtitles.Designer.cs
new file mode 100644 (file)
index 0000000..5f1eaa1
--- /dev/null
@@ -0,0 +1,482 @@
+namespace Handbrake.Controls\r
+{\r
+    partial class Subtitles\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.components = new System.ComponentModel.Container();\r
+            this.btn_addTrack = new System.Windows.Forms.Button();\r
+            this.btn_RemoveSubTrack = new System.Windows.Forms.Button();\r
+            this.lv_subList = new System.Windows.Forms.ListView();\r
+            this.col_Source = new System.Windows.Forms.ColumnHeader();\r
+            this.col_forced = new System.Windows.Forms.ColumnHeader();\r
+            this.col_burned = new System.Windows.Forms.ColumnHeader();\r
+            this.col_defaultTrack = new System.Windows.Forms.ColumnHeader();\r
+            this.col_srtLang = new System.Windows.Forms.ColumnHeader();\r
+            this.col_srtChar = new System.Windows.Forms.ColumnHeader();\r
+            this.col_srtOffset = new System.Windows.Forms.ColumnHeader();\r
+            this.subMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.mnu_moveup = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.mnu_movedown = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.mnu_remove = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.label68 = new System.Windows.Forms.Label();\r
+            this.SubGroupBox = new System.Windows.Forms.GroupBox();\r
+            this.drp_subtitleTracks = new System.Windows.Forms.ComboBox();\r
+            this.label10 = new System.Windows.Forms.Label();\r
+            this.label9 = new System.Windows.Forms.Label();\r
+            this.label2 = new System.Windows.Forms.Label();\r
+            this.srt_offset = new System.Windows.Forms.NumericUpDown();\r
+            this.srt_lang = new System.Windows.Forms.ComboBox();\r
+            this.label8 = new System.Windows.Forms.Label();\r
+            this.srt_charcode = new System.Windows.Forms.ComboBox();\r
+            this.label4 = new System.Windows.Forms.Label();\r
+            this.check_forced = new System.Windows.Forms.CheckBox();\r
+            this.label7 = new System.Windows.Forms.Label();\r
+            this.label3 = new System.Windows.Forms.Label();\r
+            this.check_default = new System.Windows.Forms.CheckBox();\r
+            this.check_burned = new System.Windows.Forms.CheckBox();\r
+            this.btn_srtAdd = new System.Windows.Forms.Button();\r
+            this.openFileDialog = new System.Windows.Forms.OpenFileDialog();\r
+            this.toolTip = new System.Windows.Forms.ToolTip(this.components);\r
+            this.subMenu.SuspendLayout();\r
+            this.SubGroupBox.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.srt_offset)).BeginInit();\r
+            this.SuspendLayout();\r
+            // \r
+            // btn_addTrack\r
+            // \r
+            this.btn_addTrack.BackColor = System.Drawing.Color.Transparent;\r
+            this.btn_addTrack.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_addTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_addTrack.Location = new System.Drawing.Point(16, 38);\r
+            this.btn_addTrack.Name = "btn_addTrack";\r
+            this.btn_addTrack.Size = new System.Drawing.Size(57, 23);\r
+            this.btn_addTrack.TabIndex = 68;\r
+            this.btn_addTrack.Text = "Add";\r
+            this.toolTip.SetToolTip(this.btn_addTrack, "Add a new subtitle track to the list below");\r
+            this.btn_addTrack.UseVisualStyleBackColor = false;\r
+            this.btn_addTrack.Click += new System.EventHandler(this.btn_addSubTrack_Click);\r
+            // \r
+            // btn_RemoveSubTrack\r
+            // \r
+            this.btn_RemoveSubTrack.BackColor = System.Drawing.Color.Transparent;\r
+            this.btn_RemoveSubTrack.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_RemoveSubTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_RemoveSubTrack.Location = new System.Drawing.Point(79, 38);\r
+            this.btn_RemoveSubTrack.Name = "btn_RemoveSubTrack";\r
+            this.btn_RemoveSubTrack.Size = new System.Drawing.Size(73, 23);\r
+            this.btn_RemoveSubTrack.TabIndex = 69;\r
+            this.btn_RemoveSubTrack.Text = "Remove";\r
+            this.btn_RemoveSubTrack.UseVisualStyleBackColor = false;\r
+            this.btn_RemoveSubTrack.Click += new System.EventHandler(this.btn_RemoveSubTrack_Click);\r
+            // \r
+            // lv_subList\r
+            // \r
+            this.lv_subList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {\r
+            this.col_Source,\r
+            this.col_forced,\r
+            this.col_burned,\r
+            this.col_defaultTrack,\r
+            this.col_srtLang,\r
+            this.col_srtChar,\r
+            this.col_srtOffset});\r
+            this.lv_subList.ContextMenuStrip = this.subMenu;\r
+            this.lv_subList.FullRowSelect = true;\r
+            this.lv_subList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;\r
+            this.lv_subList.HideSelection = false;\r
+            this.lv_subList.LabelWrap = false;\r
+            this.lv_subList.Location = new System.Drawing.Point(16, 146);\r
+            this.lv_subList.MultiSelect = false;\r
+            this.lv_subList.Name = "lv_subList";\r
+            this.lv_subList.Size = new System.Drawing.Size(688, 137);\r
+            this.lv_subList.TabIndex = 70;\r
+            this.lv_subList.UseCompatibleStateImageBehavior = false;\r
+            this.lv_subList.View = System.Windows.Forms.View.Details;\r
+            this.lv_subList.SelectedIndexChanged += new System.EventHandler(this.lb_subList_SelectedIndexChanged);\r
+            // \r
+            // col_Source\r
+            // \r
+            this.col_Source.Text = "Track";\r
+            this.col_Source.Width = 139;\r
+            // \r
+            // col_forced\r
+            // \r
+            this.col_forced.Text = "Forced Only";\r
+            this.col_forced.Width = 74;\r
+            // \r
+            // col_burned\r
+            // \r
+            this.col_burned.Text = "Burned In";\r
+            this.col_burned.Width = 64;\r
+            // \r
+            // col_defaultTrack\r
+            // \r
+            this.col_defaultTrack.Text = "Default";\r
+            this.col_defaultTrack.Width = 56;\r
+            // \r
+            // col_srtLang\r
+            // \r
+            this.col_srtLang.Text = "Srt Lang";\r
+            // \r
+            // col_srtChar\r
+            // \r
+            this.col_srtChar.Text = "Srt CharCode";\r
+            this.col_srtChar.Width = 110;\r
+            // \r
+            // col_srtOffset\r
+            // \r
+            this.col_srtOffset.Text = "Srt Offset";\r
+            this.col_srtOffset.Width = 70;\r
+            // \r
+            // subMenu\r
+            // \r
+            this.subMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_moveup,\r
+            this.mnu_movedown,\r
+            this.toolStripSeparator2,\r
+            this.mnu_remove});\r
+            this.subMenu.Name = "audioMenu";\r
+            this.subMenu.Size = new System.Drawing.Size(142, 76);\r
+            // \r
+            // mnu_moveup\r
+            // \r
+            this.mnu_moveup.Name = "mnu_moveup";\r
+            this.mnu_moveup.Size = new System.Drawing.Size(141, 22);\r
+            this.mnu_moveup.Text = "Move Up";\r
+            this.mnu_moveup.Click += new System.EventHandler(this.mnu_moveup_Click);\r
+            // \r
+            // mnu_movedown\r
+            // \r
+            this.mnu_movedown.Name = "mnu_movedown";\r
+            this.mnu_movedown.Size = new System.Drawing.Size(141, 22);\r
+            this.mnu_movedown.Text = "Move Down";\r
+            this.mnu_movedown.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.mnu_movedown.Click += new System.EventHandler(this.mnu_movedown_Click);\r
+            // \r
+            // toolStripSeparator2\r
+            // \r
+            this.toolStripSeparator2.Name = "toolStripSeparator2";\r
+            this.toolStripSeparator2.Size = new System.Drawing.Size(138, 6);\r
+            // \r
+            // mnu_remove\r
+            // \r
+            this.mnu_remove.Name = "mnu_remove";\r
+            this.mnu_remove.Size = new System.Drawing.Size(141, 22);\r
+            this.mnu_remove.Text = "Remove";\r
+            this.mnu_remove.Click += new System.EventHandler(this.mnu_remove_Click);\r
+            // \r
+            // label68\r
+            // \r
+            this.label68.AutoSize = true;\r
+            this.label68.BackColor = System.Drawing.Color.Transparent;\r
+            this.label68.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label68.Location = new System.Drawing.Point(13, 13);\r
+            this.label68.Name = "label68";\r
+            this.label68.Size = new System.Drawing.Size(57, 13);\r
+            this.label68.TabIndex = 67;\r
+            this.label68.Text = "Subtitles";\r
+            // \r
+            // SubGroupBox\r
+            // \r
+            this.SubGroupBox.BackColor = System.Drawing.Color.Transparent;\r
+            this.SubGroupBox.Controls.Add(this.drp_subtitleTracks);\r
+            this.SubGroupBox.Controls.Add(this.label10);\r
+            this.SubGroupBox.Controls.Add(this.label9);\r
+            this.SubGroupBox.Controls.Add(this.label2);\r
+            this.SubGroupBox.Controls.Add(this.srt_offset);\r
+            this.SubGroupBox.Controls.Add(this.srt_lang);\r
+            this.SubGroupBox.Controls.Add(this.label8);\r
+            this.SubGroupBox.Controls.Add(this.srt_charcode);\r
+            this.SubGroupBox.Controls.Add(this.label4);\r
+            this.SubGroupBox.Controls.Add(this.check_forced);\r
+            this.SubGroupBox.Controls.Add(this.label7);\r
+            this.SubGroupBox.Controls.Add(this.label3);\r
+            this.SubGroupBox.Controls.Add(this.check_default);\r
+            this.SubGroupBox.Controls.Add(this.check_burned);\r
+            this.SubGroupBox.Location = new System.Drawing.Point(16, 67);\r
+            this.SubGroupBox.Name = "SubGroupBox";\r
+            this.SubGroupBox.Size = new System.Drawing.Size(688, 73);\r
+            this.SubGroupBox.TabIndex = 72;\r
+            this.SubGroupBox.TabStop = false;\r
+            this.SubGroupBox.Text = "Selected Track: New Track";\r
+            // \r
+            // drp_subtitleTracks\r
+            // \r
+            this.drp_subtitleTracks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_subtitleTracks.FormattingEnabled = true;\r
+            this.drp_subtitleTracks.Location = new System.Drawing.Point(6, 35);\r
+            this.drp_subtitleTracks.Name = "drp_subtitleTracks";\r
+            this.drp_subtitleTracks.Size = new System.Drawing.Size(164, 21);\r
+            this.drp_subtitleTracks.TabIndex = 74;\r
+            this.drp_subtitleTracks.SelectedIndexChanged += new System.EventHandler(this.drp_subtitleTracks_SelectedIndexChanged);\r
+            // \r
+            // label10\r
+            // \r
+            this.label10.AutoSize = true;\r
+            this.label10.Location = new System.Drawing.Point(308, 19);\r
+            this.label10.Name = "label10";\r
+            this.label10.Size = new System.Drawing.Size(42, 13);\r
+            this.label10.TabIndex = 81;\r
+            this.label10.Text = "Default";\r
+            // \r
+            // label9\r
+            // \r
+            this.label9.AutoSize = true;\r
+            this.label9.Location = new System.Drawing.Point(248, 19);\r
+            this.label9.Name = "label9";\r
+            this.label9.Size = new System.Drawing.Size(54, 13);\r
+            this.label9.TabIndex = 80;\r
+            this.label9.Text = "Burned In";\r
+            // \r
+            // label2\r
+            // \r
+            this.label2.AutoSize = true;\r
+            this.label2.Location = new System.Drawing.Point(371, 19);\r
+            this.label2.Name = "label2";\r
+            this.label2.Size = new System.Drawing.Size(71, 13);\r
+            this.label2.TabIndex = 72;\r
+            this.label2.Text = "Srt Language";\r
+            // \r
+            // srt_offset\r
+            // \r
+            this.srt_offset.Enabled = false;\r
+            this.srt_offset.Increment = new decimal(new int[] {\r
+            10,\r
+            0,\r
+            0,\r
+            0});\r
+            this.srt_offset.Location = new System.Drawing.Point(549, 35);\r
+            this.srt_offset.Maximum = new decimal(new int[] {\r
+            1000000000,\r
+            0,\r
+            0,\r
+            0});\r
+            this.srt_offset.Name = "srt_offset";\r
+            this.srt_offset.Size = new System.Drawing.Size(58, 21);\r
+            this.srt_offset.TabIndex = 79;\r
+            this.srt_offset.ValueChanged += new System.EventHandler(this.srt_offset_ValueChanged);\r
+            // \r
+            // srt_lang\r
+            // \r
+            this.srt_lang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.srt_lang.Enabled = false;\r
+            this.srt_lang.FormattingEnabled = true;\r
+            this.srt_lang.Location = new System.Drawing.Point(356, 35);\r
+            this.srt_lang.Name = "srt_lang";\r
+            this.srt_lang.Size = new System.Drawing.Size(103, 21);\r
+            this.srt_lang.TabIndex = 50;\r
+            this.srt_lang.SelectedIndexChanged += new System.EventHandler(this.srt_lang_SelectedIndexChanged);\r
+            // \r
+            // label8\r
+            // \r
+            this.label8.AutoSize = true;\r
+            this.label8.Location = new System.Drawing.Point(177, 19);\r
+            this.label8.Name = "label8";\r
+            this.label8.Size = new System.Drawing.Size(65, 13);\r
+            this.label8.TabIndex = 79;\r
+            this.label8.Text = "Forced Only";\r
+            // \r
+            // srt_charcode\r
+            // \r
+            this.srt_charcode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.srt_charcode.Enabled = false;\r
+            this.srt_charcode.FormattingEnabled = true;\r
+            this.srt_charcode.Items.AddRange(new object[] {\r
+            "ANSI_X3.4-1968",\r
+            "ANSI_X3.4-1986",\r
+            "ANSI_X3.4",\r
+            "ANSI_X3.110-1983",\r
+            "ANSI_X3.110",\r
+            "ASCII",\r
+            "ECMA-114",\r
+            "ECMA-118",\r
+            "ECMA-128",\r
+            "ECMA-CYRILLIC",\r
+            "IEC_P27-1",\r
+            "ISO-8859-1",\r
+            "ISO-8859-2",\r
+            "ISO-8859-3",\r
+            "ISO-8859-4",\r
+            "ISO-8859-5",\r
+            "ISO-8859-6",\r
+            "ISO-8859-7",\r
+            "ISO-8859-8",\r
+            "ISO-8859-9",\r
+            "ISO-8859-9E",\r
+            "ISO-8859-10",\r
+            "ISO-8859-11",\r
+            "ISO-8859-13",\r
+            "ISO-8859-14",\r
+            "ISO-8859-15",\r
+            "ISO-8859-16",\r
+            "UTF-7",\r
+            "UTF-8",\r
+            "UTF-16",\r
+            "UTF-32"});\r
+            this.srt_charcode.Location = new System.Drawing.Point(465, 35);\r
+            this.srt_charcode.Name = "srt_charcode";\r
+            this.srt_charcode.Size = new System.Drawing.Size(78, 21);\r
+            this.srt_charcode.TabIndex = 73;\r
+            this.srt_charcode.SelectedIndexChanged += new System.EventHandler(this.srt_charcode_SelectedIndexChanged);\r
+            // \r
+            // label4\r
+            // \r
+            this.label4.AutoSize = true;\r
+            this.label4.Location = new System.Drawing.Point(548, 19);\r
+            this.label4.Name = "label4";\r
+            this.label4.Size = new System.Drawing.Size(62, 13);\r
+            this.label4.TabIndex = 76;\r
+            this.label4.Text = "Offset (ms)";\r
+            // \r
+            // check_forced\r
+            // \r
+            this.check_forced.AutoSize = true;\r
+            this.check_forced.Location = new System.Drawing.Point(199, 38);\r
+            this.check_forced.Name = "check_forced";\r
+            this.check_forced.Size = new System.Drawing.Size(15, 14);\r
+            this.check_forced.TabIndex = 75;\r
+            this.check_forced.UseVisualStyleBackColor = true;\r
+            this.check_forced.CheckedChanged += new System.EventHandler(this.check_forced_CheckedChanged);\r
+            // \r
+            // label7\r
+            // \r
+            this.label7.AutoSize = true;\r
+            this.label7.Location = new System.Drawing.Point(69, 19);\r
+            this.label7.Name = "label7";\r
+            this.label7.Size = new System.Drawing.Size(37, 13);\r
+            this.label7.TabIndex = 78;\r
+            this.label7.Text = "Track:";\r
+            // \r
+            // label3\r
+            // \r
+            this.label3.AutoSize = true;\r
+            this.label3.Location = new System.Drawing.Point(471, 19);\r
+            this.label3.Name = "label3";\r
+            this.label3.Size = new System.Drawing.Size(58, 13);\r
+            this.label3.TabIndex = 74;\r
+            this.label3.Text = "Char Code";\r
+            // \r
+            // check_default\r
+            // \r
+            this.check_default.AutoSize = true;\r
+            this.check_default.Location = new System.Drawing.Point(320, 38);\r
+            this.check_default.Name = "check_default";\r
+            this.check_default.Size = new System.Drawing.Size(15, 14);\r
+            this.check_default.TabIndex = 77;\r
+            this.check_default.UseVisualStyleBackColor = true;\r
+            this.check_default.CheckedChanged += new System.EventHandler(this.check_default_CheckedChanged);\r
+            // \r
+            // check_burned\r
+            // \r
+            this.check_burned.AutoSize = true;\r
+            this.check_burned.Location = new System.Drawing.Point(260, 38);\r
+            this.check_burned.Name = "check_burned";\r
+            this.check_burned.Size = new System.Drawing.Size(15, 14);\r
+            this.check_burned.TabIndex = 76;\r
+            this.check_burned.UseVisualStyleBackColor = true;\r
+            this.check_burned.CheckedChanged += new System.EventHandler(this.check_burned_CheckedChanged);\r
+            // \r
+            // btn_srtAdd\r
+            // \r
+            this.btn_srtAdd.BackColor = System.Drawing.Color.Transparent;\r
+            this.btn_srtAdd.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_srtAdd.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_srtAdd.Location = new System.Drawing.Point(158, 38);\r
+            this.btn_srtAdd.Name = "btn_srtAdd";\r
+            this.btn_srtAdd.Size = new System.Drawing.Size(88, 23);\r
+            this.btn_srtAdd.TabIndex = 73;\r
+            this.btn_srtAdd.Text = "Import SRT";\r
+            this.toolTip.SetToolTip(this.btn_srtAdd, "Add a new SRT file to the \"track\" dropdown menu.");\r
+            this.btn_srtAdd.UseVisualStyleBackColor = false;\r
+            this.btn_srtAdd.Click += new System.EventHandler(this.btn_srtAdd_Click);\r
+            // \r
+            // openFileDialog\r
+            // \r
+            this.openFileDialog.DefaultExt = "srt";\r
+            this.openFileDialog.Filter = "SRT Files |*.srt";\r
+            // \r
+            // Subtitles\r
+            // \r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
+            this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.SubGroupBox);\r
+            this.Controls.Add(this.btn_addTrack);\r
+            this.Controls.Add(this.label68);\r
+            this.Controls.Add(this.btn_RemoveSubTrack);\r
+            this.Controls.Add(this.lv_subList);\r
+            this.Controls.Add(this.btn_srtAdd);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Name = "Subtitles";\r
+            this.Size = new System.Drawing.Size(719, 300);\r
+            this.subMenu.ResumeLayout(false);\r
+            this.SubGroupBox.ResumeLayout(false);\r
+            this.SubGroupBox.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.srt_offset)).EndInit();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.Button btn_RemoveSubTrack;\r
+        private System.Windows.Forms.Button btn_addTrack;\r
+        internal System.Windows.Forms.ListView lv_subList;\r
+        private System.Windows.Forms.ColumnHeader col_Source;\r
+        private System.Windows.Forms.ColumnHeader col_forced;\r
+        private System.Windows.Forms.ColumnHeader col_burned;\r
+        internal System.Windows.Forms.Label label68;\r
+        private System.Windows.Forms.ColumnHeader col_defaultTrack;\r
+        private System.Windows.Forms.ContextMenuStrip subMenu;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_moveup;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_movedown;\r
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_remove;\r
+        private System.Windows.Forms.Button btn_srtAdd;\r
+        private System.Windows.Forms.ColumnHeader col_srtChar;\r
+        private System.Windows.Forms.ColumnHeader col_srtOffset;\r
+        private System.Windows.Forms.GroupBox SubGroupBox;\r
+        private System.Windows.Forms.Label label4;\r
+        private System.Windows.Forms.Label label3;\r
+        internal System.Windows.Forms.ComboBox srt_charcode;\r
+        private System.Windows.Forms.Label label2;\r
+        internal System.Windows.Forms.ComboBox srt_lang;\r
+        private System.Windows.Forms.NumericUpDown srt_offset;\r
+        private System.Windows.Forms.OpenFileDialog openFileDialog;\r
+        private System.Windows.Forms.Label label7;\r
+        private System.Windows.Forms.CheckBox check_default;\r
+        private System.Windows.Forms.CheckBox check_burned;\r
+        private System.Windows.Forms.CheckBox check_forced;\r
+        internal System.Windows.Forms.ComboBox drp_subtitleTracks;\r
+        private System.Windows.Forms.Label label8;\r
+        private System.Windows.Forms.Label label9;\r
+        private System.Windows.Forms.Label label10;\r
+        private System.Windows.Forms.ColumnHeader col_srtLang;\r
+        private System.Windows.Forms.ToolTip toolTip;\r
+    }\r
+}\r
diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs
new file mode 100644 (file)
index 0000000..80c7edb
--- /dev/null
@@ -0,0 +1,454 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.IO;\r
+using System.Windows.Forms;\r
+using Handbrake.Functions;\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    public partial class Subtitles : UserControl\r
+    {\r
+        readonly IDictionary<string, string> LangMap = new Dictionary<string, string>();\r
+        List<SubtitleInfo> SubList = new List<SubtitleInfo>();\r
+        private int _fileContainer;\r
+\r
+        public Subtitles()\r
+        {\r
+            InitializeComponent();\r
+\r
+            LangMap = Main.mapLanguages();\r
+            foreach (string key in LangMap.Keys)\r
+                srt_lang.Items.Add(key);\r
+\r
+            srt_charcode.SelectedIndex = 28;\r
+            srt_lang.SelectedIndex = 40;\r
+        }\r
+\r
+        // Primary Controls\r
+        private void btn_addSubTrack_Click(object sender, EventArgs e)\r
+        {\r
+            // Logic\r
+            string forcedVal = check_forced.CheckState == CheckState.Checked ? "Yes" : "No";\r
+            string defaultSub = check_default.CheckState == CheckState.Checked ? "Yes" : "No";\r
+            string burnedVal = check_burned.CheckState == CheckState.Checked && (!drp_subtitleTracks.Text.Contains("Text")) ? "Yes" : "No";\r
+            string srtCode = "-", srtLangVal = "-", srtPath = "-", srtFile = "-";\r
+            int srtOffsetMs = 0;\r
+\r
+            if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))\r
+            {\r
+                burnedVal = "No";\r
+                forcedVal = "No";\r
+                srtPath = openFileDialog.FileName;\r
+                srtFile = Path.GetFileName(openFileDialog.FileName);\r
+                srtLangVal = srt_lang.SelectedItem.ToString();\r
+                srtCode = srt_charcode.SelectedItem.ToString();\r
+                srtOffsetMs = (int)srt_offset.Value;\r
+                if (defaultSub == "Yes") setNoSrtDefault();\r
+            } else\r
+            {\r
+                if (defaultSub == "Yes") SetNoDefault();\r
+                if (burnedVal == "Yes") SetNoBurned();\r
+\r
+                if (_fileContainer == 0)\r
+                    burnedVal = "Yes";  // MP4 must have bitmap subs burned in.\r
+            }\r
+\r
+            if (_fileContainer == 0) // MP4 and M4V file extension\r
+            {\r
+                // Make sure we only have 1 bitmap track.\r
+                if (drp_subtitleTracks.SelectedItem != null && drp_subtitleTracks.SelectedItem.ToString().Contains("Bitmap"))\r
+                {\r
+                    foreach (ListViewItem item in lv_subList.Items)\r
+                    {\r
+                        if (item.SubItems[0].Text.Contains("Bitmap"))\r
+                        {\r
+                            MessageBox.Show(this, "More than one vobsub is not supported in mp4... Your first vobsub track will now be used.",\r
+                                            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                            return;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            string trackName = (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))\r
+                               ? srtLangVal + " (" + srtFile + ")"\r
+                               : drp_subtitleTracks.SelectedItem.ToString();\r
+\r
+\r
+            SubtitleInfo track = new SubtitleInfo\r
+                                     {\r
+                                         Track = trackName,\r
+                                         Forced = forcedVal,\r
+                                         Burned = burnedVal,\r
+                                         Default = defaultSub,\r
+                                         SrtLang = srtLangVal,\r
+                                         SrtCharCode = srtCode,\r
+                                         SrtOffset = srtOffsetMs,\r
+                                         SrtPath = srtPath,\r
+                                         SrtFileName = srtFile\r
+                                     };\r
+\r
+            lv_subList.Items.Add(track.ListView);\r
+            SubList.Add(track);\r
+\r
+        }\r
+        private void btn_srtAdd_Click(object sender, EventArgs e)\r
+        {\r
+            if (openFileDialog.ShowDialog() != DialogResult.OK)\r
+                return;\r
+            drp_subtitleTracks.Items.Add(Path.GetFileName(openFileDialog.FileName));\r
+            drp_subtitleTracks.SelectedItem = Path.GetFileName(openFileDialog.FileName);\r
+        }\r
+        private void btn_RemoveSubTrack_Click(object sender, EventArgs e)\r
+        {\r
+            RemoveTrack();\r
+        }\r
+\r
+        // Secondary Controls\r
+        private void lb_subList_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            // Set the dropdown controls based on the selected item in the List.\r
+            if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0)\r
+            {\r
+                SubtitleInfo track = SubList[lv_subList.SelectedIndices[0]];\r
+\r
+                int c = 0;\r
+                if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.ToLower().Contains(".srt"))  // We have an SRT\r
+                {\r
+                    foreach (var item in drp_subtitleTracks.Items)\r
+                    {\r
+                        if (item.ToString() == track.SrtFileName)\r
+                            drp_subtitleTracks.SelectedIndex = c;\r
+                        c++;\r
+                    }\r
+                    srt_lang.SelectedItem = track.SrtLang;\r
+                    srt_offset.Value = track.SrtOffset;\r
+                    srt_charcode.SelectedItem = track.SrtCharCode;\r
+                    check_default.CheckState = track.Default == "Yes" ? CheckState.Checked : CheckState.Unchecked;\r
+                    SubGroupBox.Text = "Selected Track: " + track.Track;\r
+                }\r
+                else  // We have Bitmap/CC\r
+                {\r
+                    foreach (var item in drp_subtitleTracks.Items)\r
+                    {\r
+                        if (item.ToString() == track.Track)\r
+                            drp_subtitleTracks.SelectedIndex = c;\r
+                        c++;\r
+                    }\r
+                    check_forced.CheckState = track.Forced == "Yes" ? CheckState.Checked : CheckState.Unchecked;\r
+                    check_burned.CheckState = track.Burned == "Yes" ? CheckState.Checked : CheckState.Unchecked;\r
+                    check_default.CheckState = track.Default == "Yes" ? CheckState.Checked : CheckState.Unchecked;\r
+                    SubGroupBox.Text = "Selected Track: " + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text;\r
+                }\r
+            }\r
+            else\r
+                SubGroupBox.Text = "Selected Track: None (Click \"Add\" to add another track to the list)";\r
+        }\r
+\r
+        // Bitmap / CC / SRT Controls\r
+        private void drp_subtitleTracks_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))\r
+            {\r
+                check_forced.Enabled = false;\r
+                check_burned.Enabled = false;\r
+                srt_lang.Enabled = true;\r
+                srt_charcode.Enabled = true;\r
+                srt_offset.Enabled = true;\r
+            }\r
+            else\r
+            {\r
+                check_forced.Enabled = true;\r
+                check_burned.Enabled = true;\r
+                srt_lang.Enabled = false;\r
+                srt_charcode.Enabled = false;\r
+                srt_offset.Enabled = false;\r
+            }\r
+            // Update an item in the  list if required.\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt"))\r
+            {\r
+                lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text = srt_lang.SelectedItem + "(" +\r
+                    drp_subtitleTracks.SelectedItem + ")";\r
+                lv_subList.Select();\r
+            } else\r
+            {\r
+                lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text =\r
+                    drp_subtitleTracks.SelectedItem.ToString();\r
+                lv_subList.Select();\r
+            }\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].Track = drp_subtitleTracks.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>\r
+        }\r
+        private void check_forced_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1].Text = check_forced.Checked ? "Yes" : "No";\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].Forced = check_forced.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo> \r
+        }\r
+        private void check_burned_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            if (check_burned.Checked) // Make sure we only have 1 burned track\r
+                SetNoBurned();\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[2].Text = check_burned.Checked ? "Yes" : "No";\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].Burned = check_burned.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo> \r
+        }\r
+        private void check_default_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            if (check_default.Checked) // Make sure we only have 1 default track\r
+                if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.Contains(".srt"))\r
+                    setNoSrtDefault();\r
+                else\r
+                    SetNoDefault();\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text = check_default.Checked ? "Yes" : "No";\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].Default = check_default.Checked ? "Yes" : "No"; // Update SubList List<SubtitleInfo>\r
+        }\r
+        private void srt_offset_ValueChanged(object sender, EventArgs e)\r
+        {\r
+            // Update an item in the  list if required.\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0)\r
+                return;\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[6].Text = srt_offset.Value.ToString();\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].SrtOffset = (int)srt_offset.Value; // Update SubList List<SubtitleInfo>\r
+        }\r
+        private void srt_charcode_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[5].Text = srt_charcode.SelectedItem.ToString();\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].SrtCharCode = srt_charcode.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>\r
+        }\r
+        private void srt_lang_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.Items.Count == 0 || lv_subList.SelectedIndices.Count == 0) return;\r
+\r
+            lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text = srt_lang.SelectedItem.ToString();\r
+            lv_subList.Select();\r
+\r
+            SubList[lv_subList.SelectedIndices[0]].SrtLang = srt_lang.SelectedItem.ToString(); // Update SubList List<SubtitleInfo>\r
+        }\r
+\r
+        // Right Click Menu\r
+        private void mnu_moveup_Click(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.SelectedIndices.Count != 0)\r
+            {\r
+                ListViewItem item = lv_subList.SelectedItems[0];\r
+                int index = item.Index;\r
+                index--;\r
+\r
+                if (lv_subList.Items.Count > index && index >= 0)\r
+                {\r
+                    lv_subList.Items.Remove(item);\r
+                    lv_subList.Items.Insert(index, item);\r
+                    item.Selected = true;\r
+                    lv_subList.Focus();\r
+                }\r
+            }\r
+        }\r
+        private void mnu_movedown_Click(object sender, EventArgs e)\r
+        {\r
+            if (lv_subList.SelectedIndices.Count != 0)\r
+            {\r
+                ListViewItem item = lv_subList.SelectedItems[0];\r
+                int index = item.Index;\r
+                index++;\r
+\r
+                if (index < lv_subList.Items.Count)\r
+                {\r
+                    lv_subList.Items.Remove(item);\r
+                    lv_subList.Items.Insert(index, item);\r
+                    item.Selected = true;\r
+                    lv_subList.Focus();\r
+                }\r
+            }\r
+        }\r
+        private void mnu_remove_Click(object sender, EventArgs e)\r
+        {\r
+            RemoveTrack();\r
+        }\r
+\r
+        // Functions\r
+        private void SetNoDefault()\r
+        {\r
+            int c = 0;\r
+            foreach (ListViewItem item in lv_subList.Items)\r
+            {\r
+                if (SubList[c].SrtPath == "-")\r
+                {\r
+                    if (item.SubItems[3].Text == "Yes")\r
+                    {\r
+                        item.SubItems[3].Text = "No";\r
+                        SubList[c].Default = "No";\r
+                    }     \r
+                }\r
+                c++;\r
+            }\r
+        }\r
+\r
+        private void setNoSrtDefault()\r
+        {\r
+            int c = 0;\r
+            foreach (ListViewItem item in lv_subList.Items)\r
+            {\r
+                if (SubList[c].SrtPath != "-")\r
+                {\r
+                    if (item.SubItems[3].Text == "Yes")\r
+                    {\r
+                        item.SubItems[3].Text = "No";\r
+                        SubList[c].Default = "No";\r
+                    }\r
+                }\r
+                c++;\r
+            }\r
+        }\r
+        private void SetNoBurned()\r
+        {\r
+            int c = 0;\r
+            foreach (ListViewItem item in lv_subList.Items)\r
+            {\r
+                if (item.SubItems[2].Text == "Yes")\r
+                {\r
+                    item.SubItems[2].Text = "No";\r
+                    SubList[c].Burned = "No";\r
+                }\r
+                c++;\r
+            }\r
+        }\r
+        private void RemoveTrack()\r
+        {\r
+            // Remove the Item and reselect the control if the following conditions are met.\r
+            if (lv_subList.SelectedItems.Count != 0)\r
+            {\r
+                // Record the current selected index.\r
+                int currentPosition = lv_subList.SelectedIndices[0];\r
+                int selectedInd = lv_subList.SelectedIndices[0];\r
+\r
+                lv_subList.Items.RemoveAt(selectedInd);\r
+                SubList.RemoveAt(selectedInd);\r
+\r
+                // Now reslect the correct item and give focus to the list.\r
+                if (lv_subList.Items.Count != 0)\r
+                {\r
+                    if (currentPosition <= (lv_subList.Items.Count - 1))\r
+                        lv_subList.Items[currentPosition].Selected = true;\r
+                    else if (currentPosition > (lv_subList.Items.Count - 1))\r
+                        lv_subList.Items[lv_subList.Items.Count - 1].Selected = true;\r
+\r
+                    lv_subList.Select();\r
+                }\r
+            }\r
+        }\r
+\r
+        // Public Functions\r
+        public void Clear()\r
+        {\r
+            lv_subList.Items.Clear();\r
+            SubList.Clear();\r
+        }\r
+        public void SmartClear()\r
+        {\r
+            /* Smart clear will only remove subtitle tracks that do not have an equivlent \r
+              for the new source / title which the user has selected. */\r
+            throw new NotImplementedException();\r
+        }\r
+        public Boolean RequiresM4V()\r
+        {\r
+            foreach (ListViewItem item in lv_subList.Items)\r
+            {\r
+                if (item.SubItems.Count != 5)\r
+                    return true;\r
+\r
+                if (item.SubItems[1].Text.Contains("(Text)"))\r
+                    return true;\r
+            }\r
+            return false;\r
+        }\r
+        public void SetSubtitleTrackAuto()\r
+        {\r
+            // Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options\r
+            if (Properties.Settings.Default.NativeLanguage != "Any")\r
+            {\r
+                if (!Properties.Settings.Default.DubAudio) // We need to add a subtitle track if this is false.\r
+                {\r
+                    int i = 0;\r
+                    foreach (object item in drp_subtitleTracks.Items)\r
+                    {\r
+                        if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage))\r
+                            drp_subtitleTracks.SelectedIndex = i;\r
+\r
+                        i++;\r
+                    }\r
+\r
+                    btn_addSubTrack_Click(this, new EventArgs());\r
+                }\r
+            }\r
+        }\r
+        public void SetContainer(int value)\r
+        {\r
+            _fileContainer = value;\r
+            Boolean trigger = false;\r
+            if (_fileContainer != 1)\r
+                foreach (ListViewItem item in lv_subList.Items)\r
+                {\r
+                    if (item.SubItems[1].Text.Contains("Bitmap"))\r
+                    {\r
+                        if (trigger)\r
+                            lv_subList.Items.Remove(item);\r
+                        trigger = true;\r
+                    }\r
+                }\r
+        }\r
+        public List<SubtitleInfo> GetSubtitleInfoList()\r
+        {\r
+            return SubList;\r
+        }\r
+    }\r
+\r
+    public class SubtitleInfo\r
+    {\r
+        public string Track { get; set; }\r
+        public string Forced { get; set; }\r
+        public string Burned { get; set; }\r
+        public string Default { get; set; }\r
+        public string SrtLang { get; set; }\r
+        public string SrtCharCode { get; set; }\r
+        public int SrtOffset { get; set; }\r
+        public string SrtPath { get; set; }\r
+        public string SrtFileName { get; set; }\r
+\r
+        public ListViewItem ListView\r
+        {\r
+            get\r
+            {\r
+                ListViewItem listTrack = new ListViewItem(Track);\r
+                listTrack.SubItems.Add(Forced);\r
+                listTrack.SubItems.Add(Burned);\r
+                listTrack.SubItems.Add(Default);\r
+                listTrack.SubItems.Add(SrtLang);\r
+                listTrack.SubItems.Add(SrtCharCode);\r
+                listTrack.SubItems.Add(SrtOffset.ToString());\r
+                return listTrack;\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/Controls/Subtitles.resx b/win/C#/Controls/Subtitles.resx
new file mode 100644 (file)
index 0000000..2e6f00c
--- /dev/null
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>237, 17</value>\r
+  </metadata>\r
+  <metadata name="subMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>237, 17</value>\r
+  </metadata>\r
+  <metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>113, 17</value>\r
+  </metadata>\r
+</root>
\ No newline at end of file
diff --git a/win/C#/Controls/x264Panel.Designer.cs b/win/C#/Controls/x264Panel.Designer.cs
new file mode 100644 (file)
index 0000000..206a0b6
--- /dev/null
@@ -0,0 +1,773 @@
+/*  x264Panel.Designer.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    partial class x264Panel\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.components = new System.ComponentModel.Container();\r
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(x264Panel));\r
+            this.slider_psytrellis = new System.Windows.Forms.TrackBar();\r
+            this.lbl_psytrellis = new System.Windows.Forms.Label();\r
+            this.lbl_psyrd = new System.Windows.Forms.Label();\r
+            this.slider_psyrd = new System.Windows.Forms.TrackBar();\r
+            this.lbl_adaptBFrames = new System.Windows.Forms.Label();\r
+            this.drop_adaptBFrames = new System.Windows.Forms.ComboBox();\r
+            this.label43 = new System.Windows.Forms.Label();\r
+            this.btn_reset = new System.Windows.Forms.Button();\r
+            this.rtf_x264Query = new System.Windows.Forms.RichTextBox();\r
+            this.check_Cabac = new System.Windows.Forms.CheckBox();\r
+            this.check_noDCTDecimate = new System.Windows.Forms.CheckBox();\r
+            this.check_noFastPSkip = new System.Windows.Forms.CheckBox();\r
+            this.lbl_trellis = new System.Windows.Forms.Label();\r
+            this.drop_trellis = new System.Windows.Forms.ComboBox();\r
+            this.drop_deblockBeta = new System.Windows.Forms.ComboBox();\r
+            this.label41 = new System.Windows.Forms.Label();\r
+            this.drop_deblockAlpha = new System.Windows.Forms.ComboBox();\r
+            this.panel3 = new System.Windows.Forms.Panel();\r
+            this.panel1 = new System.Windows.Forms.Panel();\r
+            this.panel2 = new System.Windows.Forms.Panel();\r
+            this.check_8x8DCT = new System.Windows.Forms.CheckBox();\r
+            this.label45 = new System.Windows.Forms.Label();\r
+            this.drop_analysis = new System.Windows.Forms.ComboBox();\r
+            this.label48 = new System.Windows.Forms.Label();\r
+            this.drop_subpixelMotionEstimation = new System.Windows.Forms.ComboBox();\r
+            this.lbl_merange = new System.Windows.Forms.Label();\r
+            this.drop_MotionEstimationRange = new System.Windows.Forms.ComboBox();\r
+            this.label54 = new System.Windows.Forms.Label();\r
+            this.drop_MotionEstimationMethod = new System.Windows.Forms.ComboBox();\r
+            this.check_pyrmidalBFrames = new System.Windows.Forms.CheckBox();\r
+            this.check_weightedBFrames = new System.Windows.Forms.CheckBox();\r
+            this.lbl_direct_prediction = new System.Windows.Forms.Label();\r
+            this.drop_directPrediction = new System.Windows.Forms.ComboBox();\r
+            this.label62 = new System.Windows.Forms.Label();\r
+            this.drop_bFrames = new System.Windows.Forms.ComboBox();\r
+            this.label64 = new System.Windows.Forms.Label();\r
+            this.drop_refFrames = new System.Windows.Forms.ComboBox();\r
+            this.check_mixedReferences = new System.Windows.Forms.CheckBox();\r
+            this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_psytrellis)).BeginInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_psyrd)).BeginInit();\r
+            this.SuspendLayout();\r
+            // \r
+            // slider_psytrellis\r
+            // \r
+            this.slider_psytrellis.Location = new System.Drawing.Point(436, 194);\r
+            this.slider_psytrellis.Name = "slider_psytrellis";\r
+            this.slider_psytrellis.Size = new System.Drawing.Size(131, 45);\r
+            this.slider_psytrellis.TabIndex = 86;\r
+            this.ToolTip.SetToolTip(this.slider_psytrellis, "Psychovisual Trellis tries to retain more sharpness and detail, but can cause art" +\r
+                    "ifacting. \r\nIt is considered experimental, which is why it\'s off by default. Goo" +\r
+                    "d values are 0.1 to 0.2.");\r
+            this.slider_psytrellis.Scroll += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // lbl_psytrellis\r
+            // \r
+            this.lbl_psytrellis.AutoSize = true;\r
+            this.lbl_psytrellis.Location = new System.Drawing.Point(328, 198);\r
+            this.lbl_psytrellis.Name = "lbl_psytrellis";\r
+            this.lbl_psytrellis.Size = new System.Drawing.Size(102, 13);\r
+            this.lbl_psytrellis.TabIndex = 85;\r
+            this.lbl_psytrellis.Text = "Psychovisual Trellis:";\r
+            // \r
+            // lbl_psyrd\r
+            // \r
+            this.lbl_psyrd.AutoSize = true;\r
+            this.lbl_psyrd.Location = new System.Drawing.Point(283, 164);\r
+            this.lbl_psyrd.Name = "lbl_psyrd";\r
+            this.lbl_psyrd.Size = new System.Drawing.Size(147, 13);\r
+            this.lbl_psyrd.TabIndex = 84;\r
+            this.lbl_psyrd.Text = "Psychovisual Rate Distortion:";\r
+            // \r
+            // slider_psyrd\r
+            // \r
+            this.slider_psyrd.Location = new System.Drawing.Point(436, 153);\r
+            this.slider_psyrd.Name = "slider_psyrd";\r
+            this.slider_psyrd.Size = new System.Drawing.Size(131, 45);\r
+            this.slider_psyrd.TabIndex = 83;\r
+            this.ToolTip.SetToolTip(this.slider_psyrd, resources.GetString("slider_psyrd.ToolTip"));\r
+            this.slider_psyrd.Scroll += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // lbl_adaptBFrames\r
+            // \r
+            this.lbl_adaptBFrames.AutoSize = true;\r
+            this.lbl_adaptBFrames.Location = new System.Drawing.Point(21, 124);\r
+            this.lbl_adaptBFrames.Name = "lbl_adaptBFrames";\r
+            this.lbl_adaptBFrames.Size = new System.Drawing.Size(102, 13);\r
+            this.lbl_adaptBFrames.TabIndex = 81;\r
+            this.lbl_adaptBFrames.Text = "Adaptive B-Frames:";\r
+            // \r
+            // drop_adaptBFrames\r
+            // \r
+            this.drop_adaptBFrames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_adaptBFrames.FormattingEnabled = true;\r
+            this.drop_adaptBFrames.Items.AddRange(new object[] {\r
+            "Default (Fast)",\r
+            "Off",\r
+            "Fast",\r
+            "Optimal"});\r
+            this.drop_adaptBFrames.Location = new System.Drawing.Point(129, 121);\r
+            this.drop_adaptBFrames.Name = "drop_adaptBFrames";\r
+            this.drop_adaptBFrames.Size = new System.Drawing.Size(121, 21);\r
+            this.drop_adaptBFrames.TabIndex = 82;\r
+            this.ToolTip.SetToolTip(this.drop_adaptBFrames, resources.GetString("drop_adaptBFrames.ToolTip"));\r
+            this.drop_adaptBFrames.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label43\r
+            // \r
+            this.label43.AutoSize = true;\r
+            this.label43.BackColor = System.Drawing.Color.Transparent;\r
+            this.label43.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label43.Location = new System.Drawing.Point(13, 13);\r
+            this.label43.Name = "label43";\r
+            this.label43.Size = new System.Drawing.Size(144, 13);\r
+            this.label43.TabIndex = 49;\r
+            this.label43.Text = "Advanced H.264 Options";\r
+            // \r
+            // btn_reset\r
+            // \r
+            this.btn_reset.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_reset.ForeColor = System.Drawing.Color.DarkOrange;\r
+            this.btn_reset.Location = new System.Drawing.Point(13, 229);\r
+            this.btn_reset.Name = "btn_reset";\r
+            this.btn_reset.Size = new System.Drawing.Size(75, 23);\r
+            this.btn_reset.TabIndex = 79;\r
+            this.btn_reset.Text = "Reset All";\r
+            this.btn_reset.UseVisualStyleBackColor = true;\r
+            this.btn_reset.Click += new System.EventHandler(this.btn_reset_Click);\r
+            // \r
+            // rtf_x264Query\r
+            // \r
+            this.rtf_x264Query.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+            this.rtf_x264Query.Location = new System.Drawing.Point(13, 258);\r
+            this.rtf_x264Query.Name = "rtf_x264Query";\r
+            this.rtf_x264Query.Size = new System.Drawing.Size(698, 43);\r
+            this.rtf_x264Query.TabIndex = 80;\r
+            this.rtf_x264Query.Text = "";\r
+            this.rtf_x264Query.TextChanged += new System.EventHandler(this.rtf_x264Query_TextChanged);\r
+            // \r
+            // check_Cabac\r
+            // \r
+            this.check_Cabac.AutoSize = true;\r
+            this.check_Cabac.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_Cabac.Checked = true;\r
+            this.check_Cabac.CheckState = System.Windows.Forms.CheckState.Checked;\r
+            this.check_Cabac.Location = new System.Drawing.Point(277, 129);\r
+            this.check_Cabac.Name = "check_Cabac";\r
+            this.check_Cabac.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_Cabac.Size = new System.Drawing.Size(141, 17);\r
+            this.check_Cabac.TabIndex = 78;\r
+            this.check_Cabac.Text = "CABAC Entropy Coding:";\r
+            this.check_Cabac.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.ToolTip.SetToolTip(this.check_Cabac, resources.GetString("check_Cabac.ToolTip"));\r
+            this.check_Cabac.UseVisualStyleBackColor = true;\r
+            this.check_Cabac.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // check_noDCTDecimate\r
+            // \r
+            this.check_noDCTDecimate.AutoSize = true;\r
+            this.check_noDCTDecimate.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_noDCTDecimate.Location = new System.Drawing.Point(597, 41);\r
+            this.check_noDCTDecimate.Name = "check_noDCTDecimate";\r
+            this.check_noDCTDecimate.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_noDCTDecimate.Size = new System.Drawing.Size(114, 17);\r
+            this.check_noDCTDecimate.TabIndex = 77;\r
+            this.check_noDCTDecimate.Text = "No DCT-Decimate:";\r
+            this.check_noDCTDecimate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.ToolTip.SetToolTip(this.check_noDCTDecimate, resources.GetString("check_noDCTDecimate.ToolTip"));\r
+            this.check_noDCTDecimate.UseVisualStyleBackColor = true;\r
+            this.check_noDCTDecimate.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // check_noFastPSkip\r
+            // \r
+            this.check_noFastPSkip.AutoSize = true;\r
+            this.check_noFastPSkip.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_noFastPSkip.Location = new System.Drawing.Point(611, 18);\r
+            this.check_noFastPSkip.Name = "check_noFastPSkip";\r
+            this.check_noFastPSkip.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_noFastPSkip.Size = new System.Drawing.Size(100, 17);\r
+            this.check_noFastPSkip.TabIndex = 76;\r
+            this.check_noFastPSkip.Text = "No Fast-P-Skip:";\r
+            this.check_noFastPSkip.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.ToolTip.SetToolTip(this.check_noFastPSkip, "This can help with blocking on solid colors like blue skies, but it also slows do" +\r
+                    "wn the encode.");\r
+            this.check_noFastPSkip.UseVisualStyleBackColor = true;\r
+            this.check_noFastPSkip.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // lbl_trellis\r
+            // \r
+            this.lbl_trellis.AutoSize = true;\r
+            this.lbl_trellis.Location = new System.Drawing.Point(421, 130);\r
+            this.lbl_trellis.Name = "lbl_trellis";\r
+            this.lbl_trellis.Size = new System.Drawing.Size(38, 13);\r
+            this.lbl_trellis.TabIndex = 67;\r
+            this.lbl_trellis.Text = "Trellis:";\r
+            // \r
+            // drop_trellis\r
+            // \r
+            this.drop_trellis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_trellis.FormattingEnabled = true;\r
+            this.drop_trellis.Items.AddRange(new object[] {\r
+            "Default (1)",\r
+            "0",\r
+            "1",\r
+            "2"});\r
+            this.drop_trellis.Location = new System.Drawing.Point(468, 127);\r
+            this.drop_trellis.Name = "drop_trellis";\r
+            this.drop_trellis.Size = new System.Drawing.Size(94, 21);\r
+            this.drop_trellis.TabIndex = 75;\r
+            this.ToolTip.SetToolTip(this.drop_trellis, resources.GetString("drop_trellis.ToolTip"));\r
+            this.drop_trellis.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // drop_deblockBeta\r
+            // \r
+            this.drop_deblockBeta.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_deblockBeta.FormattingEnabled = true;\r
+            this.drop_deblockBeta.Items.AddRange(new object[] {\r
+            "Default (0)",\r
+            "-6",\r
+            "-5",\r
+            "-4",\r
+            "-3",\r
+            "-2",\r
+            "-1",\r
+            "0",\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6"});\r
+            this.drop_deblockBeta.Location = new System.Drawing.Point(643, 95);\r
+            this.drop_deblockBeta.Name = "drop_deblockBeta";\r
+            this.drop_deblockBeta.Size = new System.Drawing.Size(68, 21);\r
+            this.drop_deblockBeta.TabIndex = 74;\r
+            this.ToolTip.SetToolTip(this.drop_deblockBeta, resources.GetString("drop_deblockBeta.ToolTip"));\r
+            this.drop_deblockBeta.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label41\r
+            // \r
+            this.label41.AutoSize = true;\r
+            this.label41.Location = new System.Drawing.Point(575, 72);\r
+            this.label41.Name = "label41";\r
+            this.label41.Size = new System.Drawing.Size(62, 13);\r
+            this.label41.TabIndex = 66;\r
+            this.label41.Text = "Deblocking:";\r
+            // \r
+            // drop_deblockAlpha\r
+            // \r
+            this.drop_deblockAlpha.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_deblockAlpha.FormattingEnabled = true;\r
+            this.drop_deblockAlpha.Items.AddRange(new object[] {\r
+            "Default (0)",\r
+            "-6",\r
+            "-5",\r
+            "-4",\r
+            "-3",\r
+            "-2",\r
+            "-1",\r
+            "0",\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6"});\r
+            this.drop_deblockAlpha.Location = new System.Drawing.Point(643, 69);\r
+            this.drop_deblockAlpha.Name = "drop_deblockAlpha";\r
+            this.drop_deblockAlpha.Size = new System.Drawing.Size(68, 21);\r
+            this.drop_deblockAlpha.TabIndex = 73;\r
+            this.ToolTip.SetToolTip(this.drop_deblockAlpha, resources.GetString("drop_deblockAlpha.ToolTip"));\r
+            this.drop_deblockAlpha.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // panel3\r
+            // \r
+            this.panel3.BackColor = System.Drawing.Color.Black;\r
+            this.panel3.Location = new System.Drawing.Point(277, 123);\r
+            this.panel3.Margin = new System.Windows.Forms.Padding(0);\r
+            this.panel3.Name = "panel3";\r
+            this.panel3.Size = new System.Drawing.Size(290, 1);\r
+            this.panel3.TabIndex = 65;\r
+            // \r
+            // panel1\r
+            // \r
+            this.panel1.BackColor = System.Drawing.Color.Black;\r
+            this.panel1.Location = new System.Drawing.Point(13, 89);\r
+            this.panel1.Margin = new System.Windows.Forms.Padding(0);\r
+            this.panel1.Name = "panel1";\r
+            this.panel1.Size = new System.Drawing.Size(247, 1);\r
+            this.panel1.TabIndex = 51;\r
+            // \r
+            // panel2\r
+            // \r
+            this.panel2.BackColor = System.Drawing.Color.Black;\r
+            this.panel2.Location = new System.Drawing.Point(277, 95);\r
+            this.panel2.Margin = new System.Windows.Forms.Padding(0);\r
+            this.panel2.Name = "panel2";\r
+            this.panel2.Size = new System.Drawing.Size(290, 1);\r
+            this.panel2.TabIndex = 63;\r
+            // \r
+            // check_8x8DCT\r
+            // \r
+            this.check_8x8DCT.AutoSize = true;\r
+            this.check_8x8DCT.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_8x8DCT.Location = new System.Drawing.Point(492, 101);\r
+            this.check_8x8DCT.Name = "check_8x8DCT";\r
+            this.check_8x8DCT.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_8x8DCT.Size = new System.Drawing.Size(71, 17);\r
+            this.check_8x8DCT.TabIndex = 72;\r
+            this.check_8x8DCT.Text = "8x8 DCT:";\r
+            this.check_8x8DCT.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.ToolTip.SetToolTip(this.check_8x8DCT, resources.GetString("check_8x8DCT.ToolTip"));\r
+            this.check_8x8DCT.UseVisualStyleBackColor = true;\r
+            this.check_8x8DCT.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label45\r
+            // \r
+            this.label45.AutoSize = true;\r
+            this.label45.Location = new System.Drawing.Point(367, 102);\r
+            this.label45.Name = "label45";\r
+            this.label45.Size = new System.Drawing.Size(50, 13);\r
+            this.label45.TabIndex = 64;\r
+            this.label45.Text = "Analysis:";\r
+            // \r
+            // drop_analysis\r
+            // \r
+            this.drop_analysis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_analysis.FormattingEnabled = true;\r
+            this.drop_analysis.Items.AddRange(new object[] {\r
+            "Default (some)",\r
+            "None",\r
+            "All"});\r
+            this.drop_analysis.Location = new System.Drawing.Point(423, 99);\r
+            this.drop_analysis.Name = "drop_analysis";\r
+            this.drop_analysis.Size = new System.Drawing.Size(63, 21);\r
+            this.drop_analysis.TabIndex = 71;\r
+            this.ToolTip.SetToolTip(this.drop_analysis, resources.GetString("drop_analysis.ToolTip"));\r
+            this.drop_analysis.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label48\r
+            // \r
+            this.label48.AutoSize = true;\r
+            this.label48.Location = new System.Drawing.Point(279, 45);\r
+            this.label48.Name = "label48";\r
+            this.label48.Size = new System.Drawing.Size(138, 13);\r
+            this.label48.TabIndex = 62;\r
+            this.label48.Text = "Subpixel Motion Estimation:";\r
+            // \r
+            // drop_subpixelMotionEstimation\r
+            // \r
+            this.drop_subpixelMotionEstimation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_subpixelMotionEstimation.FormattingEnabled = true;\r
+            this.drop_subpixelMotionEstimation.Items.AddRange(new object[] {\r
+            "Default (7)",\r
+            "0",\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6",\r
+            "7",\r
+            "8",\r
+            "9"});\r
+            this.drop_subpixelMotionEstimation.Location = new System.Drawing.Point(423, 42);\r
+            this.drop_subpixelMotionEstimation.Name = "drop_subpixelMotionEstimation";\r
+            this.drop_subpixelMotionEstimation.Size = new System.Drawing.Size(139, 21);\r
+            this.drop_subpixelMotionEstimation.TabIndex = 70;\r
+            this.ToolTip.SetToolTip(this.drop_subpixelMotionEstimation, resources.GetString("drop_subpixelMotionEstimation.ToolTip"));\r
+            this.drop_subpixelMotionEstimation.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // lbl_merange\r
+            // \r
+            this.lbl_merange.AutoSize = true;\r
+            this.lbl_merange.Location = new System.Drawing.Point(288, 71);\r
+            this.lbl_merange.Name = "lbl_merange";\r
+            this.lbl_merange.Size = new System.Drawing.Size(129, 13);\r
+            this.lbl_merange.TabIndex = 61;\r
+            this.lbl_merange.Text = "Motion Estimation Range:";\r
+            // \r
+            // drop_MotionEstimationRange\r
+            // \r
+            this.drop_MotionEstimationRange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_MotionEstimationRange.FormattingEnabled = true;\r
+            this.drop_MotionEstimationRange.Items.AddRange(new object[] {\r
+            "Default (16)",\r
+            "4",\r
+            "5",\r
+            "6",\r
+            "7",\r
+            "8",\r
+            "9",\r
+            "10",\r
+            "11",\r
+            "12",\r
+            "13",\r
+            "14",\r
+            "15",\r
+            "16",\r
+            "17",\r
+            "18",\r
+            "19",\r
+            "20",\r
+            "21",\r
+            "22",\r
+            "23",\r
+            "24",\r
+            "25",\r
+            "26",\r
+            "27",\r
+            "28",\r
+            "29",\r
+            "30",\r
+            "31",\r
+            "32",\r
+            "33",\r
+            "34",\r
+            "35",\r
+            "36",\r
+            "37",\r
+            "38",\r
+            "39",\r
+            "40",\r
+            "41",\r
+            "42",\r
+            "43",\r
+            "44",\r
+            "45",\r
+            "46",\r
+            "47",\r
+            "48",\r
+            "49",\r
+            "50",\r
+            "51",\r
+            "52",\r
+            "53",\r
+            "54",\r
+            "55",\r
+            "56",\r
+            "57",\r
+            "58",\r
+            "59",\r
+            "60",\r
+            "61",\r
+            "62",\r
+            "63",\r
+            "64"});\r
+            this.drop_MotionEstimationRange.Location = new System.Drawing.Point(423, 68);\r
+            this.drop_MotionEstimationRange.Name = "drop_MotionEstimationRange";\r
+            this.drop_MotionEstimationRange.Size = new System.Drawing.Size(139, 21);\r
+            this.drop_MotionEstimationRange.TabIndex = 69;\r
+            this.ToolTip.SetToolTip(this.drop_MotionEstimationRange, resources.GetString("drop_MotionEstimationRange.ToolTip"));\r
+            this.drop_MotionEstimationRange.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label54\r
+            // \r
+            this.label54.AutoSize = true;\r
+            this.label54.Location = new System.Drawing.Point(283, 19);\r
+            this.label54.Name = "label54";\r
+            this.label54.Size = new System.Drawing.Size(134, 13);\r
+            this.label54.TabIndex = 60;\r
+            this.label54.Text = "Motion Estimation Method:";\r
+            // \r
+            // drop_MotionEstimationMethod\r
+            // \r
+            this.drop_MotionEstimationMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_MotionEstimationMethod.FormattingEnabled = true;\r
+            this.drop_MotionEstimationMethod.ItemHeight = 13;\r
+            this.drop_MotionEstimationMethod.Items.AddRange(new object[] {\r
+            "Default (Hexagon)",\r
+            "Diamond",\r
+            "Hexagon",\r
+            "Uneven Multi-Hexagon",\r
+            "Exhaustive",\r
+            "Transformed Exhaustive"});\r
+            this.drop_MotionEstimationMethod.Location = new System.Drawing.Point(423, 16);\r
+            this.drop_MotionEstimationMethod.Name = "drop_MotionEstimationMethod";\r
+            this.drop_MotionEstimationMethod.Size = new System.Drawing.Size(139, 21);\r
+            this.drop_MotionEstimationMethod.TabIndex = 68;\r
+            this.ToolTip.SetToolTip(this.drop_MotionEstimationMethod, resources.GetString("drop_MotionEstimationMethod.ToolTip"));\r
+            this.drop_MotionEstimationMethod.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // check_pyrmidalBFrames\r
+            // \r
+            this.check_pyrmidalBFrames.AutoSize = true;\r
+            this.check_pyrmidalBFrames.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_pyrmidalBFrames.Location = new System.Drawing.Point(17, 194);\r
+            this.check_pyrmidalBFrames.Name = "check_pyrmidalBFrames";\r
+            this.check_pyrmidalBFrames.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_pyrmidalBFrames.Size = new System.Drawing.Size(124, 17);\r
+            this.check_pyrmidalBFrames.TabIndex = 59;\r
+            this.check_pyrmidalBFrames.Text = "Pyramidal B-Frames:";\r
+            this.ToolTip.SetToolTip(this.check_pyrmidalBFrames, resources.GetString("check_pyrmidalBFrames.ToolTip"));\r
+            this.check_pyrmidalBFrames.UseVisualStyleBackColor = true;\r
+            this.check_pyrmidalBFrames.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // check_weightedBFrames\r
+            // \r
+            this.check_weightedBFrames.AutoSize = true;\r
+            this.check_weightedBFrames.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_weightedBFrames.Location = new System.Drawing.Point(17, 173);\r
+            this.check_weightedBFrames.Name = "check_weightedBFrames";\r
+            this.check_weightedBFrames.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_weightedBFrames.Size = new System.Drawing.Size(124, 17);\r
+            this.check_weightedBFrames.TabIndex = 58;\r
+            this.check_weightedBFrames.Text = "Weighted B-Frames:";\r
+            this.ToolTip.SetToolTip(this.check_weightedBFrames, resources.GetString("check_weightedBFrames.ToolTip"));\r
+            this.check_weightedBFrames.UseVisualStyleBackColor = true;\r
+            this.check_weightedBFrames.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // lbl_direct_prediction\r
+            // \r
+            this.lbl_direct_prediction.AutoSize = true;\r
+            this.lbl_direct_prediction.Location = new System.Drawing.Point(34, 150);\r
+            this.lbl_direct_prediction.Name = "lbl_direct_prediction";\r
+            this.lbl_direct_prediction.Size = new System.Drawing.Size(89, 13);\r
+            this.lbl_direct_prediction.TabIndex = 53;\r
+            this.lbl_direct_prediction.Text = "Direct Prediction:";\r
+            // \r
+            // drop_directPrediction\r
+            // \r
+            this.drop_directPrediction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_directPrediction.FormattingEnabled = true;\r
+            this.drop_directPrediction.Items.AddRange(new object[] {\r
+            "Default (Spatial)",\r
+            "None",\r
+            "Spatial",\r
+            "Temporal",\r
+            "Automatic"});\r
+            this.drop_directPrediction.Location = new System.Drawing.Point(129, 147);\r
+            this.drop_directPrediction.Name = "drop_directPrediction";\r
+            this.drop_directPrediction.Size = new System.Drawing.Size(121, 21);\r
+            this.drop_directPrediction.TabIndex = 57;\r
+            this.ToolTip.SetToolTip(this.drop_directPrediction, resources.GetString("drop_directPrediction.ToolTip"));\r
+            this.drop_directPrediction.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label62\r
+            // \r
+            this.label62.AutoSize = true;\r
+            this.label62.Location = new System.Drawing.Point(67, 98);\r
+            this.label62.Name = "label62";\r
+            this.label62.Size = new System.Drawing.Size(56, 13);\r
+            this.label62.TabIndex = 52;\r
+            this.label62.Text = "B-Frames:";\r
+            // \r
+            // drop_bFrames\r
+            // \r
+            this.drop_bFrames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_bFrames.FormattingEnabled = true;\r
+            this.drop_bFrames.Items.AddRange(new object[] {\r
+            "Default (3)",\r
+            "0",\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6",\r
+            "7",\r
+            "8",\r
+            "9",\r
+            "10",\r
+            "11",\r
+            "12",\r
+            "13",\r
+            "14",\r
+            "15",\r
+            "16"});\r
+            this.drop_bFrames.Location = new System.Drawing.Point(129, 95);\r
+            this.drop_bFrames.Name = "drop_bFrames";\r
+            this.drop_bFrames.Size = new System.Drawing.Size(121, 21);\r
+            this.drop_bFrames.TabIndex = 56;\r
+            this.ToolTip.SetToolTip(this.drop_bFrames, "Sane values are 1-6. \r\nB-Frames are smaller than other frames, so they let you pa" +\r
+                    "ck in more quality at the same bitrate. \r\nUse more of them with animated materia" +\r
+                    "l.");\r
+            this.drop_bFrames.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // label64\r
+            // \r
+            this.label64.AutoSize = true;\r
+            this.label64.Location = new System.Drawing.Point(24, 45);\r
+            this.label64.Name = "label64";\r
+            this.label64.Size = new System.Drawing.Size(99, 13);\r
+            this.label64.TabIndex = 50;\r
+            this.label64.Text = "Reference Frames:";\r
+            // \r
+            // drop_refFrames\r
+            // \r
+            this.drop_refFrames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_refFrames.FormattingEnabled = true;\r
+            this.drop_refFrames.Items.AddRange(new object[] {\r
+            "Default (3)",\r
+            "0",\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6",\r
+            "7",\r
+            "8",\r
+            "9",\r
+            "10",\r
+            "11",\r
+            "12",\r
+            "13",\r
+            "14",\r
+            "15",\r
+            "16"});\r
+            this.drop_refFrames.Location = new System.Drawing.Point(129, 42);\r
+            this.drop_refFrames.Name = "drop_refFrames";\r
+            this.drop_refFrames.Size = new System.Drawing.Size(121, 21);\r
+            this.drop_refFrames.TabIndex = 54;\r
+            this.ToolTip.SetToolTip(this.drop_refFrames, "Sane values are 1-6. \r\nThe more you add, the higher the quality, but the slower t" +\r
+                    "he encode. Be careful... too many and QuickTime struggles to play the video back" +\r
+                    ".");\r
+            this.drop_refFrames.SelectedIndexChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // check_mixedReferences\r
+            // \r
+            this.check_mixedReferences.AutoSize = true;\r
+            this.check_mixedReferences.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.check_mixedReferences.Location = new System.Drawing.Point(25, 68);\r
+            this.check_mixedReferences.Name = "check_mixedReferences";\r
+            this.check_mixedReferences.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
+            this.check_mixedReferences.Size = new System.Drawing.Size(116, 17);\r
+            this.check_mixedReferences.TabIndex = 55;\r
+            this.check_mixedReferences.Text = "Mixed References:";\r
+            this.check_mixedReferences.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
+            this.ToolTip.SetToolTip(this.check_mixedReferences, "With this on, different references can be used for different parts of each 16x16 " +\r
+                    "pixel macroblock, increasing quality.");\r
+            this.check_mixedReferences.UseVisualStyleBackColor = true;\r
+            this.check_mixedReferences.CheckedChanged += new System.EventHandler(this.widgetControlChanged);\r
+            // \r
+            // ToolTip\r
+            // \r
+            this.ToolTip.Active = false;\r
+            this.ToolTip.AutomaticDelay = 1000;\r
+            this.ToolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;\r
+            // \r
+            // x264Panel\r
+            // \r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
+            this.BackColor = System.Drawing.Color.Transparent;\r
+            this.Controls.Add(this.slider_psytrellis);\r
+            this.Controls.Add(this.lbl_psytrellis);\r
+            this.Controls.Add(this.lbl_psyrd);\r
+            this.Controls.Add(this.slider_psyrd);\r
+            this.Controls.Add(this.lbl_adaptBFrames);\r
+            this.Controls.Add(this.drop_adaptBFrames);\r
+            this.Controls.Add(this.label43);\r
+            this.Controls.Add(this.btn_reset);\r
+            this.Controls.Add(this.rtf_x264Query);\r
+            this.Controls.Add(this.check_Cabac);\r
+            this.Controls.Add(this.check_noDCTDecimate);\r
+            this.Controls.Add(this.check_noFastPSkip);\r
+            this.Controls.Add(this.lbl_trellis);\r
+            this.Controls.Add(this.drop_trellis);\r
+            this.Controls.Add(this.drop_deblockBeta);\r
+            this.Controls.Add(this.label41);\r
+            this.Controls.Add(this.drop_deblockAlpha);\r
+            this.Controls.Add(this.panel3);\r
+            this.Controls.Add(this.panel1);\r
+            this.Controls.Add(this.panel2);\r
+            this.Controls.Add(this.check_8x8DCT);\r
+            this.Controls.Add(this.label45);\r
+            this.Controls.Add(this.drop_analysis);\r
+            this.Controls.Add(this.label48);\r
+            this.Controls.Add(this.drop_subpixelMotionEstimation);\r
+            this.Controls.Add(this.lbl_merange);\r
+            this.Controls.Add(this.drop_MotionEstimationRange);\r
+            this.Controls.Add(this.label54);\r
+            this.Controls.Add(this.drop_MotionEstimationMethod);\r
+            this.Controls.Add(this.check_pyrmidalBFrames);\r
+            this.Controls.Add(this.check_weightedBFrames);\r
+            this.Controls.Add(this.lbl_direct_prediction);\r
+            this.Controls.Add(this.drop_directPrediction);\r
+            this.Controls.Add(this.label62);\r
+            this.Controls.Add(this.drop_bFrames);\r
+            this.Controls.Add(this.label64);\r
+            this.Controls.Add(this.drop_refFrames);\r
+            this.Controls.Add(this.check_mixedReferences);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Name = "x264Panel";\r
+            this.Size = new System.Drawing.Size(720, 306);\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_psytrellis)).EndInit();\r
+            ((System.ComponentModel.ISupportInitialize)(this.slider_psyrd)).EndInit();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        internal System.Windows.Forms.TrackBar slider_psytrellis;\r
+        internal System.Windows.Forms.Label lbl_psytrellis;\r
+        internal System.Windows.Forms.Label lbl_psyrd;\r
+        internal System.Windows.Forms.TrackBar slider_psyrd;\r
+        internal System.Windows.Forms.Label lbl_adaptBFrames;\r
+        internal System.Windows.Forms.ComboBox drop_adaptBFrames;\r
+        internal System.Windows.Forms.Label label43;\r
+        internal System.Windows.Forms.Button btn_reset;\r
+        internal System.Windows.Forms.RichTextBox rtf_x264Query;\r
+        internal System.Windows.Forms.CheckBox check_Cabac;\r
+        internal System.Windows.Forms.CheckBox check_noDCTDecimate;\r
+        internal System.Windows.Forms.CheckBox check_noFastPSkip;\r
+        internal System.Windows.Forms.Label lbl_trellis;\r
+        internal System.Windows.Forms.ComboBox drop_trellis;\r
+        internal System.Windows.Forms.ComboBox drop_deblockBeta;\r
+        internal System.Windows.Forms.Label label41;\r
+        internal System.Windows.Forms.ComboBox drop_deblockAlpha;\r
+        internal System.Windows.Forms.Panel panel3;\r
+        internal System.Windows.Forms.Panel panel1;\r
+        internal System.Windows.Forms.Panel panel2;\r
+        internal System.Windows.Forms.CheckBox check_8x8DCT;\r
+        internal System.Windows.Forms.Label label45;\r
+        internal System.Windows.Forms.ComboBox drop_analysis;\r
+        internal System.Windows.Forms.Label label48;\r
+        internal System.Windows.Forms.ComboBox drop_subpixelMotionEstimation;\r
+        internal System.Windows.Forms.Label lbl_merange;\r
+        internal System.Windows.Forms.ComboBox drop_MotionEstimationRange;\r
+        internal System.Windows.Forms.Label label54;\r
+        internal System.Windows.Forms.ComboBox drop_MotionEstimationMethod;\r
+        internal System.Windows.Forms.CheckBox check_pyrmidalBFrames;\r
+        internal System.Windows.Forms.CheckBox check_weightedBFrames;\r
+        internal System.Windows.Forms.Label lbl_direct_prediction;\r
+        internal System.Windows.Forms.ComboBox drop_directPrediction;\r
+        internal System.Windows.Forms.Label label62;\r
+        internal System.Windows.Forms.ComboBox drop_bFrames;\r
+        internal System.Windows.Forms.Label label64;\r
+        internal System.Windows.Forms.ComboBox drop_refFrames;\r
+        internal System.Windows.Forms.CheckBox check_mixedReferences;\r
+        private System.Windows.Forms.ToolTip ToolTip;\r
+    }\r
+}\r
diff --git a/win/C#/Controls/x264Panel.cs b/win/C#/Controls/x264Panel.cs
new file mode 100644 (file)
index 0000000..4229c82
--- /dev/null
@@ -0,0 +1,1002 @@
+/*  x264Panel.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace Handbrake.Controls\r
+{\r
+    public partial class x264Panel : UserControl\r
+    {\r
+        public x264Panel()\r
+        {\r
+            InitializeComponent();\r
+\r
+            if (Properties.Settings.Default.tooltipEnable)\r
+                ToolTip.Active = true;\r
+\r
+            reset2Defaults();\r
+        }\r
+\r
+        public string x264Query\r
+        {\r
+            get { return rtf_x264Query.Text; }\r
+            set { rtf_x264Query.Text = value; }\r
+        }\r
+\r
+        private void widgetControlChanged(object sender, EventArgs e)\r
+        {\r
+            Control changedControlName = (Control) sender;\r
+            string controlName = "";\r
+\r
+            switch (changedControlName.Name.Trim())\r
+            {\r
+                case "drop_refFrames":\r
+                    controlName = "ref";\r
+                    break;\r
+                case "check_mixedReferences":\r
+                    controlName = "mixed-refs";\r
+                    break;\r
+                case "drop_bFrames":\r
+                    controlName = "bframes";\r
+                    break;\r
+                case "drop_directPrediction":\r
+                    controlName = "direct";\r
+                    break;\r
+                case "check_weightedBFrames":\r
+                    controlName = "weightb";\r
+                    break;\r
+                case "check_pyrmidalBFrames":\r
+                    controlName = "b-pyramid";\r
+                    break;\r
+                case "drop_MotionEstimationMethod":\r
+                    controlName = "me";\r
+                    break;\r
+                case "drop_MotionEstimationRange":\r
+                    controlName = "merange";\r
+                    break;\r
+                case "drop_subpixelMotionEstimation":\r
+                    controlName = "subq";\r
+                    break;\r
+                case "drop_analysis":\r
+                    controlName = "analyse";\r
+                    break;\r
+                case "check_8x8DCT":\r
+                    controlName = "8x8dct";\r
+                    break;\r
+                case "drop_deblockAlpha":\r
+                    controlName = "deblock";\r
+                    break;\r
+                case "drop_deblockBeta":\r
+                    controlName = "deblock";\r
+                    break;\r
+                case "drop_trellis":\r
+                    controlName = "trellis";\r
+                    break;\r
+                case "check_noFastPSkip":\r
+                    controlName = "no-fast-pskip";\r
+                    break;\r
+                case "check_noDCTDecimate":\r
+                    controlName = "no-dct-decimate";\r
+                    break;\r
+                case "check_Cabac":\r
+                    controlName = "cabac";\r
+                    break;\r
+                case "slider_psyrd":\r
+                    controlName = "psy-rd";\r
+                    break;\r
+                case "slider_psytrellis":\r
+                    controlName = "psy-rd";\r
+                    break;\r
+                case "drop_adaptBFrames":\r
+                    controlName = "b-adapt";\r
+                    break;\r
+            }\r
+            on_x264_WidgetChange(controlName);\r
+        }\r
+        private void rtf_x264Query_TextChanged(object sender, EventArgs e)\r
+        {\r
+            if (rtf_x264Query.Text.EndsWith("\n"))\r
+            {\r
+                string query = rtf_x264Query.Text.Replace("\n", "");\r
+                reset2Defaults();\r
+                rtf_x264Query.Text = query;\r
+                X264_StandardizeOptString();\r
+                X264_SetCurrentSettingsInPanel();\r
+\r
+                if (rtf_x264Query.Text == string.Empty)\r
+                    reset2Defaults();\r
+            }\r
+        }\r
+        private void btn_reset_Click(object sender, EventArgs e)\r
+        {\r
+            rtf_x264Query.Text = "";\r
+            reset2Defaults();\r
+        }\r
+        \r
+        /// <summary>\r
+        /// Reset all components to defaults and clears the x264 rtf box\r
+        /// </summary>\r
+        public void reset2Defaults()\r
+        {\r
+            check_8x8DCT.CheckState = CheckState.Checked;\r
+            check_Cabac.CheckState = CheckState.Checked;\r
+            check_mixedReferences.CheckState = CheckState.Checked;\r
+            check_noDCTDecimate.CheckState = CheckState.Unchecked;\r
+            check_noFastPSkip.CheckState = CheckState.Unchecked;\r
+            check_pyrmidalBFrames.CheckState = CheckState.Unchecked;\r
+            check_weightedBFrames.CheckState = CheckState.Checked;\r
+            drop_analysis.SelectedIndex = 0;\r
+            drop_bFrames.SelectedIndex = 0;\r
+            drop_deblockAlpha.SelectedIndex = 0;\r
+            drop_deblockBeta.SelectedIndex = 0;\r
+            drop_directPrediction.SelectedIndex = 0;\r
+            drop_MotionEstimationMethod.SelectedIndex = 0;\r
+            drop_MotionEstimationRange.SelectedIndex = 0;\r
+            drop_refFrames.SelectedIndex = 0;\r
+            drop_subpixelMotionEstimation.SelectedIndex = 0;\r
+            drop_trellis.SelectedIndex = 0;\r
+            slider_psyrd.Value = 10;\r
+            slider_psytrellis.Value = 0;\r
+            drop_adaptBFrames.SelectedIndex = 0;\r
+\r
+            rtf_x264Query.Text = "";\r
+        }\r
+\r
+        /// <summary>\r
+        /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box\r
+        /// </summary>\r
+        public void X264_StandardizeOptString()\r
+        {\r
+            /* Set widgets depending on the opt string in field */\r
+            String thisOpt; // The separated option such as "bframes=3"\r
+            String optName; // The option name such as "bframes"\r
+            String optValue;// The option value such as "3"\r
+            String changedOptString = "";\r
+            String[] currentOptsArray;\r
+\r
+            /*First, we get an opt string to process */\r
+            String currentOptString = rtf_x264Query.Text;\r
+\r
+            /*verify there is an opt string to process */\r
+            if (currentOptString.Contains("="))\r
+            {\r
+                /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+                currentOptsArray = currentOptString.Split(':');\r
+\r
+                /*iterate through the array and get <opts> and <values*/\r
+                int loopcounter;\r
+                int currentOptsArrayCount = currentOptsArray.Length;\r
+                for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)\r
+                {\r
+                    thisOpt = currentOptsArray[loopcounter];\r
+                    if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)\r
+                        break;\r
+\r
+                    String[] splitOptRange = thisOpt.Split('=');\r
+                    if (thisOpt != "")\r
+                    {\r
+                        if (thisOpt.Contains("="))\r
+                        {\r
+                            optName = splitOptRange[0];\r
+                            optValue = splitOptRange[1];\r
+\r
+                            /* Standardize the names here depending on whats in the string */\r
+                            optName = X264_StandardizeOptNames(optName);\r
+                            thisOpt = optName + "=" + optValue;\r
+                        }\r
+                        else // No value given so we use a default of "1"\r
+                        {\r
+                            optName = thisOpt;\r
+                            /* Standardize the names here depending on whats in the string */\r
+                            optName = X264_StandardizeOptNames(optName);\r
+                            thisOpt = optName + "=1";\r
+                        }\r
+                    }\r
+\r
+                    /* Construct New String for opts here */\r
+                    if (thisOpt == string.Empty)\r
+                        changedOptString = changedOptString + thisOpt;\r
+                    else\r
+                    {\r
+                        if (changedOptString == string.Empty)\r
+                            changedOptString = thisOpt;\r
+                        else\r
+                            changedOptString = changedOptString + ":" + thisOpt;\r
+                    }\r
+                }\r
+            }\r
+\r
+            /* Change the option string to reflect the new standardized option string */\r
+            if (changedOptString != "")\r
+                rtf_x264Query.Text = changedOptString;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Take a single option and standardize it. Returns as a String\r
+        /// Input: String. - Single X264 Option. Name only\r
+        /// Output: String - Single X264 Option. Name only. Changed to standard format\r
+        /// </summary>\r
+        /// <param name="cleanOptNameString"></param>\r
+        /// <returns></returns>\r
+        private static string X264_StandardizeOptNames(String cleanOptNameString)\r
+        {\r
+            String input = cleanOptNameString;\r
+\r
+            if (input.Equals("ref") || input.Equals("frameref"))\r
+                cleanOptNameString = "ref";\r
+\r
+            /*No Fast PSkip nofast_pskip*/\r
+            if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))\r
+                cleanOptNameString = "no-fast-pskip";\r
+\r
+            /*No Dict Decimate*/\r
+            if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))\r
+                cleanOptNameString = "no-dct-decimate";\r
+\r
+            /*Subme*/\r
+            if (input.Equals("subme"))\r
+                cleanOptNameString = "subq";\r
+\r
+            /*ME Range*/\r
+            if (input.Equals("me-range") || input.Equals("me_range"))\r
+                cleanOptNameString = "merange";\r
+\r
+            /*WeightB*/\r
+            if (input.Equals("weight-b") || input.Equals("weight_b"))\r
+                cleanOptNameString = "weightb";\r
+\r
+            /*B Pyramid*/\r
+            if (input.Equals("b_pyramid"))\r
+                cleanOptNameString = "b-pyramid";\r
+\r
+            /*Direct Prediction*/\r
+            if (input.Equals("direct-pred") || input.Equals("direct_pred"))\r
+                cleanOptNameString = "direct";\r
+\r
+            /*Deblocking*/\r
+            if (input.Equals("filter"))\r
+                cleanOptNameString = "deblock";\r
+\r
+            /*Analysis*/\r
+            if (input.Equals("partitions"))\r
+                cleanOptNameString = "analyse";\r
+\r
+            return cleanOptNameString;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Resets the GUI widgets to the contents of the option string.\r
+        /// </summary>\r
+        public void X264_SetCurrentSettingsInPanel()\r
+        {\r
+            /* Set widgets depending on the opt string in field */\r
+            String thisOpt; // The separated option such as "bframes=3"\r
+            String optName; // The option name such as "bframes"\r
+            String optValue;// The option value such as "3"\r
+            String[] currentOptsArray;\r
+\r
+            //Set currentOptString to the contents of the text box.\r
+            String currentOptString = rtf_x264Query.Text.Replace("\n", "");\r
+\r
+            /*verify there is an opt string to process */\r
+            if (currentOptString.Contains("="))\r
+            {\r
+                /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+                currentOptsArray = currentOptString.Split(':');\r
+\r
+                /*iterate through the array and get <opts> and <values*/\r
+                int loopcounter;\r
+                int currentOptsArrayCount = currentOptsArray.Length;\r
+\r
+                /*iterate through the array and get <opts> and <values*/\r
+                for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)\r
+                {\r
+                    thisOpt = currentOptsArray[loopcounter];\r
+                    String[] splitOptRange = thisOpt.Split('=');\r
+\r
+                    if (thisOpt.Contains("="))\r
+                    {\r
+                        optName = splitOptRange[0];\r
+                        optValue = splitOptRange[1];\r
+\r
+                        /*Run through the available widgets for x264 opts and set them, as you add widgets, \r
+                            they need to be added here. This should be moved to its own method probably*/\r
+                        switch (optName)\r
+                        {\r
+                            case "bframes":\r
+                                drop_bFrames.SelectedItem = optValue;\r
+                                continue;\r
+                            case "ref":\r
+                                drop_refFrames.SelectedItem = optValue;\r
+                                continue;\r
+                            case "no-fast-pskip":\r
+                                check_noFastPSkip.CheckState = CheckState.Checked;\r
+                                continue;\r
+                            case "no-dct-decimate":\r
+                                check_noDCTDecimate.CheckState = CheckState.Checked;\r
+                                continue;\r
+                            case "subq":\r
+                                drop_subpixelMotionEstimation.SelectedItem = optValue;\r
+                                continue;\r
+                            case "trellis":\r
+                                drop_trellis.SelectedItem = optValue;\r
+                                continue;\r
+                            case "mixed-refs":\r
+                                check_mixedReferences.CheckState = CheckState.Checked;\r
+                                continue;\r
+                            case "me":\r
+                                if (optValue.Equals("dia"))\r
+                                    drop_MotionEstimationMethod.SelectedItem = "Diamond";\r
+                                else if (optValue.Equals("hex"))\r
+                                    drop_MotionEstimationMethod.SelectedItem = "Hexagon";\r
+                                else if (optValue.Equals("umh"))\r
+                                    drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";\r
+                                else if (optValue.Equals("esa"))\r
+                                    drop_MotionEstimationMethod.SelectedItem = "Exhaustive";\r
+                                else if (optValue.Equals("tesa"))\r
+                                    drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";\r
+                                continue;\r
+                            case "merange":\r
+                                drop_MotionEstimationRange.SelectedItem = optValue;\r
+                                continue;\r
+                            case "b-adapt":\r
+                                int badapt;\r
+                                int.TryParse(optValue, out badapt);\r
+                                drop_adaptBFrames.SelectedIndex = (badapt + 1);\r
+                                continue;\r
+                            case "weightb":\r
+                                if (optValue != "0")\r
+                                    check_weightedBFrames.CheckState = CheckState.Checked;\r
+                                else\r
+                                    check_weightedBFrames.CheckState = CheckState.Unchecked;\r
+                                continue;\r
+                            case "b-pyramid":\r
+                                check_pyrmidalBFrames.CheckState = CheckState.Checked;\r
+                                continue;\r
+                            case "direct":\r
+                                if (optValue == "auto")\r
+                                    optValue = "Automatic";\r
+\r
+                                if (optValue != "")\r
+                                {\r
+                                    Char[] letters = optValue.ToCharArray();\r
+                                    letters[0] = Char.ToUpper(letters[0]);\r
+                                    optValue = new string(letters);\r
+                                }\r
+\r
+                                drop_directPrediction.SelectedItem = optValue;\r
+                                continue;\r
+                            case "deblock":\r
+                                string[] splitDeblock = optValue.Split(',');\r
+                                string alphaDeblock = splitDeblock[0];\r
+                                string betaDeblock = splitDeblock[1];\r
+\r
+                                if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))\r
+                                {\r
+                                    drop_deblockAlpha.SelectedItem = "Default (0)";\r
+                                    drop_deblockBeta.SelectedItem = "Default (0)";\r
+                                }\r
+                                else\r
+                                {\r
+                                    drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";\r
+\r
+                                    drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", "").Equals("0") ? betaDeblock.Replace("\n", "") : "0";\r
+                                }\r
+                                continue;\r
+                            case "analyse":\r
+                                if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))\r
+                                    drop_analysis.SelectedItem = "Default (some)";\r
+                                if (optValue.Equals("none"))\r
+                                    drop_analysis.SelectedItem = "None";\r
+                                if (optValue.Equals("all"))\r
+                                    drop_analysis.SelectedItem = "All";\r
+                                continue;\r
+                            case "8x8dct":\r
+                                check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;\r
+                                continue;\r
+                            case "cabac":\r
+                                check_Cabac.CheckState = CheckState.Unchecked;\r
+                                continue;\r
+                            case "psy-rd":\r
+                                string[] x = optValue.Split(',');\r
+\r
+                                double psyrd, psytrellis;\r
+                                int val, val2;\r
+\r
+                                // default psy-rd = 1 (10 for the slider)\r
+                                psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;\r
+                                // default psy-trellis = 0\r
+                                psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 10 : 0.0; \r
+\r
+                                int.TryParse(psyrd.ToString(), out val);\r
+                                int.TryParse(psytrellis.ToString(), out val2);\r
+\r
+                                slider_psyrd.Value = val;\r
+                                slider_psytrellis.Value = val2;\r
+                                continue;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// This function will update the X264 Query when one of the GUI widgets changes.\r
+        /// </summary>\r
+        private void on_x264_WidgetChange(string sender)\r
+        {\r
+            animate(sender);\r
+            String optNameToChange = sender;\r
+            String currentOptString = rtf_x264Query.Text;\r
+\r
+            /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after\r
+                the first character of the opt string (hence the ":") */\r
+            String checkOptNameToChange = ":" + optNameToChange + "=";\r
+            String checkOptNameToChangeBegin = optNameToChange + "=";\r
+\r
+            // IF the current H264 Option String Contains Multiple Items or Just 1 Item\r
+            if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))\r
+                hasOptions(currentOptString, optNameToChange);\r
+            else // IF there is no options in the rich text box!\r
+                hasNoOptions(optNameToChange);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :\r
+        /// it updates the current option that the widget corrosponds to, if it is already in thes string.\r
+        /// </summary>\r
+        /// <param name="currentOptString"></param>\r
+        /// <param name="optNameToChange"></param>\r
+        private void hasOptions(string currentOptString, string optNameToChange)\r
+        {\r
+            String thisOpt;             // The separated option such as "bframes=3"\r
+            String optName;        // The option name such as "bframes"\r
+            String[] currentOptsArray;\r
+\r
+            /* Create new empty opt string*/\r
+            String changedOptString = "";\r
+\r
+            /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+            currentOptsArray = currentOptString.Split(':');\r
+\r
+            /*iterate through the array and get <opts> and <values*/\r
+            for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)\r
+            {\r
+                thisOpt = currentOptsArray[loopcounter];\r
+\r
+                if (thisOpt.Contains("="))\r
+                {\r
+                    string[] splitOptRange = thisOpt.Split('=');\r
+\r
+                    optName = splitOptRange[0];     // e.g bframes\r
+\r
+                    /* \r
+                     * Run through the available widgets for x264 opts and set them, as you add widgets,\r
+                     * they need to be added here. This should be moved to its own method probably\r
+                     * If the optNameToChange is found, appropriately change the value or delete it if\r
+                     * "unspecified" is set.\r
+                     */\r
+                    if (optName.Equals(optNameToChange))\r
+                    {\r
+                        if (optNameToChange.Equals("deblock"))\r
+                        {\r
+                            String da = drop_deblockAlpha.SelectedItem.ToString();\r
+                            String db = drop_deblockBeta.SelectedItem.ToString();\r
+\r
+                            if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
+                            {\r
+                                drop_deblockBeta.SelectedItem = "Default (0)";\r
+                                drop_deblockAlpha.SelectedItem = "Default (0)";\r
+                                thisOpt = "";\r
+                            }\r
+                            else if ((!da.Contains("Default")) && (db.Contains("Default")))\r
+                            {\r
+                                drop_deblockBeta.SelectedItem = "0";\r
+                                thisOpt = "deblock=" + da + ",0";\r
+                            }\r
+                            else if ((da.Contains("Default")) && (!db.Contains("Default")))\r
+                            {\r
+                                drop_deblockAlpha.SelectedItem = "0";\r
+                                thisOpt = "deblock=0," + db;\r
+                            }\r
+                            else if ((!da.Contains("Default")) && (!db.Contains("Default")))\r
+                                thisOpt = "deblock=" + da + "," + db;\r
+                        }\r
+                        else if (optNameToChange.Equals("psy-rd"))\r
+                        {\r
+                            if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)\r
+                                thisOpt = "";\r
+                            else\r
+                            {\r
+                                double psyrd = slider_psyrd.Value * 0.1;\r
+                                double psytre = slider_psytrellis.Value * 0.1;\r
+\r
+                                string rd = psyrd.ToString("f1");\r
+                                string rt = psytre.ToString("f1");\r
+\r
+                                thisOpt = "psy-rd=" + rd + "," + rt;\r
+                            }\r
+                        }\r
+                        else if (optNameToChange.Equals("mixed-refs"))\r
+                            thisOpt = check_mixedReferences.CheckState == CheckState.Checked ? "mixed-refs=1" : "mixed-refs=0";\r
+                        else if (optNameToChange.Equals("weightb"))\r
+                            thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? "" : "weightb=0";\r
+                        else if (optNameToChange.Equals("b-pyramid"))\r
+                            thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : "";\r
+                        else if (optNameToChange.Equals("no-fast-pskip"))\r
+                            thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : "";\r
+                        else if (optNameToChange.Equals("no-dct-decimate"))\r
+                            thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : "";\r
+                        else if (optNameToChange.Equals("8x8dct"))\r
+                            thisOpt = check_8x8DCT.CheckState == CheckState.Checked ? "8x8dct=1" : "8x8dct=0";\r
+                        else if (optNameToChange.Equals("cabac"))\r
+                            thisOpt = check_Cabac.CheckState == CheckState.Checked ? "" : "cabac=0";\r
+                        else if (optNameToChange.Equals("me"))\r
+                        {\r
+                            switch (drop_MotionEstimationMethod.SelectedIndex)\r
+                            {\r
+                                case 1:\r
+                                    thisOpt = "me=dia";\r
+                                    break;\r
+\r
+                                case 2:\r
+                                    thisOpt = "me=hex";\r
+                                    break;\r
+\r
+                                case 3:\r
+                                    thisOpt = "me=umh";\r
+                                    break;\r
+\r
+                                case 4:\r
+                                    thisOpt = "me=esa";\r
+                                    break;\r
+\r
+                                case 5:\r
+                                    thisOpt = "me=tesa";\r
+                                    break;\r
+\r
+                                default:\r
+                                    thisOpt = "";\r
+                                    break;\r
+                            }\r
+                        }\r
+                        else if (optNameToChange.Equals("direct"))\r
+                        {\r
+                            switch (drop_directPrediction.SelectedIndex)\r
+                            {\r
+                                case 1:\r
+                                    thisOpt = "direct=none";\r
+                                    break;\r
+\r
+                                case 2:\r
+                                    thisOpt = "direct=spatial";\r
+                                    break;\r
+\r
+                                case 3:\r
+                                    thisOpt = "direct=temporal";\r
+                                    break;\r
+\r
+                                case 4:\r
+                                    thisOpt = "direct=auto";\r
+                                    break;\r
+\r
+                                default:\r
+                                    thisOpt = "";\r
+                                    break;\r
+                            }\r
+                        }\r
+                        else if (optNameToChange.Equals("analyse"))\r
+                        {\r
+                            switch (drop_analysis.SelectedIndex)\r
+                            {\r
+                                case 1:\r
+                                    thisOpt = "analyse=none";\r
+                                    break;\r
+\r
+                                case 2:\r
+                                    thisOpt = "analyse=all";\r
+                                    break;\r
+\r
+                                default:\r
+                                    thisOpt = "";\r
+                                    break;\r
+                            }\r
+                        }\r
+                        else if (optNameToChange.Equals("merange"))\r
+                        {\r
+                            thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")\r
+                                          ? "merange=" + drop_MotionEstimationRange.SelectedItem\r
+                                          : "";\r
+                        }\r
+                        else if (optNameToChange.Equals("b-adapt"))\r
+                        {\r
+                            thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")\r
+                                          ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)\r
+                                          : "";\r
+                        }\r
+                        else if (optNameToChange.Equals("ref"))\r
+                        {\r
+                            thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")\r
+                                          ? "ref=" + drop_refFrames.SelectedItem\r
+                                          : "";\r
+                        }\r
+                        else if (optNameToChange.Equals("bframes"))\r
+                        {\r
+                            String value = drop_bFrames.SelectedItem.ToString();\r
+                            thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")\r
+                                          ? "bframes=" + value\r
+                                          : "";\r
+                        }\r
+                        else if (optNameToChange.Equals("subq"))\r
+                        {\r
+                            String value = drop_subpixelMotionEstimation.SelectedItem.ToString();\r
+                            thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")\r
+                                          ? "subq=" + value\r
+                                          : "";\r
+                        }\r
+                        else if (optNameToChange.Equals("trellis"))\r
+                        {\r
+                            String value = drop_trellis.SelectedItem.ToString();\r
+                            thisOpt = !drop_trellis.SelectedItem.ToString().Contains("Default")\r
+                                          ? "trellis=" + value\r
+                                          : "";\r
+                        }\r
+                    }\r
+                }\r
+\r
+                /* Construct New String for opts here */\r
+                if (!thisOpt.Equals(""))\r
+                    changedOptString = changedOptString.Equals("") ? thisOpt : changedOptString + ":" + thisOpt;\r
+            }\r
+\r
+            /* Change the option string to reflect the new mod settings */\r
+            rtf_x264Query.Text = changedOptString;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Add's an option to the x264 query string.\r
+        /// Handles 2 cases.  1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,\r
+        /// e.g no-fast-pskip\r
+        /// </summary>\r
+        /// <param name="optNameToChange"></param>\r
+        private void hasNoOptions(string optNameToChange)\r
+        {\r
+            string colon = "";\r
+            if (rtf_x264Query.Text != "")\r
+                colon = ":";\r
+\r
+            string query = rtf_x264Query.Text;\r
+            if (optNameToChange.Equals("me"))\r
+            {\r
+                switch (drop_MotionEstimationMethod.SelectedIndex)\r
+                {\r
+                    case 1:\r
+                        query = query + colon + "me=dia";\r
+                        break;\r
+\r
+                    case 2:\r
+                        query = query + colon + "me=hex";\r
+                        break;\r
+\r
+                    case 3:\r
+                        query = query + colon + "me=umh";\r
+                        break;\r
+\r
+                    case 4:\r
+                        query = query + colon + "me=esa";\r
+                        break;\r
+\r
+                    case 5:\r
+                        query = query + colon + "me=tesa";\r
+                        break;\r
+\r
+                    default:\r
+                        break;\r
+                }\r
+            }\r
+            else if (optNameToChange.Equals("direct"))\r
+            {\r
+                switch (drop_directPrediction.SelectedIndex)\r
+                {\r
+                    case 1:\r
+                        query = query + colon + "direct=none";\r
+                        break;\r
+\r
+                    case 2:\r
+                        query = query + colon + "direct=spatial";\r
+                        break;\r
+\r
+                    case 3:\r
+                        query = query + colon + "direct=temporal";\r
+                        break;\r
+\r
+                    case 4:\r
+                        query = query + colon + "direct=auto";\r
+                        break;\r
+\r
+                    default:\r
+                        break;\r
+                }\r
+            }\r
+            else if (optNameToChange.Equals("analyse"))\r
+            {\r
+                switch (drop_analysis.SelectedIndex)\r
+                {\r
+                    case 1:\r
+                        query = query + colon + "analyse=none";\r
+                        break;\r
+\r
+                    case 2:\r
+                        query = query + colon + "analyse=all";\r
+                        break;\r
+\r
+                    default:\r
+                        break;\r
+                }\r
+            }\r
+            else if (optNameToChange.Equals("merange"))\r
+            {\r
+                int value = drop_MotionEstimationRange.SelectedIndex + 3;\r
+                query = query + colon + "merange=" + value;\r
+            }\r
+            else if (optNameToChange.Equals("b-adapt"))\r
+            {\r
+                int value = drop_adaptBFrames.SelectedIndex - 1;\r
+                query = query + colon + "b-adapt=" + value;\r
+            }\r
+\r
+            else if (optNameToChange.Equals("deblock"))\r
+            {\r
+                String da = drop_deblockAlpha.SelectedItem.ToString();\r
+                String db = drop_deblockBeta.Text;\r
+\r
+                if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
+                {\r
+                    drop_deblockBeta.SelectedItem = "Default (0)";\r
+                    drop_deblockAlpha.SelectedItem = "Default (0)";\r
+                }\r
+                else\r
+                {\r
+                    if (db.Contains("Default"))\r
+                        db = "0";\r
+\r
+                    if (da.Contains("Default"))\r
+                        da = "0";\r
+\r
+                    query = query + colon + "deblock=" + da + "," + db;\r
+                }\r
+            }\r
+            else if (optNameToChange.Equals("psy-rd"))\r
+            {\r
+                if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)\r
+                    query += "";\r
+                else\r
+                {\r
+                    double psyrd = slider_psyrd.Value * 0.1;\r
+                    double psytre = slider_psytrellis.Value * 0.1;\r
+\r
+                    string rd = psyrd.ToString("f1");\r
+                    string rt = psytre.ToString("f1");\r
+\r
+                    query += colon + "psy-rd=" + rd + "," + rt;\r
+                }\r
+            }\r
+            else if (optNameToChange.Equals("mixed-refs"))\r
+            {\r
+                if (check_mixedReferences.CheckState == CheckState.Checked)\r
+                    query = query + colon + "mixed-refs=1";\r
+                else\r
+                    query = query + colon + "mixed-refs=0";\r
+            }\r
+            else if (optNameToChange.Equals("weightb"))\r
+            {\r
+                if (check_weightedBFrames.CheckState != CheckState.Checked)\r
+                    query = query + colon + "weightb=0";\r
+            }\r
+            else if (optNameToChange.Equals("b-pyramid"))\r
+            {\r
+                if (check_pyrmidalBFrames.CheckState == CheckState.Checked)\r
+                    query = query + colon + "b-pyramid=1";\r
+            }\r
+            else if (optNameToChange.Equals("no-fast-pskip"))\r
+            {\r
+                if (check_noFastPSkip.CheckState == CheckState.Checked)\r
+                    query = query + colon + "no-fast-pskip=1";\r
+            }\r
+            else if (optNameToChange.Equals("no-dct-decimate"))\r
+            {\r
+                if (check_noDCTDecimate.CheckState == CheckState.Checked)\r
+                    query = query + colon + "no-dct-decimate=1";\r
+            }\r
+            else if (optNameToChange.Equals("8x8dct"))\r
+            {\r
+                if (check_8x8DCT.CheckState == CheckState.Checked)\r
+                    query = query + colon + "8x8dct=1";\r
+            }\r
+            else if (optNameToChange.Equals("cabac"))\r
+            {\r
+                if (check_Cabac.CheckState != CheckState.Checked)\r
+                    query = query + colon + "cabac=0";\r
+            }\r
+            else if (optNameToChange.Equals("ref"))\r
+            {\r
+                if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))\r
+                    query = query + colon + "ref=" + drop_refFrames.SelectedItem;\r
+            }\r
+            else if (optNameToChange.Equals("bframes"))\r
+            {\r
+                String value = drop_bFrames.SelectedItem.ToString();\r
+                if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))\r
+                    query = query + colon + "bframes=" + value;\r
+            }\r
+            else if (optNameToChange.Equals("subq"))\r
+            {\r
+                String value = drop_subpixelMotionEstimation.SelectedItem.ToString();\r
+                if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))\r
+                    query = query + colon + "subq=" + value;\r
+            }\r
+            else if (optNameToChange.Equals("trellis"))\r
+            {\r
+                if (!drop_trellis.SelectedItem.ToString().Contains("Default"))\r
+                    query = query + colon + "trellis=" + drop_trellis.SelectedItem;\r
+            }\r
+\r
+            rtf_x264Query.Text = query;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Shows and hides controls based on the values of other controls.\r
+        /// </summary>\r
+        /// <param name="sender"></param>\r
+        private void animate(string sender)\r
+        {\r
+            /* Lots of situations to cover.\r
+                  - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)\r
+                  - CABAC (when 0 turn off trellis)\r
+                  - analysis (if none, turn off 8x8dct)\r
+                  - refs (under 2, disable mixed-refs)\r
+                  - subme (if under 6, turn off psy-rd and psy-trel)\r
+                  - trellis (if 0, turn off psy-trel)\r
+               */\r
+\r
+            switch(sender)\r
+            {\r
+                case "bframes":\r
+                    if (drop_bFrames.SelectedIndex >0 && drop_bFrames.SelectedIndex < 2  )\r
+                    {\r
+                        /* If the b-frame widget is at 0 or 1, the user has chosen\r
+                           not to use b-frames at all. So disable the options\r
+                           that can only be used when b-frames are enabled.        */\r
+                        check_weightedBFrames.Visible = false;\r
+                        check_pyrmidalBFrames.Visible = false;\r
+                        drop_directPrediction.Visible = false;\r
+                        lbl_direct_prediction.Visible = false;\r
+\r
+                        check_weightedBFrames.CheckState = CheckState.Unchecked;\r
+                        check_pyrmidalBFrames.CheckState = CheckState.Unchecked;\r
+                        drop_directPrediction.SelectedIndex = 0;\r
+\r
+                        drop_adaptBFrames.Visible = false;\r
+                        lbl_adaptBFrames.Visible = false;\r
+                        drop_adaptBFrames.SelectedIndex = 0;\r
+                    }\r
+                    else if (drop_bFrames.SelectedIndex == 2)\r
+                    {\r
+                        /* Only 1 b-frame? Disable b-pyramid. */\r
+                        check_pyrmidalBFrames.Visible = false;\r
+                        check_pyrmidalBFrames.CheckState = CheckState.Unchecked;\r
+\r
+                        check_weightedBFrames.Visible = true;\r
+                        drop_directPrediction.Visible = true;\r
+                        lbl_direct_prediction.Visible = true;\r
+\r
+                        drop_adaptBFrames.Visible = true;\r
+                        lbl_adaptBFrames.Visible = true;\r
+                    }\r
+                    else\r
+                    {\r
+                        check_weightedBFrames.Visible = true;\r
+                        check_pyrmidalBFrames.Visible = true;\r
+                        drop_directPrediction.Visible = true;\r
+                        lbl_direct_prediction.Visible = true;\r
+\r
+                        drop_adaptBFrames.Visible = true;\r
+                        lbl_adaptBFrames.Visible = true;\r
+                    }\r
+                break;\r
+                case "cabac":\r
+                    if (check_Cabac.Checked == false)\r
+                    {\r
+                        /* Without CABAC entropy coding, trellis doesn't run. */\r
+                        drop_trellis.Visible = false;\r
+                        drop_trellis.SelectedIndex = 0;\r
+                        lbl_trellis.Visible = false;\r
+                    }\r
+                    else\r
+                    {\r
+                        drop_trellis.Visible = true;\r
+                        lbl_trellis.Visible = true;\r
+                    }\r
+                break;\r
+                case "analyse":\r
+                    if (drop_analysis.SelectedIndex == 1)\r
+                    {\r
+                        /* No analysis? Disable 8x8dct */\r
+                        check_8x8DCT.Visible = false;\r
+                        if (sender != "8x8dct")\r
+                            check_8x8DCT.CheckState = CheckState.Unchecked;\r
+                    }\r
+                    else\r
+                        check_8x8DCT.Visible = true;\r
+                break;\r
+                case "ref":\r
+                    if (drop_refFrames.SelectedIndex > 0 && drop_refFrames.SelectedIndex < 3)\r
+                    {\r
+                        check_mixedReferences.Visible = false;\r
+                        if (sender != "mixed-refs")\r
+                            check_mixedReferences.CheckState = CheckState.Unchecked;\r
+                    }\r
+                    else\r
+                        check_mixedReferences.Visible = true;\r
+                break;\r
+                case "me":        // Motion Estimation\r
+                    if (drop_MotionEstimationMethod.SelectedIndex < 3)\r
+                    {\r
+                        drop_MotionEstimationRange.Visible = false;\r
+                        lbl_merange.Visible = false;\r
+                        drop_MotionEstimationRange.SelectedIndex = 0;\r
+                    }\r
+                    else\r
+                    {\r
+                        drop_MotionEstimationRange.Visible = true;\r
+                        lbl_merange.Visible = true;\r
+                    }\r
+                break;\r
+                case "subq":        // subme\r
+                    if (drop_subpixelMotionEstimation.SelectedIndex != 0 && drop_subpixelMotionEstimation.SelectedIndex < 7)\r
+                    {\r
+                        slider_psyrd.Visible = false;\r
+                        slider_psyrd.Value = 10;\r
+                        lbl_psyrd.Visible = false;\r
+\r
+\r
+                        slider_psytrellis.Visible = false;\r
+                        slider_psytrellis.Value = 0;\r
+                        lbl_psytrellis.Visible = false;\r
+                    }\r
+                    else\r
+                    {\r
+                        slider_psyrd.Visible = true;\r
+                        lbl_psyrd.Visible = true;\r
+\r
+                        if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)\r
+                        {\r
+                            slider_psytrellis.Visible = true;\r
+                            lbl_psytrellis.Visible = true;\r
+                        }\r
+                    }\r
+                break;\r
+                case "trellis":        // subme\r
+                    if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2 )\r
+                    {\r
+                        slider_psytrellis.Visible = false;\r
+                        slider_psytrellis.Value = 0;\r
+                        lbl_psytrellis.Visible = false;\r
+                    }\r
+                    else\r
+                    {\r
+                        if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked && slider_psytrellis.Visible == false)\r
+                        {\r
+                            slider_psytrellis.Visible = true;\r
+                            lbl_psytrellis.Visible = true;\r
+                        }\r
+                    }\r
+                break;\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/Controls/x264Panel.resx b/win/C#/Controls/x264Panel.resx
new file mode 100644 (file)
index 0000000..064df4a
--- /dev/null
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <data name="slider_psyrd.ToolTip" xml:space="preserve">\r
+    <value>Psychovisual Rate Distortion Optimization sure is a mouthful, isn't it? Basically, it means x264 tries to retain detail, for better quality to the human eye, \r
+as opposed to trying to maximize quality the way a computer understands it, through signal-to-noise ratios that have trouble telling apart fine detail and noise.</value>\r
+  </data>\r
+  <data name="drop_adaptBFrames.ToolTip" xml:space="preserve">\r
+    <value>When adaptive B-Frames are disabled, the number of B-Frames you specify is the constant length of every B-Frame sequence. \r
+When one of the adaptive modes is enabled, the number of B-Frames is treated as a maximum, with the length of each sequence varying, but never exceeding the max.\r
+\r
+Fast mode takes the same amount of time no matter how many B-frames you specify. However, it doesn't always make the best decisions on how many B-Frames to use in a sequence.\r
+\r
+Optimal mode gets slower as the maximum number of B-Frames increases, but does a much better job at deciding sequence length, which can mean smaller file sizes and better quality.</value>\r
+  </data>\r
+  <data name="check_Cabac.ToolTip" xml:space="preserve">\r
+    <value>CABAC, or context adaptive binary arithmetic coding, is used by x264 to reduce the bitrate needed for a given quality by 15\%. \r
+This makes it very cool and very useful, and it should be left on whenever possible. However, it is incompatible with the iPod, and makes the AppleTV struggle. So turn it off for those.\r
+\r
+CABAC is a kind of entropy coding, which means that it compresses data by making shorthand symbols to represent long streams of data. The \"entropy\" part means that the symbols it uses the most often are the smallest. \r
+When you disable CABAC, another entropy coding scheme gets enabled, called CAVLC (context adaptive variable-length coding). \r
+CAVLC is a lot less efficient, which is why it needs 15\% more bitrate to achieve the same quality as CABAC.</value>\r
+  </data>\r
+  <data name="check_noDCTDecimate.ToolTip" xml:space="preserve">\r
+    <value>To save space, x264 will \"zero out\" blocks when it thinks they won't be perceptible by the viewer. \r
+This negligibly reduces quality, but in rare cases it can mess up and produce visible artifacts. \r
+This situation can be alleviated by telling x264 not to decimate DCT blocks.\r
+\r
+It increases quality but also bitrate/file size, so if you use it when you've specified a target bitrate you will end up with a worse picture than without it. \r
+However, when used with constant quality encoding, or if you boost the average bitrate to compensate, you might get a better result.</value>\r
+  </data>\r
+  <data name="drop_trellis.ToolTip" xml:space="preserve">\r
+    <value>Trellis fine-tunes how bitrate is doled out, so it can reduce file size/bitrate or increase quality. \r
+A value of 1 means it only fine-tunes the final encode of a block of pixels, while 2 means it is considered during earlier phases of the decision-making process as well.</value>\r
+  </data>\r
+  <data name="drop_deblockBeta.ToolTip" xml:space="preserve">\r
+    <value>x264 includes an in-loop deblocking filter. What this means is that blocky compression artifacts are smoothed away when you play back the video. \r
+It has two settings: strength and threshold, just like a simple filter in Photoshop.\r
+\r
+Strength controls the amount of deblocking applied to the whole frame. If you drop down below 0, you reduce the amount of blurring. \r
+Go too negative, and you'll get an effect somewhat like oversharpening an image. Go into positive values, and the image may become too soft.\r
+\r
+Threshold controls how sensitive the filter is to whether something in a block is detail that needs to be preserved: lower numbers blur details less.\r
+\r
+The default deblocking values are 0 and 0. \r
+This does not mean zero deblocking. \r
+It means x264 will apply the regular deblocking strength and thresholds the codec authors have selected as working the best in most cases.\r
+\r
+While many, many people stick with the default deblocking values of 0,0, and you should never change the deblocking without disabling adaptive quantization, \r
+other people disagree. \r
+Some prefer a slightly less blurred image for live action material, and use values like -2,-1 or -2,-2. Others will raise it to 1,1 or even 3,3 for animation. \r
+While the values for each setting extend from -6 to 6, the consensus is that going below -3 or above 3 is worthless.</value>\r
+  </data>\r
+  <data name="drop_deblockAlpha.ToolTip" xml:space="preserve">\r
+    <value>x264 includes an in-loop deblocking filter. What this means is that blocky compression artifacts are smoothed away when you play back the video. \r
+It has two settings: strength and threshold, just like a simple filter in Photoshop.\r
+\r
+Strength controls the amount of deblocking applied to the whole frame. If you drop down below 0, you reduce the amount of blurring. \r
+Go too negative, and you'll get an effect somewhat like oversharpening an image. Go into positive values, and the image may become too soft.\r
+\r
+Threshold controls how sensitive the filter is to whether something in a block is detail that needs to be preserved: lower numbers blur details less.\r
+\r
+The default deblocking values are 0 and 0. \r
+This does not mean zero deblocking. \r
+It means x264 will apply the regular deblocking strength and thresholds the codec authors have selected as working the best in most cases.\r
+\r
+While many, many people stick with the default deblocking values of 0,0, and you should never change the deblocking without disabling adaptive quantization, \r
+other people disagree. \r
+Some prefer a slightly less blurred image for live action material, and use values like -2,-1 or -2,-2. Others will raise it to 1,1 or even 3,3 for animation. \r
+While the values for each setting extend from -6 to 6, the consensus is that going below -3 or above 3 is worthless.</value>\r
+  </data>\r
+  <data name="check_8x8DCT.ToolTip" xml:space="preserve">\r
+    <value>Checking this box lets x264 break key frames down into 8x8 blocks of pixels for analysis. \r
+This is a high profile feature of H.264, which makes it less compatible. It should slightly decrease bitrate or improve quality. \r
+Turn it on whenever possible.</value>\r
+  </data>\r
+  <data name="drop_analysis.ToolTip" xml:space="preserve">\r
+    <value>Analysis controls how finely x264 divides up a frame to capture detail. Full macroblocks are 16x16 pixels, but x264 can go down all the way to 4x4 blocks if it judges it necessary. \r
+By default it only breaks up key frames that much. To give x264 the freedom to make the best decisions for all frames, use \"all\" analysis. \r
+If you want to create a high profile H.264 video (which is less compatible with the world at large than main profile), also check the \"8x8 DCT blocks\" box to add yet another block size for analysis.</value>\r
+  </data>\r
+  <data name="drop_subpixelMotionEstimation.ToolTip" xml:space="preserve">\r
+    <value>This setting is finer-grained than the motion estimation settings above. Instead of dealing with whole pixels, it deals with 4 fractional pixels, or quarter pixels (qpel). \r
+Higher levels increase quality by further refining the motion prediction for these quarter pixels, but take longer to encode.\r
+\r
+Level 6, turns on a feature called rate distortion optimization, including psychovisual enhancements. \r
+7, the default, enables that rate distortion for B-frames.\r
+8 refines those decisions for I and P frames, and 9 adds on refinement for B-frames as well.</value>\r
+  </data>\r
+  <data name="drop_MotionEstimationRange.ToolTip" xml:space="preserve">\r
+    <value>This range is the radius, in pixels, x264 should use for motion estimation searches. \r
+It only has an effect when you use Uneven Multi-Hexagonal, Exhaustive, or Transformed Exhaustive searching. \r
+24, 32, and 64 are good values, with each being progressively smaller for progressively less improvement to picture quality.</value>\r
+  </data>\r
+  <data name="drop_MotionEstimationMethod.ToolTip" xml:space="preserve">\r
+    <value>Controls the motion estimation method. \r
+Motion estimation is how the encoder decides how each block of pixels in a frame has moved, compared to most similar blocks in the other frames it references. \r
+There are many ways of finding the most similar blocks, with varying speeds and accuracy.\r
+\r
+At the most basic setting, dia, x264 will only consider a diamond-shaped region around each pixel.\r
+\r
+The default setting, hex, is similar to dia but uses a hexagon shape.\r
+\r
+Uneven multi-hexagon, umh, searches a number of different patterns across a wider area and thus is slower than hex and dia but further increases compression efficiency and quality.\r
+\r
+esa, an exhaustive search of a square around each pixel (whose size is controlled by the me-range parameter), is much slower and offers only minimal quality gains.\r
+\r
+tesa, transformed exhaustive search, which performs just as thorough a search, is slower still but offers further slight improvements to quality.</value>\r
+  </data>\r
+  <data name="check_pyrmidalBFrames.ToolTip" xml:space="preserve">\r
+    <value>B-frame pyramids are a High Profile feature. Pyramidal B-frames mean that B-frames don't just reference surrounding reference frames - \r
+instead, it also treats a previous B-frame as a reference, improving quality/lowering bitrate at the expense of complexity. \r
+Logically, to reference an earlier B-frame, you must tell x264 to use at least 2 B-frames.</value>\r
+  </data>\r
+  <data name="check_weightedBFrames.ToolTip" xml:space="preserve">\r
+    <value>Sometimes x264 will base a B-frame's motion compensation on frames both before and after. \r
+With weighted B-frames, the amount of influence each frame has is related to its distance from the frame being encoded, \r
+instead of both having equal influence. \r
+The AppleTV can have issues with this.</value>\r
+  </data>\r
+  <data name="drop_directPrediction.ToolTip" xml:space="preserve">\r
+    <value>Direct prediction tells x264 what method to use when guessing motion for certain parts of a B-frame. \r
+It can either look at other parts of the current frame (spatial) or compare against the following P-frameframe (temporal). \r
+You're best off setting this to automatic, so x264 decides which method is best on its own. \r
+Don't select none assuming it will be faster; instead it will take longer and look worse. If you're going to choose between spatial and temporal, spatial is usually better.</value>\r
+  </data>\r
+</root>
\ No newline at end of file
diff --git a/win/C#/EncodeQueue/EncodeAndQueueHandler.cs b/win/C#/EncodeQueue/EncodeAndQueueHandler.cs
new file mode 100644 (file)
index 0000000..f2a4eae
--- /dev/null
@@ -0,0 +1,533 @@
+/*  EncodeAndQueueHandler.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr/>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Collections.ObjectModel;\r
+using System.Diagnostics;\r
+using System.IO;\r
+using System.Threading;\r
+using System.Windows.Forms;\r
+using System.Xml.Serialization;\r
+using Handbrake.Functions;\r
+\r
+namespace Handbrake.EncodeQueue\r
+{\r
+    public class EncodeAndQueueHandler\r
+    {\r
+        private static XmlSerializer serializer = new XmlSerializer(typeof(List<Job>));\r
+        private List<Job> queue = new List<Job>();\r
+        private int nextJobId;\r
+\r
+        #region Event Handlers\r
+        /// <summary>\r
+        /// Fires when an encode job has been started.\r
+        /// </summary>\r
+        public event EventHandler NewJobStarted;\r
+\r
+        /// <summary>\r
+        /// Fires when a pause to the encode queue has been requested.\r
+        /// </summary>\r
+        public event EventHandler QueuePauseRequested;\r
+\r
+        /// <summary>\r
+        /// Fires when an encode job has been completed.\r
+        /// </summary>\r
+        public event EventHandler CurrentJobCompleted;\r
+\r
+        /// <summary>\r
+        /// Fires when the entire encode queue has completed.\r
+        /// </summary>\r
+        public event EventHandler QueueCompleted;\r
+        #endregion\r
+\r
+        #region Queue\r
+        /// <summary>\r
+        /// Gets and removes the next job in the queue.\r
+        /// </summary>\r
+        /// <returns>The job that was removed from the queue.</returns>\r
+        private Job GetNextJob()\r
+        {\r
+            Job job = queue[0];\r
+            LastEncode = job;\r
+            RemoveJob(0); // Remove the item which we are about to pass out.\r
+\r
+            WriteQueueStateToFile("hb_queue_recovery.xml");\r
+\r
+            return job;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets the current state of the encode queue.\r
+        /// </summary>\r
+        public ReadOnlyCollection<Job> CurrentQueue\r
+        {\r
+            get { return queue.AsReadOnly(); }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets the number of items in the queue.\r
+        /// </summary>\r
+        public int Count\r
+        {\r
+            get { return queue.Count; }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Adds an item to the queue.\r
+        /// </summary>\r
+        /// <param name="query">The query that will be passed to the HandBrake CLI.</param>\r
+        /// <param name="source">The location of the source video.</param>\r
+        /// <param name="destination">The location where the encoded video will be.</param>\r
+        /// <param name="customJob"></param>\r
+        public void AddJob(string query, string source, string destination, bool customJob)\r
+        {\r
+            Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination, CustomQuery = customJob };\r
+\r
+            queue.Add(newJob);\r
+            WriteQueueStateToFile("hb_queue_recovery.xml");\r
+        }\r
+\r
+        /// <summary>\r
+        /// Removes an item from the queue.\r
+        /// </summary>\r
+        /// <param name="index">The zero-based location of the job in the queue.</param>\r
+        public void RemoveJob(int index)\r
+        {\r
+            queue.RemoveAt(index);\r
+            WriteQueueStateToFile("hb_queue_recovery.xml");\r
+        }\r
+\r
+        /// <summary>\r
+        /// Moves an item up one position in the queue.\r
+        /// </summary>\r
+        /// <param name="index">The zero-based location of the job in the queue.</param>\r
+        public void MoveUp(int index)\r
+        {\r
+            if (index > 0)\r
+            {\r
+                Job item = queue[index];\r
+\r
+                queue.RemoveAt(index);\r
+                queue.Insert((index - 1), item);\r
+            }\r
+\r
+            WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+        }\r
+\r
+        /// <summary>\r
+        /// Moves an item down one position in the queue.\r
+        /// </summary>\r
+        /// <param name="index">The zero-based location of the job in the queue.</param>\r
+        public void MoveDown(int index)\r
+        {\r
+            if (index < queue.Count - 1)\r
+            {\r
+                Job item = queue[index];\r
+\r
+                queue.RemoveAt(index);\r
+                queue.Insert((index + 1), item);\r
+            }\r
+\r
+            WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+        }\r
+\r
+        /// <summary>\r
+        /// Writes the current state of the queue to a file.\r
+        /// </summary>\r
+        /// <param name="file">The location of the file to write the queue to.</param>\r
+        public void WriteQueueStateToFile(string file)\r
+        {\r
+            string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file;\r
+\r
+            try\r
+            {\r
+                using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
+                {\r
+                    serializer.Serialize(strm, queue);\r
+                    strm.Close();\r
+                    strm.Dispose();\r
+                }\r
+            }\r
+            catch (Exception)\r
+            {\r
+                // Any Errors will be out of diskspace/permissions problems. \r
+                // Don't report them as they'll annoy the user.\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Writes the current state of the queue in the form of a batch (.bat) file.\r
+        /// </summary>\r
+        /// <param name="file">The location of the file to write the batch file to.</param>\r
+        public void WriteBatchScriptToFile(string file)\r
+        {\r
+            string queries = "";\r
+            foreach (Job queue_item in queue)\r
+            {\r
+                string q_item = queue_item.Query;\r
+                string fullQuery = '"' + Application.StartupPath + "\\HandBrakeCLI.exe" + '"' + q_item;\r
+\r
+                if (queries == string.Empty)\r
+                    queries = queries + fullQuery;\r
+                else\r
+                    queries = queries + " && " + fullQuery;\r
+            }\r
+            string strCmdLine = queries;\r
+\r
+            if (file != "")\r
+            {\r
+                try\r
+                {\r
+                    // Create a StreamWriter and open the file, Write the batch file query to the file and \r
+                    // Close the stream\r
+                    using (StreamWriter line = new StreamWriter(file))\r
+                    {\r
+                        line.WriteLine(strCmdLine);\r
+                    }\r
+\r
+                    MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+                }\r
+                catch (Exception)\r
+                {\r
+                    MessageBox.Show("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                }\r
+\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Reads a serialized XML file that represents a queue of encoding jobs.\r
+        /// </summary>\r
+        /// <param name="file">The location of the file to read the queue from.</param>\r
+        public void LoadQueueFromFile(string file)\r
+        {\r
+            string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file;\r
+\r
+            if (File.Exists(tempPath))\r
+            {\r
+                using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
+                {\r
+                    if (strm.Length != 0)\r
+                    {\r
+                        List<Job> list = serializer.Deserialize(strm) as List<Job>;\r
+\r
+                        if (list != null)\r
+                            foreach (Job item in list)\r
+                                queue.Add(item);\r
+\r
+                        if (file != "hb_queue_recovery.xml")\r
+                            WriteQueueStateToFile("hb_queue_recovery.xml");\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Checks the current queue for an existing instance of the specified destination.\r
+        /// </summary>\r
+        /// <param name="destination">The destination of the encode.</param>\r
+        /// <returns>Whether or not the supplied destination is already in the queue.</returns>\r
+        public bool CheckForDestinationDuplicate(string destination)\r
+        {\r
+            foreach (Job checkItem in queue)\r
+            {\r
+                if (checkItem.Destination.Contains(destination.Replace("\\\\", "\\")))\r
+                    return true;\r
+            }\r
+\r
+            return false;\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region Encoding\r
+\r
+        /// <summary>\r
+        /// Gets the last encode that was processed.\r
+        /// </summary>\r
+        /// <returns></returns> \r
+        public Job LastEncode { get; set; }\r
+\r
+        /// <summary>\r
+        /// Request Pause\r
+        /// </summary>\r
+        public Boolean PauseRequested { get; private set; }\r
+\r
+        /// <summary>\r
+        /// Starts encoding the first job in the queue and continues encoding until all jobs\r
+        /// have been encoded.\r
+        /// </summary>\r
+        public void StartEncodeQueue()\r
+        {\r
+            if (this.Count != 0)\r
+            {\r
+                if (PauseRequested)\r
+                    PauseRequested = false;\r
+                else\r
+                {\r
+                    PauseRequested = false;\r
+                    try\r
+                    {\r
+                        Thread theQueue = new Thread(startProcess) { IsBackground = true };\r
+                        theQueue.Start();\r
+                    }\r
+                    catch (Exception exc)\r
+                    {\r
+                        MessageBox.Show(exc.ToString());\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Requests a pause of the encode queue.\r
+        /// </summary>\r
+        public void RequestPause()\r
+        {\r
+            PauseRequested = true;\r
+\r
+            if (QueuePauseRequested != null)\r
+                QueuePauseRequested(this, new EventArgs());\r
+        }\r
+\r
+        /// <summary>\r
+        /// Stops the current job.\r
+        /// </summary>\r
+        public void EndEncodeJob()\r
+        {\r
+            CloseCLI();\r
+        }\r
+\r
+        private void startProcess(object state)\r
+        {\r
+            // Run through each item on the queue\r
+            while (this.Count != 0)\r
+            {\r
+                Job encJob = GetNextJob();\r
+                string query = encJob.Query;\r
+                WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+\r
+                RunCli(query);\r
+\r
+                if (NewJobStarted != null)\r
+                    NewJobStarted(this, new EventArgs());\r
+\r
+                hbProcess.WaitForExit();\r
+\r
+                AddCLIQueryToLog(encJob);\r
+                CopyLog(LastEncode.Destination);\r
+\r
+                hbProcess.Close();\r
+                hbProcess.Dispose();\r
+                \r
+                isEncoding = false;\r
+\r
+                //Growl\r
+                if (Properties.Settings.Default.growlEncode)\r
+                    GrowlCommunicator.Notify("Encode Completed", "Put down that cocktail...\nyour Handbrake encode is done.");\r
+\r
+                if (CurrentJobCompleted != null)\r
+                    CurrentJobCompleted(this, new EventArgs());\r
+\r
+                while (PauseRequested) // Need to find a better way of doing this.\r
+                {\r
+                    Thread.Sleep(5000);\r
+                }\r
+            }\r
+            LastEncode = new Job();\r
+\r
+            if (QueueCompleted != null)\r
+                QueueCompleted(this, new EventArgs());\r
+\r
+            // After the encode is done, we may want to shutdown, suspend etc.\r
+            AfterEncodeAction();\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region CLI and Log Handling\r
+        public Process hbProcess { get; set; }\r
+        public int processID { get; set; }\r
+        public IntPtr processHandle { get; set; }\r
+        public String currentQuery { get; set; }\r
+        public Boolean isEncoding { get; set; }\r
+\r
+        /// <summary>\r
+        /// Execute a HandBrakeCLI process.\r
+        /// </summary>\r
+        /// <param name="query">The CLI Query</param>\r
+        public void RunCli(string query)\r
+        {\r
+            try\r
+            {\r
+                isEncoding = true;\r
+\r
+                string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
+                string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs", "last_encode_log.txt");\r
+                string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);\r
+                ProcessStartInfo cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);\r
+\r
+                if (Properties.Settings.Default.enocdeStatusInGui)\r
+                {\r
+                    cliStart.RedirectStandardOutput = true;\r
+                    cliStart.UseShellExecute = false;\r
+                }\r
+                if (Properties.Settings.Default.cli_minimized)\r
+                    cliStart.WindowStyle = ProcessWindowStyle.Minimized;\r
+\r
+                Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
+                hbProcess = Process.Start(cliStart);\r
+                processID = Main.getCliProcess(before); \r
+                currentQuery = query;\r
+                if (hbProcess != null)\r
+                    processHandle = hbProcess.MainWindowHandle; // Set the process Handle\r
+\r
+                // Set the process Priority\r
+                Process hbCliProcess = null;\r
+                if (processID != -1)\r
+                    hbCliProcess = Process.GetProcessById(processID);\r
+\r
+                if (hbCliProcess != null)\r
+                    switch (Properties.Settings.Default.processPriority)\r
+                    {\r
+                        case "Realtime":\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.RealTime;\r
+                            break;\r
+                        case "High":\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.High;\r
+                            break;\r
+                        case "Above Normal":\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+                            break;\r
+                        case "Normal":\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.Normal;\r
+                            break;\r
+                        case "Low":\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.Idle;\r
+                            break;\r
+                        default:\r
+                            hbCliProcess.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+                            break;\r
+                    }\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n   Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Kill the CLI process\r
+        /// </summary>\r
+        private void CloseCLI()\r
+        {\r
+            hbProcess.Kill();\r
+            isEncoding = false;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Perform an action after an encode. e.g a shutdown, standby, restart etc.\r
+        /// </summary>\r
+        private void AfterEncodeAction()\r
+        {\r
+            isEncoding = false;\r
+            currentQuery = String.Empty;\r
+\r
+            //Growl\r
+            if (Properties.Settings.Default.growlQueue)\r
+                GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");\r
+\r
+            // Do something whent he encode ends.\r
+            switch (Properties.Settings.Default.CompletionOption)\r
+            {\r
+                case "Shutdown":\r
+                    Process.Start("Shutdown", "-s -t 60");\r
+                    break;\r
+                case "Log Off":\r
+                    Win32.ExitWindowsEx(0, 0);\r
+                    break;\r
+                case "Suspend":\r
+                    Application.SetSuspendState(PowerState.Suspend, true, true);\r
+                    break;\r
+                case "Hibernate":\r
+                    Application.SetSuspendState(PowerState.Hibernate, true, true);\r
+                    break;\r
+                case "Lock System":\r
+                    Win32.LockWorkStation();\r
+                    break;\r
+                case "Quit HandBrake":\r
+                    Application.Exit();\r
+                    break;\r
+                default:\r
+                    break;\r
+            }\r
+        }\r
+\r
+        /// <summar>\r
+        /// Append the CLI query to the start of the log file.\r
+        /// </summary>\r
+        /// <param name="query"></param>\r
+        private static void AddCLIQueryToLog(Job encJob)\r
+        {\r
+            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+            string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
+\r
+            StreamReader reader = new StreamReader(File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.Read));\r
+            String log = reader.ReadToEnd();\r
+            reader.Close();\r
+\r
+            StreamWriter writer = new StreamWriter(File.Create(logPath));\r
+\r
+            writer.Write("### CLI Query: " + encJob.Query + "\n\n");\r
+            writer.Write("### User Query: " + encJob.CustomQuery + "\n\n");\r
+            writer.Write("#########################################\n\n");\r
+            writer.WriteLine(log);\r
+            writer.Flush();\r
+            writer.Close();\r
+        }\r
+\r
+        /// <summary>\r
+        /// Save a copy of the log to the users desired location or a default location\r
+        /// if this feature is enabled in options.\r
+        /// </summary>\r
+        /// <param name="destination"></param>\r
+        private static void CopyLog(string destination)\r
+        {\r
+            try\r
+            {\r
+                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+                string tempLogFile = Path.Combine(logDir, "last_encode_log.txt");\r
+\r
+                string encodeDestinationPath = Path.GetDirectoryName(destination);\r
+                String destinationFile = Path.GetFileName(destination);\r
+                string encodeLogFile = destinationFile + " " + DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + ".txt";\r
+\r
+                // Make sure the log directory exists.\r
+                if (!Directory.Exists(logDir))\r
+                    Directory.CreateDirectory(logDir);\r
+\r
+                // Copy the Log to HandBrakes log folder in the users applciation data folder.\r
+                File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));\r
+\r
+                // Save a copy of the log file in the same location as the enocde.\r
+                if (Properties.Settings.Default.saveLogWithVideo)\r
+                    File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));\r
+\r
+                // Save a copy of the log file to a user specified location\r
+                if (Directory.Exists(Properties.Settings.Default.saveLogPath))\r
+                    if (Properties.Settings.Default.saveLogPath != String.Empty && Properties.Settings.Default.saveLogToSpecifiedPath)\r
+                        File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.saveLogPath, encodeLogFile));\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show("Something went a bit wrong trying to copy your log file.\nError Information:\n\n" + exc, "Error",\r
+                                MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+        }\r
+        #endregion\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/EncodeQueue/Job.cs b/win/C#/EncodeQueue/Job.cs
new file mode 100644 (file)
index 0000000..7dfe7e5
--- /dev/null
@@ -0,0 +1,46 @@
+/*  QueueItem.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+\r
+namespace Handbrake.EncodeQueue\r
+{\r
+    public struct Job\r
+    {\r
+        /// <summary>\r
+        /// Gets or sets the job ID.\r
+        /// </summary>\r
+        public int Id { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the query string.\r
+        /// </summary>\r
+        public string Query { get; set; }\r
+\r
+        /// <summary>\r
+        /// record if this is a user or GUI generated query\r
+        /// </summary>\r
+        public Boolean CustomQuery { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the source file of encoding.\r
+        /// </summary>\r
+        public string Source { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets or sets the destination for the file to be encoded.\r
+        /// </summary>\r
+        public string Destination { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets whether or not this instance is empty.\r
+        /// </summary>\r
+        public bool IsEmpty\r
+        {\r
+            get { return Id == 0 && string.IsNullOrEmpty(Query) && string.IsNullOrEmpty(Source) && string.IsNullOrEmpty(Destination); }\r
+        }\r
+    }\r
+}
\ No newline at end of file
index dfe96eb..7f1e90b 100644 (file)
@@ -5,74 +5,36 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
-using System.IO;\r
 using System.Xml;\r
 using System.Text.RegularExpressions;\r
+using System.IO;\r
 \r
 namespace Handbrake.Functions\r
 {\r
     public class AppcastReader\r
     {\r
-        XmlDocument rssDoc;\r
-        XmlNode nodeRss;\r
-        XmlNode nodeChannel;\r
-        XmlNode nodeItem;\r
-        private string hb_description;\r
-        private string hb_version;\r
-        private string hb_build;\r
-        private string hb_file;\r
-\r
         /// <summary>\r
-        /// Get the build information from the required appcasts.\r
-        /// This must be run before calling any of the public return functions.\r
+        /// Get the build information from the required appcasts. Run before accessing the public vars.\r
         /// </summary>\r
-        public void getInfo()\r
+        public void getInfo(string input)\r
         {\r
-            Match ver;\r
-            int stable_build, unstable_build = 0;\r
-            string input, unstable_description = "", stable_description, unstable_version = "", stable_version;\r
-            string stable_file, unstable_file = "";\r
-\r
-            // Check the stable appcast and get the stable build number\r
-            readRss(new XmlTextReader(Properties.Settings.Default.appcast));\r
-            input = nodeItem.InnerXml;\r
-            ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
-            stable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));\r
-            ver = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");\r
-            stable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
-            stable_description = nodeItem["description"].InnerText;\r
-            stable_file = nodeItem["windows"].InnerText;\r
-\r
-            // If this is a snapshot release, or the user wants to check for snapshot releases\r
-            if (Properties.Settings.Default.checkSnapshot == "Checked" || Properties.Settings.Default.hb_build.ToString().EndsWith("1"))\r
+            try\r
             {\r
-                // Get the stable build\r
-                readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable));\r
-                input = nodeItem.InnerXml;\r
-                ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
-                unstable_build = int.Parse(ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""));\r
-                ver = Regex.Match(input, @"sparkle:shortVersionString=""([0-9a-zA-Z.]*)\""");\r
-                unstable_version = ver.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
-                unstable_description = nodeItem["description"].InnerText;\r
-                unstable_file = nodeItem["windows"].InnerText;\r
-            }\r
+                // Get the correct Appcast and set input.\r
+                XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));\r
+                string result = nodeItem.InnerXml;\r
 \r
+                // Regular Expressions\r
+                Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");\r
+                Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");\r
 \r
-            // Set the global version information\r
-            if (stable_build >= unstable_build)\r
+                build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
+                version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
+                downloadFile = nodeItem["windows"].InnerText;\r
+                descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
+            } catch( Exception)\r
             {\r
-                hb_description = stable_description;\r
-                hb_version = stable_version;\r
-                hb_build = stable_build.ToString();\r
-                hb_file = stable_file;\r
-            }\r
-            else\r
-            {\r
-                hb_description = unstable_description;\r
-                hb_version = unstable_version;\r
-                hb_build = unstable_build.ToString();\r
-                hb_file = unstable_file;\r
+                // Ignore Error.\r
             }\r
         }\r
 \r
@@ -80,9 +42,13 @@ namespace Handbrake.Functions
         /// Read the RSS file.\r
         /// </summary>\r
         /// <param name="rssReader"></param>\r
-        private void readRss(XmlTextReader rssReader)\r
+        private static XmlNode readRss(XmlReader rssReader)\r
         {\r
-            rssDoc = new XmlDocument();\r
+            XmlNode nodeItem = null;\r
+            XmlNode nodeChannel = null;\r
+            XmlNode nodeRss = null;\r
+\r
+            XmlDocument rssDoc = new XmlDocument();\r
             rssDoc.Load(rssReader);\r
 \r
             for (int i = 0; i < rssDoc.ChildNodes.Count; i++)\r
@@ -91,53 +57,41 @@ namespace Handbrake.Functions
                     nodeRss = rssDoc.ChildNodes[i];\r
             }\r
 \r
-            for (int i = 0; i < nodeRss.ChildNodes.Count; i++)\r
-            {\r
-                if (nodeRss.ChildNodes[i].Name == "channel")\r
-                    nodeChannel = nodeRss.ChildNodes[i];\r
-            }\r
+            if (nodeRss != null)\r
+                for (int i = 0; i < nodeRss.ChildNodes.Count; i++)\r
+                {\r
+                    if (nodeRss.ChildNodes[i].Name == "channel")\r
+                        nodeChannel = nodeRss.ChildNodes[i];\r
+                }\r
 \r
-            for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)\r
-            {\r
-                if (nodeChannel.ChildNodes[i].Name == "item")\r
-                    nodeItem = nodeChannel.ChildNodes[i];\r
-            }\r
+            if (nodeChannel != null)\r
+                for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)\r
+                {\r
+                    if (nodeChannel.ChildNodes[i].Name == "item")\r
+                        nodeItem = nodeChannel.ChildNodes[i];\r
+                }\r
+\r
+            return nodeItem;\r
         }\r
 \r
         /// <summary>\r
         /// Get Information about an update to HandBrake\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string versionInfo()\r
-        {\r
-            return hb_description;\r
-        }\r
+        public Uri descriptionUrl { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's version from the appcast.xml file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string version()\r
-        {\r
-            return hb_version;\r
-        }\r
+        public string version { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's Build from the appcast.xml file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string build()\r
-        {\r
-            return hb_build;\r
-        }\r
+        public string build { get; set; }\r
 \r
         /// <summary>\r
         /// Get's the URL for update file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string downloadFile()\r
-        {\r
-            return hb_file;\r
-        }\r
+        public string downloadFile { get; set; }\r
     }\r
 }
\ No newline at end of file
diff --git a/win/C#/Functions/GrowlCommunicator.cs b/win/C#/Functions/GrowlCommunicator.cs
new file mode 100644 (file)
index 0000000..507ebd5
--- /dev/null
@@ -0,0 +1,108 @@
+/*  GrowlCommunicator.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Growl.Connector;\r
+using Growl.CoreLibrary;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+    /// <summary>\r
+    /// Provides all functionality for communicating with Growl for Windows.\r
+    /// </summary>\r
+    /// <remarks>\r
+    /// This class is implemented as a static class because:\r
+    ///     1. It allows nearly all of the Growl-related code to be in one place\r
+    ///     2. It prevents the main form, queue handler, and any other part of Handbrake from having to declare\r
+    ///        or track any new instance variables\r
+    /// </remarks>\r
+    public static class GrowlCommunicator\r
+    {\r
+        /// <summary>\r
+        /// The <see cref="GrowlConnector"/> that actually talks to Growl\r
+        /// </summary>\r
+        private static GrowlConnector growl;\r
+\r
+        /// <summary>\r
+        /// The Handbrake application instance that is registered with Growl\r
+        /// </summary>\r
+        private static Application application;\r
+\r
+        /// <summary>\r
+        /// Notification shown upon completion of encoding\r
+        /// </summary>\r
+        public static NotificationType EncodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");\r
+\r
+        /// <summary>\r
+        /// Checks to see if Growl is currently running on the local machine.\r
+        /// </summary>\r
+        /// <returns>\r
+        /// <c>true</c> if Growl is running;\r
+        /// <c>false</c> otherwise\r
+        /// </returns>\r
+        public static bool IsRunning()\r
+        {\r
+            Initialize();\r
+\r
+            return growl.IsGrowlRunning();\r
+        }\r
+\r
+        /// <summary>\r
+        /// Registers Handbrake with the local Growl instance\r
+        /// </summary>\r
+        /// <remarks>\r
+        /// This should usually be called at application start-up\r
+        /// </remarks>\r
+        public static void Register()\r
+        {\r
+            Initialize();\r
+            growl.Register(application, new NotificationType[] { EncodeOrQueueCompleted });\r
+        }\r
+\r
+        /// <summary>\r
+        /// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with\r
+        /// static text, this is a shortcut method).\r
+        /// </summary>\r
+        public static void Notify(string title, string text)\r
+        {\r
+            Notification notification = new Notification(application.Name, EncodeOrQueueCompleted.Name, String.Empty, title, text);\r
+            growl.Notify(notification);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Sends a notification to Growl. (This is the more generic version that could be used in the future if \r
+        /// more notification types are implemented)\r
+        /// </summary>\r
+        /// <param name="notificationType">The <see cref="NotificationType">type</see> of notification to send</param>\r
+        /// <param name="title">The notification title</param>\r
+        /// <param name="text">The notification text</param>\r
+        /// <param name="imageUrl">The notification image as a url</param>\r
+        public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)\r
+        {\r
+            Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text);\r
+            notification.Icon = imageUrl;\r
+\r
+            growl.Notify(notification);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Initializes the GrowlCommunicator\r
+        /// </summary>\r
+        private static void Initialize()\r
+        {\r
+            if (growl == null)\r
+            {\r
+                growl = new GrowlConnector();\r
+                growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;\r
+\r
+                application = new Application("Handbrake");\r
+                application.Icon = global::Handbrake.Properties.Resources.logo64;\r
+            }\r
+        }\r
+    }\r
+}\r
index f8600d3..6f8efaa 100644 (file)
-/*  Common.cs $\r
+/*  Main.cs $\r
        \r
           This file is part of the HandBrake source code.\r
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.Globalization;\r
 using System.IO;\r
-using System.Drawing;\r
 using System.Diagnostics;\r
 using System.Text.RegularExpressions;\r
+using System.Collections.Generic;\r
+using System.Xml.Serialization;\r
+using System.Threading;\r
+using Handbrake.EncodeQueue;\r
+using System.Net;\r
 \r
 namespace Handbrake.Functions\r
 {\r
-    class Main\r
+    static class Main\r
     {\r
+        // Private Variables\r
+        private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Job>));\r
+\r
         /// <summary>\r
         /// Calculate the duration of the selected title and chapters\r
         /// </summary>\r
-        public TimeSpan calculateDuration(string chapter_start, string chapter_end, Parsing.Title selectedTitle)\r
+        public static TimeSpan calculateDuration(int chapterStart, int chapterEnd, Parsing.Title selectedTitle)\r
         {\r
-            TimeSpan Duration = TimeSpan.FromSeconds(0.0);\r
-\r
-            // Get the durations between the 2 chapter points and add them together.\r
-            if (chapter_start != "Auto" && chapter_end != "Auto")\r
+            TimeSpan duration = TimeSpan.FromSeconds(0.0);\r
+            chapterStart++; chapterEnd++;\r
+            if (chapterStart != 0 && chapterEnd != 0 && chapterEnd <= selectedTitle.Chapters.Count)\r
             {\r
-                int start_chapter, end_chapter = 0;\r
-                int.TryParse(chapter_start, out start_chapter);\r
-                int.TryParse(chapter_end, out end_chapter);\r
-\r
-                int position = start_chapter - 1;\r
-\r
-                if (start_chapter <= end_chapter)\r
-                {\r
-                    if (end_chapter > selectedTitle.Chapters.Count)\r
-                        end_chapter = selectedTitle.Chapters.Count;\r
-\r
-                    while (position != end_chapter)\r
-                    {\r
-                        TimeSpan dur = selectedTitle.Chapters[position].Duration;\r
-                        Duration = Duration + dur;\r
-                        position++;\r
-                    }\r
-                }\r
+                for (int i = chapterStart; i <= chapterEnd; i++)\r
+                    duration += selectedTitle.Chapters[i - 1].Duration;\r
             }\r
-            return Duration;\r
+\r
+            return duration;\r
         }\r
 \r
         /// <summary>\r
-        /// Calculate the non-anamorphic resoltuion of the source\r
+        /// Select the longest title in the DVD title dropdown menu on frmMain\r
         /// </summary>\r
-        /// <param name="width"></param>\r
-        /// <returns></returns>\r
-        public int cacluateNonAnamorphicHeight(int width, decimal top, decimal bottom, decimal left, decimal right, Parsing.Title selectedTitle)\r
+        public static Parsing.Title selectLongestTitle(Parsing.DVD thisDvd)\r
         {\r
-            float aspect = selectedTitle.AspectRatio;\r
-            int aw;\r
-            int ah;\r
-            if (aspect.ToString() == "1.78")\r
-            {\r
-                aw = 16;\r
-                ah = 9;\r
-            }\r
-            else\r
-            {\r
-                aw = 4;\r
-                ah = 3;\r
-            }\r
-\r
-            double a = width * selectedTitle.Resolution.Width * ah * (selectedTitle.Resolution.Height - (double)top - (double)bottom);\r
-            double b = selectedTitle.Resolution.Height * aw * (selectedTitle.Resolution.Width - (double)left - (double)right);\r
+            TimeSpan longestDurationFound = TimeSpan.FromSeconds(0.0);\r
+            Parsing.Title returnTitle = null;\r
 \r
-            double y = a / b;\r
-\r
-            // If it's not Mod 16, make it mod 16\r
-            if ((y % 16) != 0)\r
+            foreach (Parsing.Title item in thisDvd.Titles)\r
             {\r
-                double mod16 = y % 16;\r
-                if (mod16 >= 8)\r
-                {\r
-                    mod16 = 16 - mod16;\r
-                    y = y + mod16;\r
-                }\r
-                else\r
+                if (item.Duration > longestDurationFound)\r
                 {\r
-                    y = y - mod16;\r
+                    returnTitle = item;\r
+                    longestDurationFound = item.Duration;\r
                 }\r
             }\r
-\r
-            //16 * (421 / 16)\r
-            //double z = ( 16 * (( y + 8 ) / 16 ) );\r
-            int x = int.Parse(y.ToString());\r
-            return x;\r
+            return returnTitle;\r
         }\r
 \r
         /// <summary>\r
-        /// Select the longest title in the DVD title dropdown menu on frmMain\r
+        /// Set's up the DataGridView on the Chapters tab (frmMain)\r
         /// </summary>\r
-        public Handbrake.Parsing.Title selectLongestTitle(ComboBox drp_dvdtitle)\r
+        public static DataGridView chapterNaming(DataGridView dataChpt, string chapterEnd)\r
         {\r
-            int current_largest = 0;\r
-            Handbrake.Parsing.Title title2Select;\r
+            int i = 0, finish = 0;\r
 \r
-            // Check if there are titles in the DVD title dropdown menu and make sure, it's not just "Automatic"\r
-            if (drp_dvdtitle.Items[0].ToString() != "Automatic")\r
-                title2Select = (Handbrake.Parsing.Title)drp_dvdtitle.Items[0];\r
-            else\r
-                title2Select = null;\r
+            if (chapterEnd != "Auto")\r
+                int.TryParse(chapterEnd, out finish);\r
 \r
-            // So, If there are titles in the DVD Title dropdown menu, lets select the longest.\r
-            if (title2Select != null)\r
+            while (i < finish)\r
             {\r
-                foreach (Handbrake.Parsing.Title x in drp_dvdtitle.Items)\r
-                {\r
-                    string title = x.ToString();\r
-                    if (title != "Automatic")\r
-                    {\r
-                        string[] y = title.Split(' ');\r
-                        string time = y[1].Replace("(", "").Replace(")", "");\r
-                        string[] z = time.Split(':');\r
-\r
-                        int hours = int.Parse(z[0]) * 60 * 60;\r
-                        int minutes = int.Parse(z[1]) * 60;\r
-                        int seconds = int.Parse(z[2]);\r
-                        int total_sec = hours + minutes + seconds;\r
-\r
-                        if (current_largest == 0)\r
-                        {\r
-                            current_largest = hours + minutes + seconds;\r
-                            title2Select = x;\r
-                        }\r
-                        else\r
-                        {\r
-                            if (total_sec > current_largest)\r
-                            {\r
-                                current_largest = total_sec;\r
-                                title2Select = x;\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
+                int n = dataChpt.Rows.Add();\r
+                dataChpt.Rows[n].Cells[0].Value = (i + 1);\r
+                dataChpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);\r
+                dataChpt.Rows[n].Cells[0].ValueType = typeof(int);\r
+                dataChpt.Rows[n].Cells[1].ValueType = typeof(string);\r
+                i++;\r
             }\r
-            return title2Select;\r
+\r
+            return dataChpt;\r
         }\r
 \r
         /// <summary>\r
-        /// Set's up the DataGridView on the Chapters tab (frmMain)\r
+        /// Import a CSV file which contains Chapter Names\r
         /// </summary>\r
-        /// <param name="mainWindow"></param>\r
-        public DataGridView chapterNaming(DataGridView data_chpt, string chapter_start, string chapter_end)\r
+        /// <param name="dataChpt"></param>\r
+        /// <param name="filename"></param>\r
+        /// <returns></returns>\r
+        public static DataGridView importChapterNames(DataGridView dataChpt, string filename)\r
         {\r
+            IDictionary<int, string> chapterMap = new Dictionary<int, string>();\r
             try\r
             {\r
-                int i = 0;\r
-                int rowCount = 0;\r
-                int start = 0;\r
-                int finish = 0;\r
-                if (chapter_end != "Auto")\r
-                    finish = int.Parse(chapter_end);\r
-\r
-                if (chapter_start != "Auto")\r
-                    start = int.Parse(chapter_start);\r
-\r
-                rowCount = finish - (start - 1);\r
-\r
-                while (i < rowCount)\r
+                StreamReader sr = new StreamReader(filename);\r
+                string csv = sr.ReadLine();\r
+                while (csv != null)\r
                 {\r
-                    DataGridViewRow row = new DataGridViewRow();\r
-\r
-                    data_chpt.Rows.Insert(i, row);\r
-                    data_chpt.Rows[i].Cells[0].Value = (i + 1);\r
-                    data_chpt.Rows[i].Cells[1].Value = "Chapter " + (i + 1);\r
-                    i++;\r
+                    if (csv.Trim() != "")\r
+                    {\r
+                        string[] contents = csv.Split(',');\r
+                        int chapter;\r
+                        int.TryParse(contents[0], out chapter);\r
+                        chapterMap.Add(chapter, contents[1]);\r
+                    }\r
+                    csv = sr.ReadLine();\r
                 }\r
-                return data_chpt;\r
             }\r
-            catch (Exception exc)\r
+            catch (Exception)\r
             {\r
-                MessageBox.Show("chapterNaming() Error has occured: \n" + exc.ToString());\r
                 return null;\r
             }\r
+\r
+            foreach (DataGridViewRow item in dataChpt.Rows)\r
+            {\r
+                string name;\r
+                chapterMap.TryGetValue((int)item.Cells[0].Value, out name);\r
+                item.Cells[1].Value = name ?? "Chapter " + item.Cells[0].Value;\r
+            }\r
+\r
+            return dataChpt;\r
         }\r
 \r
         /// <summary>\r
         /// Function which generates the filename and path automatically based on \r
         /// the Source Name, DVD title and DVD Chapters\r
         /// </summary>\r
-        /// <param name="mainWindow"></param>\r
-        public string autoName(ComboBox drp_dvdtitle, string chapter_start, string chatper_end, string source, string dest, int format)\r
+        public static string autoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters)\r
         {\r
-\r
             string AutoNamePath = string.Empty;\r
-\r
-            if (drp_dvdtitle.Text != "Automatic")\r
+            if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
             {\r
-                // Todo: This code is a tad messy. Clean it up at some point.\r
-                // Get the Source Name\r
-                string[] sourceName = source.Split('\\');\r
-                source = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");\r
+                // Get the Source Name \r
+                string sourceName = mainWindow.SourceName;\r
 \r
                 // Get the Selected Title Number\r
-                string title = drp_dvdtitle.Text;\r
-                string[] titlesplit = title.Split(' ');\r
-                title = titlesplit[0];\r
+                string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');\r
+                string dvdTitle = titlesplit[0].Replace("Automatic", "");\r
 \r
                 // Get the Chapter Start and Chapter End Numbers\r
-                string cs = chapter_start;\r
-                string cf = chatper_end;\r
-\r
-                // Just incase the above are set to their default Automatic values, set the varible to ""\r
-                if (title == "Automatic")\r
-                    title = "";\r
-                if (cs == "Auto")\r
-                    cs = "";\r
-                if (cf == "Auto")\r
-                    cf = "";\r
-\r
-                // If both CS and CF are populated, set the dash varible\r
-                string dash = "";\r
-                if (cf != "Auto")\r
-                    dash = "-";\r
+                string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", "");\r
+                string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", "");\r
+                string combinedChapterTag = chapterStart;\r
+                if (chapterFinish != chapterStart && chapterFinish != "")\r
+                    combinedChapterTag = chapterStart + "-" + chapterFinish;\r
 \r
                 // Get the destination filename.\r
-                string destination_filename = "";\r
+                string destinationFilename;\r
                 if (Properties.Settings.Default.autoNameFormat != "")\r
                 {\r
-                    destination_filename = Properties.Settings.Default.autoNameFormat;\r
-                    destination_filename = destination_filename.Replace("{source}", source).Replace("{title}", title).Replace("{chapters}", cs + dash + cf);\r
+                    destinationFilename = Properties.Settings.Default.autoNameFormat;\r
+                    destinationFilename = destinationFilename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);\r
                 }\r
                 else\r
-                    destination_filename = source + "_T" + title + "_C" + cs + dash + cf;\r
+                    destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
 \r
-                // If the text box is blank\r
-                if (!dest.Contains("\\"))\r
+                // Add the appropriate file extension\r
+                if (mainWindow.drop_format.SelectedIndex == 0)\r
                 {\r
-                    string filePath = "";\r
-                    if (Properties.Settings.Default.autoNamePath.Trim() != "")\r
-                    {\r
-                        if (Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")\r
-                            filePath = Properties.Settings.Default.autoNamePath + "\\";\r
-                    }\r
+                    if (Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked || mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V())\r
+                        destinationFilename += ".m4v";\r
+                    else\r
+                        destinationFilename += ".mp4";\r
+                }\r
+                else if (mainWindow.drop_format.SelectedIndex == 1)\r
+                    destinationFilename += ".mkv";\r
 \r
-                    if (format == 0)\r
-                        AutoNamePath = filePath + destination_filename + ".mp4";\r
-                    else if (format == 1)\r
-                        AutoNamePath = filePath + destination_filename + ".m4v";\r
-                    else if (format == 2)\r
-                        AutoNamePath = filePath + destination_filename + ".mkv";\r
-                    else if (format == 3)\r
-                        AutoNamePath = filePath + destination_filename + ".avi";\r
-                    else if (format == 4)\r
-                        AutoNamePath = filePath + destination_filename + ".ogm";\r
+                // Now work out the path where the file will be stored.\r
+                // First case: If the destination box doesn't already contain a path, make one.\r
+                if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))\r
+                {\r
+                    // If there is an auto name path, use it...\r
+                    if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")\r
+                        AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);\r
+                    else // ...otherwise, output to the source directory\r
+                        AutoNamePath = null;\r
                 }\r
-                else // If the text box already has a path and file\r
+                else // Otherwise, use the path that is already there.\r
                 {\r
-                    string destination = AutoNamePath;\r
-                    string[] destName = dest.Split('\\');\r
-                    string[] extension = dest.Split('.');\r
-                    string ext = extension[extension.Length - 1];\r
+                    // Use the path and change the file extension to match the previous destination\r
+                    AutoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);\r
 \r
-                    destName[destName.Length - 1] = destination_filename + "." + ext;\r
-\r
-                    string fullDest = "";\r
-                    foreach (string part in destName)\r
-                    {\r
-                        if (fullDest != "")\r
-                            fullDest = fullDest + "\\" + part;\r
-                        else\r
-                            fullDest = fullDest + part;\r
-                    }\r
-                    return fullDest;\r
+                    if (Path.HasExtension(mainWindow.text_destination.Text))\r
+                        AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
                 }\r
             }\r
+\r
             return AutoNamePath;\r
         }\r
 \r
         /// <summary>\r
-        /// Checks for updates and returns true if an update is available.\r
+        /// Get's HandBrakes version data from the CLI.\r
         /// </summary>\r
-        /// <param name="debug">Turns on debug mode. Don't use on program startup</param>\r
-        /// <returns>Boolean True = Update available</returns>\r
-        public Boolean updateCheck(Boolean debug)\r
+        /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>\r
+        public static void setCliVersionData()\r
         {\r
+            String line;\r
+\r
+            // 0 = SVN Build / Version\r
+            // 1 = Build Date\r
+\r
+            DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");\r
+\r
+\r
+            if (Properties.Settings.Default.cliLastModified == lastModified && Properties.Settings.Default.hb_build != 0)\r
+                return;\r
+\r
+            Properties.Settings.Default.cliLastModified = lastModified;\r
+            \r
+            Process cliProcess = new Process();\r
+            ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")\r
+                                                {\r
+                                                    UseShellExecute = false,\r
+                                                    RedirectStandardError = true,\r
+                                                    RedirectStandardOutput = true,\r
+                                                    CreateNoWindow = true\r
+                                                };\r
+            cliProcess.StartInfo = handBrakeCLI;\r
+\r
             try\r
             {\r
-                Functions.AppcastReader rssRead = new Functions.AppcastReader();\r
-                rssRead.getInfo(); // Initializes the class.\r
-                string build = rssRead.build();\r
+                cliProcess.Start();\r
+                // Retrieve standard output and report back to parent thread until the process is complete\r
+                TextReader stdOutput = cliProcess.StandardError;\r
 \r
-                int latest = int.Parse(build);\r
-                int current = Properties.Settings.Default.hb_build;\r
-                int skip = Properties.Settings.Default.skipversion;\r
-\r
-                if (latest == skip)\r
-                    return false;\r
-                else\r
+                while (!cliProcess.HasExited)\r
                 {\r
-                    Boolean update = (latest > current);\r
-                    return update;\r
+                    line = stdOutput.ReadLine() ?? "";\r
+                    Match m = Regex.Match(line, @"HandBrake ([0-9.]*)(svn[0-9M]*) \([0-9]*\)");\r
+                    Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");\r
+\r
+                    if (m.Success)\r
+                    {\r
+                        string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
+                        string[] arr = data.Split(' ');\r
+\r
+                        Properties.Settings.Default.hb_build = int.Parse(arr[1]);\r
+                        Properties.Settings.Default.hb_version = arr[0];\r
+                    }\r
+                    if (platform.Success)\r
+                        Properties.Settings.Default.hb_platform = platform.Value.Replace("-", "").Trim();\r
+\r
+                    if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.\r
+                    {\r
+                        Process cli = Process.GetProcessById(cliProcess.Id);\r
+                        if (!cli.HasExited)\r
+                            cli.Kill();\r
+                    }\r
                 }\r
+                Properties.Settings.Default.Save();\r
             }\r
-            catch (Exception exc)\r
+            catch (Exception e)\r
             {\r
-                if (debug == true)\r
-                    MessageBox.Show("Unable to check for updates, Please try again later. \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Check if the queue recovery file contains records.\r
+        /// If it does, it means the last queue did not complete before HandBrake closed.\r
+        /// So, return a boolean if true. \r
+        /// </summary>\r
+        public static Boolean checkQueueRecovery()\r
+        {\r
+            try\r
+            {\r
+                string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
+                if (File.Exists(tempPath))\r
+                {\r
+                    using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
+                    {\r
+                        List<Job> list = ser.Deserialize(strm) as List<Job>;\r
+                        if (list != null)\r
+                            if (list.Count != 0)\r
+                                return true;\r
+                    }\r
+                }\r
                 return false;\r
             }\r
+            catch (Exception)\r
+            {\r
+                return false; // Keep quiet about the error.\r
+            }\r
         }\r
 \r
         /// <summary>\r
-        /// Get's HandBrakes version data from the CLI.\r
+        /// Get the Process ID of HandBrakeCLI for the current instance.\r
         /// </summary>\r
-        /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>\r
-        public ArrayList getCliVersionData()\r
+        /// <param name="before">List of processes before the new process was started</param>\r
+        /// <returns>Int - Process ID</returns>\r
+        public static int getCliProcess(Process[] before)\r
         {\r
-            ArrayList cliVersionData = new ArrayList();\r
-            // 0 = SVN Build / Version\r
-            // 1 = Build Date\r
+            // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.\r
+            // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.\r
+            // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe\r
+            // avoiding any previous instances of HandBrakeCLI.exe in before.\r
+            // Kill the current process.\r
 \r
-            Process cliProcess = new Process();\r
-            ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");\r
-            handBrakeCLI.UseShellExecute = false;\r
-            handBrakeCLI.RedirectStandardError = true;\r
-            handBrakeCLI.RedirectStandardOutput = true;\r
-            handBrakeCLI.CreateNoWindow = true;\r
-            cliProcess.StartInfo = handBrakeCLI;\r
-            cliProcess.Start();\r
+            DateTime startTime = DateTime.Now;\r
+            TimeSpan duration;\r
 \r
-            // Retrieve standard output and report back to parent thread until the process is complete\r
-            String line;\r
-            TextReader stdOutput = cliProcess.StandardError;\r
+            Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
+            while (hbProcesses.Length == 0)\r
+            {\r
+                hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
+                duration = DateTime.Now - startTime;\r
+                if (duration.Seconds > 5 && hbProcesses.Length == 0) // Make sure we don't wait forever if the process doesn't start\r
+                    return -1;\r
+            }\r
 \r
-            while (!cliProcess.HasExited)\r
+            Process hbProcess = null;\r
+            foreach (Process process in hbProcesses)\r
             {\r
-                line = stdOutput.ReadLine();\r
-                if (line == null) line = "";\r
-                Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");\r
+                Boolean found = false;\r
+                // Check if the current CLI instance was running before we started the current one\r
+                foreach (Process bprocess in before)\r
+                {\r
+                    if (process.Id == bprocess.Id)\r
+                        found = true;\r
+                }\r
 \r
-                if (m.Success != false)\r
+                // If it wasn't running before, we found the process we want.\r
+                if (!found)\r
                 {\r
-                    string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
-                    string[] arr = data.Split(' ');\r
-                    cliVersionData.Add(arr[0]);\r
-                    cliVersionData.Add(arr[1]);\r
-                    return cliVersionData;\r
+                    hbProcess = process;\r
+                    break;\r
                 }\r
             }\r
-            return null;\r
+            if (hbProcess != null)\r
+                return hbProcess.Id;\r
+\r
+            return -1;\r
         }\r
 \r
         /// <summary>\r
-        /// Check if the queue recovery file contains records.\r
-        /// If it does, it means the last queue did not complete before HandBrake closed.\r
-        /// So, return a boolean if true. \r
+        ///  Clear all the encode log files.\r
         /// </summary>\r
-        public Boolean check_queue_recovery()\r
+        public static void clearLogs()\r
         {\r
-            try\r
+            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+            if (Directory.Exists(logDir))\r
             {\r
-                string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
-                using (StreamReader reader = new StreamReader(tempPath))\r
+                DirectoryInfo info = new DirectoryInfo(logDir);\r
+                FileInfo[] logFiles = info.GetFiles("*.txt");\r
+                foreach (FileInfo file in logFiles)\r
                 {\r
-                    string queue_item = reader.ReadLine();\r
-                    if (queue_item == null)\r
-                    {\r
-                        reader.Close();\r
-                        reader.Dispose();\r
-                        return false;\r
-                    }\r
-                    else // There exists an item in the recovery queue file, so try and recovr it.\r
+                    if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") && !file.Name.Contains("tmp_appReadable_log.txt"))\r
+                        File.Delete(file.FullName);\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Begins checking for an update to HandBrake.\r
+        /// </summary>\r
+        /// <param name="callback">The method that will be called when the check is finished.</param>\r
+        /// <param name="debug">Whether or not to execute this in debug mode.</param>\r
+        public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)\r
+        {\r
+            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate\r
+            {\r
+                try\r
+                {\r
+                    // Is this a stable or unstable build?\r
+                    string url = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? Properties.Settings.Default.appcast_unstable : Properties.Settings.Default.appcast;\r
+\r
+                    // Initialize variables\r
+                    WebRequest request = WebRequest.Create(url);\r
+                    WebResponse response = request.GetResponse();\r
+                    AppcastReader reader = new AppcastReader();\r
+\r
+                    // Get the data, convert it to a string, and parse it into the AppcastReader\r
+                    reader.getInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
+\r
+                    // Further parse the information\r
+                    string build = reader.build;\r
+\r
+                    int latest = int.Parse(build);\r
+                    int current = Properties.Settings.Default.hb_build;\r
+                    int skip = Properties.Settings.Default.skipversion;\r
+\r
+                    // If the user wanted to skip this version, don't report the update\r
+                    if (latest == skip)\r
                     {\r
-                        reader.Close();\r
-                        reader.Dispose();\r
-                        return true;\r
+                        UpdateCheckInformation info = new UpdateCheckInformation() { NewVersionAvailable = false, BuildInformation = null };\r
+                        callback(new UpdateCheckResult(debug, info));\r
+                        return;\r
                     }\r
+\r
+                    // Set when the last update was\r
+                    Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
+                    Properties.Settings.Default.Save();\r
+\r
+                    UpdateCheckInformation info2 = new UpdateCheckInformation() { NewVersionAvailable = latest > current, BuildInformation = reader };\r
+                    callback(new UpdateCheckResult(debug, info2));\r
                 }\r
-            }\r
-            catch (Exception)\r
+                catch (Exception exc)\r
+                {\r
+                    callback(new UpdateCheckResult(debug, new UpdateCheckInformation() { Error = exc }));\r
+                }\r
+            }));\r
+        }\r
+\r
+        /// <summary>\r
+        /// \r
+        /// </summary>\r
+        /// <param name="result"></param>\r
+        /// <returns></returns>\r
+        public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)\r
+        {\r
+            UpdateCheckResult checkResult = (UpdateCheckResult)result;\r
+            return checkResult.Result;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Used in EndUpdateCheck() for update checking and the IAsyncResult design pattern.\r
+        /// </summary>\r
+        private class UpdateCheckResult : IAsyncResult\r
+        {\r
+            public UpdateCheckResult(object asyncState, UpdateCheckInformation info)\r
             {\r
-                // Keep quiet about the error.\r
-                return false;\r
+                AsyncState = asyncState;\r
+                Result = info;\r
             }\r
+\r
+            /// <summary>\r
+            /// Gets whether the check was executed in debug mode.\r
+            /// </summary>\r
+            public object AsyncState { get; private set; }\r
+\r
+            /// <summary>\r
+            /// Gets the result of the update check.\r
+            /// </summary>\r
+            public UpdateCheckInformation Result { get; private set; }\r
+\r
+            public WaitHandle AsyncWaitHandle { get { throw new NotImplementedException(); } }\r
+            public bool CompletedSynchronously { get { throw new NotImplementedException(); } }\r
+            public bool IsCompleted { get { throw new NotImplementedException(); } }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Map languages and their iso639_2 value into a IDictionary\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        public static IDictionary<string, string> mapLanguages()\r
+        {\r
+            IDictionary<string, string> languageMap = new Dictionary<string, string>\r
+                                                          {\r
+                                                              {"Any", "und"},\r
+                                                              {"Afar", "aar"},\r
+                                                              {"Abkhazian", "abk"},\r
+                                                              {"Afrikaans", "afr"},\r
+                                                              {"Akan", "aka"},\r
+                                                              {"Albanian", "sqi"},\r
+                                                              {"Amharic", "amh"},\r
+                                                              {"Arabic", "ara"},\r
+                                                              {"Aragonese", "arg"},\r
+                                                              {"Armenian", "hye"},\r
+                                                              {"Assamese", "asm"},\r
+                                                              {"Avaric", "ava"},\r
+                                                              {"Avestan", "ave"},\r
+                                                              {"Aymara", "aym"},\r
+                                                              {"Azerbaijani", "aze"},\r
+                                                              {"Bashkir", "bak"},\r
+                                                              {"Bambara", "bam"},\r
+                                                              {"Basque", "eus"},\r
+                                                              {"Belarusian", "bel"},\r
+                                                              {"Bengali", "ben"},\r
+                                                              {"Bihari", "bih"},\r
+                                                              {"Bislama", "bis"},\r
+                                                              {"Bosnian", "bos"},\r
+                                                              {"Breton", "bre"},\r
+                                                              {"Bulgarian", "bul"},\r
+                                                              {"Burmese", "mya"},\r
+                                                              {"Catalan", "cat"},\r
+                                                              {"Chamorro", "cha"},\r
+                                                              {"Chechen", "che"},\r
+                                                              {"Chinese", "zho"},\r
+                                                              {"Church Slavic", "chu"},\r
+                                                              {"Chuvash", "chv"},\r
+                                                              {"Cornish", "cor"},\r
+                                                              {"Corsican", "cos"},\r
+                                                              {"Cree", "cre"},\r
+                                                              {"Czech", "ces"},\r
+                                                              {"Dansk", "dan"},\r
+                                                              {"Divehi", "div"},\r
+                                                              {"Nederlands", "nld"},\r
+                                                              {"Dzongkha", "dzo"},\r
+                                                              {"English", "eng"},\r
+                                                              {"Esperanto", "epo"},\r
+                                                              {"Estonian", "est"},\r
+                                                              {"Ewe", "ewe"},\r
+                                                              {"Faroese", "fao"},\r
+                                                              {"Fijian", "fij"},\r
+                                                              {"Suomi", "fin"},\r
+                                                              {"Francais", "fra"},\r
+                                                              {"Western Frisian", "fry"},\r
+                                                              {"Fulah", "ful"},\r
+                                                              {"Georgian", "kat"},\r
+                                                              {"Deutsch", "deu"},\r
+                                                              {"Gaelic (Scots)", "gla"},\r
+                                                              {"Irish", "gle"},\r
+                                                              {"Galician", "glg"},\r
+                                                              {"Manx", "glv"},\r
+                                                              {"Greek Modern", "ell"},\r
+                                                              {"Guarani", "grn"},\r
+                                                              {"Gujarati", "guj"},\r
+                                                              {"Haitian", "hat"},\r
+                                                              {"Hausa", "hau"},\r
+                                                              {"Hebrew", "heb"},\r
+                                                              {"Herero", "her"},\r
+                                                              {"Hindi", "hin"},\r
+                                                              {"Hiri Motu", "hmo"},\r
+                                                              {"Magyar", "hun"},\r
+                                                              {"Igbo", "ibo"},\r
+                                                              {"Islenska", "isl"},\r
+                                                              {"Ido", "ido"},\r
+                                                              {"Sichuan Yi", "iii"},\r
+                                                              {"Inuktitut", "iku"},\r
+                                                              {"Interlingue", "ile"},\r
+                                                              {"Interlingua", "ina"},\r
+                                                              {"Indonesian", "ind"},\r
+                                                              {"Inupiaq", "ipk"},\r
+                                                              {"Italiano", "ita"},\r
+                                                              {"Javanese", "jav"},\r
+                                                              {"Japanese", "jpn"},\r
+                                                              {"Kalaallisut", "kal"},\r
+                                                              {"Kannada", "kan"},\r
+                                                              {"Kashmiri", "kas"},\r
+                                                              {"Kanuri", "kau"},\r
+                                                              {"Kazakh", "kaz"},\r
+                                                              {"Central Khmer", "khm"},\r
+                                                              {"Kikuyu", "kik"},\r
+                                                              {"Kinyarwanda", "kin"},\r
+                                                              {"Kirghiz", "kir"},\r
+                                                              {"Komi", "kom"},\r
+                                                              {"Kongo", "kon"},\r
+                                                              {"Korean", "kor"},\r
+                                                              {"Kuanyama", "kua"},\r
+                                                              {"Kurdish", "kur"},\r
+                                                              {"Lao", "lao"},\r
+                                                              {"Latin", "lat"},\r
+                                                              {"Latvian", "lav"},\r
+                                                              {"Limburgan", "lim"},\r
+                                                              {"Lingala", "lin"},\r
+                                                              {"Lithuanian", "lit"},\r
+                                                              {"Luxembourgish", "ltz"},\r
+                                                              {"Luba-Katanga", "lub"},\r
+                                                              {"Ganda", "lug"},\r
+                                                              {"Macedonian", "mkd"},\r
+                                                              {"Marshallese", "mah"},\r
+                                                              {"Malayalam", "mal"},\r
+                                                              {"Maori", "mri"},\r
+                                                              {"Marathi", "mar"},\r
+                                                              {"Malay", "msa"},\r
+                                                              {"Malagasy", "mlg"},\r
+                                                              {"Maltese", "mlt"},\r
+                                                              {"Moldavian", "mol"},\r
+                                                              {"Mongolian", "mon"},\r
+                                                              {"Nauru", "nau"},\r
+                                                              {"Navajo", "nav"},\r
+                                                              {"Ndebele, South", "nbl"},\r
+                                                              {"Ndebele, North", "nde"},\r
+                                                              {"Ndonga", "ndo"},\r
+                                                              {"Nepali", "nep"},\r
+                                                              {"Norwegian Nynorsk", "nno"},\r
+                                                              {"Norwegian BokmÃ¥l", "nob"},\r
+                                                              {"Norsk", "nor"},\r
+                                                              {"Chichewa; Nyanja", "nya"},\r
+                                                              {"Occitan", "oci"},\r
+                                                              {"Ojibwa", "oji"},\r
+                                                              {"Oriya", "ori"},\r
+                                                              {"Oromo", "orm"},\r
+                                                              {"Ossetian", "oss"},\r
+                                                              {"Panjabi", "pan"},\r
+                                                              {"Persian", "fas"},\r
+                                                              {"Pali", "pli"},\r
+                                                              {"Polish", "pol"},\r
+                                                              {"Portugues", "por"},\r
+                                                              {"Pushto", "pus"},\r
+                                                              {"Quechua", "que"},\r
+                                                              {"Romansh", "roh"},\r
+                                                              {"Romanian", "ron"},\r
+                                                              {"Rundi", "run"},\r
+                                                              {"Russian", "rus"},\r
+                                                              {"Sango", "sag"},\r
+                                                              {"Sanskrit", "san"},\r
+                                                              {"Serbian", "srp"},\r
+                                                              {"Hrvatski", "hrv"},\r
+                                                              {"Sinhala", "sin"},\r
+                                                              {"Slovak", "slk"},\r
+                                                              {"Slovenian", "slv"},\r
+                                                              {"Northern Sami", "sme"},\r
+                                                              {"Samoan", "smo"},\r
+                                                              {"Shona", "sna"},\r
+                                                              {"Sindhi", "snd"},\r
+                                                              {"Somali", "som"},\r
+                                                              {"Sotho Southern", "sot"},\r
+                                                              {"Espanol", "spa"},\r
+                                                              {"Sardinian", "srd"},\r
+                                                              {"Swati", "ssw"},\r
+                                                              {"Sundanese", "sun"},\r
+                                                              {"Swahili", "swa"},\r
+                                                              {"Svenska", "swe"},\r
+                                                              {"Tahitian", "tah"},\r
+                                                              {"Tamil", "tam"},\r
+                                                              {"Tatar", "tat"},\r
+                                                              {"Telugu", "tel"},\r
+                                                              {"Tajik", "tgk"},\r
+                                                              {"Tagalog", "tgl"},\r
+                                                              {"Thai", "tha"},\r
+                                                              {"Tibetan", "bod"},\r
+                                                              {"Tigrinya", "tir"},\r
+                                                              {"Tonga", "ton"},\r
+                                                              {"Tswana", "tsn"},\r
+                                                              {"Tsonga", "tso"},\r
+                                                              {"Turkmen", "tuk"},\r
+                                                              {"Turkish", "tur"},\r
+                                                              {"Twi", "twi"},\r
+                                                              {"Uighur", "uig"},\r
+                                                              {"Ukrainian", "ukr"},\r
+                                                              {"Urdu", "urd"},\r
+                                                              {"Uzbek", "uzb"},\r
+                                                              {"Venda", "ven"},\r
+                                                              {"Vietnamese", "vie"},\r
+                                                              {"Volapük", "vol"},\r
+                                                              {"Welsh", "cym"},\r
+                                                              {"Walloon", "wln"},\r
+                                                              {"Wolof", "wol"},\r
+                                                              {"Xhosa", "xho"},\r
+                                                              {"Yiddish", "yid"},\r
+                                                              {"Yoruba", "yor"},\r
+                                                              {"Zhuang", "zha"},\r
+                                                              {"Zulu", "zul"}\r
+                                                          };\r
+            return languageMap;\r
         }\r
 \r
     }\r
-}
\ No newline at end of file
+}\r
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
new file mode 100644 (file)
index 0000000..3018b91
--- /dev/null
@@ -0,0 +1,242 @@
+/*  PresetLoader.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Drawing;\r
+using System.Windows.Forms;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+    class PresetLoader\r
+    {\r
+        /// <summary>\r
+        /// This function takes in a Query which has been parsed by QueryParser and\r
+        /// set's all the GUI widgets correctly.\r
+        /// </summary>\r
+        /// <param name="mainWindow"></param>\r
+        /// <param name="presetQuery">The Parsed CLI Query</param>\r
+        /// <param name="name">Name of the preset</param>\r
+        /// <param name="pictureSettings">Save picture settings in the preset</param>\r
+        public static void presetLoader(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)\r
+        {\r
+            // ---------------------------\r
+            // Setup the GUI\r
+            // ---------------------------\r
+\r
+            #region Source\r
+            // Reset some vaules to stock first to prevent errors.\r
+            mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
+\r
+            // Now load all the new settings onto the main window\r
+            if (presetQuery.Format != null)\r
+            {\r
+                string destination = mainWindow.text_destination.Text;\r
+                destination = destination.Replace(".mp4", "." + presetQuery.Format);\r
+                destination = destination.Replace(".m4v", "." + presetQuery.Format);\r
+                destination = destination.Replace(".mkv", "." + presetQuery.Format);\r
+                mainWindow.text_destination.Text = destination;\r
+            }\r
+\r
+            #endregion\r
+\r
+            #region Destination and Output Settings\r
+\r
+            if (presetQuery.Format != null)\r
+            {\r
+                if (presetQuery.Format == "mp4" || presetQuery.Format == "m4v")\r
+                {\r
+                    if (mainWindow.drop_format.SelectedIndex == 0)\r
+                        mainWindow.SetExtension(".mp4");\r
+                    else \r
+                        mainWindow.drop_format.SelectedIndex = 0;\r
+                }\r
+                else if (presetQuery.Format == "mkv")\r
+                {\r
+                    if(mainWindow.drop_format.SelectedIndex == 1)\r
+                        mainWindow.SetExtension(".mkv");\r
+                    else\r
+                        mainWindow.drop_format.SelectedIndex = 1;\r
+                }\r
+            }\r
+\r
+            mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            mainWindow.check_largeFile.CheckState = presetQuery.LargeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            mainWindow.setContainerOpts(); // select the container options according to the selected format\r
+\r
+            #endregion\r
+\r
+            #region Picture\r
+            mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
+            if (pictureSettings) // only Load picture settings if the perset requires it\r
+            {\r
+                if (presetQuery.CropValues != null)\r
+                {\r
+                    int top, bottom, left, right;\r
+                    int.TryParse(presetQuery.CropTop, out top);\r
+                    int.TryParse(presetQuery.CropBottom, out bottom);\r
+                    int.TryParse(presetQuery.CropLeft, out left);\r
+                    int.TryParse(presetQuery.CropRight, out right);\r
+\r
+                    mainWindow.PictureSettings.check_customCrop.Checked = true;\r
+                    mainWindow.PictureSettings.crop_top.Value = top;\r
+                    mainWindow.PictureSettings.crop_bottom.Value = bottom;\r
+                    mainWindow.PictureSettings.crop_left.Value = left;\r
+                    mainWindow.PictureSettings.crop_right.Value = right;\r
+                }\r
+            }\r
+            \r
+            // Set the anamorphic mode 0,1,2,3\r
+            mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
+\r
+            // Aspect Ratio\r
+            mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;\r
+                \r
+            // Set the Width and height as Required.\r
+            if (presetQuery.Width != 0)\r
+                mainWindow.PictureSettings.text_width.Value = presetQuery.Width;\r
+\r
+            if (presetQuery.Height != 0)\r
+                mainWindow.PictureSettings.text_height.Value = presetQuery.Height;\r
+\r
+            // Max Width/Height override Width/Height\r
+            if (presetQuery.MaxWidth != 0)\r
+                mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth;\r
+\r
+            if (presetQuery.MaxHeight != 0)\r
+                mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight;\r
+\r
+            mainWindow.PictureSettings.PresetMaximumResolution = new Size(presetQuery.MaxWidth, presetQuery.MaxHeight);\r
+\r
+            // Case where both height and max height are 0 - For built-in presets\r
+            if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0)\r
+                mainWindow.PictureSettings.text_height.Value = 0;\r
+\r
+            if (presetQuery.MaxWidth == 0 && presetQuery.Width == 0)\r
+                if (mainWindow.selectedTitle != null && mainWindow.selectedTitle.Resolution.Width != 0)\r
+                    mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width;\r
+\r
+            // Custom Anamorphic Controls\r
+            mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.displayWidthValue.ToString();\r
+            mainWindow.PictureSettings.updownParHeight.Text = presetQuery.pixelAspectWidth.ToString();\r
+            mainWindow.PictureSettings.updownParWidth.Text = presetQuery.pixelAspectHeight.ToString();\r
+            mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
+\r
+            #endregion\r
+\r
+            #region Filters\r
+            mainWindow.Filters.setDecomb(presetQuery.Decomb);\r
+            mainWindow.Filters.setDeInterlace(presetQuery.DeInterlace);\r
+            mainWindow.Filters.setDeNoise(presetQuery.DeNoise);\r
+            mainWindow.Filters.setDeTelecine(presetQuery.DeTelecine);\r
+            mainWindow.Filters.setDeBlock(presetQuery.DeBlock);\r
+            mainWindow.Filters.setGrayScale(presetQuery.Grayscale);\r
+            #endregion\r
+\r
+            #region Video\r
+            mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
+\r
+            if (presetQuery.AverageVideoBitrate != null)\r
+            {\r
+                mainWindow.radio_avgBitrate.Checked = true;\r
+                mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate;\r
+            }\r
+            if (presetQuery.VideoTargetSize != null)\r
+            {\r
+                mainWindow.radio_targetFilesize.Checked = true;\r
+                mainWindow.text_filesize.Text = presetQuery.VideoTargetSize;\r
+            }\r
+\r
+            // Quality\r
+            if (presetQuery.VideoQuality != 0)\r
+            {\r
+                mainWindow.radio_cq.Checked = true;\r
+                if (presetQuery.VideoEncoder == "H.264 (x264)")\r
+                {\r
+                    double cqStep = Properties.Settings.Default.x264cqstep;\r
+                    int value;\r
+                    double x264step = cqStep;\r
+                    double presetValue = presetQuery.VideoQuality;\r
+\r
+                    double x = 51 / x264step;\r
+\r
+                    double calculated = presetValue / x264step;\r
+                    calculated = x - calculated;\r
+\r
+                    int.TryParse(calculated.ToString(), out value);\r
+\r
+                    // This will sometimes occur when the preset was generated \r
+                    // with a different granularity, so, round and try again.\r
+                    if (value == 0)\r
+                    {\r
+                        double val = Math.Round(calculated, 0);\r
+                        int.TryParse(val.ToString(), out value);\r
+                    }\r
+                    if (value < mainWindow.slider_videoQuality.Maximum)\r
+                        mainWindow.slider_videoQuality.Value = value;\r
+                }\r
+                else\r
+                {\r
+                    int presetVal;\r
+                    int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal);\r
+                    mainWindow.slider_videoQuality.Value = presetVal;\r
+                }\r
+            }\r
+\r
+            mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
+\r
+            mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            #endregion\r
+\r
+            #region Chapter Markers\r
+\r
+            if (presetQuery.ChapterMarkers)\r
+            {\r
+                mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;\r
+                mainWindow.Check_ChapterMarkers.Enabled = true;\r
+            }\r
+            else\r
+                mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;\r
+\r
+            #endregion\r
+\r
+            #region Audio\r
+            // Clear the audio listing\r
+            mainWindow.AudioSettings.ClearAudioList();\r
+\r
+            if (presetQuery.AudioInformation != null)\r
+                foreach (AudioTrack track in presetQuery.AudioInformation)\r
+                {\r
+                    ListViewItem newTrack = new ListViewItem(mainWindow.AudioSettings.GetNewID().ToString());\r
+\r
+                    newTrack.SubItems.Add("Automatic");\r
+                    newTrack.SubItems.Add(track.Encoder);\r
+                    newTrack.SubItems.Add(track.MixDown);\r
+                    newTrack.SubItems.Add(track.SampleRate);\r
+                    if (track.Encoder.Contains("AC3"))\r
+                        newTrack.SubItems.Add("Auto");\r
+                    else\r
+                        newTrack.SubItems.Add(track.Bitrate);\r
+                    newTrack.SubItems.Add(track.DRC);\r
+                    mainWindow.AudioSettings.AddTrackForPreset(newTrack);\r
+                }\r
+            #endregion\r
+\r
+            #region Other\r
+            mainWindow.x264Panel.x264Query = presetQuery.H264Query;\r
+\r
+            // Set the preset name\r
+            mainWindow.labelPreset.Text = "Output Settings (Preset: " + name + ")";\r
+            #endregion\r
+        }\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
new file mode 100644 (file)
index 0000000..7491036
--- /dev/null
@@ -0,0 +1,594 @@
+/*  QueryGenerator.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr/>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
+using System.Windows.Forms;\r
+using System.Globalization;\r
+using System.IO;\r
+using System.Collections.Generic;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+    class QueryGenerator\r
+    {\r
+        /// <summary>\r
+        /// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.\r
+        /// </summary>\r
+        /// <param name="mainWindow"></param>\r
+        /// <param name="duration"></param>\r
+        /// <param name="preview"></param>\r
+        /// <returns></returns>\r
+        public string GenerateCLIQuery(frmMain mainWindow, int duration, string preview)\r
+        {\r
+            string query = "";\r
+\r
+            if (!string.IsNullOrEmpty(mainWindow.sourcePath))\r
+                if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")\r
+                    query = " -i " + '"' + mainWindow.sourcePath + '"';\r
+\r
+            if (mainWindow.drp_dvdtitle.Text != "")\r
+            {\r
+                string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');\r
+                query += " -t " + titleInfo[0];\r
+            }\r
+\r
+            if (!Properties.Settings.Default.noDvdNav)\r
+                if (mainWindow.drop_angle.Items.Count != 0)\r
+                    query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
+\r
+\r
+            if (duration != 0 && preview != null) // Preivew Query\r
+            {\r
+                query += " --start-at-preview " + preview;\r
+                query += " --stop-at duration:" + duration + " ";\r
+\r
+                if (mainWindow.text_destination.Text != "")\r
+                    query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';\r
+            }\r
+            else // Non Preview Query\r
+            {\r
+                if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")\r
+                    query += " -c " + mainWindow.drop_chapterStart.Text;\r
+                else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")\r
+                    query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;\r
+                else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")\r
+                    query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;\r
+\r
+                if (mainWindow.text_destination.Text != "")\r
+                    query += " -o " + '"' + mainWindow.text_destination.Text + '"';\r
+            }\r
+\r
+            query += GenerateTabbedComponentsQuery(mainWindow);\r
+\r
+            return query;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Generates part of the CLI query, for the tabbed components only.\r
+        /// </summary>\r
+        /// <param name="mainWindow"></param>\r
+        /// <returns></returns>\r
+        public static string GenerateTabbedComponentsQuery(frmMain mainWindow)\r
+        {\r
+            string query = "";\r
+\r
+            #region Output Settings Box\r
+            query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", "");\r
+\r
+            // These are output settings features\r
+            if (mainWindow.check_largeFile.Checked)\r
+                query += " -4 ";\r
+\r
+            if (mainWindow.check_iPodAtom.Checked)\r
+                query += " -I ";\r
+\r
+            if (mainWindow.check_optimiseMP4.Checked)\r
+                query += " -O ";\r
+            #endregion\r
+\r
+            #region Picture Settings Tab\r
+\r
+            // Use MaxWidth for built-in presets and width for user settings.\r
+            if (mainWindow.PictureSettings.PresetMaximumResolution.Width == 0)\r
+            {\r
+                if (mainWindow.PictureSettings.text_width.Value != 0)\r
+                    if (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex != 1) // Prevent usage for strict anamorphic\r
+                        query += " -w " + mainWindow.PictureSettings.text_width.Text;\r
+            }\r
+            else\r
+            {\r
+                if (mainWindow.PictureSettings.text_width.Value != 0)\r
+                    if (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex != 1)\r
+                        query += " -X " + mainWindow.PictureSettings.text_width.Text;\r
+            }\r
+\r
+            // Use MaxHeight for built-in presets and height for user settings.\r
+            if (mainWindow.PictureSettings.PresetMaximumResolution.Height == 0)\r
+            {\r
+                if (mainWindow.PictureSettings.text_height.Value != 0)\r
+                    if (mainWindow.PictureSettings.text_height.Text != "")\r
+                        if (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 0 || mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 3) // Prevent usage for strict anamorphic\r
+                            query += " -l " + mainWindow.PictureSettings.text_height.Text;\r
+            }\r
+            else\r
+            {\r
+                if (mainWindow.PictureSettings.text_height.Value != 0)\r
+                    if (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 0 || mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 3)\r
+                        query += " -Y " + mainWindow.PictureSettings.text_height.Text;\r
+            }\r
+\r
+            string cropTop = mainWindow.PictureSettings.crop_top.Text;\r
+            string cropBottom = mainWindow.PictureSettings.crop_bottom.Text;\r
+            string cropLeft = mainWindow.PictureSettings.crop_left.Text;\r
+            string cropRight = mainWindow.PictureSettings.crop_right.Text;\r
+\r
+            if (mainWindow.PictureSettings.check_customCrop.Checked)\r
+            {\r
+                if (mainWindow.PictureSettings.crop_top.Text == string.Empty)\r
+                    cropTop = "0";\r
+                if (mainWindow.PictureSettings.crop_bottom.Text == string.Empty)\r
+                    cropBottom = "0";\r
+                if (mainWindow.PictureSettings.crop_left.Text == string.Empty)\r
+                    cropLeft = "0";\r
+                if (mainWindow.PictureSettings.crop_right.Text == string.Empty)\r
+                    cropRight = "0";\r
+\r
+                query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
+            }\r
+\r
+            switch (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex)\r
+            {\r
+                case 1:\r
+                    query += " --strict-anamorphic ";\r
+                    break;\r
+                case 2:\r
+                    query += " --loose-anamorphic ";\r
+                    break;\r
+                case 3:\r
+                    query += " --custom-anamorphic ";\r
+\r
+                    if (mainWindow.PictureSettings.drp_modulus.SelectedIndex != 0)\r
+                        query += " --modulus " + mainWindow.PictureSettings.drp_modulus.SelectedItem;\r
+\r
+                    if (mainWindow.PictureSettings.check_KeepAR.Checked)\r
+                        query += " --display-width " + mainWindow.PictureSettings.updownDisplayWidth.Text + " ";\r
+\r
+                    if (mainWindow.PictureSettings.check_KeepAR.Checked)\r
+                        query += " --keep-display-aspect ";\r
+\r
+                    if (!mainWindow.PictureSettings.check_KeepAR.Checked)\r
+                        if (mainWindow.PictureSettings.updownParWidth.Text != "" && mainWindow.PictureSettings.updownParHeight.Text != "")\r
+                            query += " --pixel-aspect " + mainWindow.PictureSettings.updownParWidth.Text + ":" + mainWindow.PictureSettings.updownParHeight.Text + " ";\r
+                    break;\r
+            }\r
+            #endregion\r
+\r
+            #region Filters\r
+            query += mainWindow.Filters.getCLIQuery;\r
+            #endregion\r
+\r
+            #region Video Settings Tab\r
+\r
+            switch (mainWindow.drp_videoEncoder.Text)\r
+            {\r
+                case "MPEG-4 (FFmpeg)":\r
+                    query += " -e ffmpeg";\r
+                    break;\r
+                case "H.264 (x264)":\r
+                    query += " -e x264";\r
+                    break;\r
+                case "VP3 (Theora)":\r
+                    query += " -e theora";\r
+                    break;\r
+                default:\r
+                    query += " -e x264";\r
+                    break;\r
+            }\r
+\r
+            // Video Settings\r
+            if (mainWindow.radio_avgBitrate.Checked)\r
+                query += " -b " + mainWindow.text_bitrate.Text;\r
+\r
+            if (mainWindow.radio_targetFilesize.Checked)\r
+                query += " -S " + mainWindow.text_filesize.Text;\r
+\r
+            // Video Quality Setting\r
+            if (mainWindow.radio_cq.Checked)\r
+            {\r
+                double cqStep = Properties.Settings.Default.x264cqstep;\r
+                double value;\r
+                switch (mainWindow.drp_videoEncoder.Text)\r
+                {\r
+                    case "MPEG-4 (FFmpeg)":\r
+                        value = 31 - (mainWindow.slider_videoQuality.Value - 1);\r
+                        query += " -q " + value.ToString(new CultureInfo("en-US"));\r
+                        break;\r
+                    case "H.264 (x264)":\r
+                        CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");\r
+                        value = 51 - mainWindow.slider_videoQuality.Value * cqStep;\r
+                        value = Math.Round(value, 2);\r
+                        query += " -q " + value.ToString(culture);\r
+                        break;\r
+                    case "VP3 (Theora)":\r
+                        value = mainWindow.slider_videoQuality.Value;\r
+                        query += " -q " + value.ToString(new CultureInfo("en-US"));\r
+                        break;\r
+                }\r
+            }\r
+\r
+            if (mainWindow.check_2PassEncode.Checked)\r
+                query += " -2 ";\r
+\r
+            if (mainWindow.check_turbo.Checked)\r
+                query += " -T ";\r
+\r
+            if (mainWindow.drp_videoFramerate.Text != "Same as source")\r
+                query += " -r " + mainWindow.drp_videoFramerate.Text;\r
+            #endregion\r
+\r
+            #region Audio Settings Tab\r
+\r
+            ListView audioTracks = mainWindow.AudioSettings.GetAudioPanel();\r
+            List<string> tracks = new List<string>();\r
+            List<string> codecs = new List<string>();\r
+            List<string> mixdowns = new List<string>();\r
+            List<string> samplerates = new List<string>();\r
+            List<string> bitrates = new List<string>();\r
+            List<string> drcs = new List<string>();\r
+\r
+            // No Audio\r
+            if (audioTracks.Items.Count == 0)\r
+                query += " -a none ";\r
+\r
+            // Gather information about each audio track and store them in the declared lists.\r
+            foreach (ListViewItem row in audioTracks.Items)\r
+            {\r
+                // Audio Track (-a)\r
+                if (row.SubItems[1].Text == "Automatic")\r
+                    tracks.Add("1");\r
+                else if (row.Text != "None")\r
+                {\r
+                    string[] tempSub = row.SubItems[1].Text.Split(' ');\r
+                    tracks.Add(tempSub[0]);\r
+                }\r
+\r
+                // Audio Codec (-E)\r
+                if (row.SubItems[2].Text != String.Empty)\r
+                    codecs.Add(getAudioEncoder(row.SubItems[2].Text));\r
+\r
+                // Audio Mixdown (-6)\r
+                if (row.SubItems[3].Text != String.Empty)\r
+                    mixdowns.Add(getMixDown(row.SubItems[3].Text));\r
+\r
+                // Sample Rate (-R)\r
+                if (row.SubItems[4].Text != String.Empty)\r
+                    samplerates.Add(row.SubItems[4].Text.Replace("Auto", "Auto"));\r
+\r
+                // Audio Bitrate (-B)\r
+                if (row.SubItems[5].Text != String.Empty)\r
+                    bitrates.Add(row.SubItems[5].Text.Replace("Auto", "auto"));\r
+\r
+                // DRC (-D)\r
+                if (row.SubItems[6].Text != String.Empty)\r
+                    drcs.Add(row.SubItems[6].Text);\r
+            }\r
+\r
+            // Audio Track (-a)\r
+            String audioItems = "";\r
+            Boolean firstLoop = true;\r
+\r
+            foreach (String item in tracks)\r
+            {\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -a " + audioItems;\r
+            firstLoop = true; audioItems = ""; // Reset for another pass.\r
+\r
+            // Audio Codec (-E)\r
+            foreach (String item in codecs)\r
+            {\r
+\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -E " + audioItems;\r
+            firstLoop = true; audioItems = ""; // Reset for another pass.\r
+\r
+            // Audio Mixdown (-6)\r
+            foreach (String item in mixdowns)\r
+            {\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -6 " + audioItems;\r
+            firstLoop = true; audioItems = ""; // Reset for another pass.\r
+\r
+            // Sample Rate (-R)\r
+            foreach (String item in samplerates)\r
+            {\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -R " + audioItems;\r
+            firstLoop = true; audioItems = ""; // Reset for another pass.\r
+\r
+            // Audio Bitrate (-B)\r
+            foreach (String item in bitrates)\r
+            {\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -B " + audioItems;\r
+            firstLoop = true; audioItems = ""; // Reset for another pass.\r
+\r
+            // DRC (-D)\r
+            foreach (var itm in drcs)\r
+            {\r
+                string item = itm.ToString(new CultureInfo("en-US"));\r
+                if (firstLoop)\r
+                {\r
+                    audioItems = item; firstLoop = false;\r
+                }\r
+                else\r
+                    audioItems += "," + item;\r
+            }\r
+            if (audioItems.Trim() != String.Empty)\r
+                query += " -D " + audioItems;\r
+\r
+            #endregion\r
+\r
+            #region Subtitles Tab\r
+            if (mainWindow.Subtitles.lv_subList.Items.Count != 0) // If we have subtitle tracks\r
+            {\r
+                IDictionary<string, string> langMap = Main.mapLanguages();\r
+\r
+                // BitMap and CC's\r
+                string subtitleTracks = String.Empty;\r
+                string subtitleForced = String.Empty;\r
+                string subtitleBurn = String.Empty;\r
+                string subtitleDefault = String.Empty;\r
\r
+                // SRT\r
+                string srtFile = String.Empty;\r
+                string srtCodeset = String.Empty;\r
+                string srtOffset = String.Empty;\r
+                string srtLang = String.Empty;\r
+                string srtDefault = String.Empty;\r
+                int srtCount = 0;\r
+\r
+                List<Controls.SubtitleInfo> SubList = mainWindow.Subtitles.GetSubtitleInfoList();\r
+\r
+                foreach (var item in SubList)\r
+                {\r
+                    string itemToAdd, trackID;\r
+\r
+                    if (item.SrtPath != "-") // We have an SRT file\r
+                    {\r
+                        srtCount++; // SRT track id.\r
+\r
+                        srtLang += srtLang == "" ? langMap[item.SrtLang] : "," + langMap[item.SrtLang];\r
+                        srtCodeset += srtCodeset == "" ? item.SrtCharCode : "," + item.SrtCharCode;\r
+\r
+                        if (item.Default == "Yes") // default\r
+                            srtDefault = srtCount.ToString();\r
+\r
+                        itemToAdd = item.SrtPath;\r
+                        srtFile += srtFile == "" ? itemToAdd : "," + itemToAdd;\r
+\r
+                        itemToAdd = item.SrtOffset.ToString();\r
+                        srtOffset += srtOffset == "" ? itemToAdd : "," + itemToAdd;\r
+                    }\r
+                    else // We have Bitmap or CC\r
+                    {\r
+                        string[] tempSub;\r
+\r
+                        // Find --subtitle <string>\r
+                        if (item.Track.Contains("Foreign Audio Search"))\r
+                            itemToAdd = "scan";\r
+                        else\r
+                        {\r
+                            tempSub = item.Track.Split(' ');\r
+                            itemToAdd = tempSub[0];\r
+                        }\r
+\r
+                        subtitleTracks += subtitleTracks == "" ? itemToAdd : "," + itemToAdd;\r
+\r
+                        // Find --subtitle-forced\r
+                        itemToAdd = "";\r
+                        tempSub = item.Track.Split(' ');\r
+                        trackID = tempSub[0];\r
+\r
+                        if (item.Forced == "Yes")\r
+                            itemToAdd = trackID;\r
+\r
+                        if (itemToAdd != "")\r
+                            subtitleForced += subtitleForced == "" ? itemToAdd : "," + itemToAdd;\r
+\r
+                        // Find --subtitle-burn and --subtitle-default\r
+                        trackID = tempSub[0];\r
+\r
+                        if (trackID.Trim() == "Foreign")\r
+                            trackID = "scan";\r
+\r
+                        if (item.Burned == "Yes") // burn\r
+                            subtitleBurn = trackID;\r
+\r
+                        if (item.Default == "Yes") // default\r
+                            subtitleDefault = trackID;\r
+                    }\r
+                }\r
+\r
+                // Build The CLI Subtitles Query\r
+                if (subtitleTracks != "")\r
+                {\r
+                    query += " --subtitle " + subtitleTracks;\r
+\r
+                    if (subtitleForced != "")\r
+                        query += " --subtitle-forced=" + subtitleForced;\r
+                    if (subtitleBurn != "")\r
+                        query += " --subtitle-burn=" + subtitleBurn;\r
+                    if (subtitleDefault != "")\r
+                        query += " --subtitle-default=" + subtitleDefault;\r
+                }\r
+\r
+                if (srtFile != "") // SRTs\r
+                {\r
+                    query += " --srt-file " + "\"" + srtFile + "\"";\r
+\r
+                    if (srtCodeset != "")\r
+                        query += " --srt-codeset " + srtCodeset;\r
+                    if (srtOffset != "")\r
+                        query += " --srt-offset " + srtOffset;\r
+                    if (srtLang != "")\r
+                        query += " --srt-lang " + srtLang;\r
+                    if (srtDefault != "")\r
+                        query += " --srt-default=" + srtDefault;\r
+                }\r
+\r
+            }\r
+            #endregion\r
+\r
+            #region Chapter Markers\r
+\r
+            // Attach Source name and dvd title to the start of the chapters.csv filename.\r
+            // This is for the queue. It allows different chapter name files for each title.\r
+            string[] destName = mainWindow.text_destination.Text.Split('\\');\r
+            string dest_name = destName[destName.Length - 1];\r
+            dest_name = dest_name.Replace("\"", "");\r
+            dest_name = dest_name.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "");\r
+\r
+            string source_title = mainWindow.drp_dvdtitle.Text;\r
+            string[] titlesplit = source_title.Split(' ');\r
+            source_title = titlesplit[0];\r
+\r
+            if (mainWindow.Check_ChapterMarkers.Checked && mainWindow.Check_ChapterMarkers.Enabled)\r
+            {\r
+                if (dest_name.Trim() != String.Empty)\r
+                {\r
+                    string path = source_title != "Automatic"\r
+                                      ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv")\r
+                                      : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");\r
+\r
+                    if (chapterCSVSave(mainWindow, path) == false)\r
+                        query += " -m ";\r
+                    else\r
+                        query += " --markers=" + "\"" + path + "\"";\r
+                }\r
+                else\r
+                    query += " -m";\r
+            }\r
+            #endregion\r
+\r
+            #region  H264 Tab\r
+            if (mainWindow.x264Panel.x264Query != "")\r
+                query += " -x " + mainWindow.x264Panel.x264Query;\r
+            #endregion\r
+\r
+            #region Processors / Other\r
+            string processors = Properties.Settings.Default.Processors;\r
+            if (processors != "Automatic")\r
+                query += " -C " + processors + " ";\r
+\r
+            query += " -v " + Properties.Settings.Default.verboseLevel;\r
+\r
+            if (Properties.Settings.Default.noDvdNav)\r
+                query += " --no-dvdnav";\r
+            #endregion\r
+\r
+            return query;\r
+        }\r
+\r
+        private static string getMixDown(string selectedAudio)\r
+        {\r
+            switch (selectedAudio)\r
+            {\r
+                case "Automatic":\r
+                    return "auto";\r
+                case "Mono":\r
+                    return "mono";\r
+                case "Stereo":\r
+                    return "stereo";\r
+                case "Dolby Surround":\r
+                    return "dpl1";\r
+                case "Dolby Pro Logic II":\r
+                    return "dpl2";\r
+                case "6 Channel Discrete":\r
+                    return "6ch";\r
+                default:\r
+                    return "auto";\r
+            }\r
+        }\r
+        private static string getAudioEncoder(string selectedEncoder)\r
+        {\r
+            switch (selectedEncoder)\r
+            {\r
+                case "AAC (faac)":\r
+                    return "faac";\r
+                case "MP3 (lame)":\r
+                    return "lame";\r
+                case "Vorbis (vorbis)":\r
+                    return "vorbis";\r
+                case "AC3 Passthru":\r
+                    return "ac3";\r
+                case "DTS Passthru":\r
+                    return "dts";\r
+                default:\r
+                    return "";\r
+            }\r
+        }\r
+        private static Boolean chapterCSVSave(frmMain mainWindow, string filePathName)\r
+        {\r
+            try\r
+            {\r
+                string csv = "";\r
+\r
+                foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)\r
+                {\r
+                    csv += row.Cells[0].Value.ToString();\r
+                    csv += ",";\r
+                    csv += row.Cells[1].Value.ToString();\r
+                    csv += Environment.NewLine;\r
+                }\r
+                StreamWriter file = new StreamWriter(filePathName);\r
+                file.Write(csv);\r
+                file.Close();\r
+                file.Dispose();\r
+                return true;\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                return false;\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 3e8b18e..7230ad9 100644 (file)
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
+using System.Globalization;\r
 using System.Text.RegularExpressions;\r
 using System.Windows.Forms;\r
+using System.Collections;\r
 \r
 namespace Handbrake.Functions\r
 {\r
-    class QueryParser\r
+    internal class QueryParser\r
     {\r
+        private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
 \r
-        // All the Main Window GUI options\r
         #region Varibles\r
 \r
-        #region Source\r
-\r
-        private string q_source;\r
-        /// <summary>\r
-        /// Returns a String \r
-        /// Full path of the source.\r
-        /// </summary>\r
-        public string Source\r
-        {\r
-            get\r
-            {\r
-                return this.q_source;\r
-            }\r
-        }\r
-\r
-        private int q_dvdTitle;\r
-        /// <summary>\r
-        /// Returns an Integer\r
-        /// DVD Title number.\r
-        /// </summary>\r
-        public int DVDTitle\r
-        {\r
-            get\r
-            {\r
-                return this.q_dvdTitle;\r
-            }\r
-        }\r
-\r
-        private int q_chaptersStart;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// DVD Chapter number or chapter range.\r
-        /// </summary>\r
-        public int DVDChapterStart\r
-        {\r
-            get\r
-            {\r
-                return this.q_chaptersStart;\r
-            }\r
-        }\r
-\r
-        private int q_chaptersFinish;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// DVD Chapter number or chapter range.\r
-        /// </summary>\r
-        public int DVDChapterFinish\r
-        {\r
-            get\r
-            {\r
-                return this.q_chaptersFinish;\r
-            }\r
-        }\r
-#endregion\r
-\r
-        #region Destination\r
-\r
-        private string q_destination;\r
-        /// <summary>\r
-        /// Returns a String \r
-        /// Full path of the destination.\r
-        /// </summary>\r
-        public string Destination\r
-        {\r
-            get\r
-            {\r
-                return this.q_destination;\r
-            }\r
-        }\r
-\r
-        private string q_format;\r
-        /// <summary>\r
-        /// Returns a String \r
-        /// Full path of the destination.\r
-        /// </summary>\r
-        public string Format\r
-        {\r
-            get\r
-            {\r
-                return this.q_format;\r
-            }\r
-        }\r
-\r
-        private string q_videoEncoder;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// The Video Encoder used.\r
-        /// </summary>\r
-        public string VideoEncoder\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoEncoder;\r
-            }\r
-        }\r
-        #endregion\r
-\r
-        #region Picture Settings\r
-        private int q_videoWidth;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// The selected Width for the encoding.\r
-        /// </summary>\r
-        public int Width\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoWidth;\r
-            }\r
-        }\r
-\r
-        private int q_videoHeight;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// The selected Height for the encoding.\r
-        /// </summary>\r
-        public int Height\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoHeight;\r
-            }\r
-        }\r
-\r
-        private int q_maxWidth;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// The selected Width for the encoding.\r
-        /// </summary>\r
-        public int MaxWidth\r
-        {\r
-            get\r
-            {\r
-                return this.q_maxWidth;\r
-            }\r
-        }\r
-\r
-        private int q_maxHeight;\r
-        /// <summary>\r
-        /// Returns an Int\r
-        /// The selected Height for the encoding.\r
-        /// </summary>\r
-        public int MaxHeight\r
-        {\r
-            get\r
-            {\r
-                return this.q_maxHeight;\r
-            }\r
-        }\r
-\r
-        private string q_cropValues;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// Cropping values.\r
-        /// </summary>\r
-        public string CropValues\r
-        {\r
-            get\r
-            {\r
-                return this.q_cropValues;\r
-            }\r
-        }\r
-\r
-        private string q_croptop;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// Cropping values.\r
-        /// </summary>\r
-        public string CropTop\r
-        {\r
-            get\r
-            {\r
-                return this.q_croptop;\r
-            }\r
-        }\r
-\r
-        private string q_cropbottom;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// Cropping values.\r
-        /// </summary>\r
-        public string CropBottom\r
-        {\r
-            get\r
-            {\r
-                return this.q_cropbottom;\r
-            }\r
-        }\r
-\r
-        private string q_cropLeft;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// Cropping values.\r
-        /// </summary>\r
-        public string CropLeft\r
-        {\r
-            get\r
-            {\r
-                return this.q_cropLeft;\r
-            }\r
-        }\r
-\r
-        private string q_cropRight;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// Cropping values.\r
-        /// </summary>\r
-        public string CropRight\r
-        {\r
-            get\r
-            {\r
-                return this.q_cropRight;\r
-            }\r
-        }\r
-\r
-        private Boolean q_detelecine;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither DeTelecine is on or off\r
-        /// </summary>\r
-        public Boolean DeTelecine\r
-        {\r
-            get\r
-            {\r
-                return this.q_detelecine;\r
-            }\r
-        }\r
-\r
-        private int q_deBlock;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither DeBlock is on or off.\r
-        /// </summary>\r
-        public int DeBlock\r
-        {\r
-            get\r
-            {\r
-                return this.q_deBlock;\r
-            }\r
-        }\r
-\r
-        private string q_deinterlace;\r
-        /// <summary>\r
-        /// Returns a string with the De-Interlace option used.\r
-        /// </summary>\r
-        public string DeInterlace\r
-        {\r
-            get\r
-            {\r
-                return this.q_deinterlace;\r
-            }\r
-        }\r
-\r
-        private string q_denoise;\r
-        /// <summary>\r
-        /// Returns a string with the DeNoise option used.\r
-        /// </summary>\r
-        public string DeNoise\r
-        {\r
-            get\r
-            {\r
-                return this.q_denoise;\r
-            }\r
-        }\r
-\r
-        private Boolean q_decomb;\r
-        /// <summary>\r
-        /// Returns a string with the DeNoise option used.\r
-        /// </summary>\r
-        public Boolean Decomb\r
-        {\r
-            get\r
-            {\r
-                return this.q_decomb;\r
-            }\r
-        }\r
-\r
-        private Boolean q_anamorphic;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Anamorphic is on or off.\r
-        /// </summary>\r
-        public Boolean Anamorphic\r
-        {\r
-            get\r
-            {\r
-                return this.q_anamorphic;\r
-            }\r
-        }\r
-\r
-        private Boolean q_looseAnamorphic;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Anamorphic is on or off.\r
-        /// </summary>\r
-        public Boolean LooseAnamorphic\r
-        {\r
-            get\r
-            {\r
-                return this.q_looseAnamorphic;\r
-            }\r
-        }\r
-\r
-        private Boolean q_chapterMarkers;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
-        /// </summary>\r
-        public Boolean ChapterMarkers\r
-        {\r
-            get\r
-            {\r
-                return this.q_chapterMarkers;\r
-            }\r
-        }\r
-        #endregion\r
-\r
-        #region Video Settings\r
-        private Boolean q_grayscale;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Grayscale is on or off.\r
-        /// </summary>\r
-        public Boolean Grayscale\r
-        {\r
-            get\r
-            {\r
-                return this.q_grayscale;\r
-            }\r
-        }\r
-\r
-        private Boolean q_twoPass;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Two Pass Encoding is on or off.\r
-        /// </summary>\r
-        public Boolean TwoPass\r
-        {\r
-            get\r
-            {\r
-                return this.q_twoPass;\r
-            }\r
-        }\r
-\r
-        private Boolean q_turboFirst;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
-        /// </summary>\r
-        public Boolean TurboFirstPass\r
-        {\r
-            get\r
-            {\r
-                return this.q_turboFirst;\r
-            }\r
-        }\r
-\r
-        private Boolean q_largeMp4;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
-        /// </summary>\r
-        public Boolean LargeMP4\r
-        {\r
-            get\r
-            {\r
-                return this.q_largeMp4;\r
-            }\r
-        }\r
-\r
-        private Boolean q_ipodAtom;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
-        /// </summary>\r
-        public Boolean IpodAtom\r
-        {\r
-            get\r
-            {\r
-                return this.q_ipodAtom;\r
-            }\r
-        }\r
-\r
-        private Boolean q_optimizeMp4;\r
-        /// <summary>\r
-        /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
-        /// </summary>\r
-        public Boolean OptimizeMP4\r
-        {\r
-            get\r
-            {\r
-                return this.q_optimizeMp4;\r
-            }\r
-        }\r
-\r
-        private string q_videoFramerate;\r
-        /// <summary>\r
-        /// Returns a string with the video Framerate\r
-        /// </summary>\r
-        public string VideoFramerate\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoFramerate;\r
-            }\r
-        }\r
-\r
-        private string q_avgBitrate;\r
-        /// <summary>\r
-        /// Returns a string with the average video bitrate\r
-        /// </summary>\r
-        public string AverageVideoBitrate\r
-        {\r
-            get\r
-            {\r
-                return this.q_avgBitrate;\r
-            }\r
-        }\r
-\r
-        private string q_videoTargetSize;\r
-        /// <summary>\r
-        /// Returns a string with the video target size\r
-        /// </summary>\r
-        public string VideoTargetSize\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoTargetSize;\r
-            }\r
-        }\r
-\r
-        private int q_videoQuality;\r
-        /// <summary>\r
-        /// Returns a int with the video quality value\r
-        /// </summary>\r
-        public int VideoQuality\r
-        {\r
-            get\r
-            {\r
-                return this.q_videoQuality;\r
-            }\r
-        }\r
-\r
-        #endregion\r
-\r
-        #region Audio Settings\r
-        private string q_audioTrack1;\r
-        /// <summary>\r
-        /// Returns a string with the selected Audio track\r
-        /// </summary>\r
-        public string AudioTrack1\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrack1;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrack2;\r
-        /// <summary>\r
-        /// Returns a string with the selected Audio track\r
-        /// </summary>\r
-        public string AudioTrack2\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrack2;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrack3;\r
-        /// <summary>\r
-        /// Returns a string with the selected Audio track\r
-        /// </summary>\r
-        public string AudioTrack3\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrack3;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrack4;\r
-        /// <summary>\r
-        /// Returns a string with the selected Audio track\r
-        /// </summary>\r
-        public string AudioTrack4\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrack4;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrackMix1;\r
-        /// <summary>\r
-        /// Returns a string with the First selected Audio track Mix\r
-        /// </summary>\r
-        public string AudioTrackMix1\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrackMix1;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrackMix2;\r
-        /// <summary>\r
-        /// Returns a string with the First selected Audio track Mix\r
-        /// </summary>\r
-        public string AudioTrackMix2\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrackMix2;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrackMix3;\r
-        /// <summary>\r
-        /// Returns a string with the First selected Audio track Mix\r
-        /// </summary>\r
-        public string AudioTrackMix3\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrackMix3;\r
-            }\r
-        }\r
-\r
-        private string q_audioTrackMix4;\r
-        /// <summary>\r
-        /// Returns a string with the First selected Audio track Mix\r
-        /// </summary>\r
-        public string AudioTrackMix4\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioTrackMix4;\r
-            }\r
-        }\r
-\r
-        private string q_audioEncoder1;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// The Audio Encoder used.\r
-        /// </summary>\r
-        public string AudioEncoder1\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioEncoder1;\r
-            }\r
-        }\r
-\r
-        private string q_audioEncoder2;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// The Audio Encoder used.\r
-        /// </summary>\r
-        public string AudioEncoder2\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioEncoder2;\r
-            }\r
-        }\r
-\r
-        private string q_audioEncoder3;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// The Audio Encoder used.\r
-        /// </summary>\r
-        public string AudioEncoder3\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioEncoder3;\r
-            }\r
-        }\r
-\r
-        private string q_audioEncoder4;\r
-        /// <summary>\r
-        /// Returns an String\r
-        /// The Audio Encoder used.\r
-        /// </summary>\r
-        public string AudioEncoder4\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioEncoder4;\r
-            }\r
-        }\r
-\r
-        private string q_audioBitrate1;\r
-        /// <summary>\r
-        /// Returns a string with the audio bitrate\r
-        /// </summary>\r
-        public string AudioBitrate1\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioBitrate1;\r
-            }\r
-        }\r
-\r
-        private string q_audioBitrate2;\r
-        /// <summary>\r
-        /// Returns a string with the audio bitrate\r
-        /// </summary>\r
-        public string AudioBitrate2\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioBitrate2;\r
-            }\r
-        }\r
-\r
-        private string q_audioBitrate3;\r
-        /// <summary>\r
-        /// Returns a string with the audio bitrate\r
-        /// </summary>\r
-        public string AudioBitrate3\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioBitrate3;\r
-            }\r
-        }\r
-\r
-        private string q_audioBitrate4;\r
-        /// <summary>\r
-        /// Returns a string with the audio bitrate\r
-        /// </summary>\r
-        public string AudioBitrate4\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioBitrate4;\r
-            }\r
-        }\r
-\r
-        private string q_audioSamplerate1;\r
-        /// <summary>\r
-        /// Returns a string with the audio sample rate\r
-        /// </summary>\r
-        public string AudioSamplerate1\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioSamplerate1;\r
-            }\r
-        }\r
-\r
-        private string q_audioSamplerate2;\r
-        /// <summary>\r
-        /// Returns a string with the audio sample rate\r
-        /// </summary>\r
-        public string AudioSamplerate2\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioSamplerate2;\r
-            }\r
-        }\r
-\r
-        private string q_audioSamplerate3;\r
-        /// <summary>\r
-        /// Returns a string with the audio sample rate\r
-        /// </summary>\r
-        public string AudioSamplerate3\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioSamplerate3;\r
-            }\r
-        }\r
-\r
-        private string q_audioSamplerate4;\r
-        /// <summary>\r
-        /// Returns a string with the audio sample rate\r
-        /// </summary>\r
-        public string AudioSamplerate4\r
-        {\r
-            get\r
-            {\r
-                return this.q_audioSamplerate4;\r
-            }\r
-        }\r
-\r
-        private double q_drc1;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public double DRC1\r
-        {\r
-            get\r
-            {\r
-                return this.q_drc1;\r
-            }\r
-        }\r
-\r
-        private double q_drc2;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public double DRC2\r
-        {\r
-            get\r
-            {\r
-                return this.q_drc2;\r
-            }\r
-        }\r
-\r
-        private double q_drc3;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public double DRC3\r
-        {\r
-            get\r
-            {\r
-                return this.q_drc3;\r
-            }\r
-        }\r
-\r
-        private double q_drc4;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public double DRC4\r
-        {\r
-            get\r
-            {\r
-                return this.q_drc4;\r
-            }\r
-        }\r
-\r
-        private string q_subtitles;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public string Subtitles\r
-        {\r
-            get\r
-            {\r
-                return this.q_subtitles;\r
-            }\r
-        }\r
-\r
-        private Boolean q_forcedSubs;\r
-        /// <summary>\r
-        /// Returns a string with the selected subtitle track\r
-        /// </summary>\r
-        public Boolean ForcedSubtitles\r
-        {\r
-            get\r
-            {\r
-                return this.q_forcedSubs;\r
-            }\r
-        }\r
-\r
-        #endregion\r
-\r
-        #region Other\r
-        private string q_h264;\r
-        /// <summary>\r
-        /// Returns a string with the Advanced H264 query string\r
-        /// </summary>\r
-        public string H264Query\r
-        {\r
-            get\r
-            {\r
-                return this.q_h264;\r
-            }\r
-        }\r
-        private Boolean q_verbose;\r
-        /// <summary>\r
-        /// Returns a string with the Advanced H264 query string\r
-        /// </summary>\r
-        public Boolean Verbose\r
-        {\r
-            get\r
-            {\r
-                return this.q_verbose;\r
-            }\r
-        }\r
-        #endregion\r
+        // Source\r
+        public int DVDTitle { get; set; }\r
+        public int DVDChapterStart { get; set; }\r
+        public int DVDChapterFinish { get; set; }\r
+\r
+        // Output Settings\r
+        public string Format { get; set; }\r
+        public Boolean LargeMP4 { get; set; }\r
+        public Boolean IpodAtom { get; set; }\r
+        public Boolean OptimizeMP4 { get; set; }\r
+\r
+        // Picture Settings\r
+        public int Width { get; set; }\r
+        public int Height { get; set; }\r
+        public int MaxWidth { get; set; }\r
+        public int MaxHeight { get; set; }\r
+        public string CropValues { get; set; }\r
+        public string CropTop { get; set; }\r
+        public string CropBottom { get; set; }\r
+        public string CropLeft { get; set; }\r
+        public string CropRight { get; set; }\r
+        public int AnamorphicMode { get; set; }\r
+        public Boolean keepDisplayAsect { get; set; }\r
+        public double displayWidthValue { get; set; }\r
+        public int pixelAspectWidth { get; set; }\r
+        public int pixelAspectHeight { get; set; }\r
+        public int AnamorphicModulus { get; set; }\r
+\r
+        // Video Filters\r
+        public string DeTelecine { get; set; }\r
+        public int DeBlock { get; set; }\r
+        public string DeInterlace { get; set; }\r
+        public string DeNoise { get; set; }\r
+        public string Decomb { get; set; }\r
+\r
+        // Video Settings\r
+        public string VideoEncoder { get; set; }\r
+        public Boolean Grayscale { get; set; }\r
+        public Boolean TwoPass { get; set; }\r
+        public Boolean TurboFirstPass { get; set; }\r
+        public string VideoFramerate { get; set; }\r
+        public string AverageVideoBitrate { get; set; }\r
+        public string VideoTargetSize { get; set; }\r
+        public float VideoQuality { get; set; }\r
+\r
+        // Audio Settings\r
+        public ArrayList AudioInformation { get; set; }\r
+        public string Subtitles { get; set; }\r
+        public Boolean ForcedSubtitles { get; set; }\r
+\r
+        // Chapter Markers\r
+        public Boolean ChapterMarkers { get; set; }\r
+\r
+        // Other\r
+        public string H264Query { get; set; }\r
+        public Boolean Verbose { get; set; }\r
+\r
+        // Preset Information\r
+        public int PresetBuildNumber { get; set; }\r
+        public string PresetDescription { get; set; }\r
+        public string PresetName { get; set; }\r
+        public string Type { get; set; }\r
+        public Boolean UsesMaxPictureSettings { get; set; }\r
+        public Boolean UsesPictureFilters { get; set; }\r
+        public Boolean UsesPictureSettings { get; set; }\r
 \r
         #endregion\r
 \r
@@ -805,505 +92,346 @@ namespace Handbrake.Functions
         /// </summary>\r
         /// <param name="input">A ClI Query</param>\r
         /// <returns>A Parsed Query</returns>\r
\r
         public static QueryParser Parse(String input)\r
         {\r
-            QueryParser thisQuery = new QueryParser();\r
+            var thisQuery = new QueryParser();\r
 \r
             #region Regular Expressions\r
+\r
             //Source\r
-            Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");\r
-            Match source = r1.Match(input.Replace('"', '\"'));\r
             Match title = Regex.Match(input, @"-t ([0-9]*)");\r
             Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
-            Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
 \r
-            //Destination\r
-            Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");\r
-            Match destination = r2.Match(input.Replace('"', '\"'));\r
-            Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
+            //Output Settings\r
+            Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
+            Match grayscale = Regex.Match(input, @" -g");\r
+            Match largerMp4 = Regex.Match(input, @" -4");\r
+            Match ipodAtom = Regex.Match(input, @" -I");\r
 \r
             //Picture Settings Tab\r
             Match width = Regex.Match(input, @"-w ([0-9]*)");\r
             Match height = Regex.Match(input, @"-l ([0-9]*)");\r
             Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");\r
             Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");\r
-            Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z]*)\""");\r
-            Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z]*)\""");\r
-            Match deblock = Regex.Match(input, @"--deblock=([0-9]*)");\r
-            Match detelecine = Regex.Match(input, @"--detelecine");\r
-            Match anamorphic = Regex.Match(input, @" -p ");\r
-            Match chapterMarkers = Regex.Match(input, @" -m");\r
-            Match chapterMarkersFileMode = Regex.Match(input, @"--markers");\r
             Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");\r
-            Match lanamorphic = Regex.Match(input, @" -P");\r
+\r
+            Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");\r
+            Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");\r
+            Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");\r
+\r
+            Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");\r
+            Match displayWidth = Regex.Match(input, @"--display-width ([0-9*])");\r
+            Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");\r
+            Match modulus = Regex.Match(input, @"--modulus ([0-9*])");\r
+\r
+            // Picture Settings - Filters\r
             Match decomb = Regex.Match(input, @" --decomb");\r
+            Match decombValue = Regex.Match(input, @" --decomb=\""([a-zA-Z0-9.:]*)\""");\r
+            Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\""");\r
+            Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\""");\r
+            Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)");\r
+            Match detelecine = Regex.Match(input, @"--detelecine");\r
+            Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");\r
 \r
             //Video Settings Tab\r
-            Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");\r
+            Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
+            Match videoFramerate = Regex.Match(input, @"-r ([0-9.]*)");\r
             Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");\r
             Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");\r
             Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");\r
             Match twoPass = Regex.Match(input, @" -2");\r
             Match turboFirstPass = Regex.Match(input, @" -T");\r
-            Match grayscale = Regex.Match(input, @" -g");\r
-            Match largerMp4 = Regex.Match(input, @" -4");\r
-            Match ipodAtom = Regex.Match(input, @" -I");\r
             Match optimizeMP4 = Regex.Match(input, @" -O");\r
 \r
             //Audio Settings Tab\r
-            Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");\r
-            Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");\r
-            Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");\r
-            Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");\r
-\r
-            Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");  \r
-            Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");\r
-            Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");\r
-            Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)"); \r
-\r
-            Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");\r
-            Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
-            Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
-            Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");\r
-\r
-            Match audioBitrate1 = Regex.Match(input, @"-B ([0-9]*)");\r
-            Match audioBitrate2 = Regex.Match(input, @"-B ([0-9]*),([0-9]*)");\r
-            Match audioBitrate3 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*)");\r
-            Match audioBitrate4 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");\r
-\r
-            Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9.]*)");\r
-            Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*)");\r
-            Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*)");\r
-            Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");\r
-\r
-            Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");\r
-            Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");\r
-            Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");\r
-            Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");\r
+            Match noAudio = Regex.Match(input, @"-a none");\r
+            Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)");\r
+            Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)");\r
+            Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,]*)");\r
+            Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)");       // Auto = a-z\r
+            Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)");  // Auto = a-z\r
+            Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");\r
 \r
             Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");\r
             Match subScan = Regex.Match(input, @" -U");\r
             Match forcedSubtitles = Regex.Match(input, @" -F");\r
 \r
+            // Chapters Tab\r
+            Match chapterMarkers = Regex.Match(input, @" -m");\r
+            Match chapterMarkersFileMode = Regex.Match(input, @"--markers");\r
+\r
             //H264 Tab\r
             Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");\r
 \r
             //Program Options\r
             Match verbose = Regex.Match(input, @" -v");\r
+\r
             #endregion\r
 \r
             #region Set Varibles\r
+\r
             try\r
             {\r
-      \r
                 #region Source Tab\r
 \r
-                thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");\r
-                if (title.Success != false)\r
-                    thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
+                if (title.Success)\r
+                    thisQuery.DVDTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
 \r
-                if (chapters.Success != false)\r
+                if (chapters.Success)\r
                 {\r
-                    string[] actTitles = new string[2];\r
-                    actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
-                    thisQuery.q_chaptersStart = int.Parse(actTitles[0]);\r
+                    string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
+                    thisQuery.DVDChapterStart = int.Parse(actTitles[0]);\r
                     if (actTitles.Length > 1)\r
                     {\r
-                        thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);\r
+                        thisQuery.DVDChapterFinish = int.Parse(actTitles[1]);\r
                     }\r
 \r
-                    if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))\r
-                        thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;\r
+                    if ((thisQuery.DVDChapterStart == 1) && (thisQuery.DVDChapterFinish == 0))\r
+                        thisQuery.DVDChapterFinish = thisQuery.DVDChapterStart;\r
                 }\r
-\r
-                if (format.Success != false)\r
-                    thisQuery.q_format = format.ToString().Replace("-f ", "");\r
-\r
                 #endregion\r
 \r
-                #region Destination\r
-                thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");\r
-\r
-                string videoEncoderConvertion;\r
+                #region Output Settings\r
 \r
-                videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
-                switch (videoEncoderConvertion)\r
-                {\r
-                    case "ffmpeg":\r
-                        videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
-                        break;\r
-                    case "xvid":\r
-                        videoEncoderConvertion = "MPEG-4 (XviD)";\r
-                        break;\r
-                    case "x264":\r
-                        videoEncoderConvertion = "H.264 (x264)";\r
-                        break;\r
-                    case "theora":\r
-                        videoEncoderConvertion = "VP3 (Theora)";\r
-                        break;\r
-                    default:\r
-                        videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
-                        break;\r
-                }\r
-                thisQuery.q_videoEncoder = videoEncoderConvertion;\r
+                if (format.Success)\r
+                    thisQuery.Format = format.ToString().Replace("-f ", "");\r
+                thisQuery.LargeMP4 = largerMp4.Success;\r
+                thisQuery.IpodAtom = ipodAtom.Success;\r
+                thisQuery.OptimizeMP4 = optimizeMP4.Success;\r
 \r
                 #endregion\r
 \r
                 #region Picture Tab\r
 \r
-                if (width.Success != false)\r
-                    thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));\r
-\r
-                if (height.Success != false)\r
-                    thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));\r
-\r
-                if (maxWidth.Success != false)\r
-                    thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));\r
-\r
-                if (maxHeight.Success != false)\r
-                    thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));\r
-\r
-                if (crop.Success != false)\r
-                {\r
-                    thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");\r
-                    string[] actCropValues = new string[3];\r
-                    actCropValues = thisQuery.q_cropValues.Split(':');\r
-                    thisQuery.q_croptop = actCropValues[0];\r
-                    thisQuery.q_cropbottom = actCropValues[1];\r
-                    thisQuery.q_cropLeft = actCropValues[2];\r
-                    thisQuery.q_cropRight = actCropValues[3];\r
-                }\r
-\r
-                // Deblock Slider\r
-                string deblockValue = "";\r
-                thisQuery.q_deBlock = 0;\r
-                if (deblock.Success != false)\r
-                    deblockValue = deblock.ToString().Replace("--deblock=", "");\r
+                if (width.Success)\r
+                    thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", ""));\r
 \r
-                if (deblockValue != "")\r
-                    int.TryParse(deblockValue, out thisQuery.q_deBlock);\r
+                if (height.Success)\r
+                    thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", ""));\r
 \r
-                thisQuery.q_detelecine = detelecine.Success;\r
-                thisQuery.q_decomb = decomb.Success;\r
+                if (maxWidth.Success)\r
+                    thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", ""));\r
 \r
-                thisQuery.q_deinterlace = "None";\r
-                if (deinterlace.Success != false)\r
-                {\r
-                    switch (deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"",""))\r
-                    {\r
-                        case "fast":\r
-                            thisQuery.q_deinterlace = "Fast";\r
-                            break;\r
-                        case "slow":\r
-                            thisQuery.q_deinterlace = "Slow";\r
-                            break;\r
-                        case "slower":\r
-                            thisQuery.q_deinterlace = "Slower";\r
-                            break;\r
-                        case "slowest":\r
-                            thisQuery.q_deinterlace = "Slowest";\r
-                            break;\r
-                        default:\r
-                            thisQuery.q_deinterlace = "None";\r
-                            break;\r
-                    }\r
-                }\r
+                if (maxHeight.Success)\r
+                    thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", ""));\r
 \r
-                thisQuery.q_denoise = "None";\r
-                if (denoise.Success != false)\r
+                if (crop.Success)\r
                 {\r
-                    switch (denoise.ToString().Replace("--denoise=", "").Replace("\"", ""))\r
-                    {\r
-                        case "weak":\r
-                            thisQuery.q_denoise = "Weak";\r
-                            break;\r
-                        case "medium":\r
-                            thisQuery.q_denoise = "Medium";\r
-                            break;\r
-                        case "strong":\r
-                            thisQuery.q_denoise = "Strong";\r
-                            break;\r
-                        default:\r
-                            thisQuery.q_denoise = "None";\r
-                            break;\r
-                    }\r
-\r
+                    thisQuery.CropValues = crop.ToString().Replace("--crop ", "");\r
+                    string[] actCropValues = thisQuery.CropValues.Split(':');\r
+                    thisQuery.CropTop = actCropValues[0];\r
+                    thisQuery.CropBottom = actCropValues[1];\r
+                    thisQuery.CropLeft = actCropValues[2];\r
+                    thisQuery.CropRight = actCropValues[3];\r
                 }\r
-                thisQuery.q_anamorphic = anamorphic.Success;\r
-                if (chapterMarkersFileMode.Success == true || chapterMarkers.Success == true)\r
-                    thisQuery.q_chapterMarkers = true;\r
-                \r
-                thisQuery.q_looseAnamorphic = lanamorphic.Success;\r
 \r
-                #endregion\r
-     \r
-                #region Video Settings Tab\r
-                thisQuery.q_grayscale = grayscale.Success;\r
-                thisQuery.q_twoPass = twoPass.Success;\r
-                thisQuery.q_turboFirst = turboFirstPass.Success;\r
-                thisQuery.q_largeMp4 = largerMp4.Success;\r
-                if (videoFramerate.Success != false)\r
-                    thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");\r
+                if (strictAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 1;\r
+                else if (looseAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 2;\r
+                else if (customAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 3;\r
                 else\r
-                    thisQuery.q_videoFramerate = "Same as source";\r
-\r
-                if (videoBitrate.Success != false)\r
-                    thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");\r
-                if (videoFilesize.Success != false)\r
-                    thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
+                    thisQuery.AnamorphicMode = 0;\r
 \r
-                double qConvert = 0;\r
-                if (videoQuality.Success != false)\r
-                {\r
-                    qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;\r
-                    qConvert = System.Math.Ceiling(qConvert);\r
-                    thisQuery.q_videoQuality = int.Parse(qConvert.ToString());\r
-                }\r
-                thisQuery.q_ipodAtom = ipodAtom.Success;\r
-                thisQuery.q_optimizeMp4 = optimizeMP4.Success;\r
+                thisQuery.keepDisplayAsect = keepDisplayAsect.Success;\r
 \r
-                #endregion\r
+                if (displayWidth.Success)\r
+                    thisQuery.displayWidthValue = double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", ""));\r
 \r
-                #region Audio Tab\r
+                if (pixelAspect.Success)\r
+                    thisQuery.pixelAspectWidth = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", ""));\r
 \r
-                // Tracks\r
-                if (audioTrack1.Success != false)\r
-                    thisQuery.q_audioTrack1 = audioTrack1.ToString().Replace("-a ", "");\r
-                else\r
-                    thisQuery.q_audioTrack1 = "Automatic";\r
+                if (pixelAspect.Success && pixelAspect.Groups.Count >=3)\r
+                    thisQuery.pixelAspectHeight = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", ""));\r
 \r
-                if (audioTrack2.Success != false)\r
-                {\r
-                    string[] audioChan = audioTrack2.ToString().Split(',');\r
-                    thisQuery.q_audioTrack2 = audioChan[1];\r
-                }\r
-                else\r
-                    thisQuery.q_audioTrack2 = "None";\r
+                if (modulus.Success)\r
+                    thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", ""));\r
 \r
-                if (audioTrack3.Success != false)\r
-                {\r
-                    string[] audioChan = audioTrack3.ToString().Split(',');\r
-                    thisQuery.q_audioTrack3 = audioChan[2];\r
-                }\r
-                else\r
-                    thisQuery.q_audioTrack3 = "None";\r
 \r
-                if (audioTrack4.Success != false)\r
-                {\r
-                    string[] audioChan = audioTrack4.ToString().Split(',');\r
-                    thisQuery.q_audioTrack4 = audioChan[3];\r
-                }\r
-                else\r
-                    thisQuery.q_audioTrack4 = "None";\r
+                #endregion\r
 \r
-    \r
-                // Mixdowns\r
-                thisQuery.q_audioTrackMix1 = "Automatic";\r
-                if (audioTrack1Mix.Success != false)\r
-                {\r
-                    thisQuery.q_audioTrackMix1 = getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));\r
-                }\r
+                #region Filters\r
 \r
-                thisQuery.q_audioTrackMix2 = "Automatic";\r
-                if (audioTrack2Mix.Success != false)\r
+                thisQuery.Decomb = "Off";\r
+                if (decomb.Success)\r
                 {\r
-                    string[] audio2mix = audioTrack2Mix.ToString().Split(',');\r
-                    audio2mix[1] = audio2mix[1].Trim();\r
-                    thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1]);\r
+                    thisQuery.Decomb = "Default";\r
+                    if (decombValue.Success)\r
+                        thisQuery.Decomb = decombValue.ToString().Replace("--decomb=", "").Replace("\"", "");\r
                 }\r
 \r
-                thisQuery.q_audioTrackMix3 = "Automatic";\r
-                if (audioTrack3Mix.Success != false)\r
+                thisQuery.DeInterlace = "Off";\r
+                if (deinterlace.Success)\r
                 {\r
-                    string[] audio3mix = audioTrack3Mix.ToString().Split(',');\r
-                    audio3mix[1] = audio3mix[2].Trim();\r
-                    thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[1]);\r
+                    thisQuery.DeInterlace = deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"", "");\r
+                    thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");\r
+                    thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("slowest", "Slowest");\r
                 }\r
 \r
-                thisQuery.q_audioTrackMix4 = "Automatic";\r
-                if (audioTrack4Mix.Success != false)\r
+                thisQuery.DeNoise = "Off";\r
+                if (denoise.Success)\r
                 {\r
-                    string[] audio4mix = audioTrack4Mix.ToString().Split(',');\r
-                    audio4mix[1] = audio4mix[3].Trim();\r
-                    thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[1]);\r
+                    thisQuery.DeNoise = denoise.ToString().Replace("--denoise=", "").Replace("\"", "");\r
+                    thisQuery.DeNoise = thisQuery.DeNoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");\r
                 }\r
-                \r
-\r
-                // Audio Encoders\r
-                if (audioEncoder1.Success != false)\r
-                    thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));\r
 \r
-                if (audioEncoder2.Success != false)\r
-                {\r
-                    string[] audio2enc = audioEncoder2.ToString().Split(',');\r
-                    thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());\r
-                }\r
+                string deblockValue = "";\r
+                thisQuery.DeBlock = 0;\r
+                if (deblock.Success)\r
+                    deblockValue = deblock.ToString().Replace("--deblock=", "");\r
 \r
-                if (audioEncoder3.Success != false)\r
-                {\r
-                    string[] audio3enc = audioEncoder3.ToString().Split(',');\r
-                    thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());\r
-                }\r
+                int dval = 0;\r
+                if (deblockValue != "")\r
+                    int.TryParse(deblockValue, out dval);\r
+                thisQuery.DeBlock = dval;\r
 \r
-                if (audioEncoder4.Success != false)\r
+                thisQuery.DeTelecine = "Off";\r
+                if (detelecine.Success)\r
                 {\r
-                    string[] audio4enc = audioEncoder4.ToString().Split(',');\r
-                    thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());\r
+                    thisQuery.DeTelecine = "Default";\r
+                    if (detelecineValue.Success)\r
+                        thisQuery.DeTelecine = detelecineValue.ToString().Replace("--detelecine=", "").Replace("\"", "");\r
                 }\r
 \r
+                #endregion\r
 \r
-                // Audio Bitrate\r
-                if (audioBitrate1.Success != false)\r
-                    thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();\r
-                else\r
-                    thisQuery.q_audioBitrate1 = "";\r
-\r
-                if (audioBitrate2.Success != false)\r
-                {\r
-                    string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');\r
-                    thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();\r
-                }\r
-                else\r
-                    thisQuery.q_audioBitrate2 = "";\r
+                #region Video Settings Tab\r
 \r
-                if (audioBitrate3.Success != false)\r
+                string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
+                switch (videoEncoderConvertion)\r
                 {\r
-                    string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');\r
-                    thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();\r
+                    case "ffmpeg":\r
+                        videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
+                        break;\r
+                    case "x264":\r
+                        videoEncoderConvertion = "H.264 (x264)";\r
+                        break;\r
+                    case "theora":\r
+                        videoEncoderConvertion = "VP3 (Theora)";\r
+                        break;\r
+                    default:\r
+                        videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
+                        break;\r
                 }\r
-                else\r
-                    thisQuery.q_audioBitrate3 = "";\r
-\r
-                if (audioBitrate4.Success != false)\r
+                thisQuery.VideoEncoder = videoEncoderConvertion;\r
+                thisQuery.VideoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";\r
+                thisQuery.Grayscale = grayscale.Success;\r
+                thisQuery.TwoPass = twoPass.Success;\r
+                thisQuery.TurboFirstPass = turboFirstPass.Success;\r
+\r
+                if (videoBitrate.Success)\r
+                    thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", "");\r
+                if (videoFilesize.Success)\r
+                    thisQuery.VideoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
+\r
+                if (videoQuality.Success)\r
                 {\r
-                    string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');\r
-                    thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();\r
+                    float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);\r
+                    thisQuery.VideoQuality = qConvert;\r
                 }\r
-                else\r
-                    thisQuery.q_audioBitrate4 = "";\r
-\r
+                #endregion\r
 \r
-                // Audio Sample Rate\r
-                // Make sure to change 0 to Auto\r
-                if (audioSampleRate1.Success != false)\r
+                #region Audio Tab\r
+                // Find out how many tracks we need to add by checking how many encoders or audio tracks are selected.\r
+                int encoderCount = 0;\r
+                if (audioEncoders.Success)\r
                 {\r
-                    thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();\r
-                    if (thisQuery.q_audioSamplerate1 == "0")\r
-                        thisQuery.q_audioSamplerate1 = "Auto";\r
+                    string[] audioDataCounters = audioEncoders.ToString().Replace("-E ", "").Split(',');\r
+                    encoderCount = audioDataCounters.Length;\r
                 }\r
-                else\r
-                    thisQuery.q_audioSamplerate1 = "Auto";\r
 \r
-                if (audioSampleRate2.Success != false)\r
+                // Get the data from the regular expression results\r
+                string[] trackData = null;\r
+                string[] trackMixes = null;\r
+                string[] trackEncoders = null;\r
+                string[] trackBitrates = null;\r
+                string[] trackSamplerates = null;\r
+                string[] trackDRCvalues = null;\r
+\r
+                if (audioTracks.Success)\r
+                    trackData = audioTracks.ToString().Replace("-a ", "").Split(',');\r
+                if (audioTrackMixes.Success)\r
+                    trackMixes = audioTrackMixes.ToString().Replace("-6 ", "").Split(',');\r
+                if (audioEncoders.Success)\r
+                    trackEncoders = audioEncoders.ToString().Replace("-E ", "").Split(',');\r
+                if (audioBitrates.Success)\r
+                    trackBitrates = audioBitrates.ToString().Replace("-B ", "").Split(',');\r
+                if (audioSampleRates.Success)\r
+                    trackSamplerates = audioSampleRates.ToString().Replace("-R ", "").Split(',');\r
+                if (drcValues.Success)\r
+                    trackDRCvalues = drcValues.ToString().Replace("-D ", "").Split(',');\r
+\r
+                // Create new Audio Track Classes and store them in the ArrayList\r
+                ArrayList AllAudioTrackInfo = new ArrayList();\r
+                for (int x = 0; x < encoderCount; x++)\r
                 {\r
-                    string[] audioSRSelect = audioSampleRate2.ToString().Split(',');\r
-                    if (audioSRSelect[1] == "0")\r
-                        audioSRSelect[1] = "Auto";\r
-                    thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();\r
-                }\r
+                    AudioTrack track = new AudioTrack();\r
+                    if (trackData != null)\r
+                        if (trackData.Length >= (x + 1))                         // Audio Track\r
+                            track.Track = trackData[x].Trim();\r
 \r
-                if (audioSampleRate3.Success != false)\r
-                {\r
-                    string[] audioSRSelect = audioSampleRate3.ToString().Split(',');\r
-                    if (audioSRSelect[1] == "0")\r
-                        audioSRSelect[1] = "Auto";\r
-                    thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();\r
-                }\r
+                    if (trackMixes != null)\r
+                        if (trackMixes.Length >= (x + 1))                        // Audio Mix\r
+                            track.MixDown = getMixDown(trackMixes[x].Trim());\r
 \r
-                if (audioSampleRate4.Success != false)\r
-                {\r
-                    string[] audioSRSelect = audioSampleRate4.ToString().Split(',');\r
-                    if (audioSRSelect[1] == "0")\r
-                        audioSRSelect[1] = "Auto";\r
-                    thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();\r
-                }\r
+                    if (trackEncoders != null)\r
+                        if (trackEncoders.Length >= (x + 1))                     // Audio Mix\r
+                            track.Encoder = getAudioEncoder(trackEncoders[x].Trim());\r
 \r
-                // DRC\r
-                if (drc1.Success != false)\r
-                {\r
-                    string value = drc1.ToString().Replace("-D ", "");\r
-                    float drcValue = float.Parse(value);\r
-                    drcValue = drcValue * 10;\r
-                    thisQuery.q_drc1 = drcValue;\r
-                }\r
-                else\r
-                    thisQuery.q_drc1 = 10;\r
+                    if (trackBitrates != null)\r
+                        if (trackBitrates.Length >= (x + 1))                     // Audio Encoder\r
+                            track.Bitrate = trackBitrates[x].Trim() == "auto" ? "Auto" : trackBitrates[x].Trim();\r
 \r
-                if (drc2.Success != false)\r
-                {\r
-                    string[] drcPoint = drc2.ToString().Split(',');\r
-                    string value = drcPoint[1];\r
-                    float drcValue = float.Parse(value);\r
-                    drcValue = drcValue * 10;\r
-                    thisQuery.q_drc2 = drcValue;\r
-                }\r
-                else\r
-                    thisQuery.q_drc2 = 10;\r
+                    if (trackSamplerates != null)\r
+                        if (trackSamplerates.Length >= (x + 1))                  // Audio SampleRate\r
+                            track.SampleRate = trackSamplerates[x].Trim() == "0" ? "Auto" : trackSamplerates[x].Trim();\r
 \r
-                if (drc3.Success != false)\r
-                {\r
-                    string[] drcPoint = drc3.ToString().Split(',');\r
-                    string value = drcPoint[2];\r
-                    float drcValue = float.Parse(value);\r
-                    drcValue = drcValue * 10;\r
-                    thisQuery.q_drc3 = drcValue;\r
-                }\r
-                else\r
-                    thisQuery.q_drc3 = 10;\r
+                    if (trackDRCvalues != null)\r
+                        if (trackDRCvalues.Length >= (x + 1))                   // Audio DRC Values\r
+                            track.DRC = trackDRCvalues[x].Trim();\r
 \r
-                if (drc4.Success != false)\r
-                {\r
-                    string[] drcPoint = drc4.ToString().Split(',');\r
-                    string value = drcPoint[3];\r
-                    float drcValue = float.Parse(value);\r
-                    drcValue = drcValue * 10;\r
-                    thisQuery.q_drc4 = drcValue;\r
+                    AllAudioTrackInfo.Add(track);\r
                 }\r
-                else\r
-                    thisQuery.q_drc4 = 10;\r
-\r
+                thisQuery.AudioInformation = AllAudioTrackInfo;\r
 \r
                 // Subtitle Stuff\r
-                if (subtitles.Success != false)\r
-                    thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");\r
+                if (subtitles.Success)\r
+                    thisQuery.Subtitles = subtitles.ToString().Replace("-s ", "");\r
                 else\r
-                {\r
-                    if (subScan.Success)\r
-                        thisQuery.q_subtitles = "Autoselect";\r
-                    else\r
-                        thisQuery.q_subtitles = "None";\r
-                }\r
+                    thisQuery.Subtitles = subScan.Success ? "Autoselect" : "None";\r
 \r
-                thisQuery.q_forcedSubs = forcedSubtitles.Success;\r
+                thisQuery.ForcedSubtitles = forcedSubtitles.Success;\r
+                #endregion\r
 \r
+                #region Chapters Tab\r
+                if (chapterMarkersFileMode.Success || chapterMarkers.Success)\r
+                    thisQuery.ChapterMarkers = true;\r
                 #endregion\r
 \r
                 #region H.264 and other\r
-                //\r
-                //H264 Tab\r
-                //\r
-                if (x264.Success != false)\r
-                    thisQuery.q_h264 = x264.ToString().Replace("-x ", "");\r
-\r
-                //\r
-                //Progam Options\r
-                //\r
-                thisQuery.q_verbose = verbose.Success;\r
+\r
+                if (x264.Success)\r
+                    thisQuery.H264Query = x264.ToString().Replace("-x ", "");\r
+\r
+                thisQuery.Verbose = verbose.Success;\r
+\r
                 #endregion\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show(\r
+                    "An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" +\r
+                    exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
+\r
             #endregion\r
 \r
             return thisQuery;\r
         }\r
-\r
         private static string getMixDown(string mixdown)\r
         {\r
-            switch (mixdown)\r
+            switch (mixdown.Trim())\r
             {\r
                 case "mono":\r
                     return "Mono";\r
@@ -1324,16 +452,37 @@ namespace Handbrake.Functions
             switch (audioEnc)\r
             {\r
                 case "faac":\r
-                    return "AAC";\r
+                    return "AAC (faac)";\r
                 case "lame":\r
-                    return "MP3";\r
+                    return "MP3 (lame)";\r
                 case "vorbis":\r
-                    return "Vorbis";\r
+                    return "Vorbis (vorbis)";\r
                 case "ac3":\r
-                    return "AC3";\r
+                    return "AC3 Passthru";\r
+                case "dts":\r
+                    return "DTS Passthru";\r
                 default:\r
-                    return "AAC";\r
+                    return "AAC (faac)";\r
             }\r
         }\r
     }\r
+\r
+    public class AudioTrack\r
+    {\r
+        public AudioTrack()\r
+        {\r
+            // Default Values\r
+            Track = "Automatic";\r
+            MixDown = "Automatic";\r
+            SampleRate = "Auto";\r
+            Bitrate = "Auto";\r
+            DRC = "1";\r
+        }\r
+        public string Track { get; set; }\r
+        public string MixDown { get; set; }\r
+        public string Encoder { get; set; }\r
+        public string Bitrate { get; set; }\r
+        public string SampleRate { get; set; }\r
+        public string DRC { get; set; }\r
+    }\r
 }
\ No newline at end of file
diff --git a/win/C#/Functions/UpdateCheckInformation.cs b/win/C#/Functions/UpdateCheckInformation.cs
new file mode 100644 (file)
index 0000000..2538178
--- /dev/null
@@ -0,0 +1,23 @@
+using System;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+    /// <summary>\r
+    /// Provides information about an update check.\r
+    /// </summary>\r
+    public struct UpdateCheckInformation\r
+    {\r
+        public bool NewVersionAvailable { get; set; }\r
+        public bool ErrorOccured { get { return Error != null; } }\r
+\r
+        /// <summary>\r
+        /// Gets information about the new build, if any. This will be null if there is no new verison.\r
+        /// </summary>\r
+        public AppcastReader BuildInformation { get; set; }\r
+\r
+        /// <summary>\r
+        /// Gets the error that occurred, if any. This will be null if no error occured.\r
+        /// </summary>\r
+        public Exception Error { get; set; }\r
+    }\r
+}\r
diff --git a/win/C#/Functions/Win32.cs b/win/C#/Functions/Win32.cs
new file mode 100644 (file)
index 0000000..bf0bde6
--- /dev/null
@@ -0,0 +1,45 @@
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+    class Win32\r
+    {\r
+        [DllImport("user32.dll")]\r
+        public static extern bool SetForegroundWindow(int hWnd);\r
+\r
+        [DllImport("user32.dll")]\r
+        public static extern void LockWorkStation();\r
+\r
+        [DllImport("user32.dll")]\r
+        public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
+\r
+        public struct MEMORYSTATUS // Unused var's are required here.\r
+        {\r
+            public UInt32 dwLength;\r
+            public UInt32 dwMemoryLoad;\r
+            public UInt32 dwTotalPhys; // Used\r
+            public UInt32 dwAvailPhys;\r
+            public UInt32 dwTotalPageFile;\r
+            public UInt32 dwAvailPageFile;\r
+            public UInt32 dwTotalVirtual;\r
+            public UInt32 dwAvailVirtual;\r
+        }\r
+\r
+        [DllImport("kernel32.dll")]\r
+        public static extern void GlobalMemoryStatus\r
+        (\r
+            ref MEMORYSTATUS lpBuffer\r
+        );\r
+\r
+        [DllImport("kernel32.dll", SetLastError = true)]\r
+        public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);\r
+\r
+        public enum ConsoleCtrlEvent\r
+        {\r
+            CTRL_C = 0,\r
+            CTRL_BREAK = 1,\r
+            CTRL_CLOSE = 2,\r
+        }\r
+    }\r
+}\r
index df5258c..4c3a4f8 100644 (file)
@@ -2,7 +2,7 @@
   <PropertyGroup>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
-    <ProductVersion>9.0.30729</ProductVersion>\r
+    <ProductVersion>9.0.21022</ProductVersion>\r
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{A2923D42-C38B-4B12-8CBA-B8D93D6B13A3}</ProjectGuid>\r
     <OutputType>WinExe</OutputType>\r
@@ -41,7 +41,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
     <DebugSymbols>true</DebugSymbols>\r
     <DebugType>full</DebugType>\r
-    <Optimize>true</Optimize>\r
+    <Optimize>false</Optimize>\r
     <OutputPath>bin\Debug\</OutputPath>\r
     <DefineConstants>DEBUG;TRACE</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
@@ -51,6 +51,7 @@
     <NoStdLib>false</NoStdLib>\r
     <DocumentationFile>\r
     </DocumentationFile>\r
+    <PlatformTarget>x86</PlatformTarget>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
     <DebugType>full</DebugType>\r
@@ -67,7 +68,7 @@
     <NoStdLib>false</NoStdLib>\r
     <DebugSymbols>true</DebugSymbols>\r
     <FileAlignment>512</FileAlignment>\r
-    <PlatformTarget>AnyCPU</PlatformTarget>\r
+    <PlatformTarget>x86</PlatformTarget>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
     <PlatformTarget>x86</PlatformTarget>\r
     <PlatformTarget>x86</PlatformTarget>\r
     <OutputPath>bin\x86\Release\</OutputPath>\r
     <UseVSHostingProcess>false</UseVSHostingProcess>\r
+    <DefineConstants>TRACE;DEBUG</DefineConstants>\r
+    <Optimize>true</Optimize>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">\r
     <OutputPath>bin\Build\</OutputPath>\r
     <DefineConstants>TRACE</DefineConstants>\r
     <DebugType>pdbonly</DebugType>\r
-    <PlatformTarget>AnyCPU</PlatformTarget>\r
+    <PlatformTarget>x86</PlatformTarget>\r
     <ErrorReport>prompt</ErrorReport>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|x86' ">\r
     <PlatformTarget>x86</PlatformTarget>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Reference Include="PresentationCore">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    <Reference Include="Growl.Connector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=980c2339411be384, processorArchitecture=x86">\r
+      <SpecificVersion>False</SpecificVersion>\r
+      <HintPath>libraries\Growl.Connector.dll</HintPath>\r
+      <Private>True</Private>\r
     </Reference>\r
-    <Reference Include="PresentationFramework">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    <Reference Include="Growl.CoreLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=13e59d82e007b064, processorArchitecture=x86">\r
+      <SpecificVersion>False</SpecificVersion>\r
+      <HintPath>libraries\Growl.CoreLibrary.dll</HintPath>\r
+      <Private>True</Private>\r
     </Reference>\r
     <Reference Include="System" />\r
     <Reference Include="System.Data" />\r
     <Reference Include="System.Drawing" />\r
     <Reference Include="System.Messaging" />\r
     <Reference Include="System.Windows.Forms" />\r
-    <Reference Include="System.Xml" />\r
-    <Reference Include="UIAutomationProvider">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
-    <Reference Include="WindowsBase">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
+    <Reference Include="System.XML" />\r
+    <Reference Include="UIAutomationProvider, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
+    <Reference Include="WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
+    <Reference Include="WindowsFormsIntegration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="Controls\AudioPanel.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="Controls\AudioPanel.Designer.cs">\r
+      <DependentUpon>AudioPanel.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="Controls\Filters.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="Controls\Filters.Designer.cs">\r
+      <DependentUpon>Filters.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="Controls\PictureSettings.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="Controls\PictureSettings.designer.cs">\r
+      <DependentUpon>PictureSettings.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="Controls\Subtitles.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="Controls\Subtitles.Designer.cs">\r
+      <DependentUpon>Subtitles.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="Controls\x264Panel.cs">\r
+      <SubType>UserControl</SubType>\r
+    </Compile>\r
+    <Compile Include="Controls\x264Panel.Designer.cs">\r
+      <DependentUpon>x264Panel.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="frmPreview.cs">\r
+      <SubType>Form</SubType>\r
+    </Compile>\r
+    <Compile Include="frmPreview.Designer.cs">\r
+      <DependentUpon>frmPreview.cs</DependentUpon>\r
+    </Compile>\r
     <Compile Include="frmActivityWindow.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
     <Compile Include="frmUpdater.designer.cs">\r
       <DependentUpon>frmUpdater.cs</DependentUpon>\r
     </Compile>\r
-    <Compile Include="frmMain\PresetLoader.cs" />\r
-    <Compile Include="frmMain\QueryGenerator.cs" />\r
-    <Compile Include="Functions\SystemInfo.cs" />\r
+    <Compile Include="Functions\GrowlCommunicator.cs" />\r
+    <Compile Include="Functions\PresetLoader.cs" />\r
+    <Compile Include="Functions\QueryGenerator.cs" />\r
     <Compile Include="Functions\Main.cs" />\r
+    <Compile Include="Functions\UpdateCheckInformation.cs" />\r
+    <Compile Include="Functions\Win32.cs" />\r
+    <Compile Include="Presets\Import.cs" />\r
     <Compile Include="Presets\preset.cs" />\r
     <Compile Include="Presets\PresetsHandler.cs" />\r
-    <Compile Include="Functions\Queue.cs" />\r
+    <Compile Include="EncodeQueue\EncodeAndQueueHandler.cs" />\r
     <Compile Include="Functions\AppcastReader.cs" />\r
-    <Compile Include="Functions\Encode.cs" />\r
     <Compile Include="Functions\QueryParser.cs" />\r
-    <Compile Include="frmMain\x264Panel.cs" />\r
     <Compile Include="Parsing\AudioTrack.cs" />\r
     <Compile Include="Parsing\Chapter.cs" />\r
     <Compile Include="Parsing\DVD.cs" />\r
     <Compile Include="Parsing\Title.cs" />\r
     <Compile Include="Program.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <EmbeddedResource Include="Controls\AudioPanel.resx">\r
+      <DependentUpon>AudioPanel.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="Controls\Filters.resx">\r
+      <DependentUpon>Filters.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="Controls\PictureSettings.resx">\r
+      <DependentUpon>PictureSettings.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="Controls\Subtitles.resx">\r
+      <DependentUpon>Subtitles.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="Controls\x264Panel.resx">\r
+      <DependentUpon>x264Panel.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="frmPreview.resx">\r
+      <DependentUpon>frmPreview.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
     <EmbeddedResource Include="frmActivityWindow.resx">\r
       <DependentUpon>frmActivityWindow.cs</DependentUpon>\r
       <SubType>Designer</SubType>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="frmUpdater.resx">\r
       <DependentUpon>frmUpdater.cs</DependentUpon>\r
+      <SubType>Designer</SubType>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="Properties\Resources.resx">\r
       <Generator>ResXFileCodeGenerator</Generator>\r
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
       <SubType>Designer</SubType>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="frmReadDVD.resx">\r
-      <SubType>Designer</SubType>\r
-      <DependentUpon>frmReadDVD.cs</DependentUpon>\r
-    </EmbeddedResource>\r
     <EmbeddedResource Include="frmSplashScreen.resx">\r
       <SubType>Designer</SubType>\r
       <DependentUpon>frmSplashScreen.cs</DependentUpon>\r
       <DependentUpon>Settings.settings</DependentUpon>\r
       <DesignTimeSharedInput>True</DesignTimeSharedInput>\r
     </Compile>\r
-    <Compile Include="frmReadDVD.cs">\r
-      <SubType>Form</SubType>\r
-    </Compile>\r
-    <Compile Include="frmReadDVD.Designer.cs">\r
-      <DependentUpon>frmReadDVD.cs</DependentUpon>\r
-    </Compile>\r
     <Compile Include="frmSplashScreen.cs">\r
       <SubType>Form</SubType>\r
     </Compile>\r
     <Compile Include="frmSplashScreen.Designer.cs">\r
       <DependentUpon>frmSplashScreen.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="EncodeQueue\Job.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Content Include="Changelog.html" />\r
     <Content Include="handbrakepineapple.ico" />\r
     <None Include="Resources\logo64.png" />\r
     <None Include="Resources\logo128.png" />\r
     <None Include="Resources\ActivityWindow.png" />\r
     <None Include="Resources\AddToQueue.png" />\r
     <Content Include="Resources\ActivityWindow_small.png" />\r
+    <None Include="Resources\AddToQueue_small.png" />\r
     <Content Include="Resources\copy.png" />\r
     <Content Include="Resources\disc_small.png" />\r
     <None Include="Resources\hb32.png" />\r
     <Content Include="Resources\Output_Small.png" />\r
     <None Include="Resources\Pause.png" />\r
     <None Include="Resources\Play.png" />\r
+    <None Include="Resources\picture.png" />\r
+    <None Include="Resources\Play_small.png" />\r
     <Content Include="Resources\Pref_Small.png" />\r
     <Content Include="Resources\Queue.png" />\r
     <Content Include="Resources\Queue_Small.png" />\r
+    <Content Include="Resources\window.png" />\r
     <None Include="Resources\save.png" />\r
     <None Include="Resources\stop.png" />\r
     <None Include="Resources\SplashScreen.jpg" />\r
       <Install>true</Install>\r
     </BootstrapperPackage>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <COMReference Include="AxQTOControlLib">\r
+      <Guid>{7B92F833-027D-402B-BFF9-A67697366F4E}</Guid>\r
+      <VersionMajor>1</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>aximp</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+    </COMReference>\r
+    <COMReference Include="QTOControlLib">\r
+      <Guid>{7B92F833-027D-402B-BFF9-A67697366F4E}</Guid>\r
+      <VersionMajor>1</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>tlbimp</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+    </COMReference>\r
+    <COMReference Include="QTOLibrary">\r
+      <Guid>{29866AED-1E14-417D-BA0F-1A2BE6F5A19E}</Guid>\r
+      <VersionMajor>1</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>tlbimp</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+    </COMReference>\r
+    <COMReference Include="stdole">\r
+      <Guid>{00020430-0000-0000-C000-000000000046}</Guid>\r
+      <VersionMajor>2</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+    </COMReference>\r
+  </ItemGroup>\r
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
index bb24dd5..5f0cad7 100644 (file)
@@ -8,11 +8,14 @@
 \r
 ; HM NIS Edit Wizard helper defines\r
 !define PRODUCT_NAME "Handbrake"\r
-!define PRODUCT_VERSION "0.9.1"\r
+!define PRODUCT_VERSION "SVN 2754 Snapshot"\r
+!define PRODUCT_VERSION_NUMBER "svn2754"\r
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Handbrake.exe"\r
 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"\r
 !define PRODUCT_UNINST_ROOT_KEY "HKLM"\r
 \r
+SetCompressor lzma\r
+\r
 ; MUI 1.67 compatible ------\r
 !include "MUI.nsh"\r
 \r
@@ -42,7 +45,7 @@
 ; MUI end ------\r
 \r
 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"\r
-OutFile "Handbrake-Setup.exe"\r
+OutFile "HandBrake-${PRODUCT_VERSION_NUMBER}-Win_GUI_CLI.exe"\r
 \r
 !include WordFunc.nsh\r
 !insertmacro VersionCompare\r
@@ -53,7 +56,7 @@ Function .onInit
   Call GetDotNETVersion\r
   Pop $0\r
   ${If} $0 == "not found"\r
-    MessageBox MB_OK|MB_ICONSTOP ".NET runtime library is not installed. $\r$\n You can download .Net Framework 2 from the microsoft website. $\r$\n Alternatively you can use google for a direct download URL"\r
+    MessageBox MB_OK|MB_ICONSTOP ".NET runtime library is not installed. $\r$\n You can download .Net Framework 2.0 redistributable from the microsoft website. $\r$\n Alternatively you can use google for a direct download URL"\r
     Abort\r
   ${EndIf}\r
 \r
@@ -61,7 +64,7 @@ Function .onInit
 \r
   ${VersionCompare} $0 "2.0" $1\r
   ${If} $1 == 2\r
-    MessageBox MB_OK|MB_ICONSTOP ".NET runtime library v2.0 or newer is required. You have $0. $\r$\n You can download .Net Framework 2 from the microsoft website. $\r$\n Alternatively you can use google for a direct download URL"\r
+    MessageBox MB_OK|MB_ICONSTOP ".NET runtime library v2.0 or newer is required. You have $0. $\r$\n You can download .Net Framework 2.0 redistributable from the Microsoft website. $\r$\n Alternatively you can use google for a direct download URL"\r
     Abort\r
   ${EndIf}\r
 FunctionEnd\r
@@ -91,16 +94,19 @@ Section "Handbrake" SEC01
   CreateDirectory "$SMPROGRAMS\Handbrake"\r
   CreateShortCut "$SMPROGRAMS\Handbrake\Handbrake.lnk" "$INSTDIR\Handbrake.exe"\r
   CreateShortCut "$DESKTOP\Handbrake.lnk" "$INSTDIR\Handbrake.exe"\r
-  File "dvdinfo.dat"\r
-  File "cygwin1.dll"\r
-  File "hbcli.exe"\r
+  File "Interop.QTOLibrary.dll"\r
+  File "Interop.QTOControlLib.dll"\r
+  File "AxInterop.QTOControlLib.dll"\r
+  File "Growl.Connector.dll"\r
+  File "Growl.CoreLibrary.dll"\r
+  File "libgcc_s_sjlj-1.dll"\r
+  File "HandBrakeCLI.exe"\r
   File "Handbrake.exe.config"\r
   File "handbrakepineapple.ico"\r
-  \r
+\r
   SetOutPath "$INSTDIR\doc"\r
   SetOverwrite ifnewer\r
   File "doc\AUTHORS"\r
-  File "doc\BUILD"\r
   File "doc\COPYING"\r
   File "doc\CREDITS"\r
   File "doc\NEWS"\r
@@ -134,25 +140,29 @@ FunctionEnd
 \r
 Section Uninstall\r
   Delete "$INSTDIR\uninst.exe"\r
+  \r
+  Delete "$INSTDIR\Interop.QTOLibrary.dll"\r
+  Delete "$INSTDIR\Interop.QTOControlLib.dll"\r
+  Delete "$INSTDIR\AxInterop.QTOControlLib.dll"\r
+  Delete "$INSTDIR\HandBrakeCLI.exe"\r
   Delete "$INSTDIR\handbrakepineapple.ico"\r
-  Delete "$INSTDIR\hbcli.exe"\r
-  Delete "$INSTDIR\cygwin1.dll"\r
-  Delete "$INSTDIR\dvdinfo.dat"\r
   Delete "$INSTDIR\Handbrake.exe"\r
   Delete "$INSTDIR\Handbrake.exe.config"\r
+  Delete "$INSTDIR\Growl.Connector.dll"\r
+  Delete "$INSTDIR\Growl.CoreLibrary.dll"\r
+  Delete "$INSTDIR\libgcc_s_sjlj-1.dll"\r
   Delete "$INSTDIR\doc\AUTHORS"\r
-  Delete "$INSTDIR\doc\BUILD"\r
   Delete "$INSTDIR\doc\COPYING"\r
   Delete "$INSTDIR\doc\CREDITS"\r
   Delete "$INSTDIR\doc\NEWS"\r
   Delete "$INSTDIR\doc\THANKS"\r
   Delete "$INSTDIR\doc\TRANSLATIONS"\r
-\r
+  RMDir  "$INSTDIR"\r
   Delete "$SMPROGRAMS\Handbrake\Uninstall.lnk"\r
   Delete "$DESKTOP\Handbrake.lnk"\r
   Delete "$SMPROGRAMS\Handbrake\Handbrake.lnk"\r
-  RMDir "$SMPROGRAMS\Handbrake"\r
-  RMDir "$INSTDIR"\r
+  RMDir  "$SMPROGRAMS\Handbrake"\r
+  RMDir  "$INSTDIR"\r
 \r
   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"\r
   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"\r
index 129ae78..56a3519 100644 (file)
@@ -16,76 +16,65 @@ namespace Handbrake.Parsing
     /// </summary>\r
     public class AudioTrack\r
     {\r
+        private int m_bitrate;\r
+        private string m_format;\r
+        private int m_frequency;\r
+        private string m_language;\r
+        private string m_subFormat;\r
         private int m_trackNumber;\r
+        private string m_iso639_2;\r
+\r
         /// <summary>\r
         /// The track number of this Audio Track\r
         /// </summary>\r
         public int TrackNumber\r
         {\r
-            get\r
-            {\r
-                return this.m_trackNumber;\r
-            }\r
+            get { return m_trackNumber; }\r
         }\r
 \r
-        private string m_language;\r
         /// <summary>\r
         /// The language (if detected) of this Audio Track\r
         /// </summary>\r
         public string Language\r
         {\r
-            get\r
-            {\r
-                return this.m_language;\r
-            }\r
+            get { return m_language; }\r
         }\r
 \r
-        private string m_format;\r
         /// <summary>\r
         /// The primary format of this Audio Track\r
         /// </summary>\r
         public string Format\r
         {\r
-            get\r
-            {\r
-                return this.m_format;\r
-            }\r
+            get { return m_format; }\r
         }\r
 \r
-        private string m_subFormat;\r
         /// <summary>\r
         /// Additional format info for this Audio Track\r
         /// </summary>\r
         public string SubFormat\r
         {\r
-            get\r
-            {\r
-                return this.m_subFormat;\r
-            }\r
+            get { return m_subFormat; }\r
         }\r
 \r
-        private int m_frequency;\r
         /// <summary>\r
         /// The frequency (in MHz) of this Audio Track\r
         /// </summary>\r
         public int Frequency\r
         {\r
-            get\r
-            {\r
-                return this.m_frequency;\r
-            }\r
+            get { return m_frequency; }\r
         }\r
 \r
-        private int m_bitrate;\r
         /// <summary>\r
         /// The bitrate (in kbps) of this Audio Track\r
         /// </summary>\r
         public int Bitrate\r
         {\r
-            get\r
-            {\r
-                return this.m_bitrate;\r
-            }\r
+            get { return m_bitrate; }\r
+        }\r
+\r
+        public string ISO639_2\r
+        {\r
+            get { return m_iso639_2;  }\r
         }\r
 \r
         /// <summary>\r
@@ -94,43 +83,49 @@ namespace Handbrake.Parsing
         /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>\r
         public override string ToString()\r
         {\r
-            return string.Format("{0} {1} ({2}) ({3})", this.m_trackNumber, this.m_language, this.m_format, this.m_subFormat);\r
+            if (m_subFormat == null)\r
+                return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_format);\r
+            \r
+            return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);\r
         }\r
 \r
         public static AudioTrack Parse(StringReader output)\r
         {\r
-            String audio_track= output.ReadLine();\r
-            Match m = Regex.Match(audio_track, @"^    \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\), ([0-9]*)Hz, ([0-9]*)bps");\r
-            Match y = Regex.Match(audio_track, @"^    \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)");\r
-            if (m.Success)\r
-            {\r
-                AudioTrack thisTrack = new AudioTrack();\r
-                thisTrack.m_trackNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
-                thisTrack.m_language = m.Groups[2].Value;\r
-                thisTrack.m_format = m.Groups[3].Value;\r
-                thisTrack.m_subFormat = m.Groups[4].Value;\r
-                thisTrack.m_frequency = int.Parse(m.Groups[5].Value.Trim().ToString());\r
-                thisTrack.m_bitrate = int.Parse(m.Groups[6].Value.Trim().ToString());\r
-                return thisTrack;\r
-            }\r
-            else if (y.Success)\r
+            String audio_track = output.ReadLine();\r
+            Match m = Regex.Match(audio_track, @"^    \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\)");\r
+            Match track = Regex.Match(audio_track, @"^    \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); // ID and Language\r
+            Match iso639_2 = Regex.Match(audio_track, @"iso639-2: ([a-zA-Z]*)\)");\r
+            Match samplerate = Regex.Match(audio_track, @"([0-9]*)Hz");\r
+            Match bitrate = Regex.Match(audio_track, @"([0-9]*)bps");\r
+\r
+            string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value;\r
+            string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", "").Trim() : "0";\r
+            string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", "").Trim() : "0";\r
+\r
+            if (track.Success)\r
             {\r
-                AudioTrack thisTrack = new AudioTrack();\r
-                thisTrack.m_trackNumber = int.Parse(y.Groups[1].Value.Trim().ToString());\r
-                thisTrack.m_language = y.Groups[2].Value;\r
-                thisTrack.m_format = y.Groups[3].Value;\r
-                return thisTrack;\r
+                var thisTrack = new AudioTrack\r
+                {\r
+                    m_trackNumber = int.Parse(track.Groups[1].Value.Trim()),\r
+                    m_language = track.Groups[2].Value,\r
+                    m_format = m.Groups[3].Value,\r
+                    m_subFormat = subformat,\r
+                    m_frequency = int.Parse(samplerateVal),\r
+                    m_bitrate = int.Parse(bitrateVal),\r
+                    m_iso639_2 = iso639_2.Value.Replace("iso639-2: ", "").Replace(")", "")\r
+                };\r
+                return thisTrack; \r
             }\r
-            else\r
-                return null;\r
+          \r
+            return null;\r
         }\r
 \r
         public static AudioTrack[] ParseList(StringReader output)\r
         {\r
-            List<AudioTrack> tracks = new List<AudioTrack>();\r
+            var tracks = new List<AudioTrack>();\r
             while (true)\r
             {\r
-                AudioTrack thisTrack = AudioTrack.Parse(output);\r
+                AudioTrack thisTrack = Parse(output);\r
                 if (thisTrack != null)\r
                     tracks.Add(thisTrack);\r
                 else\r
@@ -139,4 +134,4 @@ namespace Handbrake.Parsing
             return tracks.ToArray();\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
index 5269675..1bf38f4 100644 (file)
@@ -17,27 +17,23 @@ namespace Handbrake.Parsing
     public class Chapter\r
     {\r
         private int m_chapterNumber;\r
+\r
+        private TimeSpan m_duration;\r
+\r
         /// <summary>\r
         /// The number of this Chapter, in regards to it's parent Title\r
         /// </summary>\r
         public int ChapterNumber\r
         {\r
-            get\r
-            {\r
-                return this.m_chapterNumber;\r
-            }\r
+            get { return m_chapterNumber; }\r
         }\r
 \r
-        private TimeSpan m_duration;\r
         /// <summary>\r
         /// The length in time this Chapter spans\r
         /// </summary>\r
         public TimeSpan Duration\r
         {\r
-            get\r
-            {\r
-                return this.m_duration;\r
-            }\r
+            get { return m_duration; }\r
         }\r
 \r
         /// <summary>\r
@@ -46,26 +42,28 @@ namespace Handbrake.Parsing
         /// <returns>A string formatted as: {chapter #}</returns>\r
         public override string ToString()\r
         {\r
-            return this.m_chapterNumber.ToString();\r
+            return m_chapterNumber.ToString();\r
         }\r
 \r
         public static Chapter Parse(StringReader output)\r
         {\r
-            Match m = Regex.Match(output.ReadLine(), @"^    \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
+            Match m = Regex.Match(output.ReadLine(),\r
+                                  @"^    \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
             if (m.Success)\r
             {\r
-                Chapter thisChapter = new Chapter();\r
-                thisChapter.m_chapterNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
-                thisChapter.m_duration = TimeSpan.Parse(m.Groups[5].Value);\r
+                var thisChapter = new Chapter\r
+                                      {\r
+                                          m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),\r
+                                          m_duration = TimeSpan.Parse(m.Groups[5].Value)\r
+                                      };\r
                 return thisChapter;\r
             }\r
-            else\r
-                return null;\r
+            return null;\r
         }\r
 \r
         public static Chapter[] ParseList(StringReader output)\r
         {\r
-            List<Chapter> chapters = new List<Chapter>();\r
+            var chapters = new List<Chapter>();\r
 \r
             // this is to read the "  + chapters:" line from the buffer\r
             // so we can start reading the chapters themselvs\r
@@ -74,7 +72,7 @@ namespace Handbrake.Parsing
             while (true)\r
             {\r
                 // Start of the chapter list for this Title\r
-                Chapter thisChapter = Chapter.Parse(output);\r
+                Chapter thisChapter = Parse(output);\r
 \r
                 if (thisChapter != null)\r
                     chapters.Add(thisChapter);\r
@@ -84,4 +82,4 @@ namespace Handbrake.Parsing
             return chapters.ToArray();\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
index d0802e4..31fe2de 100644 (file)
@@ -4,47 +4,41 @@
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
-using System;\r
 using System.Collections.Generic;\r
-using System.Windows.Forms;\r
 using System.IO;\r
 \r
 namespace Handbrake.Parsing\r
 {\r
-\r
     /// <summary>\r
     /// An object representing a scanned DVD\r
     /// </summary>\r
     public class DVD\r
     {\r
+        private readonly List<Title> m_titles;\r
 \r
-        private List<Title> m_titles;\r
         /// <summary>\r
-        /// Collection of Titles associated with this DVD\r
+        /// Default constructor for this object\r
         /// </summary>\r
-        public List<Title> Titles\r
+        public DVD()\r
         {\r
-            get\r
-            {\r
-                return this.m_titles;\r
-            }\r
+            m_titles = new List<Title>();\r
         }\r
 \r
         /// <summary>\r
-        /// Default constructor for this object\r
+        /// Collection of Titles associated with this DVD\r
         /// </summary>\r
-        public DVD()\r
+        public List<Title> Titles\r
         {\r
-            this.m_titles = new List<Title>();\r
+            get { return m_titles; }\r
         }\r
 \r
         public static DVD Parse(StreamReader output)\r
         {\r
-            DVD thisDVD = new DVD();\r
+            var thisDVD = new DVD();\r
 \r
             while (!output.EndOfStream)\r
             {\r
-                if ((char)output.Peek() == '+')\r
+                if ((char) output.Peek() == '+')\r
                     thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
                 else\r
                     output.ReadLine();\r
@@ -53,4 +47,4 @@ namespace Handbrake.Parsing
             return thisDVD;\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
index bbafc92..9b0e645 100644 (file)
@@ -4,11 +4,10 @@
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
-using System;\r
-using System.Collections.Generic;\r
 using System.IO;\r
 using System.Text.RegularExpressions;\r
-using System.Windows.Forms;\r
+using System;\r
+using System.Globalization;\r
 \r
 namespace Handbrake.Parsing\r
 {\r
@@ -28,6 +27,19 @@ namespace Handbrake.Parsing
     public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);\r
 \r
     /// <summary>\r
+    /// A delegate to handle encode progress updates // EXPERIMENTAL\r
+    /// </summary>\r
+    /// <param name="Sender">The object which raised the event</param>\r
+    /// <param name="CurrentTask">The current task being processed from the queue</param>\r
+    /// <param name="TaskCount">The total number of tasks in queue</param>\r
+    /// <param name="PercentComplete">The percentage this task is complete</param>\r
+    /// <param name="CurrentFps">The current encoding fps</param>\r
+    /// <param name="AverageFps">The average encoding fps for this task</param>\r
+    /// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>\r
+    public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);\r
+\r
+       \r
+    /// <summary>\r
     /// A simple wrapper around a StreamReader to keep track of the entire output from a cli process\r
     /// </summary>\r
     internal class Parser : StreamReader\r
@@ -40,7 +52,7 @@ namespace Handbrake.Parsing
         {\r
             get\r
             {\r
-                return this.m_buffer;\r
+                return m_buffer;\r
             }\r
         }\r
 \r
@@ -59,22 +71,27 @@ namespace Handbrake.Parsing
         /// </summary>\r
         public event ScanProgressEventHandler OnScanProgress;\r
 \r
+        #region Experimetnal Code\r
+        /// <summary>\r
+        /// Raised upon the catching of a "Scanning title # of #..." in the stream\r
+        /// </summary>\r
+        public event EncodeProgressEventHandler OnEncodeProgress;\r
+        #endregion\r
 \r
         /// <summary>\r
         /// Default constructor for this object\r
         /// </summary>\r
         /// <param name="baseStream">The stream to parse from</param>\r
-        public Parser(Stream baseStream)\r
-            : base(baseStream)\r
+        public Parser(Stream baseStream) : base(baseStream)\r
         {\r
-            this.m_buffer = string.Empty;\r
+            m_buffer = string.Empty;\r
         }\r
 \r
         public override string ReadLine()\r
         {\r
             string tmp = base.ReadLine();\r
 \r
-            this.m_buffer += tmp;\r
+            m_buffer += tmp;\r
             Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");\r
             if (OnReadLine != null)\r
                 OnReadLine(this, tmp);\r
@@ -89,11 +106,36 @@ namespace Handbrake.Parsing
         {\r
             string tmp = base.ReadToEnd();\r
 \r
-            this.m_buffer += tmp;\r
+            m_buffer += tmp;\r
             if (OnReadToEnd != null)\r
                 OnReadToEnd(this, tmp);\r
 \r
             return tmp;\r
         }\r
+\r
+        /// <summary>\r
+        /// Pase the CLI status output (from standard output)\r
+        /// </summary>\r
+        public void readEncodeStatus()\r
+        {\r
+            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");\r
+            string tmp = base.ReadLine();\r
+\r
+            Match m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");\r
+            if (m.Success && OnEncodeProgress != null)\r
+            {\r
+                int currentTask = int.Parse(m.Groups[1].Value);\r
+                int totalTasks = int.Parse(m.Groups[2].Value);\r
+                float percent = float.Parse(m.Groups[3].Value, culture);\r
+                float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value, culture);\r
+                float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value, culture);\r
+                TimeSpan remaining = TimeSpan.Zero;\r
+                if (m.Groups[7].Value != string.Empty)\r
+                {\r
+                    remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value);\r
+                }\r
+                OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining);\r
+            }\r
+        }\r
     }\r
 }\r
index c5a722b..a765f1d 100644 (file)
@@ -4,7 +4,6 @@
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
-using System;\r
 using System.Collections.Generic;\r
 using System.IO;\r
 using System.Text.RegularExpressions;\r
@@ -16,61 +15,79 @@ namespace Handbrake.Parsing
     /// </summary>\r
     public class Subtitle\r
     {\r
+        private string m_language;\r
         private int m_trackNumber;\r
+        private string m_type;\r
+        private string m_typecode;\r
+\r
         /// <summary>\r
         /// The track number of this Subtitle\r
         /// </summary>\r
         public int TrackNumber\r
         {\r
-            get\r
-            {\r
-                return this.m_trackNumber;\r
-            }\r
+            get { return m_trackNumber; }\r
         }\r
 \r
-        private string m_language;\r
         /// <summary>\r
         /// The language (if detected) of this Subtitle\r
         /// </summary>\r
         public string Language\r
         {\r
-            get\r
-            {\r
-                return this.m_language;\r
-            }\r
+            get { return m_language; }\r
         }\r
 \r
         /// <summary>\r
+        /// Langauage Code\r
+        /// </summary>\r
+        public string LanguageCode\r
+        {\r
+            get { return m_typecode; }\r
+        }\r
+\r
+\r
+        /// <summary>\r
+        /// Subtitle Type\r
+        /// </summary>\r
+        public string Type\r
+        {\r
+            get { return m_type; }\r
+        }\r
+\r
+\r
+        /// <summary>\r
         /// Override of the ToString method to make this object easier to use in the UI\r
         /// </summary>\r
         /// <returns>A string formatted as: {track #} {language}</returns>\r
         public override string ToString()\r
         {\r
-            return string.Format("{0} {1}", this.m_trackNumber, this.m_language);\r
+            return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_type);\r
         }\r
 \r
         public static Subtitle Parse(StringReader output)\r
         {\r
             string curLine = output.ReadLine();\r
 \r
-            Match m = Regex.Match(curLine, @"^    \+ ([0-9]*), ([A-Za-z, ]*) \((.*)\)");\r
+            Match m = Regex.Match(curLine, @"^    \+ ([0-9]*), ([A-Za-z, ]*) \((.*)\) \(([a-zA-Z]*)\)");\r
             if (m.Success && !curLine.Contains("HandBrake has exited."))\r
             {\r
-                Subtitle thisSubtitle = new Subtitle();\r
-                thisSubtitle.m_trackNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
-                thisSubtitle.m_language = m.Groups[2].Value;\r
+                var thisSubtitle = new Subtitle\r
+                                       {\r
+                                           m_trackNumber = int.Parse(m.Groups[1].Value.Trim()),\r
+                                           m_language = m.Groups[2].Value,\r
+                                           m_typecode = m.Groups[3].Value,\r
+                                           m_type = m.Groups[4].Value\r
+                                       };\r
                 return thisSubtitle;\r
             }\r
-            else\r
-                return null;\r
+            return null;\r
         }\r
 \r
         public static Subtitle[] ParseList(StringReader output)\r
         {\r
-            List<Subtitle> subtitles = new List<Subtitle>();\r
-            while ((char)output.Peek() != '+')\r
+            var subtitles = new List<Subtitle>();\r
+            while ((char) output.Peek() != '+')\r
             {\r
-                Subtitle thisSubtitle = Subtitle.Parse(output);\r
+                Subtitle thisSubtitle = Parse(output);\r
 \r
                 if (thisSubtitle != null)\r
                     subtitles.Add(thisSubtitle);\r
@@ -80,4 +97,4 @@ namespace Handbrake.Parsing
             return subtitles.ToArray();\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
index 05521c0..a88b7ba 100644 (file)
@@ -7,8 +7,8 @@
 using System;\r
 using System.Collections.Generic;\r
 using System.Drawing;\r
+using System.Globalization;\r
 using System.IO;\r
-using System.Windows.Forms;\r
 using System.Text.RegularExpressions;\r
 \r
 namespace Handbrake.Parsing\r
@@ -18,91 +18,92 @@ namespace Handbrake.Parsing
     /// </summary>\r
     public class Title\r
     {\r
-        private List<Chapter> m_chapters;\r
+        private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
+        private readonly List<AudioTrack> m_audioTracks;\r
+        private readonly List<Chapter> m_chapters;\r
+        private readonly List<Subtitle> m_subtitles;\r
+        private List<String> m_angles = new List<string>();\r
+        private float m_aspectRatio;\r
+        private int[] m_autoCrop;\r
+        private TimeSpan m_duration;\r
+        private Size m_resolution;\r
+        private int m_titleNumber;\r
+        private Size m_parVal;\r
+        \r
+        /// <summary>\r
+        /// The constructor for this object\r
+        /// </summary>\r
+        public Title()\r
+        {\r
+            m_audioTracks = new List<AudioTrack>();\r
+            m_chapters = new List<Chapter>();\r
+            m_subtitles = new List<Subtitle>();\r
+        }\r
+\r
         /// <summary>\r
         /// Collection of chapters in this Title\r
         /// </summary>\r
         public List<Chapter> Chapters\r
         {\r
-            get\r
-            {\r
-                return this.m_chapters;\r
-            }\r
+            get { return m_chapters; }\r
         }\r
 \r
-        private List<AudioTrack> m_audioTracks;\r
         /// <summary>\r
         /// Collection of audio tracks associated with this Title\r
         /// </summary>\r
         public List<AudioTrack> AudioTracks\r
         {\r
-            get\r
-            {\r
-                return this.m_audioTracks;\r
-            }\r
+            get { return m_audioTracks; }\r
         }\r
 \r
-        private List<Subtitle> m_subtitles;\r
         /// <summary>\r
         /// Collection of subtitles associated with this Title\r
         /// </summary>\r
         public List<Subtitle> Subtitles\r
         {\r
-            get\r
-            {\r
-                return this.m_subtitles;\r
-            }\r
+            get { return m_subtitles; }\r
         }\r
 \r
-        private int m_titleNumber;\r
         /// <summary>\r
         /// The track number of this Title\r
         /// </summary>\r
         public int TitleNumber\r
         {\r
-            get\r
-            {\r
-                return this.m_titleNumber;\r
-            }\r
+            get { return m_titleNumber; }\r
         }\r
 \r
-        private TimeSpan m_duration;\r
         /// <summary>\r
         /// The length in time of this Title\r
         /// </summary>\r
         public TimeSpan Duration\r
         {\r
-            get\r
-            {\r
-                return this.m_duration;\r
-            }\r
+            get { return m_duration; }\r
         }\r
 \r
-        private Size m_resolution;\r
         /// <summary>\r
         /// The resolution (width/height) of this Title\r
         /// </summary>\r
         public Size Resolution\r
         {\r
-            get\r
-            {\r
-                return this.m_resolution;\r
-            }\r
+            get { return m_resolution; }\r
         }\r
 \r
-        private float m_aspectRatio;\r
         /// <summary>\r
         /// The aspect ratio of this Title\r
         /// </summary>\r
         public float AspectRatio\r
         {\r
-            get\r
-            {\r
-                return this.m_aspectRatio;\r
-            }\r
+            get { return m_aspectRatio; }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Par Value\r
+        /// </summary>\r
+        public Size ParVal\r
+        {\r
+            get { return m_parVal; }\r
         }\r
 \r
-        private int[] m_autoCrop;\r
         /// <summary>\r
         /// The automatically detected crop region for this Title.\r
         /// This is an int array with 4 items in it as so:\r
@@ -113,61 +114,78 @@ namespace Handbrake.Parsing
         /// </summary>\r
         public int[] AutoCropDimensions\r
         {\r
-            get\r
-            {\r
-                return this.m_autoCrop;\r
-            }\r
+            get { return m_autoCrop; }\r
         }\r
 \r
         /// <summary>\r
-        /// The constructor for this object\r
+        /// Collection of Angles in this Title\r
         /// </summary>\r
-        public Title()\r
+        public List<string> Angles\r
         {\r
-            this.m_audioTracks = new List<AudioTrack>();\r
-            this.m_chapters = new List<Chapter>();\r
-            this.m_subtitles = new List<Subtitle>();\r
+            get { return m_angles; }\r
         }\r
-\r
+  \r
         /// <summary>\r
         /// Override of the ToString method to provide an easy way to use this object in the UI\r
         /// </summary>\r
         /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>\r
         public override string ToString()\r
         {\r
-            return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.m_titleNumber, this.m_duration.Hours,\r
-             this.m_duration.Minutes, this.m_duration.Seconds);\r
+            return string.Format("{0} ({1:00}:{2:00}:{3:00})", m_titleNumber, m_duration.Hours,\r
+                                 m_duration.Minutes, m_duration.Seconds);\r
         }\r
 \r
         public static Title Parse(StringReader output)\r
         {\r
-            Title thisTitle = new Title();\r
+            var thisTitle = new Title();\r
 \r
             Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
             // Match track number for this title\r
             if (m.Success)\r
-                thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());\r
+                thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim());\r
 \r
-            String testData = output.ReadLine();\r
+            output.ReadLine();\r
 \r
-            // Get duration for this title\r
+            if (!Properties.Settings.Default.noDvdNav)\r
+            {\r
+                // Get the Angles for the title.\r
+                m = Regex.Match(output.ReadLine(), @"  \+ angle\(s\) ([0-9])");\r
+                if (m.Success)\r
+                {\r
+                    String angleList = m.Value.Replace("+ angle(s) ", "").Trim();\r
+                    int angleCount;\r
+                    int.TryParse(angleList, out angleCount);\r
+\r
+                    for (int i = 1; i <= angleCount; i++)\r
+                        thisTitle.m_angles.Add(i.ToString());\r
+                }\r
+            }\r
 \r
+            // Get duration for this title\r
             m = Regex.Match(output.ReadLine(), @"^  \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
             if (m.Success)\r
                 thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
 \r
             // Get resolution, aspect ratio and FPS for this title\r
-            m = Regex.Match(output.ReadLine(), @"^  \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
+            m = Regex.Match(output.ReadLine(),\r
+                            @"^  \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
+            //size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps\r
+\r
             if (m.Success)\r
             {\r
                 thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
-                thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);\r
+                thisTitle.m_parVal = new Size(int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value));\r
+                thisTitle.m_aspectRatio = float.Parse(m.Groups[5].Value, Culture);\r
             }\r
 \r
             // Get autocrop region for this title\r
             m = Regex.Match(output.ReadLine(), @"^  \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
             if (m.Success)\r
-                thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };\r
+                thisTitle.m_autoCrop = new int[]\r
+                                           {\r
+                                               int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value),\r
+                                               int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)\r
+                                           };\r
 \r
             thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
 \r
@@ -180,8 +198,8 @@ namespace Handbrake.Parsing
 \r
         public static Title[] ParseList(string output)\r
         {\r
-            List<Title> titles = new List<Title>();\r
-            StringReader sr = new StringReader(output);\r
+            var titles = new List<Title>();\r
+            var sr = new StringReader(output);\r
 \r
             while (sr.Peek() == '+' || sr.Peek() == ' ')\r
             {\r
@@ -189,10 +207,10 @@ namespace Handbrake.Parsing
                 if (sr.Peek() == ' ') // If the character is a space, then chances are it's the combing detected line.\r
                     sr.ReadLine(); // Skip over it\r
                 else\r
-                    titles.Add(Title.Parse(sr));              \r
+                    titles.Add(Parse(sr));\r
             }\r
 \r
             return titles.ToArray();\r
         }\r
     }\r
-}\r
+}
\ No newline at end of file
diff --git a/win/C#/Presets/Import.cs b/win/C#/Presets/Import.cs
new file mode 100644 (file)
index 0000000..4d6b1b4
--- /dev/null
@@ -0,0 +1,264 @@
+using System;\r
+using System.IO;\r
+using System.Xml;\r
+using System.Windows.Forms;\r
+using System.Collections;\r
+using Handbrake.Functions;\r
+\r
+namespace Handbrake.Presets\r
+{\r
+    class Import\r
+    {\r
+        public QueryParser importMacPreset(string filename)\r
+        {\r
+            if (!File.Exists(filename))\r
+                return null;\r
+\r
+            StreamReader sr = File.OpenText(filename);\r
+            string fromfile = string.Empty;\r
+            int fileChar;\r
+            while ((fileChar = sr.Read()) != -1)\r
+                fromfile += Convert.ToChar(fileChar);\r
+\r
+            XmlDocument doc = new XmlDocument();\r
+            doc.LoadXml(fromfile);\r
+\r
+            XmlNode root = doc;\r
+            if (!root.HasChildNodes)\r
+            {\r
+                MessageBox.Show(\r
+                    "The Preset file you selected appears to be invlaid or from an older version of HandBrake", "Error",\r
+                    MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                return null;\r
+            }\r
+\r
+            // We'll query a query parser object and use it's public var structures to store all the data.\r
+            // This will allow the preset loader logic to be used instead of writing custom logic just for this file.\r
+            QueryParser queryParsed = new QueryParser();\r
+\r
+            /***** Get the Audio Tracks *****/\r
+            XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];\r
+            ArrayList AudioInfo = new ArrayList();\r
+            for (int i = 0; i < audioListDict.ChildNodes.Count; i++)\r
+            {\r
+                XmlNode audioChannel = audioListDict.ChildNodes[i];\r
+                AudioTrack track = new AudioTrack();\r
+\r
+                for (int subi = 0; subi < audioChannel.ChildNodes.Count; subi += 2)\r
+                {\r
+                    // Audio Channel Information is here.\r
+                    string key = audioChannel.ChildNodes[subi].InnerText;\r
+                    string value = audioChannel.ChildNodes[subi + 1].InnerText;\r
+                    switch (key)\r
+                    {\r
+                        case "AudioBitrate":\r
+                            track.Bitrate = value;\r
+                            break;\r
+                        case "AudioEncoder":\r
+                            track.Encoder = value.Replace("AAC (CoreAudio)", "AAC (faac)");\r
+                            break;\r
+                        case "AudioMixdown":\r
+                            track.MixDown = value;\r
+                            break;\r
+                        case "AudioSamplerate":\r
+                            track.SampleRate = value;\r
+                            break;\r
+                        case "AudioTrack":\r
+                            track.Track = value;\r
+                            break;\r
+                        case "AudioTrackDRCSlider":\r
+                            track.DRC = value;\r
+                            break;\r
+                    }\r
+                }\r
+               AudioInfo.Add(track);\r
+            }\r
+            queryParsed.AudioInformation = AudioInfo;\r
+\r
+            /***** Get the rest of the settings. *****/\r
+            XmlNode presetSettings = root.ChildNodes[2].ChildNodes[0].FirstChild;\r
+            for (int i = 2; i < presetSettings.ChildNodes.Count; i += 2) // Start from 2 to avoid the audio settings which we don't need.\r
+            {\r
+                string key = presetSettings.ChildNodes[i].InnerText;\r
+                string value = presetSettings.ChildNodes[i + 1].InnerText;\r
+\r
+                switch (key)\r
+                {\r
+                    // Output Settings\r
+                    case "FileFormat":\r
+                        queryParsed.Format = value;\r
+                        break;\r
+                    case "Mp4HttpOptimize":\r
+                        queryParsed.OptimizeMP4 = value == "1";\r
+                        break;\r
+                    case "Mp4LargeFile":\r
+                        queryParsed.LargeMP4 = value == "1";\r
+                        break;\r
+                    case "Mp4iPodCompatible":\r
+                        queryParsed.IpodAtom = value == "1";\r
+                        break;\r
+\r
+                    // Picture Settings\r
+                    case "PictureAutoCrop":\r
+                        break;\r
+                    case "PictureTopCrop":\r
+                        queryParsed.CropTop = value;\r
+                        break;\r
+                    case "PictureBottomCrop":\r
+                        queryParsed.CropBottom = value;\r
+                        break;\r
+                    case "PictureLeftCrop":\r
+                        queryParsed.CropLeft = value;\r
+                        break;\r
+                    case "PictureRightCrop":\r
+                        queryParsed.CropRight = value;\r
+                        break;\r
+                    case "PictureHeight":\r
+                        queryParsed.Height = int.Parse(value);\r
+                        break;\r
+                    case "PictureWidth":\r
+                        queryParsed.Width = int.Parse(value);\r
+                        break;\r
+                    case "PictureKeepRatio":\r
+                        queryParsed.keepDisplayAsect = value == "1";\r
+                        break;\r
+                    case "PicturePAR":\r
+                        queryParsed.AnamorphicMode = int.Parse(value);\r
+                        break;\r
+\r
+\r
+                    // Filters\r
+                    case "PictureDeblock":\r
+                        queryParsed.DeBlock = int.Parse(value);\r
+                        break;\r
+                    case "PictureDecomb":\r
+                        queryParsed.Decomb = "Off";\r
+                        if (value == "2") queryParsed.Decomb = "Default";\r
+                        break;\r
+                    case "PictureDecombCustom":\r
+                        if (value != "")\r
+                            queryParsed.Decomb = value;\r
+                        break;\r
+                    case "PictureDecombDeinterlace":\r
+                        // Not Used\r
+                        break;\r
+                    case "PictureDeinterlace":\r
+                        switch (value)\r
+                        {\r
+                            case "0":\r
+                                queryParsed.DeInterlace = "Off";\r
+                                break;\r
+                            case "2":\r
+                                queryParsed.DeInterlace = "Fast";\r
+                                break;\r
+                            case "3":\r
+                                queryParsed.DeInterlace = "Slow";\r
+                                break;\r
+                            case "4":\r
+                                queryParsed.DeInterlace = "Slowest";\r
+                                break;\r
+                        }\r
+                        break;\r
+                    case "PictureDeinterlaceCustom":\r
+                        if (value != "")\r
+                            queryParsed.DeInterlace = value;\r
+                        break;\r
+                    case "PictureDenoise":\r
+                        switch (value)\r
+                        {\r
+                            case "0":\r
+                                queryParsed.DeNoise = "Off";\r
+                                break;\r
+                            case "2":\r
+                                queryParsed.DeNoise = "Weak";\r
+                                break;\r
+                            case "3":\r
+                                queryParsed.DeNoise = "Medium";\r
+                                break;\r
+                            case "4":\r
+                                queryParsed.DeNoise = "Strong";\r
+                                break;\r
+                        }\r
+\r
+                        break;\r
+                    case "PictureDenoiseCustom":\r
+                        if (value != "")\r
+                            queryParsed.DeNoise = value;\r
+                        break;\r
+                    case "PictureDetelecine":\r
+                        queryParsed.DeTelecine = "Off";\r
+                        if (value == "1") queryParsed.DeTelecine = "Default";\r
+                        break;\r
+                    case "PictureDetelecineCustom":\r
+                        if (value != "")\r
+                            queryParsed.DeTelecine = value;\r
+                        break;\r
+\r
+                    // Video Tab\r
+                    case "VideoAvgBitrate":\r
+                        queryParsed.Width = int.Parse(value);\r
+                        break;\r
+                    case "VideoEncoder":\r
+                        queryParsed.VideoEncoder = value;\r
+                        break;\r
+                    case "VideoFramerate":\r
+                        queryParsed.VideoFramerate = value;\r
+                        break;\r
+                    case "VideoGrayScale":\r
+                        queryParsed.Grayscale = value == "1";\r
+                        break;\r
+                    case "VideoQualitySlider":\r
+                        queryParsed.VideoQuality = float.Parse(value);\r
+                        break;\r
+                    case "VideoQualityType":\r
+                        break;\r
+                    case "VideoTargetSize":\r
+                        queryParsed.VideoTargetSize = value;\r
+                        break;\r
+                    case "VideoTurboTwoPass":\r
+                        queryParsed.TurboFirstPass = value == "1";\r
+                        break;\r
+                    case "VideoTwoPass":\r
+                        queryParsed.TwoPass = value == "1";\r
+                        break;\r
+\r
+                    // Chapter Markers Tab\r
+                    case "ChapterMarkers":\r
+                        queryParsed.ChapterMarkers = value == "1";\r
+                        break;\r
+\r
+                    // Advanced x264 tab\r
+                    case "x264Option":\r
+                        queryParsed.H264Query = value;\r
+                        break;\r
+\r
+                    // Preset Information\r
+                    case "PresetBuildNumber":\r
+                        queryParsed.PresetBuildNumber = int.Parse(value);\r
+                        break;\r
+                    case "PresetDescription":\r
+                        queryParsed.PresetDescription = value;\r
+                        break;\r
+                    case "PresetName":\r
+                        queryParsed.PresetName = value;\r
+                        break;\r
+                    case "Type":\r
+                        queryParsed.Type = value;\r
+                        break;\r
+                    case "UsesMaxPictureSettings":\r
+                        queryParsed.UsesMaxPictureSettings = value == "1";\r
+                        break;\r
+                    case "UsesPictureFilters":\r
+                        queryParsed.UsesPictureFilters = value == "1";\r
+                        break;\r
+                    case "UsesPictureSettings":\r
+                        queryParsed.UsesPictureSettings = value == "1";\r
+                        break;\r
+                }\r
+            }\r
+            return queryParsed;\r
+        }\r
+\r
+        // --- It's the end of the road\r
+    }\r
+}
\ No newline at end of file
index 172125a..1609c1f 100644 (file)
@@ -1,6 +1,11 @@
-using System;\r
+/*  PresetHandler.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+using System;\r
 using System.Collections.Generic;\r
-using System.Text;\r
+using System.Drawing;\r
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Text.RegularExpressions;\r
@@ -11,116 +16,113 @@ namespace Handbrake.Presets
 {\r
     public class PresetsHandler\r
     {\r
-        List<Preset> presets = new List<Preset>();  // Category+Level+Preset Name: Query\r
-        List<Preset> user_presets = new List<Preset>(); // Preset Name: Query\r
-        private static XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));\r
+        List<Preset> _presets = new List<Preset>();\r
+        List<Preset> _userPresets = new List<Preset>();\r
+        private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));\r
+        readonly string _userPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";\r
+        readonly string _hbPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml";\r
 \r
         /// <summary>\r
         /// Add a new preset to the system\r
         /// </summary>\r
         /// <param name="presetName">String, The name of the new preset</param>\r
         /// <param name="query">String, the CLI query for the new preset</param>\r
-        public Boolean addPreset(string presetName, string query)\r
+        /// <param name="pictureSettings"> Bool, store crop/picture sizes in the _presets</param>\r
+        public Boolean Add(string presetName, string query, Boolean pictureSettings)\r
         {\r
-            if (checkIfPresetExists(presetName) == false)\r
+            if (CheckIfPresetExists(presetName) == false)\r
             {\r
-                Preset newPreset = new Preset();\r
-                newPreset.Name = presetName;\r
-                newPreset.Query = query;\r
-                user_presets.Add(newPreset);\r
-                updateUserPresetsFile();\r
+                Preset newPreset = new Preset { Name = presetName, Query = query, PictureSettings = pictureSettings, Version = Properties.Settings.Default.hb_version };\r
+                _userPresets.Add(newPreset);\r
+                UpdatePresetFiles();\r
                 return true;\r
             }\r
-            else\r
-            {\r
-                MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-                return false;\r
-            }\r
+            return false;\r
         }\r
 \r
         /// <summary>\r
         /// Remove a preset with a given name from either the built in or user preset list.\r
         /// </summary>\r
         /// <param name="name">String, the preset name</param>\r
-        public void remove(string name)\r
+        public void Remove(string name)\r
         {\r
             List<Preset> newPresets = new List<Preset>();\r
             List<Preset> newUserPresets = new List<Preset>();\r
 \r
             // Built In Presets\r
-            foreach (Preset item in presets)\r
+            foreach (Preset item in _presets)\r
             {\r
                 if (item.Name != name)\r
                 {\r
                     newPresets.Add(item);\r
                 }\r
             }\r
-            presets = newPresets;\r
+            _presets = newPresets;\r
 \r
             // User Presets\r
-            foreach (Preset item in user_presets)\r
+            foreach (Preset item in _userPresets)\r
             {\r
                 if (item.Name != name)\r
                 {\r
                     newUserPresets.Add(item);\r
                 }\r
             }\r
-            user_presets = newUserPresets;\r
-\r
-            // Now, Update the presets.xml and user_presets.xml file with the new items.\r
-            string userPresets = Application.StartupPath.ToString() + "\\user_presets.xml";\r
-            string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";\r
+            _userPresets = newUserPresets;\r
 \r
-            // Rebuild the user_presets.xml file\r
-            updateUserPresetsFile();\r
-            updatePresetsFile();\r
+            // Rebuild the _userPresets.xml file\r
+            UpdatePresetFiles();\r
+            UpdatePresetFiles();\r
         }\r
 \r
         /// <summary>\r
-        /// Get a List of all the built in preset names.\r
+        /// Remove all built in _presets;\r
         /// </summary>\r
-        /// <returns>List<String> of preset names</returns>\r
-        public List<Preset> getBuildInPresets()\r
+        public void RemoveBuiltInPresets()\r
         {\r
-            return presets;\r
+            _presets.Clear();\r
+            UpdatePresetFiles();\r
         }\r
 \r
         /// <summary>\r
-        /// Get a List of all the User preset names.\r
+        /// Save changes to a given preset in the user preset list.\r
         /// </summary>\r
-        /// <returns>List<String> of preset names</returns>\r
-        public List<string> getUserPresetNames()\r
+        /// <param name="presetName">String, The name of the new preset</param>\r
+        /// <param name="query">String, the CLI query for the new preset</param>\r
+        /// <param name="pictureSettings"> Bool, store crop/picture sizes in the preset</param>\r
+        public void Update(string presetName, string query, Boolean pictureSettings)\r
         {\r
-            List<string> names = new List<string>();\r
-\r
             // User Presets\r
-            foreach (Preset item in user_presets)\r
+            foreach (Preset item in _userPresets)\r
             {\r
-                names.Add(item.Name);\r
+                if (item.Name == presetName)\r
+                {\r
+                    item.Query = query;\r
+                    item.PictureSettings = pictureSettings;\r
+                    MessageBox.Show("Changes to \"" + presetName + "\" Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+                    UpdatePresetFiles();\r
+                }\r
             }\r
-\r
-            return names;\r
         }\r
 \r
         /// <summary>\r
         /// Return the CLI query for a preset name given in name\r
         /// </summary>\r
         /// <param name="name">String, The preset's name</param>\r
-        /// <returns>String, the CLI query for the given preset name</returns>\r
-        public string getCliForPreset(string name)\r
+        /// <returns>String, the CLI query for the given preset name</returns>    not\r
+        public Preset GetPreset(string name)\r
         {\r
             // Built In Presets\r
-            foreach (Preset item in presets)\r
+            foreach (Preset item in _presets)\r
             {\r
                 if (item.Name == name)\r
-                    return item.Query;\r
+                    return item;\r
             }\r
 \r
             // User Presets\r
-            foreach (Preset item in user_presets)\r
+            foreach (Preset item in _userPresets)\r
             {\r
                 if (item.Name == name)\r
-                    return item.Query;\r
+                    return item;\r
             }\r
 \r
             return null;\r
@@ -129,183 +131,184 @@ namespace Handbrake.Presets
         /// <summary>\r
         /// Reads the CLI's CLI output format and load's them into the preset List<Preset>\r
         /// </summary>\r
-        public void updateBuiltInPresets()\r
+        public void UpdateBuiltInPresets()\r
         {\r
-            // Create a new tempory file and execute the CLI to get the built in presets.\r
+            // Create a new tempory file and execute the CLI to get the built in _presets.\r
             string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
             string presetsPath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");\r
-\r
             string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);\r
 \r
-            ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);\r
-            hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;\r
-\r
+            ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden };\r
             Process hbproc = Process.Start(hbGetPresets);\r
-            hbproc.WaitForExit();\r
-            hbproc.Dispose();\r
-            hbproc.Close();\r
-\r
-            // Clear the current built in presets and now parse the tempory presets file.\r
-            presets.Clear();\r
-            string filePath = Path.Combine(Path.GetTempPath(), "temp_presets.dat");\r
-            if (File.Exists(filePath))\r
+            if (hbproc != null)\r
             {\r
-                StreamReader presetInput = new StreamReader(filePath);\r
-                int level = 1;\r
+                hbproc.WaitForExit();\r
+                hbproc.Dispose();\r
+                hbproc.Close();\r
+            }\r
+\r
+            // Clear the current built in _presets and now parse the tempory _presets file.\r
+            _presets.Clear();\r
+\r
+            if (File.Exists(presetsPath))\r
+            {\r
+                StreamReader presetInput = new StreamReader(presetsPath);\r
+\r
                 string category = String.Empty;\r
-                string level_1_category = String.Empty;\r
 \r
                 while (!presetInput.EndOfStream)\r
                 {\r
                     string line = presetInput.ReadLine();\r
-                    if (line.Contains("<") && !line.Contains("<<"))\r
-                    {\r
-                        level = 1;\r
+                    if (line.Contains("<") && !line.Contains("<<")) // Found the beginning of a preset block \r
                         category = line.Replace("<", "").Trim();\r
-                        level_1_category = category;\r
-                    }\r
-\r
-                    if (line.Contains("<<"))\r
-                    {\r
-                        level = 2;\r
-                        category = line.Replace("<<", "").Trim();\r
-                    }\r
 \r
-                    if (line.Trim().Contains(">>"))\r
-                    {\r
-                        level = 1;\r
-                        category = level_1_category;\r
-                    }\r
-\r
-                    if (line.Contains("+"))\r
+                    if (line.Contains("+")) // A Preset\r
                     {\r
                         Regex r = new Regex("(:  )"); // Split on hyphens. \r
                         string[] presetName = r.Split(line);\r
 \r
-                        Preset newPreset = new Preset();\r
-                        newPreset.Level = level;\r
-                        newPreset.Category = category;\r
-                        newPreset.Name = presetName[0].Replace("+", "").Trim();\r
-                        newPreset.Query = presetName[2];\r
-                        presets.Add(newPreset);\r
+                        Preset newPreset = new Preset\r
+                                               {   Category = category,\r
+                                                   Name = presetName[0].Replace("+", "").Trim(),\r
+                                                   Query = presetName[2],\r
+                                                   Version = Properties.Settings.Default.hb_version,\r
+                                                   PictureSettings = true\r
+                                               };\r
+                        _presets.Add(newPreset);\r
                     }\r
                 }\r
                 presetInput.Close();\r
                 presetInput.Dispose();\r
             }\r
 \r
-            // Finally, Create a new or update the current presets.xml file\r
-            updatePresetsFile();\r
+            // Finally, Create a new or update the current _presets.xml file\r
+            UpdatePresetFiles();\r
         }\r
 \r
         /// <summary>\r
-        /// Load in the preset data from presets.xml and user_presets.xml\r
-        /// Load it into the 2 arraylist's presets and user_presets\r
+        /// Load in the preset data from _presets.xml and _userPresets.xml\r
+        /// Load it into the 2 arraylist's _presets and _userPresets\r
         /// </summary>\r
-        public void loadPresetData()\r
+        private void LoadPresetData()\r
         {\r
-            // First clear the presets arraylists\r
-            presets.Clear();\r
-            user_presets.Clear();\r
-\r
-            string filePath = string.Empty;\r
+            // First clear the _presets arraylists\r
+            _presets.Clear();\r
+            _userPresets.Clear();\r
 \r
-            // Load in the users presets from user_presets.xml\r
-            filePath = Application.StartupPath.ToString() + "\\presets.xml";\r
-            if (File.Exists(filePath))\r
+            // Load in the users _presets from _userPresets.xml\r
+            if (File.Exists(_hbPresetFile))\r
             {\r
-                using (FileStream strm = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r
+                using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Open, FileAccess.Read))\r
                 {\r
                     if (strm.Length != 0)\r
                     {\r
-                        List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
+                        List<Preset> list = Ser.Deserialize(strm) as List<Preset>;\r
 \r
-                        foreach (Preset preset in list)\r
-                            presets.Add(preset);\r
+                        if (list != null)\r
+                            foreach (Preset preset in list)\r
+                                _presets.Add(preset);\r
                     }\r
                 }\r
             }\r
 \r
-            // Load in the users presets from user_presets.xml\r
-            filePath = Application.StartupPath.ToString() + "\\user_presets.xml";\r
-            if (File.Exists(filePath))\r
+            // Load in the users _presets from _userPresets.xml\r
+            if (File.Exists(_userPresetFile))\r
             {\r
-                using (FileStream strm = new FileStream(filePath, FileMode.Open, FileAccess.Read))\r
+                using (FileStream strm = new FileStream(_userPresetFile, FileMode.Open, FileAccess.Read))\r
                 {\r
                     if (strm.Length != 0)\r
                     {\r
-                        List<Preset> list = ser.Deserialize(strm) as List<Preset>;\r
+                        List<Preset> list = Ser.Deserialize(strm) as List<Preset>;\r
 \r
-                        foreach (Preset preset in list)\r
-                            user_presets.Add(preset);\r
+                        if (list != null)\r
+                            foreach (Preset preset in list)\r
+                                _userPresets.Add(preset);\r
                     }\r
                 }\r
             }\r
         }\r
 \r
         /// <summary>\r
-        /// Updates the presets.xml file which contains the built in presets\r
-        /// It takes the List of Presets and converts them into XML which is stored in presets.xml\r
+        /// Setup the frmMain preset panel\r
         /// </summary>\r
-        private void updatePresetsFile()\r
+        /// <param name="presetPanel"></param>\r
+        public void GetPresetPanel(ref TreeView presetPanel)\r
         {\r
-            string userPresets = Application.StartupPath.ToString() + "\\presets.xml";\r
-            try\r
+            this.LoadPresetData();\r
+            presetPanel.Nodes.Clear();\r
+\r
+            if (_presets.Count != 0) // Built In Presets\r
             {\r
-                using (FileStream strm = new FileStream(userPresets, FileMode.Create, FileAccess.Write))\r
+                string category = string.Empty;\r
+                TreeNode rootNode = null;\r
+\r
+                foreach (Preset preset in _presets)\r
                 {\r
-                    ser.Serialize(strm, presets);\r
-                    strm.Close();\r
-                    strm.Dispose();\r
+                    if (preset.Category != category)\r
+                    {\r
+                        rootNode = new TreeNode(preset.Category);\r
+                        presetPanel.Nodes.Add(rootNode);\r
+                        category = preset.Category;\r
+                    }\r
+\r
+                    if (preset.Category == category && rootNode != null)\r
+                        rootNode.Nodes.Add(preset.Name);\r
                 }\r
             }\r
-            catch (Exception exc)\r
+\r
+            foreach (Preset preset in _userPresets) // User Presets\r
             {\r
-                MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                TreeNode presetTreeview = new TreeNode(preset.Name) { ForeColor = Color.Black };\r
+                presetPanel.Nodes.Add(presetTreeview);\r
             }\r
         }\r
 \r
         /// <summary>\r
-        /// Updates the user_presets.xml file which contains the built in presets\r
-        /// It takes the List of Presets and converts them into XML which is stored in user_presets.xml\r
+        /// Update the preset files\r
         /// </summary>\r
-        private void updateUserPresetsFile()\r
+        private void UpdatePresetFiles()\r
         {\r
-            string userPresets = Application.StartupPath.ToString() + "\\user_presets.xml";\r
             try\r
             {\r
-                using (FileStream strm = new FileStream(userPresets, FileMode.Create, FileAccess.Write))\r
+                using (FileStream strm = new FileStream(_hbPresetFile, FileMode.Create, FileAccess.Write))\r
                 {\r
-                    ser.Serialize(strm, user_presets);\r
+                    Ser.Serialize(strm, _presets);\r
+                    strm.Close();\r
+                    strm.Dispose();\r
+                }\r
+\r
+                using (FileStream strm = new FileStream(_userPresetFile, FileMode.Create, FileAccess.Write))\r
+                {\r
+                    Ser.Serialize(strm, _userPresets);\r
                     strm.Close();\r
                     strm.Dispose();\r
                 }\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.\n Error Information: \n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
             }\r
         }\r
 \r
         /// <summary>\r
-        /// Check if the preset "name" exists in either presets or user_presets lists.\r
+        /// Check if the preset "name" exists in either _presets or _userPresets lists.\r
         /// </summary>\r
         /// <param name="name"></param>\r
         /// <returns></returns>\r
-        private Boolean checkIfPresetExists(string name)\r
+        private Boolean CheckIfPresetExists(string name)\r
         {\r
             if (name == string.Empty)\r
                 return true;\r
 \r
             // Built In Presets\r
-            foreach (Preset item in presets)\r
+            foreach (Preset item in _presets)\r
             {\r
                 if (item.Name == name)\r
                     return true;\r
             }\r
 \r
             // User Presets\r
-            foreach (Preset item in user_presets)\r
+            foreach (Preset item in _userPresets)\r
             {\r
                 if (item.Name == name)\r
                     return true;\r
@@ -313,5 +316,44 @@ namespace Handbrake.Presets
 \r
             return false;\r
         }\r
+\r
+        /// <summary>\r
+        /// Check if the user preset "name" exists in _userPresets list.\r
+        /// </summary>\r
+        /// <param name="name"></param>\r
+        /// <returns></returns>\r
+        public Boolean CheckIfUserPresetExists(string name)\r
+        {\r
+            if (name == string.Empty)\r
+                return false;\r
+\r
+            // User Presets\r
+            foreach (Preset item in _userPresets)\r
+            {\r
+                if (item.Name == name)\r
+                    return true;\r
+            }\r
+\r
+            return false;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Check if the built in _presets stored are not out of date.\r
+        /// Update them if they are.\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        public Boolean CheckIfPresetsAreOutOfDate()\r
+        {\r
+            LoadPresetData();\r
+            // Update built-in _presets if the built-in _presets belong to an older version.\r
+            if (_presets.Count != 0)\r
+                if (_presets[0].Version != Properties.Settings.Default.hb_version)\r
+                {\r
+                    UpdateBuiltInPresets();\r
+                    return true;\r
+                }\r
+\r
+            return false;\r
+        }\r
     }\r
 }
\ No newline at end of file
index 58d3be9..088d39c 100644 (file)
@@ -1,56 +1,38 @@
-using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
-using System.Windows.Forms;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
-using System.Diagnostics;\r
+/*  Preset.cs $\r
+       \r
+          This file is part of the HandBrake source code.\r
+          Homepage: <http://handbrake.fr>.\r
+          It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
 \r
 namespace Handbrake.Presets\r
 {\r
     public class Preset\r
     {\r
-\r
-        private int level = 0;\r
-        private string category = null;\r
-        private string name;\r
-        private string query;\r
-\r
-        /// <summary>\r
-        /// Get or Set the preset's level. This indicated if it is a root or child node\r
-        /// </summary>\r
-        public int Level\r
-        {\r
-            get { return level; }\r
-            set { this.level = value; }\r
-        }\r
-\r
         /// <summary>\r
         /// Get or Set the category which the preset resides under\r
         /// </summary>\r
-        public string Category\r
-        {\r
-            get { return category; }\r
-            set { this.category = value; }\r
-        }\r
+        public string Category { get; set; }\r
 \r
         /// <summary>\r
         /// Get or Set the preset name\r
         /// </summary>\r
-        public string Name\r
-        {\r
-            get { return name; }\r
-            set { this.name = value; }\r
-        }\r
+        public string Name { get; set; }\r
 \r
         /// <summary>\r
         /// Get or set the preset query\r
         /// </summary>\r
-        public string Query\r
-        {\r
-            get { return query; }\r
-            set { this.query = value; }\r
-        }\r
+        public string Query { get; set; }\r
 \r
+        /// <summary>\r
+        /// Get or set the usage of Picture Settings in presets.\r
+        /// </summary>\r
+        public Boolean PictureSettings { get; set; }\r
+\r
+        /// <summary>\r
+        /// The version number which associates this preset with a HB build\r
+        /// </summary>\r
+        public string Version { get; set; }\r
     }\r
 }
\ No newline at end of file
index ae9edec..282f9f5 100644 (file)
@@ -5,20 +5,9 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
-using System.Collections.Specialized;\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.Net;\r
 using System.IO;\r
-using System.Diagnostics;\r
-using System.Threading;\r
-using System.Runtime.InteropServices;\r
-using System.Globalization;\r
-\r
+using Handbrake.Presets;\r
 \r
 namespace Handbrake\r
 {\r
@@ -30,48 +19,25 @@ namespace Handbrake
         [STAThread]\r
         static void Main()\r
         {\r
-            // Development Code Expiry.\r
-            // Remember to comment out on public release!!!\r
-            //if (DateTime.Now > DateTime.Parse("2008/02/25", new CultureInfo("en-US"))) { MessageBox.Show("Sorry, This development build of Handbrake has expired."); return; } \r
-\r
-            // Check the system meets the system requirements.\r
-            Boolean launch = true;\r
-            try\r
+            Screen scr = Screen.PrimaryScreen;\r
+            if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620))\r
+                MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width + "x" + scr.Bounds.Height + " \nScreen resolution is too Low. Must be 1024x620 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            else\r
             {\r
-                // Make sure the screen resolution is not below 1024x768\r
-                System.Windows.Forms.Screen scr = System.Windows.Forms.Screen.PrimaryScreen;\r
-                if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 720))\r
-                {\r
-                    MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width.ToString() + "x" + scr.Bounds.Height.ToString() + " \nScreen resolution is too Low. Must be 1024x720 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                    launch = false;\r
-                }\r
+                string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs");\r
+                if (!Directory.Exists(logDir))\r
+                    Directory.CreateDirectory(logDir);\r
 \r
-                // Make sure the system has enough RAM. 384MB or greater\r
-                Functions.SystemInfo info = new Functions.SystemInfo();\r
-                uint memory = info.TotalPhysicalMemory();\r
-                \r
-                if (memory < 256)\r
+                if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\presets.xml")))\r
                 {\r
-                    MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Insufficient RAM. 384MB or greater required. You have: " + memory.ToString() + "MB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                    launch = false;\r
+                    PresetsHandler x = new PresetsHandler();\r
+                    x.UpdateBuiltInPresets();\r
                 }\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("frmMain.cs - systemCheck() " + exc.ToString());\r
-            }\r
 \r
-            // Either Launch or Close the Application\r
-            if (launch == true)\r
-            {\r
                 Application.EnableVisualStyles();\r
                 Application.SetCompatibleTextRenderingDefault(false);\r
                 Application.Run(new frmMain());\r
             }\r
-            else\r
-            {\r
-                Application.Exit();\r
-            }\r
         }\r
     }\r
 \r
index f88d1cc..f8eba52 100644 (file)
@@ -17,7 +17,7 @@ using System.Resources;
 [assembly: AssemblyConfiguration("")]\r
 [assembly: AssemblyCompany("HandBrake")]\r
 [assembly: AssemblyProduct("HandBrake")]\r
-[assembly: AssemblyCopyright("Copyright Â©  2008")]\r
+[assembly: AssemblyCopyright("Copyright Â©  2009")]\r
 [assembly: AssemblyTrademark("")]\r
 [assembly: AssemblyCulture("")]\r
 \r
@@ -36,6 +36,6 @@ using System.Resources;
 //      Build Number\r
 //      Revision\r
 //\r
-[assembly: AssemblyVersion("0.9.3.0")]\r
-[assembly: AssemblyFileVersion("0.9.3.0")]\r
+[assembly: AssemblyVersion("0.9.4.0")]\r
+[assembly: AssemblyFileVersion("0.9.4.0")]\r
 [assembly: NeutralResourcesLanguageAttribute("")]\r
index 0a9c4b7..36b3388 100644 (file)
@@ -1,7 +1,7 @@
 ï»¿//------------------------------------------------------------------------------\r
 // <auto-generated>\r
 //     This code was generated by a tool.\r
-//     Runtime Version:2.0.50727.3053\r
+//     Runtime Version:2.0.50727.1433\r
 //\r
 //     Changes to this file may cause incorrect behavior and will be lost if\r
 //     the code is regenerated.\r
@@ -81,6 +81,13 @@ namespace Handbrake.Properties {
             }\r
         }\r
         \r
+        internal static System.Drawing.Bitmap AddToQueue_small {\r
+            get {\r
+                object obj = ResourceManager.GetObject("AddToQueue_small", resourceCulture);\r
+                return ((System.Drawing.Bitmap)(obj));\r
+            }\r
+        }\r
+        \r
         internal static System.Drawing.Bitmap copy {\r
             get {\r
                 object obj = ResourceManager.GetObject("copy", resourceCulture);\r
@@ -179,6 +186,13 @@ namespace Handbrake.Properties {
             }\r
         }\r
         \r
+        internal static System.Drawing.Bitmap picture {\r
+            get {\r
+                object obj = ResourceManager.GetObject("picture", resourceCulture);\r
+                return ((System.Drawing.Bitmap)(obj));\r
+            }\r
+        }\r
+        \r
         internal static System.Drawing.Bitmap Play {\r
             get {\r
                 object obj = ResourceManager.GetObject("Play", resourceCulture);\r
@@ -186,6 +200,13 @@ namespace Handbrake.Properties {
             }\r
         }\r
         \r
+        internal static System.Drawing.Bitmap Play_small {\r
+            get {\r
+                object obj = ResourceManager.GetObject("Play_small", resourceCulture);\r
+                return ((System.Drawing.Bitmap)(obj));\r
+            }\r
+        }\r
+        \r
         internal static System.Drawing.Bitmap Pref_Small {\r
             get {\r
                 object obj = ResourceManager.GetObject("Pref_Small", resourceCulture);\r
@@ -227,5 +248,12 @@ namespace Handbrake.Properties {
                 return ((System.Drawing.Bitmap)(obj));\r
             }\r
         }\r
+        \r
+        internal static System.Drawing.Bitmap window {\r
+            get {\r
+                object obj = ResourceManager.GetObject("window", resourceCulture);\r
+                return ((System.Drawing.Bitmap)(obj));\r
+            }\r
+        }\r
     }\r
 }\r
index 7fa9934..d5524c8 100644 (file)
   <data name="copy" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
     <value>..\resources\copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
   </data>\r
+  <data name="window" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>..\resources\window.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
+  <data name="picture" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>..\Resources\picture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
+  <data name="AddToQueue_small" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>..\Resources\AddToQueue_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
+  <data name="Play_small" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>..\Resources\Play_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index c8f9f66..af174ab 100644 (file)
@@ -1,7 +1,7 @@
 ï»¿//------------------------------------------------------------------------------\r
 // <auto-generated>\r
 //     This code was generated by a tool.\r
-//     Runtime Version:2.0.50727.3053\r
+//     Runtime Version:2.0.50727.4927\r
 //\r
 //     Changes to this file may cause incorrect behavior and will be lost if\r
 //     the code is regenerated.\r
@@ -49,22 +49,10 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Checked")]\r
-        public string defaultSettings {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool updateStatus {\r
             get {\r
-                return ((string)(this["defaultSettings"]));\r
-            }\r
-            set {\r
-                this["defaultSettings"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Checked")]\r
-        public string updateStatus {\r
-            get {\r
-                return ((string)(this["updateStatus"]));\r
+                return ((bool)(this["updateStatus"]));\r
             }\r
             set {\r
                 this["updateStatus"] = value;\r
@@ -85,10 +73,10 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Checked")]\r
-        public string tooltipEnable {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool tooltipEnable {\r
             get {\r
-                return ((string)(this["tooltipEnable"]));\r
+                return ((bool)(this["tooltipEnable"]));\r
             }\r
             set {\r
                 this["tooltipEnable"] = value;\r
@@ -110,12 +98,12 @@ namespace Handbrake.Properties {
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
         [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string defaultUserSettings {\r
+        public string defaultPreset {\r
             get {\r
-                return ((string)(this["defaultUserSettings"]));\r
+                return ((string)(this["defaultPreset"]));\r
             }\r
             set {\r
-                this["defaultUserSettings"] = value;\r
+                this["defaultPreset"] = value;\r
             }\r
         }\r
         \r
@@ -145,10 +133,10 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string autoNaming {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool autoNaming {\r
             get {\r
-                return ((string)(this["autoNaming"]));\r
+                return ((bool)(this["autoNaming"]));\r
             }\r
             set {\r
                 this["autoNaming"] = value;\r
@@ -193,109 +181,299 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Checked")]\r
-        public string drive_detection {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool cli_minimized {\r
             get {\r
-                return ((string)(this["drive_detection"]));\r
+                return ((bool)(this["cli_minimized"]));\r
             }\r
             set {\r
-                this["drive_detection"] = value;\r
+                this["cli_minimized"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string cli_minimized {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}")]\r
+        public string autoNameFormat {\r
             get {\r
-                return ((string)(this["cli_minimized"]));\r
+                return ((string)(this["autoNameFormat"]));\r
             }\r
             set {\r
-                this["cli_minimized"] = value;\r
+                this["autoNameFormat"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool saveLogToSpecifiedPath {\r
+            get {\r
+                return ((bool)(this["saveLogToSpecifiedPath"]));\r
+            }\r
+            set {\r
+                this["saveLogToSpecifiedPath"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
         [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string checkSnapshot {\r
+        public string saveLogPath {\r
             get {\r
-                return ((string)(this["checkSnapshot"]));\r
+                return ((string)(this["saveLogPath"]));\r
             }\r
             set {\r
-                this["checkSnapshot"] = value;\r
+                this["saveLogPath"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("4:10:15:9:10:35:9")]\r
-        public string decomb {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool saveLogWithVideo {\r
             get {\r
-                return ((string)(this["decomb"]));\r
+                return ((bool)(this["saveLogWithVideo"]));\r
             }\r
             set {\r
-                this["decomb"] = value;\r
+                this["saveLogWithVideo"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("4:10:15:9:10:35:9")]\r
-        public string default_decomb {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("C:\\Program Files\\VideoLAN\\vlc\\vlc.exe")]\r
+        public string VLC_Path {\r
             get {\r
-                return ((string)(this["default_decomb"]));\r
+                return ((string)(this["VLC_Path"]));\r
             }\r
             set {\r
-                this["default_decomb"] = value;\r
+                this["VLC_Path"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}-{chapters}")]\r
-        public string autoNameFormat {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool MainWindowMinimize {\r
             get {\r
-                return ((string)(this["autoNameFormat"]));\r
+                return ((bool)(this["MainWindowMinimize"]));\r
             }\r
             set {\r
-                this["autoNameFormat"] = value;\r
+                this["MainWindowMinimize"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string saveLog {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool QueryEditorTab {\r
             get {\r
-                return ((string)(this["saveLog"]));\r
+                return ((bool)(this["QueryEditorTab"]));\r
             }\r
             set {\r
-                this["saveLog"] = value;\r
+                this["QueryEditorTab"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string saveLogPath {\r
+        [global::System.Configuration.DefaultSettingValueAttribute("0.25")]\r
+        public double x264cqstep {\r
             get {\r
-                return ((string)(this["saveLogPath"]));\r
+                return ((double)(this["x264cqstep"]));\r
             }\r
             set {\r
-                this["saveLogPath"] = value;\r
+                this["x264cqstep"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("1")]\r
+        public int verboseLevel {\r
+            get {\r
+                return ((int)(this["verboseLevel"]));\r
+            }\r
+            set {\r
+                this["verboseLevel"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool noDvdNav {\r
+            get {\r
+                return ((bool)(this["noDvdNav"]));\r
+            }\r
+            set {\r
+                this["noDvdNav"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool presetNotification {\r
+            get {\r
+                return ((bool)(this["presetNotification"]));\r
+            }\r
+            set {\r
+                this["presetNotification"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool enocdeStatusInGui {\r
+            get {\r
+                return ((bool)(this["enocdeStatusInGui"]));\r
+            }\r
+            set {\r
+                this["enocdeStatusInGui"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool trayIconAlerts {\r
+            get {\r
+                return ((bool)(this["trayIconAlerts"]));\r
+            }\r
+            set {\r
+                this["trayIconAlerts"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        public global::System.DateTime lastUpdateCheckDate {\r
+            get {\r
+                return ((global::System.DateTime)(this["lastUpdateCheckDate"]));\r
+            }\r
+            set {\r
+                this["lastUpdateCheckDate"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("7")]\r
+        public int daysBetweenUpdateCheck {\r
+            get {\r
+                return ((int)(this["daysBetweenUpdateCheck"]));\r
+            }\r
+            set {\r
+                this["daysBetweenUpdateCheck"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool useM4v {\r
+            get {\r
+                return ((bool)(this["useM4v"]));\r
+            }\r
+            set {\r
+                this["useM4v"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
+        public bool PromptOnUnmatchingQueries {\r
+            get {\r
+                return ((bool)(this["PromptOnUnmatchingQueries"]));\r
+            }\r
+            set {\r
+                this["PromptOnUnmatchingQueries"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("Any")]\r
+        public string NativeLanguage {\r
+            get {\r
+                return ((string)(this["NativeLanguage"]));\r
+            }\r
+            set {\r
+                this["NativeLanguage"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool DubAudio {\r
+            get {\r
+                return ((bool)(this["DubAudio"]));\r
+            }\r
+            set {\r
+                this["DubAudio"] = value;\r
             }\r
         }\r
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
         [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string saveLogWithVideo {\r
+        public string hb_platform {\r
             get {\r
-                return ((string)(this["saveLogWithVideo"]));\r
+                return ((string)(this["hb_platform"]));\r
             }\r
             set {\r
-                this["saveLogWithVideo"] = value;\r
+                this["hb_platform"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool disableResCalc {\r
+            get {\r
+                return ((bool)(this["disableResCalc"]));\r
+            }\r
+            set {\r
+                this["disableResCalc"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool growlQueue {\r
+            get {\r
+                return ((bool)(this["growlQueue"]));\r
+            }\r
+            set {\r
+                this["growlQueue"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
+        public bool growlEncode {\r
+            get {\r
+                return ((bool)(this["growlEncode"]));\r
+            }\r
+            set {\r
+                this["growlEncode"] = value;\r
+            }\r
+        }\r
+        \r
+        [global::System.Configuration.UserScopedSettingAttribute()]\r
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+        public global::System.DateTime cliLastModified {\r
+            get {\r
+                return ((global::System.DateTime)(this["cliLastModified"]));\r
+            }\r
+            set {\r
+                this["cliLastModified"] = value;\r
             }\r
         }\r
     }\r
index 8d4af32..f1c0263 100644 (file)
@@ -8,22 +8,19 @@
     <Setting Name="Processors" Type="System.String" Scope="User">\r
       <Value Profile="(Default)">Automatic</Value>\r
     </Setting>\r
-    <Setting Name="defaultSettings" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Checked</Value>\r
-    </Setting>\r
-    <Setting Name="updateStatus" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Checked</Value>\r
+    <Setting Name="updateStatus" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
     </Setting>\r
     <Setting Name="hb_version" Type="System.String" Scope="User">\r
       <Value Profile="(Default)">{hb_version}</Value>\r
     </Setting>\r
-    <Setting Name="tooltipEnable" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Checked</Value>\r
+    <Setting Name="tooltipEnable" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
     </Setting>\r
     <Setting Name="CompletionOption" Type="System.String" Scope="User">\r
       <Value Profile="(Default)">Do Nothing</Value>\r
     </Setting>\r
-    <Setting Name="defaultUserSettings" Type="System.String" Scope="User">\r
+    <Setting Name="defaultPreset" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
     </Setting>\r
     <Setting Name="hb_build" Type="System.Int32" Scope="User">\r
@@ -32,8 +29,8 @@
     <Setting Name="skipversion" Type="System.Int32" Scope="User">\r
       <Value Profile="(Default)">0</Value>\r
     </Setting>\r
-    <Setting Name="autoNaming" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
+    <Setting Name="autoNaming" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
     </Setting>\r
     <Setting Name="autoNamePath" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
     <Setting Name="appcast_unstable" Type="System.String" Scope="User">\r
       <Value Profile="(Default)">http://handbrake.fr/appcast_unstable.xml</Value>\r
     </Setting>\r
-    <Setting Name="drive_detection" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Checked</Value>\r
+    <Setting Name="cli_minimized" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
     </Setting>\r
-    <Setting Name="cli_minimized" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
+    <Setting Name="autoNameFormat" Type="System.String" Scope="User">\r
+      <Value Profile="(Default)">{source}-{title}</Value>\r
+    </Setting>\r
+    <Setting Name="saveLogToSpecifiedPath" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
     </Setting>\r
-    <Setting Name="checkSnapshot" Type="System.String" Scope="User">\r
+    <Setting Name="saveLogPath" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
     </Setting>\r
-    <Setting Name="decomb" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">4:10:15:9:10:35:9</Value>\r
+    <Setting Name="saveLogWithVideo" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
     </Setting>\r
-    <Setting Name="default_decomb" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">4:10:15:9:10:35:9</Value>\r
+    <Setting Name="VLC_Path" Type="System.String" Scope="User">\r
+      <Value Profile="(Default)">C:\Program Files\VideoLAN\vlc\vlc.exe</Value>\r
     </Setting>\r
-    <Setting Name="autoNameFormat" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">{source}-{title}-{chapters}</Value>\r
+    <Setting Name="MainWindowMinimize" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
+    </Setting>\r
+    <Setting Name="QueryEditorTab" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="x264cqstep" Type="System.Double" Scope="User">\r
+      <Value Profile="(Default)">0.25</Value>\r
+    </Setting>\r
+    <Setting Name="verboseLevel" Type="System.Int32" Scope="User">\r
+      <Value Profile="(Default)">1</Value>\r
+    </Setting>\r
+    <Setting Name="noDvdNav" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="presetNotification" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
     </Setting>\r
-    <Setting Name="saveLog" Type="System.String" Scope="User">\r
+    <Setting Name="enocdeStatusInGui" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="trayIconAlerts" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
+    </Setting>\r
+    <Setting Name="lastUpdateCheckDate" Type="System.DateTime" Scope="User">\r
       <Value Profile="(Default)" />\r
     </Setting>\r
-    <Setting Name="saveLogPath" Type="System.String" Scope="User">\r
+    <Setting Name="daysBetweenUpdateCheck" Type="System.Int32" Scope="User">\r
+      <Value Profile="(Default)">7</Value>\r
+    </Setting>\r
+    <Setting Name="useM4v" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
+    </Setting>\r
+    <Setting Name="PromptOnUnmatchingQueries" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">True</Value>\r
+    </Setting>\r
+    <Setting Name="NativeLanguage" Type="System.String" Scope="User">\r
+      <Value Profile="(Default)">Any</Value>\r
+    </Setting>\r
+    <Setting Name="DubAudio" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="hb_platform" Type="System.String" Scope="User">\r
       <Value Profile="(Default)" />\r
     </Setting>\r
-    <Setting Name="saveLogWithVideo" Type="System.String" Scope="User">\r
+    <Setting Name="disableResCalc" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="growlQueue" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="growlEncode" Type="System.Boolean" Scope="User">\r
+      <Value Profile="(Default)">False</Value>\r
+    </Setting>\r
+    <Setting Name="cliLastModified" Type="System.DateTime" Scope="User">\r
       <Value Profile="(Default)" />\r
     </Setting>\r
   </Settings>\r
diff --git a/win/C#/Resources/AddToQueue_small.png b/win/C#/Resources/AddToQueue_small.png
new file mode 100644 (file)
index 0000000..5bb0818
Binary files /dev/null and b/win/C#/Resources/AddToQueue_small.png differ
diff --git a/win/C#/Resources/Play_small.png b/win/C#/Resources/Play_small.png
new file mode 100644 (file)
index 0000000..3e4647a
Binary files /dev/null and b/win/C#/Resources/Play_small.png differ
index ca1072d..f9c1827 100644 (file)
Binary files a/win/C#/Resources/SplashScreen.jpg and b/win/C#/Resources/SplashScreen.jpg differ
diff --git a/win/C#/Resources/picture.png b/win/C#/Resources/picture.png
new file mode 100644 (file)
index 0000000..0072ccf
Binary files /dev/null and b/win/C#/Resources/picture.png differ
diff --git a/win/C#/Resources/window.png b/win/C#/Resources/window.png
new file mode 100644 (file)
index 0000000..48a14a3
Binary files /dev/null and b/win/C#/Resources/window.png differ
index 522578b..6cd2d7e 100644 (file)
             <setting name="Processors" serializeAs="String">\r
                 <value>Automatic</value>\r
             </setting>\r
-            <setting name="defaultSettings" serializeAs="String">\r
-                <value>Checked</value>\r
-            </setting>\r
             <setting name="updateStatus" serializeAs="String">\r
-                <value>Checked</value>\r
+                <value>True</value>\r
             </setting>\r
             <setting name="hb_version" serializeAs="String">\r
                 <value>{hb_version}</value>\r
             </setting>\r
             <setting name="tooltipEnable" serializeAs="String">\r
-                <value>Checked</value>\r
+                <value>True</value>\r
             </setting>\r
             <setting name="CompletionOption" serializeAs="String">\r
                 <value>Do Nothing</value>\r
             </setting>\r
-            <setting name="defaultUserSettings" serializeAs="String">\r
+            <setting name="defaultPreset" serializeAs="String">\r
                 <value />\r
             </setting>\r
             <setting name="hb_build" serializeAs="String">\r
@@ -38,7 +35,7 @@
                 <value>0</value>\r
             </setting>\r
             <setting name="autoNaming" serializeAs="String">\r
-                <value />\r
+                <value>True</value>\r
             </setting>\r
             <setting name="autoNamePath" serializeAs="String">\r
                 <value />\r
             <setting name="appcast_unstable" serializeAs="String">\r
                 <value>http://handbrake.fr/appcast_unstable.xml</value>\r
             </setting>\r
-            <setting name="drive_detection" serializeAs="String">\r
-                <value>Checked</value>\r
-            </setting>\r
             <setting name="cli_minimized" serializeAs="String">\r
-                <value />\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="autoNameFormat" serializeAs="String">\r
+                <value>{source}-{title}</value>\r
+            </setting>\r
+            <setting name="saveLogToSpecifiedPath" serializeAs="String">\r
+                <value>False</value>\r
             </setting>\r
-            <setting name="checkSnapshot" serializeAs="String">\r
+            <setting name="saveLogPath" serializeAs="String">\r
                 <value />\r
             </setting>\r
-            <setting name="decomb" serializeAs="String">\r
-                <value>4:10:15:9:10:35:9</value>\r
+            <setting name="saveLogWithVideo" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="VLC_Path" serializeAs="String">\r
+                <value>C:\Program Files\VideoLAN\vlc\vlc.exe</value>\r
             </setting>\r
-            <setting name="default_decomb" serializeAs="String">\r
-                <value>4:10:15:9:10:35:9</value>\r
+            <setting name="MainWindowMinimize" serializeAs="String">\r
+                <value>True</value>\r
             </setting>\r
-            <setting name="autoNameFormat" serializeAs="String">\r
-                <value>{source}-{title}-{chapters}</value>\r
+            <setting name="QueryEditorTab" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="x264cqstep" serializeAs="String">\r
+                <value>0.25</value>\r
+            </setting>\r
+            <setting name="verboseLevel" serializeAs="String">\r
+                <value>1</value>\r
+            </setting>\r
+            <setting name="noDvdNav" serializeAs="String">\r
+                <value>False</value>\r
             </setting>\r
-            <setting name="saveLog" serializeAs="String">\r
+            <setting name="presetNotification" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="enocdeStatusInGui" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="trayIconAlerts" serializeAs="String">\r
+                <value>True</value>\r
+            </setting>\r
+            <setting name="lastUpdateCheckDate" serializeAs="String">\r
                 <value />\r
             </setting>\r
-            <setting name="saveLogPath" serializeAs="String">\r
+            <setting name="daysBetweenUpdateCheck" serializeAs="String">\r
+                <value>7</value>\r
+            </setting>\r
+            <setting name="useM4v" serializeAs="String">\r
+                <value>True</value>\r
+            </setting>\r
+            <setting name="PromptOnUnmatchingQueries" serializeAs="String">\r
+                <value>True</value>\r
+            </setting>\r
+            <setting name="NativeLanguage" serializeAs="String">\r
+                <value>Any</value>\r
+            </setting>\r
+            <setting name="DubAudio" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="hb_platform" serializeAs="String">\r
                 <value />\r
             </setting>\r
-            <setting name="saveLogWithVideo" serializeAs="String">\r
+            <setting name="disableResCalc" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="growlQueue" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="growlEncode" serializeAs="String">\r
+                <value>False</value>\r
+            </setting>\r
+            <setting name="cliLastModified" serializeAs="String">\r
                 <value />\r
             </setting>\r
         </Handbrake.Properties.Settings>\r
index ab56957..2b9c46f 100644 (file)
@@ -35,118 +35,92 @@ namespace Handbrake
         private void InitializeComponent()\r
         {\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAbout));\r
-            this.Label4 = new System.Windows.Forms.Label();\r
-            this.btn_close = new System.Windows.Forms.Button();\r
-            this.Version = new System.Windows.Forms.Label();\r
             this.Label3 = new System.Windows.Forms.Label();\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.lbl_HBBuild = new System.Windows.Forms.Label();\r
             this.PictureBox1 = new System.Windows.Forms.PictureBox();\r
-            this.label5 = new System.Windows.Forms.Label();\r
-            this.lbl_build = new System.Windows.Forms.Label();\r
-            this.groupBox1 = new System.Windows.Forms.GroupBox();\r
+            this.btn_close = new System.Windows.Forms.Button();\r
             ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).BeginInit();\r
             this.SuspendLayout();\r
             // \r
-            // Label4\r
-            // \r
-            this.Label4.AutoSize = true;\r
-            this.Label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label4.Location = new System.Drawing.Point(168, 58);\r
-            this.Label4.Name = "Label4";\r
-            this.Label4.Size = new System.Drawing.Size(346, 26);\r
-            this.Label4.TabIndex = 28;\r
-            this.Label4.Text = "HandBrake is a GPL-licensed, multiplatform, multithreaded \r\nvideo transcoder. ";\r
-            // \r
-            // btn_close\r
-            // \r
-            this.btn_close.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_close.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.btn_close.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_close.Location = new System.Drawing.Point(402, 114);\r
-            this.btn_close.Name = "btn_close";\r
-            this.btn_close.Size = new System.Drawing.Size(115, 22);\r
-            this.btn_close.TabIndex = 27;\r
-            this.btn_close.Text = "Close";\r
-            this.btn_close.UseVisualStyleBackColor = true;\r
-            this.btn_close.Click += new System.EventHandler(this.btn_close_Click);\r
-            // \r
-            // Version\r
-            // \r
-            this.Version.AutoSize = true;\r
-            this.Version.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Version.Location = new System.Drawing.Point(266, 13);\r
-            this.Version.Name = "Version";\r
-            this.Version.Size = new System.Drawing.Size(72, 13);\r
-            this.Version.TabIndex = 26;\r
-            this.Version.Text = "{Version}";\r
-            // \r
             // Label3\r
             // \r
             this.Label3.AutoSize = true;\r
-            this.Label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label3.Location = new System.Drawing.Point(168, 13);\r
+            this.Label3.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Label3.Location = new System.Drawing.Point(124, 12);\r
+            this.Label3.Margin = new System.Windows.Forms.Padding(3, 3, 3, 1);\r
             this.Label3.Name = "Label3";\r
-            this.Label3.Size = new System.Drawing.Size(78, 13);\r
+            this.Label3.Size = new System.Drawing.Size(99, 19);\r
             this.Label3.TabIndex = 25;\r
             this.Label3.Text = "HandBrake";\r
+            this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.AutoSize = true;\r
+            this.label1.Location = new System.Drawing.Point(125, 63);\r
+            this.label1.Margin = new System.Windows.Forms.Padding(3);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(224, 13);\r
+            this.label1.TabIndex = 33;\r
+            this.label1.Text = "Copyright  2003-2009 HandBrake Developers";\r
+            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\r
+            // \r
+            // lbl_HBBuild\r
+            // \r
+            this.lbl_HBBuild.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_HBBuild.Location = new System.Drawing.Point(125, 33);\r
+            this.lbl_HBBuild.Margin = new System.Windows.Forms.Padding(3, 1, 3, 3);\r
+            this.lbl_HBBuild.Name = "lbl_HBBuild";\r
+            this.lbl_HBBuild.Size = new System.Drawing.Size(224, 13);\r
+            this.lbl_HBBuild.TabIndex = 32;\r
+            this.lbl_HBBuild.Text = "{Version}";\r
+            this.lbl_HBBuild.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\r
             // \r
             // PictureBox1\r
             // \r
+            this.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;\r
             this.PictureBox1.Image = global::Handbrake.Properties.Resources.logo128;\r
             this.PictureBox1.InitialImage = null;\r
-            this.PictureBox1.Location = new System.Drawing.Point(8, 8);\r
+            this.PictureBox1.Location = new System.Drawing.Point(9, 9);\r
+            this.PictureBox1.Margin = new System.Windows.Forms.Padding(0);\r
             this.PictureBox1.Name = "PictureBox1";\r
-            this.PictureBox1.Size = new System.Drawing.Size(153, 132);\r
-            this.PictureBox1.TabIndex = 23;\r
+            this.PictureBox1.Size = new System.Drawing.Size(96, 96);\r
+            this.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;\r
+            this.PictureBox1.TabIndex = 33;\r
             this.PictureBox1.TabStop = false;\r
             // \r
-            // label5\r
-            // \r
-            this.label5.AutoSize = true;\r
-            this.label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label5.Location = new System.Drawing.Point(168, 30);\r
-            this.label5.Name = "label5";\r
-            this.label5.Size = new System.Drawing.Size(40, 13);\r
-            this.label5.TabIndex = 29;\r
-            this.label5.Text = "Build:";\r
-            // \r
-            // lbl_build\r
-            // \r
-            this.lbl_build.AutoSize = true;\r
-            this.lbl_build.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_build.Location = new System.Drawing.Point(266, 30);\r
-            this.lbl_build.Name = "lbl_build";\r
-            this.lbl_build.Size = new System.Drawing.Size(64, 13);\r
-            this.lbl_build.TabIndex = 30;\r
-            this.lbl_build.Text = "{Version}";\r
-            // \r
-            // groupBox1\r
+            // btn_close\r
             // \r
-            this.groupBox1.Location = new System.Drawing.Point(171, 45);\r
-            this.groupBox1.Name = "groupBox1";\r
-            this.groupBox1.Size = new System.Drawing.Size(346, 10);\r
-            this.groupBox1.TabIndex = 31;\r
-            this.groupBox1.TabStop = false;\r
+            this.btn_close.DialogResult = System.Windows.Forms.DialogResult.OK;\r
+            this.btn_close.Location = new System.Drawing.Point(274, 82);\r
+            this.btn_close.Name = "btn_close";\r
+            this.btn_close.Size = new System.Drawing.Size(75, 23);\r
+            this.btn_close.TabIndex = 35;\r
+            this.btn_close.Text = "OK";\r
+            this.btn_close.UseVisualStyleBackColor = true;\r
+            this.btn_close.Click += new System.EventHandler(this.btn_close_Click);\r
             // \r
             // frmAbout\r
             // \r
             this.AcceptButton = this.btn_close;\r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(530, 148);\r
-            this.Controls.Add(this.groupBox1);\r
-            this.Controls.Add(this.lbl_build);\r
-            this.Controls.Add(this.label5);\r
-            this.Controls.Add(this.Label4);\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;\r
+            this.CancelButton = this.btn_close;\r
+            this.ClientSize = new System.Drawing.Size(363, 117);\r
             this.Controls.Add(this.btn_close);\r
-            this.Controls.Add(this.Version);\r
-            this.Controls.Add(this.Label3);\r
+            this.Controls.Add(this.label1);\r
             this.Controls.Add(this.PictureBox1);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Controls.Add(this.lbl_HBBuild);\r
+            this.Controls.Add(this.Label3);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
             this.MaximizeBox = false;\r
             this.MinimizeBox = false;\r
             this.Name = "frmAbout";\r
+            this.ShowIcon = false;\r
+            this.ShowInTaskbar = false;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
             this.Text = "About HandBrake";\r
             ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit();\r
@@ -157,13 +131,10 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        internal System.Windows.Forms.Label Label4;\r
-        internal System.Windows.Forms.Button btn_close;\r
-        internal System.Windows.Forms.Label Version;\r
         internal System.Windows.Forms.Label Label3;\r
+        internal System.Windows.Forms.Label label1;\r
+        internal System.Windows.Forms.Label lbl_HBBuild;\r
         internal System.Windows.Forms.PictureBox PictureBox1;\r
-        internal System.Windows.Forms.Label label5;\r
-        internal System.Windows.Forms.Label lbl_build;\r
-        private System.Windows.Forms.GroupBox groupBox1;\r
+        private System.Windows.Forms.Button btn_close;\r
     }\r
 }
\ No newline at end of file
index 1657cad..a35779a 100644 (file)
@@ -5,13 +5,7 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.Diagnostics;\r
 \r
 namespace Handbrake\r
 {\r
@@ -20,18 +14,12 @@ namespace Handbrake
         public frmAbout()\r
         {\r
             InitializeComponent();\r
-            Version.Text = Properties.Settings.Default.hb_version;\r
-            lbl_build.Text = Properties.Settings.Default.hb_build.ToString();\r
+            lbl_HBBuild.Text = Properties.Settings.Default.hb_version + " (" + Properties.Settings.Default.hb_build + ") - " + Properties.Settings.Default.hb_platform;\r
         }\r
 \r
         private void btn_close_Click(object sender, EventArgs e)\r
         {\r
             this.Close();\r
         }\r
-\r
-        private void label_credits_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
-        {\r
-            Process.Start("http://handbrake.frtrac/wiki/x264Options");\r
-        }\r
     }\r
 }
\ No newline at end of file
index 837bf37..9d25318 100644 (file)
@@ -37,6 +37,9 @@ namespace Handbrake
             this.components = new System.ComponentModel.Container();\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmActivityWindow));\r
             this.rtf_actLog = new System.Windows.Forms.RichTextBox();\r
+            this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.mnu_copy_log = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.mnu_openLogFolder = new System.Windows.Forms.ToolStripMenuItem();\r
             this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();\r
             this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();\r
@@ -47,11 +50,9 @@ namespace Handbrake
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();\r
             this.lbl_slb = new System.Windows.Forms.ToolStripStatusLabel();\r
             this.txt_log = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
-            this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.rightClickMenu.SuspendLayout();\r
             this.toolStrip1.SuspendLayout();\r
             this.statusStrip1.SuspendLayout();\r
-            this.rightClickMenu.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // rtf_actLog\r
@@ -63,10 +64,34 @@ namespace Handbrake
             this.rtf_actLog.Location = new System.Drawing.Point(0, 25);\r
             this.rtf_actLog.Name = "rtf_actLog";\r
             this.rtf_actLog.ReadOnly = true;\r
-            this.rtf_actLog.Size = new System.Drawing.Size(471, 530);\r
+            this.rtf_actLog.Size = new System.Drawing.Size(404, 530);\r
             this.rtf_actLog.TabIndex = 29;\r
             this.rtf_actLog.Text = "";\r
             // \r
+            // rightClickMenu\r
+            // \r
+            this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_copy_log,\r
+            this.mnu_openLogFolder});\r
+            this.rightClickMenu.Name = "rightClickMenu";\r
+            this.rightClickMenu.Size = new System.Drawing.Size(254, 48);\r
+            // \r
+            // mnu_copy_log\r
+            // \r
+            this.mnu_copy_log.Image = global::Handbrake.Properties.Resources.copy;\r
+            this.mnu_copy_log.Name = "mnu_copy_log";\r
+            this.mnu_copy_log.Size = new System.Drawing.Size(253, 22);\r
+            this.mnu_copy_log.Text = "Copy";\r
+            this.mnu_copy_log.Click += new System.EventHandler(this.mnu_copy_log_Click);\r
+            // \r
+            // mnu_openLogFolder\r
+            // \r
+            this.mnu_openLogFolder.Image = global::Handbrake.Properties.Resources.folder;\r
+            this.mnu_openLogFolder.Name = "mnu_openLogFolder";\r
+            this.mnu_openLogFolder.Size = new System.Drawing.Size(253, 22);\r
+            this.mnu_openLogFolder.Text = "Open Individual Log File Directory";\r
+            this.mnu_openLogFolder.Click += new System.EventHandler(this.mnu_openLogFolder_Click);\r
+            // \r
             // ToolTip\r
             // \r
             this.ToolTip.Active = false;\r
@@ -79,8 +104,8 @@ namespace Handbrake
             this.btn_copy});\r
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);\r
             this.toolStrip1.Name = "toolStrip1";\r
-            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;\r
-            this.toolStrip1.Size = new System.Drawing.Size(471, 25);\r
+            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
+            this.toolStrip1.Size = new System.Drawing.Size(404, 25);\r
             this.toolStrip1.TabIndex = 96;\r
             this.toolStrip1.Text = "toolStrip1";\r
             // \r
@@ -94,14 +119,14 @@ namespace Handbrake
             this.toolStripDropDownButton1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";\r
-            this.toolStripDropDownButton1.Size = new System.Drawing.Size(94, 22);\r
+            this.toolStripDropDownButton1.Size = new System.Drawing.Size(90, 22);\r
             this.toolStripDropDownButton1.Text = "Select Log";\r
             // \r
             // btn_encode_log\r
             // \r
             this.btn_encode_log.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
             this.btn_encode_log.Name = "btn_encode_log";\r
-            this.btn_encode_log.Size = new System.Drawing.Size(151, 22);\r
+            this.btn_encode_log.Size = new System.Drawing.Size(152, 22);\r
             this.btn_encode_log.Text = "Encode Log";\r
             this.btn_encode_log.Click += new System.EventHandler(this.btn_encode_log_Click);\r
             // \r
@@ -109,7 +134,7 @@ namespace Handbrake
             // \r
             this.btn_scan_log.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
             this.btn_scan_log.Name = "btn_scan_log";\r
-            this.btn_scan_log.Size = new System.Drawing.Size(151, 22);\r
+            this.btn_scan_log.Size = new System.Drawing.Size(152, 22);\r
             this.btn_scan_log.Text = "Scan Log";\r
             this.btn_scan_log.Click += new System.EventHandler(this.btn_scan_log_Click);\r
             // \r
@@ -128,7 +153,7 @@ namespace Handbrake
             this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
             this.panel1.Location = new System.Drawing.Point(0, 25);\r
             this.panel1.Name = "panel1";\r
-            this.panel1.Size = new System.Drawing.Size(471, 552);\r
+            this.panel1.Size = new System.Drawing.Size(404, 552);\r
             this.panel1.TabIndex = 97;\r
             // \r
             // statusStrip1\r
@@ -138,50 +163,37 @@ namespace Handbrake
             this.txt_log});\r
             this.statusStrip1.Location = new System.Drawing.Point(0, 555);\r
             this.statusStrip1.Name = "statusStrip1";\r
-            this.statusStrip1.Size = new System.Drawing.Size(471, 22);\r
+            this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0);\r
+            this.statusStrip1.Size = new System.Drawing.Size(404, 22);\r
             this.statusStrip1.TabIndex = 98;\r
             this.statusStrip1.Text = "statusStrip1";\r
             // \r
             // lbl_slb\r
             // \r
-            this.lbl_slb.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_slb.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_slb.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.lbl_slb.Name = "lbl_slb";\r
-            this.lbl_slb.Size = new System.Drawing.Size(94, 17);\r
+            this.lbl_slb.Size = new System.Drawing.Size(85, 17);\r
             this.lbl_slb.Text = "Selected Log: ";\r
             // \r
             // txt_log\r
             // \r
             this.txt_log.BackColor = System.Drawing.Color.Transparent;\r
             this.txt_log.Name = "txt_log";\r
-            this.txt_log.Size = new System.Drawing.Size(85, 17);\r
+            this.txt_log.Size = new System.Drawing.Size(78, 17);\r
             this.txt_log.Text = "{selected log}";\r
             // \r
-            // rightClickMenu\r
-            // \r
-            this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.copyToolStripMenuItem});\r
-            this.rightClickMenu.Name = "rightClickMenu";\r
-            this.rightClickMenu.Size = new System.Drawing.Size(153, 48);\r
-            // \r
-            // copyToolStripMenuItem\r
-            // \r
-            this.copyToolStripMenuItem.Image = global::Handbrake.Properties.Resources.copy;\r
-            this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";\r
-            this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);\r
-            this.copyToolStripMenuItem.Text = "Copy";\r
-            this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);\r
-            // \r
             // frmActivityWindow\r
             // \r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
             this.BackColor = System.Drawing.SystemColors.ControlLight;\r
-            this.ClientSize = new System.Drawing.Size(471, 577);\r
+            this.ClientSize = new System.Drawing.Size(404, 577);\r
             this.Controls.Add(this.rtf_actLog);\r
             this.Controls.Add(this.statusStrip1);\r
             this.Controls.Add(this.panel1);\r
             this.Controls.Add(this.toolStrip1);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
             this.MaximizeBox = false;\r
             this.MinimizeBox = false;\r
@@ -189,11 +201,11 @@ namespace Handbrake
             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "Activity Window";\r
+            this.rightClickMenu.ResumeLayout(false);\r
             this.toolStrip1.ResumeLayout(false);\r
             this.toolStrip1.PerformLayout();\r
             this.statusStrip1.ResumeLayout(false);\r
             this.statusStrip1.PerformLayout();\r
-            this.rightClickMenu.ResumeLayout(false);\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -213,6 +225,7 @@ namespace Handbrake
         private System.Windows.Forms.ToolStripButton btn_copy;\r
         private System.Windows.Forms.ToolStripStatusLabel lbl_slb;\r
         private System.Windows.Forms.ContextMenuStrip rightClickMenu;\r
-        private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_copy_log;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_openLogFolder;\r
     }\r
 }
\ No newline at end of file
index 5508d0b..9f9f411 100644 (file)
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections;\r
-using System.Collections.Generic;\r
 using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Threading;\r
-using System.Diagnostics;\r
-using System.Runtime.InteropServices;\r
+using Handbrake.EncodeQueue;\r
+using Handbrake.Functions;\r
+using Microsoft.Win32;\r
 \r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmActivityWindow : Form\r
     {\r
-        delegate void SetTextCallback(string text);\r
-        String read_file;\r
-        Thread monitor;\r
-        frmMain mainWindow;\r
-        frmQueue queueWindow;\r
-        int position = 0;  // Position in the arraylist reached by the current log output in the rtf box.\r
-\r
-        /// <summary>\r
-        /// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.\r
-        /// </summary>\r
-        public frmActivityWindow(string file, frmMain fm, frmQueue fq)\r
+        private delegate void setTextCallback(string text);\r
+        private String _readFile;\r
+        private readonly EncodeAndQueueHandler _encodeQueue;\r
+        private int _position;  // Position in the arraylist reached by the current log output in the rtf box.\r
+        private readonly frmMain _mainWin;\r
+        private Boolean _lastUpdate;\r
+        private Boolean fileNotFoundQuickFix;\r
+\r
+        public frmActivityWindow(string file, EncodeAndQueueHandler eh, frmMain mw)\r
         {\r
             InitializeComponent();\r
-            this.rtf_actLog.Text = string.Empty;\r
-\r
-            // When the window closes, we want to abort the monitor thread.\r
-            this.Disposed += new EventHandler(forceQuit);\r
 \r
-            mainWindow = fm;\r
-            queueWindow = fq;\r
-            read_file = file;\r
-            position = 0;\r
+            _encodeQueue = eh;\r
+            _mainWin = mw;\r
 \r
-            // Print the Log header in the Rich text box.\r
-            displayLogHeader();\r
+            fileNotFoundQuickFix = false;\r
 \r
-            if (file == "dvdinfo.dat")\r
-                txt_log.Text = "Scan Log";\r
-            else if (file == "hb_encode_log.dat")\r
-                txt_log.Text = "Encode Log";\r
+            if (file == "last_scan_log.txt")\r
+                SetLogView(true);\r
+            else\r
+                SetLogView(false);\r
 \r
             // Start a new thread which will montior and keep the log window up to date if required/\r
-            startLogThread(read_file);            \r
+            try\r
+            {\r
+                Thread monitor = new Thread(AutoUpdate) { IsBackground = true };\r
+                monitor.Start();\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show("startLogThread(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
         }\r
 \r
         /// <summary>\r
-        /// Displays the Log header\r
+        /// Set the view which the Log window displays.\r
+        /// Scan = true;\r
+        /// Encode = false;\r
         /// </summary>\r
-        private void displayLogHeader()\r
+        /// <param name="scan">Boolean. Scan = true</param>\r
+        public void SetLogView(Boolean scan)\r
         {\r
-            // System Information\r
-            Functions.SystemInfo info = new Functions.SystemInfo();\r
+            // Reset\r
+            _position = 0;\r
+            rtf_actLog.Text = String.Empty;\r
 \r
-            // Add a header to the log file indicating that it's from the Windows GUI and display the windows version\r
+            // Print the log header\r
             rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));\r
-            rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion.ToString()));\r
-            rtf_actLog.AppendText(String.Format("### CPU: {0} \n", info.getCpuCount()));\r
-            rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", info.TotalPhysicalMemory()));\r
-            rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", info.screenBounds().Bounds.Width, info.screenBounds().Bounds.Height));\r
+            rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion));\r
+            rtf_actLog.AppendText(String.Format("### CPU: {0} \n", getCpuCount()));\r
+            rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", TotalPhysicalMemory()));\r
+            rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", screenBounds().Bounds.Width, screenBounds().Bounds.Height));\r
             rtf_actLog.AppendText(String.Format("### Temp Dir: {0} \n", Path.GetTempPath()));\r
             rtf_actLog.AppendText(String.Format("### Install Dir: {0} \n", Application.StartupPath));\r
             rtf_actLog.AppendText(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath));\r
             rtf_actLog.AppendText("#########################################\n\n");\r
-        }\r
 \r
-        /// <summary>\r
-        /// Starts a new thread which runs the autoUpdate function.\r
-        /// </summary>\r
-        /// <param name="file"> File which will be used to populate the Rich text box.</param>\r
-        private void startLogThread(string file)\r
-        {\r
-            try\r
+            // Seutp the log file\r
+            if (scan)\r
             {\r
-                string logFile = Path.Combine(Path.GetTempPath(), file);\r
-                if (File.Exists(logFile))\r
-                {\r
-                    // Start a new thread to run the autoUpdate process\r
-                    monitor = new Thread(autoUpdate);\r
-                    monitor.IsBackground = true;\r
-                    monitor.Start();\r
-                }\r
-                else\r
-                    rtf_actLog.AppendText("\n\n\nERROR: The log file could not be found. \nMaybe you cleared your system's tempory folder or maybe you just havn't run an encode yet. \nTried to find the log file in: " + logFile);\r
-\r
+                txt_log.Text = "Scan Log";\r
+                _readFile = "last_scan_log.txt";\r
             }\r
-            catch (Exception exc)\r
+            else\r
             {\r
-                MessageBox.Show("startLogThread(): Exception: \n" + exc);\r
+                _readFile = "last_encode_log.txt";\r
+                txt_log.Text = "Encode Log";\r
+                if (_encodeQueue.isEncoding)\r
+                    if ((!_encodeQueue.LastEncode.IsEmpty) && _encodeQueue.LastEncode.Query != String.Empty)\r
+                    {\r
+                        rtf_actLog.AppendText("### CLI Query: " + _encodeQueue.LastEncode.Query + "\n");\r
+                        rtf_actLog.AppendText("### Custom Query: " + _encodeQueue.LastEncode.CustomQuery + "\n\n");\r
+                        rtf_actLog.AppendText("#########################################\n\n");\r
+                    }\r
             }\r
+            _lastUpdate = false;\r
         }\r
 \r
-        /// <summary>\r
-        /// Change the log file to be displayed to hb_encode_log.dat\r
-        /// </summary>\r
-        /// <param name="sender"></param>\r
-        /// <param name="e"></param>\r
-        private void btn_scan_log_Click(object sender, EventArgs e)\r
-        {\r
-            if (monitor != null)\r
-                monitor.Abort();\r
-\r
-            rtf_actLog.Clear();\r
-            read_file = "dvdinfo.dat";\r
-            displayLogHeader();\r
-            startLogThread(read_file);\r
-            txt_log.Text = "Scan Log";\r
-        }\r
-\r
-        /// <summary>\r
-        /// Change the log file to be displayed to dvdinfo.dat\r
-        /// </summary>\r
-        /// <param name="sender"></param>\r
-        /// <param name="e"></param>\r
-        private void btn_encode_log_Click(object sender, EventArgs e)\r
-        {\r
-            if (monitor != null)\r
-                monitor.Abort();\r
-\r
-            rtf_actLog.Clear();\r
-            read_file = "hb_encode_log.dat";\r
-            position = 0;\r
-            displayLogHeader();\r
-            startLogThread(read_file);\r
-            txt_log.Text = "Encode Log";\r
-        }\r
-\r
-        /// <summary>\r
-        /// Copy to Clipboard\r
-        /// </summary>\r
-        /// <param name="sender"></param>\r
-        /// <param name="e"></param>\r
-        private void btn_copy_Click(object sender, EventArgs e)\r
-        {\r
-            if (rtf_actLog.SelectedText != "")\r
-                Clipboard.SetDataObject(rtf_actLog.SelectedText, true);\r
-            else\r
-                Clipboard.SetDataObject(rtf_actLog.Text, true);\r
-        }\r
-\r
-        /// <summary>\r
-        /// Updates the log window with any new data which is in the log file.\r
-        /// This is done every 5 seconds.\r
-        /// </summary>\r
-        /// <param name="state"></param>\r
-        private void autoUpdate(object state)\r
+        private void AutoUpdate(object state)\r
         {\r
             try\r
             {\r
-                Boolean lastUpdate = false;\r
-                updateTextFromThread();\r
+                _lastUpdate = false;\r
+                UpdateTextFromThread();\r
                 while (true)\r
                 {\r
-                    if ((mainWindow.isEncoding() == true) || (queueWindow.isEncoding() == true))\r
-                        updateTextFromThread();\r
-                    else\r
+                    if (IsHandleCreated)\r
                     {\r
-                        // The encode may just have stoped, so, refresh the log one more time before restarting it.\r
-                        if (lastUpdate == false)\r
-                            updateTextFromThread();\r
-\r
-                        lastUpdate = true; // Prevents the log window from being updated when there is no encode going.\r
-                        position = 0; // There is no encoding, so reset the log position counter to 0 so it can be reused\r
+                        if (_encodeQueue.isEncoding || _mainWin.isScanning)\r
+                            UpdateTextFromThread();\r
+                        else\r
+                        {\r
+                            // The encode may just have stoped, so, refresh the log one more time before restarting it.\r
+                            if (_lastUpdate == false)\r
+                                UpdateTextFromThread();\r
+\r
+                            _lastUpdate = true; // Prevents the log window from being updated when there is no encode going.\r
+                            _position = 0; // There is no encoding, so reset the log position counter to 0 so it can be reused\r
+                        }\r
                     }\r
-                    Thread.Sleep(5000);\r
+                    Thread.Sleep(1000);\r
                 }\r
             }\r
-            catch (ThreadAbortException)\r
-            {\r
-                // Do Nothing. This is needed since we run thread.abort(). \r
-                // Should probably find a better way of making this work at some point.\r
-            }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("autoUpdate(): Exception: \n" + exc);\r
+                MessageBox.Show("AutoUpdate(): Exception: \n" + exc);\r
             }\r
         }\r
-\r
-        /// <summary>\r
-        /// Finds any new text in the log file and calls a funciton to display this new text.\r
-        /// </summary>\r
-        private void updateTextFromThread()\r
+        private void UpdateTextFromThread()\r
         {\r
             try\r
             {\r
-                string text = "";\r
-                List<string> data = readFile();\r
-                int count = data.Count;\r
-\r
-                while (position < count)\r
-                {\r
-                    text = data[position].ToString();\r
-                    if (data[position].ToString().Contains("has exited"))\r
-                        text = "\n ############ End of Log ############## \n";\r
-                    position++;\r
+                String info = ReadFile();\r
+                if (info.Contains("has exited"))\r
+                    info += "\n ############ End of Log ############## \n";\r
 \r
-                    SetText(text);\r
-                }\r
+                SetText(info);\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("updateTextFromThread(): Exception: \n" + exc);\r
+                MessageBox.Show("UpdateTextFromThread(): Exception: \n" + exc);\r
             }\r
         }\r
-\r
-        /// <summary>\r
-        /// Updates the rich text box with anything in the string text.\r
-        /// </summary>\r
-        /// <param name="text"></param>\r
         private void SetText(string text)\r
         {\r
             try\r
             {\r
-                // InvokeRequired required compares the thread ID of the\r
-                // calling thread to the thread ID of the creating thread.\r
-                // If these threads are different, it returns true.\r
-                if (this.IsHandleCreated) // Make sure the windows has a handle before doing anything\r
+                if (IsHandleCreated)\r
                 {\r
-                    if (this.rtf_actLog.InvokeRequired)\r
+                    if (rtf_actLog.InvokeRequired)\r
                     {\r
-                        SetTextCallback d = new SetTextCallback(SetText);\r
-                        this.Invoke(d, new object[] { text });\r
+                        IAsyncResult invoked = BeginInvoke(new setTextCallback(SetText), new object[] { text });\r
+                        EndInvoke(invoked);\r
                     }\r
                     else\r
-                        this.rtf_actLog.AppendText(text);\r
+                        rtf_actLog.AppendText(text);\r
                 }\r
             }\r
             catch (Exception exc)\r
@@ -243,75 +161,132 @@ namespace Handbrake
                 MessageBox.Show("SetText(): Exception: \n" + exc);\r
             }\r
         }\r
-\r
-        /// <summary>\r
-        /// Read the log file, and store the data in a List.\r
-        /// </summary>\r
-        /// <returns></returns>\r
-        private List<string> readFile()\r
+        private String ReadFile()\r
         {\r
-            // Ok, the task here is to, Get an arraylist of log data.\r
-            // And update some global varibles which are pointers to the last displayed log line.\r
-            List<string> logData = new List<string>();\r
-\r
+            String appendText = String.Empty;\r
             try\r
             {\r
-                // hb_encode_log.dat is the primary log file. Since .NET can't read this file whilst the CLI is outputing to it (Not even in read only mode),\r
+                // last_encode_log.txt is the primary log file. Since .NET can't read this file whilst the CLI is outputing to it (Not even in read only mode),\r
                 // we'll need to make a copy of it.\r
-                string logFile = Path.Combine(Path.GetTempPath(), read_file);\r
-                string logFile2 = Path.Combine(Path.GetTempPath(), "hb_encode_log_AppReadable.dat");\r
+                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+                string logFile = Path.Combine(logDir, _readFile);\r
+                string logFile2 = Path.Combine(logDir, "tmp_appReadable_log.txt");\r
 \r
                 // Make sure the application readable log file does not already exist. FileCopy fill fail if it does.\r
                 if (File.Exists(logFile2))\r
                     File.Delete(logFile2);\r
 \r
                 // Copy the log file.\r
-                File.Copy(logFile, logFile2);\r
+                if (File.Exists(logFile))\r
+                    File.Copy(logFile, logFile2, true);\r
+                else\r
+                {\r
+                    if (fileNotFoundQuickFix)\r
+                        return "";\r
+                    fileNotFoundQuickFix = true;\r
+                    return "\n\n\nERROR: The log file could not be found. \nMaybe you cleared your system's tempory folder or maybe you just havn't run an encode yet. \nTried to find the log file in: " + logFile;\r
+                }\r
 \r
-                // Open the copied log file for reading\r
                 StreamReader sr = new StreamReader(logFile2);\r
-                string line = sr.ReadLine();\r
-                while (line != null)\r
+                string line;\r
+                int i = 1;\r
+                while ((line = sr.ReadLine()) != null)\r
                 {\r
-                    if (line.Trim() != "")\r
-                        logData.Add(line + System.Environment.NewLine);\r
-\r
-                    line = sr.ReadLine();\r
+                    if (i > _position)\r
+                    {\r
+                        appendText += line + Environment.NewLine;\r
+                        _position++;\r
+                    }\r
+                    i++;\r
                 }\r
                 sr.Close();\r
                 sr.Dispose();\r
 \r
-                return logData;\r
+                return appendText;\r
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("Error in readFile() \n Unable to read the log file.\n You may have to restart HandBrake.\n  Error Information: \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                return "Error in ReadFile() \n Unable to read the log file.\n You may have to restart HandBrake. Will try reading the file again in a few seconds... \n  Error Information: \n\n" + exc;\r
             }\r
-            return null;\r
         }\r
 \r
-        /// <summary>\r
-        /// Kills the montior thead when the window is disposed of.\r
-        /// </summary>\r
-        /// <param name="sender"></param>\r
-        /// <param name="e"></param>\r
-        private void forceQuit(object sender, EventArgs e)\r
+        protected override void OnClosing(CancelEventArgs e)\r
         {\r
-            if (monitor != null)\r
-            {\r
-                while (monitor.IsAlive)\r
-                    monitor.Abort();\r
-            }\r
-\r
-            this.Close();\r
+            e.Cancel = true;\r
+            this.Hide();\r
+            base.OnClosing(e);\r
         }\r
 \r
-        private void copyToolStripMenuItem_Click(object sender, EventArgs e)\r
+        #region User Interface\r
+        private void mnu_copy_log_Click(object sender, EventArgs e)\r
         {\r
             if (rtf_actLog.SelectedText != "")\r
                 Clipboard.SetDataObject(rtf_actLog.SelectedText, true);\r
             else\r
                 Clipboard.SetDataObject(rtf_actLog.Text, true);\r
         }\r
+        private void mnu_openLogFolder_Click(object sender, EventArgs e)\r
+        {\r
+            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+            string windir = Environment.GetEnvironmentVariable("WINDIR");\r
+            System.Diagnostics.Process prc = new System.Diagnostics.Process();\r
+            prc.StartInfo.FileName = windir + @"\explorer.exe";\r
+            prc.StartInfo.Arguments = logDir;\r
+            prc.Start();\r
+        }\r
+        private void btn_copy_Click(object sender, EventArgs e)\r
+        {\r
+            if (rtf_actLog.SelectedText != "")\r
+                Clipboard.SetDataObject(rtf_actLog.SelectedText, true);\r
+            else\r
+                Clipboard.SetDataObject(rtf_actLog.Text, true);\r
+        }\r
+        private void btn_scan_log_Click(object sender, EventArgs e)\r
+        {\r
+            SetLogView(true);\r
+        }\r
+        private void btn_encode_log_Click(object sender, EventArgs e)\r
+        {\r
+            SetLogView(false);\r
+        }\r
+        #endregion\r
+\r
+        #region System Information\r
+        /// <summary>\r
+        /// Returns the total physical ram in a system\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        public uint TotalPhysicalMemory()\r
+        {\r
+            Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();\r
+            Win32.GlobalMemoryStatus(ref memStatus);\r
+\r
+            uint MemoryInfo = memStatus.dwTotalPhys;\r
+            MemoryInfo = MemoryInfo / 1024 / 1024;\r
+\r
+            return MemoryInfo;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the number of CPU Cores\r
+        /// </summary>\r
+        /// <returns>Object</returns>\r
+        public Object getCpuCount()\r
+        {\r
+            RegistryKey RegKey = Registry.LocalMachine;\r
+            RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
+            return RegKey.GetValue("ProcessorNameString");\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the System screen size information.\r
+        /// </summary>\r
+        /// <returns>System.Windows.Forms.Scree</returns>\r
+        public Screen screenBounds()\r
+        {\r
+            return Screen.PrimaryScreen;\r
+        }\r
+        #endregion\r
+\r
     }\r
 }
\ No newline at end of file
index 3d9888b..833a519 100644 (file)
   <data name="btn_copy.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
     <value>\r
         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8\r
-        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAeVJREFUOE+lk99P\r
-        kmEYhv1TSsdcdewf0FpZrTbbah7UQVvZOuJAjzpq2WzLNWy0iSHNwtIB9iE0l1KJEIgSYSL2AxfZVrCh\r
-        7vuURPTDruBlSdCGbj7bffbe1/Pc7/O+NTX7Laf3MwVJ7qiQZTRMv3OKqeB79sQumCvL7Ahwrf0ZE17v\r
-        7hD7eLTMn9v+TffAK1z+KBdbu3BPeKpDLGMzAuCKgfQBInGFB+aXSD4Fm1fG6pF5PCajH14Reu2bLwf2\r
-        OwM7E2xu5VDWsiRSaQGorI7BJRpa/DhcoRLEZPOIc33+LXSjCrekn7Q9iTPwZvk/QKsxhXNa4UizA2lk\r
-        sggx5PMWcq9nVJbkDIuJVT7GlzGNJAWgU8oJRRZWuaxLcrj5BYfOD1Hf9LQIKOTdyKo7nbWmGNcN89y3\r
-        LpZNoPxSWfixgX9uDaMUQnP2UQmgpLN8+pZi5kuCQOQ77ndfae8rrvfmYBqtIcmlezHO3Z4VMkpBNKd7\r
-        SoCGU1eoVJt+VgDUfLyUrDIXX2c8rGB/u8LDoQB1jfrq673aMS0A/3b+O0GPbZLa47rqgAs3PGQ2tzEN\r
-        h+m1hzA+D4rOBbPB4uPgsbvVAY1aV/62rUL1TWY0Z3qpO9lN7YmuvLmTA0fv7P7M9/SZ9nvoD8uZ5Oms\r
-        OGJjAAAAAElFTkSuQmCC\r
+        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHlSURBVDhPpZPfT5JhGIb9U0rHXHXsH9BaWa0222oe1EFb\r
+        2TriQI86atlsyzVstIkhzcLSAfYhNJdSiRCIEmEi9gMX2Vawoe77lET0w67gZUnQhm4+23323tfz3O/z\r
+        vjU1+y2n9zMFSe6okGU0TL9ziqnge/bELpgry+wIcK39GRNe7+4Q+3i0zJ/b/k33wCtc/igXW7twT3iq\r
+        QyxjMwLgioH0ASJxhQfml0g+BZtXxuqReTwmox9eEXrtmy8H9jsDOxNsbuVQ1rIkUmkBqKyOwSUaWvw4\r
+        XKESxGTziHN9/i10owq3pJ+0PYkz8Gb5P0CrMYVzWuFIswNpZLIIMeTzFnKvZ1SW5AyLiVU+xpcxjSQF\r
+        oFPKCUUWVrmsS3K4+QWHzg9R3/S0CCjk3ciqO521phjXDfPcty6WTaD8Uln4sYF/bg2jFEJz9lEJoKSz\r
+        fPqWYuZLgkDkO+53X2nvK6735mAarSHJpXsxzt2eFTJKQTSne0qAhlNXqFSbflYA1Hy8lKwyF19nPKxg\r
+        f7vCw6EAdY366uu92jEtAP92/jtBj22S2uO66oALNzxkNrcxDYfptYcwPg+KzgWzweLj4LG71QGNWlf+\r
+        tq1C9U1mNGd6qTvZTe2Jrry5kwNH7+z+zPf0mfZ76A/LmeTprDhiYwAAAABJRU5ErkJggg==\r
 </value>\r
   </data>\r
   <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
index 3db705c..8378390 100644 (file)
@@ -34,81 +34,140 @@ namespace Handbrake
         /// </summary>\r
         private void InitializeComponent()\r
         {\r
+            this.components = new System.ComponentModel.Container();\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAddPreset));\r
             this.lbl_name = new System.Windows.Forms.Label();\r
             this.txt_preset_name = new System.Windows.Forms.TextBox();\r
             this.btn_add = new System.Windows.Forms.Button();\r
             this.btn_cancel = new System.Windows.Forms.Button();\r
+            this.check_pictureSettings = new System.Windows.Forms.CheckBox();\r
+            this.toolTip = new System.Windows.Forms.ToolTip(this.components);\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // lbl_name\r
             // \r
+            this.lbl_name.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.lbl_name.AutoSize = true;\r
-            this.lbl_name.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_name.Location = new System.Drawing.Point(14, 20);\r
+            this.lbl_name.Location = new System.Drawing.Point(3, 7);\r
             this.lbl_name.Name = "lbl_name";\r
-            this.lbl_name.Size = new System.Drawing.Size(89, 13);\r
+            this.lbl_name.Size = new System.Drawing.Size(75, 13);\r
             this.lbl_name.TabIndex = 1;\r
             this.lbl_name.Text = "Preset Name: ";\r
             // \r
             // txt_preset_name\r
             // \r
-            this.txt_preset_name.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
-            this.txt_preset_name.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.txt_preset_name.Location = new System.Drawing.Point(109, 17);\r
+            this.txt_preset_name.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.tableLayoutPanel1.SetColumnSpan(this.txt_preset_name, 2);\r
+            this.txt_preset_name.Location = new System.Drawing.Point(84, 3);\r
             this.txt_preset_name.Name = "txt_preset_name";\r
-            this.txt_preset_name.Size = new System.Drawing.Size(241, 21);\r
-            this.txt_preset_name.TabIndex = 2;\r
+            this.txt_preset_name.Size = new System.Drawing.Size(208, 21);\r
+            this.txt_preset_name.TabIndex = 0;\r
             // \r
             // btn_add\r
             // \r
-            this.btn_add.BackColor = System.Drawing.SystemColors.Control;\r
+            this.btn_add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.btn_add.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_add.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_add.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_add.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_add.Location = new System.Drawing.Point(284, 44);\r
+            this.btn_add.Location = new System.Drawing.Point(172, 72);\r
             this.btn_add.Name = "btn_add";\r
-            this.btn_add.Size = new System.Drawing.Size(66, 22);\r
-            this.btn_add.TabIndex = 0;\r
-            this.btn_add.TabStop = false;\r
+            this.btn_add.Size = new System.Drawing.Size(57, 22);\r
+            this.btn_add.TabIndex = 2;\r
             this.btn_add.Text = "Add";\r
             this.btn_add.UseVisualStyleBackColor = false;\r
             this.btn_add.Click += new System.EventHandler(this.btn_add_Click);\r
             // \r
             // btn_cancel\r
             // \r
-            this.btn_cancel.BackColor = System.Drawing.SystemColors.Control;\r
+            this.btn_cancel.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_cancel.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_cancel.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_cancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_cancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_cancel.Location = new System.Drawing.Point(212, 44);\r
+            this.btn_cancel.Location = new System.Drawing.Point(235, 72);\r
             this.btn_cancel.Name = "btn_cancel";\r
-            this.btn_cancel.Size = new System.Drawing.Size(66, 22);\r
+            this.btn_cancel.Size = new System.Drawing.Size(57, 22);\r
             this.btn_cancel.TabIndex = 3;\r
-            this.btn_cancel.TabStop = false;\r
             this.btn_cancel.Text = "Cancel";\r
             this.btn_cancel.UseVisualStyleBackColor = false;\r
             this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);\r
             // \r
+            // check_pictureSettings\r
+            // \r
+            this.check_pictureSettings.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_pictureSettings.AutoSize = true;\r
+            this.tableLayoutPanel1.SetColumnSpan(this.check_pictureSettings, 2);\r
+            this.check_pictureSettings.Location = new System.Drawing.Point(84, 30);\r
+            this.check_pictureSettings.Name = "check_pictureSettings";\r
+            this.check_pictureSettings.Size = new System.Drawing.Size(132, 17);\r
+            this.check_pictureSettings.TabIndex = 1;\r
+            this.check_pictureSettings.Text = "Store Cropping Values";\r
+            this.toolTip.SetToolTip(this.check_pictureSettings, "Save Picture Width/Height and Crop Values");\r
+            this.check_pictureSettings.UseVisualStyleBackColor = true;\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label1.AutoSize = true;\r
+            this.tableLayoutPanel1.SetColumnSpan(this.label1, 2);\r
+            this.label1.Location = new System.Drawing.Point(84, 53);\r
+            this.label1.Margin = new System.Windows.Forms.Padding(3);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(200, 13);\r
+            this.label1.TabIndex = 4;\r
+            this.label1.Text = "Note: Subtitles are not stored in presets";\r
+            // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.AutoSize = true;\r
+            this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel1.ColumnCount = 3;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_name, 0, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_cancel, 2, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.label1, 1, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_add, 1, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.txt_preset_name, 1, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.check_pictureSettings, 1, 1);\r
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 9);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 4;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(295, 125);\r
+            this.tableLayoutPanel1.TabIndex = 5;\r
+            // \r
             // frmAddPreset\r
             // \r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(362, 76);\r
-            this.Controls.Add(this.btn_cancel);\r
-            this.Controls.Add(this.btn_add);\r
-            this.Controls.Add(this.txt_preset_name);\r
-            this.Controls.Add(this.lbl_name);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;\r
+            this.AutoSize = true;\r
+            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.ClientSize = new System.Drawing.Size(313, 143);\r
+            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
             this.MaximizeBox = false;\r
             this.MinimizeBox = false;\r
             this.Name = "frmAddPreset";\r
+            this.Padding = new System.Windows.Forms.Padding(9);\r
+            this.ShowIcon = false;\r
             this.ShowInTaskbar = false;\r
             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
             this.Text = "Add Preset";\r
             this.TopMost = true;\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -120,5 +179,9 @@ namespace Handbrake
         private System.Windows.Forms.TextBox txt_preset_name;\r
         internal System.Windows.Forms.Button btn_add;\r
         internal System.Windows.Forms.Button btn_cancel;\r
+        private System.Windows.Forms.CheckBox check_pictureSettings;\r
+        private System.Windows.Forms.ToolTip toolTip;\r
+        private System.Windows.Forms.Label label1;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
     }\r
 }
\ No newline at end of file
index 3fa157d..8ffd763 100644 (file)
@@ -5,21 +5,16 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
-using System.ComponentModel;\r
-using System.Data;\r
 using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.IO;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmAddPreset : Form\r
     {\r
-        private frmMain frmMainWindow;\r
-        Presets.PresetsHandler presetCode;\r
-        private string query = "";\r
+        private readonly frmMain frmMainWindow;\r
+        readonly Presets.PresetsHandler presetCode;\r
+        private readonly string query = "";\r
 \r
         public frmAddPreset(frmMain fmw, string query_string, Presets.PresetsHandler presetHandler)\r
         {\r
@@ -31,10 +26,21 @@ namespace Handbrake
 \r
         private void btn_add_Click(object sender, EventArgs e)\r
         {\r
-            if (presetCode.addPreset(txt_preset_name.Text.Trim(), query) == true)\r
+            Boolean pictureSettings = false;\r
+            if (check_pictureSettings.Checked)\r
+                pictureSettings = true;\r
+\r
+            if (presetCode.Add(txt_preset_name.Text.Trim(), query, pictureSettings))\r
             {\r
-                frmMainWindow.loadPresetPanel();\r
+                TreeNode preset_treeview = new TreeNode(txt_preset_name.Text.Trim()) { ForeColor = Color.Black };\r
+                frmMainWindow.treeView_presets.Nodes.Add(preset_treeview);\r
+\r
+                //frmMainWindow.loadPresetPanel();\r
                 this.Close();\r
+            } \r
+            else\r
+            {\r
+                MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             }\r
         }\r
 \r
index 37f9290..3412254 100644 (file)
   <resheader name="writer">\r
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
   </resheader>\r
+  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
   <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
     <value>\r
index 5d0f452..f987979 100644 (file)
@@ -37,70 +37,99 @@ namespace Handbrake
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmDownload));\r
             this.lblProgress = new System.Windows.Forms.Label();\r
             this.progress_download = new System.Windows.Forms.ProgressBar();\r
-            this.PictureBox1 = new System.Windows.Forms.PictureBox();\r
             this.btn_cancel = new System.Windows.Forms.Button();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.PictureBox1 = new System.Windows.Forms.PictureBox();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).BeginInit();\r
             this.SuspendLayout();\r
             // \r
             // lblProgress\r
             // \r
             this.lblProgress.AutoSize = true;\r
-            this.lblProgress.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lblProgress.Location = new System.Drawing.Point(93, 38);\r
+            this.lblProgress.Location = new System.Drawing.Point(73, 29);\r
             this.lblProgress.Name = "lblProgress";\r
-            this.lblProgress.Size = new System.Drawing.Size(115, 13);\r
+            this.lblProgress.Size = new System.Drawing.Size(98, 13);\r
             this.lblProgress.TabIndex = 10;\r
             this.lblProgress.Text = "Awaiting Download";\r
             // \r
             // progress_download\r
             // \r
-            this.progress_download.Location = new System.Drawing.Point(93, 12);\r
+            this.progress_download.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.progress_download.Location = new System.Drawing.Point(73, 3);\r
             this.progress_download.Name = "progress_download";\r
-            this.progress_download.Size = new System.Drawing.Size(318, 23);\r
+            this.progress_download.Size = new System.Drawing.Size(273, 23);\r
             this.progress_download.Style = System.Windows.Forms.ProgressBarStyle.Continuous;\r
             this.progress_download.TabIndex = 9;\r
             // \r
-            // PictureBox1\r
-            // \r
-            this.PictureBox1.Image = global::Handbrake.Properties.Resources.logo64;\r
-            this.PictureBox1.InitialImage = null;\r
-            this.PictureBox1.Location = new System.Drawing.Point(12, 12);\r
-            this.PictureBox1.Name = "PictureBox1";\r
-            this.PictureBox1.Size = new System.Drawing.Size(75, 64);\r
-            this.PictureBox1.TabIndex = 25;\r
-            this.PictureBox1.TabStop = false;\r
-            // \r
             // btn_cancel\r
             // \r
+            this.btn_cancel.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
             this.btn_cancel.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_cancel.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_cancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_cancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_cancel.Location = new System.Drawing.Point(321, 54);\r
+            this.btn_cancel.Location = new System.Drawing.Point(275, 45);\r
             this.btn_cancel.Name = "btn_cancel";\r
-            this.btn_cancel.Size = new System.Drawing.Size(90, 22);\r
-            this.btn_cancel.TabIndex = 56;\r
+            this.btn_cancel.Size = new System.Drawing.Size(71, 22);\r
+            this.btn_cancel.TabIndex = 26;\r
+            this.btn_cancel.TabStop = false;\r
             this.btn_cancel.Text = "Cancel";\r
-            this.btn_cancel.UseVisualStyleBackColor = false;\r
+            this.btn_cancel.UseVisualStyleBackColor = true;\r
             this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);\r
             // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.ColumnCount = 2;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.PictureBox1, 0, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_cancel, 1, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.progress_download, 1, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.lblProgress, 1, 1);\r
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 9);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 3;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(349, 70);\r
+            this.tableLayoutPanel1.TabIndex = 27;\r
+            // \r
+            // PictureBox1\r
+            // \r
+            this.PictureBox1.Image = global::Handbrake.Properties.Resources.logo64;\r
+            this.PictureBox1.InitialImage = null;\r
+            this.PictureBox1.Location = new System.Drawing.Point(3, 3);\r
+            this.PictureBox1.Name = "PictureBox1";\r
+            this.tableLayoutPanel1.SetRowSpan(this.PictureBox1, 3);\r
+            this.PictureBox1.Size = new System.Drawing.Size(64, 64);\r
+            this.PictureBox1.TabIndex = 25;\r
+            this.PictureBox1.TabStop = false;\r
+            // \r
             // frmDownload\r
             // \r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(426, 87);\r
-            this.Controls.Add(this.btn_cancel);\r
-            this.Controls.Add(this.PictureBox1);\r
-            this.Controls.Add(this.lblProgress);\r
-            this.Controls.Add(this.progress_download);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.AutoSize = true;\r
+            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.ClientSize = new System.Drawing.Size(367, 88);\r
+            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
+            this.MaximizeBox = false;\r
+            this.MinimizeBox = false;\r
             this.Name = "frmDownload";\r
+            this.Padding = new System.Windows.Forms.Padding(9);\r
             this.ShowIcon = false;\r
+            this.ShowInTaskbar = false;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "Downloading Update";\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit();\r
             this.ResumeLayout(false);\r
-            this.PerformLayout();\r
 \r
         }\r
 \r
@@ -108,7 +137,8 @@ namespace Handbrake
 \r
         private System.Windows.Forms.Label lblProgress;\r
         private System.Windows.Forms.ProgressBar progress_download;\r
-        internal System.Windows.Forms.PictureBox PictureBox1;\r
         internal System.Windows.Forms.Button btn_cancel;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
+        internal System.Windows.Forms.PictureBox PictureBox1;\r
     }\r
 }
\ No newline at end of file
index 8fe53ba..8b23df9 100644 (file)
@@ -5,7 +5,6 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections.Generic;\r
 using System.Windows.Forms;\r
 using System.Net;\r
 using System.IO;\r
@@ -16,7 +15,7 @@ namespace Handbrake
 {\r
     public partial class frmDownload : Form\r
     {\r
-        private Thread downloadThread;\r
+        private readonly Thread downloadThread;\r
         private Stream responceStream;\r
         private Stream loacalStream;\r
         private HttpWebRequest webRequest;\r
@@ -56,7 +55,7 @@ namespace Handbrake
                 responceStream = wcDownload.OpenRead(hbUpdate);\r
                 loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
 \r
-                int bytesSize = 0;\r
+                int bytesSize;\r
                 byte[] downBuffer = new byte[2048];\r
 \r
                 long flength = 0;\r
@@ -64,16 +63,16 @@ namespace Handbrake
                 {\r
                     loacalStream.Write(downBuffer, 0, bytesSize);\r
                     flength = loacalStream.Length;\r
-                    this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
+                    Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });\r
                 }\r
 \r
                 responceStream.Close();\r
                 loacalStream.Close();\r
 \r
                 if (flength != fileSize)\r
-                    this.Invoke(new DownloadFailedCallback(this.downloadFailed));\r
+                    Invoke(new DownloadFailedCallback(this.downloadFailed));\r
                 else\r
-                    this.Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
+                    Invoke(new DownloadCompleteCallback(this.downloadComplete));\r
             }\r
             catch (Exception)\r
             {\r
@@ -92,7 +91,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("Integer Convertion Error On Download \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("Integer Conversion Error On Download \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
 \r
@@ -102,8 +101,7 @@ namespace Handbrake
             btn_cancel.Text = "Close";\r
 \r
             string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
-\r
-            Process startInstall = Process.Start(tempPath);\r
+            Process.Start(tempPath);\r
             this.Close();\r
             Application.Exit();\r
         }\r
index 28d111e..d1446b1 100644 (file)
@@ -4,6 +4,9 @@
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
+using System;\r
+using System.Windows.Forms;\r
+\r
 namespace Handbrake\r
 {\r
     partial class frmMain\r
@@ -35,81 +38,40 @@ namespace Handbrake
         private void InitializeComponent()\r
         {\r
             this.components = new System.ComponentModel.Container();\r
-            System.Windows.Forms.Label Label38;\r
             System.Windows.Forms.ContextMenuStrip notifyIconMenu;\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));\r
             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();\r
             this.btn_restore = new System.Windows.Forms.ToolStripMenuItem();\r
             this.DVD_Save = new System.Windows.Forms.SaveFileDialog();\r
-            this.File_Save = new System.Windows.Forms.SaveFileDialog();\r
             this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
-            this.drop_chapterFinish = new System.Windows.Forms.ComboBox();\r
-            this.drop_chapterStart = new System.Windows.Forms.ComboBox();\r
-            this.drp_dvdtitle = new System.Windows.Forms.ComboBox();\r
-            this.text_source = new System.Windows.Forms.TextBox();\r
             this.text_destination = new System.Windows.Forms.TextBox();\r
             this.drp_videoEncoder = new System.Windows.Forms.ComboBox();\r
-            this.drp_audbit_1 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audsr_1 = new System.Windows.Forms.ComboBox();\r
             this.check_largeFile = new System.Windows.Forms.CheckBox();\r
             this.check_turbo = new System.Windows.Forms.CheckBox();\r
             this.drp_videoFramerate = new System.Windows.Forms.ComboBox();\r
             this.slider_videoQuality = new System.Windows.Forms.TrackBar();\r
             this.text_filesize = new System.Windows.Forms.TextBox();\r
             this.text_bitrate = new System.Windows.Forms.TextBox();\r
-            this.drp_subtitle = new System.Windows.Forms.ComboBox();\r
             this.btn_setDefault = new System.Windows.Forms.Button();\r
-            this.drp_audmix_1 = new System.Windows.Forms.ComboBox();\r
-            this.text_height = new System.Windows.Forms.TextBox();\r
-            this.text_width = new System.Windows.Forms.TextBox();\r
             this.check_optimiseMP4 = new System.Windows.Forms.CheckBox();\r
             this.check_iPodAtom = new System.Windows.Forms.CheckBox();\r
             this.data_chpt = new System.Windows.Forms.DataGridView();\r
             this.number = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.ChaptersMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.mnu_resetChapters = new System.Windows.Forms.ToolStripMenuItem();\r
             this.btn_addPreset = new System.Windows.Forms.Button();\r
             this.btn_removePreset = new System.Windows.Forms.Button();\r
-            this.drp_audmix_2 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audenc_1 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audenc_2 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audbit_2 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audsr_2 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audsr_3 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audbit_3 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audenc_3 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audmix_3 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audsr_4 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audbit_4 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audenc_4 = new System.Windows.Forms.ComboBox();\r
-            this.drp_audmix_4 = new System.Windows.Forms.ComboBox();\r
             this.drop_format = new System.Windows.Forms.ComboBox();\r
-            this.check_customCrop = new System.Windows.Forms.RadioButton();\r
-            this.check_autoCrop = new System.Windows.Forms.RadioButton();\r
-            this.check_Cabac = new System.Windows.Forms.CheckBox();\r
-            this.check_noDCTDecimate = new System.Windows.Forms.CheckBox();\r
-            this.check_noFastPSkip = new System.Windows.Forms.CheckBox();\r
-            this.drop_trellis = new System.Windows.Forms.ComboBox();\r
-            this.drop_deblockBeta = new System.Windows.Forms.ComboBox();\r
-            this.drop_deblockAlpha = new System.Windows.Forms.ComboBox();\r
-            this.check_8x8DCT = new System.Windows.Forms.CheckBox();\r
-            this.drop_analysis = new System.Windows.Forms.ComboBox();\r
-            this.drop_subpixelMotionEstimation = new System.Windows.Forms.ComboBox();\r
-            this.drop_MotionEstimationRange = new System.Windows.Forms.ComboBox();\r
-            this.drop_MotionEstimationMethod = new System.Windows.Forms.ComboBox();\r
-            this.check_pyrmidalBFrames = new System.Windows.Forms.CheckBox();\r
-            this.check_weightedBFrames = new System.Windows.Forms.CheckBox();\r
-            this.drop_directPrediction = new System.Windows.Forms.ComboBox();\r
-            this.drop_bFrames = new System.Windows.Forms.ComboBox();\r
-            this.drop_refFrames = new System.Windows.Forms.ComboBox();\r
-            this.check_mixedReferences = new System.Windows.Forms.CheckBox();\r
-            this.lbl_src_res = new System.Windows.Forms.Label();\r
-            this.lbl_duration = new System.Windows.Forms.Label();\r
-            this.label_duration = new System.Windows.Forms.Label();\r
-            this.label7 = new System.Windows.Forms.Label();\r
+            this.drop_chapterFinish = new System.Windows.Forms.ComboBox();\r
+            this.drop_chapterStart = new System.Windows.Forms.ComboBox();\r
+            this.drop_angle = new System.Windows.Forms.ComboBox();\r
+            this.drp_dvdtitle = new System.Windows.Forms.ComboBox();\r
             this.DVD_Open = new System.Windows.Forms.FolderBrowserDialog();\r
             this.File_Open = new System.Windows.Forms.OpenFileDialog();\r
             this.ISO_Open = new System.Windows.Forms.OpenFileDialog();\r
             this.FileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.mnu_killCLI = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_exit = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_open3 = new System.Windows.Forms.ToolStripMenuItem();\r
             this.ToolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
@@ -122,6 +84,7 @@ namespace Handbrake
             this.mnu_delete_preset = new System.Windows.Forms.ToolStripMenuItem();\r
             this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();\r
             this.btn_new_preset = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.mnu_importMacPreset = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_SelectDefault = new System.Windows.Forms.ToolStripMenuItem();\r
             this.HelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_user_guide = new System.Windows.Forms.ToolStripMenuItem();\r
@@ -132,109 +95,40 @@ namespace Handbrake
             this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();\r
             this.mnu_about = new System.Windows.Forms.ToolStripMenuItem();\r
             this.frmMainMenu = new System.Windows.Forms.MenuStrip();\r
-            this.GroupBox1 = new System.Windows.Forms.GroupBox();\r
-            this.Label13 = new System.Windows.Forms.Label();\r
-            this.Label17 = new System.Windows.Forms.Label();\r
-            this.Label9 = new System.Windows.Forms.Label();\r
-            this.Label10 = new System.Windows.Forms.Label();\r
-            this.groupBox_output = new System.Windows.Forms.GroupBox();\r
             this.label5 = new System.Windows.Forms.Label();\r
             this.Label47 = new System.Windows.Forms.Label();\r
             this.Label3 = new System.Windows.Forms.Label();\r
-            this.TabPage2 = new System.Windows.Forms.TabPage();\r
-            this.lbl_drc4 = new System.Windows.Forms.Label();\r
-            this.lbl_drc3 = new System.Windows.Forms.Label();\r
-            this.lbl_drc2 = new System.Windows.Forms.Label();\r
-            this.lbl_drc1 = new System.Windows.Forms.Label();\r
-            this.trackBar4 = new System.Windows.Forms.TrackBar();\r
-            this.drp_track4Audio = new System.Windows.Forms.ComboBox();\r
-            this.lbl_t4 = new System.Windows.Forms.Label();\r
-            this.trackBar3 = new System.Windows.Forms.TrackBar();\r
-            this.drp_track3Audio = new System.Windows.Forms.ComboBox();\r
-            this.lbl_t3 = new System.Windows.Forms.Label();\r
-            this.trackBar2 = new System.Windows.Forms.TrackBar();\r
-            this.label16 = new System.Windows.Forms.Label();\r
-            this.trackBar1 = new System.Windows.Forms.TrackBar();\r
-            this.groupBox5 = new System.Windows.Forms.GroupBox();\r
-            this.groupBox3 = new System.Windows.Forms.GroupBox();\r
-            this.label68 = new System.Windows.Forms.Label();\r
-            this.label67 = new System.Windows.Forms.Label();\r
-            this.label66 = new System.Windows.Forms.Label();\r
-            this.label65 = new System.Windows.Forms.Label();\r
-            this.label14 = new System.Windows.Forms.Label();\r
-            this.check_forced = new System.Windows.Forms.CheckBox();\r
-            this.drp_track2Audio = new System.Windows.Forms.ComboBox();\r
-            this.label28 = new System.Windows.Forms.Label();\r
-            this.label27 = new System.Windows.Forms.Label();\r
-            this.Label19 = new System.Windows.Forms.Label();\r
-            this.Label20 = new System.Windows.Forms.Label();\r
-            this.drp_track1Audio = new System.Windows.Forms.ComboBox();\r
-            this.Label32 = new System.Windows.Forms.Label();\r
-            this.TabPage3 = new System.Windows.Forms.TabPage();\r
+            this.tab_audio = new System.Windows.Forms.TabPage();\r
+            this.AudioSettings = new Handbrake.Controls.AudioPanel();\r
+            this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components);\r
+            this.tab_video = new System.Windows.Forms.TabPage();\r
+            this.radio_cq = new System.Windows.Forms.RadioButton();\r
+            this.radio_avgBitrate = new System.Windows.Forms.RadioButton();\r
+            this.radio_targetFilesize = new System.Windows.Forms.RadioButton();\r
             this.label25 = new System.Windows.Forms.Label();\r
-            this.check_grayscale = new System.Windows.Forms.CheckBox();\r
-            this.Label22 = new System.Windows.Forms.Label();\r
             this.check_2PassEncode = new System.Windows.Forms.CheckBox();\r
             this.Label2 = new System.Windows.Forms.Label();\r
-            this.Label42 = new System.Windows.Forms.Label();\r
             this.SliderValue = new System.Windows.Forms.Label();\r
             this.Label46 = new System.Windows.Forms.Label();\r
-            this.Label40 = new System.Windows.Forms.Label();\r
-            this.TabPage1 = new System.Windows.Forms.TabPage();\r
-            this.slider_deblock = new System.Windows.Forms.TrackBar();\r
-            this.label8 = new System.Windows.Forms.Label();\r
-            this.lbl_deblockVal = new System.Windows.Forms.Label();\r
-            this.check_decomb = new System.Windows.Forms.CheckBox();\r
-            this.label6 = new System.Windows.Forms.Label();\r
-            this.drp_anamorphic = new System.Windows.Forms.ComboBox();\r
-            this.text_bottom = new System.Windows.Forms.NumericUpDown();\r
-            this.text_top = new System.Windows.Forms.NumericUpDown();\r
-            this.text_left = new System.Windows.Forms.NumericUpDown();\r
-            this.text_right = new System.Windows.Forms.NumericUpDown();\r
-            this.label26 = new System.Windows.Forms.Label();\r
-            this.Label56 = new System.Windows.Forms.Label();\r
-            this.lbl_Aspect = new System.Windows.Forms.Label();\r
-            this.Label91 = new System.Windows.Forms.Label();\r
-            this.Label55 = new System.Windows.Forms.Label();\r
-            this.label24 = new System.Windows.Forms.Label();\r
-            this.drp_deNoise = new System.Windows.Forms.ComboBox();\r
-            this.label11 = new System.Windows.Forms.Label();\r
-            this.check_detelecine = new System.Windows.Forms.CheckBox();\r
-            this.label4 = new System.Windows.Forms.Label();\r
-            this.drp_deInterlace_option = new System.Windows.Forms.ComboBox();\r
-            this.Label1 = new System.Windows.Forms.Label();\r
-            this.Label53 = new System.Windows.Forms.Label();\r
-            this.Label52 = new System.Windows.Forms.Label();\r
-            this.Label51 = new System.Windows.Forms.Label();\r
-            this.Label15 = new System.Windows.Forms.Label();\r
+            this.tab_picture = new System.Windows.Forms.TabPage();\r
+            this.PictureSettings = new Handbrake.Controls.PictureSettings();\r
             this.Check_ChapterMarkers = new System.Windows.Forms.CheckBox();\r
-            this.advancedOptions = new System.Windows.Forms.TabControl();\r
+            this.tabs_panel = new System.Windows.Forms.TabControl();\r
+            this.tab_filters = new System.Windows.Forms.TabPage();\r
+            this.Filters = new Handbrake.Controls.Filters();\r
+            this.tab_subtitles = new System.Windows.Forms.TabPage();\r
+            this.Subtitles = new Handbrake.Controls.Subtitles();\r
             this.tab_chapters = new System.Windows.Forms.TabPage();\r
+            this.btn_importChapters = new System.Windows.Forms.Button();\r
             this.label31 = new System.Windows.Forms.Label();\r
-            this.h264Tab = new System.Windows.Forms.TabPage();\r
-            this.label43 = new System.Windows.Forms.Label();\r
-            this.btn_reset = new System.Windows.Forms.Button();\r
-            this.rtf_x264Query = new System.Windows.Forms.RichTextBox();\r
-            this.lbl_trellis = new System.Windows.Forms.Label();\r
-            this.label41 = new System.Windows.Forms.Label();\r
-            this.panel3 = new System.Windows.Forms.Panel();\r
-            this.panel1 = new System.Windows.Forms.Panel();\r
-            this.panel2 = new System.Windows.Forms.Panel();\r
-            this.label45 = new System.Windows.Forms.Label();\r
-            this.label48 = new System.Windows.Forms.Label();\r
-            this.label49 = new System.Windows.Forms.Label();\r
-            this.label54 = new System.Windows.Forms.Label();\r
-            this.lbl_direct_prediction = new System.Windows.Forms.Label();\r
-            this.label62 = new System.Windows.Forms.Label();\r
-            this.label64 = new System.Windows.Forms.Label();\r
-            this.tabPage4 = new System.Windows.Forms.TabPage();\r
+            this.tab_advanced = new System.Windows.Forms.TabPage();\r
+            this.x264Panel = new Handbrake.Controls.x264Panel();\r
+            this.tab_query = new System.Windows.Forms.TabPage();\r
             this.btn_clear = new System.Windows.Forms.Button();\r
             this.label34 = new System.Windows.Forms.Label();\r
             this.btn_generate_Query = new System.Windows.Forms.Button();\r
             this.label33 = new System.Windows.Forms.Label();\r
             this.rtf_query = new System.Windows.Forms.RichTextBox();\r
-            this.groupBox_dest = new System.Windows.Forms.GroupBox();\r
-            this.btn_destBrowse = new System.Windows.Forms.Button();\r
             this.groupBox2 = new System.Windows.Forms.GroupBox();\r
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();\r
             this.treeView_presets = new System.Windows.Forms.TreeView();\r
@@ -242,6 +136,9 @@ namespace Handbrake
             this.pmnu_expandAll = new System.Windows.Forms.ToolStripMenuItem();\r
             this.pmnu_collapse = new System.Windows.Forms.ToolStripMenuItem();\r
             this.sep1 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.pmnu_import = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.pmnu_saveChanges = new System.Windows.Forms.ToolStripMenuItem();\r
             this.pmnu_delete = new System.Windows.Forms.ToolStripMenuItem();\r
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();\r
             this.btn_source = new System.Windows.Forms.ToolStripDropDownButton();\r
@@ -254,37 +151,46 @@ namespace Handbrake
             this.btn_add2Queue = new System.Windows.Forms.ToolStripButton();\r
             this.btn_showQueue = new System.Windows.Forms.ToolStripButton();\r
             this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.tb_preview = new System.Windows.Forms.ToolStripButton();\r
             this.btn_ActivityWindow = new System.Windows.Forms.ToolStripButton();\r
-            this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();\r
-            this.btn_minimize = new System.Windows.Forms.ToolStripButton();\r
             this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);\r
             this.StatusStrip = new System.Windows.Forms.StatusStrip();\r
             this.lbl_encode = new System.Windows.Forms.ToolStripStatusLabel();\r
-            Label38 = new System.Windows.Forms.Label();\r
+            this.lbl_updateCheck = new System.Windows.Forms.ToolStripStatusLabel();\r
+            this.hbproc = new System.Diagnostics.Process();\r
+            this.File_Save = new System.Windows.Forms.SaveFileDialog();\r
+            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.btn_destBrowse = new System.Windows.Forms.Button();\r
+            this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.Label10 = new System.Windows.Forms.Label();\r
+            this.lbl_angle = new System.Windows.Forms.Label();\r
+            this.Label9 = new System.Windows.Forms.Label();\r
+            this.Label13 = new System.Windows.Forms.Label();\r
+            this.label_duration = new System.Windows.Forms.Label();\r
+            this.lbl_duration = new System.Windows.Forms.Label();\r
+            this.labelStaticDestination = new System.Windows.Forms.Label();\r
+            this.labelPreset = new System.Windows.Forms.Label();\r
+            this.labelSource = new System.Windows.Forms.Label();\r
+            this.labelStaticSource = new System.Windows.Forms.Label();\r
+            this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();\r
+            this.openPreset = new System.Windows.Forms.OpenFileDialog();\r
+            this.File_ChapterImport = new System.Windows.Forms.OpenFileDialog();\r
             notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
             notifyIconMenu.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit();\r
             ((System.ComponentModel.ISupportInitialize)(this.data_chpt)).BeginInit();\r
+            this.ChaptersMenu.SuspendLayout();\r
             this.frmMainMenu.SuspendLayout();\r
-            this.GroupBox1.SuspendLayout();\r
-            this.groupBox_output.SuspendLayout();\r
-            this.TabPage2.SuspendLayout();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();\r
-            this.TabPage3.SuspendLayout();\r
-            this.TabPage1.SuspendLayout();\r
-            ((System.ComponentModel.ISupportInitialize)(this.slider_deblock)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_bottom)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_top)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_left)).BeginInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_right)).BeginInit();\r
-            this.advancedOptions.SuspendLayout();\r
+            this.tab_audio.SuspendLayout();\r
+            this.tab_video.SuspendLayout();\r
+            this.tab_picture.SuspendLayout();\r
+            this.tabs_panel.SuspendLayout();\r
+            this.tab_filters.SuspendLayout();\r
+            this.tab_subtitles.SuspendLayout();\r
             this.tab_chapters.SuspendLayout();\r
-            this.h264Tab.SuspendLayout();\r
-            this.tabPage4.SuspendLayout();\r
-            this.groupBox_dest.SuspendLayout();\r
+            this.tab_advanced.SuspendLayout();\r
+            this.tab_query.SuspendLayout();\r
             this.groupBox2.SuspendLayout();\r
             this.splitContainer1.Panel1.SuspendLayout();\r
             this.splitContainer1.Panel2.SuspendLayout();\r
@@ -292,42 +198,31 @@ namespace Handbrake
             this.presets_menu.SuspendLayout();\r
             this.toolStrip1.SuspendLayout();\r
             this.StatusStrip.SuspendLayout();\r
+            this.tableLayoutPanel2.SuspendLayout();\r
+            this.tableLayoutPanel3.SuspendLayout();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
+            this.flowLayoutPanel1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
-            // Label38\r
-            // \r
-            Label38.AutoSize = true;\r
-            Label38.BackColor = System.Drawing.Color.Transparent;\r
-            Label38.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            Label38.Location = new System.Drawing.Point(334, 38);\r
-            Label38.Name = "Label38";\r
-            Label38.Size = new System.Drawing.Size(108, 13);\r
-            Label38.TabIndex = 11;\r
-            Label38.Text = "Target Size (MB):";\r
-            // \r
             // notifyIconMenu\r
             // \r
             notifyIconMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.btn_restore});\r
             notifyIconMenu.Name = "notifyIconMenu";\r
             notifyIconMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
-            notifyIconMenu.Size = new System.Drawing.Size(129, 26);\r
+            notifyIconMenu.Size = new System.Drawing.Size(124, 26);\r
             // \r
             // btn_restore\r
             // \r
             this.btn_restore.Name = "btn_restore";\r
-            this.btn_restore.Size = new System.Drawing.Size(128, 22);\r
+            this.btn_restore.Size = new System.Drawing.Size(123, 22);\r
             this.btn_restore.Text = "Restore";\r
             this.btn_restore.Click += new System.EventHandler(this.btn_restore_Click);\r
             // \r
             // DVD_Save\r
             // \r
-            this.DVD_Save.Filter = "mp4|*.mp4|m4v|*.m4v|avi|*.avi|ogm|*.ogm|mkv|*.mkv";\r
-            // \r
-            // File_Save\r
-            // \r
-            this.File_Save.DefaultExt = "hb";\r
-            this.File_Save.Filter = "hb|*.hb";\r
+            this.DVD_Save.Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv";\r
+            this.DVD_Save.SupportMultiDottedExtensions = true;\r
             // \r
             // ToolTip\r
             // \r
@@ -336,62 +231,13 @@ namespace Handbrake
             this.ToolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;\r
             this.ToolTip.ToolTipTitle = "Tooltip";\r
             // \r
-            // drop_chapterFinish\r
-            // \r
-            this.drop_chapterFinish.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drop_chapterFinish.FormattingEnabled = true;\r
-            this.drop_chapterFinish.Location = new System.Drawing.Point(427, 52);\r
-            this.drop_chapterFinish.Name = "drop_chapterFinish";\r
-            this.drop_chapterFinish.Size = new System.Drawing.Size(69, 21);\r
-            this.drop_chapterFinish.TabIndex = 10;\r
-            this.drop_chapterFinish.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drop_chapterFinish, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
-            this.drop_chapterFinish.SelectedIndexChanged += new System.EventHandler(this.drop_chapterFinish_SelectedIndexChanged);\r
-            // \r
-            // drop_chapterStart\r
-            // \r
-            this.drop_chapterStart.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drop_chapterStart.FormattingEnabled = true;\r
-            this.drop_chapterStart.Location = new System.Drawing.Point(295, 52);\r
-            this.drop_chapterStart.Name = "drop_chapterStart";\r
-            this.drop_chapterStart.Size = new System.Drawing.Size(69, 21);\r
-            this.drop_chapterStart.TabIndex = 9;\r
-            this.drop_chapterStart.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drop_chapterStart, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
-            this.drop_chapterStart.SelectedIndexChanged += new System.EventHandler(this.drop_chapterStart_SelectedIndexChanged);\r
-            // \r
-            // drp_dvdtitle\r
-            // \r
-            this.drp_dvdtitle.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_dvdtitle.FormattingEnabled = true;\r
-            this.drp_dvdtitle.Items.AddRange(new object[] {\r
-            "Automatic"});\r
-            this.drp_dvdtitle.Location = new System.Drawing.Point(99, 52);\r
-            this.drp_dvdtitle.Name = "drp_dvdtitle";\r
-            this.drp_dvdtitle.Size = new System.Drawing.Size(119, 21);\r
-            this.drp_dvdtitle.TabIndex = 7;\r
-            this.drp_dvdtitle.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.drp_dvdtitle, "Select the title you wish to encode.\r\nThe longest title is selected by default af" +\r
-                    "ter you have scanned a source.");\r
-            this.drp_dvdtitle.SelectedIndexChanged += new System.EventHandler(this.drp_dvdtitle_SelectedIndexChanged);\r
-            this.drp_dvdtitle.Click += new System.EventHandler(this.drp_dvdtitle_Click);\r
-            // \r
-            // text_source\r
-            // \r
-            this.text_source.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_source.Location = new System.Drawing.Point(99, 19);\r
-            this.text_source.Name = "text_source";\r
-            this.text_source.Size = new System.Drawing.Size(584, 21);\r
-            this.text_source.TabIndex = 1;\r
-            this.text_source.Text = "Click \'Source\' to continue";\r
-            this.ToolTip.SetToolTip(this.text_source, "Location of the source input file, folder or dvd.");\r
-            // \r
             // text_destination\r
             // \r
-            this.text_destination.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_destination.Location = new System.Drawing.Point(99, 19);\r
+            this.text_destination.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_destination.Location = new System.Drawing.Point(36, 3);\r
             this.text_destination.Name = "text_destination";\r
-            this.text_destination.Size = new System.Drawing.Size(503, 21);\r
+            this.text_destination.Size = new System.Drawing.Size(603, 21);\r
             this.text_destination.TabIndex = 1;\r
             this.ToolTip.SetToolTip(this.text_destination, "Location where the encoded file will be saved.");\r
             this.text_destination.TextChanged += new System.EventHandler(this.text_destination_TextChanged);\r
@@ -399,11 +245,9 @@ namespace Handbrake
             // drp_videoEncoder\r
             // \r
             this.drp_videoEncoder.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_videoEncoder.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drp_videoEncoder.FormattingEnabled = true;\r
             this.drp_videoEncoder.Items.AddRange(new object[] {\r
             "MPEG-4 (FFmpeg)",\r
-            "MPEG-4 (XviD)",\r
             "H.264 (x264)",\r
             "VP3 (Theora)"});\r
             this.drp_videoEncoder.Location = new System.Drawing.Point(125, 35);\r
@@ -413,54 +257,14 @@ namespace Handbrake
             this.ToolTip.SetToolTip(this.drp_videoEncoder, "Select a video encoder");\r
             this.drp_videoEncoder.SelectedIndexChanged += new System.EventHandler(this.drp_videoEncoder_SelectedIndexChanged);\r
             // \r
-            // drp_audbit_1\r
-            // \r
-            this.drp_audbit_1.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audbit_1.FormattingEnabled = true;\r
-            this.drp_audbit_1.Items.AddRange(new object[] {\r
-            "32",\r
-            "40",\r
-            "48",\r
-            "56",\r
-            "64",\r
-            "80",\r
-            "86",\r
-            "112",\r
-            "128",\r
-            "160"});\r
-            this.drp_audbit_1.Location = new System.Drawing.Point(546, 53);\r
-            this.drp_audbit_1.Name = "drp_audbit_1";\r
-            this.drp_audbit_1.Size = new System.Drawing.Size(70, 20);\r
-            this.drp_audbit_1.TabIndex = 11;\r
-            this.drp_audbit_1.Text = "160";\r
-            this.ToolTip.SetToolTip(this.drp_audbit_1, "Set the Audio Bit-Rate");\r
-            // \r
-            // drp_audsr_1\r
-            // \r
-            this.drp_audsr_1.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audsr_1.FormattingEnabled = true;\r
-            this.drp_audsr_1.Items.AddRange(new object[] {\r
-            "Auto",\r
-            "48",\r
-            "44.1",\r
-            "32",\r
-            "24",\r
-            "22.05"});\r
-            this.drp_audsr_1.Location = new System.Drawing.Point(488, 53);\r
-            this.drp_audsr_1.Name = "drp_audsr_1";\r
-            this.drp_audsr_1.Size = new System.Drawing.Size(55, 20);\r
-            this.drp_audsr_1.TabIndex = 9;\r
-            this.drp_audsr_1.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drp_audsr_1, "Set the Audio Sample Rate");\r
-            // \r
             // check_largeFile\r
             // \r
+            this.check_largeFile.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_largeFile.AutoSize = true;\r
             this.check_largeFile.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_largeFile.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_largeFile.Location = new System.Drawing.Point(193, 22);\r
+            this.check_largeFile.Location = new System.Drawing.Point(179, 5);\r
             this.check_largeFile.Name = "check_largeFile";\r
-            this.check_largeFile.Size = new System.Drawing.Size(105, 17);\r
+            this.check_largeFile.Size = new System.Drawing.Size(91, 17);\r
             this.check_largeFile.TabIndex = 4;\r
             this.check_largeFile.Text = "Large file size";\r
             this.ToolTip.SetToolTip(this.check_largeFile, "Caution: This option will likely break device compatibility with all but the Appl" +\r
@@ -472,10 +276,9 @@ namespace Handbrake
             this.check_turbo.AutoSize = true;\r
             this.check_turbo.BackColor = System.Drawing.Color.Transparent;\r
             this.check_turbo.Enabled = false;\r
-            this.check_turbo.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_turbo.Location = new System.Drawing.Point(37, 184);\r
+            this.check_turbo.Location = new System.Drawing.Point(146, 123);\r
             this.check_turbo.Name = "check_turbo";\r
-            this.check_turbo.Size = new System.Drawing.Size(115, 17);\r
+            this.check_turbo.Size = new System.Drawing.Size(101, 17);\r
             this.check_turbo.TabIndex = 7;\r
             this.check_turbo.Text = "Turbo first Pass";\r
             this.ToolTip.SetToolTip(this.check_turbo, "Makes the first pass of a 2 pass encode faster.");\r
@@ -483,7 +286,7 @@ namespace Handbrake
             // \r
             // drp_videoFramerate\r
             // \r
-            this.drp_videoFramerate.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.drp_videoFramerate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
             this.drp_videoFramerate.FormattingEnabled = true;\r
             this.drp_videoFramerate.Items.AddRange(new object[] {\r
             "Same as source",\r
@@ -499,63 +302,47 @@ namespace Handbrake
             this.drp_videoFramerate.Name = "drp_videoFramerate";\r
             this.drp_videoFramerate.Size = new System.Drawing.Size(126, 21);\r
             this.drp_videoFramerate.TabIndex = 2;\r
-            this.drp_videoFramerate.Text = "Same as source";\r
             this.ToolTip.SetToolTip(this.drp_videoFramerate, "Can be left to \"Same as source\" in most cases.");\r
             // \r
             // slider_videoQuality\r
             // \r
-            this.slider_videoQuality.Location = new System.Drawing.Point(468, 91);\r
+            this.slider_videoQuality.Enabled = false;\r
+            this.slider_videoQuality.Location = new System.Drawing.Point(347, 120);\r
+            this.slider_videoQuality.Margin = new System.Windows.Forms.Padding(0);\r
             this.slider_videoQuality.Maximum = 100;\r
             this.slider_videoQuality.Name = "slider_videoQuality";\r
-            this.slider_videoQuality.Size = new System.Drawing.Size(167, 42);\r
+            this.slider_videoQuality.Size = new System.Drawing.Size(322, 45);\r
             this.slider_videoQuality.TabIndex = 14;\r
             this.slider_videoQuality.TickFrequency = 17;\r
-            this.ToolTip.SetToolTip(this.slider_videoQuality, "Set the quality level of the video. (Around 70% is fine for most)");\r
-            this.slider_videoQuality.Scroll += new System.EventHandler(this.slider_videoQuality_Scroll);\r
+            this.ToolTip.SetToolTip(this.slider_videoQuality, "Set the quality level of the video. Typical sane values are between 59~63%. \r\n>70" +\r
+                    "% will likely result in the output file being larger than the input file.");\r
+            this.slider_videoQuality.ValueChanged += new System.EventHandler(this.slider_videoQuality_Scroll);\r
             // \r
             // text_filesize\r
             // \r
-            this.text_filesize.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_filesize.Location = new System.Drawing.Point(476, 36);\r
+            this.text_filesize.Enabled = false;\r
+            this.text_filesize.Location = new System.Drawing.Point(482, 36);\r
             this.text_filesize.Name = "text_filesize";\r
             this.text_filesize.Size = new System.Drawing.Size(81, 21);\r
             this.text_filesize.TabIndex = 12;\r
             this.ToolTip.SetToolTip(this.text_filesize, "Set the file size you wish the encoded file to be.");\r
-            this.text_filesize.TextChanged += new System.EventHandler(this.text_filesize_TextChanged);\r
             // \r
             // text_bitrate\r
             // \r
-            this.text_bitrate.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_bitrate.Location = new System.Drawing.Point(476, 63);\r
+            this.text_bitrate.Location = new System.Drawing.Point(482, 63);\r
             this.text_bitrate.Name = "text_bitrate";\r
             this.text_bitrate.Size = new System.Drawing.Size(81, 21);\r
             this.text_bitrate.TabIndex = 10;\r
             this.ToolTip.SetToolTip(this.text_bitrate, "Set the bitrate of the video");\r
-            this.text_bitrate.TextChanged += new System.EventHandler(this.text_bitrate_TextChanged);\r
-            // \r
-            // drp_subtitle\r
-            // \r
-            this.drp_subtitle.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_subtitle.FormattingEnabled = true;\r
-            this.drp_subtitle.Items.AddRange(new object[] {\r
-            "None",\r
-            "Autoselect"});\r
-            this.drp_subtitle.Location = new System.Drawing.Point(79, 244);\r
-            this.drp_subtitle.Name = "drp_subtitle";\r
-            this.drp_subtitle.Size = new System.Drawing.Size(138, 21);\r
-            this.drp_subtitle.TabIndex = 43;\r
-            this.drp_subtitle.Text = "None";\r
-            this.ToolTip.SetToolTip(this.drp_subtitle, resources.GetString("drp_subtitle.ToolTip"));\r
-            this.drp_subtitle.SelectedIndexChanged += new System.EventHandler(this.drp_subtitle_SelectedIndexChanged);\r
             // \r
             // btn_setDefault\r
             // \r
             this.btn_setDefault.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_setDefault.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_setDefault.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_setDefault.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_setDefault.Location = new System.Drawing.Point(108, 8);\r
+            this.btn_setDefault.Location = new System.Drawing.Point(135, 8);\r
             this.btn_setDefault.Name = "btn_setDefault";\r
-            this.btn_setDefault.Size = new System.Drawing.Size(72, 22);\r
+            this.btn_setDefault.Size = new System.Drawing.Size(101, 22);\r
             this.btn_setDefault.TabIndex = 1;\r
             this.btn_setDefault.TabStop = false;\r
             this.btn_setDefault.Text = "Set Default";\r
@@ -564,55 +351,14 @@ namespace Handbrake
             this.btn_setDefault.UseVisualStyleBackColor = true;\r
             this.btn_setDefault.Click += new System.EventHandler(this.btn_setDefault_Click);\r
             // \r
-            // drp_audmix_1\r
-            // \r
-            this.drp_audmix_1.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audmix_1.FormattingEnabled = true;\r
-            this.drp_audmix_1.Items.AddRange(new object[] {\r
-            "Automatic",\r
-            "Mono",\r
-            "Stereo",\r
-            "Dolby Surround",\r
-            "Dolby Pro Logic II",\r
-            "6 Channel Discrete"});\r
-            this.drp_audmix_1.Location = new System.Drawing.Point(353, 53);\r
-            this.drp_audmix_1.Name = "drp_audmix_1";\r
-            this.drp_audmix_1.Size = new System.Drawing.Size(129, 20);\r
-            this.drp_audmix_1.TabIndex = 7;\r
-            this.drp_audmix_1.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.drp_audmix_1, "Please note: Some options require a 5.1 audio channel to be selected");\r
-            this.drp_audmix_1.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_1_SelectedIndexChanged);\r
-            // \r
-            // text_height\r
-            // \r
-            this.text_height.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_height.ForeColor = System.Drawing.SystemColors.InfoText;\r
-            this.text_height.Location = new System.Drawing.Point(498, 81);\r
-            this.text_height.Name = "text_height";\r
-            this.text_height.Size = new System.Drawing.Size(64, 21);\r
-            this.text_height.TabIndex = 19;\r
-            this.ToolTip.SetToolTip(this.text_height, "Video Resolution (Height)\r\nCan only be altered when Anamorphic is set to \"None\"");\r
-            this.text_height.TextChanged += new System.EventHandler(this.text_height_TextChanged);\r
-            // \r
-            // text_width\r
-            // \r
-            this.text_width.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.text_width.Location = new System.Drawing.Point(407, 81);\r
-            this.text_width.Name = "text_width";\r
-            this.text_width.Size = new System.Drawing.Size(64, 21);\r
-            this.text_width.TabIndex = 17;\r
-            this.ToolTip.SetToolTip(this.text_width, "Video Resolution (Width)\r\nCan only be altered when Anamorphic is set to \"None\" or" +\r
-                    " \"Loose\"");\r
-            this.text_width.TextChanged += new System.EventHandler(this.text_width_TextChanged);\r
-            // \r
             // check_optimiseMP4\r
             // \r
+            this.check_optimiseMP4.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_optimiseMP4.AutoSize = true;\r
             this.check_optimiseMP4.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_optimiseMP4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_optimiseMP4.Location = new System.Drawing.Point(304, 22);\r
+            this.check_optimiseMP4.Location = new System.Drawing.Point(276, 5);\r
             this.check_optimiseMP4.Name = "check_optimiseMP4";\r
-            this.check_optimiseMP4.Size = new System.Drawing.Size(110, 17);\r
+            this.check_optimiseMP4.Size = new System.Drawing.Size(96, 17);\r
             this.check_optimiseMP4.TabIndex = 25;\r
             this.check_optimiseMP4.Text = "Web optimized";\r
             this.ToolTip.SetToolTip(this.check_optimiseMP4, "MP4 files can be optimized for progressive downloads over the Web,\r\nbut note that" +\r
@@ -622,12 +368,12 @@ namespace Handbrake
             // \r
             // check_iPodAtom\r
             // \r
+            this.check_iPodAtom.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_iPodAtom.AutoSize = true;\r
             this.check_iPodAtom.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_iPodAtom.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_iPodAtom.Location = new System.Drawing.Point(420, 22);\r
+            this.check_iPodAtom.Location = new System.Drawing.Point(378, 5);\r
             this.check_iPodAtom.Name = "check_iPodAtom";\r
-            this.check_iPodAtom.Size = new System.Drawing.Size(117, 17);\r
+            this.check_iPodAtom.Size = new System.Drawing.Size(102, 17);\r
             this.check_iPodAtom.TabIndex = 26;\r
             this.check_iPodAtom.Text = "iPod 5G support";\r
             this.ToolTip.SetToolTip(this.check_iPodAtom, "Support for legacy 5th Generation iPods.\r\nEncodes will not sync if this option is" +\r
@@ -643,9 +389,12 @@ namespace Handbrake
             this.data_chpt.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {\r
             this.number,\r
             this.name});\r
+            this.data_chpt.ContextMenuStrip = this.ChaptersMenu;\r
             this.data_chpt.Location = new System.Drawing.Point(16, 55);\r
+            this.data_chpt.MultiSelect = false;\r
             this.data_chpt.Name = "data_chpt";\r
-            this.data_chpt.Size = new System.Drawing.Size(661, 234);\r
+            this.data_chpt.RowHeadersVisible = false;\r
+            this.data_chpt.Size = new System.Drawing.Size(684, 236);\r
             this.data_chpt.TabIndex = 3;\r
             this.ToolTip.SetToolTip(this.data_chpt, resources.GetString("data_chpt.ToolTip"));\r
             // \r
@@ -654,25 +403,42 @@ namespace Handbrake
             dataGridViewCellStyle1.Format = "N0";\r
             dataGridViewCellStyle1.NullValue = null;\r
             this.number.DefaultCellStyle = dataGridViewCellStyle1;\r
+            this.number.Frozen = true;\r
             this.number.HeaderText = "Chapter Number";\r
             this.number.MaxInputLength = 3;\r
             this.number.Name = "number";\r
-            this.number.Width = 135;\r
+            this.number.Resizable = System.Windows.Forms.DataGridViewTriState.False;\r
+            this.number.Width = 165;\r
             // \r
             // name\r
             // \r
             this.name.HeaderText = "Chapter Name";\r
             this.name.Name = "name";\r
-            this.name.Width = 460;\r
+            this.name.Width = 480;\r
+            // \r
+            // ChaptersMenu\r
+            // \r
+            this.ChaptersMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_resetChapters});\r
+            this.ChaptersMenu.Name = "presets_menu";\r
+            this.ChaptersMenu.Size = new System.Drawing.Size(191, 26);\r
+            this.ChaptersMenu.Text = ";";\r
+            // \r
+            // mnu_resetChapters\r
+            // \r
+            this.mnu_resetChapters.Name = "mnu_resetChapters";\r
+            this.mnu_resetChapters.Size = new System.Drawing.Size(190, 22);\r
+            this.mnu_resetChapters.Text = "Reset Chapter Names";\r
+            this.mnu_resetChapters.Click += new System.EventHandler(this.mnu_resetChapters_Click);\r
             // \r
             // btn_addPreset\r
             // \r
             this.btn_addPreset.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_addPreset.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_addPreset.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_addPreset.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
             this.btn_addPreset.Location = new System.Drawing.Point(3, 8);\r
             this.btn_addPreset.Name = "btn_addPreset";\r
-            this.btn_addPreset.Size = new System.Drawing.Size(35, 22);\r
+            this.btn_addPreset.Size = new System.Drawing.Size(49, 22);\r
             this.btn_addPreset.TabIndex = 3;\r
             this.btn_addPreset.TabStop = false;\r
             this.btn_addPreset.Text = "Add";\r
@@ -683,11 +449,11 @@ namespace Handbrake
             // btn_removePreset\r
             // \r
             this.btn_removePreset.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_removePreset.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_removePreset.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_removePreset.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_removePreset.Location = new System.Drawing.Point(44, 8);\r
+            this.btn_removePreset.Location = new System.Drawing.Point(58, 8);\r
             this.btn_removePreset.Name = "btn_removePreset";\r
-            this.btn_removePreset.Size = new System.Drawing.Size(58, 22);\r
+            this.btn_removePreset.Size = new System.Drawing.Size(71, 22);\r
             this.btn_removePreset.TabIndex = 4;\r
             this.btn_removePreset.TabStop = false;\r
             this.btn_removePreset.Text = "Remove";\r
@@ -695,751 +461,66 @@ namespace Handbrake
             this.btn_removePreset.UseVisualStyleBackColor = true;\r
             this.btn_removePreset.Click += new System.EventHandler(this.btn_removePreset_Click);\r
             // \r
-            // drp_audmix_2\r
-            // \r
-            this.drp_audmix_2.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audmix_2.FormattingEnabled = true;\r
-            this.drp_audmix_2.Items.AddRange(new object[] {\r
-            "Automatic",\r
-            "Mono",\r
-            "Stereo",\r
-            "Dolby Surround",\r
-            "Dolby Pro Logic II",\r
-            "6 Channel Discrete"});\r
-            this.drp_audmix_2.Location = new System.Drawing.Point(353, 92);\r
-            this.drp_audmix_2.Name = "drp_audmix_2";\r
-            this.drp_audmix_2.Size = new System.Drawing.Size(129, 20);\r
-            this.drp_audmix_2.TabIndex = 19;\r
-            this.drp_audmix_2.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.drp_audmix_2, "Please note: Some options require a 5.1 audio channel to be selected");\r
-            this.drp_audmix_2.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_2_SelectedIndexChanged);\r
-            // \r
-            // drp_audenc_1\r
-            // \r
-            this.drp_audenc_1.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audenc_1.FormattingEnabled = true;\r
-            this.drp_audenc_1.Items.AddRange(new object[] {\r
-            "AAC",\r
-            "MP3",\r
-            "Vorbis",\r
-            "AC3"});\r
-            this.drp_audenc_1.Location = new System.Drawing.Point(236, 53);\r
-            this.drp_audenc_1.Name = "drp_audenc_1";\r
-            this.drp_audenc_1.Size = new System.Drawing.Size(111, 20);\r
-            this.drp_audenc_1.TabIndex = 5;\r
-            this.drp_audenc_1.Text = "AAC";\r
-            this.ToolTip.SetToolTip(this.drp_audenc_1, "Select an audio encoder.");\r
-            this.drp_audenc_1.SelectedIndexChanged += new System.EventHandler(this.drp_audenc_1_SelectedIndexChanged);\r
-            // \r
-            // drp_audenc_2\r
-            // \r
-            this.drp_audenc_2.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audenc_2.FormattingEnabled = true;\r
-            this.drp_audenc_2.Items.AddRange(new object[] {\r
-            "AAC",\r
-            "MP3",\r
-            "Vorbis",\r
-            "AC3"});\r
-            this.drp_audenc_2.Location = new System.Drawing.Point(236, 92);\r
-            this.drp_audenc_2.Name = "drp_audenc_2";\r
-            this.drp_audenc_2.Size = new System.Drawing.Size(111, 20);\r
-            this.drp_audenc_2.TabIndex = 18;\r
-            this.drp_audenc_2.Text = "AAC";\r
-            this.ToolTip.SetToolTip(this.drp_audenc_2, "Select an audio encoder.");\r
-            this.drp_audenc_2.SelectedIndexChanged += new System.EventHandler(this.drp_audenc_2_SelectedIndexChanged);\r
-            // \r
-            // drp_audbit_2\r
-            // \r
-            this.drp_audbit_2.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audbit_2.FormattingEnabled = true;\r
-            this.drp_audbit_2.Items.AddRange(new object[] {\r
-            "32",\r
-            "40",\r
-            "48",\r
-            "56",\r
-            "64",\r
-            "80",\r
-            "86",\r
-            "112",\r
-            "128",\r
-            "160"});\r
-            this.drp_audbit_2.Location = new System.Drawing.Point(546, 92);\r
-            this.drp_audbit_2.Name = "drp_audbit_2";\r
-            this.drp_audbit_2.Size = new System.Drawing.Size(71, 20);\r
-            this.drp_audbit_2.TabIndex = 21;\r
-            this.drp_audbit_2.Text = "160";\r
-            this.ToolTip.SetToolTip(this.drp_audbit_2, "Set the Audio Bit-Rate");\r
-            // \r
-            // drp_audsr_2\r
-            // \r
-            this.drp_audsr_2.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audsr_2.FormattingEnabled = true;\r
-            this.drp_audsr_2.Items.AddRange(new object[] {\r
-            "Auto",\r
-            "48",\r
-            "44.1",\r
-            "32",\r
-            "24",\r
-            "22.05"});\r
-            this.drp_audsr_2.Location = new System.Drawing.Point(488, 92);\r
-            this.drp_audsr_2.Name = "drp_audsr_2";\r
-            this.drp_audsr_2.Size = new System.Drawing.Size(52, 20);\r
-            this.drp_audsr_2.TabIndex = 20;\r
-            this.drp_audsr_2.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drp_audsr_2, "Set the Audio Sample Rate");\r
-            // \r
-            // drp_audsr_3\r
-            // \r
-            this.drp_audsr_3.Enabled = false;\r
-            this.drp_audsr_3.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audsr_3.FormattingEnabled = true;\r
-            this.drp_audsr_3.Items.AddRange(new object[] {\r
-            "Auto",\r
-            "48",\r
-            "44.1",\r
-            "32",\r
-            "24",\r
-            "22.05"});\r
-            this.drp_audsr_3.Location = new System.Drawing.Point(488, 133);\r
-            this.drp_audsr_3.Name = "drp_audsr_3";\r
-            this.drp_audsr_3.Size = new System.Drawing.Size(52, 20);\r
-            this.drp_audsr_3.TabIndex = 28;\r
-            this.drp_audsr_3.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drp_audsr_3, "Set the Audio Sample Rate");\r
-            // \r
-            // drp_audbit_3\r
-            // \r
-            this.drp_audbit_3.Enabled = false;\r
-            this.drp_audbit_3.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audbit_3.FormattingEnabled = true;\r
-            this.drp_audbit_3.Items.AddRange(new object[] {\r
-            "32",\r
-            "40",\r
-            "48",\r
-            "56",\r
-            "64",\r
-            "80",\r
-            "86",\r
-            "112",\r
-            "128",\r
-            "160"});\r
-            this.drp_audbit_3.Location = new System.Drawing.Point(546, 133);\r
-            this.drp_audbit_3.Name = "drp_audbit_3";\r
-            this.drp_audbit_3.Size = new System.Drawing.Size(71, 20);\r
-            this.drp_audbit_3.TabIndex = 29;\r
-            this.drp_audbit_3.Text = "160";\r
-            this.ToolTip.SetToolTip(this.drp_audbit_3, "Set the Audio Bit-Rate");\r
-            // \r
-            // drp_audenc_3\r
-            // \r
-            this.drp_audenc_3.Enabled = false;\r
-            this.drp_audenc_3.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audenc_3.FormattingEnabled = true;\r
-            this.drp_audenc_3.Items.AddRange(new object[] {\r
-            "AAC",\r
-            "MP3",\r
-            "Vorbis",\r
-            "AC3"});\r
-            this.drp_audenc_3.Location = new System.Drawing.Point(236, 133);\r
-            this.drp_audenc_3.Name = "drp_audenc_3";\r
-            this.drp_audenc_3.Size = new System.Drawing.Size(111, 20);\r
-            this.drp_audenc_3.TabIndex = 26;\r
-            this.drp_audenc_3.Text = "AAC";\r
-            this.ToolTip.SetToolTip(this.drp_audenc_3, "Select an audio encoder.");\r
-            this.drp_audenc_3.SelectedIndexChanged += new System.EventHandler(this.drp_audenc_3_SelectedIndexChanged);\r
-            // \r
-            // drp_audmix_3\r
-            // \r
-            this.drp_audmix_3.Enabled = false;\r
-            this.drp_audmix_3.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audmix_3.FormattingEnabled = true;\r
-            this.drp_audmix_3.Items.AddRange(new object[] {\r
-            "Automatic",\r
-            "Mono",\r
-            "Stereo",\r
-            "Dolby Surround",\r
-            "Dolby Pro Logic II",\r
-            "6 Channel Discrete"});\r
-            this.drp_audmix_3.Location = new System.Drawing.Point(353, 133);\r
-            this.drp_audmix_3.Name = "drp_audmix_3";\r
-            this.drp_audmix_3.Size = new System.Drawing.Size(129, 20);\r
-            this.drp_audmix_3.TabIndex = 27;\r
-            this.drp_audmix_3.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.drp_audmix_3, "Please note: Some options require a 5.1 audio channel to be selected");\r
-            this.drp_audmix_3.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_3_SelectedIndexChanged);\r
-            // \r
-            // drp_audsr_4\r
-            // \r
-            this.drp_audsr_4.Enabled = false;\r
-            this.drp_audsr_4.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audsr_4.FormattingEnabled = true;\r
-            this.drp_audsr_4.Items.AddRange(new object[] {\r
-            "Auto",\r
-            "48",\r
-            "44.1",\r
-            "32",\r
-            "24",\r
-            "22.05"});\r
-            this.drp_audsr_4.Location = new System.Drawing.Point(488, 175);\r
-            this.drp_audsr_4.Name = "drp_audsr_4";\r
-            this.drp_audsr_4.Size = new System.Drawing.Size(52, 20);\r
-            this.drp_audsr_4.TabIndex = 36;\r
-            this.drp_audsr_4.Text = "Auto";\r
-            this.ToolTip.SetToolTip(this.drp_audsr_4, "Set the Audio Sample Rate");\r
-            // \r
-            // drp_audbit_4\r
-            // \r
-            this.drp_audbit_4.Enabled = false;\r
-            this.drp_audbit_4.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audbit_4.FormattingEnabled = true;\r
-            this.drp_audbit_4.Items.AddRange(new object[] {\r
-            "32",\r
-            "40",\r
-            "48",\r
-            "56",\r
-            "64",\r
-            "80",\r
-            "86",\r
-            "112",\r
-            "128",\r
-            "160"});\r
-            this.drp_audbit_4.Location = new System.Drawing.Point(546, 175);\r
-            this.drp_audbit_4.Name = "drp_audbit_4";\r
-            this.drp_audbit_4.Size = new System.Drawing.Size(70, 20);\r
-            this.drp_audbit_4.TabIndex = 37;\r
-            this.drp_audbit_4.Text = "160";\r
-            this.ToolTip.SetToolTip(this.drp_audbit_4, "Set the Audio Bit-Rate");\r
-            // \r
-            // drp_audenc_4\r
-            // \r
-            this.drp_audenc_4.Enabled = false;\r
-            this.drp_audenc_4.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audenc_4.FormattingEnabled = true;\r
-            this.drp_audenc_4.Items.AddRange(new object[] {\r
-            "AAC",\r
-            "MP3",\r
-            "Vorbis",\r
-            "AC3"});\r
-            this.drp_audenc_4.Location = new System.Drawing.Point(236, 175);\r
-            this.drp_audenc_4.Name = "drp_audenc_4";\r
-            this.drp_audenc_4.Size = new System.Drawing.Size(111, 20);\r
-            this.drp_audenc_4.TabIndex = 34;\r
-            this.drp_audenc_4.Text = "AAC";\r
-            this.ToolTip.SetToolTip(this.drp_audenc_4, "Select an audio encoder.");\r
-            this.drp_audenc_4.SelectedIndexChanged += new System.EventHandler(this.drp_audenc_4_SelectedIndexChanged);\r
-            // \r
-            // drp_audmix_4\r
-            // \r
-            this.drp_audmix_4.Enabled = false;\r
-            this.drp_audmix_4.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_audmix_4.FormattingEnabled = true;\r
-            this.drp_audmix_4.Items.AddRange(new object[] {\r
-            "Automatic",\r
-            "Mono",\r
-            "Stereo",\r
-            "Dolby Surround",\r
-            "Dolby Pro Logic II",\r
-            "6 Channel Discrete"});\r
-            this.drp_audmix_4.Location = new System.Drawing.Point(353, 175);\r
-            this.drp_audmix_4.Name = "drp_audmix_4";\r
-            this.drp_audmix_4.Size = new System.Drawing.Size(129, 20);\r
-            this.drp_audmix_4.TabIndex = 35;\r
-            this.drp_audmix_4.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.drp_audmix_4, "Please note: Some options require a 5.1 audio channel to be selected");\r
-            this.drp_audmix_4.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_4_SelectedIndexChanged);\r
-            // \r
             // drop_format\r
             // \r
             this.drop_format.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_format.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drop_format.FormattingEnabled = true;\r
             this.drop_format.Items.AddRange(new object[] {\r
             "MP4 File",\r
-            "M4V File",\r
-            "MKV File",\r
-            "AVI File",\r
-            "OGM File"});\r
-            this.drop_format.Location = new System.Drawing.Point(75, 19);\r
+            "MKV File"});\r
+            this.drop_format.Location = new System.Drawing.Point(67, 3);\r
             this.drop_format.Name = "drop_format";\r
             this.drop_format.Size = new System.Drawing.Size(106, 21);\r
             this.drop_format.TabIndex = 28;\r
             this.ToolTip.SetToolTip(this.drop_format, "Select the file container format.");\r
             this.drop_format.SelectedIndexChanged += new System.EventHandler(this.drop_format_SelectedIndexChanged);\r
             // \r
-            // check_customCrop\r
-            // \r
-            this.check_customCrop.AutoSize = true;\r
-            this.check_customCrop.Location = new System.Drawing.Point(16, 58);\r
-            this.check_customCrop.Name = "check_customCrop";\r
-            this.check_customCrop.Size = new System.Drawing.Size(74, 17);\r
-            this.check_customCrop.TabIndex = 34;\r
-            this.check_customCrop.Text = "Custom:";\r
-            this.ToolTip.SetToolTip(this.check_customCrop, "Set some custom cropping values.");\r
-            this.check_customCrop.UseVisualStyleBackColor = true;\r
-            this.check_customCrop.CheckedChanged += new System.EventHandler(this.check_customCrop_CheckedChanged);\r
-            // \r
-            // check_autoCrop\r
-            // \r
-            this.check_autoCrop.AutoSize = true;\r
-            this.check_autoCrop.Checked = true;\r
-            this.check_autoCrop.Location = new System.Drawing.Point(16, 34);\r
-            this.check_autoCrop.Name = "check_autoCrop";\r
-            this.check_autoCrop.Size = new System.Drawing.Size(82, 17);\r
-            this.check_autoCrop.TabIndex = 33;\r
-            this.check_autoCrop.TabStop = true;\r
-            this.check_autoCrop.Text = "Automatic";\r
-            this.ToolTip.SetToolTip(this.check_autoCrop, "Automatically set cropping values.");\r
-            this.check_autoCrop.UseVisualStyleBackColor = true;\r
-            this.check_autoCrop.CheckedChanged += new System.EventHandler(this.check_autoCrop_CheckedChanged);\r
-            // \r
-            // check_Cabac\r
-            // \r
-            this.check_Cabac.AutoSize = true;\r
-            this.check_Cabac.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_Cabac.Checked = true;\r
-            this.check_Cabac.CheckState = System.Windows.Forms.CheckState.Checked;\r
-            this.check_Cabac.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_Cabac.Location = new System.Drawing.Point(536, 214);\r
-            this.check_Cabac.Name = "check_Cabac";\r
-            this.check_Cabac.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_Cabac.Size = new System.Drawing.Size(144, 16);\r
-            this.check_Cabac.TabIndex = 40;\r
-            this.check_Cabac.Text = "CABAC Entropy Coding:";\r
-            this.check_Cabac.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_Cabac, resources.GetString("check_Cabac.ToolTip"));\r
-            this.check_Cabac.UseVisualStyleBackColor = true;\r
-            this.check_Cabac.CheckStateChanged += new System.EventHandler(this.check_Cabac_CheckedChanged);\r
-            // \r
-            // check_noDCTDecimate\r
-            // \r
-            this.check_noDCTDecimate.AutoSize = true;\r
-            this.check_noDCTDecimate.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_noDCTDecimate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_noDCTDecimate.Location = new System.Drawing.Point(562, 192);\r
-            this.check_noDCTDecimate.Name = "check_noDCTDecimate";\r
-            this.check_noDCTDecimate.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_noDCTDecimate.Size = new System.Drawing.Size(118, 16);\r
-            this.check_noDCTDecimate.TabIndex = 39;\r
-            this.check_noDCTDecimate.Text = "No DCT-Decimate:";\r
-            this.check_noDCTDecimate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_noDCTDecimate, "Only use this with constant quality encoding. \r\nIt increases quality but also bit" +\r
-                    "rate/file size.");\r
-            this.check_noDCTDecimate.UseVisualStyleBackColor = true;\r
-            this.check_noDCTDecimate.CheckStateChanged += new System.EventHandler(this.check_noDCTDecimate_CheckedChanged);\r
-            // \r
-            // check_noFastPSkip\r
-            // \r
-            this.check_noFastPSkip.AutoSize = true;\r
-            this.check_noFastPSkip.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_noFastPSkip.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_noFastPSkip.Location = new System.Drawing.Point(444, 192);\r
-            this.check_noFastPSkip.Name = "check_noFastPSkip";\r
-            this.check_noFastPSkip.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_noFastPSkip.Size = new System.Drawing.Size(103, 16);\r
-            this.check_noFastPSkip.TabIndex = 38;\r
-            this.check_noFastPSkip.Text = "No Fast-P-Skip:";\r
-            this.check_noFastPSkip.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_noFastPSkip, "This can help with blocking on solid colors like blue skies, \r\nbut it also slows " +\r
-                    "down the encode.");\r
-            this.check_noFastPSkip.UseVisualStyleBackColor = true;\r
-            this.check_noFastPSkip.CheckStateChanged += new System.EventHandler(this.check_noFastPSkip_CheckedChanged);\r
-            // \r
-            // drop_trellis\r
-            // \r
-            this.drop_trellis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_trellis.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_trellis.FormattingEnabled = true;\r
-            this.drop_trellis.Items.AddRange(new object[] {\r
-            "Default (0)",\r
-            "0",\r
-            "1",\r
-            "2"});\r
-            this.drop_trellis.Location = new System.Drawing.Point(537, 166);\r
-            this.drop_trellis.Name = "drop_trellis";\r
-            this.drop_trellis.Size = new System.Drawing.Size(143, 20);\r
-            this.drop_trellis.TabIndex = 37;\r
-            this.ToolTip.SetToolTip(this.drop_trellis, "Trellis fine-tunes how bitrate is doled out, so it can reduce file size/bitrate o" +\r
-                    "r increase quality. \r\nA value of 2 forces it to be used more often than a value " +\r
-                    "of 1.");\r
-            this.drop_trellis.SelectedIndexChanged += new System.EventHandler(this.drop_trellis_SelectedIndexChanged);\r
-            // \r
-            // drop_deblockBeta\r
-            // \r
-            this.drop_deblockBeta.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_deblockBeta.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_deblockBeta.FormattingEnabled = true;\r
-            this.drop_deblockBeta.Items.AddRange(new object[] {\r
-            "Default (0)",\r
-            "-6",\r
-            "-5",\r
-            "-4",\r
-            "-3",\r
-            "-2",\r
-            "-1",\r
-            "0",\r
-            "1",\r
-            "2",\r
-            "3",\r
-            "4",\r
-            "5",\r
-            "6"});\r
-            this.drop_deblockBeta.Location = new System.Drawing.Point(611, 139);\r
-            this.drop_deblockBeta.Name = "drop_deblockBeta";\r
-            this.drop_deblockBeta.Size = new System.Drawing.Size(69, 20);\r
-            this.drop_deblockBeta.TabIndex = 36;\r
-            this.ToolTip.SetToolTip(this.drop_deblockBeta, resources.GetString("drop_deblockBeta.ToolTip"));\r
-            this.drop_deblockBeta.SelectedIndexChanged += new System.EventHandler(this.drop_deblockBeta_SelectedIndexChanged);\r
-            // \r
-            // drop_deblockAlpha\r
-            // \r
-            this.drop_deblockAlpha.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_deblockAlpha.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_deblockAlpha.FormattingEnabled = true;\r
-            this.drop_deblockAlpha.Items.AddRange(new object[] {\r
-            "Default (0)",\r
-            "-6",\r
-            "-5",\r
-            "-4",\r
-            "-3",\r
-            "-2",\r
-            "-1",\r
-            "0",\r
-            "1",\r
-            "2",\r
-            "3",\r
-            "4",\r
-            "5",\r
-            "6"});\r
-            this.drop_deblockAlpha.Location = new System.Drawing.Point(537, 139);\r
-            this.drop_deblockAlpha.Name = "drop_deblockAlpha";\r
-            this.drop_deblockAlpha.Size = new System.Drawing.Size(68, 20);\r
-            this.drop_deblockAlpha.TabIndex = 35;\r
-            this.ToolTip.SetToolTip(this.drop_deblockAlpha, resources.GetString("drop_deblockAlpha.ToolTip"));\r
-            this.drop_deblockAlpha.SelectedIndexChanged += new System.EventHandler(this.drop_deblockAlpha_SelectedIndexChanged);\r
-            // \r
-            // check_8x8DCT\r
-            // \r
-            this.check_8x8DCT.AutoSize = true;\r
-            this.check_8x8DCT.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_8x8DCT.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_8x8DCT.Location = new System.Drawing.Point(608, 106);\r
-            this.check_8x8DCT.Name = "check_8x8DCT";\r
-            this.check_8x8DCT.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_8x8DCT.Size = new System.Drawing.Size(71, 16);\r
-            this.check_8x8DCT.TabIndex = 34;\r
-            this.check_8x8DCT.Text = "8x8 DCT:";\r
-            this.check_8x8DCT.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_8x8DCT, resources.GetString("check_8x8DCT.ToolTip"));\r
-            this.check_8x8DCT.UseVisualStyleBackColor = true;\r
-            this.check_8x8DCT.CheckStateChanged += new System.EventHandler(this.check_8x8DCT_CheckedChanged);\r
-            // \r
-            // drop_analysis\r
-            // \r
-            this.drop_analysis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_analysis.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_analysis.FormattingEnabled = true;\r
-            this.drop_analysis.Items.AddRange(new object[] {\r
-            "Default (some)",\r
-            "None",\r
-            "All"});\r
-            this.drop_analysis.Location = new System.Drawing.Point(537, 105);\r
-            this.drop_analysis.Name = "drop_analysis";\r
-            this.drop_analysis.Size = new System.Drawing.Size(63, 20);\r
-            this.drop_analysis.TabIndex = 33;\r
-            this.ToolTip.SetToolTip(this.drop_analysis, resources.GetString("drop_analysis.ToolTip"));\r
-            this.drop_analysis.SelectedIndexChanged += new System.EventHandler(this.drop_analysis_SelectedIndexChanged);\r
-            // \r
-            // drop_subpixelMotionEstimation\r
-            // \r
-            this.drop_subpixelMotionEstimation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_subpixelMotionEstimation.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_subpixelMotionEstimation.FormattingEnabled = true;\r
-            this.drop_subpixelMotionEstimation.Items.AddRange(new object[] {\r
-            "Default (6)",\r
-            "0",\r
-            "1",\r
-            "2",\r
-            "3",\r
-            "4",\r
-            "5",\r
-            "6",\r
-            "7",\r
-            "8",\r
-            "9"});\r
-            this.drop_subpixelMotionEstimation.Location = new System.Drawing.Point(537, 69);\r
-            this.drop_subpixelMotionEstimation.Name = "drop_subpixelMotionEstimation";\r
-            this.drop_subpixelMotionEstimation.Size = new System.Drawing.Size(139, 20);\r
-            this.drop_subpixelMotionEstimation.TabIndex = 32;\r
-            this.ToolTip.SetToolTip(this.drop_subpixelMotionEstimation, resources.GetString("drop_subpixelMotionEstimation.ToolTip"));\r
-            this.drop_subpixelMotionEstimation.SelectedIndexChanged += new System.EventHandler(this.drop_subpixelMotionEstimation_SelectedIndexChanged);\r
-            // \r
-            // drop_MotionEstimationRange\r
-            // \r
-            this.drop_MotionEstimationRange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_MotionEstimationRange.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_MotionEstimationRange.FormattingEnabled = true;\r
-            this.drop_MotionEstimationRange.Items.AddRange(new object[] {\r
-            "Default (16)",\r
-            "4",\r
-            "5",\r
-            "6",\r
-            "7",\r
-            "8",\r
-            "9",\r
-            "10",\r
-            "11",\r
-            "12",\r
-            "13",\r
-            "14",\r
-            "15",\r
-            "16",\r
-            "17",\r
-            "18",\r
-            "19",\r
-            "20",\r
-            "21",\r
-            "22",\r
-            "23",\r
-            "24",\r
-            "25",\r
-            "26",\r
-            "27",\r
-            "28",\r
-            "29",\r
-            "30",\r
-            "31",\r
-            "32",\r
-            "33",\r
-            "34",\r
-            "35",\r
-            "36",\r
-            "37",\r
-            "38",\r
-            "39",\r
-            "40",\r
-            "41",\r
-            "42",\r
-            "43",\r
-            "44",\r
-            "45",\r
-            "46",\r
-            "47",\r
-            "48",\r
-            "49",\r
-            "50",\r
-            "51",\r
-            "52",\r
-            "53",\r
-            "54",\r
-            "55",\r
-            "56",\r
-            "57",\r
-            "58",\r
-            "59",\r
-            "60",\r
-            "61",\r
-            "62",\r
-            "63",\r
-            "64"});\r
-            this.drop_MotionEstimationRange.Location = new System.Drawing.Point(537, 40);\r
-            this.drop_MotionEstimationRange.Name = "drop_MotionEstimationRange";\r
-            this.drop_MotionEstimationRange.Size = new System.Drawing.Size(139, 20);\r
-            this.drop_MotionEstimationRange.TabIndex = 31;\r
-            this.ToolTip.SetToolTip(this.drop_MotionEstimationRange, resources.GetString("drop_MotionEstimationRange.ToolTip"));\r
-            this.drop_MotionEstimationRange.SelectedIndexChanged += new System.EventHandler(this.drop_MotionEstimationRange_SelectedIndexChanged);\r
-            // \r
-            // drop_MotionEstimationMethod\r
-            // \r
-            this.drop_MotionEstimationMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_MotionEstimationMethod.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_MotionEstimationMethod.FormattingEnabled = true;\r
-            this.drop_MotionEstimationMethod.ItemHeight = 12;\r
-            this.drop_MotionEstimationMethod.Items.AddRange(new object[] {\r
-            "Default (Hexagon)",\r
-            "Diamond",\r
-            "Hexagon",\r
-            "Uneven Multi-Hexagon",\r
-            "Exhaustive"});\r
-            this.drop_MotionEstimationMethod.Location = new System.Drawing.Point(537, 11);\r
-            this.drop_MotionEstimationMethod.Name = "drop_MotionEstimationMethod";\r
-            this.drop_MotionEstimationMethod.Size = new System.Drawing.Size(139, 20);\r
-            this.drop_MotionEstimationMethod.TabIndex = 30;\r
-            this.ToolTip.SetToolTip(this.drop_MotionEstimationMethod, resources.GetString("drop_MotionEstimationMethod.ToolTip"));\r
-            this.drop_MotionEstimationMethod.SelectedIndexChanged += new System.EventHandler(this.drop_MotionEstimationMethod_SelectedIndexChanged);\r
-            // \r
-            // check_pyrmidalBFrames\r
-            // \r
-            this.check_pyrmidalBFrames.AutoSize = true;\r
-            this.check_pyrmidalBFrames.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_pyrmidalBFrames.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_pyrmidalBFrames.Location = new System.Drawing.Point(46, 165);\r
-            this.check_pyrmidalBFrames.Name = "check_pyrmidalBFrames";\r
-            this.check_pyrmidalBFrames.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_pyrmidalBFrames.Size = new System.Drawing.Size(121, 16);\r
-            this.check_pyrmidalBFrames.TabIndex = 17;\r
-            this.check_pyrmidalBFrames.Text = "Pyrmidal B-Frames:";\r
-            this.check_pyrmidalBFrames.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_pyrmidalBFrames, resources.GetString("check_pyrmidalBFrames.ToolTip"));\r
-            this.check_pyrmidalBFrames.UseVisualStyleBackColor = true;\r
-            this.check_pyrmidalBFrames.CheckStateChanged += new System.EventHandler(this.check_pyrmidalBFrames_CheckedChanged);\r
-            // \r
-            // check_weightedBFrames\r
-            // \r
-            this.check_weightedBFrames.AutoSize = true;\r
-            this.check_weightedBFrames.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_weightedBFrames.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_weightedBFrames.Location = new System.Drawing.Point(44, 144);\r
-            this.check_weightedBFrames.Name = "check_weightedBFrames";\r
-            this.check_weightedBFrames.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_weightedBFrames.Size = new System.Drawing.Size(123, 16);\r
-            this.check_weightedBFrames.TabIndex = 14;\r
-            this.check_weightedBFrames.Text = "Weighted B-Frames:";\r
-            this.ToolTip.SetToolTip(this.check_weightedBFrames, resources.GetString("check_weightedBFrames.ToolTip"));\r
-            this.check_weightedBFrames.UseVisualStyleBackColor = true;\r
-            this.check_weightedBFrames.CheckStateChanged += new System.EventHandler(this.check_weightedBFrames_CheckedChanged);\r
-            // \r
-            // drop_directPrediction\r
-            // \r
-            this.drop_directPrediction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_directPrediction.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_directPrediction.FormattingEnabled = true;\r
-            this.drop_directPrediction.Items.AddRange(new object[] {\r
-            "Default (Spatial)",\r
-            "None",\r
-            "Spatial",\r
-            "Temporal",\r
-            "Automatic"});\r
-            this.drop_directPrediction.Location = new System.Drawing.Point(157, 118);\r
-            this.drop_directPrediction.Name = "drop_directPrediction";\r
-            this.drop_directPrediction.Size = new System.Drawing.Size(121, 20);\r
-            this.drop_directPrediction.TabIndex = 13;\r
-            this.ToolTip.SetToolTip(this.drop_directPrediction, resources.GetString("drop_directPrediction.ToolTip"));\r
-            this.drop_directPrediction.SelectedIndexChanged += new System.EventHandler(this.drop_directPrediction_SelectedIndexChanged);\r
-            // \r
-            // drop_bFrames\r
-            // \r
-            this.drop_bFrames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_bFrames.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_bFrames.FormattingEnabled = true;\r
-            this.drop_bFrames.Items.AddRange(new object[] {\r
-            "Default (0)",\r
-            "0",\r
-            "1",\r
-            "2",\r
-            "3",\r
-            "4",\r
-            "5",\r
-            "6",\r
-            "7",\r
-            "8",\r
-            "9",\r
-            "10",\r
-            "11",\r
-            "12",\r
-            "13",\r
-            "14",\r
-            "15",\r
-            "16"});\r
-            this.drop_bFrames.Location = new System.Drawing.Point(157, 91);\r
-            this.drop_bFrames.Name = "drop_bFrames";\r
-            this.drop_bFrames.Size = new System.Drawing.Size(121, 20);\r
-            this.drop_bFrames.TabIndex = 12;\r
-            this.ToolTip.SetToolTip(this.drop_bFrames, "Sane values are 1-6. \r\nB-Frames are smaller than other frames, so they let you pa" +\r
-                    "ck in more quality at the same bitrate. \r\nUse more of them with animated materia" +\r
-                    "l: 9-16. ");\r
-            this.drop_bFrames.SelectedIndexChanged += new System.EventHandler(this.drop_bFrames_SelectedIndexChanged);\r
-            // \r
-            // drop_refFrames\r
-            // \r
-            this.drop_refFrames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drop_refFrames.FlatStyle = System.Windows.Forms.FlatStyle.Popup;\r
-            this.drop_refFrames.FormattingEnabled = true;\r
-            this.drop_refFrames.Items.AddRange(new object[] {\r
-            "Default (1)",\r
-            "0",\r
-            "1",\r
-            "2",\r
-            "3",\r
-            "4",\r
-            "5",\r
-            "6",\r
-            "7",\r
-            "8",\r
-            "9",\r
-            "10",\r
-            "11",\r
-            "12",\r
-            "13",\r
-            "14",\r
-            "15",\r
-            "16"});\r
-            this.drop_refFrames.Location = new System.Drawing.Point(157, 37);\r
-            this.drop_refFrames.Name = "drop_refFrames";\r
-            this.drop_refFrames.Size = new System.Drawing.Size(121, 20);\r
-            this.drop_refFrames.TabIndex = 10;\r
-            this.ToolTip.SetToolTip(this.drop_refFrames, "Sane values are 1-6. The more you add, the higher the quality \97 but the slower th" +\r
-                    "e encode. ");\r
-            this.drop_refFrames.SelectedIndexChanged += new System.EventHandler(this.drop_refFrames_SelectedIndexChanged);\r
-            // \r
-            // check_mixedReferences\r
-            // \r
-            this.check_mixedReferences.AutoSize = true;\r
-            this.check_mixedReferences.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.check_mixedReferences.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
-            this.check_mixedReferences.Location = new System.Drawing.Point(54, 63);\r
-            this.check_mixedReferences.Name = "check_mixedReferences";\r
-            this.check_mixedReferences.RightToLeft = System.Windows.Forms.RightToLeft.No;\r
-            this.check_mixedReferences.Size = new System.Drawing.Size(114, 16);\r
-            this.check_mixedReferences.TabIndex = 11;\r
-            this.check_mixedReferences.Text = "Mixed References:";\r
-            this.check_mixedReferences.TextAlign = System.Drawing.ContentAlignment.MiddleRight;\r
-            this.ToolTip.SetToolTip(this.check_mixedReferences, "With this on, different parts of a frame will refer back to different prior frame" +\r
-                    "s, \r\ndepending on what\'s best for that part of the image. ");\r
-            this.check_mixedReferences.UseVisualStyleBackColor = true;\r
-            this.check_mixedReferences.CheckStateChanged += new System.EventHandler(this.check_mixedReferences_CheckedChanged);\r
-            // \r
-            // lbl_src_res\r
-            // \r
-            this.lbl_src_res.AutoSize = true;\r
-            this.lbl_src_res.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_src_res.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_src_res.Location = new System.Drawing.Point(405, 34);\r
-            this.lbl_src_res.Name = "lbl_src_res";\r
-            this.lbl_src_res.Size = new System.Drawing.Size(72, 12);\r
-            this.lbl_src_res.TabIndex = 13;\r
-            this.lbl_src_res.Text = "Select a Title";\r
+            // drop_chapterFinish\r
             // \r
-            // lbl_duration\r
+            this.drop_chapterFinish.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_chapterFinish.FormattingEnabled = true;\r
+            this.drop_chapterFinish.Location = new System.Drawing.Point(447, 3);\r
+            this.drop_chapterFinish.Name = "drop_chapterFinish";\r
+            this.drop_chapterFinish.Size = new System.Drawing.Size(69, 21);\r
+            this.drop_chapterFinish.TabIndex = 10;\r
+            this.ToolTip.SetToolTip(this.drop_chapterFinish, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
+            this.drop_chapterFinish.SelectedIndexChanged += new System.EventHandler(this.chapersChanged);\r
             // \r
-            this.lbl_duration.AutoSize = true;\r
-            this.lbl_duration.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_duration.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_duration.Location = new System.Drawing.Point(569, 56);\r
-            this.lbl_duration.Name = "lbl_duration";\r
-            this.lbl_duration.Size = new System.Drawing.Size(72, 12);\r
-            this.lbl_duration.TabIndex = 43;\r
-            this.lbl_duration.Text = "Select a Title";\r
+            // drop_chapterStart\r
             // \r
-            // label_duration\r
+            this.drop_chapterStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_chapterStart.FormattingEnabled = true;\r
+            this.drop_chapterStart.Location = new System.Drawing.Point(321, 3);\r
+            this.drop_chapterStart.Name = "drop_chapterStart";\r
+            this.drop_chapterStart.Size = new System.Drawing.Size(69, 21);\r
+            this.drop_chapterStart.TabIndex = 9;\r
+            this.ToolTip.SetToolTip(this.drop_chapterStart, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
+            this.drop_chapterStart.SelectedIndexChanged += new System.EventHandler(this.chapersChanged);\r
             // \r
-            this.label_duration.AutoSize = true;\r
-            this.label_duration.BackColor = System.Drawing.Color.Transparent;\r
-            this.label_duration.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label_duration.Location = new System.Drawing.Point(502, 55);\r
-            this.label_duration.Name = "label_duration";\r
-            this.label_duration.Size = new System.Drawing.Size(61, 13);\r
-            this.label_duration.TabIndex = 42;\r
-            this.label_duration.Text = "Duration:";\r
+            // drop_angle\r
             // \r
-            // label7\r
+            this.drop_angle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_angle.FormattingEnabled = true;\r
+            this.drop_angle.Location = new System.Drawing.Point(209, 3);\r
+            this.drop_angle.Name = "drop_angle";\r
+            this.drop_angle.Size = new System.Drawing.Size(45, 21);\r
+            this.drop_angle.TabIndex = 45;\r
+            this.ToolTip.SetToolTip(this.drop_angle, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
             // \r
-            this.label7.AutoSize = true;\r
-            this.label7.BackColor = System.Drawing.Color.Transparent;\r
-            this.label7.Location = new System.Drawing.Point(311, 34);\r
-            this.label7.Name = "label7";\r
-            this.label7.Size = new System.Drawing.Size(52, 13);\r
-            this.label7.TabIndex = 12;\r
-            this.label7.Text = "Source:";\r
+            // drp_dvdtitle\r
+            // \r
+            this.drp_dvdtitle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drp_dvdtitle.FormattingEnabled = true;\r
+            this.drp_dvdtitle.Items.AddRange(new object[] {\r
+            "Automatic"});\r
+            this.drp_dvdtitle.Location = new System.Drawing.Point(40, 3);\r
+            this.drp_dvdtitle.Name = "drp_dvdtitle";\r
+            this.drp_dvdtitle.Size = new System.Drawing.Size(119, 21);\r
+            this.drp_dvdtitle.TabIndex = 7;\r
+            this.ToolTip.SetToolTip(this.drp_dvdtitle, "Select the title you wish to encode.\r\nThe longest title is selected by default af" +\r
+                    "ter you have scanned a source.");\r
+            this.drp_dvdtitle.SelectedIndexChanged += new System.EventHandler(this.drp_dvdtitle_SelectedIndexChanged);\r
+            this.drp_dvdtitle.Click += new System.EventHandler(this.drp_dvdtitle_Click);\r
             // \r
             // DVD_Open\r
             // \r
@@ -1460,15 +541,24 @@ namespace Handbrake
             // FileToolStripMenuItem\r
             // \r
             this.FileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_killCLI,\r
             this.mnu_exit});\r
             this.FileToolStripMenuItem.Name = "FileToolStripMenuItem";\r
-            this.FileToolStripMenuItem.Size = new System.Drawing.Size(38, 20);\r
+            this.FileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);\r
             this.FileToolStripMenuItem.Text = "&File";\r
             // \r
+            // mnu_killCLI\r
+            // \r
+            this.mnu_killCLI.Name = "mnu_killCLI";\r
+            this.mnu_killCLI.Size = new System.Drawing.Size(143, 22);\r
+            this.mnu_killCLI.Text = "Cancel Scan";\r
+            this.mnu_killCLI.Visible = false;\r
+            this.mnu_killCLI.Click += new System.EventHandler(this.mnu_killCLI_Click);\r
+            // \r
             // mnu_exit\r
             // \r
             this.mnu_exit.Name = "mnu_exit";\r
-            this.mnu_exit.Size = new System.Drawing.Size(106, 22);\r
+            this.mnu_exit.Size = new System.Drawing.Size(143, 22);\r
             this.mnu_exit.Text = "E&xit";\r
             this.mnu_exit.Click += new System.EventHandler(this.mnu_exit_Click);\r
             // \r
@@ -1485,7 +575,7 @@ namespace Handbrake
             this.ToolStripSeparator5,\r
             this.mnu_options});\r
             this.ToolsToolStripMenuItem.Name = "ToolsToolStripMenuItem";\r
-            this.ToolsToolStripMenuItem.Size = new System.Drawing.Size(49, 20);\r
+            this.ToolsToolStripMenuItem.Size = new System.Drawing.Size(44, 20);\r
             this.ToolsToolStripMenuItem.Text = "&Tools";\r
             // \r
             // mnu_encode\r
@@ -1493,7 +583,7 @@ namespace Handbrake
             this.mnu_encode.Image = global::Handbrake.Properties.Resources.Queue_Small;\r
             this.mnu_encode.Name = "mnu_encode";\r
             this.mnu_encode.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));\r
-            this.mnu_encode.Size = new System.Drawing.Size(203, 22);\r
+            this.mnu_encode.Size = new System.Drawing.Size(186, 22);\r
             this.mnu_encode.Text = "Show Queue";\r
             this.mnu_encode.Click += new System.EventHandler(this.mnu_encode_Click);\r
             // \r
@@ -1501,20 +591,20 @@ namespace Handbrake
             // \r
             this.mnu_encodeLog.Image = global::Handbrake.Properties.Resources.ActivityWindow_small;\r
             this.mnu_encodeLog.Name = "mnu_encodeLog";\r
-            this.mnu_encodeLog.Size = new System.Drawing.Size(203, 22);\r
+            this.mnu_encodeLog.Size = new System.Drawing.Size(186, 22);\r
             this.mnu_encodeLog.Text = "Activity Window";\r
             this.mnu_encodeLog.Click += new System.EventHandler(this.mnu_encodeLog_Click);\r
             // \r
             // ToolStripSeparator5\r
             // \r
             this.ToolStripSeparator5.Name = "ToolStripSeparator5";\r
-            this.ToolStripSeparator5.Size = new System.Drawing.Size(200, 6);\r
+            this.ToolStripSeparator5.Size = new System.Drawing.Size(183, 6);\r
             // \r
             // mnu_options\r
             // \r
             this.mnu_options.Image = global::Handbrake.Properties.Resources.Pref_Small;\r
             this.mnu_options.Name = "mnu_options";\r
-            this.mnu_options.Size = new System.Drawing.Size(203, 22);\r
+            this.mnu_options.Size = new System.Drawing.Size(186, 22);\r
             this.mnu_options.Text = "Options";\r
             this.mnu_options.Click += new System.EventHandler(this.mnu_options_Click);\r
             // \r
@@ -1525,15 +615,16 @@ namespace Handbrake
             this.mnu_delete_preset,\r
             this.toolStripSeparator7,\r
             this.btn_new_preset,\r
+            this.mnu_importMacPreset,\r
             this.mnu_SelectDefault});\r
             this.PresetsToolStripMenuItem.Name = "PresetsToolStripMenuItem";\r
-            this.PresetsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);\r
+            this.PresetsToolStripMenuItem.Size = new System.Drawing.Size(55, 20);\r
             this.PresetsToolStripMenuItem.Text = "&Presets";\r
             // \r
             // mnu_presetReset\r
             // \r
             this.mnu_presetReset.Name = "mnu_presetReset";\r
-            this.mnu_presetReset.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_presetReset.Size = new System.Drawing.Size(194, 22);\r
             this.mnu_presetReset.Text = "Update Built-in Presets";\r
             this.mnu_presetReset.ToolTipText = "Resets all presets.";\r
             this.mnu_presetReset.Click += new System.EventHandler(this.mnu_presetReset_Click);\r
@@ -1541,26 +632,33 @@ namespace Handbrake
             // mnu_delete_preset\r
             // \r
             this.mnu_delete_preset.Name = "mnu_delete_preset";\r
-            this.mnu_delete_preset.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_delete_preset.Size = new System.Drawing.Size(194, 22);\r
             this.mnu_delete_preset.Text = "Delete Built-in Presets";\r
             this.mnu_delete_preset.Click += new System.EventHandler(this.mnu_delete_preset_Click);\r
             // \r
             // toolStripSeparator7\r
             // \r
             this.toolStripSeparator7.Name = "toolStripSeparator7";\r
-            this.toolStripSeparator7.Size = new System.Drawing.Size(212, 6);\r
+            this.toolStripSeparator7.Size = new System.Drawing.Size(191, 6);\r
             // \r
             // btn_new_preset\r
             // \r
             this.btn_new_preset.Name = "btn_new_preset";\r
-            this.btn_new_preset.Size = new System.Drawing.Size(215, 22);\r
+            this.btn_new_preset.Size = new System.Drawing.Size(194, 22);\r
             this.btn_new_preset.Text = "New Preset";\r
             this.btn_new_preset.Click += new System.EventHandler(this.btn_new_preset_Click);\r
             // \r
+            // mnu_importMacPreset\r
+            // \r
+            this.mnu_importMacPreset.Name = "mnu_importMacPreset";\r
+            this.mnu_importMacPreset.Size = new System.Drawing.Size(194, 22);\r
+            this.mnu_importMacPreset.Text = "Import";\r
+            this.mnu_importMacPreset.Click += new System.EventHandler(this.mnu_importMacPreset_Click);\r
+            // \r
             // mnu_SelectDefault\r
             // \r
             this.mnu_SelectDefault.Name = "mnu_SelectDefault";\r
-            this.mnu_SelectDefault.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_SelectDefault.Size = new System.Drawing.Size(194, 22);\r
             this.mnu_SelectDefault.Text = "Select Default Preset";\r
             this.mnu_SelectDefault.ToolTipText = "Select HandBrake\'s default preset";\r
             this.mnu_SelectDefault.Click += new System.EventHandler(this.mnu_SelectDefault_Click);\r
@@ -1576,14 +674,14 @@ namespace Handbrake
             this.toolStripSeparator6,\r
             this.mnu_about});\r
             this.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem";\r
-            this.HelpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);\r
+            this.HelpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);\r
             this.HelpToolStripMenuItem.Text = "&Help";\r
             // \r
             // mnu_user_guide\r
             // \r
             this.mnu_user_guide.Image = global::Handbrake.Properties.Resources.Help16;\r
             this.mnu_user_guide.Name = "mnu_user_guide";\r
-            this.mnu_user_guide.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_user_guide.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_user_guide.Text = "HandBrake User Guide";\r
             this.mnu_user_guide.Click += new System.EventHandler(this.mnu_user_guide_Click);\r
             // \r
@@ -1591,46 +689,44 @@ namespace Handbrake
             // \r
             this.mnu_handbrake_home.Image = global::Handbrake.Properties.Resources.info16;\r
             this.mnu_handbrake_home.Name = "mnu_handbrake_home";\r
-            this.mnu_handbrake_home.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_handbrake_home.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_handbrake_home.Text = "HandBrake Homepage";\r
             this.mnu_handbrake_home.Click += new System.EventHandler(this.mnu_handbrake_home_Click);\r
             // \r
             // mnu_handbrake_forums\r
             // \r
             this.mnu_handbrake_forums.Name = "mnu_handbrake_forums";\r
-            this.mnu_handbrake_forums.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_handbrake_forums.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_handbrake_forums.Text = "HandBrake Forums";\r
             this.mnu_handbrake_forums.Click += new System.EventHandler(this.mnu_handbrake_forums_Click);\r
             // \r
             // ToolStripSeparator3\r
             // \r
             this.ToolStripSeparator3.Name = "ToolStripSeparator3";\r
-            this.ToolStripSeparator3.Size = new System.Drawing.Size(212, 6);\r
+            this.ToolStripSeparator3.Size = new System.Drawing.Size(189, 6);\r
             // \r
             // mnu_UpdateCheck\r
             // \r
             this.mnu_UpdateCheck.Name = "mnu_UpdateCheck";\r
-            this.mnu_UpdateCheck.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_UpdateCheck.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_UpdateCheck.Text = "Check for Updates";\r
             this.mnu_UpdateCheck.Click += new System.EventHandler(this.mnu_UpdateCheck_Click);\r
             // \r
             // toolStripSeparator6\r
             // \r
             this.toolStripSeparator6.Name = "toolStripSeparator6";\r
-            this.toolStripSeparator6.Size = new System.Drawing.Size(212, 6);\r
+            this.toolStripSeparator6.Size = new System.Drawing.Size(189, 6);\r
             // \r
             // mnu_about\r
             // \r
             this.mnu_about.Image = global::Handbrake.Properties.Resources.hb16;\r
             this.mnu_about.Name = "mnu_about";\r
-            this.mnu_about.Size = new System.Drawing.Size(215, 22);\r
+            this.mnu_about.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_about.Text = "About...";\r
             this.mnu_about.Click += new System.EventHandler(this.mnu_about_Click);\r
             // \r
             // frmMainMenu\r
             // \r
-            this.frmMainMenu.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.frmMainMenu.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible;\r
             this.frmMainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.FileToolStripMenuItem,\r
             this.ToolsToolStripMenuItem,\r
@@ -1638,559 +734,153 @@ namespace Handbrake
             this.HelpToolStripMenuItem});\r
             this.frmMainMenu.Location = new System.Drawing.Point(0, 0);\r
             this.frmMainMenu.Name = "frmMainMenu";\r
-            this.frmMainMenu.Size = new System.Drawing.Size(985, 24);\r
+            this.frmMainMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
+            this.frmMainMenu.Size = new System.Drawing.Size(1002, 24);\r
             this.frmMainMenu.TabIndex = 0;\r
-            this.frmMainMenu.Text = "MenuStrip1";\r
-            // \r
-            // GroupBox1\r
-            // \r
-            this.GroupBox1.Controls.Add(this.lbl_duration);\r
-            this.GroupBox1.Controls.Add(this.label_duration);\r
-            this.GroupBox1.Controls.Add(this.Label13);\r
-            this.GroupBox1.Controls.Add(this.drop_chapterFinish);\r
-            this.GroupBox1.Controls.Add(this.drop_chapterStart);\r
-            this.GroupBox1.Controls.Add(this.drp_dvdtitle);\r
-            this.GroupBox1.Controls.Add(this.Label17);\r
-            this.GroupBox1.Controls.Add(this.text_source);\r
-            this.GroupBox1.Controls.Add(this.Label9);\r
-            this.GroupBox1.Controls.Add(this.Label10);\r
-            this.GroupBox1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.GroupBox1.ForeColor = System.Drawing.Color.Black;\r
-            this.GroupBox1.Location = new System.Drawing.Point(12, 70);\r
-            this.GroupBox1.Name = "GroupBox1";\r
-            this.GroupBox1.Size = new System.Drawing.Size(705, 87);\r
-            this.GroupBox1.TabIndex = 2;\r
-            this.GroupBox1.TabStop = false;\r
-            this.GroupBox1.Text = "Source";\r
-            // \r
-            // Label13\r
-            // \r
-            this.Label13.AutoSize = true;\r
-            this.Label13.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label13.Location = new System.Drawing.Point(370, 55);\r
-            this.Label13.Name = "Label13";\r
-            this.Label13.Size = new System.Drawing.Size(51, 13);\r
-            this.Label13.TabIndex = 10;\r
-            this.Label13.Text = "through";\r
-            // \r
-            // Label17\r
-            // \r
-            this.Label17.AutoSize = true;\r
-            this.Label17.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label17.ForeColor = System.Drawing.Color.Black;\r
-            this.Label17.Location = new System.Drawing.Point(17, 22);\r
-            this.Label17.Name = "Label17";\r
-            this.Label17.Size = new System.Drawing.Size(52, 13);\r
-            this.Label17.TabIndex = 0;\r
-            this.Label17.Text = "Source:";\r
-            // \r
-            // Label9\r
-            // \r
-            this.Label9.AutoSize = true;\r
-            this.Label9.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label9.ForeColor = System.Drawing.Color.Black;\r
-            this.Label9.Location = new System.Drawing.Point(225, 55);\r
-            this.Label9.Name = "Label9";\r
-            this.Label9.Size = new System.Drawing.Size(64, 13);\r
-            this.Label9.TabIndex = 8;\r
-            this.Label9.Text = "Chapters:";\r
-            // \r
-            // Label10\r
-            // \r
-            this.Label10.AutoSize = true;\r
-            this.Label10.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label10.ForeColor = System.Drawing.Color.Black;\r
-            this.Label10.Location = new System.Drawing.Point(17, 55);\r
-            this.Label10.Name = "Label10";\r
-            this.Label10.Size = new System.Drawing.Size(36, 13);\r
-            this.Label10.TabIndex = 6;\r
-            this.Label10.Text = "Title:";\r
-            // \r
-            // groupBox_output\r
-            // \r
-            this.groupBox_output.Controls.Add(this.drop_format);\r
-            this.groupBox_output.Controls.Add(this.label5);\r
-            this.groupBox_output.Controls.Add(this.check_largeFile);\r
-            this.groupBox_output.Controls.Add(this.check_iPodAtom);\r
-            this.groupBox_output.Controls.Add(this.check_optimiseMP4);\r
-            this.groupBox_output.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.groupBox_output.ForeColor = System.Drawing.Color.Black;\r
-            this.groupBox_output.Location = new System.Drawing.Point(12, 214);\r
-            this.groupBox_output.Name = "groupBox_output";\r
-            this.groupBox_output.Size = new System.Drawing.Size(705, 50);\r
-            this.groupBox_output.TabIndex = 4;\r
-            this.groupBox_output.TabStop = false;\r
-            this.groupBox_output.Text = "Output Settings (Preset: None)";\r
+            this.frmMainMenu.Text = "MenuStrip";\r
             // \r
             // label5\r
             // \r
+            this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.label5.AutoSize = true;\r
-            this.label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.label5.ForeColor = System.Drawing.Color.Black;\r
-            this.label5.Location = new System.Drawing.Point(17, 23);\r
+            this.label5.Location = new System.Drawing.Point(3, 7);\r
             this.label5.Name = "label5";\r
-            this.label5.Size = new System.Drawing.Size(52, 13);\r
+            this.label5.Size = new System.Drawing.Size(58, 13);\r
             this.label5.TabIndex = 27;\r
-            this.label5.Text = "Format:";\r
+            this.label5.Text = "Container:";\r
             // \r
             // Label47\r
             // \r
             this.Label47.AutoSize = true;\r
-            this.Label47.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Label47.BackColor = System.Drawing.Color.Transparent;\r
             this.Label47.ForeColor = System.Drawing.Color.Black;\r
             this.Label47.Location = new System.Drawing.Point(13, 39);\r
             this.Label47.Name = "Label47";\r
-            this.Label47.Size = new System.Drawing.Size(84, 13);\r
+            this.Label47.Size = new System.Drawing.Size(70, 13);\r
             this.Label47.TabIndex = 0;\r
             this.Label47.Text = "Video Codec:";\r
             // \r
             // Label3\r
             // \r
+            this.Label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
             this.Label3.AutoSize = true;\r
-            this.Label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Label3.ForeColor = System.Drawing.Color.Black;\r
-            this.Label3.Location = new System.Drawing.Point(17, 21);\r
+            this.Label3.Location = new System.Drawing.Point(3, 8);\r
             this.Label3.Name = "Label3";\r
-            this.Label3.Size = new System.Drawing.Size(31, 13);\r
+            this.Label3.Size = new System.Drawing.Size(27, 13);\r
             this.Label3.TabIndex = 0;\r
             this.Label3.Text = "File:";\r
             // \r
-            // TabPage2\r
-            // \r
-            this.TabPage2.BackColor = System.Drawing.Color.Transparent;\r
-            this.TabPage2.Controls.Add(this.lbl_drc4);\r
-            this.TabPage2.Controls.Add(this.lbl_drc3);\r
-            this.TabPage2.Controls.Add(this.lbl_drc2);\r
-            this.TabPage2.Controls.Add(this.lbl_drc1);\r
-            this.TabPage2.Controls.Add(this.trackBar4);\r
-            this.TabPage2.Controls.Add(this.drp_audsr_4);\r
-            this.TabPage2.Controls.Add(this.drp_audbit_4);\r
-            this.TabPage2.Controls.Add(this.drp_audenc_4);\r
-            this.TabPage2.Controls.Add(this.drp_audmix_4);\r
-            this.TabPage2.Controls.Add(this.drp_track4Audio);\r
-            this.TabPage2.Controls.Add(this.lbl_t4);\r
-            this.TabPage2.Controls.Add(this.trackBar3);\r
-            this.TabPage2.Controls.Add(this.drp_audsr_3);\r
-            this.TabPage2.Controls.Add(this.drp_audbit_3);\r
-            this.TabPage2.Controls.Add(this.drp_audenc_3);\r
-            this.TabPage2.Controls.Add(this.drp_audmix_3);\r
-            this.TabPage2.Controls.Add(this.drp_track3Audio);\r
-            this.TabPage2.Controls.Add(this.lbl_t3);\r
-            this.TabPage2.Controls.Add(this.trackBar2);\r
-            this.TabPage2.Controls.Add(this.label16);\r
-            this.TabPage2.Controls.Add(this.trackBar1);\r
-            this.TabPage2.Controls.Add(this.groupBox5);\r
-            this.TabPage2.Controls.Add(this.groupBox3);\r
-            this.TabPage2.Controls.Add(this.label68);\r
-            this.TabPage2.Controls.Add(this.label67);\r
-            this.TabPage2.Controls.Add(this.drp_audsr_2);\r
-            this.TabPage2.Controls.Add(this.label66);\r
-            this.TabPage2.Controls.Add(this.drp_audbit_2);\r
-            this.TabPage2.Controls.Add(this.label65);\r
-            this.TabPage2.Controls.Add(this.label14);\r
-            this.TabPage2.Controls.Add(this.drp_audenc_2);\r
-            this.TabPage2.Controls.Add(this.drp_audenc_1);\r
-            this.TabPage2.Controls.Add(this.drp_audmix_2);\r
-            this.TabPage2.Controls.Add(this.check_forced);\r
-            this.TabPage2.Controls.Add(this.drp_track2Audio);\r
-            this.TabPage2.Controls.Add(this.label28);\r
-            this.TabPage2.Controls.Add(this.label27);\r
-            this.TabPage2.Controls.Add(this.drp_subtitle);\r
-            this.TabPage2.Controls.Add(this.Label19);\r
-            this.TabPage2.Controls.Add(this.Label20);\r
-            this.TabPage2.Controls.Add(this.drp_audmix_1);\r
-            this.TabPage2.Controls.Add(this.drp_track1Audio);\r
-            this.TabPage2.Controls.Add(this.drp_audbit_1);\r
-            this.TabPage2.Controls.Add(this.Label32);\r
-            this.TabPage2.Controls.Add(this.drp_audsr_1);\r
-            this.TabPage2.Location = new System.Drawing.Point(4, 22);\r
-            this.TabPage2.Name = "TabPage2";\r
-            this.TabPage2.Padding = new System.Windows.Forms.Padding(3);\r
-            this.TabPage2.Size = new System.Drawing.Size(697, 316);\r
-            this.TabPage2.TabIndex = 3;\r
-            this.TabPage2.Text = "Audio && Subtitles";\r
-            // \r
-            // lbl_drc4\r
-            // \r
-            this.lbl_drc4.AutoSize = true;\r
-            this.lbl_drc4.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_drc4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_drc4.Location = new System.Drawing.Point(670, 176);\r
-            this.lbl_drc4.Name = "lbl_drc4";\r
-            this.lbl_drc4.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_drc4.TabIndex = 39;\r
-            this.lbl_drc4.Text = "1:";\r
-            // \r
-            // lbl_drc3\r
-            // \r
-            this.lbl_drc3.AutoSize = true;\r
-            this.lbl_drc3.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_drc3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_drc3.Location = new System.Drawing.Point(670, 135);\r
-            this.lbl_drc3.Name = "lbl_drc3";\r
-            this.lbl_drc3.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_drc3.TabIndex = 31;\r
-            this.lbl_drc3.Text = "1:";\r
-            // \r
-            // lbl_drc2\r
-            // \r
-            this.lbl_drc2.AutoSize = true;\r
-            this.lbl_drc2.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_drc2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_drc2.Location = new System.Drawing.Point(670, 90);\r
-            this.lbl_drc2.Name = "lbl_drc2";\r
-            this.lbl_drc2.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_drc2.TabIndex = 23;\r
-            this.lbl_drc2.Text = "1:";\r
-            // \r
-            // lbl_drc1\r
-            // \r
-            this.lbl_drc1.AutoSize = true;\r
-            this.lbl_drc1.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_drc1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_drc1.Location = new System.Drawing.Point(670, 53);\r
-            this.lbl_drc1.Name = "lbl_drc1";\r
-            this.lbl_drc1.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_drc1.TabIndex = 15;\r
-            this.lbl_drc1.Text = "1:";\r
-            // \r
-            // trackBar4\r
-            // \r
-            this.trackBar4.Enabled = false;\r
-            this.trackBar4.LargeChange = 0;\r
-            this.trackBar4.Location = new System.Drawing.Point(620, 169);\r
-            this.trackBar4.Margin = new System.Windows.Forms.Padding(0);\r
-            this.trackBar4.Maximum = 30;\r
-            this.trackBar4.Name = "trackBar4";\r
-            this.trackBar4.Size = new System.Drawing.Size(49, 42);\r
-            this.trackBar4.TabIndex = 38;\r
-            this.trackBar4.TickFrequency = 10;\r
-            this.trackBar4.ValueChanged += new System.EventHandler(this.trackBar4_Scroll);\r
-            // \r
-            // drp_track4Audio\r
-            // \r
-            this.drp_track4Audio.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_track4Audio.FormattingEnabled = true;\r
-            this.drp_track4Audio.Items.AddRange(new object[] {\r
-            "None"});\r
-            this.drp_track4Audio.Location = new System.Drawing.Point(36, 174);\r
-            this.drp_track4Audio.Name = "drp_track4Audio";\r
-            this.drp_track4Audio.Size = new System.Drawing.Size(194, 20);\r
-            this.drp_track4Audio.TabIndex = 33;\r
-            this.drp_track4Audio.SelectedIndexChanged += new System.EventHandler(this.drp_track4Audio_SelectedIndexChanged);\r
-            // \r
-            // lbl_t4\r
-            // \r
-            this.lbl_t4.AutoSize = true;\r
-            this.lbl_t4.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_t4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_t4.Location = new System.Drawing.Point(13, 177);\r
-            this.lbl_t4.Name = "lbl_t4";\r
-            this.lbl_t4.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_t4.TabIndex = 32;\r
-            this.lbl_t4.Text = "4:";\r
-            // \r
-            // trackBar3\r
-            // \r
-            this.trackBar3.Enabled = false;\r
-            this.trackBar3.LargeChange = 0;\r
-            this.trackBar3.Location = new System.Drawing.Point(620, 128);\r
-            this.trackBar3.Margin = new System.Windows.Forms.Padding(0);\r
-            this.trackBar3.Maximum = 30;\r
-            this.trackBar3.Name = "trackBar3";\r
-            this.trackBar3.Size = new System.Drawing.Size(49, 42);\r
-            this.trackBar3.TabIndex = 30;\r
-            this.trackBar3.TickFrequency = 10;\r
-            this.trackBar3.ValueChanged += new System.EventHandler(this.trackBar3_Scroll);\r
-            // \r
-            // drp_track3Audio\r
-            // \r
-            this.drp_track3Audio.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_track3Audio.FormattingEnabled = true;\r
-            this.drp_track3Audio.Items.AddRange(new object[] {\r
-            "None"});\r
-            this.drp_track3Audio.Location = new System.Drawing.Point(36, 132);\r
-            this.drp_track3Audio.Name = "drp_track3Audio";\r
-            this.drp_track3Audio.Size = new System.Drawing.Size(194, 20);\r
-            this.drp_track3Audio.TabIndex = 25;\r
-            this.drp_track3Audio.SelectedIndexChanged += new System.EventHandler(this.drp_track3Audio_SelectedIndexChanged);\r
-            // \r
-            // lbl_t3\r
-            // \r
-            this.lbl_t3.AutoSize = true;\r
-            this.lbl_t3.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_t3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_t3.Location = new System.Drawing.Point(13, 135);\r
-            this.lbl_t3.Name = "lbl_t3";\r
-            this.lbl_t3.Size = new System.Drawing.Size(19, 13);\r
-            this.lbl_t3.TabIndex = 24;\r
-            this.lbl_t3.Text = "3:";\r
-            // \r
-            // trackBar2\r
-            // \r
-            this.trackBar2.LargeChange = 0;\r
-            this.trackBar2.Location = new System.Drawing.Point(620, 86);\r
-            this.trackBar2.Margin = new System.Windows.Forms.Padding(0);\r
-            this.trackBar2.Maximum = 30;\r
-            this.trackBar2.Name = "trackBar2";\r
-            this.trackBar2.Size = new System.Drawing.Size(49, 42);\r
-            this.trackBar2.TabIndex = 22;\r
-            this.trackBar2.TickFrequency = 10;\r
-            this.trackBar2.ValueChanged += new System.EventHandler(this.trackBar2_Scroll);\r
-            // \r
-            // label16\r
-            // \r
-            this.label16.AutoSize = true;\r
-            this.label16.BackColor = System.Drawing.Color.Transparent;\r
-            this.label16.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label16.Location = new System.Drawing.Point(628, 36);\r
-            this.label16.Name = "label16";\r
-            this.label16.Size = new System.Drawing.Size(28, 12);\r
-            this.label16.TabIndex = 14;\r
-            this.label16.Text = "DRC";\r
-            // \r
-            // trackBar1\r
-            // \r
-            this.trackBar1.LargeChange = 0;\r
-            this.trackBar1.Location = new System.Drawing.Point(619, 48);\r
-            this.trackBar1.Margin = new System.Windows.Forms.Padding(0);\r
-            this.trackBar1.Maximum = 30;\r
-            this.trackBar1.Name = "trackBar1";\r
-            this.trackBar1.Size = new System.Drawing.Size(50, 42);\r
-            this.trackBar1.TabIndex = 13;\r
-            this.trackBar1.TickFrequency = 10;\r
-            this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_Scroll);\r
-            // \r
-            // groupBox5\r
-            // \r
-            this.groupBox5.Location = new System.Drawing.Point(107, 13);\r
-            this.groupBox5.Name = "groupBox5";\r
-            this.groupBox5.Size = new System.Drawing.Size(577, 10);\r
-            this.groupBox5.TabIndex = 1;\r
-            this.groupBox5.TabStop = false;\r
-            // \r
-            // groupBox3\r
-            // \r
-            this.groupBox3.Location = new System.Drawing.Point(83, 219);\r
-            this.groupBox3.Name = "groupBox3";\r
-            this.groupBox3.Size = new System.Drawing.Size(601, 10);\r
-            this.groupBox3.TabIndex = 41;\r
-            this.groupBox3.TabStop = false;\r
-            // \r
-            // label68\r
-            // \r
-            this.label68.AutoSize = true;\r
-            this.label68.BackColor = System.Drawing.Color.Transparent;\r
-            this.label68.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label68.Location = new System.Drawing.Point(13, 13);\r
-            this.label68.Name = "label68";\r
-            this.label68.Size = new System.Drawing.Size(92, 13);\r
-            this.label68.TabIndex = 0;\r
-            this.label68.Text = "Audio Tracks";\r
-            // \r
-            // label67\r
-            // \r
-            this.label67.AutoSize = true;\r
-            this.label67.BackColor = System.Drawing.Color.Transparent;\r
-            this.label67.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label67.Location = new System.Drawing.Point(479, 24);\r
-            this.label67.Name = "label67";\r
-            this.label67.Size = new System.Drawing.Size(65, 24);\r
-            this.label67.TabIndex = 10;\r
-            this.label67.Text = "Samplerate \r\n(kHz)";\r
-            // \r
-            // label66\r
-            // \r
-            this.label66.AutoSize = true;\r
-            this.label66.BackColor = System.Drawing.Color.Transparent;\r
-            this.label66.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label66.Location = new System.Drawing.Point(542, 36);\r
-            this.label66.Name = "label66";\r
-            this.label66.Size = new System.Drawing.Size(75, 12);\r
-            this.label66.TabIndex = 12;\r
-            this.label66.Text = "Bitrate (Kbps)";\r
-            // \r
-            // label65\r
-            // \r
-            this.label65.AutoSize = true;\r
-            this.label65.BackColor = System.Drawing.Color.Transparent;\r
-            this.label65.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label65.Location = new System.Drawing.Point(255, 36);\r
-            this.label65.Name = "label65";\r
-            this.label65.Size = new System.Drawing.Size(69, 12);\r
-            this.label65.TabIndex = 6;\r
-            this.label65.Text = "Audio Codec";\r
-            // \r
-            // label14\r
-            // \r
-            this.label14.AutoSize = true;\r
-            this.label14.BackColor = System.Drawing.Color.Transparent;\r
-            this.label14.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label14.Location = new System.Drawing.Point(380, 36);\r
-            this.label14.Name = "label14";\r
-            this.label14.Size = new System.Drawing.Size(48, 12);\r
-            this.label14.TabIndex = 8;\r
-            this.label14.Text = "Mixdown";\r
-            // \r
-            // check_forced\r
-            // \r
-            this.check_forced.AutoSize = true;\r
-            this.check_forced.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_forced.Enabled = false;\r
-            this.check_forced.Location = new System.Drawing.Point(223, 247);\r
-            this.check_forced.Name = "check_forced";\r
-            this.check_forced.Size = new System.Drawing.Size(147, 17);\r
-            this.check_forced.TabIndex = 44;\r
-            this.check_forced.Text = "Forced Subtitles Only";\r
-            this.check_forced.UseVisualStyleBackColor = false;\r
-            // \r
-            // drp_track2Audio\r
-            // \r
-            this.drp_track2Audio.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_track2Audio.FormattingEnabled = true;\r
-            this.drp_track2Audio.Items.AddRange(new object[] {\r
-            "None"});\r
-            this.drp_track2Audio.Location = new System.Drawing.Point(36, 91);\r
-            this.drp_track2Audio.Name = "drp_track2Audio";\r
-            this.drp_track2Audio.Size = new System.Drawing.Size(194, 20);\r
-            this.drp_track2Audio.TabIndex = 17;\r
-            this.drp_track2Audio.SelectedIndexChanged += new System.EventHandler(this.drp_track2Audio_SelectedIndexChanged);\r
-            // \r
-            // label28\r
-            // \r
-            this.label28.AutoSize = true;\r
-            this.label28.BackColor = System.Drawing.Color.Transparent;\r
-            this.label28.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label28.Location = new System.Drawing.Point(13, 94);\r
-            this.label28.Name = "label28";\r
-            this.label28.Size = new System.Drawing.Size(19, 13);\r
-            this.label28.TabIndex = 16;\r
-            this.label28.Text = "2:";\r
-            // \r
-            // label27\r
-            // \r
-            this.label27.AutoSize = true;\r
-            this.label27.BackColor = System.Drawing.Color.Transparent;\r
-            this.label27.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label27.Location = new System.Drawing.Point(107, 36);\r
-            this.label27.Name = "label27";\r
-            this.label27.Size = new System.Drawing.Size(40, 12);\r
-            this.label27.TabIndex = 4;\r
-            this.label27.Text = "Source";\r
-            // \r
-            // Label19\r
-            // \r
-            this.Label19.AutoSize = true;\r
-            this.Label19.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label19.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label19.Location = new System.Drawing.Point(13, 219);\r
-            this.Label19.Name = "Label19";\r
-            this.Label19.Size = new System.Drawing.Size(64, 13);\r
-            this.Label19.TabIndex = 40;\r
-            this.Label19.Text = "Subtitles";\r
-            // \r
-            // Label20\r
-            // \r
-            this.Label20.AutoSize = true;\r
-            this.Label20.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label20.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label20.Location = new System.Drawing.Point(13, 247);\r
-            this.Label20.Name = "Label20";\r
-            this.Label20.Size = new System.Drawing.Size(61, 13);\r
-            this.Label20.TabIndex = 42;\r
-            this.Label20.Text = "Subtitles:";\r
-            // \r
-            // drp_track1Audio\r
-            // \r
-            this.drp_track1Audio.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_track1Audio.FormattingEnabled = true;\r
-            this.drp_track1Audio.Items.AddRange(new object[] {\r
-            "Automatic"});\r
-            this.drp_track1Audio.Location = new System.Drawing.Point(36, 54);\r
-            this.drp_track1Audio.Name = "drp_track1Audio";\r
-            this.drp_track1Audio.Size = new System.Drawing.Size(194, 20);\r
-            this.drp_track1Audio.TabIndex = 3;\r
-            // \r
-            // Label32\r
-            // \r
-            this.Label32.AutoSize = true;\r
-            this.Label32.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label32.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label32.Location = new System.Drawing.Point(13, 57);\r
-            this.Label32.Name = "Label32";\r
-            this.Label32.Size = new System.Drawing.Size(19, 13);\r
-            this.Label32.TabIndex = 2;\r
-            this.Label32.Text = "1:";\r
-            // \r
-            // TabPage3\r
-            // \r
-            this.TabPage3.BackColor = System.Drawing.Color.Transparent;\r
-            this.TabPage3.Controls.Add(this.drp_videoEncoder);\r
-            this.TabPage3.Controls.Add(this.Label47);\r
-            this.TabPage3.Controls.Add(this.label25);\r
-            this.TabPage3.Controls.Add(this.check_grayscale);\r
-            this.TabPage3.Controls.Add(this.check_turbo);\r
-            this.TabPage3.Controls.Add(this.Label22);\r
-            this.TabPage3.Controls.Add(this.check_2PassEncode);\r
-            this.TabPage3.Controls.Add(this.Label2);\r
-            this.TabPage3.Controls.Add(this.text_filesize);\r
-            this.TabPage3.Controls.Add(this.Label42);\r
-            this.TabPage3.Controls.Add(this.slider_videoQuality);\r
-            this.TabPage3.Controls.Add(this.text_bitrate);\r
-            this.TabPage3.Controls.Add(Label38);\r
-            this.TabPage3.Controls.Add(this.SliderValue);\r
-            this.TabPage3.Controls.Add(this.Label46);\r
-            this.TabPage3.Controls.Add(this.Label40);\r
-            this.TabPage3.Controls.Add(this.drp_videoFramerate);\r
-            this.TabPage3.Location = new System.Drawing.Point(4, 22);\r
-            this.TabPage3.Name = "TabPage3";\r
-            this.TabPage3.Padding = new System.Windows.Forms.Padding(3);\r
-            this.TabPage3.Size = new System.Drawing.Size(697, 316);\r
-            this.TabPage3.TabIndex = 2;\r
-            this.TabPage3.Text = "Video";\r
+            // tab_audio\r
+            // \r
+            this.tab_audio.BackColor = System.Drawing.Color.Transparent;\r
+            this.tab_audio.Controls.Add(this.AudioSettings);\r
+            this.tab_audio.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_audio.Name = "tab_audio";\r
+            this.tab_audio.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_audio.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_audio.TabIndex = 3;\r
+            this.tab_audio.Text = "Audio";\r
+            this.tab_audio.UseVisualStyleBackColor = true;\r
+            // \r
+            // AudioSettings\r
+            // \r
+            this.AudioSettings.BackColor = System.Drawing.Color.Transparent;\r
+            this.AudioSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.AudioSettings.Location = new System.Drawing.Point(0, 0);\r
+            this.AudioSettings.Name = "AudioSettings";\r
+            this.AudioSettings.Size = new System.Drawing.Size(715, 310);\r
+            this.AudioSettings.TabIndex = 0;\r
+            // \r
+            // AudioMenuRowHeightHack\r
+            // \r
+            this.AudioMenuRowHeightHack.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;\r
+            this.AudioMenuRowHeightHack.ImageSize = new System.Drawing.Size(1, 18);\r
+            this.AudioMenuRowHeightHack.TransparentColor = System.Drawing.Color.Transparent;\r
+            // \r
+            // tab_video\r
+            // \r
+            this.tab_video.BackColor = System.Drawing.Color.Transparent;\r
+            this.tab_video.Controls.Add(this.radio_cq);\r
+            this.tab_video.Controls.Add(this.radio_avgBitrate);\r
+            this.tab_video.Controls.Add(this.radio_targetFilesize);\r
+            this.tab_video.Controls.Add(this.drp_videoEncoder);\r
+            this.tab_video.Controls.Add(this.Label47);\r
+            this.tab_video.Controls.Add(this.label25);\r
+            this.tab_video.Controls.Add(this.check_turbo);\r
+            this.tab_video.Controls.Add(this.check_2PassEncode);\r
+            this.tab_video.Controls.Add(this.Label2);\r
+            this.tab_video.Controls.Add(this.text_filesize);\r
+            this.tab_video.Controls.Add(this.slider_videoQuality);\r
+            this.tab_video.Controls.Add(this.text_bitrate);\r
+            this.tab_video.Controls.Add(this.SliderValue);\r
+            this.tab_video.Controls.Add(this.Label46);\r
+            this.tab_video.Controls.Add(this.drp_videoFramerate);\r
+            this.tab_video.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_video.Name = "tab_video";\r
+            this.tab_video.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_video.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_video.TabIndex = 2;\r
+            this.tab_video.Text = "Video";\r
+            this.tab_video.UseVisualStyleBackColor = true;\r
+            // \r
+            // radio_cq\r
+            // \r
+            this.radio_cq.AutoSize = true;\r
+            this.radio_cq.BackColor = System.Drawing.Color.Transparent;\r
+            this.radio_cq.Location = new System.Drawing.Point(336, 97);\r
+            this.radio_cq.Name = "radio_cq";\r
+            this.radio_cq.Size = new System.Drawing.Size(110, 17);\r
+            this.radio_cq.TabIndex = 18;\r
+            this.radio_cq.Text = "Constant Quality:";\r
+            this.radio_cq.UseVisualStyleBackColor = false;\r
+            this.radio_cq.CheckedChanged += new System.EventHandler(this.radio_cq_CheckedChanged);\r
+            // \r
+            // radio_avgBitrate\r
+            // \r
+            this.radio_avgBitrate.AutoSize = true;\r
+            this.radio_avgBitrate.BackColor = System.Drawing.Color.Transparent;\r
+            this.radio_avgBitrate.Checked = true;\r
+            this.radio_avgBitrate.Location = new System.Drawing.Point(336, 64);\r
+            this.radio_avgBitrate.Name = "radio_avgBitrate";\r
+            this.radio_avgBitrate.Size = new System.Drawing.Size(116, 17);\r
+            this.radio_avgBitrate.TabIndex = 17;\r
+            this.radio_avgBitrate.TabStop = true;\r
+            this.radio_avgBitrate.Text = "Avg Bitrate (kbps):";\r
+            this.radio_avgBitrate.UseVisualStyleBackColor = false;\r
+            this.radio_avgBitrate.CheckedChanged += new System.EventHandler(this.radio_avgBitrate_CheckedChanged);\r
+            // \r
+            // radio_targetFilesize\r
+            // \r
+            this.radio_targetFilesize.AutoSize = true;\r
+            this.radio_targetFilesize.BackColor = System.Drawing.Color.Transparent;\r
+            this.radio_targetFilesize.Location = new System.Drawing.Point(336, 37);\r
+            this.radio_targetFilesize.Name = "radio_targetFilesize";\r
+            this.radio_targetFilesize.Size = new System.Drawing.Size(108, 17);\r
+            this.radio_targetFilesize.TabIndex = 16;\r
+            this.radio_targetFilesize.Text = "Target Size (MB):";\r
+            this.radio_targetFilesize.UseVisualStyleBackColor = false;\r
+            this.radio_targetFilesize.CheckedChanged += new System.EventHandler(this.radio_targetFilesize_CheckedChanged);\r
             // \r
             // label25\r
             // \r
             this.label25.AutoSize = true;\r
             this.label25.BackColor = System.Drawing.Color.Transparent;\r
-            this.label25.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label25.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.label25.Location = new System.Drawing.Point(13, 13);\r
             this.label25.Name = "label25";\r
-            this.label25.Size = new System.Drawing.Size(43, 13);\r
+            this.label25.Size = new System.Drawing.Size(38, 13);\r
             this.label25.TabIndex = 0;\r
             this.label25.Text = "Video";\r
             // \r
-            // check_grayscale\r
-            // \r
-            this.check_grayscale.AutoSize = true;\r
-            this.check_grayscale.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_grayscale.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_grayscale.Location = new System.Drawing.Point(16, 138);\r
-            this.check_grayscale.Name = "check_grayscale";\r
-            this.check_grayscale.Size = new System.Drawing.Size(138, 17);\r
-            this.check_grayscale.TabIndex = 5;\r
-            this.check_grayscale.Text = "Grayscale Encoding";\r
-            this.check_grayscale.UseVisualStyleBackColor = false;\r
-            // \r
-            // Label22\r
-            // \r
-            this.Label22.AutoSize = true;\r
-            this.Label22.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label22.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label22.Location = new System.Drawing.Point(13, 118);\r
-            this.Label22.Name = "Label22";\r
-            this.Label22.Size = new System.Drawing.Size(191, 13);\r
-            this.Label22.TabIndex = 4;\r
-            this.Label22.Text = "Advanced Encoding Settings";\r
-            // \r
             // check_2PassEncode\r
             // \r
             this.check_2PassEncode.AutoSize = true;\r
             this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_2PassEncode.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_2PassEncode.Location = new System.Drawing.Point(16, 161);\r
+            this.check_2PassEncode.Location = new System.Drawing.Point(125, 100);\r
             this.check_2PassEncode.Name = "check_2PassEncode";\r
-            this.check_2PassEncode.Size = new System.Drawing.Size(119, 17);\r
+            this.check_2PassEncode.Size = new System.Drawing.Size(104, 17);\r
             this.check_2PassEncode.TabIndex = 6;\r
             this.check_2PassEncode.Text = "2-Pass Encoding";\r
             this.check_2PassEncode.UseVisualStyleBackColor = false;\r
@@ -2200,32 +890,20 @@ namespace Handbrake
             // \r
             this.Label2.AutoSize = true;\r
             this.Label2.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Label2.Location = new System.Drawing.Point(334, 13);\r
             this.Label2.Name = "Label2";\r
-            this.Label2.Size = new System.Drawing.Size(53, 13);\r
+            this.Label2.Size = new System.Drawing.Size(47, 13);\r
             this.Label2.TabIndex = 8;\r
             this.Label2.Text = "Quality";\r
             // \r
-            // Label42\r
-            // \r
-            this.Label42.AutoSize = true;\r
-            this.Label42.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label42.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label42.Location = new System.Drawing.Point(334, 65);\r
-            this.Label42.Name = "Label42";\r
-            this.Label42.Size = new System.Drawing.Size(117, 13);\r
-            this.Label42.TabIndex = 9;\r
-            this.Label42.Text = "Avg Bitrate (kbps):";\r
-            // \r
             // SliderValue\r
             // \r
             this.SliderValue.AutoSize = true;\r
             this.SliderValue.BackColor = System.Drawing.Color.Transparent;\r
-            this.SliderValue.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.SliderValue.Location = new System.Drawing.Point(641, 100);\r
+            this.SliderValue.Location = new System.Drawing.Point(480, 100);\r
             this.SliderValue.Name = "SliderValue";\r
-            this.SliderValue.Size = new System.Drawing.Size(23, 12);\r
+            this.SliderValue.Size = new System.Drawing.Size(24, 13);\r
             this.SliderValue.TabIndex = 15;\r
             this.SliderValue.Text = "0%";\r
             // \r
@@ -2233,639 +911,183 @@ namespace Handbrake
             // \r
             this.Label46.AutoSize = true;\r
             this.Label46.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label46.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Label46.Location = new System.Drawing.Point(13, 71);\r
             this.Label46.Name = "Label46";\r
-            this.Label46.Size = new System.Drawing.Size(106, 13);\r
+            this.Label46.Size = new System.Drawing.Size(90, 13);\r
             this.Label46.TabIndex = 1;\r
             this.Label46.Text = "Framerate (FPS):";\r
             // \r
-            // Label40\r
-            // \r
-            this.Label40.AutoSize = true;\r
-            this.Label40.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label40.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label40.Location = new System.Drawing.Point(334, 99);\r
-            this.Label40.Name = "Label40";\r
-            this.Label40.Size = new System.Drawing.Size(107, 13);\r
-            this.Label40.TabIndex = 13;\r
-            this.Label40.Text = "Constant Quality:";\r
-            // \r
-            // TabPage1\r
-            // \r
-            this.TabPage1.BackColor = System.Drawing.Color.Transparent;\r
-            this.TabPage1.Controls.Add(this.slider_deblock);\r
-            this.TabPage1.Controls.Add(this.label8);\r
-            this.TabPage1.Controls.Add(this.lbl_deblockVal);\r
-            this.TabPage1.Controls.Add(this.check_customCrop);\r
-            this.TabPage1.Controls.Add(this.check_autoCrop);\r
-            this.TabPage1.Controls.Add(this.check_decomb);\r
-            this.TabPage1.Controls.Add(this.lbl_src_res);\r
-            this.TabPage1.Controls.Add(this.label7);\r
-            this.TabPage1.Controls.Add(this.label6);\r
-            this.TabPage1.Controls.Add(this.drp_anamorphic);\r
-            this.TabPage1.Controls.Add(this.text_bottom);\r
-            this.TabPage1.Controls.Add(this.text_top);\r
-            this.TabPage1.Controls.Add(this.text_left);\r
-            this.TabPage1.Controls.Add(this.text_right);\r
-            this.TabPage1.Controls.Add(this.label26);\r
-            this.TabPage1.Controls.Add(this.Label56);\r
-            this.TabPage1.Controls.Add(this.lbl_Aspect);\r
-            this.TabPage1.Controls.Add(this.Label91);\r
-            this.TabPage1.Controls.Add(this.text_height);\r
-            this.TabPage1.Controls.Add(this.Label55);\r
-            this.TabPage1.Controls.Add(this.text_width);\r
-            this.TabPage1.Controls.Add(this.label24);\r
-            this.TabPage1.Controls.Add(this.drp_deNoise);\r
-            this.TabPage1.Controls.Add(this.label11);\r
-            this.TabPage1.Controls.Add(this.check_detelecine);\r
-            this.TabPage1.Controls.Add(this.label4);\r
-            this.TabPage1.Controls.Add(this.drp_deInterlace_option);\r
-            this.TabPage1.Controls.Add(this.Label1);\r
-            this.TabPage1.Controls.Add(this.Label53);\r
-            this.TabPage1.Controls.Add(this.Label52);\r
-            this.TabPage1.Controls.Add(this.Label51);\r
-            this.TabPage1.Controls.Add(this.Label15);\r
-            this.TabPage1.Location = new System.Drawing.Point(4, 22);\r
-            this.TabPage1.Name = "TabPage1";\r
-            this.TabPage1.Padding = new System.Windows.Forms.Padding(3);\r
-            this.TabPage1.Size = new System.Drawing.Size(697, 316);\r
-            this.TabPage1.TabIndex = 0;\r
-            this.TabPage1.Text = "Picture Settings";\r
-            // \r
-            // slider_deblock\r
-            // \r
-            this.slider_deblock.Location = new System.Drawing.Point(407, 264);\r
-            this.slider_deblock.Maximum = 15;\r
-            this.slider_deblock.Minimum = 4;\r
-            this.slider_deblock.Name = "slider_deblock";\r
-            this.slider_deblock.Size = new System.Drawing.Size(174, 42);\r
-            this.slider_deblock.TabIndex = 35;\r
-            this.slider_deblock.Value = 4;\r
-            this.slider_deblock.Scroll += new System.EventHandler(this.slider_deblock_Scroll);\r
-            // \r
-            // label8\r
-            // \r
-            this.label8.AutoSize = true;\r
-            this.label8.BackColor = System.Drawing.Color.Transparent;\r
-            this.label8.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label8.Location = new System.Drawing.Point(311, 269);\r
-            this.label8.Name = "label8";\r
-            this.label8.Size = new System.Drawing.Size(58, 13);\r
-            this.label8.TabIndex = 37;\r
-            this.label8.Text = "Deblock:";\r
-            // \r
-            // lbl_deblockVal\r
-            // \r
-            this.lbl_deblockVal.AutoSize = true;\r
-            this.lbl_deblockVal.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_deblockVal.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_deblockVal.Location = new System.Drawing.Point(585, 269);\r
-            this.lbl_deblockVal.Name = "lbl_deblockVal";\r
-            this.lbl_deblockVal.Size = new System.Drawing.Size(24, 13);\r
-            this.lbl_deblockVal.TabIndex = 36;\r
-            this.lbl_deblockVal.Text = "Off";\r
-            // \r
-            // check_decomb\r
-            // \r
-            this.check_decomb.AutoSize = true;\r
-            this.check_decomb.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_decomb.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_decomb.Location = new System.Drawing.Point(314, 188);\r
-            this.check_decomb.Name = "check_decomb";\r
-            this.check_decomb.Size = new System.Drawing.Size(73, 17);\r
-            this.check_decomb.TabIndex = 32;\r
-            this.check_decomb.Text = "Decomb";\r
-            this.check_decomb.UseVisualStyleBackColor = false;\r
-            // \r
-            // label6\r
-            // \r
-            this.label6.AutoSize = true;\r
-            this.label6.BackColor = System.Drawing.Color.Transparent;\r
-            this.label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label6.Location = new System.Drawing.Point(311, 111);\r
-            this.label6.Name = "label6";\r
-            this.label6.Size = new System.Drawing.Size(80, 13);\r
-            this.label6.TabIndex = 20;\r
-            this.label6.Text = "Anamorphic:";\r
-            // \r
-            // drp_anamorphic\r
-            // \r
-            this.drp_anamorphic.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_anamorphic.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_anamorphic.FormattingEnabled = true;\r
-            this.drp_anamorphic.Items.AddRange(new object[] {\r
-            "None",\r
-            "Strict",\r
-            "Loose"});\r
-            this.drp_anamorphic.Location = new System.Drawing.Point(407, 108);\r
-            this.drp_anamorphic.Name = "drp_anamorphic";\r
-            this.drp_anamorphic.Size = new System.Drawing.Size(110, 21);\r
-            this.drp_anamorphic.TabIndex = 21;\r
-            this.drp_anamorphic.SelectedIndexChanged += new System.EventHandler(this.drp_anamorphic_SelectedIndexChanged);\r
-            // \r
-            // text_bottom\r
-            // \r
-            this.text_bottom.Enabled = false;\r
-            this.text_bottom.Location = new System.Drawing.Point(96, 147);\r
-            this.text_bottom.Maximum = new decimal(new int[] {\r
-            1080,\r
-            0,\r
-            0,\r
-            0});\r
-            this.text_bottom.Name = "text_bottom";\r
-            this.text_bottom.Size = new System.Drawing.Size(44, 21);\r
-            this.text_bottom.TabIndex = 9;\r
-            // \r
-            // text_top\r
-            // \r
-            this.text_top.Enabled = false;\r
-            this.text_top.Location = new System.Drawing.Point(96, 101);\r
-            this.text_top.Maximum = new decimal(new int[] {\r
-            1080,\r
-            0,\r
-            0,\r
-            0});\r
-            this.text_top.Name = "text_top";\r
-            this.text_top.Size = new System.Drawing.Size(44, 21);\r
-            this.text_top.TabIndex = 6;\r
-            // \r
-            // text_left\r
-            // \r
-            this.text_left.Enabled = false;\r
-            this.text_left.Location = new System.Drawing.Point(45, 123);\r
-            this.text_left.Maximum = new decimal(new int[] {\r
-            1920,\r
-            0,\r
-            0,\r
-            0});\r
-            this.text_left.Name = "text_left";\r
-            this.text_left.Size = new System.Drawing.Size(44, 21);\r
-            this.text_left.TabIndex = 4;\r
-            // \r
-            // text_right\r
-            // \r
-            this.text_right.Enabled = false;\r
-            this.text_right.Location = new System.Drawing.Point(147, 123);\r
-            this.text_right.Maximum = new decimal(new int[] {\r
-            1920,\r
-            0,\r
-            0,\r
-            0});\r
-            this.text_right.Name = "text_right";\r
-            this.text_right.Size = new System.Drawing.Size(44, 21);\r
-            this.text_right.TabIndex = 7;\r
-            // \r
-            // label26\r
-            // \r
-            this.label26.AutoSize = true;\r
-            this.label26.BackColor = System.Drawing.Color.Transparent;\r
-            this.label26.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label26.Location = new System.Drawing.Point(311, 13);\r
-            this.label26.Name = "label26";\r
-            this.label26.Size = new System.Drawing.Size(34, 13);\r
-            this.label26.TabIndex = 11;\r
-            this.label26.Text = "Size";\r
-            // \r
-            // Label56\r
-            // \r
-            this.Label56.AutoSize = true;\r
-            this.Label56.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label56.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label56.ForeColor = System.Drawing.Color.Black;\r
-            this.Label56.Location = new System.Drawing.Point(477, 85);\r
-            this.Label56.Name = "Label56";\r
-            this.Label56.Size = new System.Drawing.Size(15, 13);\r
-            this.Label56.TabIndex = 18;\r
-            this.Label56.Text = "x";\r
-            // \r
-            // lbl_Aspect\r
-            // \r
-            this.lbl_Aspect.AutoSize = true;\r
-            this.lbl_Aspect.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_Aspect.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_Aspect.Location = new System.Drawing.Point(405, 58);\r
-            this.lbl_Aspect.Name = "lbl_Aspect";\r
-            this.lbl_Aspect.Size = new System.Drawing.Size(72, 12);\r
-            this.lbl_Aspect.TabIndex = 15;\r
-            this.lbl_Aspect.Text = "Select a Title";\r
-            // \r
-            // Label91\r
-            // \r
-            this.Label91.AutoSize = true;\r
-            this.Label91.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label91.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label91.Location = new System.Drawing.Point(311, 57);\r
-            this.Label91.Name = "Label91";\r
-            this.Label91.Size = new System.Drawing.Size(83, 13);\r
-            this.Label91.TabIndex = 14;\r
-            this.Label91.Text = "Aspect Ratio:";\r
-            // \r
-            // Label55\r
-            // \r
-            this.Label55.AutoSize = true;\r
-            this.Label55.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label55.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label55.ForeColor = System.Drawing.Color.Black;\r
-            this.Label55.Location = new System.Drawing.Point(311, 84);\r
-            this.Label55.Name = "Label55";\r
-            this.Label55.Size = new System.Drawing.Size(85, 13);\r
-            this.Label55.TabIndex = 16;\r
-            this.Label55.Text = "Width/Height:";\r
-            // \r
-            // label24\r
-            // \r
-            this.label24.AutoSize = true;\r
-            this.label24.BackColor = System.Drawing.Color.Transparent;\r
-            this.label24.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label24.Location = new System.Drawing.Point(311, 142);\r
-            this.label24.Name = "label24";\r
-            this.label24.Size = new System.Drawing.Size(49, 13);\r
-            this.label24.TabIndex = 22;\r
-            this.label24.Text = "Filters";\r
-            // \r
-            // drp_deNoise\r
-            // \r
-            this.drp_deNoise.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_deNoise.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_deNoise.FormattingEnabled = true;\r
-            this.drp_deNoise.Items.AddRange(new object[] {\r
-            "None",\r
-            "Weak",\r
-            "Medium",\r
-            "Strong"});\r
-            this.drp_deNoise.Location = new System.Drawing.Point(413, 237);\r
-            this.drp_deNoise.Name = "drp_deNoise";\r
-            this.drp_deNoise.Size = new System.Drawing.Size(161, 21);\r
-            this.drp_deNoise.TabIndex = 29;\r
-            // \r
-            // label11\r
-            // \r
-            this.label11.AutoSize = true;\r
-            this.label11.BackColor = System.Drawing.Color.Transparent;\r
-            this.label11.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label11.Location = new System.Drawing.Point(311, 240);\r
-            this.label11.Name = "label11";\r
-            this.label11.Size = new System.Drawing.Size(58, 13);\r
-            this.label11.TabIndex = 28;\r
-            this.label11.Text = "Denoise:";\r
-            // \r
-            // check_detelecine\r
-            // \r
-            this.check_detelecine.AutoSize = true;\r
-            this.check_detelecine.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_detelecine.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_detelecine.Location = new System.Drawing.Point(314, 165);\r
-            this.check_detelecine.Name = "check_detelecine";\r
-            this.check_detelecine.Size = new System.Drawing.Size(86, 17);\r
-            this.check_detelecine.TabIndex = 23;\r
-            this.check_detelecine.Text = "Detelecine";\r
-            this.check_detelecine.UseVisualStyleBackColor = false;\r
-            // \r
-            // label4\r
-            // \r
-            this.label4.AutoSize = true;\r
-            this.label4.BackColor = System.Drawing.Color.Transparent;\r
-            this.label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label4.Location = new System.Drawing.Point(311, 212);\r
-            this.label4.Name = "label4";\r
-            this.label4.Size = new System.Drawing.Size(77, 13);\r
-            this.label4.TabIndex = 26;\r
-            this.label4.Text = "Deinterlace:";\r
-            // \r
-            // drp_deInterlace_option\r
-            // \r
-            this.drp_deInterlace_option.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_deInterlace_option.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.drp_deInterlace_option.FormattingEnabled = true;\r
-            this.drp_deInterlace_option.Items.AddRange(new object[] {\r
-            "None",\r
-            "Fast",\r
-            "Slow",\r
-            "Slower"});\r
-            this.drp_deInterlace_option.Location = new System.Drawing.Point(413, 209);\r
-            this.drp_deInterlace_option.Name = "drp_deInterlace_option";\r
-            this.drp_deInterlace_option.Size = new System.Drawing.Size(161, 21);\r
-            this.drp_deInterlace_option.TabIndex = 27;\r
-            // \r
-            // Label1\r
-            // \r
-            this.Label1.AutoSize = true;\r
-            this.Label1.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label1.Location = new System.Drawing.Point(13, 13);\r
-            this.Label1.Name = "Label1";\r
-            this.Label1.Size = new System.Drawing.Size(37, 13);\r
-            this.Label1.TabIndex = 0;\r
-            this.Label1.Text = "Crop";\r
-            // \r
-            // Label53\r
-            // \r
-            this.Label53.AutoSize = true;\r
-            this.Label53.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label53.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label53.Location = new System.Drawing.Point(94, 171);\r
-            this.Label53.Name = "Label53";\r
-            this.Label53.Size = new System.Drawing.Size(48, 13);\r
-            this.Label53.TabIndex = 10;\r
-            this.Label53.Text = "Bottom";\r
-            // \r
-            // Label52\r
-            // \r
-            this.Label52.AutoSize = true;\r
-            this.Label52.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label52.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label52.Location = new System.Drawing.Point(103, 86);\r
-            this.Label52.Name = "Label52";\r
-            this.Label52.Size = new System.Drawing.Size(28, 13);\r
-            this.Label52.TabIndex = 5;\r
-            this.Label52.Text = "Top";\r
-            // \r
-            // Label51\r
-            // \r
-            this.Label51.AutoSize = true;\r
-            this.Label51.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label51.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label51.Location = new System.Drawing.Point(190, 125);\r
-            this.Label51.Name = "Label51";\r
-            this.Label51.Size = new System.Drawing.Size(36, 13);\r
-            this.Label51.TabIndex = 8;\r
-            this.Label51.Text = "Right";\r
-            // \r
-            // Label15\r
-            // \r
-            this.Label15.AutoSize = true;\r
-            this.Label15.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label15.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label15.Location = new System.Drawing.Point(13, 125);\r
-            this.Label15.Name = "Label15";\r
-            this.Label15.Size = new System.Drawing.Size(28, 13);\r
-            this.Label15.TabIndex = 3;\r
-            this.Label15.Text = "Left";\r
+            // tab_picture\r
+            // \r
+            this.tab_picture.BackColor = System.Drawing.Color.Transparent;\r
+            this.tab_picture.Controls.Add(this.PictureSettings);\r
+            this.tab_picture.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_picture.Name = "tab_picture";\r
+            this.tab_picture.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_picture.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_picture.TabIndex = 0;\r
+            this.tab_picture.Text = "Picture";\r
+            this.tab_picture.UseVisualStyleBackColor = true;\r
+            // \r
+            // PictureSettings\r
+            // \r
+            this.PictureSettings.BackColor = System.Drawing.Color.Transparent;\r
+            this.PictureSettings.Enabled = false;\r
+            this.PictureSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.PictureSettings.Location = new System.Drawing.Point(0, 0);\r
+            this.PictureSettings.Name = "PictureSettings";\r
+            this.PictureSettings.Size = new System.Drawing.Size(666, 279);\r
+            this.PictureSettings.TabIndex = 0;\r
             // \r
             // Check_ChapterMarkers\r
             // \r
             this.Check_ChapterMarkers.AutoSize = true;\r
             this.Check_ChapterMarkers.BackColor = System.Drawing.Color.Transparent;\r
-            this.Check_ChapterMarkers.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Check_ChapterMarkers.Location = new System.Drawing.Point(16, 32);\r
             this.Check_ChapterMarkers.Name = "Check_ChapterMarkers";\r
-            this.Check_ChapterMarkers.Size = new System.Drawing.Size(164, 17);\r
+            this.Check_ChapterMarkers.Size = new System.Drawing.Size(140, 17);\r
             this.Check_ChapterMarkers.TabIndex = 1;\r
             this.Check_ChapterMarkers.Text = "Create chapter markers";\r
             this.Check_ChapterMarkers.UseVisualStyleBackColor = false;\r
             this.Check_ChapterMarkers.CheckedChanged += new System.EventHandler(this.Check_ChapterMarkers_CheckedChanged);\r
             // \r
-            // advancedOptions\r
-            // \r
-            this.advancedOptions.Controls.Add(this.TabPage1);\r
-            this.advancedOptions.Controls.Add(this.TabPage3);\r
-            this.advancedOptions.Controls.Add(this.TabPage2);\r
-            this.advancedOptions.Controls.Add(this.tab_chapters);\r
-            this.advancedOptions.Controls.Add(this.h264Tab);\r
-            this.advancedOptions.Controls.Add(this.tabPage4);\r
-            this.advancedOptions.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.advancedOptions.Location = new System.Drawing.Point(12, 274);\r
-            this.advancedOptions.Name = "advancedOptions";\r
-            this.advancedOptions.SelectedIndex = 0;\r
-            this.advancedOptions.Size = new System.Drawing.Size(705, 342);\r
-            this.advancedOptions.TabIndex = 5;\r
-            this.advancedOptions.TabStop = false;\r
+            // tabs_panel\r
+            // \r
+            this.tabs_panel.Controls.Add(this.tab_picture);\r
+            this.tabs_panel.Controls.Add(this.tab_filters);\r
+            this.tabs_panel.Controls.Add(this.tab_video);\r
+            this.tabs_panel.Controls.Add(this.tab_audio);\r
+            this.tabs_panel.Controls.Add(this.tab_subtitles);\r
+            this.tabs_panel.Controls.Add(this.tab_chapters);\r
+            this.tabs_panel.Controls.Add(this.tab_advanced);\r
+            this.tabs_panel.Controls.Add(this.tab_query);\r
+            this.tabs_panel.Location = new System.Drawing.Point(12, 218);\r
+            this.tabs_panel.Name = "tabs_panel";\r
+            this.tabs_panel.SelectedIndex = 0;\r
+            this.tabs_panel.Size = new System.Drawing.Size(732, 334);\r
+            this.tabs_panel.TabIndex = 5;\r
+            this.tabs_panel.TabStop = false;\r
+            // \r
+            // tab_filters\r
+            // \r
+            this.tab_filters.Controls.Add(this.Filters);\r
+            this.tab_filters.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_filters.Name = "tab_filters";\r
+            this.tab_filters.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_filters.TabIndex = 9;\r
+            this.tab_filters.Text = "Video Filters";\r
+            this.tab_filters.UseVisualStyleBackColor = true;\r
+            // \r
+            // Filters\r
+            // \r
+            this.Filters.BackColor = System.Drawing.Color.Transparent;\r
+            this.Filters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Filters.Location = new System.Drawing.Point(0, 0);\r
+            this.Filters.Name = "Filters";\r
+            this.Filters.Size = new System.Drawing.Size(713, 310);\r
+            this.Filters.TabIndex = 0;\r
+            // \r
+            // tab_subtitles\r
+            // \r
+            this.tab_subtitles.Controls.Add(this.Subtitles);\r
+            this.tab_subtitles.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_subtitles.Name = "tab_subtitles";\r
+            this.tab_subtitles.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_subtitles.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_subtitles.TabIndex = 10;\r
+            this.tab_subtitles.Text = "Subtitles";\r
+            this.tab_subtitles.UseVisualStyleBackColor = true;\r
+            // \r
+            // Subtitles\r
+            // \r
+            this.Subtitles.BackColor = System.Drawing.Color.Transparent;\r
+            this.Subtitles.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Subtitles.Location = new System.Drawing.Point(0, 0);\r
+            this.Subtitles.Name = "Subtitles";\r
+            this.Subtitles.Size = new System.Drawing.Size(722, 310);\r
+            this.Subtitles.TabIndex = 0;\r
             // \r
             // tab_chapters\r
             // \r
             this.tab_chapters.BackColor = System.Drawing.Color.Transparent;\r
+            this.tab_chapters.Controls.Add(this.btn_importChapters);\r
             this.tab_chapters.Controls.Add(this.label31);\r
             this.tab_chapters.Controls.Add(this.data_chpt);\r
             this.tab_chapters.Controls.Add(this.Check_ChapterMarkers);\r
             this.tab_chapters.Location = new System.Drawing.Point(4, 22);\r
             this.tab_chapters.Name = "tab_chapters";\r
-            this.tab_chapters.Size = new System.Drawing.Size(697, 316);\r
+            this.tab_chapters.Size = new System.Drawing.Size(724, 308);\r
             this.tab_chapters.TabIndex = 6;\r
             this.tab_chapters.Text = "Chapters";\r
+            this.tab_chapters.UseVisualStyleBackColor = true;\r
+            // \r
+            // btn_importChapters\r
+            // \r
+            this.btn_importChapters.AutoSize = true;\r
+            this.btn_importChapters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_importChapters.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_importChapters.Location = new System.Drawing.Point(625, 26);\r
+            this.btn_importChapters.Name = "btn_importChapters";\r
+            this.btn_importChapters.Size = new System.Drawing.Size(75, 23);\r
+            this.btn_importChapters.TabIndex = 14;\r
+            this.btn_importChapters.Text = "Import";\r
+            this.ToolTip.SetToolTip(this.btn_importChapters, resources.GetString("btn_importChapters.ToolTip"));\r
+            this.btn_importChapters.UseVisualStyleBackColor = true;\r
+            this.btn_importChapters.Click += new System.EventHandler(this.btn_importChapters_Click);\r
             // \r
             // label31\r
             // \r
             this.label31.AutoSize = true;\r
             this.label31.BackColor = System.Drawing.Color.Transparent;\r
-            this.label31.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label31.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.label31.Location = new System.Drawing.Point(13, 13);\r
             this.label31.Name = "label31";\r
-            this.label31.Size = new System.Drawing.Size(115, 13);\r
+            this.label31.Size = new System.Drawing.Size(102, 13);\r
             this.label31.TabIndex = 0;\r
             this.label31.Text = "Chapter Markers";\r
             // \r
-            // h264Tab\r
-            // \r
-            this.h264Tab.BackColor = System.Drawing.Color.Transparent;\r
-            this.h264Tab.Controls.Add(this.label43);\r
-            this.h264Tab.Controls.Add(this.btn_reset);\r
-            this.h264Tab.Controls.Add(this.rtf_x264Query);\r
-            this.h264Tab.Controls.Add(this.check_Cabac);\r
-            this.h264Tab.Controls.Add(this.check_noDCTDecimate);\r
-            this.h264Tab.Controls.Add(this.check_noFastPSkip);\r
-            this.h264Tab.Controls.Add(this.lbl_trellis);\r
-            this.h264Tab.Controls.Add(this.drop_trellis);\r
-            this.h264Tab.Controls.Add(this.drop_deblockBeta);\r
-            this.h264Tab.Controls.Add(this.label41);\r
-            this.h264Tab.Controls.Add(this.drop_deblockAlpha);\r
-            this.h264Tab.Controls.Add(this.panel3);\r
-            this.h264Tab.Controls.Add(this.panel1);\r
-            this.h264Tab.Controls.Add(this.panel2);\r
-            this.h264Tab.Controls.Add(this.check_8x8DCT);\r
-            this.h264Tab.Controls.Add(this.label45);\r
-            this.h264Tab.Controls.Add(this.drop_analysis);\r
-            this.h264Tab.Controls.Add(this.label48);\r
-            this.h264Tab.Controls.Add(this.drop_subpixelMotionEstimation);\r
-            this.h264Tab.Controls.Add(this.label49);\r
-            this.h264Tab.Controls.Add(this.drop_MotionEstimationRange);\r
-            this.h264Tab.Controls.Add(this.label54);\r
-            this.h264Tab.Controls.Add(this.drop_MotionEstimationMethod);\r
-            this.h264Tab.Controls.Add(this.check_pyrmidalBFrames);\r
-            this.h264Tab.Controls.Add(this.check_weightedBFrames);\r
-            this.h264Tab.Controls.Add(this.lbl_direct_prediction);\r
-            this.h264Tab.Controls.Add(this.drop_directPrediction);\r
-            this.h264Tab.Controls.Add(this.label62);\r
-            this.h264Tab.Controls.Add(this.drop_bFrames);\r
-            this.h264Tab.Controls.Add(this.label64);\r
-            this.h264Tab.Controls.Add(this.drop_refFrames);\r
-            this.h264Tab.Controls.Add(this.check_mixedReferences);\r
-            this.h264Tab.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.h264Tab.Location = new System.Drawing.Point(4, 22);\r
-            this.h264Tab.Name = "h264Tab";\r
-            this.h264Tab.Padding = new System.Windows.Forms.Padding(3);\r
-            this.h264Tab.Size = new System.Drawing.Size(697, 316);\r
-            this.h264Tab.TabIndex = 8;\r
-            this.h264Tab.Text = "Advanced";\r
-            // \r
-            // label43\r
-            // \r
-            this.label43.AutoSize = true;\r
-            this.label43.BackColor = System.Drawing.Color.Transparent;\r
-            this.label43.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label43.Location = new System.Drawing.Point(13, 13);\r
-            this.label43.Name = "label43";\r
-            this.label43.Size = new System.Drawing.Size(165, 13);\r
-            this.label43.TabIndex = 0;\r
-            this.label43.Text = "Advanced H.264 Options";\r
-            // \r
-            // btn_reset\r
-            // \r
-            this.btn_reset.Location = new System.Drawing.Point(13, 224);\r
-            this.btn_reset.Name = "btn_reset";\r
-            this.btn_reset.Size = new System.Drawing.Size(75, 23);\r
-            this.btn_reset.TabIndex = 41;\r
-            this.btn_reset.Text = "Reset All";\r
-            this.btn_reset.UseVisualStyleBackColor = true;\r
-            this.btn_reset.Click += new System.EventHandler(this.btn_reset_Click);\r
-            // \r
-            // rtf_x264Query\r
-            // \r
-            this.rtf_x264Query.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
-            this.rtf_x264Query.Location = new System.Drawing.Point(13, 253);\r
-            this.rtf_x264Query.Name = "rtf_x264Query";\r
-            this.rtf_x264Query.Size = new System.Drawing.Size(667, 43);\r
-            this.rtf_x264Query.TabIndex = 42;\r
-            this.rtf_x264Query.Text = "";\r
-            this.rtf_x264Query.LostFocus += new System.EventHandler(this.rtf_x264Query_TextChanged);\r
-            this.rtf_x264Query.TextChanged += new System.EventHandler(this.rtf_x264Query_TextChanged);\r
-            // \r
-            // lbl_trellis\r
-            // \r
-            this.lbl_trellis.AutoSize = true;\r
-            this.lbl_trellis.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_trellis.Location = new System.Drawing.Point(490, 169);\r
-            this.lbl_trellis.Name = "lbl_trellis";\r
-            this.lbl_trellis.Size = new System.Drawing.Size(41, 12);\r
-            this.lbl_trellis.TabIndex = 26;\r
-            this.lbl_trellis.Text = "Trellis:";\r
-            // \r
-            // label41\r
-            // \r
-            this.label41.AutoSize = true;\r
-            this.label41.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label41.Location = new System.Drawing.Point(466, 147);\r
-            this.label41.Name = "label41";\r
-            this.label41.Size = new System.Drawing.Size(65, 12);\r
-            this.label41.TabIndex = 25;\r
-            this.label41.Text = "Deblocking:";\r
-            // \r
-            // panel3\r
-            // \r
-            this.panel3.BackColor = System.Drawing.Color.Black;\r
-            this.panel3.Location = new System.Drawing.Point(396, 131);\r
-            this.panel3.Margin = new System.Windows.Forms.Padding(0);\r
-            this.panel3.Name = "panel3";\r
-            this.panel3.Size = new System.Drawing.Size(284, 1);\r
-            this.panel3.TabIndex = 24;\r
-            // \r
-            // panel1\r
-            // \r
-            this.panel1.BackColor = System.Drawing.Color.Black;\r
-            this.panel1.Location = new System.Drawing.Point(13, 84);\r
-            this.panel1.Margin = new System.Windows.Forms.Padding(0);\r
-            this.panel1.Name = "panel1";\r
-            this.panel1.Size = new System.Drawing.Size(284, 1);\r
-            this.panel1.TabIndex = 3;\r
-            // \r
-            // panel2\r
-            // \r
-            this.panel2.BackColor = System.Drawing.Color.Black;\r
-            this.panel2.Location = new System.Drawing.Point(396, 95);\r
-            this.panel2.Margin = new System.Windows.Forms.Padding(0);\r
-            this.panel2.Name = "panel2";\r
-            this.panel2.Size = new System.Drawing.Size(284, 1);\r
-            this.panel2.TabIndex = 21;\r
-            // \r
-            // label45\r
-            // \r
-            this.label45.AutoSize = true;\r
-            this.label45.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label45.Location = new System.Drawing.Point(478, 108);\r
-            this.label45.Name = "label45";\r
-            this.label45.Size = new System.Drawing.Size(53, 12);\r
-            this.label45.TabIndex = 22;\r
-            this.label45.Text = "Analysis:";\r
-            // \r
-            // label48\r
-            // \r
-            this.label48.AutoSize = true;\r
-            this.label48.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label48.Location = new System.Drawing.Point(385, 72);\r
-            this.label48.Name = "label48";\r
-            this.label48.Size = new System.Drawing.Size(146, 12);\r
-            this.label48.TabIndex = 20;\r
-            this.label48.Text = "Subpixel Motion Estimation:";\r
-            // \r
-            // label49\r
-            // \r
-            this.label49.AutoSize = true;\r
-            this.label49.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label49.Location = new System.Drawing.Point(397, 43);\r
-            this.label49.Name = "label49";\r
-            this.label49.Size = new System.Drawing.Size(134, 12);\r
-            this.label49.TabIndex = 19;\r
-            this.label49.Text = "Motion Estimation Range:";\r
-            // \r
-            // label54\r
-            // \r
-            this.label54.AutoSize = true;\r
-            this.label54.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label54.Location = new System.Drawing.Point(391, 14);\r
-            this.label54.Name = "label54";\r
-            this.label54.Size = new System.Drawing.Size(140, 12);\r
-            this.label54.TabIndex = 18;\r
-            this.label54.Text = "Motion Estimation Method:";\r
-            // \r
-            // lbl_direct_prediction\r
-            // \r
-            this.lbl_direct_prediction.AutoSize = true;\r
-            this.lbl_direct_prediction.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_direct_prediction.Location = new System.Drawing.Point(52, 121);\r
-            this.lbl_direct_prediction.Name = "lbl_direct_prediction";\r
-            this.lbl_direct_prediction.Size = new System.Drawing.Size(94, 12);\r
-            this.lbl_direct_prediction.TabIndex = 5;\r
-            this.lbl_direct_prediction.Text = "Direct Prediction:";\r
-            // \r
-            // label62\r
-            // \r
-            this.label62.AutoSize = true;\r
-            this.label62.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label62.Location = new System.Drawing.Point(88, 94);\r
-            this.label62.Name = "label62";\r
-            this.label62.Size = new System.Drawing.Size(58, 12);\r
-            this.label62.TabIndex = 4;\r
-            this.label62.Text = "B-Frames:";\r
-            // \r
-            // label64\r
-            // \r
-            this.label64.AutoSize = true;\r
-            this.label64.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label64.Location = new System.Drawing.Point(47, 40);\r
-            this.label64.Name = "label64";\r
-            this.label64.Size = new System.Drawing.Size(99, 12);\r
-            this.label64.TabIndex = 1;\r
-            this.label64.Text = "Reference Frames:";\r
-            // \r
-            // tabPage4\r
-            // \r
-            this.tabPage4.Controls.Add(this.btn_clear);\r
-            this.tabPage4.Controls.Add(this.label34);\r
-            this.tabPage4.Controls.Add(this.btn_generate_Query);\r
-            this.tabPage4.Controls.Add(this.label33);\r
-            this.tabPage4.Controls.Add(this.rtf_query);\r
-            this.tabPage4.Location = new System.Drawing.Point(4, 22);\r
-            this.tabPage4.Name = "tabPage4";\r
-            this.tabPage4.Size = new System.Drawing.Size(697, 316);\r
-            this.tabPage4.TabIndex = 7;\r
-            this.tabPage4.Text = "Query Editor";\r
+            // tab_advanced\r
+            // \r
+            this.tab_advanced.BackColor = System.Drawing.Color.Transparent;\r
+            this.tab_advanced.Controls.Add(this.x264Panel);\r
+            this.tab_advanced.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_advanced.Name = "tab_advanced";\r
+            this.tab_advanced.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_advanced.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_advanced.TabIndex = 8;\r
+            this.tab_advanced.Text = "Advanced";\r
+            this.tab_advanced.UseVisualStyleBackColor = true;\r
+            // \r
+            // x264Panel\r
+            // \r
+            this.x264Panel.BackColor = System.Drawing.Color.Transparent;\r
+            this.x264Panel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.x264Panel.Location = new System.Drawing.Point(0, 0);\r
+            this.x264Panel.Name = "x264Panel";\r
+            this.x264Panel.Size = new System.Drawing.Size(720, 306);\r
+            this.x264Panel.TabIndex = 0;\r
+            this.x264Panel.x264Query = "";\r
+            // \r
+            // tab_query\r
+            // \r
+            this.tab_query.Controls.Add(this.btn_clear);\r
+            this.tab_query.Controls.Add(this.label34);\r
+            this.tab_query.Controls.Add(this.btn_generate_Query);\r
+            this.tab_query.Controls.Add(this.label33);\r
+            this.tab_query.Controls.Add(this.rtf_query);\r
+            this.tab_query.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_query.Name = "tab_query";\r
+            this.tab_query.Size = new System.Drawing.Size(724, 308);\r
+            this.tab_query.TabIndex = 7;\r
+            this.tab_query.Text = "Query Editor";\r
+            this.tab_query.UseVisualStyleBackColor = true;\r
             // \r
             // btn_clear\r
             // \r
             this.btn_clear.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_clear.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_clear.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_clear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_clear.Location = new System.Drawing.Point(602, 75);\r
+            this.btn_clear.Location = new System.Drawing.Point(634, 75);\r
             this.btn_clear.Name = "btn_clear";\r
             this.btn_clear.Size = new System.Drawing.Size(75, 22);\r
             this.btn_clear.TabIndex = 4;\r
@@ -2878,7 +1100,7 @@ namespace Handbrake
             this.label34.AutoSize = true;\r
             this.label34.Location = new System.Drawing.Point(13, 36);\r
             this.label34.Name = "label34";\r
-            this.label34.Size = new System.Drawing.Size(434, 26);\r
+            this.label34.Size = new System.Drawing.Size(367, 26);\r
             this.label34.TabIndex = 1;\r
             this.label34.Text = "Here you can alter the query generated by this program.\r\nDon\'t forget to re-gener" +\r
                 "ate this query should you change any GUI options.";\r
@@ -2886,7 +1108,7 @@ namespace Handbrake
             // btn_generate_Query\r
             // \r
             this.btn_generate_Query.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_generate_Query.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_generate_Query.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_generate_Query.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
             this.btn_generate_Query.Location = new System.Drawing.Point(16, 75);\r
             this.btn_generate_Query.Name = "btn_generate_Query";\r
@@ -2900,10 +1122,10 @@ namespace Handbrake
             // \r
             this.label33.AutoSize = true;\r
             this.label33.BackColor = System.Drawing.Color.Transparent;\r
-            this.label33.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label33.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.label33.Location = new System.Drawing.Point(13, 13);\r
             this.label33.Name = "label33";\r
-            this.label33.Size = new System.Drawing.Size(89, 13);\r
+            this.label33.Size = new System.Drawing.Size(77, 13);\r
             this.label33.TabIndex = 0;\r
             this.label33.Text = "Query Editor";\r
             // \r
@@ -2912,43 +1134,17 @@ namespace Handbrake
             this.rtf_query.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
             this.rtf_query.Location = new System.Drawing.Point(16, 103);\r
             this.rtf_query.Name = "rtf_query";\r
-            this.rtf_query.Size = new System.Drawing.Size(661, 182);\r
+            this.rtf_query.Size = new System.Drawing.Size(693, 190);\r
             this.rtf_query.TabIndex = 5;\r
             this.rtf_query.Text = "";\r
             // \r
-            // groupBox_dest\r
-            // \r
-            this.groupBox_dest.Controls.Add(this.btn_destBrowse);\r
-            this.groupBox_dest.Controls.Add(this.Label3);\r
-            this.groupBox_dest.Controls.Add(this.text_destination);\r
-            this.groupBox_dest.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.groupBox_dest.ForeColor = System.Drawing.Color.Black;\r
-            this.groupBox_dest.Location = new System.Drawing.Point(12, 160);\r
-            this.groupBox_dest.Name = "groupBox_dest";\r
-            this.groupBox_dest.Size = new System.Drawing.Size(705, 50);\r
-            this.groupBox_dest.TabIndex = 3;\r
-            this.groupBox_dest.TabStop = false;\r
-            this.groupBox_dest.Text = "Destination";\r
-            // \r
-            // btn_destBrowse\r
-            // \r
-            this.btn_destBrowse.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_destBrowse.Location = new System.Drawing.Point(608, 17);\r
-            this.btn_destBrowse.Name = "btn_destBrowse";\r
-            this.btn_destBrowse.Size = new System.Drawing.Size(75, 23);\r
-            this.btn_destBrowse.TabIndex = 13;\r
-            this.btn_destBrowse.Text = "Browse";\r
-            this.btn_destBrowse.UseVisualStyleBackColor = true;\r
-            this.btn_destBrowse.Click += new System.EventHandler(this.btn_destBrowse_Click);\r
-            // \r
             // groupBox2\r
             // \r
             this.groupBox2.Controls.Add(this.splitContainer1);\r
-            this.groupBox2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.groupBox2.ForeColor = System.Drawing.Color.Black;\r
-            this.groupBox2.Location = new System.Drawing.Point(728, 70);\r
+            this.groupBox2.Location = new System.Drawing.Point(750, 70);\r
             this.groupBox2.Name = "groupBox2";\r
-            this.groupBox2.Size = new System.Drawing.Size(245, 546);\r
+            this.groupBox2.Size = new System.Drawing.Size(246, 482);\r
             this.groupBox2.TabIndex = 6;\r
             this.groupBox2.TabStop = false;\r
             this.groupBox2.Text = "Presets";\r
@@ -2969,14 +1165,15 @@ namespace Handbrake
             this.splitContainer1.Panel2.Controls.Add(this.btn_addPreset);\r
             this.splitContainer1.Panel2.Controls.Add(this.btn_removePreset);\r
             this.splitContainer1.Panel2.Controls.Add(this.btn_setDefault);\r
-            this.splitContainer1.Size = new System.Drawing.Size(239, 526);\r
-            this.splitContainer1.SplitterDistance = 485;\r
+            this.splitContainer1.Size = new System.Drawing.Size(240, 462);\r
+            this.splitContainer1.SplitterDistance = 424;\r
             this.splitContainer1.TabIndex = 1;\r
             // \r
             // treeView_presets\r
             // \r
             this.treeView_presets.ContextMenuStrip = this.presets_menu;\r
             this.treeView_presets.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.treeView_presets.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.treeView_presets.ForeColor = System.Drawing.Color.DarkBlue;\r
             this.treeView_presets.FullRowSelect = true;\r
             this.treeView_presets.HideSelection = false;\r
@@ -2984,7 +1181,7 @@ namespace Handbrake
             this.treeView_presets.Location = new System.Drawing.Point(0, 0);\r
             this.treeView_presets.Name = "treeView_presets";\r
             this.treeView_presets.ShowLines = false;\r
-            this.treeView_presets.Size = new System.Drawing.Size(239, 485);\r
+            this.treeView_presets.Size = new System.Drawing.Size(240, 424);\r
             this.treeView_presets.TabIndex = 0;\r
             this.treeView_presets.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeview_presets_mouseUp);\r
             this.treeView_presets.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_presets_AfterSelect);\r
@@ -2996,33 +1193,57 @@ namespace Handbrake
             this.pmnu_expandAll,\r
             this.pmnu_collapse,\r
             this.sep1,\r
+            this.pmnu_import,\r
+            this.toolStripSeparator2,\r
+            this.pmnu_saveChanges,\r
             this.pmnu_delete});\r
             this.presets_menu.Name = "presets_menu";\r
-            this.presets_menu.Size = new System.Drawing.Size(146, 76);\r
+            this.presets_menu.Size = new System.Drawing.Size(155, 126);\r
+            this.presets_menu.Text = ";";\r
+            this.presets_menu.Opening += new System.ComponentModel.CancelEventHandler(this.presets_menu_Opening);\r
             // \r
             // pmnu_expandAll\r
             // \r
             this.pmnu_expandAll.Name = "pmnu_expandAll";\r
-            this.pmnu_expandAll.Size = new System.Drawing.Size(145, 22);\r
+            this.pmnu_expandAll.Size = new System.Drawing.Size(154, 22);\r
             this.pmnu_expandAll.Text = "Expand All";\r
             this.pmnu_expandAll.Click += new System.EventHandler(this.pmnu_expandAll_Click);\r
             // \r
             // pmnu_collapse\r
             // \r
             this.pmnu_collapse.Name = "pmnu_collapse";\r
-            this.pmnu_collapse.Size = new System.Drawing.Size(145, 22);\r
+            this.pmnu_collapse.Size = new System.Drawing.Size(154, 22);\r
             this.pmnu_collapse.Text = "Collapse All";\r
             this.pmnu_collapse.Click += new System.EventHandler(this.pmnu_collapse_Click);\r
             // \r
             // sep1\r
             // \r
             this.sep1.Name = "sep1";\r
-            this.sep1.Size = new System.Drawing.Size(142, 6);\r
+            this.sep1.Size = new System.Drawing.Size(151, 6);\r
+            // \r
+            // pmnu_import\r
+            // \r
+            this.pmnu_import.Name = "pmnu_import";\r
+            this.pmnu_import.Size = new System.Drawing.Size(154, 22);\r
+            this.pmnu_import.Text = "Import";\r
+            this.pmnu_import.Click += new System.EventHandler(this.pmnu_import_Click);\r
+            // \r
+            // toolStripSeparator2\r
+            // \r
+            this.toolStripSeparator2.Name = "toolStripSeparator2";\r
+            this.toolStripSeparator2.Size = new System.Drawing.Size(151, 6);\r
+            // \r
+            // pmnu_saveChanges\r
+            // \r
+            this.pmnu_saveChanges.Name = "pmnu_saveChanges";\r
+            this.pmnu_saveChanges.Size = new System.Drawing.Size(154, 22);\r
+            this.pmnu_saveChanges.Text = "Save Changes";\r
+            this.pmnu_saveChanges.Click += new System.EventHandler(this.pmnu_saveChanges_Click);\r
             // \r
             // pmnu_delete\r
             // \r
             this.pmnu_delete.Name = "pmnu_delete";\r
-            this.pmnu_delete.Size = new System.Drawing.Size(145, 22);\r
+            this.pmnu_delete.Size = new System.Drawing.Size(154, 22);\r
             this.pmnu_delete.Text = "Delete";\r
             this.pmnu_delete.Click += new System.EventHandler(this.pmnu_delete_click);\r
             // \r
@@ -3036,13 +1257,12 @@ namespace Handbrake
             this.btn_add2Queue,\r
             this.btn_showQueue,\r
             this.toolStripSeparator4,\r
-            this.btn_ActivityWindow,\r
-            this.toolStripSeparator8,\r
-            this.btn_minimize});\r
+            this.tb_preview,\r
+            this.btn_ActivityWindow});\r
             this.toolStrip1.Location = new System.Drawing.Point(0, 24);\r
             this.toolStrip1.Name = "toolStrip1";\r
-            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;\r
-            this.toolStrip1.Size = new System.Drawing.Size(985, 39);\r
+            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
+            this.toolStrip1.Size = new System.Drawing.Size(1002, 39);\r
             this.toolStrip1.TabIndex = 1;\r
             this.toolStrip1.Text = "toolStrip1";\r
             // \r
@@ -3057,7 +1277,7 @@ namespace Handbrake
             this.btn_source.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_source.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_source.Name = "btn_source";\r
-            this.btn_source.Size = new System.Drawing.Size(90, 36);\r
+            this.btn_source.Size = new System.Drawing.Size(85, 36);\r
             this.btn_source.Text = "Source";\r
             this.btn_source.ToolTipText = "Open a new source file or folder.";\r
             this.btn_source.Click += new System.EventHandler(this.btn_source_Click);\r
@@ -3066,7 +1286,7 @@ namespace Handbrake
             // \r
             this.btn_file_source.Image = global::Handbrake.Properties.Resources.Movies_Small;\r
             this.btn_file_source.Name = "btn_file_source";\r
-            this.btn_file_source.Size = new System.Drawing.Size(214, 22);\r
+            this.btn_file_source.Size = new System.Drawing.Size(194, 22);\r
             this.btn_file_source.Text = "Video File";\r
             this.btn_file_source.Click += new System.EventHandler(this.btn_file_source_Click);\r
             // \r
@@ -3075,20 +1295,20 @@ namespace Handbrake
             this.btn_dvd_source.Image = ((System.Drawing.Image)(resources.GetObject("btn_dvd_source.Image")));\r
             this.btn_dvd_source.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_dvd_source.Name = "btn_dvd_source";\r
-            this.btn_dvd_source.Size = new System.Drawing.Size(214, 22);\r
+            this.btn_dvd_source.Size = new System.Drawing.Size(194, 22);\r
             this.btn_dvd_source.Text = "DVD/ VIDEO_TS Folder";\r
             this.btn_dvd_source.Click += new System.EventHandler(this.btn_dvd_source_Click);\r
             // \r
             // toolStripSeparator1\r
             // \r
             this.toolStripSeparator1.Name = "toolStripSeparator1";\r
-            this.toolStripSeparator1.Size = new System.Drawing.Size(211, 6);\r
+            this.toolStripSeparator1.Size = new System.Drawing.Size(191, 6);\r
             // \r
             // mnu_dvd_drive\r
             // \r
             this.mnu_dvd_drive.Image = global::Handbrake.Properties.Resources.disc_small;\r
             this.mnu_dvd_drive.Name = "mnu_dvd_drive";\r
-            this.mnu_dvd_drive.Size = new System.Drawing.Size(214, 22);\r
+            this.mnu_dvd_drive.Size = new System.Drawing.Size(194, 22);\r
             this.mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
             this.mnu_dvd_drive.Visible = false;\r
             this.mnu_dvd_drive.Click += new System.EventHandler(this.mnu_dvd_drive_Click);\r
@@ -3104,7 +1324,7 @@ namespace Handbrake
             this.btn_start.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_start.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_start.Name = "btn_start";\r
-            this.btn_start.Size = new System.Drawing.Size(70, 36);\r
+            this.btn_start.Size = new System.Drawing.Size(67, 36);\r
             this.btn_start.Text = "Start";\r
             this.btn_start.ToolTipText = "Start the encoding process";\r
             this.btn_start.Click += new System.EventHandler(this.btn_start_Click);\r
@@ -3115,7 +1335,7 @@ namespace Handbrake
             this.btn_add2Queue.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_add2Queue.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_add2Queue.Name = "btn_add2Queue";\r
-            this.btn_add2Queue.Size = new System.Drawing.Size(122, 36);\r
+            this.btn_add2Queue.Size = new System.Drawing.Size(110, 36);\r
             this.btn_add2Queue.Text = "Add to Queue";\r
             this.btn_add2Queue.ToolTipText = "Add a new item to the Queue";\r
             this.btn_add2Queue.Click += new System.EventHandler(this.btn_add2Queue_Click);\r
@@ -3126,7 +1346,7 @@ namespace Handbrake
             this.btn_showQueue.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_showQueue.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_showQueue.Name = "btn_showQueue";\r
-            this.btn_showQueue.Size = new System.Drawing.Size(115, 36);\r
+            this.btn_showQueue.Size = new System.Drawing.Size(104, 36);\r
             this.btn_showQueue.Tag = "";\r
             this.btn_showQueue.Text = "Show Queue";\r
             this.btn_showQueue.Click += new System.EventHandler(this.btn_showQueue_Click);\r
@@ -3136,32 +1356,28 @@ namespace Handbrake
             this.toolStripSeparator4.Name = "toolStripSeparator4";\r
             this.toolStripSeparator4.Size = new System.Drawing.Size(6, 39);\r
             // \r
+            // tb_preview\r
+            // \r
+            this.tb_preview.Image = global::Handbrake.Properties.Resources.window;\r
+            this.tb_preview.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
+            this.tb_preview.ImageTransparentColor = System.Drawing.Color.Magenta;\r
+            this.tb_preview.Name = "tb_preview";\r
+            this.tb_preview.Size = new System.Drawing.Size(81, 36);\r
+            this.tb_preview.Text = "Preview";\r
+            this.tb_preview.Click += new System.EventHandler(this.tb_preview_Click);\r
+            // \r
             // btn_ActivityWindow\r
             // \r
             this.btn_ActivityWindow.Image = global::Handbrake.Properties.Resources.ActivityWindow;\r
             this.btn_ActivityWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_ActivityWindow.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_ActivityWindow.Name = "btn_ActivityWindow";\r
-            this.btn_ActivityWindow.Size = new System.Drawing.Size(132, 36);\r
+            this.btn_ActivityWindow.Size = new System.Drawing.Size(120, 36);\r
             this.btn_ActivityWindow.Text = "Activity Window";\r
             this.btn_ActivityWindow.ToolTipText = "Displays the activity window which displays the log of the last completed or curr" +\r
                 "ently running encode.";\r
             this.btn_ActivityWindow.Click += new System.EventHandler(this.btn_ActivityWindow_Click);\r
             // \r
-            // toolStripSeparator8\r
-            // \r
-            this.toolStripSeparator8.Name = "toolStripSeparator8";\r
-            this.toolStripSeparator8.Size = new System.Drawing.Size(6, 39);\r
-            // \r
-            // btn_minimize\r
-            // \r
-            this.btn_minimize.Image = global::Handbrake.Properties.Resources.hb32;\r
-            this.btn_minimize.ImageTransparentColor = System.Drawing.Color.Magenta;\r
-            this.btn_minimize.Name = "btn_minimize";\r
-            this.btn_minimize.Size = new System.Drawing.Size(162, 36);\r
-            this.btn_minimize.Text = "Minimize To System Tray";\r
-            this.btn_minimize.Click += new System.EventHandler(this.btn_minimize_Click);\r
-            // \r
             // notifyIcon\r
             // \r
             this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;\r
@@ -3175,72 +1391,300 @@ namespace Handbrake
             // StatusStrip\r
             // \r
             this.StatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.lbl_encode});\r
-            this.StatusStrip.Location = new System.Drawing.Point(0, 629);\r
+            this.lbl_encode,\r
+            this.lbl_updateCheck});\r
+            this.StatusStrip.Location = new System.Drawing.Point(0, 561);\r
             this.StatusStrip.Name = "StatusStrip";\r
-            this.StatusStrip.Size = new System.Drawing.Size(985, 22);\r
+            this.StatusStrip.Size = new System.Drawing.Size(1002, 22);\r
+            this.StatusStrip.SizingGrip = false;\r
             this.StatusStrip.TabIndex = 7;\r
             this.StatusStrip.Text = "statusStrip1";\r
             // \r
             // lbl_encode\r
             // \r
-            this.lbl_encode.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_encode.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.lbl_encode.Name = "lbl_encode";\r
-            this.lbl_encode.Size = new System.Drawing.Size(31, 17);\r
+            this.lbl_encode.Size = new System.Drawing.Size(28, 17);\r
             this.lbl_encode.Text = "{0}";\r
             // \r
+            // lbl_updateCheck\r
+            // \r
+            this.lbl_updateCheck.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_updateCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
+            this.lbl_updateCheck.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_updateCheck.Name = "lbl_updateCheck";\r
+            this.lbl_updateCheck.Size = new System.Drawing.Size(139, 17);\r
+            this.lbl_updateCheck.Text = "Checking for Updates ...";\r
+            this.lbl_updateCheck.Visible = false;\r
+            // \r
+            // hbproc\r
+            // \r
+            this.hbproc.StartInfo.Domain = "";\r
+            this.hbproc.StartInfo.LoadUserProfile = false;\r
+            this.hbproc.StartInfo.Password = null;\r
+            this.hbproc.StartInfo.StandardErrorEncoding = null;\r
+            this.hbproc.StartInfo.StandardOutputEncoding = null;\r
+            this.hbproc.StartInfo.UserName = "";\r
+            this.hbproc.SynchronizingObject = this;\r
+            // \r
+            // File_Save\r
+            // \r
+            this.File_Save.DefaultExt = "hb";\r
+            this.File_Save.Filter = "hb|*.hb";\r
+            // \r
+            // tableLayoutPanel2\r
+            // \r
+            this.tableLayoutPanel2.AutoSize = true;\r
+            this.tableLayoutPanel2.ColumnCount = 3;\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.Controls.Add(this.Label3, 0, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.text_destination, 1, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.btn_destBrowse, 2, 0);\r
+            this.tableLayoutPanel2.Location = new System.Drawing.Point(21, 132);\r
+            this.tableLayoutPanel2.Name = "tableLayoutPanel2";\r
+            this.tableLayoutPanel2.RowCount = 1;\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F));\r
+            this.tableLayoutPanel2.Size = new System.Drawing.Size(723, 29);\r
+            this.tableLayoutPanel2.TabIndex = 50;\r
+            // \r
+            // btn_destBrowse\r
+            // \r
+            this.btn_destBrowse.AutoSize = true;\r
+            this.btn_destBrowse.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_destBrowse.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_destBrowse.Location = new System.Drawing.Point(645, 3);\r
+            this.btn_destBrowse.Name = "btn_destBrowse";\r
+            this.btn_destBrowse.Size = new System.Drawing.Size(75, 23);\r
+            this.btn_destBrowse.TabIndex = 13;\r
+            this.btn_destBrowse.Text = "Browse";\r
+            this.btn_destBrowse.UseVisualStyleBackColor = true;\r
+            this.btn_destBrowse.Click += new System.EventHandler(this.btn_destBrowse_Click);\r
+            // \r
+            // tableLayoutPanel3\r
+            // \r
+            this.tableLayoutPanel3.AutoSize = true;\r
+            this.tableLayoutPanel3.ColumnCount = 5;\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.Controls.Add(this.label5, 0, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.drop_format, 1, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_largeFile, 2, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_optimiseMP4, 3, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_iPodAtom, 4, 0);\r
+            this.tableLayoutPanel3.Location = new System.Drawing.Point(21, 180);\r
+            this.tableLayoutPanel3.Name = "tableLayoutPanel3";\r
+            this.tableLayoutPanel3.RowCount = 1;\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel3.Size = new System.Drawing.Size(723, 27);\r
+            this.tableLayoutPanel3.TabIndex = 51;\r
+            // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.AutoSize = true;\r
+            this.tableLayoutPanel1.ColumnCount = 10;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.Label10, 0, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.drp_dvdtitle, 1, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_angle, 2, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_angle, 3, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.Label9, 4, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_chapterStart, 5, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.Label13, 6, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.drop_chapterFinish, 7, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.label_duration, 8, 0);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_duration, 9, 0);\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(21, 86);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 1;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(723, 27);\r
+            this.tableLayoutPanel1.TabIndex = 49;\r
+            // \r
+            // Label10\r
+            // \r
+            this.Label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.Label10.AutoSize = true;\r
+            this.Label10.ForeColor = System.Drawing.Color.Black;\r
+            this.Label10.Location = new System.Drawing.Point(3, 7);\r
+            this.Label10.Name = "Label10";\r
+            this.Label10.Size = new System.Drawing.Size(31, 13);\r
+            this.Label10.TabIndex = 6;\r
+            this.Label10.Text = "Title:";\r
+            // \r
+            // lbl_angle\r
+            // \r
+            this.lbl_angle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.lbl_angle.AutoSize = true;\r
+            this.lbl_angle.ForeColor = System.Drawing.Color.Black;\r
+            this.lbl_angle.Location = new System.Drawing.Point(165, 7);\r
+            this.lbl_angle.Name = "lbl_angle";\r
+            this.lbl_angle.Size = new System.Drawing.Size(38, 13);\r
+            this.lbl_angle.TabIndex = 44;\r
+            this.lbl_angle.Text = "Angle:";\r
+            // \r
+            // Label9\r
+            // \r
+            this.Label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.Label9.AutoSize = true;\r
+            this.Label9.ForeColor = System.Drawing.Color.Black;\r
+            this.Label9.Location = new System.Drawing.Point(260, 7);\r
+            this.Label9.Name = "Label9";\r
+            this.Label9.Size = new System.Drawing.Size(55, 13);\r
+            this.Label9.TabIndex = 8;\r
+            this.Label9.Text = "Chapters:";\r
+            // \r
+            // Label13\r
+            // \r
+            this.Label13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.Label13.AutoSize = true;\r
+            this.Label13.Location = new System.Drawing.Point(396, 7);\r
+            this.Label13.Name = "Label13";\r
+            this.Label13.Size = new System.Drawing.Size(45, 13);\r
+            this.Label13.TabIndex = 10;\r
+            this.Label13.Text = "through";\r
+            // \r
+            // label_duration\r
+            // \r
+            this.label_duration.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label_duration.AutoSize = true;\r
+            this.label_duration.BackColor = System.Drawing.Color.Transparent;\r
+            this.label_duration.Location = new System.Drawing.Point(522, 7);\r
+            this.label_duration.Name = "label_duration";\r
+            this.label_duration.Size = new System.Drawing.Size(52, 13);\r
+            this.label_duration.TabIndex = 42;\r
+            this.label_duration.Text = "Duration:";\r
+            // \r
+            // lbl_duration\r
+            // \r
+            this.lbl_duration.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.lbl_duration.AutoSize = true;\r
+            this.lbl_duration.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_duration.Location = new System.Drawing.Point(580, 7);\r
+            this.lbl_duration.Name = "lbl_duration";\r
+            this.lbl_duration.Size = new System.Drawing.Size(39, 13);\r
+            this.lbl_duration.TabIndex = 43;\r
+            this.lbl_duration.Text = "--:--:--";\r
+            // \r
+            // labelStaticDestination\r
+            // \r
+            this.labelStaticDestination.AutoSize = true;\r
+            this.labelStaticDestination.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.labelStaticDestination.Location = new System.Drawing.Point(9, 116);\r
+            this.labelStaticDestination.Name = "labelStaticDestination";\r
+            this.labelStaticDestination.Size = new System.Drawing.Size(75, 13);\r
+            this.labelStaticDestination.TabIndex = 53;\r
+            this.labelStaticDestination.Text = "Destination:";\r
+            // \r
+            // labelPreset\r
+            // \r
+            this.labelPreset.AutoSize = true;\r
+            this.labelPreset.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.labelPreset.Location = new System.Drawing.Point(9, 164);\r
+            this.labelPreset.Name = "labelPreset";\r
+            this.labelPreset.Size = new System.Drawing.Size(180, 13);\r
+            this.labelPreset.TabIndex = 54;\r
+            this.labelPreset.Text = "Output Settings (Preset: None)";\r
+            // \r
+            // labelSource\r
+            // \r
+            this.labelSource.AutoSize = true;\r
+            this.labelSource.Location = new System.Drawing.Point(55, 0);\r
+            this.labelSource.Name = "labelSource";\r
+            this.labelSource.Size = new System.Drawing.Size(137, 13);\r
+            this.labelSource.TabIndex = 52;\r
+            this.labelSource.Text = "Select \"Source\" to continue";\r
+            // \r
+            // labelStaticSource\r
+            // \r
+            this.labelStaticSource.AutoSize = true;\r
+            this.labelStaticSource.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.labelStaticSource.Location = new System.Drawing.Point(0, 0);\r
+            this.labelStaticSource.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);\r
+            this.labelStaticSource.Name = "labelStaticSource";\r
+            this.labelStaticSource.Size = new System.Drawing.Size(49, 13);\r
+            this.labelStaticSource.TabIndex = 51;\r
+            this.labelStaticSource.Text = "Source:";\r
+            // \r
+            // flowLayoutPanel1\r
+            // \r
+            this.flowLayoutPanel1.AutoSize = true;\r
+            this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.flowLayoutPanel1.Controls.Add(this.labelStaticSource);\r
+            this.flowLayoutPanel1.Controls.Add(this.labelSource);\r
+            this.flowLayoutPanel1.Location = new System.Drawing.Point(9, 70);\r
+            this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);\r
+            this.flowLayoutPanel1.Name = "flowLayoutPanel1";\r
+            this.flowLayoutPanel1.Size = new System.Drawing.Size(195, 13);\r
+            this.flowLayoutPanel1.TabIndex = 55;\r
+            // \r
+            // openPreset\r
+            // \r
+            this.openPreset.DefaultExt = "plist";\r
+            this.openPreset.Filter = "Plist Files|*.plist";\r
+            // \r
+            // File_ChapterImport\r
+            // \r
+            this.File_ChapterImport.Filter = "CSV Files|*.csv";\r
+            // \r
             // frmMain\r
             // \r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(985, 651);\r
-            this.Controls.Add(this.GroupBox1);\r
-            this.Controls.Add(this.groupBox_dest);\r
-            this.Controls.Add(this.groupBox_output);\r
-            this.Controls.Add(this.groupBox2);\r
+            this.AllowDrop = true;\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;\r
+            this.AutoScroll = true;\r
+            this.AutoSize = true;\r
+            this.ClientSize = new System.Drawing.Size(1002, 583);\r
+            this.Controls.Add(this.tableLayoutPanel3);\r
             this.Controls.Add(this.toolStrip1);\r
-            this.Controls.Add(this.advancedOptions);\r
+            this.Controls.Add(this.flowLayoutPanel1);\r
             this.Controls.Add(this.frmMainMenu);\r
+            this.Controls.Add(this.tableLayoutPanel2);\r
+            this.Controls.Add(this.labelPreset);\r
+            this.Controls.Add(this.groupBox2);\r
             this.Controls.Add(this.StatusStrip);\r
+            this.Controls.Add(this.labelStaticDestination);\r
+            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.Controls.Add(this.tabs_panel);\r
             this.DoubleBuffered = true;\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
-            this.MinimumSize = new System.Drawing.Size(946, 668);\r
+            this.MinimumSize = new System.Drawing.Size(900, 500);\r
             this.Name = "frmMain";\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "HandBrake";\r
             notifyIconMenu.ResumeLayout(false);\r
             ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).EndInit();\r
             ((System.ComponentModel.ISupportInitialize)(this.data_chpt)).EndInit();\r
+            this.ChaptersMenu.ResumeLayout(false);\r
             this.frmMainMenu.ResumeLayout(false);\r
             this.frmMainMenu.PerformLayout();\r
-            this.GroupBox1.ResumeLayout(false);\r
-            this.GroupBox1.PerformLayout();\r
-            this.groupBox_output.ResumeLayout(false);\r
-            this.groupBox_output.PerformLayout();\r
-            this.TabPage2.ResumeLayout(false);\r
-            this.TabPage2.PerformLayout();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();\r
-            this.TabPage3.ResumeLayout(false);\r
-            this.TabPage3.PerformLayout();\r
-            this.TabPage1.ResumeLayout(false);\r
-            this.TabPage1.PerformLayout();\r
-            ((System.ComponentModel.ISupportInitialize)(this.slider_deblock)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_bottom)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_top)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_left)).EndInit();\r
-            ((System.ComponentModel.ISupportInitialize)(this.text_right)).EndInit();\r
-            this.advancedOptions.ResumeLayout(false);\r
+            this.tab_audio.ResumeLayout(false);\r
+            this.tab_video.ResumeLayout(false);\r
+            this.tab_video.PerformLayout();\r
+            this.tab_picture.ResumeLayout(false);\r
+            this.tabs_panel.ResumeLayout(false);\r
+            this.tab_filters.ResumeLayout(false);\r
+            this.tab_subtitles.ResumeLayout(false);\r
             this.tab_chapters.ResumeLayout(false);\r
             this.tab_chapters.PerformLayout();\r
-            this.h264Tab.ResumeLayout(false);\r
-            this.h264Tab.PerformLayout();\r
-            this.tabPage4.ResumeLayout(false);\r
-            this.tabPage4.PerformLayout();\r
-            this.groupBox_dest.ResumeLayout(false);\r
-            this.groupBox_dest.PerformLayout();\r
+            this.tab_advanced.ResumeLayout(false);\r
+            this.tab_query.ResumeLayout(false);\r
+            this.tab_query.PerformLayout();\r
             this.groupBox2.ResumeLayout(false);\r
             this.splitContainer1.Panel1.ResumeLayout(false);\r
             this.splitContainer1.Panel2.ResumeLayout(false);\r
@@ -3250,6 +1694,14 @@ namespace Handbrake
             this.toolStrip1.PerformLayout();\r
             this.StatusStrip.ResumeLayout(false);\r
             this.StatusStrip.PerformLayout();\r
+            this.tableLayoutPanel2.ResumeLayout(false);\r
+            this.tableLayoutPanel2.PerformLayout();\r
+            this.tableLayoutPanel3.ResumeLayout(false);\r
+            this.tableLayoutPanel3.PerformLayout();\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
+            this.flowLayoutPanel1.ResumeLayout(false);\r
+            this.flowLayoutPanel1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -3257,7 +1709,6 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-        internal System.Windows.Forms.SaveFileDialog File_Save;\r
         internal System.Windows.Forms.ToolTip ToolTip;\r
         internal System.Windows.Forms.ToolStripMenuItem FileToolStripMenuItem;\r
         internal System.Windows.Forms.ToolStripMenuItem mnu_open3;\r
@@ -3272,58 +1723,25 @@ namespace Handbrake
         internal System.Windows.Forms.ToolStripSeparator ToolStripSeparator3;\r
         internal System.Windows.Forms.ToolStripMenuItem mnu_about;\r
         internal System.Windows.Forms.MenuStrip frmMainMenu;\r
-        internal System.Windows.Forms.GroupBox GroupBox1;\r
-        internal System.Windows.Forms.Label Label13;\r
-        internal System.Windows.Forms.ComboBox drop_chapterFinish;\r
-        internal System.Windows.Forms.ComboBox drop_chapterStart;\r
-        internal System.Windows.Forms.ComboBox drp_dvdtitle;\r
-        internal System.Windows.Forms.Label Label17;\r
-        internal System.Windows.Forms.TextBox text_source;\r
-        internal System.Windows.Forms.Label Label9;\r
-        internal System.Windows.Forms.Label Label10;\r
-        internal System.Windows.Forms.GroupBox groupBox_output;\r
         internal System.Windows.Forms.Label Label3;\r
         internal System.Windows.Forms.ComboBox drp_videoEncoder;\r
         internal System.Windows.Forms.Label Label47;\r
         internal System.Windows.Forms.TextBox text_destination;\r
-        internal System.Windows.Forms.TabPage TabPage2;\r
-        internal System.Windows.Forms.ComboBox drp_audmix_1;\r
-        internal System.Windows.Forms.ComboBox drp_track1Audio;\r
-        internal System.Windows.Forms.ComboBox drp_audbit_1;\r
-        internal System.Windows.Forms.Label Label32;\r
-        internal System.Windows.Forms.ComboBox drp_audsr_1;\r
-        internal System.Windows.Forms.TabPage TabPage3;\r
+        internal System.Windows.Forms.TabPage tab_audio;\r
+        internal System.Windows.Forms.TabPage tab_video;\r
         internal System.Windows.Forms.CheckBox check_largeFile;\r
         internal System.Windows.Forms.CheckBox check_turbo;\r
-        internal System.Windows.Forms.Label Label22;\r
         internal System.Windows.Forms.Label Label2;\r
         internal System.Windows.Forms.Label SliderValue;\r
         internal System.Windows.Forms.ComboBox drp_videoFramerate;\r
         internal System.Windows.Forms.CheckBox check_2PassEncode;\r
         internal System.Windows.Forms.TrackBar slider_videoQuality;\r
         internal System.Windows.Forms.TextBox text_filesize;\r
-        internal System.Windows.Forms.Label Label40;\r
         internal System.Windows.Forms.TextBox text_bitrate;\r
-        internal System.Windows.Forms.Label Label42;\r
-        internal System.Windows.Forms.TabPage TabPage1;\r
+        internal System.Windows.Forms.TabPage tab_picture;\r
         internal System.Windows.Forms.CheckBox Check_ChapterMarkers;\r
-        internal System.Windows.Forms.Label Label1;\r
-        internal System.Windows.Forms.Label Label53;\r
-        internal System.Windows.Forms.Label Label52;\r
-        internal System.Windows.Forms.Label Label51;\r
-        internal System.Windows.Forms.Label Label15;\r
-        internal System.Windows.Forms.TabControl advancedOptions;\r
+        internal System.Windows.Forms.TabControl tabs_panel;\r
         internal System.Windows.Forms.Label Label46;\r
-        private System.Windows.Forms.GroupBox groupBox_dest;\r
-        internal System.Windows.Forms.ComboBox drp_subtitle;\r
-        internal System.Windows.Forms.Label Label19;\r
-        internal System.Windows.Forms.Label Label20;\r
-        internal System.Windows.Forms.CheckBox check_grayscale;\r
-        internal System.Windows.Forms.Label label24;\r
-        internal System.Windows.Forms.Label label11;\r
-        internal System.Windows.Forms.CheckBox check_detelecine;\r
-        internal System.Windows.Forms.Label label4;\r
-        internal System.Windows.Forms.ComboBox drp_deInterlace_option;\r
         private System.Windows.Forms.GroupBox groupBox2;\r
         internal System.Windows.Forms.Button btn_setDefault;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_SelectDefault;\r
@@ -3333,26 +1751,11 @@ namespace Handbrake
         private System.Windows.Forms.OpenFileDialog File_Open;\r
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;\r
         internal System.Windows.Forms.CheckBox check_iPodAtom;\r
-        internal System.Windows.Forms.Label label26;\r
-        internal System.Windows.Forms.Label Label56;\r
-        internal System.Windows.Forms.Label lbl_Aspect;\r
-        internal System.Windows.Forms.Label Label91;\r
-        internal System.Windows.Forms.TextBox text_height;\r
-        internal System.Windows.Forms.Label Label55;\r
-        internal System.Windows.Forms.TextBox text_width;\r
-        internal System.Windows.Forms.Label label27;\r
-        internal System.Windows.Forms.ComboBox drp_track2Audio;\r
-        internal System.Windows.Forms.Label label28;\r
         private System.Windows.Forms.TabPage tab_chapters;\r
         internal System.Windows.Forms.Label label31;\r
-        internal System.Windows.Forms.NumericUpDown text_right;\r
-        internal System.Windows.Forms.NumericUpDown text_bottom;\r
-        internal System.Windows.Forms.NumericUpDown text_top;\r
-        internal System.Windows.Forms.NumericUpDown text_left;\r
         internal System.Windows.Forms.CheckBox check_optimiseMP4;\r
-        internal System.Windows.Forms.CheckBox check_forced;\r
         internal System.Windows.Forms.DataGridView data_chpt;\r
-        private System.Windows.Forms.TabPage tabPage4;\r
+        private System.Windows.Forms.TabPage tab_query;\r
         private System.Windows.Forms.Label label34;\r
         internal System.Windows.Forms.Button btn_generate_Query;\r
         internal System.Windows.Forms.Label label33;\r
@@ -3363,91 +1766,15 @@ namespace Handbrake
         private System.Windows.Forms.ToolStripButton btn_showQueue;\r
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;\r
         private System.Windows.Forms.ToolStripButton btn_ActivityWindow;\r
-        private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_handbrake_home;\r
         internal System.Windows.Forms.Button btn_removePreset;\r
         internal System.Windows.Forms.Button btn_addPreset;\r
         internal System.Windows.Forms.Label label25;\r
-        internal System.Windows.Forms.Label label6;\r
-        internal System.Windows.Forms.ComboBox drp_anamorphic;\r
-        internal System.Windows.Forms.TabPage h264Tab;\r
-        internal System.Windows.Forms.RichTextBox rtf_x264Query;\r
-        internal System.Windows.Forms.Label label43;\r
-        internal System.Windows.Forms.Button btn_reset;\r
-        internal System.Windows.Forms.CheckBox check_Cabac;\r
-        internal System.Windows.Forms.CheckBox check_noDCTDecimate;\r
-        internal System.Windows.Forms.CheckBox check_noFastPSkip;\r
-        internal System.Windows.Forms.Label lbl_trellis;\r
-        internal System.Windows.Forms.ComboBox drop_trellis;\r
-        internal System.Windows.Forms.ComboBox drop_deblockBeta;\r
-        internal System.Windows.Forms.Label label41;\r
-        internal System.Windows.Forms.ComboBox drop_deblockAlpha;\r
-        internal System.Windows.Forms.Panel panel3;\r
-        internal System.Windows.Forms.Panel panel1;\r
-        internal System.Windows.Forms.Panel panel2;\r
-        internal System.Windows.Forms.CheckBox check_8x8DCT;\r
-        internal System.Windows.Forms.Label label45;\r
-        internal System.Windows.Forms.ComboBox drop_analysis;\r
-        internal System.Windows.Forms.Label label48;\r
-        internal System.Windows.Forms.ComboBox drop_subpixelMotionEstimation;\r
-        internal System.Windows.Forms.Label label49;\r
-        internal System.Windows.Forms.ComboBox drop_MotionEstimationRange;\r
-        internal System.Windows.Forms.Label label54;\r
-        internal System.Windows.Forms.ComboBox drop_MotionEstimationMethod;\r
-        internal System.Windows.Forms.CheckBox check_pyrmidalBFrames;\r
-        internal System.Windows.Forms.CheckBox check_weightedBFrames;\r
-        internal System.Windows.Forms.Label lbl_direct_prediction;\r
-        internal System.Windows.Forms.ComboBox drop_directPrediction;\r
-        internal System.Windows.Forms.Label label62;\r
-        internal System.Windows.Forms.ComboBox drop_bFrames;\r
-        internal System.Windows.Forms.Label label64;\r
-        internal System.Windows.Forms.ComboBox drop_refFrames;\r
-        internal System.Windows.Forms.CheckBox check_mixedReferences;\r
-        internal System.Windows.Forms.ComboBox drp_audmix_2;\r
-        internal System.Windows.Forms.Label label65;\r
-        internal System.Windows.Forms.Label label14;\r
-        internal System.Windows.Forms.ComboBox drp_audenc_2;\r
-        internal System.Windows.Forms.ComboBox drp_audenc_1;\r
-        internal System.Windows.Forms.Label label66;\r
-        internal System.Windows.Forms.ComboBox drp_audbit_2;\r
-        internal System.Windows.Forms.Label label67;\r
-        internal System.Windows.Forms.ComboBox drp_audsr_2;\r
-        internal System.Windows.Forms.Label label68;\r
-        private System.Windows.Forms.DataGridViewTextBoxColumn number;\r
-        private System.Windows.Forms.DataGridViewTextBoxColumn name;\r
-        private System.Windows.Forms.GroupBox groupBox3;\r
-        private System.Windows.Forms.GroupBox groupBox5;\r
-        private System.Windows.Forms.Button btn_destBrowse;\r
-        internal System.Windows.Forms.TrackBar trackBar1;\r
-        internal System.Windows.Forms.Label lbl_drc4;\r
-        internal System.Windows.Forms.Label lbl_drc3;\r
-        internal System.Windows.Forms.Label lbl_drc2;\r
-        internal System.Windows.Forms.TrackBar trackBar4;\r
-        internal System.Windows.Forms.ComboBox drp_audsr_4;\r
-        internal System.Windows.Forms.ComboBox drp_audbit_4;\r
-        internal System.Windows.Forms.ComboBox drp_audenc_4;\r
-        internal System.Windows.Forms.ComboBox drp_audmix_4;\r
-        internal System.Windows.Forms.ComboBox drp_track4Audio;\r
-        internal System.Windows.Forms.Label lbl_t4;\r
-        internal System.Windows.Forms.TrackBar trackBar3;\r
-        internal System.Windows.Forms.ComboBox drp_audsr_3;\r
-        internal System.Windows.Forms.ComboBox drp_audbit_3;\r
-        internal System.Windows.Forms.ComboBox drp_audenc_3;\r
-        internal System.Windows.Forms.ComboBox drp_audmix_3;\r
-        internal System.Windows.Forms.ComboBox drp_track3Audio;\r
-        internal System.Windows.Forms.Label lbl_t3;\r
-        internal System.Windows.Forms.TrackBar trackBar2;\r
-        internal System.Windows.Forms.Label label16;\r
-        internal System.Windows.Forms.Label lbl_drc1;\r
+        internal System.Windows.Forms.TabPage tab_advanced;\r
         internal System.Windows.Forms.TreeView treeView_presets;\r
         internal System.Windows.Forms.RichTextBox rtf_query;\r
         private System.Windows.Forms.NotifyIcon notifyIcon;\r
-        private System.Windows.Forms.ToolStripButton btn_minimize;\r
         private System.Windows.Forms.ToolStripMenuItem btn_restore;\r
-        internal System.Windows.Forms.Label lbl_src_res;\r
-        internal System.Windows.Forms.Label label7;\r
-        internal System.Windows.Forms.Label lbl_duration;\r
-        internal System.Windows.Forms.Label label_duration;\r
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator10;\r
         private System.Windows.Forms.ToolStripMenuItem btn_file_source;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_delete_preset;\r
@@ -3462,13 +1789,6 @@ namespace Handbrake
         internal System.Windows.Forms.ToolStripMenuItem mnu_encodeLog;\r
         private System.Windows.Forms.StatusStrip StatusStrip;\r
         private System.Windows.Forms.ToolStripStatusLabel lbl_encode;\r
-        internal System.Windows.Forms.CheckBox check_decomb;\r
-        internal System.Windows.Forms.RadioButton check_customCrop;\r
-        internal System.Windows.Forms.RadioButton check_autoCrop;\r
-        internal System.Windows.Forms.Label lbl_deblockVal;\r
-        internal System.Windows.Forms.TrackBar slider_deblock;\r
-        internal System.Windows.Forms.ComboBox drp_deNoise;\r
-        internal System.Windows.Forms.Label label8;\r
         internal System.Windows.Forms.OpenFileDialog ISO_Open;\r
         internal System.Windows.Forms.FolderBrowserDialog DVD_Open;\r
         internal System.Windows.Forms.ToolStripMenuItem mnu_dvd_drive;\r
@@ -3478,6 +1798,51 @@ namespace Handbrake
         private System.Windows.Forms.ToolStripSeparator sep1;\r
         private System.Windows.Forms.ToolStripMenuItem pmnu_delete;\r
         private System.Windows.Forms.SplitContainer splitContainer1;\r
-\r
+        private System.Windows.Forms.ImageList AudioMenuRowHeightHack;\r
+        private System.Windows.Forms.ToolStripMenuItem pmnu_saveChanges;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_killCLI;\r
+        private System.Windows.Forms.TabPage tab_filters;\r
+        internal System.Windows.Forms.RadioButton radio_cq;\r
+        internal System.Windows.Forms.RadioButton radio_avgBitrate;\r
+        internal System.Windows.Forms.RadioButton radio_targetFilesize;\r
+        internal Handbrake.Controls.x264Panel x264Panel;\r
+        private System.Windows.Forms.ToolStripButton tb_preview;\r
+        private System.Windows.Forms.DataGridViewTextBoxColumn number;\r
+        private System.Windows.Forms.DataGridViewTextBoxColumn name;\r
+        private System.Diagnostics.Process hbproc;\r
+        private TabPage tab_subtitles;\r
+        internal Handbrake.Controls.AudioPanel AudioSettings;\r
+        internal Handbrake.Controls.Subtitles Subtitles;\r
+        internal Handbrake.Controls.Filters Filters;\r
+        private ToolStripStatusLabel lbl_updateCheck;\r
+        internal SaveFileDialog File_Save;\r
+        private TableLayoutPanel tableLayoutPanel2;\r
+        private Button btn_destBrowse;\r
+        private TableLayoutPanel tableLayoutPanel3;\r
+        private TableLayoutPanel tableLayoutPanel1;\r
+        internal Label lbl_angle;\r
+        internal ComboBox drop_angle;\r
+        internal Label Label9;\r
+        internal ComboBox drop_chapterStart;\r
+        internal Label Label13;\r
+        internal ComboBox drop_chapterFinish;\r
+        internal Label label_duration;\r
+        internal Label lbl_duration;\r
+        private Label labelStaticDestination;\r
+        internal Label labelPreset;\r
+        internal Handbrake.Controls.PictureSettings PictureSettings;\r
+        private Label labelSource;\r
+        internal ComboBox drp_dvdtitle;\r
+        internal Label Label10;\r
+        private Label labelStaticSource;\r
+        private FlowLayoutPanel flowLayoutPanel1;\r
+        private ToolStripMenuItem mnu_importMacPreset;\r
+        private OpenFileDialog openPreset;\r
+        private Button btn_importChapters;\r
+        private OpenFileDialog File_ChapterImport;\r
+        private ContextMenuStrip ChaptersMenu;\r
+        private ToolStripMenuItem mnu_resetChapters;\r
+        private ToolStripMenuItem pmnu_import;\r
+        private ToolStripSeparator toolStripSeparator2;\r
     }\r
 }
\ No newline at end of file
index 1496646..9cf29a2 100644 (file)
@@ -5,59 +5,52 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Collections;\r
 using System.Collections.Generic;\r
 using System.Drawing;\r
-using System.Text;\r
+using System.Globalization;\r
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Diagnostics;\r
 using System.Threading;\r
-using System.Runtime.InteropServices;\r
-using System.Globalization;\r
-using System.Text.RegularExpressions;\r
+using Handbrake.EncodeQueue;\r
+using Handbrake.Functions;\r
+using Handbrake.Presets;\r
+using Handbrake.Parsing;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmMain : Form\r
     {\r
-        // Declarations *******************************************************\r
-        // Objects which may be used by one or more other objects\r
-        Functions.Main hb_common_func = new Functions.Main();\r
-        Functions.Encode cliObj = new Functions.Encode();\r
-        Functions.Queue encodeQueue = new Functions.Queue();\r
-        Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();\r
-        Parsing.Title selectedTitle;\r
-\r
-        // Objects belonging to this window only\r
-        PresetLoader presetLoader = new PresetLoader();\r
-        x264Panel x264PanelFunctions = new x264Panel();\r
+        // Objects which may be used by one or more other objects *************\r
+        EncodeAndQueueHandler encodeQueue = new EncodeAndQueueHandler();\r
+        PresetsHandler presetHandler = new PresetsHandler();\r
         QueryGenerator queryGen = new QueryGenerator();\r
 \r
-        internal Process hbProc;\r
-        private Parsing.DVD thisDVD;\r
+        // Globals: Mainly used for tracking. *********************************\r
+        public Title selectedTitle;\r
+        private DVD thisDVD;\r
         private frmQueue queueWindow;\r
-        private delegate void updateStatusChanger();\r
-        private string lastAction = null;\r
-        public int maxWidth = 0;\r
-        public int maxHeight = 0;\r
+        private frmPreview qtpreview;\r
+        private frmActivityWindow ActivityWindow;\r
+        private Form splash;\r
+        public string sourcePath;\r
+        private string lastAction;\r
+        private SourceType selectedSourceType;\r
+        private string dvdDrivePath;\r
+        private string dvdDriveLabel;\r
+\r
+        // Delegates **********************************************************\r
+        private delegate void UpdateWindowHandler();\r
 \r
         // Applicaiton Startup ************************************************\r
 \r
         #region Application Startup\r
-\r
         public frmMain()\r
         {\r
-            // Load the splash screen in this thread\r
-            Form splash = new frmSplashScreen();\r
-            splash.Show();\r
-\r
-            // Initialize the queue window.\r
-            queueWindow = new frmQueue(this);\r
-            //Create a label that can be updated from the parent thread.\r
-            Label lblStatus = new Label();\r
-            lblStatus.Size = new Size(250, 20);\r
-            lblStatus.Location = new Point(10, 280);\r
+            // Load and setup the splash screen in this thread\r
+            splash = new frmSplashScreen();\r
+            splash.Show(this);\r
+            Label lblStatus = new Label { Size = new Size(150, 20), Location = new Point(182, 102) };\r
             splash.Controls.Add(lblStatus);\r
 \r
             InitializeComponent();\r
@@ -65,141 +58,289 @@ namespace Handbrake
             // Update the users config file with the CLI version data.\r
             lblStatus.Text = "Setting Version Data ...";\r
             Application.DoEvents();\r
-            ArrayList x = hb_common_func.getCliVersionData();\r
-            if (x != null)\r
-            {\r
-                try\r
-                {\r
-                    Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
-                    Properties.Settings.Default.hb_version = x[0].ToString();\r
-                }\r
-                catch (Exception)\r
-                {\r
-                    Properties.Settings.Default.hb_build = 0;\r
-                    Properties.Settings.Default.hb_version = "0";\r
-                }\r
-            }\r
+            Main.setCliVersionData();\r
 \r
-            // show the form, but leave disabled until preloading is complete then show the main form\r
+            // Show the form, but leave disabled until preloading is complete then show the main form\r
             this.Enabled = false;\r
             this.Show();\r
             Application.DoEvents(); // Forces frmMain to draw\r
 \r
-            // update the status\r
-            if (Properties.Settings.Default.updateStatus == "Checked")\r
+            // Check for new versions, if update checking is enabled\r
+            if (Properties.Settings.Default.updateStatus)\r
             {\r
-                lblStatus.Text = "Checking for updates ...";\r
-                Application.DoEvents();\r
-                Thread updateCheckThread = new Thread(startupUpdateCheck);\r
-                updateCheckThread.Start();\r
+                DateTime now = DateTime.Now;\r
+                DateTime lastCheck = Properties.Settings.Default.lastUpdateCheckDate;\r
+                TimeSpan elapsed = now.Subtract(lastCheck);\r
+                if (elapsed.TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)\r
+                {\r
+                    lblStatus.Text = "Checking for updates ...";\r
+                    Application.DoEvents();\r
+\r
+                    Main.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false);\r
+                }\r
             }\r
 \r
             // Setup the GUI components\r
             lblStatus.Text = "Setting up the GUI ...";\r
             Application.DoEvents();\r
-            setupH264Panel();               // Initalize the H.264 Panel\r
-            loadPresetPanel();              // Load the Preset Panel\r
+            loadPresetPanel();                       // Load the Preset Panel\r
+            treeView_presets.ExpandAll();\r
+            lbl_encode.Text = "";\r
+            queueWindow = new frmQueue(encodeQueue);        // Prepare the Queue\r
+            if (!Properties.Settings.Default.QueryEditorTab)\r
+                tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.\r
+\r
             // Load the user's default settings or Normal Preset\r
-            if (Properties.Settings.Default.defaultSettings == "Checked")\r
-                loadUserDefaults();\r
+            if (Properties.Settings.Default.defaultPreset != "")\r
+            {\r
+                if (presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)\r
+                {\r
+                    string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query;\r
+                    Boolean loadPictureSettings = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings;\r
+\r
+                    if (query != null)\r
+                    {\r
+                        //Ok, Reset all the H264 widgets before changing the preset\r
+                        x264Panel.reset2Defaults();\r
+\r
+                        // Send the query from the file to the Query Parser class, then load the preset\r
+                        QueryParser presetQuery = QueryParser.Parse(query);\r
+                        PresetLoader.presetLoader(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
+\r
+                        // The x264 widgets will need updated, so do this now:\r
+                        x264Panel.X264_StandardizeOptString();\r
+                        x264Panel.X264_SetCurrentSettingsInPanel();\r
+                    }\r
+                }\r
+                else\r
+                    loadNormalPreset();\r
+            }\r
             else\r
                 loadNormalPreset();\r
-            // Expand the preset Nodes\r
-            treeView_presets.ExpandAll();\r
+\r
             // Enabled GUI tooltip's if Required\r
-            if (Properties.Settings.Default.tooltipEnable == "Checked")\r
+            if (Properties.Settings.Default.tooltipEnable)\r
                 ToolTip.Active = true;\r
-            lbl_encode.Text = "";\r
+\r
+            // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)\r
+            GrowlCommunicator.Register();\r
 \r
             //Finished Loading\r
             lblStatus.Text = "Loading Complete!";\r
             Application.DoEvents();\r
-\r
-            //Close the splash screen\r
             splash.Close();\r
             splash.Dispose();\r
-\r
-            // Turn the interface back to the user\r
             this.Enabled = true;\r
 \r
-            // Some event Handlers. Used for minimize to taskbar\r
-            this.Resize += new EventHandler(frmMain_Resize);\r
-\r
-            // Queue Recovery\r
+            // Event Handlers and Queue Recovery\r
+            events();\r
             queueRecovery();\r
         }\r
 \r
-        // Startup Functions\r
-        private void startupUpdateCheck()\r
+        private void UpdateCheckDone(IAsyncResult result)\r
         {\r
+            if (InvokeRequired)\r
+            {\r
+                Invoke(new MethodInvoker(() => UpdateCheckDone(result)));\r
+                return;\r
+            }\r
+\r
+            UpdateCheckInformation info;\r
+\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
-                {\r
-                    this.BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
-                    return;\r
-                }\r
+                info = Main.EndCheckForUpdates(result);\r
 \r
-                Boolean update = hb_common_func.updateCheck(false);\r
-                if (update == true)\r
+                if (info.NewVersionAvailable)\r
                 {\r
-                    frmUpdater updateWindow = new frmUpdater();\r
-                    updateWindow.Show();\r
+                    frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+                    updateWindow.ShowDialog();\r
                 }\r
             }\r
-            catch (Exception) { /* Do Nothing*/ }\r
-        }\r
-        private void setupH264Panel()\r
-        {\r
-            // Set the default settings of the x264 panel\r
-            drop_bFrames.Text = "Default (0)";\r
-            drop_refFrames.Text = "Default (1)";\r
-            drop_subpixelMotionEstimation.Text = "Default (4)";\r
-            drop_trellis.Text = "Default (0)";\r
-            drop_MotionEstimationMethod.Text = "Default (Hexagon)";\r
-            drop_MotionEstimationRange.Text = "Default (16)";\r
-            drop_directPrediction.Text = "Default (Spatial)";\r
-            drop_deblockAlpha.Text = "Default (0)";\r
-            drop_deblockBeta.Text = "Default (0)";\r
-            drop_analysis.Text = "Default (some)";\r
-            rtf_x264Query.Text = "";\r
-        }\r
-        private void loadUserDefaults()\r
-        {\r
-            // Try to load the users default settings.\r
-            string userDefaults = Properties.Settings.Default.defaultUserSettings;\r
-\r
-            if (userDefaults == "")\r
-                loadNormalPreset();\r
-            else\r
+            catch (Exception ex)\r
             {\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
-                presetLoader.presetLoader(this, presetQuery, "User Defaults ");\r
+                if ((bool)result.AsyncState)\r
+                    MessageBox.Show("Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
+\r
+        // Startup Functions   \r
         private void queueRecovery()\r
         {\r
-            if (hb_common_func.check_queue_recovery() == true)\r
+            if (Main.checkQueueRecovery())\r
             {\r
                 DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
                 if (result == DialogResult.Yes)\r
-                    encodeQueue.recoverQueue("hb_queue_recovery.dat"); // Start Recovery\r
+                    encodeQueue.LoadQueueFromFile("hb_queue_recovery.xml"); // Start Recovery\r
                 else\r
                 {\r
                     // Remove the Queue recovery file if the user doesn't want to recovery the last queue.\r
-                    string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
+                    string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
                     if (File.Exists(queuePath))\r
                         File.Delete(queuePath);\r
                 }\r
             }\r
         }\r
+        #endregion\r
+\r
+        #region Properties\r
+        public string SourceName\r
+        {\r
+            get\r
+            {\r
+                if (this.selectedSourceType == SourceType.DvdDrive)\r
+                {\r
+                    return this.dvdDriveLabel;\r
+                }\r
+\r
+                return Path.GetFileNameWithoutExtension(this.sourcePath);\r
+            }\r
+        }\r
+        #endregion\r
+\r
+        #region Events\r
+        // Encoding Events for setting up the GUI\r
+        private void events()\r
+        {\r
+            // Handle Widget changes when preset is selected.\r
+            RegisterPresetEventHandler();\r
+\r
+            // Handle Window Resize\r
+            if (Properties.Settings.Default.MainWindowMinimize)\r
+                this.Resize += new EventHandler(frmMain_Resize);\r
+\r
+            // Handle Encode Start / Finish / Pause\r
+            encodeQueue.CurrentJobCompleted += new EventHandler(encodeEnded);\r
+            encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
+            encodeQueue.NewJobStarted += new EventHandler(encodeStarted);\r
+\r
+            // Handle a file being draged onto the GUI.\r
+            this.DragEnter += new DragEventHandler(frmMain_DragEnter);\r
+            this.DragDrop += new DragEventHandler(frmMain_DragDrop);\r
+        }\r
+\r
+        // Change the preset label to custom when a user changes a setting. Don't want to give the impression that users can change settings and still be using a preset\r
+        private void RegisterPresetEventHandler()\r
+        {\r
+            // Output Settings\r
+            drop_format.SelectedIndexChanged += new EventHandler(changePresetLabel);\r
+            check_largeFile.CheckedChanged += new EventHandler(changePresetLabel);\r
+            check_iPodAtom.CheckedChanged += new EventHandler(changePresetLabel);\r
+            check_optimiseMP4.CheckedChanged += new EventHandler(changePresetLabel);\r
+\r
+            // Picture Settings\r
+            //PictureSettings.PictureSettingsChanged += new EventHandler(changePresetLabel);\r
+\r
+            // Filter Settings\r
+            Filters.FilterSettingsChanged += new EventHandler(changePresetLabel);\r
+\r
+            // Video Tab\r
+            drp_videoEncoder.SelectedIndexChanged += new EventHandler(changePresetLabel);\r
+            check_2PassEncode.CheckedChanged += new EventHandler(changePresetLabel);\r
+            check_turbo.CheckedChanged += new EventHandler(changePresetLabel);\r
+            text_filesize.TextChanged += new EventHandler(changePresetLabel);\r
+            text_bitrate.TextChanged += new EventHandler(changePresetLabel);\r
+            slider_videoQuality.ValueChanged += new EventHandler(changePresetLabel);\r
+\r
+            // Audio Panel\r
+            AudioSettings.AudioListChanged += new EventHandler(changePresetLabel);\r
+\r
+            // Advanced Tab\r
+            x264Panel.rtf_x264Query.TextChanged += new EventHandler(changePresetLabel);\r
+        }\r
+        private void UnRegisterPresetEventHandler()\r
+        {\r
+            // Output Settings \r
+            drop_format.SelectedIndexChanged -= new EventHandler(changePresetLabel);\r
+            check_largeFile.CheckedChanged -= new EventHandler(changePresetLabel);\r
+            check_iPodAtom.CheckedChanged -= new EventHandler(changePresetLabel);\r
+            check_optimiseMP4.CheckedChanged -= new EventHandler(changePresetLabel);\r
+\r
+            // Picture Settings\r
+            //PictureSettings.PictureSettingsChanged -= new EventHandler(changePresetLabel);\r
+\r
+            // Filter Settings\r
+            Filters.FilterSettingsChanged -= new EventHandler(changePresetLabel);\r
+\r
+            // Video Tab\r
+            drp_videoEncoder.SelectedIndexChanged -= new EventHandler(changePresetLabel);\r
+            check_2PassEncode.CheckedChanged -= new EventHandler(changePresetLabel);\r
+            check_turbo.CheckedChanged -= new EventHandler(changePresetLabel);\r
+            text_filesize.TextChanged -= new EventHandler(changePresetLabel);\r
+            text_bitrate.TextChanged -= new EventHandler(changePresetLabel);\r
+            slider_videoQuality.ValueChanged -= new EventHandler(changePresetLabel);\r
+\r
+            // Audio Panel\r
+            AudioSettings.AudioListChanged -= new EventHandler(changePresetLabel);\r
+\r
+            // Advanced Tab\r
+            x264Panel.rtf_x264Query.TextChanged -= new EventHandler(changePresetLabel);\r
+        }\r
+        private void changePresetLabel(object sender, EventArgs e)\r
+        {\r
+            labelPreset.Text = "Output Settings (Preset: Custom)";\r
+        }\r
+\r
+        private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
+        {\r
+            if (e.Data.GetDataPresent(DataFormats.FileDrop, false))\r
+                e.Effect = DragDropEffects.All;\r
+        }\r
+        private void frmMain_DragDrop(object sender, DragEventArgs e)\r
+        {\r
+            string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];\r
+            sourcePath = string.Empty;\r
+\r
+            if (fileList != null)\r
+            {\r
+                if (fileList[0].StartsWith("\\"))\r
+                {\r
+                    MessageBox.Show(\r
+                        "Sorry, HandBrake does not support UNC file paths. \nTry mounting the network share as a network drive in My Computer",\r
+                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                    UpdateSourceLabel();\r
+                }\r
+                else\r
+                {\r
+                    if (fileList[0] != "")\r
+                        startScan(fileList[0]);\r
+                    else\r
+                        UpdateSourceLabel();\r
+                }\r
+            }\r
+            else\r
+                UpdateSourceLabel();\r
+        }\r
+        private void encodeStarted(object sender, EventArgs e)\r
+        {\r
+            lastAction = "encode";\r
+            setEncodeStarted();\r
 \r
+            // Experimental HBProc Process Monitoring.\r
+            if (Properties.Settings.Default.enocdeStatusInGui)\r
+            {\r
+                Thread encodeMon = new Thread(encodeMonitorThread);\r
+                encodeMon.Start();\r
+            }\r
+        }\r
+        private void encodeEnded(object sender, EventArgs e)\r
+        {\r
+            setEncodeFinished();\r
+        }\r
+        private void encodePaused(object sender, EventArgs e)\r
+        {\r
+            setEncodeFinished();\r
+        }\r
         #endregion\r
 \r
-        // The Applications Main Menu and Menus *******************************\r
+        // User Interface Menus / Tool Strips *********************************\r
 \r
         #region File Menu\r
+        private void mnu_killCLI_Click(object sender, EventArgs e)\r
+        {\r
+            killScan();\r
+        }\r
         private void mnu_exit_Click(object sender, EventArgs e)\r
         {\r
             Application.Exit();\r
@@ -209,34 +350,29 @@ namespace Handbrake
         #region Tools Menu\r
         private void mnu_encode_Click(object sender, EventArgs e)\r
         {\r
-            queueWindow.setQueue(encodeQueue);\r
             queueWindow.Show();\r
         }\r
         private void mnu_encodeLog_Click(object sender, EventArgs e)\r
         {\r
-            String file = String.Empty;\r
-            if (lastAction == "scan")\r
-                file = "dvdinfo.dat";\r
-            else\r
-                file = "hb_encode_log.dat";\r
+            String file = lastAction == "scan" ? "last_scan_log.txt" : "last_encode_log.txt";\r
 \r
-            frmActivityWindow dvdInfoWindow = new frmActivityWindow(file, this, queueWindow);\r
+            frmActivityWindow dvdInfoWindow = new frmActivityWindow(file, encodeQueue, this);\r
             dvdInfoWindow.Show();\r
         }\r
         private void mnu_options_Click(object sender, EventArgs e)\r
         {\r
-            Form Options = new frmOptions(this);\r
-            Options.ShowDialog();\r
+            Form options = new frmOptions(this);\r
+            options.ShowDialog();\r
         }\r
         #endregion\r
 \r
         #region Presets Menu\r
         private void mnu_presetReset_Click(object sender, EventArgs e)\r
         {\r
-            presetHandler.updateBuiltInPresets();\r
+            presetHandler.UpdateBuiltInPresets();\r
             loadPresetPanel();\r
             if (treeView_presets.Nodes.Count == 0)\r
-                MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("Unable to load the presets.xml file. Please select \"Update Built-in Presets\" from the Presets Menu. \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             else\r
                 MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
 \r
@@ -244,40 +380,21 @@ namespace Handbrake
         }\r
         private void mnu_delete_preset_Click(object sender, EventArgs e)\r
         {\r
-            // Empty the preset file\r
-            string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";\r
-            if (File.Exists(presetsFile))\r
-                File.Delete(presetsFile);\r
-\r
-            try\r
-            {\r
-                FileStream strm = new FileStream(presetsFile, FileMode.Create, FileAccess.Write);\r
-                strm.Close();\r
-                strm.Dispose();\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc.ToString());\r
-            }\r
-\r
-            // Reload the preset panel\r
-            loadPresetPanel();\r
+            presetHandler.RemoveBuiltInPresets();\r
+            loadPresetPanel(); // Reload the preset panel\r
         }\r
         private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
         {\r
             loadNormalPreset();\r
         }\r
+        private void mnu_importMacPreset_Click(object sender, EventArgs e)\r
+        {\r
+            importPreset();\r
+        }\r
         private void btn_new_preset_Click(object sender, EventArgs e)\r
         {\r
-            // Remember each nodes expanded status so we can reload it\r
-            List<Boolean> nodeStatus = saveTreeViewState();\r
-            nodeStatus.Add(true);\r
-\r
-            Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);\r
+            Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, 0, null), presetHandler);\r
             preset.ShowDialog();\r
-\r
-            // Now reload the TreeView states\r
-            loadTreeViewStates(nodeStatus);\r
         }\r
         #endregion\r
 \r
@@ -296,23 +413,50 @@ namespace Handbrake
         }\r
         private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
         {\r
-            Boolean update = hb_common_func.updateCheck(true);\r
-            if (update == true)\r
+            lbl_updateCheck.Visible = true;\r
+            Main.BeginCheckForUpdates(new AsyncCallback(updateCheckDoneMenu), false);\r
+        }\r
+        private void updateCheckDoneMenu(IAsyncResult result)\r
+        {\r
+            // Make sure it's running on the calling thread\r
+            if (InvokeRequired)\r
             {\r
-                frmUpdater updateWindow = new frmUpdater();\r
-                updateWindow.Show();\r
+                Invoke(new MethodInvoker(() => updateCheckDoneMenu(result)));\r
+                return;\r
+            }\r
+            UpdateCheckInformation info;\r
+            try\r
+            {\r
+                // Get the information about the new build, if any, and close the window\r
+                info = Main.EndCheckForUpdates(result);\r
+\r
+                if (info.NewVersionAvailable && info.BuildInformation != null)\r
+                {\r
+                    frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+                    updateWindow.ShowDialog();\r
+                }\r
+                else\r
+                    MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+                lbl_updateCheck.Visible = false;\r
+                return;\r
+            }\r
+            catch (Exception ex)\r
+            {\r
+                if ((bool)result.AsyncState)\r
+                    MessageBox.Show("Unable to check for updates, Please try again later.\n\nDetailed Error Information:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
-            else\r
-                MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
         }\r
         private void mnu_about_Click(object sender, EventArgs e)\r
         {\r
-            Form About = new frmAbout();\r
-            About.ShowDialog();\r
+            using (frmAbout About = new frmAbout())\r
+            {\r
+                About.ShowDialog();\r
+            }\r
         }\r
         #endregion\r
 \r
-        #region Preset Menu\r
+        #region Preset Bar\r
+        // Right Click Menu Code\r
         private void pmnu_expandAll_Click(object sender, EventArgs e)\r
         {\r
             treeView_presets.ExpandAll();\r
@@ -321,213 +465,433 @@ namespace Handbrake
         {\r
             treeView_presets.CollapseAll();\r
         }\r
-        private void treeview_presets_mouseUp(object sender, MouseEventArgs e)\r
+        private void pmnu_import_Click(object sender, EventArgs e)\r
         {\r
-            if (e.Button == MouseButtons.Right)\r
-                treeView_presets.SelectedNode = treeView_presets.GetNodeAt(e.Location);\r
-            treeView_presets.Select();\r
+            importPreset();\r
+        }\r
+        private void pmnu_saveChanges_Click(object sender, EventArgs e)\r
+        {\r
+            DialogResult result = MessageBox.Show("Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);\r
+            if (result == DialogResult.Yes)\r
+                presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), true);\r
+            else if (result == DialogResult.No)\r
+                presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), false);\r
         }\r
         private void pmnu_delete_click(object sender, EventArgs e)\r
         {\r
             if (treeView_presets.SelectedNode != null)\r
             {\r
-                presetHandler.remove(treeView_presets.SelectedNode.Text);\r
-\r
-                // Remember each nodes expanded status so we can reload it\r
-                List<Boolean> nodeStatus = saveTreeViewState();\r
-\r
-                // Now reload the preset panel\r
-                loadPresetPanel();\r
-\r
-                // Now reload the TreeView states\r
-                loadTreeViewStates(nodeStatus);\r
+                presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
+                treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
             }\r
             treeView_presets.Select();\r
         }\r
-        #endregion\r
+        private void presets_menu_Opening(object sender, System.ComponentModel.CancelEventArgs e)\r
+        {\r
+            // Make sure that the save menu is always disabled by default\r
+            pmnu_saveChanges.Enabled = false;\r
 \r
-        // MainWindow Components, Actions and Functions ***********************\r
-        #region Actions\r
+            // Now enable the save menu if the selected preset is a user preset\r
+            if (treeView_presets.SelectedNode != null)\r
+                if (presetHandler.CheckIfUserPresetExists(treeView_presets.SelectedNode.Text))\r
+                    pmnu_saveChanges.Enabled = true;\r
 \r
-        // ToolBar\r
-        private void btn_source_Click(object sender, EventArgs e)\r
+            treeView_presets.Select();\r
+        }\r
+\r
+        // Presets Management\r
+        private void btn_addPreset_Click(object sender, EventArgs e)\r
         {\r
-            if (Properties.Settings.Default.drive_detection == "Checked")\r
-            {\r
-                mnu_dvd_drive.Visible = true;\r
-                Thread driveInfoThread = new Thread(getDriveInfoThread);\r
-                driveInfoThread.Start();\r
-            }\r
-            else\r
-                mnu_dvd_drive.Visible = false;\r
+            Form preset = new frmAddPreset(this, QueryGenerator.GenerateTabbedComponentsQuery(this), presetHandler);\r
+            preset.ShowDialog();\r
         }\r
-        private void btn_start_Click(object sender, EventArgs e)\r
+        private void btn_removePreset_Click(object sender, EventArgs e)\r
         {\r
-            if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
-                MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-            else\r
+            DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+            if (result == DialogResult.Yes)\r
             {\r
-                // Set the last action to encode. \r
-                // This is used for tracking which file to load in the activity window\r
-                lastAction = "encode";\r
-\r
-                String query;\r
-                if (rtf_query.Text != "")\r
-                    query = rtf_query.Text;\r
-                else\r
-                    query = queryGen.GenerateTheQuery(this);\r
-\r
-                ThreadPool.QueueUserWorkItem(procMonitor, query);\r
-                lbl_encode.Visible = true;\r
-                lbl_encode.Text = "Encoding in Progress";\r
-\r
-                btn_start.Text = "Stop";\r
-                btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";\r
-                btn_start.Image = Properties.Resources.stop;\r
+                if (treeView_presets.SelectedNode != null)\r
+                {\r
+                    presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
+                    treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);\r
+                }\r
             }\r
+            treeView_presets.Select();\r
         }\r
-        private void btn_add2Queue_Click(object sender, EventArgs e)\r
+        private void btn_setDefault_Click(object sender, EventArgs e)\r
         {\r
-            if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
-                MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-            else\r
+            if (treeView_presets.SelectedNode != null)\r
             {\r
-\r
-                String query = queryGen.GenerateTheQuery(this);\r
-                if (rtf_query.Text != "")\r
-                    query = rtf_query.Text;\r
-\r
-                encodeQueue.add(query);\r
-                encodeQueue.write2disk("hb_queue_recovery.dat"); // Writes the queue to the recovery file, just incase the GUI crashes.\r
-\r
-                queueWindow.setQueue(encodeQueue);\r
-                queueWindow.Show();\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to set this preset as the default?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                if (result == DialogResult.Yes)\r
+                {\r
+                    Properties.Settings.Default.defaultPreset = treeView_presets.SelectedNode.Text;\r
+                    Properties.Settings.Default.Save();\r
+                    MessageBox.Show("New default preset set.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+                }\r
             }\r
+            else\r
+                MessageBox.Show("Please select a preset first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
         }\r
-        private void btn_showQueue_Click(object sender, EventArgs e)\r
+        private void treeview_presets_mouseUp(object sender, MouseEventArgs e)\r
         {\r
-            queueWindow.setQueue(encodeQueue);\r
-            queueWindow.Show();\r
+            if (e.Button == MouseButtons.Right)\r
+                treeView_presets.SelectedNode = treeView_presets.GetNodeAt(e.Location);\r
+            else if (e.Button == MouseButtons.Left)\r
+            {\r
+                if (treeView_presets.GetNodeAt(e.Location) != null)\r
+                {\r
+                    if (labelPreset.Text.Contains(treeView_presets.GetNodeAt(e.Location).Text))\r
+                        selectPreset();\r
+                }\r
+            }\r
+\r
+            treeView_presets.Select();\r
         }\r
-        private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
+        private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
         {\r
-            String file = String.Empty;\r
-            if (lastAction == "scan")\r
-                file = "dvdinfo.dat";\r
-            else\r
-                file = "hb_encode_log.dat";\r
-\r
-            frmActivityWindow ActivityWindow = new frmActivityWindow(file, this, queueWindow);\r
-            ActivityWindow.Show();\r
+            selectPreset();\r
         }\r
-\r
-        //Source\r
-        private void btn_dvd_source_Click(object sender, EventArgs e)\r
+        private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
         {\r
-            // Enable the creation of chapter markers.\r
-            Check_ChapterMarkers.Enabled = true;\r
+            if (e.KeyCode == Keys.Delete)\r
+            {\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                if (result == DialogResult.Yes)\r
+                {\r
+                    if (treeView_presets.SelectedNode != null)\r
+                        presetHandler.Remove(treeView_presets.SelectedNode.Text);\r
 \r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
-            lastAction = "scan";\r
+                    // Remember each nodes expanded status so we can reload it\r
+                    List<Boolean> nodeStatus = new List<Boolean>();\r
+                    foreach (TreeNode node in treeView_presets.Nodes)\r
+                        nodeStatus.Add(node.IsExpanded);\r
 \r
-            String filename = "";\r
-            text_source.Text = "";\r
+                    // Now reload the preset panel\r
+                    loadPresetPanel();\r
 \r
-            DVD_Open.ShowDialog();\r
-            filename = DVD_Open.SelectedPath;\r
+                    // And finally, re-expand any of the nodes if required\r
+                    int i = 0;\r
+                    foreach (TreeNode node in treeView_presets.Nodes)\r
+                    {\r
+                        if (nodeStatus[i])\r
+                            node.Expand();\r
 \r
-            if (filename.StartsWith("\\"))\r
-                MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-            else\r
-            {\r
-                if (filename != "")\r
-                {\r
-                    Form frmRD = new frmReadDVD(filename, this);\r
-                    text_source.Text = filename;\r
-                    lbl_encode.Text = "Scanning ...";\r
-                    frmRD.ShowDialog();\r
+                        i++;\r
+                    }\r
                 }\r
-                else\r
-                    text_source.Text = "Click 'Source' to continue";\r
-\r
-                // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
-                if (drp_dvdtitle.Items.Count == 0)\r
-                    MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.\nYour Source may be copy protected, badly mastered or a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
-\r
-                lbl_encode.Text = "";\r
             }\r
         }\r
-        private void btn_file_source_Click(object sender, EventArgs e)\r
+        private void selectPreset()\r
         {\r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
-            lastAction = "scan";\r
+            if (treeView_presets.SelectedNode != null)\r
+            {\r
+                // Ok, so, we've selected a preset. Now we want to load it.\r
+                string presetName = treeView_presets.SelectedNode.Text;\r
+                if (presetHandler.GetPreset(presetName) != null)\r
+                {\r
+                    string query = presetHandler.GetPreset(presetName).Query;\r
+                    Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
 \r
-            String filename = "";\r
-            text_source.Text = "";\r
+                    if (query != null)\r
+                    {\r
+                        //Ok, Reset all the H264 widgets before changing the preset\r
+                        x264Panel.reset2Defaults();\r
 \r
-            ISO_Open.ShowDialog();\r
-            filename = ISO_Open.FileName;\r
+                        // Send the query from the file to the Query Parser class\r
+                        QueryParser presetQuery = QueryParser.Parse(query);\r
 \r
-            if (filename.StartsWith("\\"))\r
-                MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-            else\r
+                        // Now load the preset\r
+                        PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);\r
+\r
+                        // The x264 widgets will need updated, so do this now:\r
+                        x264Panel.X264_StandardizeOptString();\r
+                        x264Panel.X264_SetCurrentSettingsInPanel();\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        private void loadNormalPreset()\r
+        {\r
+            foreach (TreeNode treenode in treeView_presets.Nodes)\r
             {\r
-                if (filename != "")\r
+                foreach (TreeNode node in treenode.Nodes)\r
                 {\r
-                    Form frmRD = new frmReadDVD(filename, this);\r
-                    text_source.Text = filename;\r
-                    lbl_encode.Text = "Scanning ...";\r
-                    frmRD.ShowDialog();\r
+                    if (node.Text.Equals("Normal"))\r
+                        treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];\r
+                }\r
+            }\r
+        }\r
+        private void importPreset()\r
+        {\r
+            Import imp = new Import();\r
+            if (openPreset.ShowDialog() == DialogResult.OK)\r
+            {\r
+                QueryParser parsed = imp.importMacPreset(openPreset.FileName);\r
+                if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
+                {\r
+                    DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",\r
+                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
+                    if (result == DialogResult.Yes)\r
+                    {\r
+                        PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+                        presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null),\r
+                                                   parsed.UsesPictureSettings);\r
+                    }\r
                 }\r
                 else\r
-                    text_source.Text = "Click 'Source' to continue";\r
+                {\r
+                    PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+                    presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings);\r
 \r
-                // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
-                if (drp_dvdtitle.Items.Count == 0)\r
-                    MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.\nYour Source may be copy protected, badly mastered or a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                    if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings))\r
+                    {\r
+                        TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };\r
+                        treeView_presets.Nodes.Add(preset_treeview);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        #endregion\r
 \r
-                lbl_encode.Text = "";\r
+        #region ToolStrip\r
+        private void btn_source_Click(object sender, EventArgs e)\r
+        {\r
+            mnu_dvd_drive.Visible = true;\r
+            Thread driveInfoThread = new Thread(getDriveInfoThread);\r
+            driveInfoThread.Start();\r
+        }\r
+        private void btn_start_Click(object sender, EventArgs e)\r
+        {\r
+            if (btn_start.Text == "Stop")\r
+            {\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
-                // Enable the creation of chapter markers if the file is an image of a dvd.\r
-                if (filename.ToLower().Contains(".iso"))\r
-                    Check_ChapterMarkers.Enabled = true;\r
+                if (result == DialogResult.Yes)\r
+                {\r
+                    // Pause The Queue\r
+                    encodeQueue.RequestPause();\r
+\r
+                    // Allow the CLI to exit cleanly\r
+                    Win32.SetForegroundWindow((int)encodeQueue.processHandle);\r
+                    SendKeys.Send("^C");\r
+\r
+                    // Update the GUI\r
+                    setEncodeFinished();\r
+                }\r
+            }\r
+            else\r
+            {\r
+                if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))\r
+                {\r
+                    string generatedQuery = queryGen.GenerateCLIQuery(this, 0, null);\r
+                    string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, 0, null);\r
+                    string query = string.Empty;\r
+\r
+                    // Check to make sure the generated query matches the GUI settings\r
+                    if (Properties.Settings.Default.PromptOnUnmatchingQueries && !string.IsNullOrEmpty(specifiedQuery) && generatedQuery != specifiedQuery)\r
+                    {\r
+                        DialogResult result = MessageBox.Show("The query under the \"Query Editor\" tab " +\r
+                            "does not match the current GUI settings.\n\nBecause the manual query takes " +\r
+                            "priority over the GUI, your recently updated settings will not be taken " +\r
+                            "into account when encoding this job." + Environment.NewLine + Environment.NewLine +\r
+                            "Do you want to replace the manual query with the updated GUI-generated query?",\r
+                            "Manual Query does not Match GUI",\r
+                            MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk,\r
+                            MessageBoxDefaultButton.Button3);\r
+\r
+                        switch (result)\r
+                        {\r
+                            case DialogResult.Yes:\r
+                                // Replace the manual query with the generated one\r
+                                query = generatedQuery;\r
+                                rtf_query.Text = generatedQuery;\r
+                                break;\r
+                            case DialogResult.No:\r
+                                // Use the manual query\r
+                                query = specifiedQuery;\r
+                                break;\r
+                            case DialogResult.Cancel:\r
+                                // Don't start the encode\r
+                                return;\r
+                        }\r
+                    }\r
+                    else\r
+                    {\r
+                        query = specifiedQuery;\r
+                    }\r
+\r
+                    DialogResult overwrite = DialogResult.Yes;\r
+                    if (text_destination.Text != "")\r
+                        if (File.Exists(text_destination.Text))\r
+                            overwrite = MessageBox.Show("The destination file already exists. Are you sure you want to overwrite it?", "Overwrite File?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+\r
+                    if (overwrite == DialogResult.Yes)\r
+                    {\r
+                        if (encodeQueue.Count == 0)\r
+                            encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+\r
+                        queueWindow.setQueue();\r
+                        if (encodeQueue.Count > 1)\r
+                            queueWindow.Show(false);\r
+\r
+                        setEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
+                        encodeQueue.StartEncodeQueue(); // Start The Queue Encoding Process\r
+                        lastAction = "encode";   // Set the last action to encode - Used for activity window.\r
+\r
+                        if (ActivityWindow != null)\r
+                            ActivityWindow.SetLogView(false);\r
+\r
+                    }\r
+                    this.Focus();\r
+                }\r
+                else if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
+                    MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+        }\r
+        private void btn_add2Queue_Click(object sender, EventArgs e)\r
+        {\r
+            if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
+                MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            else\r
+            {\r
+                String query = queryGen.GenerateCLIQuery(this, 0, null);\r
+                if (rtf_query.Text != "")\r
+                    query = rtf_query.Text;\r
+\r
+                if (encodeQueue.CheckForDestinationDuplicate(text_destination.Text))\r
+                {\r
+                    DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?",\r
+                  "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
+                    if (result == DialogResult.Yes)\r
+                        encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+\r
+                }\r
                 else\r
+                    encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+\r
+                lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
+\r
+                queueWindow.Show();\r
+            }\r
+        }\r
+        private void btn_showQueue_Click(object sender, EventArgs e)\r
+        {\r
+            queueWindow.Show();\r
+            queueWindow.Activate();\r
+        }\r
+        private void tb_preview_Click(object sender, EventArgs e)\r
+        {\r
+            if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(text_destination.Text))\r
+                MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            else\r
+            {\r
+                if (qtpreview == null)\r
                 {\r
-                    Check_ChapterMarkers.Enabled = false;\r
-                    Check_ChapterMarkers.Checked = false;\r
-                    data_chpt.Rows.Clear();\r
+                    qtpreview = new frmPreview(this);\r
+                    qtpreview.Show();\r
                 }\r
+                else if (qtpreview.IsDisposed)\r
+                {\r
+                    qtpreview = new frmPreview(this);\r
+                    qtpreview.Show();\r
+                }\r
+                else\r
+                    MessageBox.Show(qtpreview, "The preview window is already open!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+        }\r
+        private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
+        {\r
+            String file = lastAction == "scan" ? "last_scan_log.txt" : "last_encode_log.txt";\r
+            if (ActivityWindow == null)\r
+                ActivityWindow = new frmActivityWindow(file, encodeQueue, this);\r
+\r
+            ActivityWindow.SetLogView(!encodeQueue.isEncoding);\r
+\r
+            ActivityWindow.Show();\r
+        }\r
+        #endregion\r
+\r
+        #region System Tray Icon\r
+        private void frmMain_Resize(object sender, EventArgs e)\r
+        {\r
+            if (FormWindowState.Minimized == this.WindowState)\r
+            {\r
+                notifyIcon.Visible = true;\r
+                this.Hide();\r
+            }\r
+            else if (FormWindowState.Normal == this.WindowState)\r
+                notifyIcon.Visible = false;\r
+        }\r
+        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
+        {\r
+            this.Visible = true;\r
+            this.Activate();\r
+            this.WindowState = FormWindowState.Normal;\r
+            notifyIcon.Visible = false;\r
+        }\r
+        private void btn_restore_Click(object sender, EventArgs e)\r
+        {\r
+            this.Visible = true;\r
+            this.Activate();\r
+            this.WindowState = FormWindowState.Normal;\r
+            notifyIcon.Visible = false;\r
+        }\r
+        #endregion\r
+\r
+        #region Tab Control\r
+\r
+        //Source\r
+        private void btn_dvd_source_Click(object sender, EventArgs e)\r
+        {\r
+            if (DVD_Open.ShowDialog() == DialogResult.OK)\r
+            {\r
+                this.selectedSourceType = SourceType.Folder;\r
+                selectSource(DVD_Open.SelectedPath);\r
             }\r
+            else\r
+                UpdateSourceLabel();\r
+        }\r
+        private void btn_file_source_Click(object sender, EventArgs e)\r
+        {\r
+            if (ISO_Open.ShowDialog() == DialogResult.OK)\r
+            {\r
+                this.selectedSourceType = SourceType.VideoFile;\r
+                selectSource(ISO_Open.FileName);\r
+            }\r
+            else\r
+                UpdateSourceLabel();\r
         }\r
         private void mnu_dvd_drive_Click(object sender, EventArgs e)\r
         {\r
-            // Enable the creation of chapter markers.\r
+            if (this.dvdDrivePath == null) return;\r
+            this.selectedSourceType = SourceType.DvdDrive;\r
+            selectSource(this.dvdDrivePath);\r
+        }\r
+        private void selectSource(string file)\r
+        {\r
             Check_ChapterMarkers.Enabled = true;\r
-\r
-            // Set the last action to scan. \r
-            // This is used for tracking which file to load in the activity window\r
             lastAction = "scan";\r
+            sourcePath = string.Empty;\r
 \r
-            String filename = "";\r
-            if (mnu_dvd_drive.Text.Contains("VIDEO_TS"))\r
+            if (file == string.Empty) // Must have a file or path\r
             {\r
-                string[] path = mnu_dvd_drive.Text.Split(' ');\r
-                filename = path[0];\r
-                lbl_encode.Text = "Scanning ...";\r
-                Form frmRD = new frmReadDVD(filename, this);\r
-                text_source.Text = filename;\r
-                frmRD.ShowDialog();\r
+                UpdateSourceLabel();\r
+                return;\r
             }\r
 \r
-            // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
-            if (drp_dvdtitle.Items.Count == 0)\r
-                MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.\nYour Source may be copy protected, badly mastered or a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+            if (file.StartsWith("\\")) // NO UNC Paths\r
+            {\r
+                MessageBox.Show(\r
+                    "Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer",\r
+                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                UpdateSourceLabel();\r
+                return;\r
+            }\r
 \r
-            lbl_encode.Text = "";\r
+            sourcePath = Path.GetFileName(file);\r
+            startScan(file);\r
         }\r
-\r
         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
         {\r
             if ((drp_dvdtitle.Items.Count == 1) && (drp_dvdtitle.Items[0].ToString() == "Automatic"))\r
@@ -535,9 +899,9 @@ namespace Handbrake
         }\r
         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            // Reset some values on the form\r
-            lbl_Aspect.Text = "Select a Title";\r
-            //lbl_RecomendedCrop.Text = "Select a Title";\r
+            UnRegisterPresetEventHandler();\r
+\r
+            PictureSettings.lbl_Aspect.Text = "Select a Title"; // Reset some values on the form\r
             drop_chapterStart.Items.Clear();\r
             drop_chapterFinish.Items.Clear();\r
 \r
@@ -545,18 +909,25 @@ namespace Handbrake
             // Otheriwse if its not, title data has to be loased from parsing.\r
             if (drp_dvdtitle.Text != "Automatic")\r
             {\r
-                selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;\r
-\r
-                // Set the Aspect Ratio\r
-                lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();\r
-                lbl_src_res.Text = selectedTitle.Resolution.Width + " x " + selectedTitle.Resolution.Height;\r
+                selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
                 lbl_duration.Text = selectedTitle.Duration.ToString();\r
+                PictureSettings.Source = selectedTitle;  // Setup Picture Settings Tab Control\r
 \r
-                // Set the Recommended Cropping values\r
-                text_top.Text = selectedTitle.AutoCropDimensions[0].ToString();\r
-                text_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();\r
-                text_left.Text = selectedTitle.AutoCropDimensions[2].ToString();\r
-                text_right.Text = selectedTitle.AutoCropDimensions[3].ToString();\r
+                // Populate the Angles dropdown\r
+                drop_angle.Items.Clear();\r
+                if (!Properties.Settings.Default.noDvdNav)\r
+                {\r
+                    drop_angle.Visible = true;\r
+                    lbl_angle.Visible = true;\r
+                    drop_angle.Items.AddRange(selectedTitle.Angles.ToArray());\r
+                    if (drop_angle.Items.Count != 0)\r
+                        drop_angle.SelectedIndex = 0;\r
+                }\r
+                else\r
+                {\r
+                    drop_angle.Visible = false;\r
+                    lbl_angle.Visible = false;\r
+                }\r
 \r
                 // Populate the Start chapter Dropdown\r
                 drop_chapterStart.Items.Clear();\r
@@ -571,89 +942,113 @@ namespace Handbrake
                     drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
 \r
                 // Populate the Audio Channels Dropdown\r
-                drp_track1Audio.Items.Clear();\r
-                drp_track1Audio.Items.Add("Automatic");\r
-                drp_track1Audio.Items.Add("None");\r
-                drp_track1Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
-                drp_track1Audio.SelectedIndex = 0;\r
-\r
-                drp_track2Audio.Items.Clear();\r
-                drp_track2Audio.Items.Add("None");\r
-                drp_track2Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
-                drp_track2Audio.SelectedIndex = 0;\r
-\r
-                drp_track3Audio.Items.Clear();\r
-                drp_track3Audio.Items.Add("None");\r
-                drp_track3Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
-                drp_track3Audio.SelectedIndex = 0;\r
-\r
-                drp_track4Audio.Items.Clear();\r
-                drp_track4Audio.Items.Add("None");\r
-                drp_track4Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
-                drp_track4Audio.SelectedIndex = 0;\r
+                AudioSettings.SetTrackList(selectedTitle);\r
 \r
                 // Populate the Subtitles dropdown\r
-                drp_subtitle.Items.Clear();\r
-                drp_subtitle.Items.Add("None");\r
-                drp_subtitle.Items.Add("Autoselect");\r
-                drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
-                if (drp_subtitle.Items.Count > 0)\r
-                    drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
-\r
+                Subtitles.drp_subtitleTracks.Items.Clear();\r
+                Subtitles.drp_subtitleTracks.Items.Add("Foreign Audio Search (Bitmap)");\r
+                Subtitles.drp_subtitleTracks.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
+                Subtitles.drp_subtitleTracks.SelectedIndex = 0;\r
+                Subtitles.Clear();\r
+                Subtitles.SetSubtitleTrackAuto();\r
             }\r
 \r
             // Run the autoName & chapterNaming functions\r
-            if (Properties.Settings.Default.autoNaming == "Checked")\r
-                text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+            if (Properties.Settings.Default.autoNaming)\r
+            {\r
+                string autoPath = Main.autoName(this);\r
+                if (autoPath != null)\r
+                    text_destination.Text = autoPath;\r
+                else\r
+                    MessageBox.Show("You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
 \r
             data_chpt.Rows.Clear();\r
-            DataGridView chapterGridView = hb_common_func.chapterNaming(data_chpt, drop_chapterStart.Text, drop_chapterFinish.Text);\r
-            if (chapterGridView != null)\r
-                data_chpt = chapterGridView;\r
-        }\r
-        private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            int c_start, c_end = 1;\r
-\r
-            if (drop_chapterFinish.Text == "Auto" && drop_chapterFinish.Items.Count != 0)\r
-                drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
-\r
-            int.TryParse(drop_chapterStart.Text, out c_start);\r
-            int.TryParse(drop_chapterFinish.Text, out c_end);\r
-\r
-            if (c_end != 0)\r
+            if (selectedTitle.Chapters.Count != 1)\r
+            {\r
+                DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+                if (chapterGridView != null)\r
+                    data_chpt = chapterGridView;\r
+            }\r
+            else\r
             {\r
-                if (c_start > c_end)\r
-                    drop_chapterFinish.Text = c_start.ToString();\r
+                Check_ChapterMarkers.Checked = false;\r
+                Check_ChapterMarkers.Enabled = false;\r
             }\r
 \r
-            lbl_duration.Text = hb_common_func.calculateDuration(drop_chapterStart.Text, drop_chapterFinish.Text, selectedTitle).ToString();\r
+            // Hack to force the redraw of the scrollbars which don't resize properly when the control is disabled.\r
+            data_chpt.Columns[0].Width = 166;\r
+            data_chpt.Columns[0].Width = 165;\r
 \r
-            // Run the Autonaming function\r
-            if (Properties.Settings.Default.autoNaming == "Checked")\r
-                text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+            RegisterPresetEventHandler();\r
         }\r
-        private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void chapersChanged(object sender, EventArgs e)\r
         {\r
-            int c_start, c_end = 1;\r
+            Control ctl = (Control)sender;\r
+            int chapterStart, chapterEnd;\r
+            int.TryParse(drop_chapterStart.Text, out chapterStart);\r
+            int.TryParse(drop_chapterFinish.Text, out chapterEnd);\r
 \r
-            if (drop_chapterStart.Text == "Auto" && drop_chapterStart.Items.Count >= 1)\r
-                drop_chapterStart.SelectedIndex = 1;\r
+            switch (ctl.Name)\r
+            {\r
+                case "drop_chapterStart":\r
+                    if (drop_chapterFinish.SelectedIndex == -1 && drop_chapterFinish.Items.Count != 0)\r
+                        drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
 \r
-            int.TryParse(drop_chapterStart.Text, out c_start);\r
-            int.TryParse(drop_chapterFinish.Text, out c_end);\r
+                    if (chapterEnd != 0)\r
+                        if (chapterStart > chapterEnd)\r
+                            drop_chapterFinish.Text = chapterStart.ToString();\r
+                    break;\r
+                case "drop_chapterFinish":\r
+                    if (drop_chapterStart.Items.Count >= 1 && drop_chapterStart.SelectedIndex == -1)\r
+                        drop_chapterStart.SelectedIndex = 0;\r
 \r
-            if (c_start != 0)\r
-            {\r
-                if (c_end < c_start)\r
-                    drop_chapterFinish.Text = c_start.ToString();\r
+                    if (chapterStart != 0)\r
+                        if (chapterEnd < chapterStart)\r
+                            drop_chapterFinish.Text = chapterStart.ToString();\r
+\r
+                    // Add more rows to the Chapter menu if needed.\r
+                    if (Check_ChapterMarkers.Checked)\r
+                    {\r
+                        int i = data_chpt.Rows.Count, finish = 0;\r
+                        int.TryParse(drop_chapterFinish.Text, out finish);\r
+\r
+                        while (i < finish)\r
+                        {\r
+                            int n = data_chpt.Rows.Add();\r
+                            data_chpt.Rows[n].Cells[0].Value = (i + 1);\r
+                            data_chpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);\r
+                            data_chpt.Rows[n].Cells[0].ValueType = typeof(int);\r
+                            data_chpt.Rows[n].Cells[1].ValueType = typeof(string);\r
+                            i++;\r
+                        }\r
+                    }\r
+                    break;\r
             }\r
 \r
-            lbl_duration.Text = hb_common_func.calculateDuration(drop_chapterStart.Text, drop_chapterFinish.Text, selectedTitle).ToString();\r
+            // Update the Duration\r
+            lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
 \r
             // Run the Autonaming function\r
-            if (Properties.Settings.Default.autoNaming == "Checked")\r
-                text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);\r
+            if (Properties.Settings.Default.autoNaming)\r
+                text_destination.Text = Main.autoName(this);\r
+\r
+            // Disable chapter markers if only 1 chapter is selected.\r
+            if (chapterStart == chapterEnd)\r
+            {\r
+                Check_ChapterMarkers.Enabled = false;\r
+                btn_importChapters.Enabled = false;\r
+                data_chpt.Enabled = false;\r
+            }\r
+            else\r
+            {\r
+                Check_ChapterMarkers.Enabled = true;\r
+                if (Check_ChapterMarkers.Checked)\r
+                {\r
+                    btn_importChapters.Enabled = true;\r
+                    data_chpt.Enabled = true;\r
+                }\r
+            }\r
         }\r
 \r
         //Destination\r
@@ -661,20 +1056,16 @@ namespace Handbrake
         {\r
             // This removes the file extension from the filename box on the save file dialog.\r
             // It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.\r
-            DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", "");\r
+            DVD_Save.FileName = Path.GetFileNameWithoutExtension(text_destination.Text);\r
 \r
-            // Show the dialog and set the main form file path\r
+            if (Path.IsPathRooted(text_destination.Text))\r
+                DVD_Save.InitialDirectory = Path.GetDirectoryName(text_destination.Text);\r
 \r
-            if (text_destination.Text.EndsWith(".mp4"))\r
+            // Show the dialog and set the main form file path\r
+            if (drop_format.SelectedIndex.Equals(0))\r
                 DVD_Save.FilterIndex = 1;\r
-            else if (text_destination.Text.EndsWith(".m4v"))\r
+            else if (drop_format.SelectedIndex.Equals(1))\r
                 DVD_Save.FilterIndex = 2;\r
-            else if (text_destination.Text.EndsWith(".avi"))\r
-                DVD_Save.FilterIndex = 3;\r
-            else if (text_destination.Text.EndsWith(".ogm"))\r
-                DVD_Save.FilterIndex = 4;\r
-            else if (text_destination.Text.EndsWith(".mkv"))\r
-                DVD_Save.FilterIndex = 5;\r
 \r
             if (DVD_Save.ShowDialog() == DialogResult.OK)\r
             {\r
@@ -682,53 +1073,164 @@ namespace Handbrake
                     MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
                 else\r
                 {\r
-                    setAudioByContainer(DVD_Save.FileName);\r
+                    // Add a file extension manually, as FileDialog.AddExtension has issues with dots in filenames\r
+                    switch (DVD_Save.FilterIndex)\r
+                    {\r
+                        case 1:\r
+                            if (!Path.GetExtension(DVD_Save.FileName).Equals(".mp4", StringComparison.InvariantCultureIgnoreCase))\r
+                                if (Properties.Settings.Default.useM4v)\r
+                                    DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".m4v").Replace(".mkv", ".m4v");\r
+                                else\r
+                                    DVD_Save.FileName = DVD_Save.FileName.Replace(".m4v", ".mp4").Replace(".mkv", ".mp4");\r
+                            break;\r
+                        case 2:\r
+                            if (!Path.GetExtension(DVD_Save.FileName).Equals(".mkv", StringComparison.InvariantCultureIgnoreCase))\r
+                                DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", ".mkv").Replace(".m4v", ".mkv");\r
+                            break;\r
+                        default:\r
+                            //do nothing  \r
+                            break;\r
+                    }\r
                     text_destination.Text = DVD_Save.FileName;\r
 \r
                     // Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)\r
-                    if (Check_ChapterMarkers.Checked)\r
-                        text_destination.Text = text_destination.Text.Replace(".mp4", ".m4v");\r
+                    if (Check_ChapterMarkers.Checked && DVD_Save.FilterIndex != 2)\r
+                        SetExtension(".m4v");\r
                 }\r
             }\r
         }\r
         private void text_destination_TextChanged(object sender, EventArgs e)\r
         {\r
-            setAudioByContainer(text_destination.Text);\r
-            setVideoByContainer(text_destination.Text);\r
             string path = text_destination.Text;\r
-            if (path.EndsWith(".mp4"))\r
+            if (path.EndsWith(".mp4") || path.EndsWith(".m4v"))\r
                 drop_format.SelectedIndex = 0;\r
-            else if (path.EndsWith(".m4v"))\r
-                drop_format.SelectedIndex = 1;\r
             else if (path.EndsWith(".mkv"))\r
-                drop_format.SelectedIndex = 2;\r
-            else if (path.EndsWith(".avi"))\r
-                drop_format.SelectedIndex = 3;\r
-            else if (path.EndsWith(".ogm"))\r
-                drop_format.SelectedIndex = 4;\r
-\r
+                drop_format.SelectedIndex = 1;\r
         }\r
 \r
         // Output Settings\r
         private void drop_format_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if (drop_format.SelectedIndex == 0)\r
-                setExtension(".mp4");\r
-            else if (drop_format.SelectedIndex == 1)\r
-                setExtension(".m4v");\r
-            else if (drop_format.SelectedIndex == 2)\r
-                setExtension(".mkv");\r
-            else if (drop_format.SelectedIndex == 3)\r
-                setExtension(".avi");\r
-            else if (drop_format.SelectedIndex == 4)\r
-                setExtension(".ogm");\r
+            switch (drop_format.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
+                        SetExtension(".m4v");\r
+                    else\r
+                        SetExtension(".mp4");\r
+                    break;\r
+                case 1:\r
+                    SetExtension(".mkv");\r
+                    break;\r
+            }\r
+\r
+            AudioSettings.SetContainer(drop_format.Text);\r
+            Subtitles.SetContainer(drop_format.SelectedIndex);\r
+\r
+            if (drop_format.Text.Contains("MP4"))\r
+            {\r
+                if (drp_videoEncoder.Items.Contains("VP3 (Theora)"))\r
+                {\r
+                    drp_videoEncoder.Items.Remove("VP3 (Theora)");\r
+                    drp_videoEncoder.SelectedIndex = 1;\r
+                }\r
+            }\r
+            else if (drop_format.Text.Contains("MKV"))\r
+                drp_videoEncoder.Items.Add("VP3 (Theora)");\r
+        }\r
+        public void SetExtension(string newExtension)\r
+        {\r
+            if (newExtension == ".mp4" || newExtension == ".m4v")\r
+                if (Properties.Settings.Default.useM4v || Check_ChapterMarkers.Checked || AudioSettings.RequiresM4V() || Subtitles.RequiresM4V())\r
+                    newExtension = ".m4v";\r
+                else\r
+                    newExtension = ".mp4";\r
 \r
+            if (Path.HasExtension(newExtension))\r
+                text_destination.Text = Path.ChangeExtension(text_destination.Text, newExtension);\r
         }\r
 \r
         //Video Tab\r
         private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))\r
+            setContainerOpts();\r
+\r
+            //Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
+            if (drp_videoEncoder.Text.Contains("H.264"))\r
+            {\r
+                if (check_2PassEncode.CheckState == CheckState.Checked)\r
+                    check_turbo.Enabled = true;\r
+\r
+                tab_advanced.Enabled = true;\r
+                if ((drop_format.Text.Contains("MP4")) || (drop_format.Text.Contains("M4V")))\r
+                    check_iPodAtom.Enabled = true;\r
+                else\r
+                    check_iPodAtom.Enabled = false;\r
+            }\r
+            else\r
+            {\r
+                check_turbo.CheckState = CheckState.Unchecked;\r
+                check_turbo.Enabled = false;\r
+                tab_advanced.Enabled = false;\r
+                x264Panel.x264Query = "";\r
+                check_iPodAtom.Enabled = false;\r
+                check_iPodAtom.Checked = false;\r
+            }\r
+\r
+            // Setup the CQ Slider\r
+            switch (drp_videoEncoder.Text)\r
+            {\r
+                case "MPEG-4 (FFmpeg)":\r
+                    if (slider_videoQuality.Value > 31)\r
+                        slider_videoQuality.Value = 20;   // Just reset to 70% QP 10 on encode change.\r
+                    slider_videoQuality.Minimum = 1;\r
+                    slider_videoQuality.Maximum = 31;\r
+                    break;\r
+                case "H.264 (x264)":\r
+                    slider_videoQuality.Minimum = 0;\r
+                    slider_videoQuality.TickFrequency = 1;\r
+\r
+                    CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");\r
+                    double cqStep = Properties.Settings.Default.x264cqstep;\r
+                    double multiplier = 1.0 / cqStep;\r
+                    double value = slider_videoQuality.Value * multiplier;\r
+\r
+                    switch (Properties.Settings.Default.x264cqstep.ToString(culture))\r
+                    {\r
+                        case "0.2":\r
+                            slider_videoQuality.Maximum = 255;\r
+                            break;\r
+                        case "0.25":\r
+                            slider_videoQuality.Maximum = 204;\r
+                            break;\r
+                        case "0.5":\r
+                            slider_videoQuality.Maximum = 102;\r
+                            break;\r
+                        case "1":\r
+                            slider_videoQuality.Maximum = 51;\r
+                            break;\r
+                        default:\r
+                            slider_videoQuality.Maximum = 51;\r
+                            break;\r
+                    }\r
+                    if (value < slider_videoQuality.Maximum)\r
+                        slider_videoQuality.Value = slider_videoQuality.Maximum - (int)value;\r
+\r
+                    break;\r
+                case "VP3 (Theora)":\r
+                    if (slider_videoQuality.Value > 63)\r
+                        slider_videoQuality.Value = 45;  // Just reset to 70% QP 45 on encode change.\r
+                    slider_videoQuality.Minimum = 0;\r
+                    slider_videoQuality.Maximum = 63;\r
+                    break;\r
+            }\r
+        }\r
+        /// <summary>\r
+        /// Set the container format options\r
+        /// </summary>\r
+        public void setContainerOpts()\r
+        {\r
+            if ((drop_format.Text.Contains("MP4")) || (drop_format.Text.Contains("M4V")))\r
             {\r
                 check_largeFile.Enabled = true;\r
                 check_optimiseMP4.Enabled = true;\r
@@ -743,54 +1245,101 @@ namespace Handbrake
                 check_optimiseMP4.Checked = false;\r
                 check_iPodAtom.Checked = false;\r
             }\r
+        }\r
+        private double _cachedCqStep = Properties.Settings.Default.x264cqstep;\r
+        /// <summary>\r
+        /// Update the CQ slider for x264 for a new CQ step. This is set from option\r
+        /// </summary>\r
+        public void setQualityFromSlider()\r
+        {\r
+            // Work out the current RF value.\r
+            double cqStep = _cachedCqStep;\r
+            double rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
 \r
-\r
-            //Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
-            if (drp_videoEncoder.Text.Contains("H.264"))\r
+            // Change the maximum value for the slider\r
+            switch (Properties.Settings.Default.x264cqstep.ToString(new CultureInfo("en-US")))\r
             {\r
-                if (check_2PassEncode.CheckState == CheckState.Checked)\r
-                    check_turbo.Enabled = true;\r
-\r
-                h264Tab.Enabled = true;\r
-                if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))\r
-                    check_iPodAtom.Enabled = true;\r
-                else\r
-                    check_iPodAtom.Enabled = false;\r
-                if (!drp_anamorphic.Items.Contains("Loose"))\r
-                    drp_anamorphic.Items.Add("Loose");\r
+                case "0.2":\r
+                    slider_videoQuality.Maximum = 255;\r
+                    break;\r
+                case "0.25":\r
+                    slider_videoQuality.Maximum = 204;\r
+                    break;\r
+                case "0.5":\r
+                    slider_videoQuality.Maximum = 102;\r
+                    break;\r
+                case "1":\r
+                    slider_videoQuality.Maximum = 51;\r
+                    break;\r
+                default:\r
+                    slider_videoQuality.Maximum = 51;\r
+                    break;\r
             }\r
-            else\r
+\r
+            // Reset the CQ slider to RF0\r
+            slider_videoQuality.Value = slider_videoQuality.Maximum;\r
+\r
+            // Reset the CQ slider back to the previous value as close as possible\r
+            double cqStepNew = Properties.Settings.Default.x264cqstep;\r
+            double rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew;\r
+            while (rfValueCurrent < rfValue)\r
             {\r
-                check_turbo.CheckState = CheckState.Unchecked;\r
-                check_turbo.Enabled = false;\r
-                h264Tab.Enabled = false;\r
-                rtf_x264Query.Text = "";\r
-                check_iPodAtom.Enabled = false;\r
-                check_iPodAtom.Checked = false;\r
-                if (drp_anamorphic.Items.Count == 3)\r
-                    drp_anamorphic.Items.RemoveAt(2);\r
+                slider_videoQuality.Value--;\r
+                rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew;\r
             }\r
 \r
+            // Cache the CQ step for the next calculation\r
+            _cachedCqStep = Properties.Settings.Default.x264cqstep;\r
         }\r
-        private void text_bitrate_TextChanged(object sender, EventArgs e)\r
+        private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
         {\r
-            text_filesize.Text = "";\r
-            slider_videoQuality.Value = 0;\r
-            SliderValue.Text = "0%";\r
+            double cqStep = Properties.Settings.Default.x264cqstep;\r
+            switch (drp_videoEncoder.Text)\r
+            {\r
+                case "MPEG-4 (FFmpeg)":\r
+                    double rfValue = 31 - (slider_videoQuality.Value - 1);\r
+                    double max = slider_videoQuality.Maximum;\r
+                    double min = slider_videoQuality.Minimum;\r
+                    double val = ((max - min) - (rfValue - min)) / (max - min);\r
+                    SliderValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "% QP:" + (32 - slider_videoQuality.Value);\r
+                    break;\r
+                case "H.264 (x264)":\r
+                    rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
+                    max = slider_videoQuality.Maximum * cqStep;\r
+                    min = slider_videoQuality.Minimum;\r
+                    val = ((max - min) - (rfValue - min)) / (max - min);\r
+                    rfValue = Math.Round(rfValue, 2);\r
+                    SliderValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "% RF:" + rfValue.ToString(new CultureInfo("en-US"));\r
+                    break;\r
+                case "VP3 (Theora)":\r
+                    rfValue = slider_videoQuality.Value;\r
+                    double value = rfValue / 63;\r
+                    SliderValue.Text = Math.Round((value * 100), 2).ToString(new CultureInfo("en-US")) + "% QP:" + slider_videoQuality.Value;\r
+                    break;\r
+            }\r
+        }\r
+        private void radio_targetFilesize_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            text_bitrate.Enabled = false;\r
+            text_filesize.Enabled = true;\r
+            slider_videoQuality.Enabled = false;\r
+\r
             check_2PassEncode.Enabled = true;\r
         }\r
-        private void text_filesize_TextChanged(object sender, EventArgs e)\r
+        private void radio_avgBitrate_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            text_bitrate.Text = "";\r
-            slider_videoQuality.Value = 0;\r
-            SliderValue.Text = "0%";\r
+            text_bitrate.Enabled = true;\r
+            text_filesize.Enabled = false;\r
+            slider_videoQuality.Enabled = false;\r
+\r
             check_2PassEncode.Enabled = true;\r
         }\r
-        private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
+        private void radio_cq_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
-            text_bitrate.Text = "";\r
-            text_filesize.Text = "";\r
+            text_bitrate.Enabled = false;\r
+            text_filesize.Enabled = false;\r
+            slider_videoQuality.Enabled = true;\r
+\r
             check_2PassEncode.Enabled = false;\r
             check_2PassEncode.CheckState = CheckState.Unchecked;\r
         }\r
@@ -808,803 +1357,322 @@ namespace Handbrake
             }\r
         }\r
 \r
-        //Picture Tab\r
-        private void text_width_TextChanged(object sender, EventArgs e)\r
+        // Chapter Marker Tab\r
+        private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            maxWidth = 0;  // Reset max width so that it's not using the MaxWidth -X. Quick hack to allow -X for preset usage.\r
-\r
-            int width;\r
-            Boolean parsed = int.TryParse(text_width.Text, out width);\r
-            if (parsed != false)\r
-            {\r
-                if ((width % 16) != 0)\r
-                    text_width.BackColor = Color.LightCoral;\r
-                else\r
-                    text_width.BackColor = Color.LightGreen;\r
-\r
-\r
-                if (lbl_Aspect.Text != "Select a Title" && maxWidth != 0 && maxHeight != 0)\r
-                {\r
-                    if (drp_anamorphic.Text == "None")\r
-                    {\r
-                        int height = hb_common_func.cacluateNonAnamorphicHeight(width, text_top.Value, text_bottom.Value, text_left.Value, text_right.Value, selectedTitle);\r
-                        text_height.Text = height.ToString();\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        private void text_height_TextChanged(object sender, EventArgs e)\r
-        {\r
-            maxHeight = 0;  // Reset max height so that it's not using the MaxHeight -Y. Quick hack to allow -Y for preset usage.\r
-\r
-            int height;\r
-            Boolean parsed = int.TryParse(text_height.Text, out height);\r
-            if (parsed != false)\r
-            {\r
-                if ((height % 16) != 0)\r
-                    text_height.BackColor = Color.LightCoral;\r
-                else\r
-                    text_height.BackColor = Color.LightGreen;\r
-            }\r
-        }\r
-        private void check_customCrop_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            text_left.Enabled = true;\r
-            text_right.Enabled = true;\r
-            text_top.Enabled = true;\r
-            text_bottom.Enabled = true;\r
-            if (selectedTitle != null)\r
+            if (Check_ChapterMarkers.Checked)\r
             {\r
-                text_top.Text = selectedTitle.AutoCropDimensions[0].ToString();\r
-                text_bottom.Text = selectedTitle.AutoCropDimensions[1].ToString();\r
-                text_left.Text = selectedTitle.AutoCropDimensions[2].ToString();\r
-                text_right.Text = selectedTitle.AutoCropDimensions[3].ToString();\r
+                if (drop_format.SelectedIndex != 1)\r
+                    SetExtension(".m4v");\r
+                data_chpt.Enabled = true;\r
+                btn_importChapters.Enabled = true;\r
             }\r
             else\r
             {\r
-                text_left.Text = "0";\r
-                text_right.Text = "0";\r
-                text_top.Text = "0";\r
-                text_bottom.Text = "0";\r
-            }\r
-        }\r
-        private void check_autoCrop_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            text_left.Enabled = false;\r
-            text_right.Enabled = false;\r
-            text_top.Enabled = false;\r
-            text_bottom.Enabled = false;\r
-        }\r
-        private void drp_anamorphic_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_anamorphic.SelectedIndex == 1)\r
-            {\r
-                text_height.BackColor = Color.LightGray;\r
-                text_width.BackColor = Color.LightGray;\r
-                text_height.Text = "";\r
-                text_width.Text = "";\r
-                text_height.Enabled = false;\r
-                text_width.Enabled = false;\r
-            }\r
-\r
-            if (drp_anamorphic.SelectedIndex == 2)\r
-            {\r
-                text_height.Text = "";\r
-                text_height.Enabled = false;\r
-                text_height.BackColor = Color.LightGray;\r
-\r
-                text_width.Enabled = true;\r
-                text_width.BackColor = Color.White;\r
-            }\r
-\r
-            if (drp_anamorphic.SelectedIndex == 0)\r
-            {\r
-                text_height.BackColor = Color.White;\r
-                text_width.BackColor = Color.White;\r
-                text_height.Enabled = true;\r
-                text_width.Enabled = true;\r
+                if (drop_format.SelectedIndex != 1 && !Properties.Settings.Default.useM4v)\r
+                    SetExtension(".mp4");\r
+                data_chpt.Enabled = false;\r
+                btn_importChapters.Enabled = false;\r
             }\r
         }\r
-        private void slider_deblock_Scroll(object sender, EventArgs e)\r
+        private void btn_importChapters_Click(object sender, EventArgs e)\r
         {\r
-            if (slider_deblock.Value == 4)\r
-                lbl_deblockVal.Text = "Off";\r
-            else\r
-                lbl_deblockVal.Text = slider_deblock.Value.ToString();\r
-        }\r
-\r
-        // Audio Tab\r
-        private void drp_track2Audio_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_track2Audio.SelectedItem.Equals("None"))\r
-            {\r
-                drp_audbit_2.Enabled = false;\r
-                drp_audenc_2.Enabled = false;\r
-                drp_audsr_2.Enabled = false;\r
-                drp_audmix_2.Enabled = false;\r
-                trackBar2.Enabled = false;\r
-                drp_audbit_2.Text = "";\r
-                drp_audenc_2.Text = "";\r
-                drp_audsr_2.Text = "";\r
-                drp_audmix_2.Text = "Automatic";\r
-                trackBar2.Value = 0;\r
-\r
-                // Disable the 3rd Track.\r
-                drp_track3Audio.Enabled = false;\r
-                drp_track3Audio.Text = "None";\r
-                drp_audbit_3.Text = "";\r
-                drp_audenc_3.Text = "";\r
-                drp_audsr_3.Text = "";\r
-                drp_audmix_3.Text = "Automatic";\r
-                trackBar3.Value = 0;\r
-            }\r
-            else\r
+            if (File_ChapterImport.ShowDialog() == DialogResult.OK)\r
             {\r
-                drp_audbit_2.Enabled = true;\r
-                drp_audenc_2.Enabled = true;\r
-                drp_audsr_2.Enabled = true;\r
-                drp_audmix_2.Enabled = true;\r
-                trackBar2.Enabled = true;\r
-                drp_audbit_2.Text = "160";\r
-                drp_audenc_2.Text = "AAC";\r
-                drp_audsr_2.Text = "Auto";\r
-                drp_audmix_2.Text = "Automatic";\r
-\r
-                // Enable the 3rd Track.\r
-                drp_track3Audio.Enabled = true;\r
-                drp_audbit_3.Text = "";\r
-                drp_audenc_3.Text = "";\r
-                drp_audsr_3.Text = "";\r
-                drp_audmix_3.Text = "Automatic";\r
-            }\r
-        }\r
-        private void drp_track3Audio_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_track3Audio.SelectedItem.Equals("None"))\r
-            {\r
-                drp_audbit_3.Enabled = false;\r
-                drp_audenc_3.Enabled = false;\r
-                drp_audsr_3.Enabled = false;\r
-                drp_audmix_3.Enabled = false;\r
-                trackBar3.Enabled = false;\r
-                drp_audbit_3.Text = "";\r
-                drp_audenc_3.Text = "";\r
-                drp_audsr_3.Text = "";\r
-                drp_audmix_3.Text = "Automatic";\r
-                trackBar3.Value = 0;\r
-\r
-                // Disable the 4th Track.\r
-                drp_track4Audio.Enabled = false;\r
-                drp_track4Audio.Text = "None";\r
-                drp_audbit_4.Text = "";\r
-                drp_audenc_4.Text = "";\r
-                drp_audsr_4.Text = "";\r
-                drp_audmix_4.Text = "Automatic";\r
-\r
+                String filename = File_ChapterImport.FileName;\r
+                DataGridView imported = Main.importChapterNames(data_chpt, filename);\r
+                if (imported != null)\r
+                    data_chpt = imported;\r
             }\r
-            else\r
-            {\r
-                drp_audbit_3.Enabled = true;\r
-                drp_audenc_3.Enabled = true;\r
-                drp_audsr_3.Enabled = true;\r
-                drp_audmix_3.Enabled = true;\r
-                trackBar3.Enabled = true;\r
-                drp_audbit_3.Text = "160";\r
-                drp_audenc_3.Text = "AAC";\r
-                drp_audsr_3.Text = "Auto";\r
-                drp_audmix_3.Text = "Automatic";\r
-\r
-                // Enable the 4th Track.\r
-                drp_track4Audio.Enabled = true;\r
-                drp_audbit_4.Text = "";\r
-                drp_audenc_4.Text = "";\r
-                drp_audsr_4.Text = "";\r
-                drp_audmix_4.Text = "Automatic";\r
-            }\r
-\r
         }\r
-        private void drp_track4Audio_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void mnu_resetChapters_Click(object sender, EventArgs e)\r
         {\r
-            if (drp_track4Audio.SelectedItem.Equals("None"))\r
-            {\r
-                drp_audbit_4.Enabled = false;\r
-                drp_audenc_4.Enabled = false;\r
-                drp_audsr_4.Enabled = false;\r
-                drp_audmix_4.Enabled = false;\r
-                trackBar4.Enabled = false;\r
-                drp_audbit_4.Text = "";\r
-                drp_audenc_4.Text = "";\r
-                drp_audsr_4.Text = "";\r
-                drp_audmix_4.Text = "Automatic";\r
-                trackBar4.Value = 0;\r
-            }\r
-            else\r
+            data_chpt.Rows.Clear();\r
+            DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+            if (chapterGridView != null)\r
             {\r
-                drp_audbit_4.Enabled = true;\r
-                drp_audenc_4.Enabled = true;\r
-                drp_audsr_4.Enabled = true;\r
-                drp_audmix_4.Enabled = true;\r
-                trackBar4.Enabled = true;\r
-                drp_audbit_4.Text = "160";\r
-                drp_audenc_4.Text = "AAC";\r
-                drp_audsr_4.Text = "Auto";\r
-                drp_audmix_4.Text = "Automatic";\r
+                data_chpt = chapterGridView;\r
             }\r
         }\r
 \r
-        private void drp_audmix_1_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if ((drp_audenc_1.Text == "AAC") && (drp_audmix_1.Text == "6 Channel Discrete"))\r
-                setBitrateSelections384(drp_audbit_1);\r
-            else if ((drp_audenc_1.Text == "AAC") && (drp_audmix_1.Text != "6 Channel Discrete"))\r
-            {\r
-                setBitrateSelections160(drp_audbit_1);\r
-                drp_audbit_1.Text = "160";\r
-            }\r
-        }\r
-        private void drp_audmix_2_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if ((drp_audenc_2.Text == "AAC") && (drp_audmix_2.Text == "6 Channel Discrete"))\r
-                setBitrateSelections384(drp_audbit_2);\r
-            else if ((drp_audenc_2.Text == "AAC") && (drp_audmix_2.Text != "6 Channel Discrete"))\r
-            {\r
-                setBitrateSelections160(drp_audbit_2);\r
-                drp_audbit_2.Text = "160";\r
-            }\r
-        }\r
-        private void drp_audmix_3_SelectedIndexChanged(object sender, EventArgs e)\r
+        // Query Editor Tab\r
+        private void btn_generate_Query_Click(object sender, EventArgs e)\r
         {\r
-            if ((drp_audenc_3.Text == "AAC") && (drp_audmix_3.Text == "6 Channel Discrete"))\r
-                setBitrateSelections384(drp_audbit_3);\r
-            else if ((drp_audenc_3.Text == "AAC") && (drp_audmix_3.Text != "6 Channel Discrete"))\r
-            {\r
-                setBitrateSelections160(drp_audbit_3);\r
-                drp_audbit_3.Text = "160";\r
-            }\r
+            rtf_query.Text = queryGen.GenerateCLIQuery(this, 0, null);\r
         }\r
-        private void drp_audmix_4_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void btn_clear_Click(object sender, EventArgs e)\r
         {\r
-            if ((drp_audenc_4.Text == "AAC") && (drp_audmix_4.Text == "6 Channel Discrete"))\r
-                setBitrateSelections384(drp_audbit_4);\r
-            else if ((drp_audenc_4.Text == "AAC") && (drp_audmix_4.Text != "6 Channel Discrete"))\r
-            {\r
-                setBitrateSelections160(drp_audbit_4);\r
-                drp_audbit_4.Text = "160";\r
-            }\r
+            rtf_query.Clear();\r
         }\r
+        #endregion\r
 \r
-        private void drp_audenc_1_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_audenc_1.Text == "AC3")\r
-            {\r
-                drp_audmix_1.Enabled = false;\r
-                drp_audbit_1.Enabled = false;\r
-                drp_audsr_1.Enabled = false;\r
-            }\r
-            else\r
-            {\r
-                drp_audmix_1.Enabled = true;\r
-                drp_audbit_1.Enabled = true;\r
-                drp_audsr_1.Enabled = true;\r
-\r
-                drp_audmix_1.Text = "Automatic";\r
-                drp_audbit_1.Text = "160";\r
-                drp_audsr_1.Text = "Auto";\r
-            }\r
-\r
+        // MainWindow Components, Actions and Functions ***********************\r
 \r
-            if (drp_audenc_1.Text == "AAC")\r
+        #region Source Scan\r
+        public Boolean isScanning { get; set; }\r
+        private static int scanProcessID { get; set; }\r
+        private void startScan(String filename)\r
+        {\r
+            // Setup the GUI components for the scan.\r
+            sourcePath = filename;\r
+            foreach (Control ctrl in Controls)\r
+                if (!(ctrl is StatusStrip || ctrl is MenuStrip || ctrl is ToolStrip))\r
+                    ctrl.Enabled = false;\r
+\r
+            lbl_encode.Visible = true;\r
+            lbl_encode.Text = "Scanning ...";\r
+            btn_source.Enabled = false;\r
+            btn_start.Enabled = false;\r
+            btn_showQueue.Enabled = false;\r
+            btn_add2Queue.Enabled = false;\r
+            tb_preview.Enabled = false;\r
+            mnu_killCLI.Visible = true;\r
+\r
+            // Start hte Scan Thread\r
+            try\r
             {\r
-                drp_audmix_1.Items.Clear();\r
-                drp_audmix_1.Items.Add("Mono");\r
-                drp_audmix_1.Items.Add("Stereo");\r
-                drp_audmix_1.Items.Add("Dolby Surround");\r
-                drp_audmix_1.Items.Add("Dolby Pro Logic II");\r
-                drp_audmix_1.Items.Add("6 Channel Discrete");\r
-\r
-                setBitrateSelections160(drp_audbit_1);\r
+                if (ActivityWindow != null)\r
+                    ActivityWindow.SetLogView(true);\r
+                isScanning = true;\r
+                ThreadPool.QueueUserWorkItem(scanProcess);\r
             }\r
-            else\r
+            catch (Exception exc)\r
             {\r
-                drp_audmix_1.Items.Clear();\r
-                drp_audmix_1.Items.Add("Stereo");\r
-                drp_audmix_1.Items.Add("Dolby Surround");\r
-                drp_audmix_1.Items.Add("Dolby Pro Logic II");\r
-\r
-                setBitrateSelections320(drp_audbit_1);\r
+                MessageBox.Show("frmMain.cs - startScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
-        private void drp_audenc_2_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void scanProcess(object state)\r
         {\r
-            if (drp_audenc_2.Text == "AC3")\r
-            {\r
-                drp_audmix_2.Enabled = false;\r
-                drp_audbit_2.Enabled = false;\r
-                drp_audsr_2.Enabled = false;\r
-\r
-                drp_audmix_2.Text = "Automatic";\r
-                drp_audbit_2.Text = "160";\r
-                drp_audsr_2.Text = "Auto";\r
-            }\r
-            else\r
+            try\r
             {\r
-                // Just make sure not to re-enable the following boxes if the track2 is none\r
-                if (drp_track2Audio.Text != "None")\r
-                {\r
-                    drp_audmix_2.Enabled = true;\r
-                    drp_audbit_2.Enabled = true;\r
-                    drp_audsr_2.Enabled = true;\r
-\r
-                    drp_audmix_2.Text = "Automatic";\r
-                    drp_audbit_2.Text = "160";\r
-                    drp_audsr_2.Text = "Auto";\r
-                }\r
-            }\r
+                string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
+                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+                string dvdInfoPath = Path.Combine(logDir, "last_scan_log.txt");\r
 \r
-            if (drp_audenc_2.Text == "AAC")\r
-            {\r
-                drp_audmix_2.Items.Clear();\r
-                drp_audmix_2.Items.Add("Mono");\r
-                drp_audmix_2.Items.Add("Stereo");\r
-                drp_audmix_2.Items.Add("Dolby Surround");\r
-                drp_audmix_2.Items.Add("Dolby Pro Logic II");\r
-                drp_audmix_2.Items.Add("6 Channel Discrete");\r
+                // Make we don't pick up a stale last_encode_log.txt (and that we have rights to the file)\r
+                if (File.Exists(dvdInfoPath))\r
+                    File.Delete(dvdInfoPath);\r
 \r
-                setBitrateSelections160(drp_audbit_2);\r
-            }\r
-            else\r
-            {\r
-                drp_audmix_2.Items.Clear();\r
-                drp_audmix_2.Items.Add("Stereo");\r
-                drp_audmix_2.Items.Add("Dolby Surround");\r
-                drp_audmix_2.Items.Add("Dolby Pro Logic II");\r
+                String dvdnav = string.Empty;\r
+                if (Properties.Settings.Default.noDvdNav)\r
+                    dvdnav = " --no-dvdnav";\r
+                string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 {2} -v >""{3}"" 2>&1""", handbrakeCLIPath, sourcePath, dvdnav, dvdInfoPath);\r
 \r
-                setBitrateSelections320(drp_audbit_2);\r
-            }\r
-        }\r
-        private void drp_audenc_3_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_audenc_3.Text == "AC3")\r
-            {\r
-                drp_audmix_3.Enabled = false;\r
-                drp_audbit_3.Enabled = false;\r
-                drp_audsr_3.Enabled = false;\r
+                ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden };\r
 \r
-                drp_audmix_3.Text = "Automatic";\r
-                drp_audbit_3.Text = "160";\r
-                drp_audsr_3.Text = "Auto";\r
-            }\r
-            else\r
-            {\r
-                // Just make sure not to re-enable the following boxes if the track above is none\r
-                if (drp_track2Audio.Text != "None")\r
+                Boolean cleanExit = true;\r
+                using (hbproc = Process.Start(hbParseDvd))\r
                 {\r
-                    drp_audmix_3.Enabled = true;\r
-                    drp_audbit_3.Enabled = true;\r
-                    drp_audsr_3.Enabled = true;\r
-\r
-                    drp_audmix_3.Text = "Automatic";\r
-                    drp_audbit_3.Text = "160";\r
-                    drp_audsr_3.Text = "Auto";\r
+                    Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
+                    scanProcessID = Main.getCliProcess(before);\r
+                    hbproc.WaitForExit();\r
+                    if (hbproc.ExitCode != 0)\r
+                        cleanExit = false;\r
                 }\r
-            }\r
 \r
+                if (cleanExit) // If 0 exit code, CLI exited cleanly.\r
+                {\r
+                    if (!File.Exists(dvdInfoPath))\r
+                        throw new Exception("Unable to retrieve the DVD Info. last_scan_log.txt is missing. \nExpected location of last_scan_log.txt: \n"\r
+                                            + dvdInfoPath);\r
 \r
-            if (drp_audenc_3.Text == "AAC")\r
-            {\r
-                drp_audmix_3.Items.Clear();\r
-                drp_audmix_3.Items.Add("Mono");\r
-                drp_audmix_3.Items.Add("Stereo");\r
-                drp_audmix_3.Items.Add("Dolby Surround");\r
-                drp_audmix_3.Items.Add("Dolby Pro Logic II");\r
-                drp_audmix_3.Items.Add("6 Channel Discrete");\r
+                    using (StreamReader sr = new StreamReader(dvdInfoPath))\r
+                    {\r
+                        thisDVD = DVD.Parse(sr);\r
+                        sr.Close();\r
+                        sr.Dispose();\r
+                    }\r
 \r
-                setBitrateSelections160(drp_audbit_3);\r
+                    updateUIafterScan();\r
+                }\r
             }\r
-            else\r
+            catch (Exception exc)\r
             {\r
-                drp_audmix_3.Items.Clear();\r
-                drp_audmix_3.Items.Add("Stereo");\r
-                drp_audmix_3.Items.Add("Dolby Surround");\r
-                drp_audmix_3.Items.Add("Dolby Pro Logic II");\r
-\r
-                setBitrateSelections320(drp_audbit_3);\r
+                MessageBox.Show("frmMain.cs - scanProcess() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                enableGUI();\r
             }\r
         }\r
-        private void drp_audenc_4_SelectedIndexChanged(object sender, EventArgs e)\r
+        private void updateUIafterScan()\r
         {\r
-            if (drp_audenc_4.Text == "AC3")\r
-            {\r
-                drp_audmix_4.Enabled = false;\r
-                drp_audbit_4.Enabled = false;\r
-                drp_audsr_4.Enabled = false;\r
-\r
-                drp_audmix_4.Text = "Automatic";\r
-                drp_audbit_4.Text = "160";\r
-                drp_audsr_4.Text = "Auto";\r
-            }\r
-            else\r
+            try\r
             {\r
-                // Just make sure not to re-enable the following boxes if the track above is none\r
-                if (drp_track2Audio.Text != "None")\r
+                if (InvokeRequired)\r
                 {\r
-                    drp_audmix_4.Enabled = true;\r
-                    drp_audbit_4.Enabled = true;\r
-                    drp_audsr_4.Enabled = true;\r
-\r
-                    drp_audmix_4.Text = "Automatic";\r
-                    drp_audbit_4.Text = "160";\r
-                    drp_audsr_4.Text = "Auto";\r
+                    BeginInvoke(new UpdateWindowHandler(updateUIafterScan));\r
+                    return;\r
                 }\r
-            }\r
-\r
 \r
-            if (drp_audenc_4.Text == "AAC")\r
-            {\r
-                drp_audmix_4.Items.Clear();\r
-                drp_audmix_4.Items.Add("Mono");\r
-                drp_audmix_4.Items.Add("Stereo");\r
-                drp_audmix_4.Items.Add("Dolby Surround");\r
-                drp_audmix_4.Items.Add("Dolby Pro Logic II");\r
-                drp_audmix_4.Items.Add("6 Channel Discrete");\r
+                // Setup some GUI components\r
+                drp_dvdtitle.Items.Clear();\r
+                if (thisDVD.Titles.Count != 0)\r
+                    drp_dvdtitle.Items.AddRange(thisDVD.Titles.ToArray());\r
 \r
-                setBitrateSelections160(drp_audbit_4);\r
-            }\r
-            else\r
-            {\r
-                drp_audmix_4.Items.Clear();\r
-                drp_audmix_4.Items.Add("Stereo");\r
-                drp_audmix_4.Items.Add("Dolby Surround");\r
-                drp_audmix_4.Items.Add("Dolby Pro Logic II");\r
+                // Now select the longest title\r
+                if (thisDVD.Titles.Count != 0)\r
+                    drp_dvdtitle.SelectedItem = Main.selectLongestTitle(thisDVD);\r
 \r
-                setBitrateSelections320(drp_audbit_4);\r
-            }\r
-        }\r
-\r
-        private void trackBar1_Scroll(object sender, EventArgs e)\r
-        {\r
-            double value = trackBar1.Value / 10.0;\r
-            value++;\r
-\r
-            lbl_drc1.Text = value.ToString();\r
-        }\r
-        private void trackBar2_Scroll(object sender, EventArgs e)\r
-        {\r
-            double value = trackBar2.Value / 10.0;\r
-            value++;\r
-\r
-            lbl_drc2.Text = value.ToString();\r
-        }\r
-        private void trackBar3_Scroll(object sender, EventArgs e)\r
-        {\r
-            double value = trackBar3.Value / 10.0;\r
-            value++;\r
-\r
-            lbl_drc3.Text = value.ToString();\r
-        }\r
-        private void trackBar4_Scroll(object sender, EventArgs e)\r
-        {\r
-            double value = trackBar4.Value / 10.0;\r
-            value++;\r
+                // Enable the creation of chapter markers if the file is an image of a dvd.\r
+                if (sourcePath.ToLower().Contains(".iso") || sourcePath.Contains("VIDEO_TS"))\r
+                    Check_ChapterMarkers.Enabled = true;\r
+                else if (Directory.Exists(Path.Combine(sourcePath, "VIDEO_TS")))\r
+                    Check_ChapterMarkers.Enabled = true;\r
+                else\r
+                {\r
+                    Check_ChapterMarkers.Enabled = false;\r
+                    Check_ChapterMarkers.Checked = false;\r
+                    data_chpt.Rows.Clear();\r
+                }\r
 \r
-            lbl_drc4.Text = value.ToString();\r
-        }\r
+                // If no titles were found, Display an error message\r
+                if (drp_dvdtitle.Items.Count == 0)\r
+                {\r
+                    MessageBox.Show(\r
+                        "No Title(s) found. \n\nYour Source may be copy protected, badly mastered or in a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).",\r
+                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
+                    sourcePath = string.Empty;\r
+                }\r
+                UpdateSourceLabel();\r
 \r
-        private void drp_subtitle_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            if (drp_subtitle.Text.Contains("None"))\r
+                // Enable the GUI components and enable any disabled components\r
+                enableGUI();\r
+            }\r
+            catch (Exception exc)\r
             {\r
-                check_forced.Enabled = false;\r
-                check_forced.Checked = false;\r
+                MessageBox.Show("frmMain.cs - updateUIafterScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                enableGUI();\r
             }\r
-            else\r
-                check_forced.Enabled = true;\r
         }\r
-\r
-        // Chapter Marker Tab\r
-        private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
+        private void enableGUI()\r
         {\r
-            if (Check_ChapterMarkers.Checked)\r
+            try\r
             {\r
-                string destination = text_destination.Text;\r
-                destination = destination.Replace(".mp4", ".m4v");\r
-                text_destination.Text = destination;\r
-                data_chpt.Rows.Clear();\r
-                data_chpt.Enabled = true;\r
-                DataGridView chapterGridView = hb_common_func.chapterNaming(data_chpt, drop_chapterStart.Text, drop_chapterFinish.Text);\r
-                if (chapterGridView != null)\r
-                    data_chpt = chapterGridView;\r
+                if (InvokeRequired)\r
+                    BeginInvoke(new UpdateWindowHandler(enableGUI));\r
+                lbl_encode.Text = "Scan Completed";\r
+                foreach (Control ctrl in Controls)\r
+                    ctrl.Enabled = true;\r
+                btn_start.Enabled = true;\r
+                btn_showQueue.Enabled = true;\r
+                btn_add2Queue.Enabled = true;\r
+                tb_preview.Enabled = true;\r
+                btn_source.Enabled = true;\r
+                mnu_killCLI.Visible = false;\r
             }\r
-            else\r
+            catch (Exception exc)\r
             {\r
-                string destination = text_destination.Text;\r
-                destination = destination.Replace(".m4v", ".mp4");\r
-                text_destination.Text = destination;\r
-                data_chpt.Rows.Clear();\r
-                data_chpt.Enabled = false;\r
+                MessageBox.Show("frmMain.cs - enableGUI() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
-\r
-        // Advanced Tab\r
-        private void drop_refFrames_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("ref", this);\r
-        }\r
-        private void check_mixedReferences_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("mixed-refs", this);\r
-        }\r
-        private void drop_bFrames_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("bframes", this);\r
-        }\r
-        private void drop_directPrediction_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("direct", this);\r
-        }\r
-        private void check_weightedBFrames_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("weightb", this);\r
-        }\r
-        private void check_bFrameDistortion_CheckedChanged(object sender, EventArgs e)\r
+        private void killScan()\r
         {\r
-            x264PanelFunctions.on_x264_WidgetChange("brdo", this);\r
-        }\r
-        private void check_BidirectionalRefinement_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("bime", this);\r
-        }\r
-        private void check_pyrmidalBFrames_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("b-pyramid", this);\r
-        }\r
-        private void drop_MotionEstimationMethod_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("me", this);\r
-        }\r
-        private void drop_MotionEstimationRange_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("merange", this);\r
-        }\r
-        private void drop_subpixelMotionEstimation_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("subq", this);\r
-        }\r
-        private void drop_analysis_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("analyse", this);\r
-        }\r
-        private void check_8x8DCT_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("8x8dct", this);\r
-        }\r
-        private void drop_deblockAlpha_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("deblock", this);\r
-\r
-        }\r
-        private void drop_deblockBeta_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("deblock", this);\r
-\r
-        }\r
-        private void drop_trellis_SelectedIndexChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("trellis", this);\r
-        }\r
-        private void check_noFastPSkip_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("no-fast-pskip", this);\r
-        }\r
-        private void check_noDCTDecimate_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            x264PanelFunctions.on_x264_WidgetChange("no-dct-decimate", this);\r
-\r
-        }\r
-        private void check_Cabac_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-\r
-            x264PanelFunctions.on_x264_WidgetChange("cabac", this);\r
-        }\r
-\r
-        private void rtf_x264Query_TextChanged(object sender, EventArgs e)\r
-        {\r
-            if (rtf_x264Query.Text.EndsWith("\n"))\r
+            try\r
             {\r
-                rtf_x264Query.Text = rtf_x264Query.Text.Replace("\n", "");\r
-                x264PanelFunctions.X264_StandardizeOptString(this);\r
-                x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
+                enableGUI();\r
+                resetGUI();\r
 \r
-                if (rtf_x264Query.Text == string.Empty)\r
-                    x264PanelFunctions.reset2Defaults(this);\r
+                Process[] prs = Process.GetProcesses();\r
+                foreach (Process process in prs)\r
+                {\r
+                    if (process.Id == scanProcessID)\r
+                    {\r
+                        process.Refresh();\r
+                        if (!process.HasExited)\r
+                            process.Kill();\r
+                    }\r
+                }\r
             }\r
-        }\r
-        private void btn_reset_Click(object sender, EventArgs e)\r
-        {\r
-            rtf_x264Query.Text = "";\r
-            x264PanelFunctions.reset2Defaults(this);\r
-        }\r
-\r
-        // Query Editor Tab\r
-        private void btn_generate_Query_Click(object sender, EventArgs e)\r
-        {\r
-            rtf_query.Text = queryGen.GenerateTheQuery(this);\r
-        }\r
-        private void btn_clear_Click(object sender, EventArgs e)\r
-        {\r
-            rtf_query.Clear();\r
-        }\r
-\r
-        // Presets\r
-        private void btn_addPreset_Click(object sender, EventArgs e)\r
-        {\r
-            // Remember each nodes expanded status so we can reload it\r
-            List<Boolean> nodeStatus = saveTreeViewState();\r
-            nodeStatus.Add(true);\r
-\r
-            // Now add the new preset\r
-            Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);\r
-            preset.ShowDialog();\r
-\r
-            // Now reload the TreeView states\r
-            loadTreeViewStates(nodeStatus);\r
-        }\r
-        private void btn_removePreset_Click(object sender, EventArgs e)\r
-        {\r
-            DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-            if (result == DialogResult.Yes)\r
+            catch (Exception ex)\r
             {\r
-                if (treeView_presets.SelectedNode != null)\r
-                    presetHandler.remove(treeView_presets.SelectedNode.Text);\r
-\r
-                // Remember each nodes expanded status so we can reload it\r
-                List<Boolean> nodeStatus = saveTreeViewState();\r
-\r
-                // Now reload the preset panel\r
-                loadPresetPanel();\r
-\r
-                // Now reload the TreeView states\r
-                loadTreeViewStates(nodeStatus);\r
+                MessageBox.Show("Unable to kill HandBrakeCLI.exe \nYou may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically within the next few minutes. \n\nError Information: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
-            treeView_presets.Select();\r
         }\r
-        private void btn_setDefault_Click(object sender, EventArgs e)\r
+        private void resetGUI()\r
         {\r
-            String query = queryGen.GenerateTheQuery(this);\r
-            Properties.Settings.Default.defaultUserSettings = query;\r
-            // Save the new default Settings\r
-            Properties.Settings.Default.Save();\r
-            MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+            drp_dvdtitle.Items.Clear();\r
+            drop_chapterStart.Items.Clear();\r
+            drop_chapterFinish.Items.Clear();\r
+            lbl_duration.Text = "Select a Title";\r
+            PictureSettings.lbl_src_res.Text = "Select a Title";\r
+            PictureSettings.lbl_Aspect.Text = "Select a Title";\r
+            sourcePath = String.Empty;\r
+            text_destination.Text = String.Empty;\r
+            thisDVD = null;\r
+            selectedTitle = null;\r
+            isScanning = false;\r
         }\r
-        private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)\r
+        private void UpdateSourceLabel()\r
         {\r
-            // Ok, so, we've selected a preset. Now we want to load it.\r
-            string presetName = treeView_presets.SelectedNode.Text;\r
-            string query = presetHandler.getCliForPreset(presetName);\r
-\r
-            if (query != null)\r
-            {\r
-                //Ok, Reset all the H264 widgets before changing the preset\r
-                x264PanelFunctions.reset2Defaults(this);\r
-\r
-                // Send the query from the file to the Query Parser class\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);\r
-\r
-                // Now load the preset\r
-                presetLoader.presetLoader(this, presetQuery, presetName);\r
-\r
-                // The x264 widgets will need updated, so do this now:\r
-                x264PanelFunctions.X264_StandardizeOptString(this);\r
-                x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);\r
-            }\r
+            labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName;\r
         }\r
-        private void treeView_presets_deleteKey(object sender, KeyEventArgs e)\r
+        #endregion\r
+\r
+        #region GUI\r
+        /// <summary>\r
+        /// Set the GUI to it's finished encoding state.\r
+        /// </summary>\r
+        private void setEncodeFinished()\r
         {\r
-            if (e.KeyCode == Keys.Delete)\r
+            try\r
             {\r
-                DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
-                if (result == DialogResult.Yes)\r
+                if (InvokeRequired)\r
                 {\r
-                    if (treeView_presets.SelectedNode != null)\r
-                        presetHandler.remove(treeView_presets.SelectedNode.Text);\r
-\r
-                    // Remember each nodes expanded status so we can reload it\r
-                    List<Boolean> nodeStatus = new List<Boolean>();\r
-                    foreach (TreeNode node in treeView_presets.Nodes)\r
-                        nodeStatus.Add(node.IsExpanded);\r
+                    BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
+                    return;\r
+                }\r
 \r
-                    // Now reload the preset panel\r
-                    loadPresetPanel();\r
+                lbl_encode.Text = "Encoding Finished";\r
+                btn_start.Text = "Start";\r
+                btn_start.ToolTipText = "Start the encoding process";\r
+                btn_start.Image = Properties.Resources.Play;\r
 \r
-                    // And finally, re-expand any of the nodes if required\r
-                    int i = 0;\r
-                    foreach (TreeNode node in treeView_presets.Nodes)\r
+                // If the window is minimized, display the notification in a popup.\r
+                if (Properties.Settings.Default.trayIconAlerts)\r
+                    if (FormWindowState.Minimized == this.WindowState)\r
                     {\r
-                        if (nodeStatus[i] == true)\r
-                            node.Expand();\r
-\r
-                        i++;\r
+                        notifyIcon.BalloonTipText = lbl_encode.Text;\r
+                        notifyIcon.ShowBalloonTip(500);\r
                     }\r
-                }\r
             }\r
-        }\r
-\r
-        #endregion\r
-\r
-        #region Preset Expand / Collaspe\r
-        private List<Boolean> saveTreeViewState()\r
-        {\r
-            // Remember each nodes expanded status so we can reload it\r
-            List<Boolean> nodeStatus = new List<Boolean>();\r
-            foreach (TreeNode node in treeView_presets.Nodes)\r
+            catch (Exception exc)\r
             {\r
-                nodeStatus.Add(node.IsExpanded);\r
-                foreach (TreeNode subNode in node.Nodes)\r
-                    nodeStatus.Add(node.IsExpanded);\r
+                MessageBox.Show(exc.ToString());\r
             }\r
-            return nodeStatus;\r
         }\r
 \r
-        private void loadTreeViewStates(List<Boolean> nodeStatus)\r
+        /// <summary>\r
+        /// Set the GUI to it's started encoding state.\r
+        /// </summary>\r
+        private void setEncodeStarted()\r
         {\r
-            // And finally, re-expand any of the nodes if required\r
-            int i = 0;\r
-            foreach (TreeNode node in treeView_presets.Nodes)\r
+            try\r
             {\r
-                if (nodeStatus[i] == true)\r
-                    node.Expand();\r
-\r
-                foreach (TreeNode subNode in node.Nodes)\r
+                if (InvokeRequired)\r
                 {\r
-                    if (nodeStatus[i] == true)\r
-                        subNode.Expand();\r
+                    BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
+                    return;\r
                 }\r
 \r
-                i++;\r
+                lbl_encode.Visible = true;\r
+                lbl_encode.Text = "Encoding with " + encodeQueue.Count + " encode(s) pending";\r
+                btn_start.Text = "Stop";\r
+                btn_start.ToolTipText = "Stop the encoding process.";\r
+                btn_start.Image = Properties.Resources.stop;\r
             }\r
-        }\r
-        #endregion\r
-\r
-        #region Functions\r
-        private void loadNormalPreset()\r
-        {\r
-            treeView_presets.Nodes.Find("Normal", true);\r
-\r
-            foreach (TreeNode treenode in treeView_presets.Nodes)\r
+            catch (Exception exc)\r
             {\r
-                foreach (TreeNode node in treenode.Nodes)\r
-                {\r
-                    if (node.Text.ToString().Equals("Normal"))\r
-                        treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];\r
-                }\r
+                MessageBox.Show(exc.ToString());\r
             }\r
         }\r
-        /// <summary>\r
-        /// Take in a File destination and change it's file extension to a new Extension\r
-        /// </summary>\r
-        /// <param name="destination"></param>\r
-        /// <param name="newExtension"></param>\r
-        /// <returns>String of the new file path and extension</returns>\r
-        public void setExtension(string newExtension)\r
-        {\r
-            text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".avi", newExtension);\r
-            text_destination.Text = text_destination.Text.Replace(".ogm", newExtension);\r
-        }\r
         #endregion\r
 \r
-        #region Drive Detection\r
-        // Source Button Drive Detection\r
-        private delegate void ProgressUpdateHandler();\r
+        #region DVD Drive Detection\r
         private void getDriveInfoThread()\r
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));\r
+                    BeginInvoke(new UpdateWindowHandler(getDriveInfoThread));\r
                     return;\r
                 }\r
 \r
@@ -1612,17 +1680,15 @@ namespace Handbrake
                 DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
                 foreach (DriveInfo curDrive in theCollectionOfDrives)\r
                 {\r
-                    if (curDrive.DriveType == DriveType.CDRom)\r
+                    if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)\r
                     {\r
-                        if (curDrive.IsReady)\r
+                        if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
                         {\r
-                            if (File.Exists(curDrive.RootDirectory.ToString() + "VIDEO_TS\\VIDEO_TS.IFO"))\r
-                                mnu_dvd_drive.Text = curDrive.RootDirectory.ToString() + "VIDEO_TS (" + curDrive.VolumeLabel + ")";\r
-                            else\r
-                                mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
-\r
+                            this.dvdDrivePath = curDrive.RootDirectory + "VIDEO_TS";\r
+                            this.dvdDriveLabel = curDrive.VolumeLabel;\r
+                            mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")";\r
                             foundDrive = true;\r
-\r
+                            break;\r
                         }\r
                     }\r
                 }\r
@@ -1637,475 +1703,79 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
-        #region Audio Panel Stuff\r
-        public void setAudioByContainer(String path)\r
-        {\r
-            string oldval = "";\r
-\r
-            if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))\r
-            {\r
-                oldval = drp_audenc_1.Text;\r
-                drp_audenc_1.Items.Clear();\r
-                drp_audenc_1.Items.Add("AAC");\r
-                drp_audenc_1.Items.Add("AC3");\r
-                if ((oldval != "AAC") && (oldval != "AC3"))\r
-                    drp_audenc_1.SelectedIndex = 0;\r
-\r
-                oldval = drp_audenc_2.Text;\r
-                drp_audenc_2.Items.Clear();\r
-                drp_audenc_2.Items.Add("AAC");\r
-                drp_audenc_2.Items.Add("AC3");\r
-                if (drp_audenc_2.Enabled)\r
-                {\r
-                    if ((oldval != "AAC") && (oldval != "AC3"))\r
-                        drp_audenc_2.SelectedIndex = 0;\r
-                }\r
-\r
-                oldval = drp_audenc_3.Text;\r
-                drp_audenc_3.Items.Clear();\r
-                drp_audenc_3.Items.Add("AAC");\r
-                drp_audenc_3.Items.Add("AC3");\r
-                if (drp_audenc_3.Enabled)\r
-                {\r
-                    if ((oldval != "AAC") && (oldval != "AC3"))\r
-                        drp_audenc_3.SelectedIndex = 0;\r
-                }\r
-\r
-                oldval = drp_audenc_4.Text;\r
-                drp_audenc_4.Items.Clear();\r
-                drp_audenc_4.Items.Add("AAC");\r
-                drp_audenc_4.Items.Add("AC3");\r
-                if (drp_audenc_4.Enabled)\r
-                {\r
-                    if ((oldval != "AAC") && (oldval != "AC3"))\r
-                        drp_audenc_4.SelectedIndex = 0;\r
-                }\r
-            }\r
-            else if (path.EndsWith(".avi"))\r
-            {\r
-                oldval = drp_audenc_1.Text;\r
-                drp_audenc_1.Items.Clear();\r
-                drp_audenc_1.Items.Add("MP3");\r
-                drp_audenc_1.Items.Add("AC3");\r
-                if ((oldval != "MP3") && (oldval != "AC3"))\r
-                    drp_audenc_1.SelectedIndex = 0;\r
-\r
-                oldval = drp_audenc_2.Text;\r
-                drp_audenc_2.Items.Clear();\r
-                drp_audenc_2.Items.Add("MP3");\r
-                drp_audenc_2.Items.Add("AC3");\r
-                if (drp_audenc_2.Enabled)\r
-                {\r
-                    if ((oldval != "MP3") && (oldval != "AC3"))\r
-                        drp_audenc_2.SelectedIndex = 0;\r
-                }\r
-\r
-\r
-                oldval = drp_audenc_3.Text;\r
-                drp_audenc_3.Items.Clear();\r
-                drp_audenc_3.Items.Add("MP3");\r
-                drp_audenc_3.Items.Add("AC3");\r
-                if (drp_audenc_3.Enabled)\r
-                {\r
-                    if ((oldval != "MP3") && (oldval != "AC3"))\r
-                        drp_audenc_3.SelectedIndex = 0;\r
-                }\r
-\r
-                oldval = drp_audenc_4.Text;\r
-                drp_audenc_4.Items.Clear();\r
-                drp_audenc_4.Items.Add("MP3");\r
-                drp_audenc_4.Items.Add("AC3");\r
-                if (drp_audenc_4.Enabled)\r
-                {\r
-                    if ((oldval != "MP3") && (oldval != "AC3"))\r
-                        drp_audenc_4.SelectedIndex = 0;\r
-                }\r
-            }\r
-            else if (path.EndsWith(".ogm"))\r
-            {\r
-                drp_audenc_1.Items.Clear();\r
-                drp_audenc_1.Items.Add("Vorbis");\r
-                drp_audenc_1.SelectedIndex = 0;\r
-\r
-                drp_audenc_2.Items.Clear();\r
-                drp_audenc_2.Items.Add("Vorbis");\r
-                if (drp_audenc_2.Enabled)\r
-                    drp_audenc_2.SelectedIndex = 0;\r
-\r
-                drp_audenc_3.Items.Clear();\r
-                drp_audenc_3.Items.Add("Vorbis");\r
-                if (drp_audenc_3.Enabled)\r
-                    drp_audenc_3.SelectedIndex = 0;\r
-\r
-                drp_audenc_4.Items.Clear();\r
-                drp_audenc_4.Items.Add("Vorbis");\r
-                if (drp_audenc_4.Enabled)\r
-                    drp_audenc_4.SelectedIndex = 0;\r
-            }\r
-            else if (path.EndsWith(".mkv"))\r
-            {\r
-                drp_audenc_1.Items.Clear();\r
-                drp_audenc_1.Items.Add("AAC");\r
-                drp_audenc_1.Items.Add("MP3");\r
-                drp_audenc_1.Items.Add("AC3");\r
-                drp_audenc_1.Items.Add("Vorbis");\r
-                if (drp_audenc_1.Text == string.Empty)\r
-                    drp_audenc_1.SelectedIndex = 0;\r
-\r
-\r
-                drp_audenc_2.Items.Clear();\r
-                drp_audenc_2.Items.Add("AAC");\r
-                drp_audenc_2.Items.Add("MP3");\r
-                drp_audenc_2.Items.Add("AC3");\r
-                drp_audenc_2.Items.Add("Vorbis");\r
-                if (drp_audenc_2.Enabled)\r
-                {\r
-                    if (drp_audenc_2.Text == string.Empty)\r
-                        drp_audenc_2.SelectedIndex = 0;\r
-                }\r
-\r
-                drp_audenc_3.Items.Clear();\r
-                drp_audenc_3.Items.Add("AAC");\r
-                drp_audenc_3.Items.Add("MP3");\r
-                drp_audenc_3.Items.Add("AC3");\r
-                drp_audenc_3.Items.Add("Vorbis");\r
-                if (drp_audenc_3.Enabled)\r
-                {\r
-                    if (drp_audenc_3.Text == string.Empty)\r
-                        drp_audenc_3.SelectedIndex = 0;\r
-                }\r
-\r
-                drp_audenc_4.Items.Clear();\r
-                drp_audenc_4.Items.Add("AAC");\r
-                drp_audenc_4.Items.Add("MP3");\r
-                drp_audenc_4.Items.Add("AC3");\r
-                drp_audenc_4.Items.Add("Vorbis");\r
-                if (drp_audenc_4.Enabled)\r
-                {\r
-                    if (drp_audenc_4.Text == string.Empty)\r
-                        drp_audenc_4.SelectedIndex = 0;\r
-                }\r
-            }\r
-        }\r
-        public void setVideoByContainer(String path)\r
-        {\r
-            string oldval = "";\r
-\r
-            if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))\r
-            {\r
-                oldval = drp_videoEncoder.Text;\r
-                drp_videoEncoder.Items.Clear();\r
-                drp_videoEncoder.Items.Add("MPEG-4 (FFmpeg)");\r
-                drp_videoEncoder.Items.Add("MPEG-4 (XviD)");\r
-                drp_videoEncoder.Items.Add("H.264 (x264)");\r
-                if (oldval == "VP3 (Theora)")\r
-                    drp_videoEncoder.SelectedIndex = 2;\r
-                else\r
-                    drp_videoEncoder.Text = oldval;\r
-\r
-            }\r
-            else if (path.EndsWith(".avi"))\r
-            {\r
-                oldval = drp_videoEncoder.Text;\r
-                drp_videoEncoder.Items.Clear();\r
-                drp_videoEncoder.Items.Add("MPEG-4 (FFmpeg)");\r
-                drp_videoEncoder.Items.Add("MPEG-4 (XviD)");\r
-                drp_videoEncoder.Items.Add("H.264 (x264)");\r
-                if (oldval == "VP3 (Theora)")\r
-                    drp_videoEncoder.SelectedIndex = 2;\r
-                else\r
-                    drp_videoEncoder.Text = oldval;\r
-            }\r
-            else if (path.EndsWith(".ogm"))\r
-            {\r
-                oldval = drp_videoEncoder.Text;\r
-                drp_videoEncoder.Items.Clear();\r
-                drp_videoEncoder.Items.Add("MPEG-4 (FFmpeg)");\r
-                drp_videoEncoder.Items.Add("MPEG-4 (XviD)");\r
-                drp_videoEncoder.Items.Add("VP3 (Theora)");\r
-                if (oldval == "H.264 (x264)")\r
-                    drp_videoEncoder.SelectedIndex = 2;\r
-                else\r
-                    drp_videoEncoder.Text = oldval;\r
-            }\r
-            else if (path.EndsWith(".mkv"))\r
-            {\r
-                oldval = drp_videoEncoder.Text;\r
-                drp_videoEncoder.Items.Clear();\r
-                drp_videoEncoder.Items.Add("MPEG-4 (FFmpeg)");\r
-                drp_videoEncoder.Items.Add("MPEG-4 (XviD)");\r
-                drp_videoEncoder.Items.Add("H.264 (x264)");\r
-                drp_videoEncoder.Items.Add("VP3 (Theora)");\r
-                drp_videoEncoder.Text = oldval;\r
-            }\r
-        }\r
-        public void setBitrateSelections384(ComboBox dropDown)\r
-        {\r
-            dropDown.Items.Clear();\r
-            dropDown.Items.Add("32");\r
-            dropDown.Items.Add("40");\r
-            dropDown.Items.Add("48");\r
-            dropDown.Items.Add("56");\r
-            dropDown.Items.Add("64");\r
-            dropDown.Items.Add("80");\r
-            dropDown.Items.Add("86");\r
-            dropDown.Items.Add("112");\r
-            dropDown.Items.Add("128");\r
-            dropDown.Items.Add("160");\r
-            dropDown.Items.Add("192");\r
-            dropDown.Items.Add("224");\r
-            dropDown.Items.Add("256");\r
-            dropDown.Items.Add("320");\r
-            dropDown.Items.Add("384");\r
-        }\r
-        public void setBitrateSelections320(ComboBox dropDown)\r
-        {\r
-            dropDown.Items.Clear();\r
-            dropDown.Items.Add("32");\r
-            dropDown.Items.Add("40");\r
-            dropDown.Items.Add("48");\r
-            dropDown.Items.Add("56");\r
-            dropDown.Items.Add("64");\r
-            dropDown.Items.Add("80");\r
-            dropDown.Items.Add("86");\r
-            dropDown.Items.Add("112");\r
-            dropDown.Items.Add("128");\r
-            dropDown.Items.Add("160");\r
-            dropDown.Items.Add("192");\r
-            dropDown.Items.Add("224");\r
-            dropDown.Items.Add("256");\r
-            dropDown.Items.Add("320");\r
-        }\r
-        public void setBitrateSelections160(ComboBox dropDown)\r
-        {\r
-            dropDown.Items.Clear();\r
-            dropDown.Items.Add("32");\r
-            dropDown.Items.Add("40");\r
-            dropDown.Items.Add("48");\r
-            dropDown.Items.Add("56");\r
-            dropDown.Items.Add("64");\r
-            dropDown.Items.Add("80");\r
-            dropDown.Items.Add("86");\r
-            dropDown.Items.Add("112");\r
-            dropDown.Items.Add("128");\r
-            dropDown.Items.Add("160");\r
-        }\r
-        #endregion\r
-\r
-        #region Encoding\r
-\r
-        // Declarations\r
-        private delegate void UpdateUIHandler();\r
-\r
-        // Encoding Functions\r
-        private void procMonitor(object state)\r
-        {\r
-            // Make sure we are not already encoding and if we are then display an error.\r
-            if (hbProc != null)\r
-                hbProc.CloseMainWindow();\r
-            else\r
-            {\r
-                hbProc = cliObj.runCli(this, (string)state);\r
-                hbProc.WaitForExit();\r
-                setEncodeLabelFinished();\r
-                hbProc = null;\r
-\r
-                // If the window is minimized, display the notification in a popup.\r
-                if (FormWindowState.Minimized == this.WindowState)\r
-                {\r
-                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
-                    notifyIcon.ShowBalloonTip(500);\r
-                }\r
-\r
-                // After the encode is done, we may want to shutdown, suspend etc.\r
-                cliObj.addCLIQueryToLog((string)state);\r
-                cliObj.copyLog((string)state); // Make a copy of the log in the users desired location if necessary\r
-                cliObj.afterEncodeAction();\r
-            }\r
-        }\r
-        private void setEncodeLabelFinished()\r
-        {\r
-            if (this.InvokeRequired)\r
-            {\r
-                this.BeginInvoke(new UpdateUIHandler(setEncodeLabelFinished));\r
-                return;\r
-            }\r
-            lbl_encode.Text = "Encoding Finished";\r
-            btn_start.Text = "Start";\r
-            btn_start.ToolTipText = "Start the encoding process";\r
-            btn_start.Image = Properties.Resources.Play;\r
-        }\r
-\r
-        #endregion\r
-\r
         #region Public Methods\r
-\r
         /// <summary>\r
-        /// Is the mainWindow currently monitoring an encoding session\r
+        /// Access the preset Handler and setup the preset panel.\r
         /// </summary>\r
-        /// <returns>boolean</returns>\r
-        public Boolean isEncoding()\r
+        public void loadPresetPanel()\r
         {\r
-            if (hbProc == null)\r
-                return false;\r
-            else\r
-                return true;\r
-        }\r
+            if (presetHandler.CheckIfPresetsAreOutOfDate())\r
+                if (!Properties.Settings.Default.presetNotification)\r
+                    MessageBox.Show(splash,\r
+                    "HandBrake has determined your built-in presets are out of date... These presets will now be updated.",\r
+                    "Preset Update", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
 \r
-        /// <summary>\r
-        /// Action can be "encode" or "scan"\r
-        /// Set the last action varible in the main window.\r
-        /// This is used to control which log file is displayed when the Activity window is displayed.\r
-        /// </summary>\r
-        /// <param name="last">String</param>\r
-        public void setLastAction(string last)\r
-        {\r
-            this.lastAction = last;\r
+            presetHandler.GetPresetPanel(ref treeView_presets);\r
+            treeView_presets.Update();\r
         }\r
+        #endregion\r
 \r
+        #region Overrides\r
         /// <summary>\r
-        /// DVD parseing. Pass in a parsed DVD.\r
+        /// If the queue is being processed, prompt the user to confirm application close.\r
         /// </summary>\r
-        /// <param name="dvd"></param>\r
-        public void setStreamReader(Parsing.DVD dvd)\r
+        /// <param name="e"></param>\r
+        protected override void OnFormClosing(FormClosingEventArgs e)\r
         {\r
-            this.thisDVD = dvd;\r
+            // If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
+            if ((encodeQueue.isEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))\r
+            {\r
+                DialogResult result = MessageBox.Show("HandBrake has queue items to process. Closing HandBrake will not stop the current encoding, but will stop processing the queue.\n\nDo you want to close HandBrake?",\r
+                    "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+                if (result == DialogResult.No)\r
+                    e.Cancel = true;\r
+            }\r
+            base.OnFormClosing(e);\r
         }\r
+        #endregion\r
 \r
-        /// <summary>\r
-        /// Reload the preset panel display\r
-        /// </summary>\r
-        public void loadPresetPanel()\r
+        #region In-GUI Encode Status (Experimental)\r
+        private void encodeMonitorThread()\r
         {\r
-            presetHandler.loadPresetData();\r
-\r
-            treeView_presets.Nodes.Clear();\r
-\r
-            List<Presets.Preset> presetNameList = new List<Presets.Preset>();\r
-            List<string> presetNames = new List<string>();\r
-            TreeNode preset_treeview = new TreeNode();\r
-\r
-            TreeNode rootNode = new TreeNode();\r
-            TreeNode rootNodeTwo = new TreeNode();\r
-            TreeNode childNode = new TreeNode();\r
-            int workingLevel = 0;\r
-            string previousCategory = String.Empty;\r
-            string currentCategory = String.Empty;\r
-\r
-            presetNameList = presetHandler.getBuildInPresets();\r
-            if (presetNameList.Count != 0)\r
+            try\r
             {\r
-                foreach (Presets.Preset preset in presetNameList)\r
-                {\r
-                    // Handle Root Nodes\r
-\r
-                    // First Case - No presets have been read yet so setup the root category\r
-                    if (preset.Level == 1 && currentCategory == String.Empty)\r
-                    {\r
-                        rootNode = new TreeNode(preset.Category);\r
-                        workingLevel = preset.Level;\r
-                        currentCategory = preset.Category;\r
-                        previousCategory = preset.Category;\r
-                    }\r
-\r
-                    // Second Case - This is the first sub child node.\r
-                    if (preset.Level == 2 && workingLevel == 1 && currentCategory != preset.Category)\r
-                    {\r
-                        rootNodeTwo = new TreeNode(preset.Category);\r
-                        workingLevel = preset.Level;\r
-                        currentCategory = preset.Category;\r
-                        rootNode.Nodes.Add(rootNodeTwo);\r
-                    }\r
-\r
-                    // Third Case - Any presets the sub presets detected in the above if statment.\r
-                    if (preset.Level == 1 && workingLevel == 2)\r
-                    {\r
-                        workingLevel = preset.Level;\r
-                        currentCategory = preset.Category;\r
-                    }\r
-\r
-                    // Fourth Case - We've finished this root node and are onto the next root node.\r
-                    if (preset.Level == 1 && workingLevel == 1 && previousCategory != preset.Category)\r
-                    {\r
-                        treeView_presets.Nodes.Add(rootNode); // Add the finished node\r
-\r
-                        rootNode = new TreeNode(preset.Category);\r
-                        workingLevel = preset.Level;\r
-                        currentCategory = preset.Category;\r
-                        previousCategory = preset.Category;\r
-                    }\r
-\r
-                    // Handle Child Nodes\r
-                    // Add First level child nodes to the current root node\r
-                    if (preset.Level == 1 && workingLevel == 1 && currentCategory == preset.Category)\r
-                    {\r
-                        childNode = new TreeNode(preset.Name);\r
-                        rootNode.Nodes.Add(childNode);\r
-                    }\r
-\r
-                    // Add Second level child nodes to the current sub root node\r
-                    if (preset.Level == 2 && workingLevel == 2 && currentCategory == preset.Category)\r
-                    {\r
-                        childNode = new TreeNode(preset.Name);\r
-                        rootNodeTwo.Nodes.Add(childNode);\r
-                    }\r
-                }\r
-\r
-                // Add the final root node which does not get added above.\r
-                treeView_presets.Nodes.Add(rootNode);\r
+                Parser encode = new Parser(encodeQueue.hbProcess.StandardOutput.BaseStream);\r
+                encode.OnEncodeProgress += encodeOnEncodeProgress;\r
+                while (!encode.EndOfStream)\r
+                    encode.readEncodeStatus();\r
             }\r
-\r
-\r
-            // User Presets\r
-            presetNames = presetHandler.getUserPresetNames();\r
-            foreach (string preset in presetNames)\r
+            catch (Exception exc)\r
             {\r
-                preset_treeview = new TreeNode(preset);\r
-                preset_treeview.ForeColor = Color.Black;\r
-\r
-                // Now Fill Out List View with Items\r
-                treeView_presets.Nodes.Add(preset_treeview);\r
+                MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
-\r
-        #endregion\r
-\r
-        #region Taskbar Tray Icon\r
-        private void frmMain_Resize(object sender, EventArgs e)\r
+        private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
         {\r
-            if (FormWindowState.Minimized == this.WindowState)\r
+            if (this.InvokeRequired)\r
             {\r
-                notifyIcon.Visible = true;\r
-                if (lbl_encode.Text != "")\r
-                    notifyIcon.BalloonTipText = lbl_encode.Text;\r
-                else\r
-                    notifyIcon.BalloonTipText = "Not Encoding";\r
-                notifyIcon.ShowBalloonTip(500);\r
-                this.Hide();\r
+                this.BeginInvoke(new EncodeProgressEventHandler(encodeOnEncodeProgress),\r
+                    new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
+                return;\r
             }\r
-            else if (FormWindowState.Normal == this.WindowState)\r
-                notifyIcon.Visible = false;\r
+            lbl_encode.Text = string.Format("Encode Progress: {0}%,       FPS: {1},       Avg FPS: {2},       Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);\r
         }\r
-        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)\r
-        {\r
-            this.Visible = true;\r
-            this.Activate();\r
-            this.WindowState = FormWindowState.Normal;\r
-            notifyIcon.Visible = false;\r
-        }\r
-        private void btn_minimize_Click(object sender, EventArgs e)\r
-        {\r
-            this.WindowState = FormWindowState.Minimized;\r
-        }\r
-        private void btn_restore_Click(object sender, EventArgs e)\r
+        #endregion\r
+\r
+        #region enum\r
+        private enum SourceType\r
         {\r
-            this.Visible = true;\r
-            this.Activate();\r
-            this.WindowState = FormWindowState.Normal;\r
-            notifyIcon.Visible = false;\r
+            None = 0,\r
+            Folder,\r
+            DvdDrive,\r
+            VideoFile\r
         }\r
         #endregion\r
 \r
-        // This is the END of the road ------------------------------------------------------------------------------\r
+        // This is the END of the road ****************************************\r
     }\r
 }
\ No newline at end of file
index 1ae5e66..be71f92 100644 (file)
   <resheader name="writer">\r
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
   </resheader>\r
-  <metadata name="Label38.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-    <value>False</value>\r
-  </metadata>\r
   <metadata name="notifyIconMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>977, 15</value>\r
+    <value>17, 54</value>\r
   </metadata>\r
   <metadata name="notifyIconMenu.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>False</value>\r
   <metadata name="DVD_Save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>556, 15</value>\r
   </metadata>\r
-  <metadata name="File_Save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>664, 15</value>\r
-  </metadata>\r
   <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>18, 15</value>\r
   </metadata>\r
-  <data name="drp_subtitle.ToolTip" xml:space="preserve">\r
-    <value>Select the subtitle language you require from this dropdown.\r
- - or -\r
-Autoselect: Scan for subtitles in an extra 1st pass, and choose\r
-the one that's only used 10 percent of the time or less. \r
-This should locate subtitles for short foreign language segments. \r
-Best used in conjunction with forced subtitles.</value>\r
-  </data>\r
   <metadata name="number.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
   <metadata name="name.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
+  <metadata name="ChaptersMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>935, 54</value>\r
+  </metadata>\r
   <data name="data_chpt.ToolTip" xml:space="preserve">\r
     <value>Here you can name each chapter that the encoded video will contain.\r
 Make sure you have selected a "Title" from the "Source" box above otherwise \r
 the list will not be populated with the correct amount of chapters.\r
 Note: Do not change any of the chapter numbers!</value>\r
   </data>\r
-  <data name="check_Cabac.ToolTip" xml:space="preserve">\r
-    <value>CABAC, or context adaptive binary arithmetic coding, is used by x264 to reduce the bitrate needed for a given quality by 15%. \r
-This makes it very cool and very useful, and it should be left on whenever possible. However, it is incompatible with the iPod 5.5G, and makes the AppleTV struggle. \r
-So turn it off for those. CABAC is a kind of entropy coding, which means that it compresses data by making shorthand symbols to represent long streams of data. \r
-The "entropy" part means that the symbols it uses the most often are the smallest. \r
-When you disable CABAC, another entropy coding scheme gets enabled, called CAVLC (context adaptive variable-length coding). \r
-CAVLC is a lot less efficient, which is why it needs 15% more bitrate to achieve the same quality as CABAC.</value>\r
-  </data>\r
-  <data name="drop_deblockBeta.ToolTip" xml:space="preserve">\r
-    <value>x264 includes an in-loop deblocking filter. \r
-What this means is that blocky compression artifacts are smoothed away when you play back the video. \r
-It has two settings: strength and threshold, just like a simple filter in Photoshop. \r
-Strength controls the amount of deblocking applied to the whole frame. \r
-If you drop down below 0, you reduce the amount of blurring.\r
-Go too negative, and you'll get an effect somewhat like oversharpening an image. \r
-Go into positive values, and the image may become too soft. \r
-Threshold controls how sensitive the filter is to whether something in a block is detail that needs to be preserved: lower numbers blur details less. \r
-The default deblocking values are 0 and 0. This does not mean zero deblocking. \r
-It means x264 will apply the regular deblocking strength and thresholds the codec authors have selected as working the best in most cases. \r
-While many, many people stick with the default deblocking values of 0,0, other people disagree. \r
-Some prefer a slightly less blurred image for live action material, and use values like -2,-1 or -2,-2. Others will raise it to 1,1 or even 3,3 for animation. \r
-While the values for each setting extend from -6 to 6, the consensus is that going below -3 or above 3 is worthless.\r
-</value>\r
-  </data>\r
-  <data name="drop_deblockAlpha.ToolTip" xml:space="preserve">\r
-    <value>x264 includes an in-loop deblocking filter. \r
-What this means is that blocky compression artifacts are smoothed away when you play back the video. \r
-It has two settings: strength and threshold, just like a simple filter in Photoshop. \r
-Strength controls the amount of deblocking applied to the whole frame. \r
-If you drop down below 0, you reduce the amount of blurring.\r
-Go too negative, and you'll get an effect somewhat like oversharpening an image. \r
-Go into positive values, and the image may become too soft. \r
-Threshold controls how sensitive the filter is to whether something in a block is detail that needs to be preserved: lower numbers blur details less. \r
-The default deblocking values are 0 and 0. This does not mean zero deblocking. \r
-It means x264 will apply the regular deblocking strength and thresholds the codec authors have selected as working the best in most cases. \r
-While many, many people stick with the default deblocking values of 0,0, other people disagree. \r
-Some prefer a slightly less blurred image for live action material, and use values like -2,-1 or -2,-2. Others will raise it to 1,1 or even 3,3 for animation. \r
-While the values for each setting extend from -6 to 6, the consensus is that going below -3 or above 3 is worthless.</value>\r
-  </data>\r
-  <data name="check_8x8DCT.ToolTip" xml:space="preserve">\r
-    <value>When Analysis is set to "all," checking this box lets x264 break key frames down into 8x8 blocks of pixels for analysis. \r
-This is a high profile feature of H.264, which makes it less compatible. It should slightly decrease bitrate or improve quality.</value>\r
-  </data>\r
-  <data name="drop_analysis.ToolTip" xml:space="preserve">\r
-    <value>Analysis controls how finely x264 divides up a frame to capture detail. \r
-Full macroblocks are 16x16 pixels, but x264 can go down all the way to 4x4 blocks if it judges it necessary. \r
-By default it only breaks up key frames that much. \r
-To give x264 the freedom to make the best decisions for all frames, use "all" analysis. \r
-If you want to create a high profile H.264 video (which is less compatible with the world at large than main profile), \r
-also check the "8x8 DCT blocks" box to add yet another block size for analysis.</value>\r
-  </data>\r
-  <data name="drop_subpixelMotionEstimation.ToolTip" xml:space="preserve">\r
-    <value>This setting is finer-grained than the motion estimation settings above. \r
-Instead of dealing with whole pixels, it deals with fractional pixels. 4, HandBrake's default, means looking at quarter pixels (qpel). \r
-Higher levels increase quality by dividing the pixel more, but take longer to encode. \r
-Using 6 or 7 turns unlocks the ability to turn on more advanced features like B-Frame rate distortion.</value>\r
-  </data>\r
-  <data name="drop_MotionEstimationRange.ToolTip" xml:space="preserve">\r
-    <value>This range is the radius, in pixels, x264 should use for motion estimation searches. \r
-It only has an effect when you use Uneven Multi-Hexagonal or Exhaustive searching. \r
-24, 32, and 64 are good values.</value>\r
-  </data>\r
-  <data name="drop_MotionEstimationMethod.ToolTip" xml:space="preserve">\r
-    <value>This sets the shape of the area x264 searches when estimating motion. \r
-Your choices are a diamond, a hexagon, a more complex hexagonal shape, or searching the entire frame. \r
-You are best off using Uneven Multi-Hexagonal searching.</value>\r
-  </data>\r
-  <data name="check_pyrmidalBFrames.ToolTip" xml:space="preserve">\r
-    <value>B-frame pyramids are a High Profile feature. \r
-This means that if you enable it, YOUR VIDEO WILL NOT PLAY IN QUICKTIME. \r
-Pyramidal B-frames mean that B-frames don't just reference surrounding reference frames â€” \r
- instead, it also treats a previous B-frame as a reference, improving quality/lowering bitrate at the expense of complexity. \r
-Logically, to reference an earlier B-frame, you must tell x264 to use at least 2 B-frames.</value>\r
-  </data>\r
-  <data name="check_weightedBFrames.ToolTip" xml:space="preserve">\r
-    <value>With weighted B-frame prediction enabled, x264 will consider how far away the previous and next P-frames are, \r
-before deciding to make a frame a B-frame. \r
-The effect is that x264 will use fewer B-frames when they'd look bad â€” when it can't accurately predict motion. \r
-Obviously, this only works when you tell x264 to use more than 1 B-frame.  </value>\r
-  </data>\r
-  <data name="drop_directPrediction.ToolTip" xml:space="preserve">\r
-    <value>Direct prediction tells x264 what method to use when guessing motion for certain parts of a B-frame. \r
-It can either look at other parts of the current frame (spatial) or compare against the preceding frame (temporal). \r
-You're best off setting this to automatic, so x264 decides which method is best on its own. \r
-Don't select none assuming it will be faster; instead it will take longer and look worse. \r
-If you're going to choose between spatial and temporal, spatial is usually better. </value>\r
-  </data>\r
   <metadata name="DVD_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>232, 15</value>\r
   </metadata>\r
@@ -254,8 +156,21 @@ If you're going to choose between spatial and temporal, spatial is usually bette
   <metadata name="frmMainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>106, 15</value>\r
   </metadata>\r
+  <metadata name="AudioMenuRowHeightHack.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>392, 54</value>\r
+  </metadata>\r
+  <data name="btn_importChapters.ToolTip" xml:space="preserve">\r
+    <value>Import a comma separated file containing the chapter information.\r
+The CSV should be formatted as follows:\r
+\r
+1,Chapter 1 Name\r
+2,Chapter 2 Name\r
+3,Chapter 3 Name\r
+\r
+Note: Currently, if you wish to use a , in your chapter name, you must escape it with a \</value>\r
+  </data>\r
   <metadata name="presets_menu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>1224, 15</value>\r
+    <value>265, 54</value>\r
   </metadata>\r
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>767, 15</value>\r
@@ -661,10 +576,13 @@ If you're going to choose between spatial and temporal, spatial is usually bette
 </value>\r
   </data>\r
   <metadata name="StatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>1113, 15</value>\r
+    <value>155, 54</value>\r
+  </metadata>\r
+  <metadata name="hbproc.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>595, 54</value>\r
   </metadata>\r
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-    <value>56</value>\r
+    <value>98</value>\r
   </metadata>\r
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
     <value>\r
@@ -1045,4 +963,13 @@ If you're going to choose between spatial and temporal, spatial is usually bette
         AAD6AQAA4AEAAMABAACAAQAAgAEAAMBBAADAYQAAjGEAAIRhAADc+wAA3/8AAA==\r
 </value>\r
   </data>\r
+  <metadata name="File_Save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>664, 15</value>\r
+  </metadata>\r
+  <metadata name="openPreset.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>680, 54</value>\r
+  </metadata>\r
+  <metadata name="File_ChapterImport.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>787, 54</value>\r
+  </metadata>\r
 </root>
\ No newline at end of file
index 91bd684..85c5e1d 100644 (file)
@@ -40,60 +40,123 @@ namespace Handbrake
             this.drp_completeOption = new System.Windows.Forms.ComboBox();\r
             this.tab_options = new System.Windows.Forms.TabControl();\r
             this.tab_general = new System.Windows.Forms.TabPage();\r
+            this.check_growlEncode = new System.Windows.Forms.CheckBox();\r
+            this.check_GrowlQueue = new System.Windows.Forms.CheckBox();\r
+            this.check_m4v = new System.Windows.Forms.CheckBox();\r
+            this.label1 = new System.Windows.Forms.Label();\r
             this.label7 = new System.Windows.Forms.Label();\r
-            this.label5 = new System.Windows.Forms.Label();\r
-            this.txt_autoNameFormat = new System.Windows.Forms.TextBox();\r
-            this.btn_browse = new System.Windows.Forms.Button();\r
-            this.label10 = new System.Windows.Forms.Label();\r
-            this.text_an_path = new System.Windows.Forms.TextBox();\r
+            this.drop_updateCheckDays = new System.Windows.Forms.ComboBox();\r
             this.check_autoNaming = new System.Windows.Forms.CheckBox();\r
-            this.label13 = new System.Windows.Forms.Label();\r
+            this.txt_autoNameFormat = new System.Windows.Forms.TextBox();\r
             this.check_tooltip = new System.Windows.Forms.CheckBox();\r
+            this.label5 = new System.Windows.Forms.Label();\r
             this.check_updateCheck = new System.Windows.Forms.CheckBox();\r
-            this.check_userDefaultSettings = new System.Windows.Forms.CheckBox();\r
-            this.label1 = new System.Windows.Forms.Label();\r
+            this.label10 = new System.Windows.Forms.Label();\r
+            this.btn_browse = new System.Windows.Forms.Button();\r
             this.label2 = new System.Windows.Forms.Label();\r
+            this.label13 = new System.Windows.Forms.Label();\r
+            this.text_an_path = new System.Windows.Forms.TextBox();\r
             this.tab_picture = new System.Windows.Forms.TabPage();\r
-            this.txt_decomb = new System.Windows.Forms.TextBox();\r
-            this.label3 = new System.Windows.Forms.Label();\r
-            this.tab_cli = new System.Windows.Forms.TabPage();\r
+            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.label29 = new System.Windows.Forms.Label();\r
+            this.btn_vlcPath = new System.Windows.Forms.Button();\r
+            this.txt_vlcPath = new System.Windows.Forms.TextBox();\r
+            this.tab_audio_sub = new System.Windows.Forms.TabPage();\r
+            this.label31 = new System.Windows.Forms.Label();\r
             this.label15 = new System.Windows.Forms.Label();\r
-            this.check_saveLogWithVideo = new System.Windows.Forms.CheckBox();\r
+            this.radio_foreignAndSubs = new System.Windows.Forms.RadioButton();\r
+            this.drop_preferredLang = new System.Windows.Forms.ComboBox();\r
+            this.radio_dub = new System.Windows.Forms.RadioButton();\r
+            this.tab_cli = new System.Windows.Forms.TabPage();\r
+            this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.label12 = new System.Windows.Forms.Label();\r
+            this.check_cli_minimized = new System.Windows.Forms.CheckBox();\r
+            this.label9 = new System.Windows.Forms.Label();\r
             this.btn_saveLog = new System.Windows.Forms.Button();\r
-            this.label14 = new System.Windows.Forms.Label();\r
+            this.check_logsInSpecifiedLocation = new System.Windows.Forms.CheckBox();\r
+            this.Label11 = new System.Windows.Forms.Label();\r
+            this.check_saveLogWithVideo = new System.Windows.Forms.CheckBox();\r
+            this.Label4 = new System.Windows.Forms.Label();\r
+            this.label3 = new System.Windows.Forms.Label();\r
             this.text_logPath = new System.Windows.Forms.TextBox();\r
-            this.check_keepLogs = new System.Windows.Forms.CheckBox();\r
-            this.label9 = new System.Windows.Forms.Label();\r
-            this.check_cli_minimized = new System.Windows.Forms.CheckBox();\r
-            this.label12 = new System.Windows.Forms.Label();\r
+            this.cb_logVerboseLvl = new System.Windows.Forms.ComboBox();\r
             this.drp_Priority = new System.Windows.Forms.ComboBox();\r
-            this.Label11 = new System.Windows.Forms.Label();\r
             this.drp_processors = new System.Windows.Forms.ComboBox();\r
-            this.Label4 = new System.Windows.Forms.Label();\r
+            this.btn_viewLogs = new System.Windows.Forms.Button();\r
+            this.btn_clearLogs = new System.Windows.Forms.Button();\r
+            this.label14 = new System.Windows.Forms.Label();\r
             this.tab_advanced = new System.Windows.Forms.TabPage();\r
-            this.lbl_appcastUnstable = new System.Windows.Forms.Label();\r
-            this.check_snapshot = new System.Windows.Forms.CheckBox();\r
-            this.btn_drive_detect = new System.Windows.Forms.CheckBox();\r
+            this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.check_promptOnUnmatchingQueries = new System.Windows.Forms.CheckBox();\r
+            this.check_dvdnav = new System.Windows.Forms.CheckBox();\r
+            this.check_trayStatusAlerts = new System.Windows.Forms.CheckBox();\r
+            this.label32 = new System.Windows.Forms.Label();\r
             this.label6 = new System.Windows.Forms.Label();\r
+            this.drop_x264step = new System.Windows.Forms.ComboBox();\r
+            this.label30 = new System.Windows.Forms.Label();\r
+            this.check_mainMinimize = new System.Windows.Forms.CheckBox();\r
+            this.label28 = new System.Windows.Forms.Label();\r
+            this.check_queryEditorTab = new System.Windows.Forms.CheckBox();\r
+            this.check_disablePresetNotification = new System.Windows.Forms.CheckBox();\r
+            this.check_inGuiStatus = new System.Windows.Forms.CheckBox();\r
+            this.tab_debug = new System.Windows.Forms.TabPage();\r
+            this.check_disableResCalc = new System.Windows.Forms.CheckBox();\r
             this.label8 = new System.Windows.Forms.Label();\r
             this.pictureBox2 = new System.Windows.Forms.PictureBox();\r
             this.pathFinder = new System.Windows.Forms.FolderBrowserDialog();\r
             this.ToolTip = new System.Windows.Forms.ToolTip(this.components);\r
+            this.textBox1 = new System.Windows.Forms.TextBox();\r
+            this.textBox2 = new System.Windows.Forms.TextBox();\r
+            this.checkBox1 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox2 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox3 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox4 = new System.Windows.Forms.CheckBox();\r
+            this.comboBox1 = new System.Windows.Forms.ComboBox();\r
+            this.textBox3 = new System.Windows.Forms.TextBox();\r
+            this.textBox4 = new System.Windows.Forms.TextBox();\r
+            this.checkBox5 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox6 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox7 = new System.Windows.Forms.CheckBox();\r
+            this.checkBox8 = new System.Windows.Forms.CheckBox();\r
+            this.comboBox2 = new System.Windows.Forms.ComboBox();\r
+            this.label16 = new System.Windows.Forms.Label();\r
+            this.label17 = new System.Windows.Forms.Label();\r
+            this.button1 = new System.Windows.Forms.Button();\r
+            this.label18 = new System.Windows.Forms.Label();\r
+            this.label19 = new System.Windows.Forms.Label();\r
+            this.label20 = new System.Windows.Forms.Label();\r
+            this.label21 = new System.Windows.Forms.Label();\r
+            this.label22 = new System.Windows.Forms.Label();\r
+            this.label23 = new System.Windows.Forms.Label();\r
+            this.button2 = new System.Windows.Forms.Button();\r
+            this.label24 = new System.Windows.Forms.Label();\r
+            this.label25 = new System.Windows.Forms.Label();\r
+            this.label26 = new System.Windows.Forms.Label();\r
+            this.label27 = new System.Windows.Forms.Label();\r
+            this.openFile_vlc = new System.Windows.Forms.OpenFileDialog();\r
+            this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();\r
             this.tab_options.SuspendLayout();\r
             this.tab_general.SuspendLayout();\r
             this.tab_picture.SuspendLayout();\r
+            this.tableLayoutPanel2.SuspendLayout();\r
+            this.tab_audio_sub.SuspendLayout();\r
             this.tab_cli.SuspendLayout();\r
+            this.tableLayoutPanel3.SuspendLayout();\r
             this.tab_advanced.SuspendLayout();\r
+            this.tableLayoutPanel4.SuspendLayout();\r
+            this.tab_debug.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();\r
+            this.tableLayoutPanel5.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // btn_close\r
             // \r
+            this.btn_close.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
             this.btn_close.BackColor = System.Drawing.SystemColors.ControlLight;\r
             this.btn_close.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_close.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_close.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_close.Location = new System.Drawing.Point(430, 346);\r
+            this.btn_close.Location = new System.Drawing.Point(519, 404);\r
             this.btn_close.Name = "btn_close";\r
             this.btn_close.Size = new System.Drawing.Size(72, 22);\r
             this.btn_close.TabIndex = 53;\r
@@ -103,18 +166,18 @@ namespace Handbrake
             // \r
             // drp_completeOption\r
             // \r
+            this.drp_completeOption.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.drp_completeOption.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_completeOption.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drp_completeOption.FormattingEnabled = true;\r
             this.drp_completeOption.Items.AddRange(new object[] {\r
-            "Do Nothing",\r
+            "Do nothing",\r
             "Shutdown",\r
             "Suspend",\r
             "Hibernate",\r
-            "Lock System",\r
-            "Log Off",\r
+            "Lock system",\r
+            "Log off",\r
             "Quit HandBrake"});\r
-            this.drp_completeOption.Location = new System.Drawing.Point(114, 100);\r
+            this.drp_completeOption.Location = new System.Drawing.Point(108, 95);\r
             this.drp_completeOption.Name = "drp_completeOption";\r
             this.drp_completeOption.Size = new System.Drawing.Size(166, 21);\r
             this.drp_completeOption.TabIndex = 43;\r
@@ -123,147 +186,187 @@ namespace Handbrake
             // \r
             // tab_options\r
             // \r
+            this.tableLayoutPanel5.SetColumnSpan(this.tab_options, 2);\r
             this.tab_options.Controls.Add(this.tab_general);\r
             this.tab_options.Controls.Add(this.tab_picture);\r
+            this.tab_options.Controls.Add(this.tab_audio_sub);\r
             this.tab_options.Controls.Add(this.tab_cli);\r
             this.tab_options.Controls.Add(this.tab_advanced);\r
-            this.tab_options.Location = new System.Drawing.Point(12, 55);\r
+            this.tab_options.Controls.Add(this.tab_debug);\r
+            this.tab_options.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.tab_options.Location = new System.Drawing.Point(3, 38);\r
             this.tab_options.Name = "tab_options";\r
             this.tab_options.SelectedIndex = 0;\r
-            this.tab_options.Size = new System.Drawing.Size(490, 285);\r
+            this.tab_options.Size = new System.Drawing.Size(588, 360);\r
             this.tab_options.TabIndex = 58;\r
             // \r
             // tab_general\r
             // \r
+            this.tab_general.Controls.Add(this.check_growlEncode);\r
+            this.tab_general.Controls.Add(this.check_GrowlQueue);\r
+            this.tab_general.Controls.Add(this.check_m4v);\r
+            this.tab_general.Controls.Add(this.label1);\r
             this.tab_general.Controls.Add(this.label7);\r
-            this.tab_general.Controls.Add(this.label5);\r
-            this.tab_general.Controls.Add(this.txt_autoNameFormat);\r
-            this.tab_general.Controls.Add(this.btn_browse);\r
-            this.tab_general.Controls.Add(this.label10);\r
-            this.tab_general.Controls.Add(this.text_an_path);\r
+            this.tab_general.Controls.Add(this.drp_completeOption);\r
+            this.tab_general.Controls.Add(this.drop_updateCheckDays);\r
             this.tab_general.Controls.Add(this.check_autoNaming);\r
-            this.tab_general.Controls.Add(this.label13);\r
+            this.tab_general.Controls.Add(this.txt_autoNameFormat);\r
             this.tab_general.Controls.Add(this.check_tooltip);\r
+            this.tab_general.Controls.Add(this.label5);\r
             this.tab_general.Controls.Add(this.check_updateCheck);\r
-            this.tab_general.Controls.Add(this.check_userDefaultSettings);\r
-            this.tab_general.Controls.Add(this.label1);\r
+            this.tab_general.Controls.Add(this.label10);\r
+            this.tab_general.Controls.Add(this.btn_browse);\r
             this.tab_general.Controls.Add(this.label2);\r
-            this.tab_general.Controls.Add(this.drp_completeOption);\r
+            this.tab_general.Controls.Add(this.label13);\r
+            this.tab_general.Controls.Add(this.text_an_path);\r
             this.tab_general.Location = new System.Drawing.Point(4, 22);\r
             this.tab_general.Name = "tab_general";\r
-            this.tab_general.Size = new System.Drawing.Size(482, 259);\r
+            this.tab_general.Padding = new System.Windows.Forms.Padding(10);\r
+            this.tab_general.Size = new System.Drawing.Size(580, 334);\r
             this.tab_general.TabIndex = 3;\r
             this.tab_general.Text = "General";\r
             this.tab_general.UseVisualStyleBackColor = true;\r
             // \r
+            // check_growlEncode\r
+            // \r
+            this.check_growlEncode.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_growlEncode.AutoSize = true;\r
+            this.check_growlEncode.BackColor = System.Drawing.Color.Transparent;\r
+            this.check_growlEncode.Location = new System.Drawing.Point(282, 122);\r
+            this.check_growlEncode.Name = "check_growlEncode";\r
+            this.check_growlEncode.Size = new System.Drawing.Size(171, 17);\r
+            this.check_growlEncode.TabIndex = 99;\r
+            this.check_growlEncode.Text = "Growl after Encode Completes";\r
+            this.ToolTip.SetToolTip(this.check_growlEncode, "If you have \"Growl for Windows\" installed, you can use this feature to see growl " +\r
+                    "alerts on your desktop.");\r
+            this.check_growlEncode.UseVisualStyleBackColor = false;\r
+            this.check_growlEncode.CheckedChanged += new System.EventHandler(this.check_growlEncode_CheckedChanged);\r
+            // \r
+            // check_GrowlQueue\r
+            // \r
+            this.check_GrowlQueue.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_GrowlQueue.AutoSize = true;\r
+            this.check_GrowlQueue.BackColor = System.Drawing.Color.Transparent;\r
+            this.check_GrowlQueue.Location = new System.Drawing.Point(108, 122);\r
+            this.check_GrowlQueue.Name = "check_GrowlQueue";\r
+            this.check_GrowlQueue.Size = new System.Drawing.Size(168, 17);\r
+            this.check_GrowlQueue.TabIndex = 98;\r
+            this.check_GrowlQueue.Text = "Growl after Queue Completes";\r
+            this.ToolTip.SetToolTip(this.check_GrowlQueue, "If you have \"Growl for Windows\" installed, you can use this feature to see growl " +\r
+                    "alerts on your desktop.");\r
+            this.check_GrowlQueue.UseVisualStyleBackColor = false;\r
+            this.check_GrowlQueue.CheckedChanged += new System.EventHandler(this.check_GrowlQueue_CheckedChanged);\r
+            // \r
+            // check_m4v\r
+            // \r
+            this.check_m4v.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_m4v.AutoSize = true;\r
+            this.check_m4v.Location = new System.Drawing.Point(108, 279);\r
+            this.check_m4v.Name = "check_m4v";\r
+            this.check_m4v.Size = new System.Drawing.Size(319, 17);\r
+            this.check_m4v.TabIndex = 82;\r
+            this.check_m4v.Text = "Always use iPod/iTunes friendly file extension (.m4v) for MP4";\r
+            this.ToolTip.SetToolTip(this.check_m4v, resources.GetString("check_m4v.ToolTip"));\r
+            this.check_m4v.UseVisualStyleBackColor = true;\r
+            this.check_m4v.CheckedChanged += new System.EventHandler(this.check_m4v_CheckedChanged);\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label1.AutoSize = true;\r
+            this.label1.BackColor = System.Drawing.Color.Transparent;\r
+            this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label1.Location = new System.Drawing.Point(15, 15);\r
+            this.label1.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(66, 13);\r
+            this.label1.TabIndex = 67;\r
+            this.label1.Text = "At Launch:";\r
+            // \r
             // label7\r
             // \r
+            this.label7.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.label7.AutoSize = true;\r
-            this.label7.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label7.Location = new System.Drawing.Point(197, 222);\r
+            this.label7.Location = new System.Drawing.Point(179, 260);\r
+            this.label7.Margin = new System.Windows.Forms.Padding(3);\r
             this.label7.Name = "label7";\r
-            this.label7.Size = new System.Drawing.Size(242, 12);\r
+            this.label7.Size = new System.Drawing.Size(225, 13);\r
             this.label7.TabIndex = 81;\r
             this.label7.Text = "Available Options: {source} {title} {chapters}";\r
             // \r
-            // label5\r
-            // \r
-            this.label5.AutoSize = true;\r
-            this.label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label5.Location = new System.Drawing.Point(111, 201);\r
-            this.label5.Name = "label5";\r
-            this.label5.Size = new System.Drawing.Size(52, 13);\r
-            this.label5.TabIndex = 80;\r
-            this.label5.Text = "Format:";\r
-            // \r
-            // txt_autoNameFormat\r
-            // \r
-            this.txt_autoNameFormat.Location = new System.Drawing.Point(199, 198);\r
-            this.txt_autoNameFormat.Name = "txt_autoNameFormat";\r
-            this.txt_autoNameFormat.Size = new System.Drawing.Size(255, 21);\r
-            this.txt_autoNameFormat.TabIndex = 79;\r
-            this.ToolTip.SetToolTip(this.txt_autoNameFormat, "Define the format of the automatically named file.\r\ne.g  {source}_{title}_some-te" +\r
-                    "xt\r\n{source} {title} {chapters} will be automatically substituted for the input " +\r
-                    "sources values.");\r
-            this.txt_autoNameFormat.TextChanged += new System.EventHandler(this.txt_autoNameFormat_TextChanged);\r
-            // \r
-            // btn_browse\r
-            // \r
-            this.btn_browse.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_browse.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.btn_browse.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_browse.Location = new System.Drawing.Point(386, 171);\r
-            this.btn_browse.Name = "btn_browse";\r
-            this.btn_browse.Size = new System.Drawing.Size(68, 22);\r
-            this.btn_browse.TabIndex = 78;\r
-            this.btn_browse.Text = "Browse";\r
-            this.btn_browse.UseVisualStyleBackColor = true;\r
-            this.btn_browse.Click += new System.EventHandler(this.btn_browse_Click);\r
-            // \r
-            // label10\r
-            // \r
-            this.label10.AutoSize = true;\r
-            this.label10.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label10.Location = new System.Drawing.Point(111, 174);\r
-            this.label10.Name = "label10";\r
-            this.label10.Size = new System.Drawing.Size(82, 13);\r
-            this.label10.TabIndex = 77;\r
-            this.label10.Text = "Default Path:";\r
-            // \r
-            // text_an_path\r
-            // \r
-            this.text_an_path.Location = new System.Drawing.Point(199, 171);\r
-            this.text_an_path.Name = "text_an_path";\r
-            this.text_an_path.Size = new System.Drawing.Size(181, 21);\r
-            this.text_an_path.TabIndex = 76;\r
-            this.ToolTip.SetToolTip(this.text_an_path, "The default location where auto named files are stored.");\r
-            this.text_an_path.TextChanged += new System.EventHandler(this.text_an_path_TextChanged);\r
+            // drop_updateCheckDays\r
+            // \r
+            this.drop_updateCheckDays.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.drop_updateCheckDays.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_updateCheckDays.FormattingEnabled = true;\r
+            this.drop_updateCheckDays.Items.AddRange(new object[] {\r
+            "Daily",\r
+            "Weekly",\r
+            "Monthly"});\r
+            this.drop_updateCheckDays.Location = new System.Drawing.Point(127, 35);\r
+            this.drop_updateCheckDays.Name = "drop_updateCheckDays";\r
+            this.drop_updateCheckDays.Size = new System.Drawing.Size(97, 21);\r
+            this.drop_updateCheckDays.TabIndex = 97;\r
+            this.ToolTip.SetToolTip(this.drop_updateCheckDays, "Check for updates: Daily, Weekly or Monthly\r\nDefault: Weekly");\r
+            this.drop_updateCheckDays.SelectedIndexChanged += new System.EventHandler(this.drop_updateCheckDays_SelectedIndexChanged);\r
             // \r
             // check_autoNaming\r
             // \r
+            this.check_autoNaming.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_autoNaming.AutoSize = true;\r
-            this.check_autoNaming.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_autoNaming.Location = new System.Drawing.Point(114, 148);\r
+            this.check_autoNaming.Location = new System.Drawing.Point(108, 174);\r
             this.check_autoNaming.Name = "check_autoNaming";\r
-            this.check_autoNaming.Size = new System.Drawing.Size(206, 17);\r
+            this.check_autoNaming.Size = new System.Drawing.Size(176, 17);\r
             this.check_autoNaming.TabIndex = 72;\r
             this.check_autoNaming.Text = "Automatically name output files";\r
             this.ToolTip.SetToolTip(this.check_autoNaming, "Automatically name output files");\r
             this.check_autoNaming.UseVisualStyleBackColor = true;\r
             this.check_autoNaming.CheckedChanged += new System.EventHandler(this.check_autoNaming_CheckedChanged);\r
             // \r
-            // label13\r
+            // txt_autoNameFormat\r
             // \r
-            this.label13.AutoSize = true;\r
-            this.label13.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label13.Location = new System.Drawing.Point(10, 149);\r
-            this.label13.Name = "label13";\r
-            this.label13.Size = new System.Drawing.Size(86, 13);\r
-            this.label13.TabIndex = 71;\r
-            this.label13.Text = "Output files:";\r
+            this.txt_autoNameFormat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.txt_autoNameFormat.Location = new System.Drawing.Point(182, 233);\r
+            this.txt_autoNameFormat.Name = "txt_autoNameFormat";\r
+            this.txt_autoNameFormat.Size = new System.Drawing.Size(349, 21);\r
+            this.txt_autoNameFormat.TabIndex = 79;\r
+            this.ToolTip.SetToolTip(this.txt_autoNameFormat, "Define the format of the automatically named file.\r\ne.g  {source}_{title}_some-te" +\r
+                    "xt\r\n{source} {title} {chapters} will be automatically substituted for the input " +\r
+                    "sources values.");\r
+            this.txt_autoNameFormat.TextChanged += new System.EventHandler(this.txt_autoNameFormat_TextChanged);\r
             // \r
             // check_tooltip\r
             // \r
+            this.check_tooltip.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_tooltip.AutoSize = true;\r
             this.check_tooltip.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_tooltip.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_tooltip.Location = new System.Drawing.Point(114, 41);\r
+            this.check_tooltip.Location = new System.Drawing.Point(108, 62);\r
             this.check_tooltip.Name = "check_tooltip";\r
-            this.check_tooltip.Size = new System.Drawing.Size(135, 17);\r
+            this.check_tooltip.Size = new System.Drawing.Size(117, 17);\r
             this.check_tooltip.TabIndex = 70;\r
             this.check_tooltip.Text = "Enable GUI tooltips";\r
-            this.ToolTip.SetToolTip(this.check_tooltip, "Enable the built in tooltips for gui controls.");\r
+            this.ToolTip.SetToolTip(this.check_tooltip, "Enable the built in tooltips for gui controls. (Requires Restart)");\r
             this.check_tooltip.UseVisualStyleBackColor = false;\r
             this.check_tooltip.CheckedChanged += new System.EventHandler(this.check_tooltip_CheckedChanged);\r
             // \r
+            // label5\r
+            // \r
+            this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label5.AutoSize = true;\r
+            this.label5.Location = new System.Drawing.Point(105, 236);\r
+            this.label5.Name = "label5";\r
+            this.label5.Size = new System.Drawing.Size(45, 13);\r
+            this.label5.TabIndex = 80;\r
+            this.label5.Text = "Format:";\r
+            // \r
             // check_updateCheck\r
             // \r
+            this.check_updateCheck.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.check_updateCheck.AutoSize = true;\r
             this.check_updateCheck.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_updateCheck.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_updateCheck.Location = new System.Drawing.Point(114, 18);\r
+            this.check_updateCheck.Location = new System.Drawing.Point(108, 14);\r
             this.check_updateCheck.Name = "check_updateCheck";\r
-            this.check_updateCheck.Size = new System.Drawing.Size(131, 17);\r
+            this.check_updateCheck.Size = new System.Drawing.Size(114, 17);\r
             this.check_updateCheck.TabIndex = 68;\r
             this.check_updateCheck.Text = "Check for updates";\r
             this.ToolTip.SetToolTip(this.check_updateCheck, "Enables the built in update checker. This check is performed when the application" +\r
@@ -271,198 +374,411 @@ namespace Handbrake
             this.check_updateCheck.UseVisualStyleBackColor = false;\r
             this.check_updateCheck.CheckedChanged += new System.EventHandler(this.check_updateCheck_CheckedChanged);\r
             // \r
-            // check_userDefaultSettings\r
+            // label10\r
             // \r
-            this.check_userDefaultSettings.AutoSize = true;\r
-            this.check_userDefaultSettings.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_userDefaultSettings.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_userDefaultSettings.Location = new System.Drawing.Point(114, 64);\r
-            this.check_userDefaultSettings.Name = "check_userDefaultSettings";\r
-            this.check_userDefaultSettings.Size = new System.Drawing.Size(166, 17);\r
-            this.check_userDefaultSettings.TabIndex = 69;\r
-            this.check_userDefaultSettings.Text = "Load my default settings";\r
-            this.ToolTip.SetToolTip(this.check_userDefaultSettings, "Loads the users default settings rather than the Normal preset.");\r
-            this.check_userDefaultSettings.UseVisualStyleBackColor = false;\r
-            this.check_userDefaultSettings.CheckedChanged += new System.EventHandler(this.check_userDefaultSettings_CheckedChanged);\r
+            this.label10.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label10.AutoSize = true;\r
+            this.label10.Location = new System.Drawing.Point(105, 209);\r
+            this.label10.Name = "label10";\r
+            this.label10.Size = new System.Drawing.Size(71, 13);\r
+            this.label10.TabIndex = 77;\r
+            this.label10.Text = "Default Path:";\r
             // \r
-            // label1\r
+            // btn_browse\r
             // \r
-            this.label1.AutoSize = true;\r
-            this.label1.BackColor = System.Drawing.Color.Transparent;\r
-            this.label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label1.Location = new System.Drawing.Point(21, 19);\r
-            this.label1.Name = "label1";\r
-            this.label1.Size = new System.Drawing.Size(75, 13);\r
-            this.label1.TabIndex = 67;\r
-            this.label1.Text = "At Launch:";\r
+            this.btn_browse.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.btn_browse.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
+            this.btn_browse.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_browse.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_browse.Location = new System.Drawing.Point(456, 204);\r
+            this.btn_browse.Name = "btn_browse";\r
+            this.btn_browse.Size = new System.Drawing.Size(75, 23);\r
+            this.btn_browse.TabIndex = 78;\r
+            this.btn_browse.Text = "Browse";\r
+            this.btn_browse.UseVisualStyleBackColor = true;\r
+            this.btn_browse.Click += new System.EventHandler(this.btn_browse_Click);\r
             // \r
             // label2\r
             // \r
+            this.label2.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
             this.label2.AutoSize = true;\r
-            this.label2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label2.Location = new System.Drawing.Point(12, 103);\r
+            this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label2.Location = new System.Drawing.Point(7, 98);\r
             this.label2.Name = "label2";\r
-            this.label2.Size = new System.Drawing.Size(84, 13);\r
+            this.label2.Size = new System.Drawing.Size(74, 13);\r
             this.label2.TabIndex = 54;\r
             this.label2.Text = "When Done:";\r
             // \r
+            // label13\r
+            // \r
+            this.label13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label13.AutoSize = true;\r
+            this.label13.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label13.Location = new System.Drawing.Point(4, 164);\r
+            this.label13.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label13.Name = "label13";\r
+            this.label13.Size = new System.Drawing.Size(77, 13);\r
+            this.label13.TabIndex = 71;\r
+            this.label13.Text = "Output Files:";\r
+            // \r
+            // text_an_path\r
+            // \r
+            this.text_an_path.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_an_path.Location = new System.Drawing.Point(182, 206);\r
+            this.text_an_path.Name = "text_an_path";\r
+            this.text_an_path.Size = new System.Drawing.Size(253, 21);\r
+            this.text_an_path.TabIndex = 76;\r
+            this.ToolTip.SetToolTip(this.text_an_path, "This is the default location where your encoded files will be stored if \"Automati" +\r
+                    "cally name output files\" is enabled.");\r
+            this.text_an_path.TextChanged += new System.EventHandler(this.text_an_path_TextChanged);\r
+            // \r
             // tab_picture\r
             // \r
-            this.tab_picture.Controls.Add(this.txt_decomb);\r
-            this.tab_picture.Controls.Add(this.label3);\r
+            this.tab_picture.Controls.Add(this.tableLayoutPanel2);\r
             this.tab_picture.Location = new System.Drawing.Point(4, 22);\r
             this.tab_picture.Name = "tab_picture";\r
-            this.tab_picture.Size = new System.Drawing.Size(482, 259);\r
+            this.tab_picture.Padding = new System.Windows.Forms.Padding(10);\r
+            this.tab_picture.Size = new System.Drawing.Size(580, 334);\r
             this.tab_picture.TabIndex = 5;\r
             this.tab_picture.Text = "Picture";\r
             this.tab_picture.UseVisualStyleBackColor = true;\r
             // \r
-            // txt_decomb\r
+            // tableLayoutPanel2\r
+            // \r
+            this.tableLayoutPanel2.AutoSize = true;\r
+            this.tableLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel2.ColumnCount = 4;\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel2.Controls.Add(this.label29, 0, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.btn_vlcPath, 3, 0);\r
+            this.tableLayoutPanel2.Controls.Add(this.txt_vlcPath, 2, 0);\r
+            this.tableLayoutPanel2.Location = new System.Drawing.Point(10, 10);\r
+            this.tableLayoutPanel2.Name = "tableLayoutPanel2";\r
+            this.tableLayoutPanel2.RowCount = 2;\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel2.Size = new System.Drawing.Size(560, 28);\r
+            this.tableLayoutPanel2.TabIndex = 84;\r
+            // \r
+            // label29\r
+            // \r
+            this.label29.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label29.AutoSize = true;\r
+            this.label29.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label29.Location = new System.Drawing.Point(3, 5);\r
+            this.label29.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label29.Name = "label29";\r
+            this.tableLayoutPanel2.SetRowSpan(this.label29, 2);\r
+            this.label29.Size = new System.Drawing.Size(59, 13);\r
+            this.label29.TabIndex = 79;\r
+            this.label29.Text = "VLC Path:";\r
+            // \r
+            // btn_vlcPath\r
+            // \r
+            this.btn_vlcPath.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.btn_vlcPath.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
+            this.btn_vlcPath.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_vlcPath.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.btn_vlcPath.Location = new System.Drawing.Point(489, 3);\r
+            this.btn_vlcPath.Name = "btn_vlcPath";\r
+            this.btn_vlcPath.Size = new System.Drawing.Size(68, 22);\r
+            this.btn_vlcPath.TabIndex = 83;\r
+            this.btn_vlcPath.Text = "Browse";\r
+            this.btn_vlcPath.UseVisualStyleBackColor = true;\r
+            this.btn_vlcPath.Click += new System.EventHandler(this.btn_vlcPath_Click);\r
+            // \r
+            // txt_vlcPath\r
+            // \r
+            this.txt_vlcPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.txt_vlcPath.Location = new System.Drawing.Point(88, 3);\r
+            this.txt_vlcPath.Name = "txt_vlcPath";\r
+            this.txt_vlcPath.Size = new System.Drawing.Size(395, 21);\r
+            this.txt_vlcPath.TabIndex = 81;\r
+            this.ToolTip.SetToolTip(this.txt_vlcPath, "The path where VLC is installed on this system.\r\nThis is used for the video previ" +\r
+                    "ew feature.");\r
+            this.txt_vlcPath.TextChanged += new System.EventHandler(this.txt_vlcPath_TextChanged);\r
+            // \r
+            // tab_audio_sub\r
+            // \r
+            this.tab_audio_sub.Controls.Add(this.label31);\r
+            this.tab_audio_sub.Controls.Add(this.label15);\r
+            this.tab_audio_sub.Controls.Add(this.radio_foreignAndSubs);\r
+            this.tab_audio_sub.Controls.Add(this.drop_preferredLang);\r
+            this.tab_audio_sub.Controls.Add(this.radio_dub);\r
+            this.tab_audio_sub.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_audio_sub.Name = "tab_audio_sub";\r
+            this.tab_audio_sub.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_audio_sub.Size = new System.Drawing.Size(580, 334);\r
+            this.tab_audio_sub.TabIndex = 6;\r
+            this.tab_audio_sub.Text = "Audio / Subtitles";\r
+            this.tab_audio_sub.UseVisualStyleBackColor = true;\r
+            // \r
+            // label31\r
+            // \r
+            this.label31.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label31.AutoSize = true;\r
+            this.label31.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label31.Location = new System.Drawing.Point(16, 19);\r
+            this.label31.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label31.Name = "label31";\r
+            this.label31.Size = new System.Drawing.Size(52, 13);\r
+            this.label31.TabIndex = 91;\r
+            this.label31.Text = "Actions:";\r
             // \r
-            this.txt_decomb.Location = new System.Drawing.Point(90, 16);\r
-            this.txt_decomb.Name = "txt_decomb";\r
-            this.txt_decomb.Size = new System.Drawing.Size(181, 21);\r
-            this.txt_decomb.TabIndex = 78;\r
-            this.ToolTip.SetToolTip(this.txt_decomb, "Default: 4:10:15:9:10:35:9");\r
-            this.txt_decomb.TextChanged += new System.EventHandler(this.txt_decomb_TextChanged);\r
-            // \r
-            // label3\r
+            // label15\r
             // \r
-            this.label3.AutoSize = true;\r
-            this.label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label3.Location = new System.Drawing.Point(21, 19);\r
-            this.label3.Name = "label3";\r
-            this.label3.Size = new System.Drawing.Size(63, 13);\r
-            this.label3.TabIndex = 77;\r
-            this.label3.Text = "Decomb:";\r
+            this.label15.AutoSize = true;\r
+            this.label15.Location = new System.Drawing.Point(87, 19);\r
+            this.label15.Name = "label15";\r
+            this.label15.Size = new System.Drawing.Size(107, 13);\r
+            this.label15.TabIndex = 88;\r
+            this.label15.Text = "Preferred Language:";\r
+            // \r
+            // radio_foreignAndSubs\r
+            // \r
+            this.radio_foreignAndSubs.AutoSize = true;\r
+            this.radio_foreignAndSubs.Location = new System.Drawing.Point(200, 76);\r
+            this.radio_foreignAndSubs.Name = "radio_foreignAndSubs";\r
+            this.radio_foreignAndSubs.Size = new System.Drawing.Size(358, 17);\r
+            this.radio_foreignAndSubs.TabIndex = 90;\r
+            this.radio_foreignAndSubs.TabStop = true;\r
+            this.radio_foreignAndSubs.Text = "Use foreign language audio and add first preferred language subtitle.";\r
+            this.ToolTip.SetToolTip(this.radio_foreignAndSubs, "Use foreign language audio and add first subtitle track of prefered language.\r\n");\r
+            this.radio_foreignAndSubs.UseVisualStyleBackColor = true;\r
+            this.radio_foreignAndSubs.CheckedChanged += new System.EventHandler(this.radio_foreignAndSubs_CheckedChanged);\r
+            // \r
+            // drop_preferredLang\r
+            // \r
+            this.drop_preferredLang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_preferredLang.FormattingEnabled = true;\r
+            this.drop_preferredLang.Location = new System.Drawing.Point(200, 16);\r
+            this.drop_preferredLang.Name = "drop_preferredLang";\r
+            this.drop_preferredLang.Size = new System.Drawing.Size(118, 21);\r
+            this.drop_preferredLang.TabIndex = 87;\r
+            this.ToolTip.SetToolTip(this.drop_preferredLang, "The number of processor\'s / processor cores. Unless your having problems, leave o" +\r
+                    "n Automatic.");\r
+            this.drop_preferredLang.SelectedIndexChanged += new System.EventHandler(this.drop_preferredLang_SelectedIndexChanged);\r
+            // \r
+            // radio_dub\r
+            // \r
+            this.radio_dub.AutoSize = true;\r
+            this.radio_dub.Location = new System.Drawing.Point(200, 53);\r
+            this.radio_dub.Name = "radio_dub";\r
+            this.radio_dub.Size = new System.Drawing.Size(164, 17);\r
+            this.radio_dub.TabIndex = 89;\r
+            this.radio_dub.TabStop = true;\r
+            this.radio_dub.Text = "DUB Foreign Language Audio";\r
+            this.ToolTip.SetToolTip(this.radio_dub, "This option will select your prefered language of audio for the source if one exi" +\r
+                    "sts.");\r
+            this.radio_dub.UseVisualStyleBackColor = true;\r
+            this.radio_dub.CheckedChanged += new System.EventHandler(this.radio_dub_CheckedChanged);\r
             // \r
             // tab_cli\r
             // \r
-            this.tab_cli.Controls.Add(this.label15);\r
-            this.tab_cli.Controls.Add(this.check_saveLogWithVideo);\r
-            this.tab_cli.Controls.Add(this.btn_saveLog);\r
-            this.tab_cli.Controls.Add(this.label14);\r
-            this.tab_cli.Controls.Add(this.text_logPath);\r
-            this.tab_cli.Controls.Add(this.check_keepLogs);\r
-            this.tab_cli.Controls.Add(this.label9);\r
-            this.tab_cli.Controls.Add(this.check_cli_minimized);\r
-            this.tab_cli.Controls.Add(this.label12);\r
-            this.tab_cli.Controls.Add(this.drp_Priority);\r
-            this.tab_cli.Controls.Add(this.Label11);\r
-            this.tab_cli.Controls.Add(this.drp_processors);\r
-            this.tab_cli.Controls.Add(this.Label4);\r
+            this.tab_cli.Controls.Add(this.tableLayoutPanel3);\r
             this.tab_cli.Location = new System.Drawing.Point(4, 22);\r
             this.tab_cli.Name = "tab_cli";\r
-            this.tab_cli.Size = new System.Drawing.Size(482, 259);\r
+            this.tab_cli.Padding = new System.Windows.Forms.Padding(10);\r
+            this.tab_cli.Size = new System.Drawing.Size(580, 334);\r
             this.tab_cli.TabIndex = 2;\r
             this.tab_cli.Text = "CLI";\r
             this.tab_cli.UseVisualStyleBackColor = true;\r
             // \r
-            // label15\r
+            // tableLayoutPanel3\r
+            // \r
+            this.tableLayoutPanel3.AutoSize = true;\r
+            this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel3.ColumnCount = 7;\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel3.Controls.Add(this.label12, 0, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_cli_minimized, 2, 0);\r
+            this.tableLayoutPanel3.Controls.Add(this.label9, 0, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.btn_saveLog, 6, 7);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_logsInSpecifiedLocation, 2, 6);\r
+            this.tableLayoutPanel3.Controls.Add(this.Label11, 2, 1);\r
+            this.tableLayoutPanel3.Controls.Add(this.check_saveLogWithVideo, 2, 5);\r
+            this.tableLayoutPanel3.Controls.Add(this.Label4, 2, 2);\r
+            this.tableLayoutPanel3.Controls.Add(this.label3, 2, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.text_logPath, 3, 7);\r
+            this.tableLayoutPanel3.Controls.Add(this.cb_logVerboseLvl, 3, 4);\r
+            this.tableLayoutPanel3.Controls.Add(this.drp_Priority, 3, 2);\r
+            this.tableLayoutPanel3.Controls.Add(this.drp_processors, 3, 1);\r
+            this.tableLayoutPanel3.Controls.Add(this.btn_viewLogs, 2, 8);\r
+            this.tableLayoutPanel3.Controls.Add(this.btn_clearLogs, 4, 8);\r
+            this.tableLayoutPanel3.Controls.Add(this.label14, 2, 7);\r
+            this.tableLayoutPanel3.Location = new System.Drawing.Point(10, 10);\r
+            this.tableLayoutPanel3.Name = "tableLayoutPanel3";\r
+            this.tableLayoutPanel3.RowCount = 10;\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel3.Size = new System.Drawing.Size(560, 227);\r
+            this.tableLayoutPanel3.TabIndex = 62;\r
             // \r
-            this.label15.AutoSize = true;\r
-            this.label15.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label15.Location = new System.Drawing.Point(195, 197);\r
-            this.label15.Name = "label15";\r
-            this.label15.Size = new System.Drawing.Size(24, 13);\r
-            this.label15.TabIndex = 84;\r
-            this.label15.Text = "OR";\r
+            // label12\r
             // \r
-            // check_saveLogWithVideo\r
+            this.label12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label12.AutoSize = true;\r
+            this.label12.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label12.Location = new System.Drawing.Point(11, 5);\r
+            this.label12.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label12.Name = "label12";\r
+            this.tableLayoutPanel3.SetRowSpan(this.label12, 2);\r
+            this.label12.Size = new System.Drawing.Size(28, 13);\r
+            this.label12.TabIndex = 75;\r
+            this.label12.Text = "CLI:";\r
             // \r
-            this.check_saveLogWithVideo.AutoSize = true;\r
-            this.check_saveLogWithVideo.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_saveLogWithVideo.Location = new System.Drawing.Point(71, 177);\r
-            this.check_saveLogWithVideo.Name = "check_saveLogWithVideo";\r
-            this.check_saveLogWithVideo.Size = new System.Drawing.Size(349, 17);\r
-            this.check_saveLogWithVideo.TabIndex = 83;\r
-            this.check_saveLogWithVideo.Text = "Put individual encode logs in the same location as movie";\r
-            this.ToolTip.SetToolTip(this.check_saveLogWithVideo, "Place a copy of the encode log in the same folder as the encoded movie.");\r
-            this.check_saveLogWithVideo.UseVisualStyleBackColor = true;\r
-            this.check_saveLogWithVideo.CheckedChanged += new System.EventHandler(this.check_saveLogWithVideo_CheckedChanged);\r
+            // check_cli_minimized\r
+            // \r
+            this.check_cli_minimized.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_cli_minimized.AutoSize = true;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.check_cli_minimized, 5);\r
+            this.check_cli_minimized.Location = new System.Drawing.Point(65, 3);\r
+            this.check_cli_minimized.Name = "check_cli_minimized";\r
+            this.check_cli_minimized.Size = new System.Drawing.Size(137, 17);\r
+            this.check_cli_minimized.TabIndex = 76;\r
+            this.check_cli_minimized.Text = "Start window minimized";\r
+            this.ToolTip.SetToolTip(this.check_cli_minimized, "Starts a CLI window minimized.");\r
+            this.check_cli_minimized.UseVisualStyleBackColor = true;\r
+            this.check_cli_minimized.CheckedChanged += new System.EventHandler(this.check_cli_minimized_CheckedChanged);\r
+            // \r
+            // label9\r
+            // \r
+            this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.label9.AutoSize = true;\r
+            this.label9.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label9.Location = new System.Drawing.Point(3, 102);\r
+            this.label9.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
+            this.label9.Name = "label9";\r
+            this.tableLayoutPanel3.SetRowSpan(this.label9, 2);\r
+            this.label9.Size = new System.Drawing.Size(36, 13);\r
+            this.label9.TabIndex = 77;\r
+            this.label9.Text = "Logs:";\r
             // \r
             // btn_saveLog\r
             // \r
+            this.btn_saveLog.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.btn_saveLog.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
-            this.btn_saveLog.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_saveLog.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_saveLog.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_saveLog.Location = new System.Drawing.Point(343, 218);\r
+            this.btn_saveLog.Location = new System.Drawing.Point(480, 173);\r
             this.btn_saveLog.Name = "btn_saveLog";\r
-            this.btn_saveLog.Size = new System.Drawing.Size(68, 22);\r
+            this.btn_saveLog.Size = new System.Drawing.Size(77, 22);\r
             this.btn_saveLog.TabIndex = 82;\r
             this.btn_saveLog.Text = "Browse";\r
             this.btn_saveLog.UseVisualStyleBackColor = true;\r
             this.btn_saveLog.Click += new System.EventHandler(this.btn_saveLog_Click);\r
             // \r
-            // label14\r
+            // check_logsInSpecifiedLocation\r
             // \r
-            this.label14.AutoSize = true;\r
-            this.label14.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label14.Location = new System.Drawing.Point(68, 221);\r
-            this.label14.Name = "label14";\r
-            this.label14.Size = new System.Drawing.Size(61, 13);\r
-            this.label14.TabIndex = 81;\r
-            this.label14.Text = "Log Path:";\r
+            this.check_logsInSpecifiedLocation.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_logsInSpecifiedLocation.AutoSize = true;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.check_logsInSpecifiedLocation, 5);\r
+            this.check_logsInSpecifiedLocation.Location = new System.Drawing.Point(65, 150);\r
+            this.check_logsInSpecifiedLocation.Name = "check_logsInSpecifiedLocation";\r
+            this.check_logsInSpecifiedLocation.Size = new System.Drawing.Size(306, 17);\r
+            this.check_logsInSpecifiedLocation.TabIndex = 87;\r
+            this.check_logsInSpecifiedLocation.Text = "Put a copy of individual encode logs in a specified location:";\r
+            this.ToolTip.SetToolTip(this.check_logsInSpecifiedLocation, "Place a copy of the encode log in the same folder as the encoded movie.");\r
+            this.check_logsInSpecifiedLocation.UseVisualStyleBackColor = true;\r
+            this.check_logsInSpecifiedLocation.CheckedChanged += new System.EventHandler(this.check_logsInSpecifiedLocation_CheckedChanged);\r
             // \r
-            // text_logPath\r
+            // Label11\r
             // \r
-            this.text_logPath.Location = new System.Drawing.Point(135, 218);\r
-            this.text_logPath.Name = "text_logPath";\r
-            this.text_logPath.Size = new System.Drawing.Size(202, 21);\r
-            this.text_logPath.TabIndex = 80;\r
-            this.ToolTip.SetToolTip(this.text_logPath, "The default location where auto named files are stored.");\r
-            this.text_logPath.TextChanged += new System.EventHandler(this.text_logPath_TextChanged);\r
+            this.Label11.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.Label11.AutoSize = true;\r
+            this.Label11.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label11.Location = new System.Drawing.Point(65, 30);\r
+            this.Label11.Name = "Label11";\r
+            this.Label11.Size = new System.Drawing.Size(87, 13);\r
+            this.Label11.TabIndex = 40;\r
+            this.Label11.Text = "Processor cores:";\r
             // \r
-            // check_keepLogs\r
+            // check_saveLogWithVideo\r
             // \r
-            this.check_keepLogs.AutoSize = true;\r
-            this.check_keepLogs.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_keepLogs.Location = new System.Drawing.Point(71, 135);\r
-            this.check_keepLogs.Name = "check_keepLogs";\r
-            this.check_keepLogs.Size = new System.Drawing.Size(185, 17);\r
-            this.check_keepLogs.TabIndex = 79;\r
-            this.check_keepLogs.Text = "Keep individual encode logs";\r
-            this.ToolTip.SetToolTip(this.check_keepLogs, "Save encode logs to a file after the encode has completed.");\r
-            this.check_keepLogs.UseVisualStyleBackColor = true;\r
-            this.check_keepLogs.CheckedChanged += new System.EventHandler(this.check_keepLogs_CheckedChanged);\r
+            this.check_saveLogWithVideo.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_saveLogWithVideo.AutoSize = true;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.check_saveLogWithVideo, 5);\r
+            this.check_saveLogWithVideo.Location = new System.Drawing.Point(65, 127);\r
+            this.check_saveLogWithVideo.Name = "check_saveLogWithVideo";\r
+            this.check_saveLogWithVideo.Size = new System.Drawing.Size(382, 17);\r
+            this.check_saveLogWithVideo.TabIndex = 83;\r
+            this.check_saveLogWithVideo.Text = "Put a copy of individual encode logs in the same location as encoded video";\r
+            this.ToolTip.SetToolTip(this.check_saveLogWithVideo, "Place a copy of the encode log in the same folder as the encoded movie.");\r
+            this.check_saveLogWithVideo.UseVisualStyleBackColor = true;\r
+            this.check_saveLogWithVideo.CheckedChanged += new System.EventHandler(this.check_saveLogWithVideo_CheckedChanged);\r
             // \r
-            // label9\r
+            // Label4\r
             // \r
-            this.label9.AutoSize = true;\r
-            this.label9.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label9.Location = new System.Drawing.Point(12, 136);\r
-            this.label9.Name = "label9";\r
-            this.label9.Size = new System.Drawing.Size(41, 13);\r
-            this.label9.TabIndex = 77;\r
-            this.label9.Text = "Logs:";\r
+            this.Label4.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.Label4.AutoSize = true;\r
+            this.Label4.BackColor = System.Drawing.Color.Transparent;\r
+            this.Label4.Location = new System.Drawing.Point(65, 57);\r
+            this.Label4.Name = "Label4";\r
+            this.Label4.Size = new System.Drawing.Size(70, 13);\r
+            this.Label4.TabIndex = 42;\r
+            this.Label4.Text = "Priority level:";\r
             // \r
-            // check_cli_minimized\r
+            // label3\r
             // \r
-            this.check_cli_minimized.AutoSize = true;\r
-            this.check_cli_minimized.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_cli_minimized.Location = new System.Drawing.Point(71, 18);\r
-            this.check_cli_minimized.Name = "check_cli_minimized";\r
-            this.check_cli_minimized.Size = new System.Drawing.Size(155, 17);\r
-            this.check_cli_minimized.TabIndex = 76;\r
-            this.check_cli_minimized.Text = "Use window minimized";\r
-            this.ToolTip.SetToolTip(this.check_cli_minimized, "Starts a CLI window minimized.");\r
-            this.check_cli_minimized.UseVisualStyleBackColor = true;\r
-            this.check_cli_minimized.CheckedChanged += new System.EventHandler(this.check_cli_minimized_CheckedChanged);\r
+            this.label3.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label3.AutoSize = true;\r
+            this.label3.BackColor = System.Drawing.Color.Transparent;\r
+            this.label3.Location = new System.Drawing.Point(65, 104);\r
+            this.label3.Name = "label3";\r
+            this.label3.Size = new System.Drawing.Size(101, 13);\r
+            this.label3.TabIndex = 85;\r
+            this.label3.Text = "Log verbosity level:";\r
             // \r
-            // label12\r
+            // text_logPath\r
             // \r
-            this.label12.AutoSize = true;\r
-            this.label12.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label12.Location = new System.Drawing.Point(21, 19);\r
-            this.label12.Name = "label12";\r
-            this.label12.Size = new System.Drawing.Size(32, 13);\r
-            this.label12.TabIndex = 75;\r
-            this.label12.Text = "CLI:";\r
+            this.text_logPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.tableLayoutPanel3.SetColumnSpan(this.text_logPath, 3);\r
+            this.text_logPath.Location = new System.Drawing.Point(172, 173);\r
+            this.text_logPath.Name = "text_logPath";\r
+            this.text_logPath.Size = new System.Drawing.Size(302, 21);\r
+            this.text_logPath.TabIndex = 80;\r
+            this.ToolTip.SetToolTip(this.text_logPath, "The default location where auto named files are stored.");\r
+            this.text_logPath.TextChanged += new System.EventHandler(this.text_logPath_TextChanged);\r
+            // \r
+            // cb_logVerboseLvl\r
+            // \r
+            this.cb_logVerboseLvl.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.cb_logVerboseLvl, 4);\r
+            this.cb_logVerboseLvl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.cb_logVerboseLvl.FormattingEnabled = true;\r
+            this.cb_logVerboseLvl.Items.AddRange(new object[] {\r
+            "0",\r
+            "1",\r
+            "2"});\r
+            this.cb_logVerboseLvl.Location = new System.Drawing.Point(172, 100);\r
+            this.cb_logVerboseLvl.Name = "cb_logVerboseLvl";\r
+            this.cb_logVerboseLvl.Size = new System.Drawing.Size(111, 21);\r
+            this.cb_logVerboseLvl.TabIndex = 86;\r
+            this.ToolTip.SetToolTip(this.cb_logVerboseLvl, "Activity Log Verbosity Level");\r
+            this.cb_logVerboseLvl.SelectedIndexChanged += new System.EventHandler(this.cb_logVerboseLvl_SelectedIndexChanged);\r
             // \r
             // drp_Priority\r
             // \r
+            this.drp_Priority.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.drp_Priority, 4);\r
             this.drp_Priority.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_Priority.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drp_Priority.FormattingEnabled = true;\r
             this.drp_Priority.Items.AddRange(new object[] {\r
             "Realtime",\r
@@ -471,7 +787,7 @@ namespace Handbrake
             "Normal",\r
             "Below Normal",\r
             "Low"});\r
-            this.drp_Priority.Location = new System.Drawing.Point(177, 72);\r
+            this.drp_Priority.Location = new System.Drawing.Point(172, 53);\r
             this.drp_Priority.Name = "drp_Priority";\r
             this.drp_Priority.Size = new System.Drawing.Size(111, 21);\r
             this.drp_Priority.TabIndex = 43;\r
@@ -479,21 +795,11 @@ namespace Handbrake
                     "w Normal if you wish to use your system whilst encoding with HandBrake.\r\n");\r
             this.drp_Priority.SelectedIndexChanged += new System.EventHandler(this.drp_Priority_SelectedIndexChanged);\r
             // \r
-            // Label11\r
-            // \r
-            this.Label11.AutoSize = true;\r
-            this.Label11.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label11.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label11.Location = new System.Drawing.Point(68, 48);\r
-            this.Label11.Name = "Label11";\r
-            this.Label11.Size = new System.Drawing.Size(103, 13);\r
-            this.Label11.TabIndex = 40;\r
-            this.Label11.Text = "Processor cores:";\r
-            // \r
             // drp_processors\r
             // \r
+            this.drp_processors.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.drp_processors, 4);\r
             this.drp_processors.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
-            this.drp_processors.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drp_processors.FormattingEnabled = true;\r
             this.drp_processors.Items.AddRange(new object[] {\r
             "Automatic",\r
@@ -505,7 +811,7 @@ namespace Handbrake
             "6",\r
             "7",\r
             "8"});\r
-            this.drp_processors.Location = new System.Drawing.Point(177, 45);\r
+            this.drp_processors.Location = new System.Drawing.Point(172, 26);\r
             this.drp_processors.Name = "drp_processors";\r
             this.drp_processors.Size = new System.Drawing.Size(111, 21);\r
             this.drp_processors.TabIndex = 41;\r
@@ -513,94 +819,305 @@ namespace Handbrake
                     "n Automatic.");\r
             this.drp_processors.SelectedIndexChanged += new System.EventHandler(this.drp_processors_SelectedIndexChanged);\r
             // \r
-            // Label4\r
+            // btn_viewLogs\r
+            // \r
+            this.btn_viewLogs.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.tableLayoutPanel3.SetColumnSpan(this.btn_viewLogs, 2);\r
+            this.btn_viewLogs.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_viewLogs.ForeColor = System.Drawing.Color.DarkOrange;\r
+            this.btn_viewLogs.Location = new System.Drawing.Point(65, 201);\r
+            this.btn_viewLogs.Name = "btn_viewLogs";\r
+            this.btn_viewLogs.Size = new System.Drawing.Size(139, 23);\r
+            this.btn_viewLogs.TabIndex = 89;\r
+            this.btn_viewLogs.Text = "View Log Directory";\r
+            this.btn_viewLogs.UseVisualStyleBackColor = true;\r
+            this.btn_viewLogs.Click += new System.EventHandler(this.btn_viewLogs_Click);\r
+            // \r
+            // btn_clearLogs\r
+            // \r
+            this.btn_clearLogs.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.btn_clearLogs.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.btn_clearLogs.ForeColor = System.Drawing.Color.DarkOrange;\r
+            this.btn_clearLogs.Location = new System.Drawing.Point(210, 201);\r
+            this.btn_clearLogs.Name = "btn_clearLogs";\r
+            this.btn_clearLogs.Size = new System.Drawing.Size(135, 23);\r
+            this.btn_clearLogs.TabIndex = 88;\r
+            this.btn_clearLogs.Text = "Clear Log History";\r
+            this.btn_clearLogs.UseVisualStyleBackColor = true;\r
+            this.btn_clearLogs.Click += new System.EventHandler(this.btn_clearLogs_Click);\r
             // \r
-            this.Label4.AutoSize = true;\r
-            this.Label4.BackColor = System.Drawing.Color.Transparent;\r
-            this.Label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.Label4.Location = new System.Drawing.Point(68, 75);\r
-            this.Label4.Name = "Label4";\r
-            this.Label4.Size = new System.Drawing.Size(84, 13);\r
-            this.Label4.TabIndex = 42;\r
-            this.Label4.Text = "Priority level:";\r
+            // label14\r
+            // \r
+            this.label14.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label14.AutoSize = true;\r
+            this.label14.Location = new System.Drawing.Point(65, 177);\r
+            this.label14.Name = "label14";\r
+            this.label14.Size = new System.Drawing.Size(53, 13);\r
+            this.label14.TabIndex = 81;\r
+            this.label14.Text = "Log Path:";\r
             // \r
             // tab_advanced\r
             // \r
-            this.tab_advanced.Controls.Add(this.lbl_appcastUnstable);\r
-            this.tab_advanced.Controls.Add(this.check_snapshot);\r
-            this.tab_advanced.Controls.Add(this.btn_drive_detect);\r
-            this.tab_advanced.Controls.Add(this.label6);\r
+            this.tab_advanced.Controls.Add(this.tableLayoutPanel4);\r
             this.tab_advanced.Location = new System.Drawing.Point(4, 22);\r
             this.tab_advanced.Name = "tab_advanced";\r
-            this.tab_advanced.Padding = new System.Windows.Forms.Padding(3);\r
-            this.tab_advanced.Size = new System.Drawing.Size(482, 259);\r
+            this.tab_advanced.Padding = new System.Windows.Forms.Padding(10);\r
+            this.tab_advanced.Size = new System.Drawing.Size(580, 334);\r
             this.tab_advanced.TabIndex = 4;\r
-            this.tab_advanced.Text = "Advanced";\r
+            this.tab_advanced.Text = "Advanced / Other";\r
             this.tab_advanced.UseVisualStyleBackColor = true;\r
             // \r
-            // lbl_appcastUnstable\r
-            // \r
-            this.lbl_appcastUnstable.AutoSize = true;\r
-            this.lbl_appcastUnstable.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_appcastUnstable.Location = new System.Drawing.Point(6, 42);\r
-            this.lbl_appcastUnstable.Name = "lbl_appcastUnstable";\r
-            this.lbl_appcastUnstable.Size = new System.Drawing.Size(64, 13);\r
-            this.lbl_appcastUnstable.TabIndex = 81;\r
-            this.lbl_appcastUnstable.Text = "Updates:";\r
-            // \r
-            // check_snapshot\r
-            // \r
-            this.check_snapshot.AutoSize = true;\r
-            this.check_snapshot.BackColor = System.Drawing.Color.Transparent;\r
-            this.check_snapshot.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.check_snapshot.Location = new System.Drawing.Point(76, 41);\r
-            this.check_snapshot.Name = "check_snapshot";\r
-            this.check_snapshot.Size = new System.Drawing.Size(273, 17);\r
-            this.check_snapshot.TabIndex = 80;\r
-            this.check_snapshot.Text = "Check for unstable development snapshots";\r
-            this.ToolTip.SetToolTip(this.check_snapshot, "Enables the built in update checker to check for the latest development snapshot " +\r
-                    "builds.\r\nWarning: These are considered unstable builds and are not supported!");\r
-            this.check_snapshot.UseVisualStyleBackColor = false;\r
-            this.check_snapshot.CheckedChanged += new System.EventHandler(this.check_snapshot_CheckedChanged);\r
-            // \r
-            // btn_drive_detect\r
-            // \r
-            this.btn_drive_detect.AutoSize = true;\r
-            this.btn_drive_detect.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.btn_drive_detect.Location = new System.Drawing.Point(76, 18);\r
-            this.btn_drive_detect.Name = "btn_drive_detect";\r
-            this.btn_drive_detect.Size = new System.Drawing.Size(383, 17);\r
-            this.btn_drive_detect.TabIndex = 72;\r
-            this.btn_drive_detect.Text = "Enable Drive Detection in the \"Source\" button dropdown menu";\r
-            this.ToolTip.SetToolTip(this.btn_drive_detect, "Enables the Source button\'s ability to detect DVD\'s.\r\nIf this option is enabled, " +\r
-                    "DVD\'s will be listed in the source menu.");\r
-            this.btn_drive_detect.UseVisualStyleBackColor = true;\r
-            this.btn_drive_detect.CheckedChanged += new System.EventHandler(this.btn_drive_detect_CheckedChanged);\r
+            // tableLayoutPanel4\r
+            // \r
+            this.tableLayoutPanel4.AutoSize = true;\r
+            this.tableLayoutPanel4.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel4.ColumnCount = 6;\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel4.Controls.Add(this.check_promptOnUnmatchingQueries, 3, 4);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_dvdnav, 2, 10);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_trayStatusAlerts, 3, 2);\r
+            this.tableLayoutPanel4.Controls.Add(this.label32, 0, 10);\r
+            this.tableLayoutPanel4.Controls.Add(this.label6, 0, 0);\r
+            this.tableLayoutPanel4.Controls.Add(this.drop_x264step, 4, 8);\r
+            this.tableLayoutPanel4.Controls.Add(this.label30, 2, 8);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_mainMinimize, 2, 1);\r
+            this.tableLayoutPanel4.Controls.Add(this.label28, 0, 8);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_queryEditorTab, 2, 3);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_disablePresetNotification, 2, 5);\r
+            this.tableLayoutPanel4.Controls.Add(this.check_inGuiStatus, 2, 6);\r
+            this.tableLayoutPanel4.Location = new System.Drawing.Point(10, 10);\r
+            this.tableLayoutPanel4.Name = "tableLayoutPanel4";\r
+            this.tableLayoutPanel4.RowCount = 12;\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel4.Size = new System.Drawing.Size(395, 228);\r
+            this.tableLayoutPanel4.TabIndex = 62;\r
+            // \r
+            // check_promptOnUnmatchingQueries\r
+            // \r
+            this.check_promptOnUnmatchingQueries.AutoSize = true;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_promptOnUnmatchingQueries, 3);\r
+            this.check_promptOnUnmatchingQueries.Location = new System.Drawing.Point(87, 72);\r
+            this.check_promptOnUnmatchingQueries.Name = "check_promptOnUnmatchingQueries";\r
+            this.check_promptOnUnmatchingQueries.Size = new System.Drawing.Size(305, 17);\r
+            this.check_promptOnUnmatchingQueries.TabIndex = 63;\r
+            this.check_promptOnUnmatchingQueries.Text = "Prompt when a manual query does not match GUI settings";\r
+            this.check_promptOnUnmatchingQueries.UseVisualStyleBackColor = true;\r
+            this.check_promptOnUnmatchingQueries.CheckedChanged += new System.EventHandler(this.check_promptOnUnmatchingQueries_CheckedChanged);\r
+            // \r
+            // check_dvdnav\r
+            // \r
+            this.check_dvdnav.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_dvdnav.AutoSize = true;\r
+            this.check_dvdnav.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_dvdnav, 4);\r
+            this.check_dvdnav.Location = new System.Drawing.Point(67, 208);\r
+            this.check_dvdnav.Name = "check_dvdnav";\r
+            this.check_dvdnav.Size = new System.Drawing.Size(276, 17);\r
+            this.check_dvdnav.TabIndex = 90;\r
+            this.check_dvdnav.Text = "Disable LibDVDNav. (libdvdread will be used instead)";\r
+            this.check_dvdnav.UseVisualStyleBackColor = false;\r
+            this.check_dvdnav.CheckedChanged += new System.EventHandler(this.check_dvdnav_CheckedChanged);\r
+            // \r
+            // check_trayStatusAlerts\r
+            // \r
+            this.check_trayStatusAlerts.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_trayStatusAlerts.AutoSize = true;\r
+            this.check_trayStatusAlerts.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_trayStatusAlerts, 3);\r
+            this.check_trayStatusAlerts.Location = new System.Drawing.Point(87, 26);\r
+            this.check_trayStatusAlerts.Name = "check_trayStatusAlerts";\r
+            this.check_trayStatusAlerts.Size = new System.Drawing.Size(296, 17);\r
+            this.check_trayStatusAlerts.TabIndex = 93;\r
+            this.check_trayStatusAlerts.Text = "Display status messages from tray icon (balloon popups)";\r
+            this.ToolTip.SetToolTip(this.check_trayStatusAlerts, "Minimize the window to the system tray rather than the task bar.\r\nThe system tray" +\r
+                    " icon has encode status notifications.\r\nNote: requires restart to take effect!\r\n" +\r
+                    "");\r
+            this.check_trayStatusAlerts.UseVisualStyleBackColor = false;\r
+            this.check_trayStatusAlerts.CheckedChanged += new System.EventHandler(this.check_trayStatusAlerts_CheckedChanged);\r
+            // \r
+            // label32\r
+            // \r
+            this.label32.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
+            this.label32.AutoSize = true;\r
+            this.label32.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label32.Location = new System.Drawing.Point(8, 210);\r
+            this.label32.Name = "label32";\r
+            this.label32.Size = new System.Drawing.Size(33, 13);\r
+            this.label32.TabIndex = 89;\r
+            this.label32.Text = "DVD:";\r
             // \r
             // label6\r
             // \r
+            this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
             this.label6.AutoSize = true;\r
-            this.label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label6.Location = new System.Drawing.Point(35, 19);\r
+            this.label6.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label6.Location = new System.Drawing.Point(10, 5);\r
+            this.label6.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);\r
             this.label6.Name = "label6";\r
-            this.label6.Size = new System.Drawing.Size(35, 13);\r
+            this.tableLayoutPanel4.SetRowSpan(this.label6, 2);\r
+            this.label6.Size = new System.Drawing.Size(31, 13);\r
             this.label6.TabIndex = 71;\r
             this.label6.Text = "GUI:";\r
             // \r
+            // drop_x264step\r
+            // \r
+            this.tableLayoutPanel4.SetColumnSpan(this.drop_x264step, 2);\r
+            this.drop_x264step.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.drop_x264step.FormattingEnabled = true;\r
+            this.drop_x264step.Items.AddRange(new object[] {\r
+            "1.0",\r
+            "0.50",\r
+            "0.25",\r
+            "0.20"});\r
+            this.drop_x264step.Location = new System.Drawing.Point(262, 161);\r
+            this.drop_x264step.Name = "drop_x264step";\r
+            this.drop_x264step.Size = new System.Drawing.Size(85, 21);\r
+            this.drop_x264step.TabIndex = 86;\r
+            this.ToolTip.SetToolTip(this.drop_x264step, "The number of processor\'s / processor cores. Unless your having problems, leave o" +\r
+                    "n Automatic.");\r
+            this.drop_x264step.SelectedIndexChanged += new System.EventHandler(this.x264step_SelectedIndexChanged);\r
+            // \r
+            // label30\r
+            // \r
+            this.label30.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.label30.AutoSize = true;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.label30, 2);\r
+            this.label30.Location = new System.Drawing.Point(67, 165);\r
+            this.label30.Name = "label30";\r
+            this.label30.Size = new System.Drawing.Size(189, 13);\r
+            this.label30.TabIndex = 87;\r
+            this.label30.Text = "Constant quality fractional granularity";\r
+            // \r
+            // check_mainMinimize\r
+            // \r
+            this.check_mainMinimize.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_mainMinimize.AutoSize = true;\r
+            this.check_mainMinimize.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_mainMinimize, 4);\r
+            this.check_mainMinimize.Location = new System.Drawing.Point(67, 3);\r
+            this.check_mainMinimize.Name = "check_mainMinimize";\r
+            this.check_mainMinimize.Size = new System.Drawing.Size(138, 17);\r
+            this.check_mainMinimize.TabIndex = 82;\r
+            this.check_mainMinimize.Text = "Minimize to system tray";\r
+            this.ToolTip.SetToolTip(this.check_mainMinimize, "Minimize the window to the system tray rather than the task bar.\r\nThe system tray" +\r
+                    " icon has encode status notifications.\r\nNote: requires restart to take effect!\r\n" +\r
+                    "");\r
+            this.check_mainMinimize.UseVisualStyleBackColor = false;\r
+            this.check_mainMinimize.CheckedChanged += new System.EventHandler(this.check_mainMinimize_CheckedChanged);\r
+            // \r
+            // label28\r
+            // \r
+            this.label28.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
+            this.label28.AutoSize = true;\r
+            this.label28.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label28.Location = new System.Drawing.Point(3, 165);\r
+            this.label28.Name = "label28";\r
+            this.label28.Size = new System.Drawing.Size(38, 13);\r
+            this.label28.TabIndex = 85;\r
+            this.label28.Text = "x264:";\r
+            // \r
+            // check_queryEditorTab\r
+            // \r
+            this.check_queryEditorTab.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_queryEditorTab.AutoSize = true;\r
+            this.check_queryEditorTab.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_queryEditorTab, 4);\r
+            this.check_queryEditorTab.Location = new System.Drawing.Point(67, 49);\r
+            this.check_queryEditorTab.Name = "check_queryEditorTab";\r
+            this.check_queryEditorTab.Size = new System.Drawing.Size(241, 17);\r
+            this.check_queryEditorTab.TabIndex = 84;\r
+            this.check_queryEditorTab.Text = "Enable \"Query Editor\" tab (Requires Restart)";\r
+            this.ToolTip.SetToolTip(this.check_queryEditorTab, "Enables the Query Editor tab on the main window. Requires program restart to take" +\r
+                    " effect.");\r
+            this.check_queryEditorTab.UseVisualStyleBackColor = false;\r
+            this.check_queryEditorTab.CheckedChanged += new System.EventHandler(this.check_queryEditorTab_CheckedChanged);\r
+            // \r
+            // check_disablePresetNotification\r
+            // \r
+            this.check_disablePresetNotification.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_disablePresetNotification.AutoSize = true;\r
+            this.check_disablePresetNotification.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_disablePresetNotification, 4);\r
+            this.check_disablePresetNotification.Location = new System.Drawing.Point(67, 95);\r
+            this.check_disablePresetNotification.Name = "check_disablePresetNotification";\r
+            this.check_disablePresetNotification.Size = new System.Drawing.Size(222, 17);\r
+            this.check_disablePresetNotification.TabIndex = 91;\r
+            this.check_disablePresetNotification.Text = "Disable built-in preset update notification";\r
+            this.ToolTip.SetToolTip(this.check_disablePresetNotification, "Disables the notification you recieve when presets are updated when a new version" +\r
+                    " of HandBrake is installed.");\r
+            this.check_disablePresetNotification.UseVisualStyleBackColor = false;\r
+            this.check_disablePresetNotification.CheckedChanged += new System.EventHandler(this.check_disablePresetNotification_CheckedChanged);\r
+            // \r
+            // check_inGuiStatus\r
+            // \r
+            this.check_inGuiStatus.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
+            this.check_inGuiStatus.AutoSize = true;\r
+            this.check_inGuiStatus.BackColor = System.Drawing.Color.Transparent;\r
+            this.tableLayoutPanel4.SetColumnSpan(this.check_inGuiStatus, 4);\r
+            this.check_inGuiStatus.Location = new System.Drawing.Point(67, 118);\r
+            this.check_inGuiStatus.Name = "check_inGuiStatus";\r
+            this.check_inGuiStatus.Size = new System.Drawing.Size(235, 17);\r
+            this.check_inGuiStatus.TabIndex = 92;\r
+            this.check_inGuiStatus.Text = "Enable in-GUI encode status (experimental)";\r
+            this.ToolTip.SetToolTip(this.check_inGuiStatus, "Displays the CLI status in the GUI windows instead of the CLI window.");\r
+            this.check_inGuiStatus.UseVisualStyleBackColor = false;\r
+            this.check_inGuiStatus.CheckedChanged += new System.EventHandler(this.check_inGuiStatus_CheckedChanged);\r
+            // \r
+            // tab_debug\r
+            // \r
+            this.tab_debug.Controls.Add(this.check_disableResCalc);\r
+            this.tab_debug.Location = new System.Drawing.Point(4, 22);\r
+            this.tab_debug.Name = "tab_debug";\r
+            this.tab_debug.Padding = new System.Windows.Forms.Padding(3);\r
+            this.tab_debug.Size = new System.Drawing.Size(580, 334);\r
+            this.tab_debug.TabIndex = 7;\r
+            this.tab_debug.Text = "Debug";\r
+            this.tab_debug.UseVisualStyleBackColor = true;\r
+            // \r
+            // check_disableResCalc\r
+            // \r
+            this.check_disableResCalc.AutoSize = true;\r
+            this.check_disableResCalc.Location = new System.Drawing.Point(13, 15);\r
+            this.check_disableResCalc.Name = "check_disableResCalc";\r
+            this.check_disableResCalc.Size = new System.Drawing.Size(327, 17);\r
+            this.check_disableResCalc.TabIndex = 0;\r
+            this.check_disableResCalc.Text = "Disable Resolution Calculation for \"None\" and \"Custom\" modes.";\r
+            this.ToolTip.SetToolTip(this.check_disableResCalc, resources.GetString("check_disableResCalc.ToolTip"));\r
+            this.check_disableResCalc.UseVisualStyleBackColor = true;\r
+            this.check_disableResCalc.CheckedChanged += new System.EventHandler(this.check_disableResCalc_CheckedChanged);\r
+            // \r
             // label8\r
             // \r
+            this.label8.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.label8.AutoSize = true;\r
-            this.label8.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label8.Location = new System.Drawing.Point(50, 24);\r
+            this.label8.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label8.Location = new System.Drawing.Point(41, 11);\r
             this.label8.Name = "label8";\r
-            this.label8.Size = new System.Drawing.Size(131, 13);\r
+            this.label8.Size = new System.Drawing.Size(115, 13);\r
             this.label8.TabIndex = 61;\r
             this.label8.Text = "HandBrake Options";\r
             // \r
             // pictureBox2\r
             // \r
             this.pictureBox2.Image = global::Handbrake.Properties.Resources.General_Preferences;\r
-            this.pictureBox2.Location = new System.Drawing.Point(12, 12);\r
+            this.pictureBox2.Location = new System.Drawing.Point(3, 0);\r
+            this.pictureBox2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);\r
             this.pictureBox2.Name = "pictureBox2";\r
             this.pictureBox2.Size = new System.Drawing.Size(32, 32);\r
             this.pictureBox2.TabIndex = 60;\r
@@ -610,34 +1127,402 @@ namespace Handbrake
             // \r
             this.ToolTip.Active = false;\r
             this.ToolTip.AutomaticDelay = 1000;\r
+            this.ToolTip.AutoPopDelay = 15000;\r
+            this.ToolTip.InitialDelay = 1000;\r
+            this.ToolTip.ReshowDelay = 200;\r
             this.ToolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;\r
             this.ToolTip.ToolTipTitle = "Tooltip";\r
             // \r
+            // textBox1\r
+            // \r
+            this.textBox1.Location = new System.Drawing.Point(199, 198);\r
+            this.textBox1.Name = "textBox1";\r
+            this.textBox1.Size = new System.Drawing.Size(255, 20);\r
+            this.textBox1.TabIndex = 79;\r
+            this.ToolTip.SetToolTip(this.textBox1, "Define the format of the automatically named file.\r\ne.g  {source}_{title}_some-te" +\r
+                    "xt\r\n{source} {title} {chapters} will be automatically substituted for the input " +\r
+                    "sources values.");\r
+            // \r
+            // textBox2\r
+            // \r
+            this.textBox2.Location = new System.Drawing.Point(199, 171);\r
+            this.textBox2.Name = "textBox2";\r
+            this.textBox2.Size = new System.Drawing.Size(181, 20);\r
+            this.textBox2.TabIndex = 76;\r
+            this.ToolTip.SetToolTip(this.textBox2, "The default location where auto named files are stored.");\r
+            // \r
+            // checkBox1\r
+            // \r
+            this.checkBox1.AutoSize = true;\r
+            this.checkBox1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox1.Location = new System.Drawing.Point(114, 148);\r
+            this.checkBox1.Name = "checkBox1";\r
+            this.checkBox1.Size = new System.Drawing.Size(206, 17);\r
+            this.checkBox1.TabIndex = 72;\r
+            this.checkBox1.Text = "Automatically name output files";\r
+            this.ToolTip.SetToolTip(this.checkBox1, "Automatically name output files");\r
+            this.checkBox1.UseVisualStyleBackColor = true;\r
+            // \r
+            // checkBox2\r
+            // \r
+            this.checkBox2.AutoSize = true;\r
+            this.checkBox2.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox2.Location = new System.Drawing.Point(114, 41);\r
+            this.checkBox2.Name = "checkBox2";\r
+            this.checkBox2.Size = new System.Drawing.Size(135, 17);\r
+            this.checkBox2.TabIndex = 70;\r
+            this.checkBox2.Text = "Enable GUI tooltips";\r
+            this.ToolTip.SetToolTip(this.checkBox2, "Enable the built in tooltips for gui controls.");\r
+            this.checkBox2.UseVisualStyleBackColor = false;\r
+            // \r
+            // checkBox3\r
+            // \r
+            this.checkBox3.AutoSize = true;\r
+            this.checkBox3.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox3.Location = new System.Drawing.Point(114, 18);\r
+            this.checkBox3.Name = "checkBox3";\r
+            this.checkBox3.Size = new System.Drawing.Size(131, 17);\r
+            this.checkBox3.TabIndex = 68;\r
+            this.checkBox3.Text = "Check for updates";\r
+            this.ToolTip.SetToolTip(this.checkBox3, "Enables the built in update checker. This check is performed when the application" +\r
+                    " starts.");\r
+            this.checkBox3.UseVisualStyleBackColor = false;\r
+            // \r
+            // checkBox4\r
+            // \r
+            this.checkBox4.AutoSize = true;\r
+            this.checkBox4.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox4.Location = new System.Drawing.Point(114, 64);\r
+            this.checkBox4.Name = "checkBox4";\r
+            this.checkBox4.Size = new System.Drawing.Size(166, 17);\r
+            this.checkBox4.TabIndex = 69;\r
+            this.checkBox4.Text = "Load my default settings";\r
+            this.ToolTip.SetToolTip(this.checkBox4, "Loads the users default settings rather than the Normal preset.");\r
+            this.checkBox4.UseVisualStyleBackColor = false;\r
+            // \r
+            // comboBox1\r
+            // \r
+            this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.comboBox1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.comboBox1.FormattingEnabled = true;\r
+            this.comboBox1.Items.AddRange(new object[] {\r
+            "Do Nothing",\r
+            "Shutdown",\r
+            "Suspend",\r
+            "Hibernate",\r
+            "Lock System",\r
+            "Log Off",\r
+            "Quit HandBrake"});\r
+            this.comboBox1.Location = new System.Drawing.Point(114, 100);\r
+            this.comboBox1.Name = "comboBox1";\r
+            this.comboBox1.Size = new System.Drawing.Size(166, 21);\r
+            this.comboBox1.TabIndex = 43;\r
+            this.ToolTip.SetToolTip(this.comboBox1, "Performs an action when an encode or queue has completed.");\r
+            // \r
+            // textBox3\r
+            // \r
+            this.textBox3.Location = new System.Drawing.Point(199, 198);\r
+            this.textBox3.Name = "textBox3";\r
+            this.textBox3.Size = new System.Drawing.Size(255, 20);\r
+            this.textBox3.TabIndex = 79;\r
+            this.ToolTip.SetToolTip(this.textBox3, "Define the format of the automatically named file.\r\ne.g  {source}_{title}_some-te" +\r
+                    "xt\r\n{source} {title} {chapters} will be automatically substituted for the input " +\r
+                    "sources values.");\r
+            // \r
+            // textBox4\r
+            // \r
+            this.textBox4.Location = new System.Drawing.Point(199, 171);\r
+            this.textBox4.Name = "textBox4";\r
+            this.textBox4.Size = new System.Drawing.Size(181, 20);\r
+            this.textBox4.TabIndex = 76;\r
+            this.ToolTip.SetToolTip(this.textBox4, "The default location where auto named files are stored.");\r
+            // \r
+            // checkBox5\r
+            // \r
+            this.checkBox5.AutoSize = true;\r
+            this.checkBox5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox5.Location = new System.Drawing.Point(114, 148);\r
+            this.checkBox5.Name = "checkBox5";\r
+            this.checkBox5.Size = new System.Drawing.Size(206, 17);\r
+            this.checkBox5.TabIndex = 72;\r
+            this.checkBox5.Text = "Automatically name output files";\r
+            this.ToolTip.SetToolTip(this.checkBox5, "Automatically name output files");\r
+            this.checkBox5.UseVisualStyleBackColor = true;\r
+            // \r
+            // checkBox6\r
+            // \r
+            this.checkBox6.AutoSize = true;\r
+            this.checkBox6.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox6.Location = new System.Drawing.Point(114, 41);\r
+            this.checkBox6.Name = "checkBox6";\r
+            this.checkBox6.Size = new System.Drawing.Size(135, 17);\r
+            this.checkBox6.TabIndex = 70;\r
+            this.checkBox6.Text = "Enable GUI tooltips";\r
+            this.ToolTip.SetToolTip(this.checkBox6, "Enable the built in tooltips for gui controls.");\r
+            this.checkBox6.UseVisualStyleBackColor = false;\r
+            // \r
+            // checkBox7\r
+            // \r
+            this.checkBox7.AutoSize = true;\r
+            this.checkBox7.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox7.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox7.Location = new System.Drawing.Point(114, 18);\r
+            this.checkBox7.Name = "checkBox7";\r
+            this.checkBox7.Size = new System.Drawing.Size(131, 17);\r
+            this.checkBox7.TabIndex = 68;\r
+            this.checkBox7.Text = "Check for updates";\r
+            this.ToolTip.SetToolTip(this.checkBox7, "Enables the built in update checker. This check is performed when the application" +\r
+                    " starts.");\r
+            this.checkBox7.UseVisualStyleBackColor = false;\r
+            // \r
+            // checkBox8\r
+            // \r
+            this.checkBox8.AutoSize = true;\r
+            this.checkBox8.BackColor = System.Drawing.Color.Transparent;\r
+            this.checkBox8.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.checkBox8.Location = new System.Drawing.Point(114, 64);\r
+            this.checkBox8.Name = "checkBox8";\r
+            this.checkBox8.Size = new System.Drawing.Size(166, 17);\r
+            this.checkBox8.TabIndex = 69;\r
+            this.checkBox8.Text = "Load my default settings";\r
+            this.ToolTip.SetToolTip(this.checkBox8, "Loads the users default settings rather than the Normal preset.");\r
+            this.checkBox8.UseVisualStyleBackColor = false;\r
+            // \r
+            // comboBox2\r
+            // \r
+            this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.comboBox2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.comboBox2.FormattingEnabled = true;\r
+            this.comboBox2.Items.AddRange(new object[] {\r
+            "Do Nothing",\r
+            "Shutdown",\r
+            "Suspend",\r
+            "Hibernate",\r
+            "Lock System",\r
+            "Log Off",\r
+            "Quit HandBrake"});\r
+            this.comboBox2.Location = new System.Drawing.Point(114, 100);\r
+            this.comboBox2.Name = "comboBox2";\r
+            this.comboBox2.Size = new System.Drawing.Size(166, 21);\r
+            this.comboBox2.TabIndex = 43;\r
+            this.ToolTip.SetToolTip(this.comboBox2, "Performs an action when an encode or queue has completed.");\r
+            // \r
+            // label16\r
+            // \r
+            this.label16.AutoSize = true;\r
+            this.label16.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label16.Location = new System.Drawing.Point(197, 222);\r
+            this.label16.Name = "label16";\r
+            this.label16.Size = new System.Drawing.Size(242, 12);\r
+            this.label16.TabIndex = 81;\r
+            this.label16.Text = "Available Options: {source} {title} {chapters}";\r
+            // \r
+            // label17\r
+            // \r
+            this.label17.AutoSize = true;\r
+            this.label17.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label17.Location = new System.Drawing.Point(111, 201);\r
+            this.label17.Name = "label17";\r
+            this.label17.Size = new System.Drawing.Size(52, 13);\r
+            this.label17.TabIndex = 80;\r
+            this.label17.Text = "Format:";\r
+            // \r
+            // button1\r
+            // \r
+            this.button1.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
+            this.button1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.button1.Location = new System.Drawing.Point(386, 171);\r
+            this.button1.Name = "button1";\r
+            this.button1.Size = new System.Drawing.Size(68, 22);\r
+            this.button1.TabIndex = 78;\r
+            this.button1.Text = "Browse";\r
+            this.button1.UseVisualStyleBackColor = true;\r
+            // \r
+            // label18\r
+            // \r
+            this.label18.AutoSize = true;\r
+            this.label18.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label18.Location = new System.Drawing.Point(111, 174);\r
+            this.label18.Name = "label18";\r
+            this.label18.Size = new System.Drawing.Size(82, 13);\r
+            this.label18.TabIndex = 77;\r
+            this.label18.Text = "Default Path:";\r
+            // \r
+            // label19\r
+            // \r
+            this.label19.AutoSize = true;\r
+            this.label19.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label19.Location = new System.Drawing.Point(10, 149);\r
+            this.label19.Name = "label19";\r
+            this.label19.Size = new System.Drawing.Size(86, 13);\r
+            this.label19.TabIndex = 71;\r
+            this.label19.Text = "Output files:";\r
+            // \r
+            // label20\r
+            // \r
+            this.label20.AutoSize = true;\r
+            this.label20.BackColor = System.Drawing.Color.Transparent;\r
+            this.label20.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label20.Location = new System.Drawing.Point(21, 19);\r
+            this.label20.Name = "label20";\r
+            this.label20.Size = new System.Drawing.Size(75, 13);\r
+            this.label20.TabIndex = 67;\r
+            this.label20.Text = "At Launch:";\r
+            // \r
+            // label21\r
+            // \r
+            this.label21.AutoSize = true;\r
+            this.label21.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label21.Location = new System.Drawing.Point(12, 103);\r
+            this.label21.Name = "label21";\r
+            this.label21.Size = new System.Drawing.Size(84, 13);\r
+            this.label21.TabIndex = 54;\r
+            this.label21.Text = "When Done:";\r
+            // \r
+            // label22\r
+            // \r
+            this.label22.AutoSize = true;\r
+            this.label22.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label22.Location = new System.Drawing.Point(197, 222);\r
+            this.label22.Name = "label22";\r
+            this.label22.Size = new System.Drawing.Size(242, 12);\r
+            this.label22.TabIndex = 81;\r
+            this.label22.Text = "Available Options: {source} {title} {chapters}";\r
+            // \r
+            // label23\r
+            // \r
+            this.label23.AutoSize = true;\r
+            this.label23.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label23.Location = new System.Drawing.Point(111, 201);\r
+            this.label23.Name = "label23";\r
+            this.label23.Size = new System.Drawing.Size(52, 13);\r
+            this.label23.TabIndex = 80;\r
+            this.label23.Text = "Format:";\r
+            // \r
+            // button2\r
+            // \r
+            this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
+            this.button2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.button2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
+            this.button2.Location = new System.Drawing.Point(386, 171);\r
+            this.button2.Name = "button2";\r
+            this.button2.Size = new System.Drawing.Size(68, 22);\r
+            this.button2.TabIndex = 78;\r
+            this.button2.Text = "Browse";\r
+            this.button2.UseVisualStyleBackColor = true;\r
+            // \r
+            // label24\r
+            // \r
+            this.label24.AutoSize = true;\r
+            this.label24.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label24.Location = new System.Drawing.Point(111, 174);\r
+            this.label24.Name = "label24";\r
+            this.label24.Size = new System.Drawing.Size(82, 13);\r
+            this.label24.TabIndex = 77;\r
+            this.label24.Text = "Default Path:";\r
+            // \r
+            // label25\r
+            // \r
+            this.label25.AutoSize = true;\r
+            this.label25.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label25.Location = new System.Drawing.Point(10, 149);\r
+            this.label25.Name = "label25";\r
+            this.label25.Size = new System.Drawing.Size(86, 13);\r
+            this.label25.TabIndex = 71;\r
+            this.label25.Text = "Output files:";\r
+            // \r
+            // label26\r
+            // \r
+            this.label26.AutoSize = true;\r
+            this.label26.BackColor = System.Drawing.Color.Transparent;\r
+            this.label26.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label26.Location = new System.Drawing.Point(21, 19);\r
+            this.label26.Name = "label26";\r
+            this.label26.Size = new System.Drawing.Size(75, 13);\r
+            this.label26.TabIndex = 67;\r
+            this.label26.Text = "At Launch:";\r
+            // \r
+            // label27\r
+            // \r
+            this.label27.AutoSize = true;\r
+            this.label27.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label27.Location = new System.Drawing.Point(12, 103);\r
+            this.label27.Name = "label27";\r
+            this.label27.Size = new System.Drawing.Size(84, 13);\r
+            this.label27.TabIndex = 54;\r
+            this.label27.Text = "When Done:";\r
+            // \r
+            // openFile_vlc\r
+            // \r
+            this.openFile_vlc.DefaultExt = "exe";\r
+            this.openFile_vlc.Filter = "exe|*.exe";\r
+            // \r
+            // tableLayoutPanel5\r
+            // \r
+            this.tableLayoutPanel5.AutoSize = true;\r
+            this.tableLayoutPanel5.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.tableLayoutPanel5.ColumnCount = 2;\r
+            this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel5.Controls.Add(this.pictureBox2, 0, 0);\r
+            this.tableLayoutPanel5.Controls.Add(this.btn_close, 1, 2);\r
+            this.tableLayoutPanel5.Controls.Add(this.label8, 1, 0);\r
+            this.tableLayoutPanel5.Controls.Add(this.tab_options, 0, 1);\r
+            this.tableLayoutPanel5.Location = new System.Drawing.Point(12, 12);\r
+            this.tableLayoutPanel5.Name = "tableLayoutPanel5";\r
+            this.tableLayoutPanel5.RowCount = 3;\r
+            this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel5.Size = new System.Drawing.Size(594, 429);\r
+            this.tableLayoutPanel5.TabIndex = 62;\r
+            // \r
             // frmOptions\r
             // \r
-            this.ClientSize = new System.Drawing.Size(514, 375);\r
-            this.Controls.Add(this.label8);\r
-            this.Controls.Add(this.pictureBox2);\r
-            this.Controls.Add(this.tab_options);\r
-            this.Controls.Add(this.btn_close);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;\r
+            this.AutoSize = true;\r
+            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.ClientSize = new System.Drawing.Size(627, 456);\r
+            this.Controls.Add(this.tableLayoutPanel5);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
             this.MaximizeBox = false;\r
             this.MinimizeBox = false;\r
             this.Name = "frmOptions";\r
+            this.Padding = new System.Windows.Forms.Padding(12);\r
+            this.ShowIcon = false;\r
+            this.ShowInTaskbar = false;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
-            this.Text = "Options";\r
+            this.Text = "HandBrake Options";\r
             this.tab_options.ResumeLayout(false);\r
             this.tab_general.ResumeLayout(false);\r
             this.tab_general.PerformLayout();\r
             this.tab_picture.ResumeLayout(false);\r
             this.tab_picture.PerformLayout();\r
+            this.tableLayoutPanel2.ResumeLayout(false);\r
+            this.tableLayoutPanel2.PerformLayout();\r
+            this.tab_audio_sub.ResumeLayout(false);\r
+            this.tab_audio_sub.PerformLayout();\r
             this.tab_cli.ResumeLayout(false);\r
             this.tab_cli.PerformLayout();\r
+            this.tableLayoutPanel3.ResumeLayout(false);\r
+            this.tableLayoutPanel3.PerformLayout();\r
             this.tab_advanced.ResumeLayout(false);\r
             this.tab_advanced.PerformLayout();\r
+            this.tableLayoutPanel4.ResumeLayout(false);\r
+            this.tableLayoutPanel4.PerformLayout();\r
+            this.tab_debug.ResumeLayout(false);\r
+            this.tab_debug.PerformLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();\r
+            this.tableLayoutPanel5.ResumeLayout(false);\r
+            this.tableLayoutPanel5.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -654,39 +1539,95 @@ namespace Handbrake
         private System.Windows.Forms.PictureBox pictureBox2;\r
         private System.Windows.Forms.TabPage tab_general;\r
         private System.Windows.Forms.FolderBrowserDialog pathFinder;\r
-        internal System.Windows.Forms.ComboBox drp_Priority;\r
         internal System.Windows.Forms.Label Label11;\r
         internal System.Windows.Forms.Label Label4;\r
-        internal System.Windows.Forms.ComboBox drp_processors;\r
         internal System.Windows.Forms.CheckBox check_tooltip;\r
         internal System.Windows.Forms.CheckBox check_updateCheck;\r
-        internal System.Windows.Forms.CheckBox check_userDefaultSettings;\r
         private System.Windows.Forms.Label label1;\r
         private System.Windows.Forms.TabPage tab_advanced;\r
-        internal System.Windows.Forms.CheckBox btn_drive_detect;\r
         private System.Windows.Forms.Label label6;\r
         private System.Windows.Forms.Label label13;\r
-        internal System.Windows.Forms.Button btn_browse;\r
         internal System.Windows.Forms.Label label10;\r
         private System.Windows.Forms.TextBox text_an_path;\r
         internal System.Windows.Forms.CheckBox check_autoNaming;\r
         internal System.Windows.Forms.CheckBox check_cli_minimized;\r
         private System.Windows.Forms.Label label12;\r
         internal System.Windows.Forms.ToolTip ToolTip;\r
-        private System.Windows.Forms.Label lbl_appcastUnstable;\r
-        internal System.Windows.Forms.CheckBox check_snapshot;\r
         private System.Windows.Forms.TabPage tab_picture;\r
-        private System.Windows.Forms.TextBox txt_decomb;\r
-        private System.Windows.Forms.Label label3;\r
         internal System.Windows.Forms.Label label5;\r
         private System.Windows.Forms.TextBox txt_autoNameFormat;\r
         private System.Windows.Forms.Label label7;\r
         private System.Windows.Forms.Label label9;\r
-        internal System.Windows.Forms.Label label15;\r
         internal System.Windows.Forms.Button btn_saveLog;\r
         internal System.Windows.Forms.Label label14;\r
         private System.Windows.Forms.TextBox text_logPath;\r
-        internal System.Windows.Forms.CheckBox check_keepLogs;\r
         internal System.Windows.Forms.CheckBox check_saveLogWithVideo;\r
+        internal System.Windows.Forms.Button btn_vlcPath;\r
+        private System.Windows.Forms.TextBox txt_vlcPath;\r
+        private System.Windows.Forms.Label label29;\r
+        private System.Windows.Forms.Label label16;\r
+        internal System.Windows.Forms.Label label17;\r
+        private System.Windows.Forms.TextBox textBox1;\r
+        internal System.Windows.Forms.Button button1;\r
+        internal System.Windows.Forms.Label label18;\r
+        private System.Windows.Forms.TextBox textBox2;\r
+        internal System.Windows.Forms.CheckBox checkBox1;\r
+        private System.Windows.Forms.Label label19;\r
+        internal System.Windows.Forms.CheckBox checkBox2;\r
+        internal System.Windows.Forms.CheckBox checkBox3;\r
+        internal System.Windows.Forms.CheckBox checkBox4;\r
+        private System.Windows.Forms.Label label20;\r
+        private System.Windows.Forms.Label label21;\r
+        internal System.Windows.Forms.ComboBox comboBox1;\r
+        private System.Windows.Forms.Label label22;\r
+        internal System.Windows.Forms.Label label23;\r
+        private System.Windows.Forms.TextBox textBox3;\r
+        internal System.Windows.Forms.Button button2;\r
+        internal System.Windows.Forms.Label label24;\r
+        private System.Windows.Forms.TextBox textBox4;\r
+        internal System.Windows.Forms.CheckBox checkBox5;\r
+        private System.Windows.Forms.Label label25;\r
+        internal System.Windows.Forms.CheckBox checkBox6;\r
+        internal System.Windows.Forms.CheckBox checkBox7;\r
+        internal System.Windows.Forms.CheckBox checkBox8;\r
+        private System.Windows.Forms.Label label26;\r
+        private System.Windows.Forms.Label label27;\r
+        internal System.Windows.Forms.ComboBox comboBox2;\r
+        private System.Windows.Forms.OpenFileDialog openFile_vlc;\r
+        internal System.Windows.Forms.CheckBox check_mainMinimize;\r
+        internal System.Windows.Forms.CheckBox check_queryEditorTab;\r
+        private System.Windows.Forms.Label label30;\r
+        internal System.Windows.Forms.ComboBox drop_x264step;\r
+        private System.Windows.Forms.Label label28;\r
+        internal System.Windows.Forms.ComboBox cb_logVerboseLvl;\r
+        internal System.Windows.Forms.Label label3;\r
+        internal System.Windows.Forms.CheckBox check_dvdnav;\r
+        private System.Windows.Forms.Label label32;\r
+        internal System.Windows.Forms.CheckBox check_logsInSpecifiedLocation;\r
+        internal System.Windows.Forms.CheckBox check_disablePresetNotification;\r
+        internal System.Windows.Forms.CheckBox check_inGuiStatus;\r
+        internal System.Windows.Forms.CheckBox check_trayStatusAlerts;\r
+        private System.Windows.Forms.Button btn_viewLogs;\r
+        private System.Windows.Forms.Button btn_clearLogs;\r
+        internal System.Windows.Forms.CheckBox check_m4v;\r
+        internal System.Windows.Forms.ComboBox drop_updateCheckDays;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;\r
+        internal System.Windows.Forms.ComboBox drp_processors;\r
+        internal System.Windows.Forms.ComboBox drp_Priority;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5;\r
+        private System.Windows.Forms.CheckBox check_promptOnUnmatchingQueries;\r
+        private System.Windows.Forms.TabPage tab_audio_sub;\r
+        internal System.Windows.Forms.ComboBox drop_preferredLang;\r
+        private System.Windows.Forms.Label label31;\r
+        private System.Windows.Forms.RadioButton radio_foreignAndSubs;\r
+        private System.Windows.Forms.RadioButton radio_dub;\r
+        private System.Windows.Forms.Label label15;\r
+        internal System.Windows.Forms.Button btn_browse;\r
+        private System.Windows.Forms.TabPage tab_debug;\r
+        private System.Windows.Forms.CheckBox check_disableResCalc;\r
+        internal System.Windows.Forms.CheckBox check_growlEncode;\r
+        internal System.Windows.Forms.CheckBox check_GrowlQueue;\r
     }\r
 }
\ No newline at end of file
index 4e6d698..77a7a58 100644 (file)
@@ -6,49 +6,52 @@
 \r
 using System;\r
 using System.Collections.Generic;\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
+using System.Globalization;\r
 using System.Windows.Forms;\r
+using Handbrake.Functions;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmOptions : Form\r
     {\r
         private frmMain mainWindow;\r
-        /// <summary>\r
-        /// When the form loads, Initialise all the setting components with their correct values\r
-        /// </summary>\r
-        public frmOptions(frmMain window)\r
+\r
+        public frmOptions(frmMain mw)\r
         {\r
             InitializeComponent();\r
-            mainWindow = window;\r
+            mainWindow = mw;\r
+\r
+            IDictionary<string, string> langList = Main.mapLanguages();\r
+            foreach (string item in langList.Keys)\r
+                drop_preferredLang.Items.Add(item);\r
 \r
             // #############################\r
             // General\r
             // #############################\r
 \r
             // Enable Tooltips.\r
-            if (Properties.Settings.Default.tooltipEnable == "Checked")\r
+            if (Properties.Settings.Default.tooltipEnable)\r
             {\r
                 check_tooltip.CheckState = CheckState.Checked;\r
                 ToolTip.Active = true;\r
             }\r
 \r
             // Setup Widgets to match settings.\r
-            if (Properties.Settings.Default.updateStatus == "Checked")\r
+            if (Properties.Settings.Default.updateStatus)\r
                 check_updateCheck.CheckState = CheckState.Checked;\r
 \r
-            // enable loading of default user settings.\r
-            if (Properties.Settings.Default.defaultSettings == "Checked")\r
-                check_userDefaultSettings.CheckState = CheckState.Checked;\r
-\r
             // On Encode Completeion Action\r
             drp_completeOption.Text = Properties.Settings.Default.CompletionOption;\r
-            \r
+\r
+            // Growl.\r
+            if (Properties.Settings.Default.growlEncode)\r
+                check_growlEncode.CheckState = CheckState.Checked;\r
+\r
+            if (Properties.Settings.Default.growlQueue)\r
+                check_GrowlQueue.CheckState = CheckState.Checked;\r
+\r
             // Enable auto naming feature.\r
-            if (Properties.Settings.Default.autoNaming == "Checked")\r
+            if (Properties.Settings.Default.autoNaming)\r
                 check_autoNaming.CheckState = CheckState.Checked;\r
 \r
             // Store the auto name path\r
@@ -59,19 +62,35 @@ namespace Handbrake
             // Store auto name format\r
             txt_autoNameFormat.Text = Properties.Settings.Default.autoNameFormat;\r
 \r
+            // Use iPod/iTunes friendly .m4v extension for MP4 files.\r
+            if (Properties.Settings.Default.useM4v)\r
+                check_m4v.CheckState = CheckState.Checked;\r
+\r
             // #############################\r
             // Picture Tab\r
             // #############################\r
 \r
-            // Store decomb value string\r
-            txt_decomb.Text = Properties.Settings.Default.decomb;\r
+            // VLC Path\r
+            txt_vlcPath.Text = Properties.Settings.Default.VLC_Path;\r
+\r
+            // #############################\r
+            // Audio and Subtitles Tab\r
+            // #############################\r
+\r
+            drop_preferredLang.SelectedItem = Properties.Settings.Default.NativeLanguage;\r
+\r
+            if (Properties.Settings.Default.DubAudio)\r
+                radio_dub.Checked = true;\r
+            else\r
+                radio_foreignAndSubs.Checked = true;\r
+\r
 \r
             // #############################\r
             // CLI\r
             // #############################\r
 \r
             // Enable Start CLI minimized\r
-            if (Properties.Settings.Default.cli_minimized == "Checked")\r
+            if (Properties.Settings.Default.cli_minimized)\r
                 check_cli_minimized.CheckState = CheckState.Checked;\r
 \r
             // Number of processor cores\r
@@ -80,14 +99,18 @@ namespace Handbrake
             // Priority level for encodes\r
             drp_Priority.Text = Properties.Settings.Default.processPriority;\r
 \r
-            // Save individual log files\r
-            if (Properties.Settings.Default.saveLog == "Checked")\r
-                check_keepLogs.CheckState = CheckState.Checked;\r
+            // Log Verbosity Level\r
+            cb_logVerboseLvl.SelectedIndex = Properties.Settings.Default.verboseLevel;\r
+\r
 \r
             // Save logs in the same directory as encoded files\r
-            if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
+            if (Properties.Settings.Default.saveLogWithVideo)\r
                 check_saveLogWithVideo.CheckState = CheckState.Checked;\r
 \r
+            // Save Logs in a specified path\r
+            if (Properties.Settings.Default.saveLogToSpecifiedPath)\r
+                check_logsInSpecifiedLocation.CheckState = CheckState.Checked;\r
+\r
             // The saved log path\r
             text_logPath.Text = Properties.Settings.Default.saveLogPath;\r
 \r
@@ -96,56 +119,101 @@ namespace Handbrake
             // Advanced\r
             // #############################\r
 \r
-            // Unstable Snapshot checking should only be visible for stable builds.\r
-            if (Properties.Settings.Default.hb_build.ToString().EndsWith("1"))\r
+            // Minimise to Tray\r
+            if (Properties.Settings.Default.trayIconAlerts)\r
+                check_trayStatusAlerts.CheckState = CheckState.Checked;\r
+\r
+            // Tray Balloon popups\r
+            if (Properties.Settings.Default.MainWindowMinimize)\r
+                check_mainMinimize.CheckState = CheckState.Checked;\r
+\r
+            // Enable / Disable Query editor tab\r
+            if (Properties.Settings.Default.QueryEditorTab)\r
+                check_queryEditorTab.CheckState = CheckState.Checked;\r
+\r
+            // Prompt on inconsistant queries\r
+            check_promptOnUnmatchingQueries.Checked = Properties.Settings.Default.PromptOnUnmatchingQueries;\r
+\r
+            // Preset update notification\r
+            if (Properties.Settings.Default.presetNotification)\r
+                check_disablePresetNotification.CheckState = CheckState.Checked;\r
+\r
+            // Experimental In-GUI encode status indicator.\r
+            if (Properties.Settings.Default.enocdeStatusInGui)\r
+                check_inGuiStatus.CheckState = CheckState.Checked;\r
+\r
+            // Days between update checks\r
+            switch (Properties.Settings.Default.daysBetweenUpdateCheck)\r
             {\r
-                lbl_appcastUnstable.Visible = false;\r
-                check_snapshot.Visible = false;\r
+                case 1:\r
+                    drop_updateCheckDays.SelectedIndex = 0;\r
+                    break;\r
+                case 7:\r
+                    drop_updateCheckDays.SelectedIndex = 1;\r
+                    break;\r
+                case 30:\r
+                    drop_updateCheckDays.SelectedIndex = 2;\r
+                    break;\r
             }\r
 \r
-            // Enable snapshot updating\r
-            if (Properties.Settings.Default.checkSnapshot == "Checked")\r
-                check_snapshot.CheckState = CheckState.Checked;\r
+            // x264 step\r
+            string step = Properties.Settings.Default.x264cqstep.ToString(new CultureInfo("en-US"));\r
+            switch (step)\r
+            {\r
+                case "1":\r
+                    drop_x264step.SelectedIndex = 0;\r
+                    break;\r
+                case "0.5":\r
+                    drop_x264step.SelectedIndex = 1;\r
+                    break;\r
+                case "0.25":\r
+                    drop_x264step.SelectedIndex = 2;\r
+                    break;\r
+                case "0.2":\r
+                    drop_x264step.SelectedIndex = 3;\r
+                    break;\r
+            }\r
 \r
-            // Enable GUI DVD Drive detection code\r
-            if (Properties.Settings.Default.drive_detection == "Checked")\r
-                btn_drive_detect.CheckState = CheckState.Checked;\r
+            // Use Experimental dvdnav\r
+            if (Properties.Settings.Default.noDvdNav)\r
+                check_dvdnav.CheckState = CheckState.Checked;\r
 \r
+            // #############################\r
+            // Debug\r
+            // #############################\r
+            if (Properties.Settings.Default.disableResCalc)\r
+                check_disableResCalc.Checked = true;\r
         }\r
 \r
         #region General\r
         private void check_updateCheck_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.updateStatus = check_updateCheck.CheckState.ToString();\r
-        }\r
-\r
-        private void check_userDefaultSettings_CheckedChanged(object sender, EventArgs e)\r
-        {\r
-            Properties.Settings.Default.defaultSettings = check_userDefaultSettings.CheckState.ToString();\r
+            Properties.Settings.Default.updateStatus = check_updateCheck.Checked;\r
         }\r
 \r
         private void check_tooltip_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.tooltipEnable = check_tooltip.CheckState.ToString();\r
-            if (check_tooltip.Checked)\r
-            {\r
-                ToolTip.Active = true;\r
-                mainWindow.ToolTip.Active = true;\r
-            }\r
-            else\r
-            {\r
-                ToolTip.Active = false;\r
-                mainWindow.ToolTip.Active = false;\r
-            }\r
+            Properties.Settings.Default.tooltipEnable = check_tooltip.Checked;\r
         }\r
+\r
         private void drp_completeOption_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
             Properties.Settings.Default.CompletionOption = drp_completeOption.Text;\r
         }\r
 \r
+        private void check_GrowlQueue_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.growlQueue = check_GrowlQueue.Checked;\r
+        }\r
+\r
+        private void check_growlEncode_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.growlEncode = check_growlEncode.Checked;\r
+        }\r
+\r
         private void check_autoNaming_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.autoNaming = check_autoNaming.CheckState.ToString();\r
+            Properties.Settings.Default.autoNaming = check_autoNaming.Checked;\r
         }\r
 \r
         private void txt_autoNameFormat_TextChanged(object sender, EventArgs e)\r
@@ -169,19 +237,47 @@ namespace Handbrake
             else\r
                 Properties.Settings.Default.autoNamePath = text_an_path.Text;\r
         }\r
+\r
+        private void check_m4v_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.useM4v = check_m4v.Checked;\r
+        }\r
         #endregion\r
 \r
         #region Picture\r
-        private void txt_decomb_TextChanged(object sender, EventArgs e)\r
+        private void btn_vlcPath_Click(object sender, EventArgs e)\r
+        {\r
+            openFile_vlc.ShowDialog();\r
+            if (openFile_vlc.FileName != string.Empty)\r
+                txt_vlcPath.Text = openFile_vlc.FileName;\r
+        }\r
+        private void txt_vlcPath_TextChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.decomb = txt_decomb.Text;\r
+            Properties.Settings.Default.VLC_Path = txt_vlcPath.Text;\r
         }\r
         #endregion\r
 \r
+        #region Audio and Subtitles\r
+        private void drop_preferredLang_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.NativeLanguage = drop_preferredLang.SelectedItem.ToString();\r
+        }\r
+        private void radio_dub_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (radio_dub.Checked)\r
+                Properties.Settings.Default.DubAudio = true;\r
+        }\r
+        private void radio_foreignAndSubs_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            if (radio_foreignAndSubs.Checked)\r
+                Properties.Settings.Default.DubAudio = false;\r
+        }       \r
+        #endregion\r
+\r
         #region CLI\r
         private void check_cli_minimized_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.cli_minimized = check_cli_minimized.CheckState.ToString();\r
+            Properties.Settings.Default.cli_minimized = check_cli_minimized.Checked;\r
         }\r
 \r
         private void drp_processors_SelectedIndexChanged(object sender, EventArgs e)\r
@@ -194,16 +290,19 @@ namespace Handbrake
             Properties.Settings.Default.processPriority = drp_Priority.Text;\r
         }\r
 \r
-        private void check_keepLogs_CheckedChanged(object sender, EventArgs e)\r
+        private void cb_logVerboseLvl_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.saveLog = check_keepLogs.CheckState.ToString();\r
+            Properties.Settings.Default.verboseLevel = cb_logVerboseLvl.SelectedIndex;\r
         }\r
 \r
         private void check_saveLogWithVideo_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.saveLogWithVideo = check_saveLogWithVideo.CheckState.ToString();\r
-            if (check_saveLogWithVideo.Checked == true)\r
-                text_logPath.Text = "";\r
+            Properties.Settings.Default.saveLogWithVideo = check_saveLogWithVideo.Checked;\r
+        }\r
+\r
+        private void check_logsInSpecifiedLocation_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.saveLogToSpecifiedPath = check_logsInSpecifiedLocation.Checked;\r
         }\r
 \r
         private void btn_saveLog_Click(object sender, EventArgs e)\r
@@ -217,21 +316,110 @@ namespace Handbrake
         private void text_logPath_TextChanged(object sender, EventArgs e)\r
         {\r
             Properties.Settings.Default.saveLogPath = text_logPath.Text;\r
-            if (text_logPath.Text != String.Empty)\r
-                check_saveLogWithVideo.Checked = false;\r
         }\r
 \r
+        private void btn_viewLogs_Click(object sender, EventArgs e)\r
+        {\r
+            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+            string windir = Environment.GetEnvironmentVariable("WINDIR");\r
+            System.Diagnostics.Process prc = new System.Diagnostics.Process();\r
+            prc.StartInfo.FileName = windir + @"\explorer.exe";\r
+            prc.StartInfo.Arguments = logDir;\r
+            prc.Start();\r
+        }\r
+\r
+        private void btn_clearLogs_Click(object sender, EventArgs e)\r
+        {\r
+            DialogResult result = MessageBox.Show("Are you sure you wish to clear the log file directory?", "Clear Logs", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);\r
+            if (result == DialogResult.Yes)\r
+            {\r
+                Main.clearLogs();\r
+                MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK,\r
+                                MessageBoxIcon.Information);\r
+            }\r
+        }\r
         #endregion\r
 \r
         #region Advanced\r
-        private void btn_drive_detect_CheckedChanged(object sender, EventArgs e)\r
+\r
+        private void check_mainMinimize_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.MainWindowMinimize = check_mainMinimize.Checked;\r
+            check_trayStatusAlerts.Enabled = check_mainMinimize.Checked;\r
+        }\r
+\r
+        private void check_trayStatusAlerts_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.trayIconAlerts = check_trayStatusAlerts.Checked;\r
+        }\r
+\r
+        private void check_queryEditorTab_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.drive_detection = btn_drive_detect.CheckState.ToString();\r
+            Properties.Settings.Default.QueryEditorTab = check_queryEditorTab.Checked;\r
+            check_promptOnUnmatchingQueries.Enabled = check_queryEditorTab.Checked;\r
         }\r
 \r
-        private void check_snapshot_CheckedChanged(object sender, EventArgs e)\r
+        private void check_promptOnUnmatchingQueries_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.PromptOnUnmatchingQueries = check_promptOnUnmatchingQueries.Checked;\r
+        }\r
+\r
+        private void check_disablePresetNotification_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.presetNotification = check_disablePresetNotification.Checked;\r
+        }\r
+\r
+        private void check_inGuiStatus_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.enocdeStatusInGui = check_inGuiStatus.Checked;\r
+        }\r
+\r
+        private void drop_updateCheckDays_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            switch (drop_updateCheckDays.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    Properties.Settings.Default.daysBetweenUpdateCheck = 1;\r
+                    break;\r
+                case 1:\r
+                    Properties.Settings.Default.daysBetweenUpdateCheck = 7;\r
+                    break;\r
+                case 2:\r
+                    Properties.Settings.Default.daysBetweenUpdateCheck = 30;\r
+                    break;\r
+            }\r
+        }\r
+\r
+        private void x264step_SelectedIndexChanged(object sender, EventArgs e)\r
+        {\r
+            switch (drop_x264step.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    Properties.Settings.Default.x264cqstep = 1.0;\r
+                    break;\r
+                case 1:\r
+                    Properties.Settings.Default.x264cqstep = 0.50;\r
+                    break;\r
+                case 2:\r
+                    Properties.Settings.Default.x264cqstep = 0.25;\r
+                    break;\r
+                case 3:\r
+                    Properties.Settings.Default.x264cqstep = 0.20;\r
+                    break;\r
+            }\r
+            mainWindow.setQualityFromSlider();\r
+        }\r
+\r
+        private void check_dvdnav_CheckedChanged(object sender, EventArgs e)\r
+        {\r
+            Properties.Settings.Default.noDvdNav = check_dvdnav.Checked;\r
+        }\r
+        #endregion\r
+\r
+        #region Debug\r
+        private void check_disableResCalc_CheckedChanged(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.checkSnapshot = check_snapshot.CheckState.ToString();\r
+            Properties.Settings.Default.disableResCalc = check_disableResCalc.Checked;\r
         }\r
         #endregion\r
 \r
index 74bf186..f16c6a9 100644 (file)
   <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>132, 18</value>\r
   </metadata>\r
+  <data name="check_m4v.ToolTip" xml:space="preserve">\r
+    <value>Use .m4v instead of .mp4 for MP4 files\r
+\r
+Chapter Markers, AC3 Audio and SRT Subtitles will require the m4v extension if you are using QuickTime for playback.\r
+When this option is disabled, Chapter Markers, AC3 audio and SRT subtitiles will still automatically change the file extension to m4v.\r
+</value>\r
+  </data>\r
+  <data name="check_disableResCalc.ToolTip" xml:space="preserve">\r
+    <value>If the new Picture Settings panel is causing you problems, enable this option.\r
+It disables some of the resolution calcuation code for None and Custom modes.\r
+When enabled, the values in the text boxes will simply be passed through to the CLI so it is up to you to get the values correct.</value>\r
+  </data>\r
   <metadata name="pathFinder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>17, 17</value>\r
   </metadata>\r
+  <metadata name="openFile_vlc.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>224, 18</value>\r
+  </metadata>\r
   <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
     <value>\r
diff --git a/win/C#/frmPreview.Designer.cs b/win/C#/frmPreview.Designer.cs
new file mode 100644 (file)
index 0000000..0868193
--- /dev/null
@@ -0,0 +1,214 @@
+namespace Handbrake\r
+{\r
+    partial class frmPreview\r
+    {\r
+        /// <summary>\r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary>\r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing)\r
+            {\r
+                if (components != null)\r
+                {\r
+                    components.Dispose();\r
+                }\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Windows Form Designer generated code\r
+\r
+        /// <summary>\r
+        /// Required method for Designer support - do not modify\r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPreview));\r
+            this.toolBar = new System.Windows.Forms.ToolStrip();\r
+            this.lbl_preview = new System.Windows.Forms.ToolStripLabel();\r
+            this.cb_preview = new System.Windows.Forms.ToolStripComboBox();\r
+            this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();\r
+            this.cb_duration = new System.Windows.Forms.ToolStripComboBox();\r
+            this.btn_playQT = new System.Windows.Forms.ToolStripButton();\r
+            this.btn_playVLC = new System.Windows.Forms.ToolStripButton();\r
+            this.QTControl = new AxQTOControlLib.AxQTControl();\r
+            this.panel1 = new System.Windows.Forms.Panel();\r
+            this.lbl_status = new System.Windows.Forms.Label();\r
+            this.toolBar.SuspendLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.QTControl)).BeginInit();\r
+            this.panel1.SuspendLayout();\r
+            this.SuspendLayout();\r
+            // \r
+            // toolBar\r
+            // \r
+            this.toolBar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;\r
+            this.toolBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.lbl_preview,\r
+            this.cb_preview,\r
+            this.toolStripLabel2,\r
+            this.cb_duration,\r
+            this.btn_playQT,\r
+            this.btn_playVLC});\r
+            this.toolBar.Location = new System.Drawing.Point(0, 0);\r
+            this.toolBar.Name = "toolBar";\r
+            this.toolBar.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
+            this.toolBar.Size = new System.Drawing.Size(772, 25);\r
+            this.toolBar.TabIndex = 37;\r
+            this.toolBar.Text = "toolStrip1";\r
+            // \r
+            // lbl_preview\r
+            // \r
+            this.lbl_preview.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_preview.Name = "lbl_preview";\r
+            this.lbl_preview.Size = new System.Drawing.Size(91, 22);\r
+            this.lbl_preview.Text = "Start at Preview:";\r
+            // \r
+            // cb_preview\r
+            // \r
+            this.cb_preview.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.cb_preview.DropDownWidth = 75;\r
+            this.cb_preview.FlatStyle = System.Windows.Forms.FlatStyle.Standard;\r
+            this.cb_preview.Font = new System.Drawing.Font("Tahoma", 9F);\r
+            this.cb_preview.Items.AddRange(new object[] {\r
+            "1",\r
+            "2",\r
+            "3",\r
+            "4",\r
+            "5",\r
+            "6",\r
+            "7",\r
+            "8",\r
+            "9",\r
+            "10"});\r
+            this.cb_preview.Name = "cb_preview";\r
+            this.cb_preview.Size = new System.Drawing.Size(75, 25);\r
+            // \r
+            // toolStripLabel2\r
+            // \r
+            this.toolStripLabel2.BackColor = System.Drawing.Color.Transparent;\r
+            this.toolStripLabel2.Name = "toolStripLabel2";\r
+            this.toolStripLabel2.Size = new System.Drawing.Size(107, 22);\r
+            this.toolStripLabel2.Text = "Duration (seconds)";\r
+            // \r
+            // cb_duration\r
+            // \r
+            this.cb_duration.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.cb_duration.DropDownWidth = 75;\r
+            this.cb_duration.FlatStyle = System.Windows.Forms.FlatStyle.Standard;\r
+            this.cb_duration.Font = new System.Drawing.Font("Tahoma", 9F);\r
+            this.cb_duration.Items.AddRange(new object[] {\r
+            "5",\r
+            "10",\r
+            "15",\r
+            "20",\r
+            "25",\r
+            "30",\r
+            "35",\r
+            "40",\r
+            "45",\r
+            "50",\r
+            "55",\r
+            "60"});\r
+            this.cb_duration.Margin = new System.Windows.Forms.Padding(0);\r
+            this.cb_duration.Name = "cb_duration";\r
+            this.cb_duration.Size = new System.Drawing.Size(75, 25);\r
+            // \r
+            // btn_playQT\r
+            // \r
+            this.btn_playQT.Image = global::Handbrake.Properties.Resources.Play_small;\r
+            this.btn_playQT.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
+            this.btn_playQT.ImageTransparentColor = System.Drawing.Color.Magenta;\r
+            this.btn_playQT.Name = "btn_playQT";\r
+            this.btn_playQT.Size = new System.Drawing.Size(96, 22);\r
+            this.btn_playQT.Text = "Play with QT";\r
+            this.btn_playQT.Click += new System.EventHandler(this.btn_playQT_Click);\r
+            // \r
+            // btn_playVLC\r
+            // \r
+            this.btn_playVLC.Image = global::Handbrake.Properties.Resources.Play_small;\r
+            this.btn_playVLC.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
+            this.btn_playVLC.ImageTransparentColor = System.Drawing.Color.Magenta;\r
+            this.btn_playVLC.Name = "btn_playVLC";\r
+            this.btn_playVLC.Size = new System.Drawing.Size(101, 22);\r
+            this.btn_playVLC.Text = "Play with VLC";\r
+            this.btn_playVLC.Click += new System.EventHandler(this.btn_playVLC_Click);\r
+            // \r
+            // QTControl\r
+            // \r
+            this.QTControl.Enabled = true;\r
+            this.QTControl.Location = new System.Drawing.Point(0, 0);\r
+            this.QTControl.Name = "QTControl";\r
+            this.QTControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("QTControl.OcxState")));\r
+            this.QTControl.Size = new System.Drawing.Size(64, 72);\r
+            this.QTControl.TabIndex = 39;\r
+            this.QTControl.Visible = false;\r
+            // \r
+            // panel1\r
+            // \r
+            this.panel1.Controls.Add(this.lbl_status);\r
+            this.panel1.Controls.Add(this.QTControl);\r
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.panel1.Location = new System.Drawing.Point(0, 25);\r
+            this.panel1.Name = "panel1";\r
+            this.panel1.Size = new System.Drawing.Size(772, 481);\r
+            this.panel1.TabIndex = 40;\r
+            // \r
+            // lbl_status\r
+            // \r
+            this.lbl_status.AutoSize = true;\r
+            this.lbl_status.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_status.Dock = System.Windows.Forms.DockStyle.Top;\r
+            this.lbl_status.Font = new System.Drawing.Font("Tahoma", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_status.ForeColor = System.Drawing.Color.White;\r
+            this.lbl_status.Location = new System.Drawing.Point(0, 0);\r
+            this.lbl_status.Name = "lbl_status";\r
+            this.lbl_status.Size = new System.Drawing.Size(51, 25);\r
+            this.lbl_status.TabIndex = 40;\r
+            this.lbl_status.Text = "{0}";\r
+            this.lbl_status.Visible = false;\r
+            // \r
+            // frmPreview\r
+            // \r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+            this.BackColor = System.Drawing.Color.Black;\r
+            this.ClientSize = new System.Drawing.Size(772, 506);\r
+            this.Controls.Add(this.panel1);\r
+            this.Controls.Add(this.toolBar);\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
+            this.Name = "frmPreview";\r
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
+            this.Text = "Video Preview";\r
+            this.toolBar.ResumeLayout(false);\r
+            this.toolBar.PerformLayout();\r
+            ((System.ComponentModel.ISupportInitialize)(this.QTControl)).EndInit();\r
+            this.panel1.ResumeLayout(false);\r
+            this.panel1.PerformLayout();\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.ToolStrip toolBar;\r
+        private System.Windows.Forms.ToolStripButton btn_playQT;\r
+        private AxQTOControlLib.AxQTControl QTControl;\r
+        private System.Windows.Forms.ToolStripComboBox cb_preview;\r
+        private System.Windows.Forms.ToolStripLabel lbl_preview;\r
+        private System.Windows.Forms.ToolStripLabel toolStripLabel2;\r
+        private System.Windows.Forms.ToolStripComboBox cb_duration;\r
+        private System.Windows.Forms.ToolStripButton btn_playVLC;\r
+        private System.Windows.Forms.Panel panel1;\r
+        private System.Windows.Forms.Label lbl_status;\r
+    }\r
+}
\ No newline at end of file
diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs
new file mode 100644 (file)
index 0000000..59e6c25
--- /dev/null
@@ -0,0 +1,221 @@
+using System;\r
+using System.Windows.Forms;\r
+using System.Threading;\r
+using System.Diagnostics;\r
+using System.Runtime.InteropServices;\r
+using System.IO;\r
+using Handbrake.EncodeQueue;\r
+using Handbrake.Functions;\r
+using QTOControlLib;\r
+using QTOLibrary;\r
+\r
+namespace Handbrake\r
+{\r
+    public partial class frmPreview : Form\r
+    {\r
+\r
+        QueryGenerator hb_common_func = new QueryGenerator();\r
+        EncodeAndQueueHandler process = new EncodeAndQueueHandler();\r
+        private delegate void UpdateUIHandler();\r
+        String currently_playing = "";\r
+        readonly frmMain mainWindow;\r
+        private Thread player;\r
+        private Boolean noQT;\r
+\r
+        public frmPreview(frmMain mw)\r
+        {\r
+            try\r
+            {\r
+                InitializeComponent();\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show(mw, "It would appear QuickTime 7 is not installed or not accessible. QuickTime preview functionality will be disabled! \n\n Debug Info:\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                btn_playQT.Enabled = false;\r
+                noQT = true;\r
+            }\r
+            this.mainWindow = mw;\r
+            cb_preview.SelectedIndex = 0;\r
+            cb_duration.SelectedIndex = 1;\r
+        }\r
+\r
+        #region Encode Sample\r
+        private void btn_playVLC_Click(object sender, EventArgs e)\r
+        {\r
+            lbl_status.Visible = true;\r
+            try\r
+            {\r
+                QTControl.URL = "";\r
+                if (File.Exists(currently_playing))\r
+                    File.Delete(currently_playing);\r
+            }\r
+            catch (Exception)\r
+            {\r
+                MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+\r
+            btn_playQT.Enabled = false;\r
+            btn_playVLC.Enabled = false;\r
+            lbl_status.Text = "Encoding Sample for (VLC) ...";\r
+            int duration;\r
+            int.TryParse(cb_duration.Text, out duration);\r
+            String query = hb_common_func.GenerateCLIQuery(mainWindow, duration, cb_preview.Text);\r
+            ThreadPool.QueueUserWorkItem(procMonitor, query);\r
+        }\r
+        private void btn_playQT_Click(object sender, EventArgs e)\r
+        {\r
+            if (mainWindow.text_destination.Text.Contains(".mkv"))\r
+            {\r
+                MessageBox.Show(this,\r
+                                "The QuickTime Control does not support MKV files, It is recommended you use VLC option instead.",\r
+                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+            else\r
+            {\r
+                lbl_status.Visible = true;\r
+                try\r
+                {\r
+                    QTControl.URL = "";\r
+                    if (File.Exists(currently_playing))\r
+                        File.Delete(currently_playing);\r
+                }\r
+                catch (Exception)\r
+                {\r
+                    MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                }\r
+\r
+                btn_playQT.Enabled = false;\r
+                btn_playVLC.Enabled = false;\r
+                lbl_status.Text = "Encoding Sample for (QT) ...";\r
+                int duration;\r
+                int.TryParse(cb_duration.Text, out duration);\r
+                String query = hb_common_func.GenerateCLIQuery(mainWindow, duration, cb_preview.Text);\r
+\r
+                ThreadPool.QueueUserWorkItem(procMonitor, query);\r
+            }\r
+        }\r
+        private void procMonitor(object state)\r
+        {\r
+            // Make sure we are not already encoding and if we are then display an error.\r
+            if (process.hbProcess != null)\r
+                MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            else\r
+            {\r
+                process.RunCli((string)state);\r
+                if (process.hbProcess != null)\r
+                {\r
+                    process.hbProcess.WaitForExit();\r
+                    process.hbProcess = null;\r
+                }\r
+                encodeCompleted();\r
+            }\r
+        }\r
+        private void encodeCompleted()\r
+        {\r
+            try\r
+            {\r
+                if (InvokeRequired)\r
+                {\r
+                    BeginInvoke(new UpdateUIHandler(encodeCompleted));\r
+                    return;\r
+                }\r
+                if (!noQT)\r
+                    btn_playQT.Enabled = true;\r
+                btn_playVLC.Enabled = true;\r
+\r
+                // Decide which player to use.\r
+                String playerSelection = lbl_status.Text.Contains("QT") ? "QT" : "VLC";\r
+\r
+                lbl_status.Text = "Loading Clip ...";\r
+\r
+                // Get the sample filename\r
+                if (mainWindow.text_destination.Text != "")\r
+                    currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".mkv", "_sample.mkv"); ;\r
+\r
+                // Play back in QT or VLC\r
+                if (playerSelection == "QT")\r
+                    play();\r
+                else\r
+                    playVLC();\r
+\r
+                lbl_status.Text = "";\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show(this, "frmPreview.cs encodeCompleted " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+        }\r
+        #endregion\r
+\r
+        #region Playback\r
+\r
+        /// <summary>\r
+        /// Play the video back in the QuickTime control\r
+        /// </summary>\r
+        private void play()\r
+        {\r
+            player = new Thread(OpenMovie) { IsBackground = true };\r
+            player.Start();\r
+            lbl_status.Visible = false;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Play the video back in an external VLC player\r
+        /// </summary>\r
+        private void playVLC()\r
+        {\r
+            // Launch VLC and play video.\r
+            if (currently_playing != "")\r
+            {\r
+                if (File.Exists(currently_playing))\r
+                {\r
+                    if (File.Exists(Properties.Settings.Default.VLC_Path))\r
+                    {\r
+                        String args = "\"" + currently_playing + "\"";\r
+                        ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.VLC_Path, args);\r
+                        Process.Start(vlc);\r
+                        lbl_status.Text = "VLC will now launch.";\r
+                    }\r
+                    else\r
+                        MessageBox.Show(this, "Unable to detect VLC Player. \nPlease make sure VLC is installed and the directory specified in HandBrake's options is correct. (See: \"Tools Menu > Options > Picture Tab\") ", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                }\r
+                else\r
+                    MessageBox.Show(this, "Unable to find the preview file. Either the file was deleted or the encode failed. Check the activity log for details.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+            lbl_status.Visible = false;\r
+        }\r
+\r
+        /// <summary>\r
+        /// QT control - Open the file\r
+        /// </summary>\r
+        [STAThread]\r
+        private void OpenMovie()\r
+        {\r
+            try\r
+            {\r
+                if (InvokeRequired)\r
+                {\r
+                    BeginInvoke(new UpdateUIHandler(OpenMovie));\r
+                    return;\r
+                }\r
+                QTControl.URL = currently_playing;\r
+                QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true);\r
+                QTControl.URL = currently_playing;\r
+                QTControl.Show();\r
+\r
+                this.ClientSize = QTControl.Size;\r
+                this.Height += 25;\r
+            }\r
+            catch (COMException ex)\r
+            {\r
+                QTUtils qtu = new QTUtils();\r
+                MessageBox.Show(this, "Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode), "QT", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+            catch (Exception ex)\r
+            {\r
+                MessageBox.Show(this, "Unable to open movie:\n\n" + ex, "QT", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            }\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/win/C#/frmPreview.resx b/win/C#/frmPreview.resx
new file mode 100644 (file)
index 0000000..f75a67c
--- /dev/null
@@ -0,0 +1,512 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <metadata name="toolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>17, 17</value>\r
+  </metadata>\r
+  <data name="QTControl.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">\r
+    <value>\r
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w\r
+        LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0\r
+        ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAVQAAAAIB\r
+        AAAAAQAAAAAAAAAAAAAAAEAAAAAACAAAnQYAAHEHAAATAA8AAIATAAAAAAADAAAAAAALAP//AwAAAAAA\r
+        CAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACw==\r
+</value>\r
+  </data>\r
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
+  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+    <value>\r
+        AAABAAYAMDAAAAEACACoDgAAZgAAACAgAAABAAgAqAgAAA4PAAAQEAAAAQAIAGgFAAC2FwAAMDAAAAEA\r
+        IACoJQAAHh0AACAgAAABACAAqBAAAMZCAAAQEAAAAQAgAGgEAABuUwAAKAAAADAAAABgAAAAAQAIAAAA\r
+        AACACgAAAAAAAAAAAAAAAQAAAAAAAAAAAAD///8A/wAAAAD/AAAAAIAAgICAAICAAAAAgAAAAICAAIAA\r
+        AACAAIAAgP//ACAgIADg4OAAIAAAAAAgAABg4CAAQOBAAGBgYAAgYAAAQKDgAAAAIABAwCAAIEAAAECg\r
+        AABg4AAAIGCAAECAoABgoMAAYECgAGDAAABgICAAoKCgAOAAAAAgIAAAAGAAAEDgAABgAAAAIAAgAEAg\r
+        IAAgQGAAIIDAAADg4ABgAGAAgOD/ACCA/wCgAAAAQGAAACCAAAAAoAAAYCAAAAAgIAAgIEAAYGBAAEBg\r
+        YAAAIIAAAGCAAGCAgABAAKAAAICgAACgoACAoKAAIKDAAECgwAAAAOAAQADgAADA4ABgwOAAIODgAADg\r
+        AADA4AAAAEAgAKDgIAAA4EAAYABAAABAYACAAGAAgCBgAGAggABA4KAAAECgAGBAwADgIOAAIEDgAACA\r
+        4ADgoOAAYAD/ACBg/wAAoP8A4KD/AGD//wAICAgACAAAAAgIAAAAAJgACAAIAAAACAAACAAACBAQACA4\r
+        SAAgYIgAOHCIADhw+AAIGAAAEBAIACg4QAAwYHgAAACIACA4QAAoQFAAKFh4AHh4eAAwaIAAIGiQADh4\r
+        mAAACAgAEAgIABAYGAAgGBgASEhIABhIYAAoUGAAIFBoAChQaAAoWGgAMFhoAChoiAAweJgAKHioACiA\r
+        sAAIEAAACAgQAAgQGAAQGCAAGCAoABhAUAAoSFgAaGhoABhQcAAgWHAAKFhwADhgcAAYWIAAOGiAAIiI\r
+        iAAoaJAAKHCYACh4oAA4gKAAMICoAKioqAAwmNAAEDgAAChYAAAweAAAMIgQAAgYGAAYGBgACBggABAg\r
+        KAAgKCgAKCgoACAwOAA4ODgAKDhIADBQWABYWFgAGEhoADBYcAAYUHgAGFh4ACBYeAAoYHgAKGCAABhY\r
+        iAAgaJgAKICoACiIuAC4uLgAMJDIADiw6AAQCAAAABgAAAggAAAAOAAAMGgAABgQCAAwgAgAEAgQABgQ\r
+        EAAwmBgAGBggAAgYKAAAICgACCAoABgoMAAgKDAAGDBAABg4QAAYOFAAEEBYACBIWAAwSFgAOEhYACBI\r
+        YAAQSGgAOFhoABhIcAAoUHAAQFhwACBgeABAaIAAIGiIADBwiABAcIgAGGCQADhwkABYeJAACBCgAChw\r
+        oAAweKAAKIC4ACiQwAAwmMgAOKjgADBg6ABAsOgAELD4AAgoAAAIMAAAGDAAABhIAAAYUAAAKHgAAACY\r
+        AAAwmAAAAMgAABAACAAIEAgAEBgIABA4CAAYOAgAMHgIABAYEAAYGBAAIBgQACh4EAAwmBAAEBAYABgg\r
+        GAAoIBgAGCAgAAgIKAAgICgAGAgwAAggMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAWwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAn2KfdXV1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAABoo2+QIJCJb28Sd3em\r
+        nQAAAFuKqW0aqsd6Y5/DXAAAAAAAAAAAAAAAAAAAAAAAAAB3kAWQkG8SpqaJb28gsncAbIeSroyii21x\r
+        kczIwwAAAAAAAAAAAAAAAAAAAAAAAABoo4mJkLKylm9vb5BvdwwAcZO/fox7z2NjqsOss2MAWwAAAAAA\r
+        AAAAAAAAAAAAAAAAvaGmo5ANlgUFEiBvo1xjq3p6qMTJroBkxXt9cGzFnAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAL2ylgV3vQAAAGOvxMXXq41uh6yVjxqp1YhknwAAAAAAAAAAAAAAAAAAAAAAAAAAAABvsolbAAAA\r
+        +5KneouS2Kx4pZF9ndywsXuvkocAAAAAAAAAAAAAAAAAAAAAAAAAAAB3sncAAAAAdayHca95bH9+cKmv\r
+        fMVucG2B4MYAAAAAAAAAAAAAAAAAAAAAAAAAAAChsqMAAAAAe3VkyHF5kW59cN3eZc/XyXutyot7AAAA\r
+        AAAAAAAAAAAAAAAAAAAAAACjIKEAAACgfv94gX+PituLDI0/aoBxqxqOY8PgbQAAAAAAAAAAAAAAAAAA\r
+        AAAAAAChkAwAAACieap4k3CVZIB/apWlxNTgepXbf4caagAAAAAAAAAAAAAAAAAAAAAAAAChkJ0AAABc\r
+        es1kxaLVl5eNkqnebHp6eK20amSvxlsAAAAAAAAAAAAAAAAAAAAAAACjlqMAAABcY5VurYBlfcuUgciB\r
+        fWSRxceHepPbgAAAAAAAAAAAAAAAAAAAAAAAAACJsqMAAACdeWOIgMeXbcN+35esZdeAedtxxYG0q54A\r
+        AAAAAAAAAAAAAAAAAAAAAKGyshJbAAD/ZGNp2LGUi9caennJh+DYi2Rx1J6LipMAAAAAAAAAAAAAAAAA\r
+        AAAAAKNvEqa9AACGccdxe3Jw1KmBioqAkm1pi5ezkofQq7BcAAAAAAAAAAAAAAAAvaUIPEI+QkI+esFc\r
+        asenr9X9bt6zqoDPsYeX1X7gq2SOfhrAAAAAAAAAAAAAAGJlQ+Mq4+PjKioqREOxS4aI3nJueox6eN7e\r
+        ktWO3WV4ybHb38NiAAAAAAAAAABcSxws4+MtZi3j4+Pj4+MNQzhszH1kjmp72Hnfen+OgHxtgXyXZXLG\r
+        AAAAAAAAAADNLCxYLWZmZmYtZi3jLS0UAUM4o4bYs4+BqYFjcH2Xl86UjpNqjJOtAAAAAAAAAM1DDWYt\r
+        U1Bm4eFmZmYtZuHaFEMpx63MiKR+25WPsX+NcNa0eLNpeZN5AAAAAAAAFWYNQ2ZmUF5m4V7hZmbhZuFe\r
+        a0sI/4aOampq1XIbzd0/bGVy4mVw0xtpAAAAAAAANywNZlNQ2l7a2l7aUOFT2tpeBMg7xTZyZWTXfaDV\r
+        l7SUfo5lZXDIZMpbAAAAAAAA2w2y2l5eXl5eXl5eXtraXl5eXl5reyw2jXHIZZFuj+J9sa/iaWWX4GwA\r
+        AAAAAAAAUA2WXl5eXl5ra2trXl5eXl5eBMU5Cws2aZU/2HHN4sptleKUbnIbcs4AAAAAAACDa1myBP7+\r
+        /v4EBAQ0///+NAQ0PQsLPWNppXqNY5eX4o+z2KWop9ulG8kAAAAAAAAA/BwNBAQ3Lh832tra0gg0NzSl\r
+        Cwul/ASGcM2zfXySiJTN23LLtLGNGwAAAAAAAAAAvTcNUdo0LjTa2tprNDzHBDekCxz8BP4Axty0G39x\r
+        sWW039gbGxvK+wAAAAAAAAAAW1umlvwnCcAENzQ3/giqNMe8pT0EXmAAAHZ8eZeK4G0blaE2ozXxYQAA\r
+        AAAAAAAAAAAAIG0lCWGj+gAAAMYIXF1bAMhL/FwAAAAAW9Xg4tN3menrvvf2t/EAAAAAAAAAAAAA/WkO\r
+        umB3vwBgAHNLYlsAAMI8QjgAAAAAAABg+Ofr6xj3vr6bmea3AAAAAAAAAAAAALUuaAANiQAAALU8xlw2\r
+        bFzBKkLBAAAAAADm9haa9773uZqZ7wAAAAAAAAAAAAAA/zc081uJEgBbW1zSCHYLHADBQjycAAAAAGH2\r
+        vru5FpoW95nnmABgAAAAAAAAAAAVUFNTN1tidQyhoAzGPAB3bcY8PsMAAAAAAObwgua5FrubEZu5F4IA\r
+        AAAAAAAAwJ68NzfaNwAAAAAAAABbPMgAxjg4AAAAAAAAAAAAt+e5vpuavhbp6GcAAAAAAACi2dPZ2dnR\r
+        hQAAAAAAAAAACM0AAAAAAAAAAAAAAAAAAOmam/K7ufbwmGdbXwAAAACk2dFt2c7Ry9NpAAAAAAAA7rjk\r
+        uOTuAAAAAAAAAAAA8euZ6bnpmpmCAAAAAAAAAADKLLI5DQ09xM7ZhgAAAGEj7Afs6gfquOQAAAAAAADw\r
+        6ZhnE5no6JmZZwAAAAAAAAAAwzlvErIFlhyiYgAAAOXqMeoxI+oHB4IAAAAAYGcTtwCY6LeY54K55QAA\r
+        AAAAAAAAAB8nCTYSPRzEAAAAXyMHIyO4YWEAAAAAAAAAAAAAAACYYQBnmABntwAAAAAAAAAAAAAOJQAA\r
+        AAAAAAAAALa4XAD/xgAAAAAAAAAAAAAAAFsAAAAAt10AAAAAAAAAAAAAAARBOgAAAAAAAAAAAAAAAAAI\r
+        PAAAAAAAAAAAAAAAAFsAAAAAgmEAAAAAAAAAAAAAAEFZUf4AAAAAAAAAAAAAAADCCAAAAAAAAAAAAAAA\r
+        AAAAAAAAWwAAAAAAAAAAAAAAADpROoMAAAAAAAAAAAAAAAAAnGIAAAAAAAAAAAAAAAAAAAAAAFsAAAAA\r
+        AAAAAAAAAAD+YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFxbAAAAAAD///////8AAP//\r
+        /////wAA//4/////AAD/wAPgA/8AAP+AAAAA/wAA/wAAAAB/AAD/gAAAAD8AAP/AAAAAPwAA//AGAAA/\r
+        AAD//BwAAD8AAP/+PAAAHwAA//48AAAfAAD//jgAAA8AAP/+OAAADwAA//44AAAHAAD//jgAAAcAAP/8\r
+        OAAABwAA//wYAAADAAD/+BgAAAMAAP/AAAAAAwAA/wAAAAADAAD8AAAAAAMAAPwAAAAAAwAA+AAAAAAD\r
+        AADwAAAAAAMAAPAAAAAAAwAA8AAAAAADAADwAAAAAAcAAOAAAAAABwAA8AAAAAAPAADwAAAQAA8AAPAA\r
+        ABgADwAA+AAAHgAHAAD8AAAfgAMAAP4QAA+ADwAA/gAADgADAAD8AAAfAAMAAPAfxD/ABwAA4B/n/+AB\r
+        AADgB+B/wB8AAOADgB+ADwAA8AOAHhAPAAD4BwB/8kcAAPz/gf/nLwAA+P/5/+8/AADwf/n//z8AAPh/\r
+        /P//vwAA+P////+fAAAoAAAAIAAAAEAAAAABAAgAAAAAAIAEAAAAAAAAAAAAAAABAAAAAAAAAAAAAP//\r
+        /wAAAP8AAP//AAAAgACAgIAAgAAAAACAAAAAgIAAgIAAAECg4ABAgKAAYOAgAEDgQAAAIAAAACAgACAg\r
+        IABgIIAAIAAAACBAAAAAYAAAIIAAAGAgIABAYGAAAACgAGCAoACgoKAA4ODgAGDAAAAAACAAYABgAIAg\r
+        YAAAYMAAICAAACBgAABgYAAAQKAAAKDAAAAA4AAAYOAAAABAIAAgQCAAYAAgACBAQABgYEAAIABgACAg\r
+        YAAgQGAAYGBgACBggABgYIAAgACgAKCAoABgIMAAQKDAAGCgwAAgwMAAAADgAIDA4ACgwOAAAODgAIDg\r
+        4ACA4AAAgIAgAEDgIACgACAAQABgAIAggAAgYP8AAKD/AAgIAAAICAgACAAAABhAWAAoUGAAaGhoADBg\r
+        eAAoaIgAMICoAChggAAACAgAEAgIABgYGAAoUGgAKFhwAChwkAAIGAgACBAQABAgKAAQKDgAIEhgACBQ\r
+        aAAAAHgAIFh4AChgeAAAeHgAeHh4AChogAAwaIAAIGCIADBoiAA4cIgAIGiQADhwkAAoeKgAKICwAAgQ\r
+        AAAIIAAACAAIABhICAAICBAAMIgQABAYGAAYICgAGCgwAEhISAAwSFgAGFBoAChYaAAICHgAOGiAACh4\r
+        oAAweKAAGAAAAAAIAAAAGAAACBgAABAoAAAYUAAAKGAAAChoAAAAeAAAAAAIAAgQCAAQEAgAGP8IACAY\r
+        EAAIEBgAMJAYABggIAAAACgACBAoACgwMAAAKDgAEDA4ADg4OAAoOEAAGDhIACA4SAAAQEgAMEBIAEhQ\r
+        UAAISFgAIEhYAChIWAAwUFgAIEhoAEhYaAAYUHAAMFhwABhYeAAoWHgAIFiAAEhwgACIiIgAGGCQAAAA\r
+        mAAgcJgAKHCYADB4mACYmJgAACjIAEBw+ACo//8ASAAAAFgAAABoAAAAeAAAABAIAABICAAAGCgAAAA4\r
+        AAAYOAAACEAAAAhIAAAoUAAAAFgAACBYAAAAaAAAIGgAADB4AAAAiAAAMIgAAGiIAACAmAAAGAAIADAI\r
+        CABgCAgAEBgIAAggCAAQIAgAECgIAAgwCAAQMAgAODAIABA4CAAYOAgAEEAIABhACAAgQAgAIFAIAChg\r
+        CAAwgAgAMJAIADCoCAAACBAAGBAQABggEAAoIBAAKGAQAChoEAAgeBAAKHgQAEh4EAAY+BAACAAYAAAI\r
+        GAAICBgAEAgYAAAQGAAQEBgAABgYAAgYGAAYMBgAKHgYADCYGAAwoBgAMKgYAGj/GABgCCAACBAgAAgY\r
+        IAAQGCAAGBggACggIABIcCAACAAoABAAKAAAECgAEBAoAAggKAAACDAASAgwAAgQMAAIKDAAECgwAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAARxBSUlJHAAAAAABYWFlY8kYAAAAAAAAAAAAAAAAAAJFgqqRLSzAwBXMAkKJbW1pdSVmE\r
+        AAAAAAAAAAAAAAAAEJdLqhpgYKQFkf9NmVRanHVJVZRQAAAAAAAAAAAAAAAAUY6RO6qXMHNYW5MxdFpm\r
+        TVtPSpAAAAAAAAAAAAAAAAAAAAAFpIYAAFSeW09PU15KU05MaEkAAAAAAAAAAAAAAAAAAEtgAAAAk55j\r
+        ml5Mp2haXUqpW3IAAAAAAAAAAAAAAAAAS0sAAEpJoE5PpZpMZVWnMZyZVQAAAAAAAAAAAAAAAABLMAAA\r
+        cqCeSnppZGZKWzFNaV2ecAAAAAAAAAAAAAAAAEtLAACLVF6iZHROp2eiW1paeWnxAAAAAAAAAAAAAABI\r
+        GmAAAElJSmh6SWNVSk5hZqJ1VXUAAAAAAAAAAAAAlpmjeJAAk12eZXZ5p3WndnZpaUlbZgAAAAAAAAAA\r
+        m2lFRTw8PDZeWV1OlE0xeWlNeVVdZmmZUAAAAAAAjzYKRaysRUVFRa02SXSnYaFNTUxpTFSoTmKTAAAA\r
+        AI8KOkSrrKysrKxErDullF6fVWhiVakLaVWbVZoAAAAAqK2sRKZEqyCsRKummKBZT0xPTHppZVMLqVN4\r
+        cQAAAAA6O6sYGKYYGKsYphgELjejY09KTTZNaWdMNpkAAAAA+zc6XFxcd3d3XASmXEw6PZZiZ6g2ZUw2\r
+        T2QLnwAAAAAdoTtcLcV3pndfLi2jraMtcmNkT05np0xnaXhUAAAAAAD5NKL87xgYd1+eLZ06+1wAVE6o\r
+        p2cKZ2WjjgAAAAAAAAAQo67EcuZuj5jkACue9gAAkTEKeJfbioptRgAAAAAAAACIr0dLVwBXmEeL5Qg4\r
+        AAAAAOnqwNbVb9O5AAAAAAAAAP38RmDae3tfkDqIX0UAAABq3W9v6+2BtssAAAAAAAD9q6v7AFl1dV9f\r
+        mpgIXwAAAABrtG9v7O2BagAAAACSF52fL/AAAAAAAHUAAAAAAAAAAACC1NS+3s/ZzAAAAJ03MjqjdJ0A\r
+        AAC3FIMUtwAAAAAAzr27goK5awAAAAAAWaNgGho3dAAAyr+/v4ODtQAAAMmAAM+2zxMTawAAAAAAAK6z\r
+        kZ1xAAC1un3HVwAAAAAAAAAAawB/ftAAAAAAAABCNUIAAAAAAAAAAF8AAAAAAAAAAEcAAGpGAAAAAAAA\r
+        AEKsEQAAAAAAAAAAlZUAAAAAAAAAAAAAAEgAAAAAAAAAAC3hAAAAAAAAAAAAAAAAAAAAAAAAAAAARgAA\r
+        AAD///////////4BwH/8AAAf/AAAD/4AAA//xgAP/84AB//MAAf/zAAD/8wAA/+MAAP/BAAD/AAAAfAA\r
+        AAHgAAAB4AAAAeAAAAPAAAADwAAAA+AAIAfgADAD8AA8A/gAOAPwgDwDwPv+AcBwfAfAYDkD8GD/Q+P9\r
+        /s/j/P/v8///7ygAAAAQAAAAIAAAAAEACAAAAAAAQAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAA////AFEl\r
+        swBJDW0ABEMwAAJHSQAFDwIAXl9ZAHJtagBwfYQAQVNqAAFtAAAAZgAAAz0CABQ/AQAXQwAAGkAAAA8g\r
+        AQAhSJQAM1SRABw6fgAFVk0ADE48AAplaQAgWgIAMYcMACl7CwAOJwMAAAMtABwPNwAhIQAABxACAA9S\r
+        UAAnQUgAAISfACRoDAAxmwQAK4MHABMpAAA8P1kATBMbACQSVwAKL1EADS5CADFMVQABIF4AJ3CGADB2\r
+        kAAzdlEAMnY1ABMnEwBARooAVVq5ABgATwAWBn0ABh56AAULaQBOeKYAT3WSACpNZwAucpgAMHifADFx\r
+        nwA1b5YAMF93AEBalgBvjecADCLAAAkPpQAbJr4AFiLGAAAJjgAzbIEANGh8AClhgAAzfKEAMHWWADJz\r
+        kwAsW3MAQ4mvADyY9AAtgf8AIpr/ACuk/wBdk9UAG0tkACladQAqbI4AK3GUAC5vjwArbpEALWJ7ACdl\r
+        aAAOaoQAJJ20ABx0gQAeTF8AJ116ACViggAgZosAJmeJAChvlAAhZIgAH1ZyAHVmYwAaPVMAJ19+ACto\r
+        hgAmaIwAKGB9ACFdfAAgY4YAGU5qAFtgYQAYQVgAIVx7ACtrjgAtZYIAJmKAACNhgQAmX3wAIUpdAHp6\r
+        ewARN0wAH1R0ACdXcgApXnoAJ2B+ACligQAdSmAAKiopAGZlZQCRkZEAbm9vAFFSUwAWO08AJFRuACFP\r
+        agAhUm0AHD9RAAMKDgA3NjUAWlpaADk5OQA3NzcAPDk3AAYSGQAVNUgAFjFAAA8jLwABAgQAVQAAAP//\r
+        /wBWAAAA/f//AFcAAAD8//8AWAAAAPz//wBZAAAA/P//AFoAAAD9//8AWwAAAP7//wBcAAAA////AF4A\r
+        AAABAAAAXwAAAAEAAABgAAAAAQAAAGEAAAABAAAAYgAAAAEAAAB3IFIAbWFuAAAAAAAAAAAAAAAAAAAA\r
+        AAC0VWMAtFVjALwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAEAAAAAADgDAACfAQAAPwAAAAEA\r
+        AABAAAAAAQAAAEEAAAABAAAAQgAAAAEAAABFAAAA////AEYAAAD+//8ARwAAAP3//wBIAAAA/P//AEkA\r
+        AAD8//8ASgAAAPz//wBLAAAA/f//AEwAAAD///8ATQAAAAMAAABOAAAABwAAAE8AAAALAAAAUAAAABAA\r
+        AABRAAAAFQAAAFIAAAAZAAAAUwAAABwAAABUAAAAHgAAAFUAAAAeAAAAVgAAAB0AAABXAAAAGgAAAFgA\r
+        AAAWAAAAWQAAABIAAABaAAAADQAAAFsAAAAIAAAAXAAAAAQAAABeAAAA/v//AF8AAAD8//8AAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAI2Oj5CRkpOUlZYAAAAAAACCg4SFhoeIiYqLjAAAAAAAAAB6AHt8fX5/gIEAAAAA\r
+        AAAAcQByc3R1dnd4eQAAAAAAAGgAaWprbG1ub3AAAAAAXF1eX2BhYmNkZWZnAAAAT1BRUlNUVVZXWFla\r
+        WwAAQUJDREVGR0hJSktMTU4AADM0NTY3ODk6Ozw9Pj9AAAAAJygpKissLQAuLzAxMgAAABwdHh8gISIA\r
+        ACMkJSYAABITFAAAFRYXAAAYGRobAAAHCAkKAAsMDQAADg8QEQAAAAMAAAAEBQAAAAAABgAAAAACAAAA\r
+        AAAAAAAAAAAAAP//AADgBwAA4AMAAPoDAAD6AQAA+gEAAOABAADAAQAAgAEAAIABAADAQQAAwGEAAIxh\r
+        AACEYQAA3PsAAN//AAAoAAAAMAAAAGAAAAABACAAAAAAAIAlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAAGAAAACAAA\r
+        AAcAAAAHAAAABgAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxIOAwgFBAEOAQAAEgAA\r
+        ABgAAAAbAAAAHQAAAB0AAAAcAQEAGQAAABYAAAAQAAAADQAAAAwAAAAKAAAACgAAAAsAAAAQAAAAFwMH\r
+        CRwBAgMhAAMEIwEEBSUAAgMmAQICIwEBAR8AAAAYAAAAEQAAAAkAAAADAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQICAAgBAgATAQEBIAcI\r
+        CCwFBgc2BQUGQAYGBkgGBgVOBAQEVQUFBVUEBARTAQICTQcHB0UGBgY+BwcHNgICAi4AAAAoAAAAJAAA\r
+        ACcBAgIsAAABKQAAADAAAAA7AAAARwAAAE0BAABOAAAATAAAAEgAAAJCAQUHOAEAACwAAAAeAAAAEgAA\r
+        AAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGRIMEgAA\r
+        AB8AAAAxAAAAOwAAAFUAAAB2AAAAjQAAAKgAAAC1AAAAsQAAALIAAACrAAAAmQAAAIcAAABuAAAAWgAA\r
+        AEoAAABAAAAAQQABAzwAAAA8AAAAfA4eJZoGDA/AEx8m2A8YHNoSFxjaEBgbxwcAAJgDAACDAAAAagAA\r
+        AFUAAABHAAAAMwAAACAAAAAQAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAIAAAAQBQMCIAAAADMBAABMEA4Nkjc2Ndh9e3r4kI+P/J+fn/+IiIn/b29v/3Jycv9xcnL/Xlxb+0lK\r
+        SvJGRkbaUVBQzBoaGqIAAAB4AAAAUwEAAF4MCwu/G1Fw/xtTdf8iQVD/ImCB/xtXdv8YN0n/HE1s/x46\r
+        S/8QIy35EiUw4QoDAKMAAABwAAAAXAIAAEIAAAArAAAAGAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAQAAAASAAAAIwUFBjIAAABkQ0ND/46Ojv9/gID8hoaG/YmJif1ycnL8YWJh/VVV\r
+        Vf1bW1v+ZGVl/nNzc/94eHj/np+f/7Ozs/9HSEn6AAECmR41QuYaP1L/KW2V+xZbh/spVm38Gi85/B1X\r
+        dPwpQE78H2OO/CZoj/0eSmP+Dz1a/w8oN/0AAACtAAABdgAAAGAAAABEAAAAKwAAABcAAAAGAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAMAAAAGwEBAC4AAAA9Dg0LtDUzMv9nZ2b/bm5u/oWF\r
+        hfu7u7v9v7+//qioqP5xcXH+cnJy/nl5efuQkJD6cXFx/FBQUP8kJCLuAwAAvyJpj/8mdJ77FRsd/ipp\r
+        iv4sW3L+KFNs/hZLbf4kOUb/HDlJ/htae/4XKjX+KF17/DCTxf4jPEj5AQAAyQUEBHEAAABRAAAAOgAA\r
+        ACIAAAAPAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAACgAAABgAAAAlAAAANhMQ\r
+        DoYqKCfbVVNT/zIxMf+Li4v/4uPi/qurq/99fX3+fX19/2FhYf+UlZX/fHt8/zIzNNEFAQCqHjdF8yNZ\r
+        dvwkUGj+Hk1q/y9adP8hKi3/IERa/xhah/8kdKT/IGOG/xEwQP4lUWj/MlVo/zJmfP4hNT3+Ey88/wkV\r
+        G9MAAABZAAIDPAAAACYAAAATAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAIAAAAJAAAAEQAAABAAAAAlAAAAUAAAAH4TExPdtbW1/qysrPx+fn7+QUBA9RUUE48AAABzSFNQRQAA\r
+        AEseOkvoI2iW/yArMf0TM0P/G2SS/h5VeP41XXH/J1d0/h0+UP8rYXz/NISq/zxrf/8hXH/+FFB4/ixt\r
+        jP8oSFn+IWKJ+w0iK/8DBAScAAMFOQAAASEAAAARAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAABMREANaW1oDDQsJAQcICAAEAwNqdHR0/8PDxPhmZmf/DAwMmHt6\r
+        egAiLzUAbImSABsgIZQoc5z/G0hn+iNQaP8fU27+Jm+W/zFwkP8qXXv/GUJc/y9QXv8papD/MFZq/xca\r
+        Gv8zfKD/KH6q/zSMtv4sUmj/G2WX+ydxlf4aPE3MAAAAHAoYHxcAAAAIMSgjAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAQEAAgIBAgAAAAMAAAArSEhI+8TE\r
+        xP1LTEz7AAAAMwAAAAIbLDUHJj9NABAVGK8oYHz+F0BV+xxkkv4kapr/Jkte/yA1Pv8veJv/KWmH/zRo\r
+        g/8TTXb/ImyW/ydVaf8ZMkP/Klx4/zFmfv8nQ07+L4ex/jap4P0WNUP1AAAAUgAAAQAAAAACfmteAAoJ\r
+        CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOrr\r
+        6gD+/v4ELzAw0rS0tP8xMTHkAgECDl5eXgARBwEADwcBLiZRZ/EOGBz+H2KH/RM/W/8eYpH/LU9f/yZk\r
+        jf8kWHf/MlRh/zFmf/8mg7r/K43C/zZviP8VSG//G2KR/x1FV/8mU2z/LWGE/y5LV/0jWXL+K1Rm9ggA\r
+        AEofEA4AJx8aAQoFAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAKSlpQGvsLAAMDExqJubm/4oJya3eHp7AGRsbwUrRVEAHSYpkClqjP8KJzf6GEpk/yeB\r
+        r/8sdZz/OGV6/xVMbv8icKP/I1Zt/x0cHP83YHD/OpC2/zNjef8idaT/IGmP/yJcdf8kWn//FlSA/iM6\r
+        Rv8RKjb8Oqnb/yRCUOMnHBgMIBsYAAgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAENDQwJFRUUALi4uh42Ojv8cHR6hRkhJAEFVXgWh3uQAHy0zuiZL\r
+        Xv4YVXv7F0Ri/iR6ov80aYH/MYCl/xxijP8hcqb/MXma/y5edv82hK3/MU9b/yUtMv8eZof/M6vj/x9O\r
+        Yv8ufqf/IXOh/y90lf4XP1T+IV+A/C1hef8AAAI7AAECAA4REQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKampgGysrIALS4uopGRkf4VFRWhNTc5ACQm\r
+        JwYsIBcADAQBqh9Sbf8TSGr7H16H/xsyPP8iMjn/MW+L/zCazf81ndH/OV5t/yVwnP8TUnv/MY28/yM5\r
+        Qf8iU23/HlFp/xhIXv8pZoH/Oa/l/zBjev8cXYX+IGaZ+Ro2RP4IBQZgCQYGAAwMCwMbEgwAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgIAAAAAAG5ubgDIyMgIPTw83KWl\r
+        pv80MzPEw8TFAXt7egQBAAAACAQDZx84Rv8tfaj7JFp1/ydef/8reKf/NG2I/y9UZP83TFX/NoGj/yR9\r
+        sv8QOVr/K4Ox/zRVZf8eXIX/JmeR/xgyPf8UO07/Gz5O/yBQZv8hdKH/JHKj+iZ8pv4AAACbAgoOAAYT\r
+        GgIQCgYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALCgkAERAPBAAA\r
+        AAAAAABWZ2Zm/7Ozs/46OzvvCwsLFrq9vwEuQT8AGRscdypNX/8kOkT7J0hW/yV5qf8LME//NZ/X/yVE\r
+        Uf8UJzH/KWmG/zCXyf8zmNH/K2B4/ztwiv8ZYI7/J3al/yVOYv8gcp7/IWqT/w4vPv8og67+Nq/o/R1c\r
+        ef4JGyPuCQ4SHQYDBAAIBAIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA\r
+        AAQNEBABHSIjACAkJQovLi7YwcDA/bS0tPpeXl7/CQkJZAAAAADA9f8CCR4txhxeif8cOEX7JTpD/zdz\r
+        kP8lhbX/NoCj/yRWbv8bZI7/Hl6D/yJPZP8kUWT/HEda/x9BT/89q+D/NXKN/yNZc/8bXYn/HmKQ/x9l\r
+        if8JGB//H1lz/hlVcPwldpz/AQAAZQEAAAAECgwHAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAA\r
+        AAH/AAEDERgdAAAAAAAKAAABAAAANwAAAKw1ODr/cnR1/F1fYf1OUVP9FRMT6wkAAEA+eaMAFCAnqyFk\r
+        j/8TO1L7H2OP/y1PZ/84eZb/K2V//yBliP8YUHX/Jnyx/xpTbv8ZUnD/JXyn/yVzmP8lQk7/KDY8/xxW\r
+        cv8wnNL/L5LH/yRxlf8XPVH/JlFv/iFadvonf6j+BQECgwYFBQAMFBoIAAAAAAAAAAAAAAAAAAAAAABs\r
+        ogACAAAAAAIDA/8CAgCBAAAAAAAAJBQRFGstTlnBBnOK/wCYtv8ArtX9AKLM/wCkz/8ArNX+CJa6/x5Y\r
+        aPwAJS6sBwICty1gff8VO1D8Fkdn/x1uof8xbIj/HSMm/yRbdf8rkMT/LZPF/xtbd/8ne6v/F0lz/yqH\r
+        t/8XPEz/M57V/zBui/8maIb/NKvi/x9cef8dX4f/GlmE/ytkhPsfYHz/CBslmhVIYQAMICoIAAAAAAAA\r
+        AAAAAAAAJNT/AABilAACAAECAgABAAQAABcADRSWPHWH9Fu00P8dxPT/BNT//RG8//wOvf//B9D//gHX\r
+        //4C0///BNb//SrU//5tzO//L5Kr/wNBU/8XIyr/KElb/yuOv/84eZb/J1Z0/yROZ/8lWXL/GlFq/xtL\r
+        Yf8qjb//K4zE/yd0mf8vb47/GViE/ymDtv81b4r/GUlg/yBEU/8rhrX/IXKh/jiVwvwbKzP/AgwRxxeB\r
+        tgEHGyUFAAAAAAAAAAADBgoAJ+b/AAA6VwEAAAAACAAAUwBBVuBbr8z/ddn//w66//sVnfn9JJD0/jps\r
+        9f4jkvT+EK/2/xan9/8Psvn+D7P4/wmm9f4luP38xOX//WnG7v8AUHb+HjVB/yFKXv8xVWX/HV2F/xZX\r
+        gv8yXnT/J1Jn/zNwkv8kTWD/LZjJ/yFRaP8udZn/GFmB/yZ5p/8nVWv/ID9O/y6BsP8qVmr/MZ/S/zZx\r
+        i/09eJP/GzZC8gAAABwJAgAAAAAAAAAAAAAAAAAABSAtAQE0TgAKAQE7AEty/2/P//+Bz//6B6D0/TCA\r
+        +P48cvn+O2z5/jtw+v87dvv/LIP1/ztt9/8lj/b/HJz4/i+J+P8XiPb+ZY32/vnv//9lyf/+AGeR/zI7\r
+        PP8bIyb/NG+N/zSUxP83aH3/KoCt/xZPev8sgbL/HThE/zJngP8yW2z/Mp3Q/zCf1P81Wmr/OYGo/xVW\r
+        g/8sdJ3/LWJ5/ytbcf0neqD/KmN/9QAAACIAAAAAAAAAAAYFBwAAAAAABBkqAQggKxIAS3DeUsb//s3M\r
+        +vsrefP/Lob8/ilE1v4ULbz/PXr//zRm8f8vXun/PnL9/zls9/82c/f/L4b6/0Bz//8uU9//ESq7/2+O\r
+        8v+Qo/D/IHPN/xc0Tf8nYYT/Ikpf/ypJVv8oPEX/LGuM/x5wov8tfaj/OWyD/ymFtP8vdJf/NV5u/zFl\r
+        fP89cIf/O7Lv/xdEX/8vk8b/KDtC/yxQX/0mdpz/KVFi6WJRShIAAAAAAAAAAAYFBgAyWHQCD0h0AAIH\r
+        Ioc6fOD/4ev/+3ma+f8uZ/r+RoD//xYuvf8AAJP/OXL5/yxV4P8DCZr/MWbv/z15//87cvv/MVzp/zdx\r
+        +P8sWOH/AACV/wAAiP8ANF3/AnSB/wUmOf8VHiv/GlyB/zBid/8yY3z/L2F5/y5xkP86epb/RYyw/xJG\r
+        bP8rgrb/Q5zE/x82Qf80a4f/O3mV/0G17P82cIn/LWOE/z9nffxNjan/JjtCwqHT5gBhf4oGAAAAAAYE\r
+        AwAvS0wAE1NlFwwsd++PrP/91dbz/Txx9P4lUd7/FCu5/wwYrf8AAJX/Bw6l/wkTqP8AAJH/Chaq/xUt\r
+        u/8vX+j/HT3J/wcPoP8KFqn/AACg/wIBZP8MPFr/Enyp/wEuQf9CW1T/NHaW/zxxiP8lYob/G2KQ/zFX\r
+        af8eJCX/MHGP/zOb0/80q+n/O4Cf/yRlif8XVn3/PG2J/ztvhP8zZoH/Ez1d/iJhh/stSFT+BgcHeAoa\r
+        IAAFBwcHAAAAAAkVLgIAAAAAAAAAOSNTuv/C1//9oKDd/gUNov4CBJr/AACQ/wAAlf8AAJr/AACZ/wAA\r
+        mP8AAJ7/AACb/wAAkv8FDKH/DRus/wAAkf8AAJT/AACY/wECp/8CAKL/CgiI/y1Ja/+V6uX/PVxf/zNd\r
+        cf8eZ47/EkBd/ztwiv8sao7/J1l2/zhofP9Jrtn/L1ls/yyHu/8cZpf/PrDp/yU4P/83cIr/MpzT/jqq\r
+        4/sgNj//AwMEZgMAAAAGBgUHAAAAAAAEJwIAAQgAAAEDQRIrof7I2f38l5rd/QAAmP8AAKP/AACd/wAA\r
+        oP8AAJf/AQGJ/wEBi/8AAIr/AACL/wAAlP8AAJr/AACb/wAAof8AAKX/AACc/wAAYf8XJk7/UIOF/p77\r
+        +P+g/Pj+OlhZ/iQ4Q/41gqb+QZ7K/jl0kf8iZpP/E0lr/0Cx6P80SlT/JT5K/zB/pP9Dwfb/OX6e/yta\r
+        ef87dZn+SY2r/Td3lPw1V2T8BAMDSgUFAwALDQ0FAAAAAAQCNAMFBCkACAcXVQAAhf6zuvP6rbLl/QAA\r
+        cv8EA1D+BwlD/xoBLf8aBDX/Dw1r/w0LZf8QDmT/FhBX/wcjO/8BFUP/CgRF/wgIV/8EA2L/CxJJ/2Og\r
+        lf+a+vD/q////3W3sf8iOUf+LDVB/jFTYPwhUW3/Ol5y/h45Rv4vmM//NpvR/0G79v82aYD/NZLD/zJw\r
+        lf8uTFj/Mltv/xdIav4hcKH/MU1a+kCJqv8aRVi+JFlxACtPXwEAAAAAAAAAAAICHgIBARMAAAAUPwIB\r
+        Q/52ebj72OD5/QcHdf0CAYT9BhV3/pgEAP9RDCj+FRqM/yYdkP8GB6f+GQmP/xRncv4CmIf+HQZS/xMW\r
+        h/4QB1r/OldT/6r///+V8/X/ME1J/gAARP8AAIT+Gxwm/zNpgP8ORG37NIrA/jJZaf8oVmv+LXKR/iVK\r
+        Wv83fZ7/E0Zn/x9vov85dpL/NkxT/zqs5f8zh7T9OGR1/kCMr/g/Ozk5Q0lLACAzOwIAAAAAAAAAAAAA\r
+        AAAHCAYAUlQJBxIPD+AeG3X/wMbw/0ZIvP8PCpr/JyBV/6EAAv4qE1P/CQuy/xUQwv8KCbL/DQiO/hYZ\r
+        T/8Atar/GSVS/xAJff8gF4T+LDdK/qL//v52wLn/AAA2/gEDYv8CBE37AAAATRs2Qb8weKH/Obbt/z+F\r
+        pfsvdJv+HGiU/zWJs/41bYX/Na3o/y+Wyv88d4//Royw/0N8nf5CfZz8L0tX+RYfI4xXVFsZRD9FAwAA\r
+        AAAAAAAAAAAAAAAAAAAMDAwCJCUQAAoLCHMKCQffS05etpedu9MICyrpQA8X+YoAAP4NFzH6FhB++xcT\r
+        c/ocF177GRlt/BwGR/sAfnr9D2Rt/x4LR/4gH17/DwcV/zRYVv9wppf+BQBc+wAAl/4AAxGxAAFhAGgA\r
+        ABEcGhyXK1hn6yRMXv8xmM7+F05y+jOj3/0nQ03/SYen/jyDs/4qLTL/M2dj/zlMKv1AbDf+IToL3gEH\r
+        AG4bXAARLGsAAAEDAgIBAAEAAAAAAAAAAAAAAAAAAAAEAQQDBAkDAwOmAAAArJWcspIoR0ueRwAA7nAA\r
+        AP8ABgDPRUEqxCkpGckAAADVAAIA2gAAANcAQkL5AHl4/gYAAMgECQCsCgwJrwAAAOgIS1X/AkVd+gIK\r
+        Nf8LAABoEQsKAB4YGwAHAAAAAAAAGggFBnwwcZD9OabY/z+y6P9BZoD+OVND/ydMGP8icQD/LJoC/y+u\r
+        Gv0pnBP+G24V1QoeA2gcPQZQDhIJJgEAAgABAAEDAAAAAAAAAAAAAAAABgYFAQsLCwANDQ0kAgICwiEi\r
+        K8EnMkLGPQAC/iEMDN0BAwWPS0pQixsbH5EAAAKWAgMGngMCA5sCCAjJAFBQ/wkND+IKCQvEAAAArAAA\r
+        AKIFISrbAZmv/wDH2vsDXnLyCAsKPQ8YGAAEIScFFRQQABEAAAADAAApAQMOcQ8SHakgSRD+LY8G/i6S\r
+        AP4zqQn/MZEN/zCZGv8ylxv/M4kO/yNSAf8WLQD/Dh0BpgAAATEBAAACAAAAAAAAAAAAAAAACAcIAAkJ\r
+        BAEDAwQAAwMCFwIBAMARAADKmAAA/xQMC5IAAABJ4uHgXGpqaVwAAABcAgMDXgADA1MQAQGBA5qa+wBD\r
+        Q9AKAQGyQWpq/yI4OOAFAADIAiAo7QDX//sAwO3/AyUsgAQ1QAAFUmQDFw4HAQ8AAAUOIggsHjEAgCZ6\r
+        Ddkwux/9MnwE/TGREP4wnhT/MJoP/zFjAP4udQD8I1AA/REVBKgWHQc0GicKIgAAAAYAAAAAAAAAAAwT\r
+        GgAHDxYABQUGAQkIEAUFAQAFDAoGKwUQOtQFGGL+GxNB/w8UErkMDAqFbm9wfGJiYmwEBARrCgoKawgL\r
+        DGkOAABrDmxs9gB5efUfGxvrsP///2qqqv0AAACRAyEoqgDN+/wDl7j/CRYWUgsWGAADHSQEAAAAAAAA\r
+        AF0DBgD4JW4U/ymvJv8tfQf/LmoA/zGvIf4weQT/MMIp/zGWE/8rWwD+GEYA/REzA/UAAAKjAQAGWggG\r
+        BjUKCAcAAAAAAA0VHQAIDxcAAAAAAAMPPAAEDTYAAgYbkQArw/8AOe75ADnr/gEWYv8GBgWfCgwQfBMU\r
+        FJwdHh+tJSYnrh4oKbAcHyCpDjc31ACdnv0BAAC+QE9O/CxJS/8AOETLAaC+/wGlx/8MLTWeF3d3ARNM\r
+        XAIAAAAAAAAAAAAAABURLAFbDjUIXAkQAKkYMwDyK2IA/DG2Jv4vfgn/MI8N/jDXN/4tiA7+LmEA/CRF\r
+        A/wIDwHVBAMBngkOAj8JBwYAAAAAAAwTGgAECQ0AAAAAHwsTKGsJDyJbDQwQmwold/0AHpD7ACCv/QAa\r
+        df0HAwQ1BwEAAAAAAAcAAAAHAAAACAgIBwsICgoHBQYFUQGVk/8ASkh3AG1pPwA2OaUBbYDfAWZ6yAEB\r
+        A2YAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAANGwAAER8AKxEkAG0XRwWpL20A/jGmHvwwhxH/MHEA/zGX\r
+        F/8txy3+JHoG/xxNAf0IGAKPAAADNgQACAQCAQEAAAAAARopNwASIjACIC05yVZ0kP9KZHz/UWyH/1t4\r
+        jf9adYr8PlVu/w8VHeMAAAAaAAAAACEaEwAAAAEABgwOAAwBAAAKAAAABwAADAJwc+0BXGXeA5moFQB4\r
+        hi8AAAACAAAAAAADAAAAAwIADQAAAA0AAAAAAAAACwgIAAAAAAAZPgIICRUDFAAABSAkdALsM30A/S+I\r
+        E/4wdwr+MYMA/jJuAP0ldA39DjgS1xExAuAHHADrCQUHvQgCC30HBQUtBAMDBQAAAAAAAAAhKjlG+Vt4\r
+        kfpDWG36KzxM/VNyj/89U2r+RmB3/jZKW/lJY3vgKTZEuRIQECoUFhgACg8RAyAAIAABAAMIABcASAYR\r
+        CeEBQgn/BSwA5ABEAP0BLAPEAhIGnwIAAh8DAAINEwAMACQCGAAAAAAAIRkXABgdDQJHcxIADAAQDhc1\r
+        BtYwmwD/LF0A/yZvBfwybwH+KnoA/y10AP4rVQD/CA0CpSx5AQ4teAAdBwAGPwQFADwAAAAPAwEBAzRH\r
+        VwA7XWAXM0VT567W9P+2xdf4XnCA/sjd7/652vv+epWr/h8oL/89Umf/YoWn/xciLI8uQ1UAJTc/BgcA\r
+        BAUDDAKDAWAA/wDJAP4AgwD+AMsD/wCQAv8AhwD/AJQA/gE6AfcEKgNpBjIEAAgiBQMAAAAAHhYVACxr\r
+        CwAAABIrFDgF0SN2AP8SPQDQCRQAuiFtAPMpWQD+GlAA/BxVAO8qVQDzIVIA/wYaAmUOMQMACBgDAAYF\r
+        AgAAAAAABQMCACg2QQIlODsACBIbTxoqM/RYcH7/dnR0/2daV/61ur//g4GB/6CnsvyApMT7Hys2/wkM\r
+        D1gLDRIADxoRAQ4ACQkFMgPgAJMA+gCrAPgAlgD8AKMA/QBeAf0AkwP/AIAD/wZxBOQDEgJRARAAAAAN\r
+        AAISDQ0BCQIJAAMACFkMGgTYHWQA4QgeAXwAAAAjDzUAmBlRAv8PHgCuEjsAxxRLAM8PEgBcLmkA/xAt\r
+        APoABQI7Ag0DAAQDAwMAAAAAAwAAAGiNrAAAAAABCxMbACIAAC1UIiyVSyco8YAAAP5MWmT7V2Bv/4ii\r
+        wP91mrf+ISs0yAAAABURIBcBAgIAAAkABlMEVAP8AIIA/wBWA/8AUAP/ADYA/QAMAP8BCgDnAAAAeRlj\r
+        EgwJPgYABgAEAAAwAABXQj8AAAAAAAAOABYAAAAUAQADBQUEAwAJFAISDzUB9wAOAIIGCwA8CRoBchA1\r
+        Af4AAAAYChgAYBEiAdUBAAKvAgAEMwUEAwACAQEDAAAAAENabQAAAAAAAwAAAlIIBQBvAAAlKQAA508B\r
+        AO0AAAAxAAAAMgAAAEIAAAAyAAAAAgQFBgAWIhkBCQAGAAAEADcAGwBzATwBjQkBAK0CAADIATA0/wQ3\r
+        Or0VmJwUBLCzAAAAAAAQVwoBBAQCAAAYAAAyJiQAAQABAAAAAAADAwIAEBIKAAwNBwAKCgWKBAQDqDkq\r
+        JwMACgARETQGIwokAf8FBwNlAgMCAAAAAFQAAgA2AAMACQAAAAAKBwcAAAAAAAAAAAABAAAAAgICAAAC\r
+        ACAcA23yYBTX/zcMmPsNBxFLFgkmABwKMwAAAAAAAAAAAAAAAAAVIxkACgAHAAEEAQAAKwAAAdMBABHn\r
+        8gAJ19YFA3Jy5wGhodMA+/kAAtXUAgAdAAAOUAkAAwQCAAAAAAAAAAAAAAAAAAAAAAATDw0CEAwLAAoH\r
+        ByUHBQWnVUU8BRANCwABDwACEEkDAAQNAcsCBgGhAwsBAgECAAIAAAA7AAAACQAAAAAAAAAAAAAAAAAA\r
+        AAAPCRECCgAWAAMAAFVfDdn/rH7/+IhI//8cAEmtRAC1AkgIpwYDAwMCAAAAAAAAAAAKCwcADQMJAAcF\r
+        BQEBCgEDAP8AAwZbWQUGeXgACCwrggF+f/8CAAA6AwAAAAQFBAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAABAAAAAAAAADwAAAAbBQQDAAAAAAEKCQcCBAAEAAYEBGIEBAPJAwICAAAAAAAAAAAKAAAAFAAA\r
+        AAAAAAAAAAAAAAAAAAAJBQoBBwQPAAQCByc7B43pfDbo/E8bp/kFAhJiDwM2ABwFQAIAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAEGAAAABAAAGwQaGdkEFBNWBRwcAAUNDQIAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAABAQEAAAAAAAAAAAAAAAAADAoJAAAAAAAeGBQABgcEAAYFBAcGBQSpAQAAIgEB\r
+        AQAEAwMAAAAAAAAAAAAAAAAAAAAAAAAAAAAOCA8AGwszABcHLQABAQJ8HQBT4gAABbUAHAAAAH4AAAA4\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAANAAAAFQwJAAoAABgBAAAMAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAdFhMACQcGAwgG\r
+        BQAFBANhBgUEUQgGBQAKCAYDAAAAAQAAAAAAAAAA////////AAD///////8AAP/+P////wAA/8AD4AP/\r
+        AAD/gAAAAP8AAP8AAAAAfwAA/4AAAAA/AAD/wAAAAD8AAP/wBgAAPwAA//wcAAA/AAD//jwAAB8AAP/+\r
+        PAAAHwAA//44AAAPAAD//jgAAA8AAP/+OAAABwAA//44AAAHAAD//DgAAAcAAP/8GAAAAwAA//gYAAAD\r
+        AAD/wAAAAAMAAP8AAAAAAwAA/AAAAAADAAD8AAAAAAMAAPgAAAAAAwAA8AAAAAADAADwAAAAAAMAAPAA\r
+        AAAAAwAA8AAAAAAHAADgAAAAAAcAAPAAAAAADwAA8AAAEAAPAADwAAAYAA8AAPgAAB4ABwAA/AAAH4AD\r
+        AAD+EAAPgA8AAP4AAA4AAwAA/AAAHwADAADwH8Q/wAcAAOAf5//gAQAA4Afgf8AfAADgA4AfgA8AAPAD\r
+        gB4QDwAA+AcAf/JHAAD8/4H/5y8AAPj/+f/vPwAA8H/5//8/AAD4f/z//78AAPj/////nwAAKAAAACAA\r
+        AABAAAAAAQAgAAAAAACAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAQEBAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABlDWggSKjYNDyIsDQsc\r
+        JAwoQlEJFB4jAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD\r
+        AgAMDQAGDA0OEQAAABoAAAAmAAAAMAAAADYAAAA1AAAALwsLCycYGRkfDAwMGwAAABkEDBAbAAAAHAAA\r
+        ACgAAAA0AAAAOAAAADMAAAAqAAYKHwABAhIAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAACCwkGEgEAACkAAABDCAYFeR0cHJ0bGxy1FxcXtxcXF7MMCwqhAAAAggAAAGEAAABCAAAANwAA\r
+        AEgMICqQDyAotxMrN84QHybQEBkeuAcFA5IBAABsAQAARwEAAC0AAAASAAAAAgAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAsHBgYkAAAASTk4ONV6eXn/lpaW/4uMjP9mZmb/ZmZm/2NjYv9iYmL4gICA60tL\r
+        S8gBAgSFFy453x1bgv8iT2n/H1Bp/x9GXP8iWHn/GkBW/w4nOPEBAwacAAAAWwAAADwAAAAaAAAAAwAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAABgICAhsAAAAzIiAftFJRUf9oaGj/lpaW/7i4uP16enr9c3Nz/42N\r
+        jv+AgYH/ODEt7g8lMOAlaIv/IEVZ+ipWbfwdSWP9IEpl/RtMZ/0bQFT8LWyO/x0/TvcDBQauAAABUAAA\r
+        AC8GFBoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwEBAA4AAAAaDQsJXS8tLKI7OjrixcXF/pKT\r
+        k/5TUlLzWlpbu0dISI0OHyqxIk1o+hw9TfwfXYT+LEtc/x9HYP4laZD+LGeE/yNSbf8pY4L9KVBk/hIw\r
+        Qf8DBASNBQoNLAUAABQGDBABAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAgIBAAAAAAAAAAAAAAAAAAAA\r
+        AD+EhIP7iYmJ/w0NDHAGAAAAAAAACyRXdPAfUnL/IFNw/SVhgf8rZIP+JVBn/ypde/8oTF7+JlNq/y6A\r
+        qv8tYHv7JHil/hlBU8mk//8MCjZOCFSt1wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAF7e3sBjY2NB2pqauB2dnb7AAAAHAALEwEVJS1NHDpI/xlPbfweX4v+KEpd/iZdev8yYXX/ImuZ/yp7\r
+        pP8eRmH+IVRy/iZNYf4ydpn8I1Rq+RkqMXQzU1cAJkxeAj5vggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAO3t7QH09PQAaGhouGVlZeLd3d0DGoW6AClOYbYYQlj+GVd4+y9+pf8qYH3/G2OS/yZK\r
+        Wf8zY3j/N2+J/yRsk/8icZj/Il2A/x5Laf4fSFn+LnOS/yYyMTAmNz8AHSwyAwAAAAAAAAAAAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAAAAAA3NzcAuTk5ABlZWa0Xl5f1gAAAAA8j74AGSkwxRtUd/4aUXL8Kk9d/i14\r
+        nP8ui73/MmuI/yNpk/8qUWT/IlJo/yFlg/8lZob+M4u1/x5UdfofUnL9ERcXZw8UFAAWIycIAAAAAAAA\r
+        AAAAAAAAAAAAAAAAAAAQDAsAEgAAAP///wKFhoYEmJucB2dqauZsb2/mS05PCwAJFQMXHyKVJ1dw/yVc\r
+        evsgW4D/MW2K/y9LVP8xfqT/HGyg/zFwj/8kWn7/HlBu/xpIXf8eTWL+JHWh+yd/sP4IFx2iP3WMAA4s\r
+        OwgAAAAAAAAAAAAAAAABKDQAAAAAAA4JBwIAAAACSk1MABoWFgAGAABrpp2b/3xycfwAAAA8M36tABk/\r
+        V8EfQFP/K09f/CV3pP8veJz/GEFZ/yJkhv8rb5D/JU5g/zCAq/8rZYP/H2WP/xtbgf8aTWT9I26P/xdL\r
+        ZPI3PUAcBA0SAAAAAAAAAAAAAAAAAAEUGgAAvPsCGRISAAAAAABOODYfL0NFch9RWfBRgI38O2t2/hk0\r
+        O85JhZw1FjNIwR1TdP8dUXP8NG2L/yZVaf8hcqH/I3Kd/xlPa/8gbJb/JlZr/ylXa/8qg7D/LY6+/xhC\r
+        W/4hUW/+IWqM/wAAADoAAAAAAAAAAAAAAAAAPlsAAQ4TAQAQFAAAAAA8MFNfsimZs/MAr93/Bbz7/wDH\r
+        +v4A0P7+C8Px/zydt/8hZXfwCyw6/yJXeP4wfaT/Ij1O/yZoif8gXnr/JXag/yeAtP8kZIX/JnSj/y5x\r
+        kf8hW3T/I2uS/yuBs/wfQ1P+AgYJXAAAAAAMEyYAAAAAAAA2SAEAPEgAACg5hUWZuP9Oy///Hqv//y+E\r
+        /fwygvv+HKD3/xqm+v8Pr/z9JrH//6je//9CkrL/FENW/y5KVv8ka5f/LGWB/yhbd/8nZoj/J2uJ/y1i\r
+        fP8if7P/LGF7/yRVcf8qcJX+MoOn+zBmf/8XM0CSGjpJAAsSJQAZbI0DBl+EAAAtSl9PodT/grz//B1/\r
+        +PspQtP+PW77/zVn8f49cPv+NnT3/jSK/v8nY+/+T2LZ/pG7/v8WXJP+IDhH/ypeeP8xW2z/JGyT/yl4\r
+        pf8vZX//L2+P/zR3lP89e5f/K4Cw/yVsk/8uTlv7K3KT/yVKWowtVmgACw8aAlOIjgAPZW4TMl2q6rvV\r
+        //1Hd/r8Llnm/wMHm/4kStb/Dh2v/yNI0v84cPb/LVjj/yRF0f8AAJH/BS9s/wdieP8RJDT/KmSB/y9e\r
+        df8pZIP/NGN1/zB3nv8qjMT/NHCL/yZSa/9AjbH/M3WV/ihRbv07aX3+GCImUxIZGgAUKlkJAAAoAAAA\r
+        IE94l+P/naLn/AgctP8CBKH+AAGh/wAAmf8AAJz/AACc/wsZtP8KFrD/AACX/wAAnP8AAIH+Cih2/2uq\r
+        p/5Fcn3+IWGG/yVihP4rT2L/K2WE/0GXv/8saor/I4G4/zdxjv4yYHf+LpDD/yJBUP4AAAAoAAAAAAUO\r
+        egoBBFAAAANBYXOD2f2Lj9f6AAB4/gACe/4AAHn+BQR6/wYFeP8GBnT/AABw/wAAfP8BAY3/AwV2/zhW\r
+        f/+GztH/hNHL/jFDSP4tZYD9OnSP/yVslf4vkMP+OnKK/y1hfP87krb/K2B+/y5nifxChqL/Lltv4Ud7\r
+        hxFAk6QEAwFFCgAAKAAAAB5cQkKR/6iv4v4AAHf/Jw9L/2EGCf4VGID9Ew6V/RQWcv0Ib2L+FRRc/ggA\r
+        Wf1TgYT9q////kVxfP8CA1L/Hi44/iNihf8ya4z6K2N+/DGBpf4zdJL+IHCf/zNieP80cY7+LH2t+zlr\r
+        g/4pV25kVpy5ADlpfQcJCAADAQAAAAcIBRsTEC3ri47B7CcxnftKCy/9Ywsc/wkRp/8WEqj/Fwd7/wt3\r
+        f/4UQXL/GAVq/0Jgbv99x779AABM/gAAWN8/SHBHJ1dy2DKIsf8ucJX/InCd/jRzj/83ltD+N2yQ/kJy\r
+        i/1CbXL+HzAuxxMfEgxia2sAKCIeAg0LAwAHBwgCBwgLAAAAAGgjISC9U3F5p0gAAPMxBgfuHyo3zxIR\r
+        GN0KBBTgAjA38wVQT/kRBhTIAAAAxxVBQvgHPHj/BQIlpBUTZwAVOkcQPzw8YSRffN4ymdD7OGaF/Dhc\r
+        RP8lYQ/+Lo4W/S+PFv4VRgawBwwAYwAPABgAAAAACgkPAAcGBgADAQACBAMABwMEA3sdFRDHVgEA8wwH\r
+        Botna2xsCgwNeQAAAHYDEhCaAVdX9wcHBcATISHAAg4TzQCInvkBoL/0AAwCPQg1RQBLamcACQAAGRgy\r
+        GYondBryLooA/jCkCf4wjgr+MIoP/iZdBvQhTwCwFzQFRGqJAAAAAAAAAAAAAAQSRwAHDy8ABgwZOgYR\r
+        TPAwFD72BQYCjYN5YXgoIhJ4EgAAdRgAAH0FeHjyEjo75H28vf8fFQ6/AGyH1wOy3P8HKS05ADpMAExK\r
+        QBMJDgSqI3cS9CyND/8whAz+MJgW/zGnGv4rYgD9GDgA8RAtBIUHGAZBBgIGAwAAAAAAAAAAAB2KAwAf\r
+        jRYCD0SbACvE/wApx/8BDTezBhxnQwwaTGkOYGFuDmRlZwZlZcYAZ2XMJ05NrwpJVeAAiKTqBmp0eQaI\r
+        mQABcnkBABMAAwIQAC4HIQRjFScAyS6KEP0xjxH9MJ4X/i6vIP0nXQD/BhEAyjAsA00LGAUAi4+UBI+V\r
+        nQAnND+hO1Jj8TtQZu09V3j8JTtm/goRI30ABCwABAwqAAdaWwAEYGIABDpDTQFdaeMAPEo3AA8nTwAA\r
+        ABgIV18ABEWBAAaKZAAQGAYATWADAIGZAgwkaQHAMoMG/zCCDfozeQD+J3sR+RE/CcsWIhG8OjMFcwge\r
+        Ay7X4uoAi56jB0ZZa+iDnLf/XXOF/4qrwvxUaXr6MUJR9UVbatEAAAAcLDJABBYACCQFRACvAWQB/wF3\r
+        AP0AYwDmAkAAsBAHBEwEHwAACC4JAhtEBwAiTAgJHDwHoyJpAP8iVgDnLGwB/yVqAPsoUwD/DRwChERu\r
+        IAIYTwEkKGoMDUxbaAYtQVAAESw6ZlRzgvh3bHL9o52k/4+eqv99la//MURW/SsuLRcAQQAAAy0CmwCR\r
+        AP8ArQH9AIsA/gB0AP8AcgD/ATIAdgNjAwAHQwMDFkUEDg4lBZMXUQC6AxQASBJDAM4SMgDHET4A0RxB\r
+        AZcdQQD/DSIAUxIrAQAGCgMAvdz2AAAAAAFkAAAAewAALEMAAOVFBwDFSDU7o0xgbq0aIylWUENTAAUR\r
+        BQkDOAKkAlQA3AEWAPIAIg7+AhMNnQQLDCQDBgYAAwADABr8BQBq/xUDCRUCDgoUBAAKFgRDChwCq0Z6\r
+        ERQNKgG2BxgBXxdABFIAAAKIAAACCgUFAwOUrcEAQAmRAmAEjgE+AlJ6Vxuw+zEMY5xnFIcASwCEACw7\r
+        RwAAAAAAAP//ABT2DQAKSVkGCYaPIAJ0d+0DeXo/A4iIAAN0dQMEAAMAGv8IAAMIAABIRkgAAwACDAcE\r
+        BXcBAAESDBwEAAUOAlsECwGjETkGAAACACEAAgAEAAAAAQAAAABzE+QCiQ/0ADYGk7GISv//Sh2XyspG\r
+        +wWqLu0EJzM9AwAAAAAAAAAAAAAAAAB2dQECgYAABD8+kQJDQ5YCXFwCAm9vAwIgAgAAAAAAAAAAAA4R\r
+        DwAAAAAKAAAADgAAAAADAAMBBQMEDwUDBI4AAAAKAAAABgUEAwQAAAEAAAAAABABMwMNATkAEwImSyoA\r
+        besJABliNglYAC0JUgMAAAAAAAAAAAAAAAAAAAAAAAAAAwkAAAQDAAAXBwAAQAoAAAAaAAABAAAAAAAA\r
+        AAAAAAAAFxgZAAAAAAAAAAAAAAAAAwoJBgEGBQMABQQDVAYKAyQFBAMADwwKAAAAAAD///////////4B\r
+        wH/8AAAf/AAAD/4AAA//xgAP/84AB//MAAf/zAAD/8wAA/+MAAP/BAAD/AAAAfAAAAHgAAAB4AAAAeAA\r
+        AAPAAAADwAAAA+AAIAfgADAD8AA8A/gAOAPwgDwDwPv+AcBwfAfAYDkD8GD/Q+P9/s/j/P/v8///7ygA\r
+        AAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoJuXACEgIQBvbm4AAAAAAP//\r
+        /wMAAAAAyMPAABAuPwDY//8A////CQAAAAAAAAAAAAAAAKoKCgARKDMAAAAAAIJ9eAAuMTUWNzY1c1pa\r
+        Wqo5OTmzNzc3oDw5N28GEhlZFTVIqRYxQL8PIy+lAQIEXgAAABeOCwwCBB8uAAAAAABqaGcAGBgYFCoq\r
+        KZ9mZWX8kZGR/25vb/9RUlPfFjtP8CRUbv8hT2r/IVJt/xw/UfIDCg5vbQ0PDQkcJgAAAAAAAAAAABIS\r
+        EwBISUoAOTg4H3p6e+xXRTpCETdMfB9UdP8nV3L4KV56/CdgfvgpYoH/HUpgynTAwQk4dZICAwwQAAAA\r
+        AAAjIyQAtra4Bevu7wBbYGGpTSscEhhBWMMhXHv+K2uO/C1lgv4mYoD/I2GB+iZffP8hSl1gL2J9ABBS\r
+        aAA4bHQAKygpACwpKQBkV1MIdWZj2DwOBBkaPVO/J19+/ytohvwmaIz/KGB9/iFdfPsgY4b+GU5qryqJ\r
+        tQAWYnsBO3B1AC1CQwEnZWhWDmqEvCSdtP8cdIG2Hkxf3iddev8lYoL9IGaL/yZnif4ob5T9IWSI/h9W\r
+        ct5+vckEQXiGA1R/iAdDia+zPJj0/y2B//8imv/9K6T//12T1f8bS2T+KVp1/ipsjv8rcZT+Lm+P/itu\r
+        kf8tYnvuAAAAIG2MwgBAWpZgb43n/wwiwPgJD6X7Gya+/hYixvsACY79M2yB/zRofP8pYYD8M3yh/zB1\r
+        lvwyc5P+LFtz30jA2gR0gMUAQEaKf1Vauf8YAE/9FgZ9/wYeev8FC2n/Tnim/091kvoqTWf/LnKY/zB4\r
+        n/8xcZ/7NW+W/zBfd41EhKMACQIAAA0EADA8P1nFTBMb6iQSV9sKL1HoDS5C6zFMVeoBIF7WFFpuSydw\r
+        hrswdpD2M3ZR/TJ2NfgTJxNYSm8RAwAIPQgJFFcAAAMtbxwPN9shIQBkBxAChQ9SUNknQUjcAISf6A+o\r
+        0QYeRhc1JGgM3TGbBPorgwf9EykAs0JpBxM7bbwCIUiUdDNUkeIcOn7oRE1QOwxjSxsFVk2ZDE48qgpl\r
+        aVUZfEQDX5EmDyBaAq8xhwz/KXsL+w4nA5onaQkwiHt1AF5fWYBybWrzcH2E+kFTaoAFKQofAW0A+gBm\r
+        APQDPQJ5CE0AABJBAjQUPwGYF0MAxhpAAMgPIAFWFzkDCE0AUABQFFYRSQ1t0SsXOz8eEDYKAj4rFgRD\r
+        MFwCR0mXBU9PBAJJSwIGBQMCBQUEJQQHAyUFDwJcBAYCIxM9BAEtDpYAHAByLFEls+ERAC4EEgIuAAkf\r
+        IwAGUV0ABDQzSwkyMgQBNTQAFCIPAAYCBQUGBAQABAAEOwUEBAAAAAEB//8AAOAHAADgAwAA+gMAAPoB\r
+        AAD6AQAA4AEAAMABAACAAQAAgAEAAMBBAADAYQAAjGEAAIRhAADc+wAA3/8AAA==\r
+</value>\r
+  </data>\r
+</root>
\ No newline at end of file
index b3bf743..e3d7259 100644 (file)
@@ -51,12 +51,14 @@ namespace Handbrake
             this.label3 = new System.Windows.Forms.Label();\r
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();\r
             this.btn_encode = new System.Windows.Forms.ToolStripButton();\r
-            this.btn_stop = new System.Windows.Forms.ToolStripButton();\r
+            this.btn_pause = new System.Windows.Forms.ToolStripButton();\r
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();\r
             this.drop_button_queue = new System.Windows.Forms.ToolStripDropDownButton();\r
             this.mnu_batch = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_import = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_export = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.mnu_readd = new System.Windows.Forms.ToolStripMenuItem();\r
             this.SaveFile = new System.Windows.Forms.SaveFileDialog();\r
             this.list_queue = new System.Windows.Forms.ListView();\r
             this.Title = new System.Windows.Forms.ColumnHeader();\r
@@ -65,25 +67,39 @@ namespace Handbrake
             this.Destination = new System.Windows.Forms.ColumnHeader();\r
             this.EncoderVideo = new System.Windows.Forms.ColumnHeader();\r
             this.Audio = new System.Windows.Forms.ColumnHeader();\r
+            this.mnu_queue = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+            this.mnu_up = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.mnu_Down = new System.Windows.Forms.ToolStripMenuItem();\r
+            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();\r
+            this.mnu_delete = new System.Windows.Forms.ToolStripMenuItem();\r
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();\r
-            this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.progressBar = new System.Windows.Forms.ToolStripProgressBar();\r
-            this.lbl_progressValue = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.OpenFile = new System.Windows.Forms.OpenFileDialog();\r
             this.lbl_encodesPending = new System.Windows.Forms.ToolStripStatusLabel();\r
+            this.OpenFile = new System.Windows.Forms.OpenFileDialog();\r
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();\r
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
+            this.panel3 = new System.Windows.Forms.Panel();\r
+            this.panel2 = new System.Windows.Forms.Panel();\r
+            this.panel1 = new System.Windows.Forms.Panel();\r
             this.toolStrip1.SuspendLayout();\r
+            this.mnu_queue.SuspendLayout();\r
             this.statusStrip1.SuspendLayout();\r
+            this.splitContainer1.Panel1.SuspendLayout();\r
+            this.splitContainer1.Panel2.SuspendLayout();\r
+            this.splitContainer1.SuspendLayout();\r
+            this.tableLayoutPanel1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // btn_down\r
             // \r
+            this.btn_down.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btn_down.BackColor = System.Drawing.SystemColors.ControlLight;\r
             this.btn_down.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_down.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_down.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_down.Location = new System.Drawing.Point(613, 110);\r
+            this.btn_down.Location = new System.Drawing.Point(625, 52);\r
             this.btn_down.Name = "btn_down";\r
-            this.btn_down.Size = new System.Drawing.Size(75, 22);\r
+            this.tableLayoutPanel1.SetRowSpan(this.btn_down, 2);\r
+            this.btn_down.Size = new System.Drawing.Size(64, 22);\r
             this.btn_down.TabIndex = 33;\r
             this.btn_down.TabStop = false;\r
             this.btn_down.Text = "Down";\r
@@ -93,13 +109,15 @@ namespace Handbrake
             // \r
             // btn_up\r
             // \r
+            this.btn_up.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btn_up.BackColor = System.Drawing.SystemColors.ControlLight;\r
             this.btn_up.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_up.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_up.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_up.Location = new System.Drawing.Point(543, 110);\r
+            this.btn_up.Location = new System.Drawing.Point(564, 52);\r
             this.btn_up.Name = "btn_up";\r
-            this.btn_up.Size = new System.Drawing.Size(64, 22);\r
+            this.tableLayoutPanel1.SetRowSpan(this.btn_up, 2);\r
+            this.btn_up.Size = new System.Drawing.Size(55, 22);\r
             this.btn_up.TabIndex = 32;\r
             this.btn_up.TabStop = false;\r
             this.btn_up.Text = "Up";\r
@@ -109,13 +127,15 @@ namespace Handbrake
             // \r
             // btn_delete\r
             // \r
+            this.btn_delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btn_delete.BackColor = System.Drawing.SystemColors.ControlLight;\r
             this.btn_delete.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_delete.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_delete.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_delete.Location = new System.Drawing.Point(695, 110);\r
+            this.btn_delete.Location = new System.Drawing.Point(695, 52);\r
             this.btn_delete.Name = "btn_delete";\r
-            this.btn_delete.Size = new System.Drawing.Size(75, 22);\r
+            this.tableLayoutPanel1.SetRowSpan(this.btn_delete, 2);\r
+            this.btn_delete.Size = new System.Drawing.Size(64, 22);\r
             this.btn_delete.TabIndex = 31;\r
             this.btn_delete.TabStop = false;\r
             this.btn_delete.Text = "Delete";\r
@@ -127,18 +147,19 @@ namespace Handbrake
             // \r
             this.label4.AutoSize = true;\r
             this.label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label4.Location = new System.Drawing.Point(225, 98);\r
+            this.label4.Location = new System.Drawing.Point(125, 49);\r
             this.label4.Name = "label4";\r
-            this.label4.Size = new System.Drawing.Size(47, 26);\r
+            this.tableLayoutPanel1.SetRowSpan(this.label4, 2);\r
+            this.label4.Size = new System.Drawing.Size(48, 26);\r
             this.label4.TabIndex = 70;\r
-            this.label4.Text = "Video:\r\nAudo:";\r
+            this.label4.Text = "Video:\r\nAudio:";\r
             // \r
             // lbl_chapt\r
             // \r
             this.lbl_chapt.AutoSize = true;\r
-            this.lbl_chapt.Location = new System.Drawing.Point(158, 110);\r
+            this.lbl_chapt.Location = new System.Drawing.Point(108, 62);\r
             this.lbl_chapt.Name = "lbl_chapt";\r
-            this.lbl_chapt.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_chapt.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_chapt.TabIndex = 69;\r
             this.lbl_chapt.Text = "-";\r
             // \r
@@ -146,36 +167,37 @@ namespace Handbrake
             // \r
             this.lbl_title.AccessibleRole = System.Windows.Forms.AccessibleRole.None;\r
             this.lbl_title.AutoSize = true;\r
-            this.lbl_title.Location = new System.Drawing.Point(158, 97);\r
+            this.lbl_title.Location = new System.Drawing.Point(108, 49);\r
             this.lbl_title.Name = "lbl_title";\r
-            this.lbl_title.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_title.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_title.TabIndex = 68;\r
             this.lbl_title.Text = "-";\r
             // \r
             // lbl_aEnc\r
             // \r
             this.lbl_aEnc.AutoSize = true;\r
-            this.lbl_aEnc.Location = new System.Drawing.Point(286, 111);\r
+            this.lbl_aEnc.Location = new System.Drawing.Point(179, 62);\r
             this.lbl_aEnc.Name = "lbl_aEnc";\r
-            this.lbl_aEnc.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_aEnc.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_aEnc.TabIndex = 67;\r
             this.lbl_aEnc.Text = "-";\r
             // \r
             // lbl_vEnc\r
             // \r
             this.lbl_vEnc.AutoSize = true;\r
-            this.lbl_vEnc.Location = new System.Drawing.Point(286, 98);\r
+            this.lbl_vEnc.Location = new System.Drawing.Point(179, 49);\r
             this.lbl_vEnc.Name = "lbl_vEnc";\r
-            this.lbl_vEnc.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_vEnc.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_vEnc.TabIndex = 66;\r
             this.lbl_vEnc.Text = "-";\r
             // \r
             // lbl_dest\r
             // \r
             this.lbl_dest.AutoSize = true;\r
-            this.lbl_dest.Location = new System.Drawing.Point(158, 85);\r
+            this.tableLayoutPanel1.SetColumnSpan(this.lbl_dest, 6);\r
+            this.lbl_dest.Location = new System.Drawing.Point(108, 36);\r
             this.lbl_dest.Name = "lbl_dest";\r
-            this.lbl_dest.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_dest.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_dest.TabIndex = 65;\r
             this.lbl_dest.Text = "-";\r
             this.lbl_dest.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;\r
@@ -183,9 +205,10 @@ namespace Handbrake
             // lbl_source\r
             // \r
             this.lbl_source.AutoSize = true;\r
-            this.lbl_source.Location = new System.Drawing.Point(158, 72);\r
+            this.tableLayoutPanel1.SetColumnSpan(this.lbl_source, 6);\r
+            this.lbl_source.Location = new System.Drawing.Point(108, 23);\r
             this.lbl_source.Name = "lbl_source";\r
-            this.lbl_source.Size = new System.Drawing.Size(12, 13);\r
+            this.lbl_source.Size = new System.Drawing.Size(11, 13);\r
             this.lbl_source.TabIndex = 64;\r
             this.lbl_source.Text = "-";\r
             // \r
@@ -193,8 +216,9 @@ namespace Handbrake
             // \r
             this.label1.AutoSize = true;\r
             this.label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label1.Location = new System.Drawing.Point(12, 72);\r
+            this.label1.Location = new System.Drawing.Point(3, 23);\r
             this.label1.Name = "label1";\r
+            this.tableLayoutPanel1.SetRowSpan(this.label1, 4);\r
             this.label1.Size = new System.Drawing.Size(99, 52);\r
             this.label1.TabIndex = 63;\r
             this.label1.Text = "Source:\r\nDestination:\r\nDVD Title:\r\nDVD Chapters:";\r
@@ -203,7 +227,7 @@ namespace Handbrake
             // \r
             this.label3.AutoSize = true;\r
             this.label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label3.Location = new System.Drawing.Point(12, 50);\r
+            this.label3.Location = new System.Drawing.Point(3, 0);\r
             this.label3.Name = "label3";\r
             this.label3.Size = new System.Drawing.Size(82, 13);\r
             this.label3.TabIndex = 62;\r
@@ -214,13 +238,13 @@ namespace Handbrake
             this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;\r
             this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.btn_encode,\r
-            this.btn_stop,\r
+            this.btn_pause,\r
             this.toolStripSeparator1,\r
             this.drop_button_queue});\r
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);\r
             this.toolStrip1.Name = "toolStrip1";\r
-            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;\r
-            this.toolStrip1.Size = new System.Drawing.Size(779, 39);\r
+            this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
+            this.toolStrip1.Size = new System.Drawing.Size(787, 39);\r
             this.toolStrip1.TabIndex = 71;\r
             this.toolStrip1.Text = "toolStrip1";\r
             // \r
@@ -230,21 +254,21 @@ namespace Handbrake
             this.btn_encode.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_encode.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_encode.Name = "btn_encode";\r
-            this.btn_encode.Size = new System.Drawing.Size(84, 36);\r
+            this.btn_encode.Size = new System.Drawing.Size(82, 36);\r
             this.btn_encode.Text = "Encode";\r
             this.btn_encode.Click += new System.EventHandler(this.btn_encode_Click);\r
             // \r
-            // btn_stop\r
+            // btn_pause\r
             // \r
-            this.btn_stop.Image = global::Handbrake.Properties.Resources.Pause;\r
-            this.btn_stop.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
-            this.btn_stop.ImageTransparentColor = System.Drawing.Color.Magenta;\r
-            this.btn_stop.Name = "btn_stop";\r
-            this.btn_stop.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never;\r
-            this.btn_stop.Size = new System.Drawing.Size(75, 36);\r
-            this.btn_stop.Text = "Pause";\r
-            this.btn_stop.Visible = false;\r
-            this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click);\r
+            this.btn_pause.Image = global::Handbrake.Properties.Resources.Pause;\r
+            this.btn_pause.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
+            this.btn_pause.ImageTransparentColor = System.Drawing.Color.Magenta;\r
+            this.btn_pause.Name = "btn_pause";\r
+            this.btn_pause.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never;\r
+            this.btn_pause.Size = new System.Drawing.Size(74, 36);\r
+            this.btn_pause.Text = "Pause";\r
+            this.btn_pause.Visible = false;\r
+            this.btn_pause.Click += new System.EventHandler(this.btn_pause_Click);\r
             // \r
             // toolStripSeparator1\r
             // \r
@@ -256,19 +280,21 @@ namespace Handbrake
             this.drop_button_queue.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.mnu_batch,\r
             this.mnu_import,\r
-            this.mnu_export});\r
+            this.mnu_export,\r
+            this.toolStripSeparator2,\r
+            this.mnu_readd});\r
             this.drop_button_queue.Image = global::Handbrake.Properties.Resources.ActivityWindow;\r
             this.drop_button_queue.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.drop_button_queue.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.drop_button_queue.Name = "drop_button_queue";\r
-            this.drop_button_queue.Size = new System.Drawing.Size(89, 36);\r
+            this.drop_button_queue.Size = new System.Drawing.Size(87, 36);\r
             this.drop_button_queue.Text = "Queue";\r
             // \r
             // mnu_batch\r
             // \r
             this.mnu_batch.Image = global::Handbrake.Properties.Resources.Output_Small;\r
             this.mnu_batch.Name = "mnu_batch";\r
-            this.mnu_batch.Size = new System.Drawing.Size(207, 22);\r
+            this.mnu_batch.Size = new System.Drawing.Size(187, 22);\r
             this.mnu_batch.Text = "Generate Batch Script";\r
             this.mnu_batch.Click += new System.EventHandler(this.mnu_batch_Click);\r
             // \r
@@ -276,7 +302,7 @@ namespace Handbrake
             // \r
             this.mnu_import.Image = global::Handbrake.Properties.Resources.folder;\r
             this.mnu_import.Name = "mnu_import";\r
-            this.mnu_import.Size = new System.Drawing.Size(207, 22);\r
+            this.mnu_import.Size = new System.Drawing.Size(187, 22);\r
             this.mnu_import.Text = "Import Queue";\r
             this.mnu_import.Click += new System.EventHandler(this.mnu_import_Click);\r
             // \r
@@ -284,10 +310,24 @@ namespace Handbrake
             // \r
             this.mnu_export.Image = global::Handbrake.Properties.Resources.save;\r
             this.mnu_export.Name = "mnu_export";\r
-            this.mnu_export.Size = new System.Drawing.Size(207, 22);\r
+            this.mnu_export.Size = new System.Drawing.Size(187, 22);\r
             this.mnu_export.Text = "Export Queue";\r
             this.mnu_export.Click += new System.EventHandler(this.mnu_export_Click);\r
             // \r
+            // toolStripSeparator2\r
+            // \r
+            this.toolStripSeparator2.Name = "toolStripSeparator2";\r
+            this.toolStripSeparator2.Size = new System.Drawing.Size(184, 6);\r
+            // \r
+            // mnu_readd\r
+            // \r
+            this.mnu_readd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;\r
+            this.mnu_readd.Image = global::Handbrake.Properties.Resources.AddToQueue_small;\r
+            this.mnu_readd.Name = "mnu_readd";\r
+            this.mnu_readd.Size = new System.Drawing.Size(187, 22);\r
+            this.mnu_readd.Text = "Re-Add Current Job";\r
+            this.mnu_readd.Click += new System.EventHandler(this.mnu_readd_Click);\r
+            // \r
             // SaveFile\r
             // \r
             this.SaveFile.Filter = "Batch|.bat";\r
@@ -301,14 +341,15 @@ namespace Handbrake
             this.Destination,\r
             this.EncoderVideo,\r
             this.Audio});\r
+            this.list_queue.ContextMenuStrip = this.mnu_queue;\r
+            this.list_queue.Dock = System.Windows.Forms.DockStyle.Fill;\r
             this.list_queue.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.list_queue.FullRowSelect = true;\r
             this.list_queue.GridLines = true;\r
             this.list_queue.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;\r
-            this.list_queue.Location = new System.Drawing.Point(15, 138);\r
-            this.list_queue.MultiSelect = false;\r
+            this.list_queue.Location = new System.Drawing.Point(13, 0);\r
             this.list_queue.Name = "list_queue";\r
-            this.list_queue.Size = new System.Drawing.Size(755, 202);\r
+            this.list_queue.Size = new System.Drawing.Size(761, 219);\r
             this.list_queue.TabIndex = 72;\r
             this.list_queue.UseCompatibleStateImageBehavior = false;\r
             this.list_queue.View = System.Windows.Forms.View.Details;\r
@@ -332,7 +373,7 @@ namespace Handbrake
             // Destination\r
             // \r
             this.Destination.Text = "Destination";\r
-            this.Destination.Width = 215;\r
+            this.Destination.Width = 210;\r
             // \r
             // EncoderVideo\r
             // \r
@@ -344,81 +385,173 @@ namespace Handbrake
             this.Audio.Text = "Audio Encoder";\r
             this.Audio.Width = 94;\r
             // \r
-            // statusStrip1\r
+            // mnu_queue\r
             // \r
-            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.lbl_encodesPending,\r
-            this.toolStripStatusLabel1,\r
-            this.progressBar,\r
-            this.lbl_progressValue});\r
-            this.statusStrip1.Location = new System.Drawing.Point(0, 359);\r
-            this.statusStrip1.Name = "statusStrip1";\r
-            this.statusStrip1.Size = new System.Drawing.Size(779, 31);\r
-            this.statusStrip1.TabIndex = 73;\r
-            this.statusStrip1.Text = "statusStrip1";\r
+            this.mnu_queue.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.mnu_up,\r
+            this.mnu_Down,\r
+            this.toolStripSeparator3,\r
+            this.mnu_delete});\r
+            this.mnu_queue.Name = "mnu_queue";\r
+            this.mnu_queue.Size = new System.Drawing.Size(139, 76);\r
             // \r
-            // toolStripStatusLabel1\r
+            // mnu_up\r
             // \r
-            this.toolStripStatusLabel1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
-            this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";\r
-            this.toolStripStatusLabel1.Size = new System.Drawing.Size(57, 26);\r
-            this.toolStripStatusLabel1.Text = "Progress:";\r
+            this.mnu_up.Name = "mnu_up";\r
+            this.mnu_up.Size = new System.Drawing.Size(138, 22);\r
+            this.mnu_up.Text = "Move Up";\r
+            this.mnu_up.Click += new System.EventHandler(this.mnu_up_Click);\r
             // \r
-            // progressBar\r
+            // mnu_Down\r
             // \r
-            this.progressBar.Name = "progressBar";\r
-            this.progressBar.Size = new System.Drawing.Size(500, 25);\r
-            this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;\r
+            this.mnu_Down.Name = "mnu_Down";\r
+            this.mnu_Down.Size = new System.Drawing.Size(138, 22);\r
+            this.mnu_Down.Text = "Move Down";\r
+            this.mnu_Down.Click += new System.EventHandler(this.mnu_Down_Click);\r
             // \r
-            // lbl_progressValue\r
+            // toolStripSeparator3\r
             // \r
-            this.lbl_progressValue.Name = "lbl_progressValue";\r
-            this.lbl_progressValue.Size = new System.Drawing.Size(34, 26);\r
-            this.lbl_progressValue.Text = " 0 %";\r
+            this.toolStripSeparator3.Name = "toolStripSeparator3";\r
+            this.toolStripSeparator3.Size = new System.Drawing.Size(135, 6);\r
             // \r
-            // OpenFile\r
+            // mnu_delete\r
             // \r
-            this.OpenFile.Filter = "HandBrake Queue|*.queue";\r
+            this.mnu_delete.Name = "mnu_delete";\r
+            this.mnu_delete.Size = new System.Drawing.Size(138, 22);\r
+            this.mnu_delete.Text = "Delete";\r
+            this.mnu_delete.Click += new System.EventHandler(this.mnu_delete_Click);\r
+            // \r
+            // statusStrip1\r
+            // \r
+            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
+            this.lbl_encodesPending});\r
+            this.statusStrip1.Location = new System.Drawing.Point(0, 368);\r
+            this.statusStrip1.Name = "statusStrip1";\r
+            this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0);\r
+            this.statusStrip1.Size = new System.Drawing.Size(787, 22);\r
+            this.statusStrip1.TabIndex = 73;\r
+            this.statusStrip1.Text = "statusStrip1";\r
             // \r
             // lbl_encodesPending\r
             // \r
             this.lbl_encodesPending.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
             this.lbl_encodesPending.Margin = new System.Windows.Forms.Padding(0, 3, 10, 2);\r
             this.lbl_encodesPending.Name = "lbl_encodesPending";\r
-            this.lbl_encodesPending.Size = new System.Drawing.Size(122, 26);\r
+            this.lbl_encodesPending.Size = new System.Drawing.Size(115, 17);\r
             this.lbl_encodesPending.Text = "0 encode(s) pending";\r
             // \r
+            // OpenFile\r
+            // \r
+            this.OpenFile.Filter = "HandBrake Queue|*.queue";\r
+            // \r
+            // splitContainer1\r
+            // \r
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;\r
+            this.splitContainer1.IsSplitterFixed = true;\r
+            this.splitContainer1.Location = new System.Drawing.Point(0, 39);\r
+            this.splitContainer1.Name = "splitContainer1";\r
+            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;\r
+            // \r
+            // splitContainer1.Panel1\r
+            // \r
+            this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel1);\r
+            // \r
+            // splitContainer1.Panel2\r
+            // \r
+            this.splitContainer1.Panel2.Controls.Add(this.list_queue);\r
+            this.splitContainer1.Panel2.Controls.Add(this.panel3);\r
+            this.splitContainer1.Panel2.Controls.Add(this.panel2);\r
+            this.splitContainer1.Panel2.Controls.Add(this.panel1);\r
+            this.splitContainer1.Size = new System.Drawing.Size(787, 329);\r
+            this.splitContainer1.SplitterDistance = 94;\r
+            this.splitContainer1.SplitterWidth = 1;\r
+            this.splitContainer1.TabIndex = 74;\r
+            // \r
+            // tableLayoutPanel1\r
+            // \r
+            this.tableLayoutPanel1.AutoSize = true;\r
+            this.tableLayoutPanel1.ColumnCount = 7;\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
+            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_delete, 6, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_down, 5, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_aEnc, 3, 5);\r
+            this.tableLayoutPanel1.Controls.Add(this.btn_up, 4, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_source, 1, 2);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_vEnc, 3, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.label4, 2, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_dest, 1, 3);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_title, 1, 4);\r
+            this.tableLayoutPanel1.Controls.Add(this.lbl_chapt, 1, 5);\r
+            this.tableLayoutPanel1.Controls.Add(this.label3, 0, 0);\r
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(13, 13);\r
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.RowCount = 6;\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F));\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(762, 77);\r
+            this.tableLayoutPanel1.TabIndex = 71;\r
+            // \r
+            // panel3\r
+            // \r
+            this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;\r
+            this.panel3.Location = new System.Drawing.Point(13, 219);\r
+            this.panel3.Name = "panel3";\r
+            this.panel3.Size = new System.Drawing.Size(761, 15);\r
+            this.panel3.TabIndex = 77;\r
+            // \r
+            // panel2\r
+            // \r
+            this.panel2.Dock = System.Windows.Forms.DockStyle.Right;\r
+            this.panel2.Location = new System.Drawing.Point(774, 0);\r
+            this.panel2.Name = "panel2";\r
+            this.panel2.Size = new System.Drawing.Size(13, 234);\r
+            this.panel2.TabIndex = 76;\r
+            // \r
+            // panel1\r
+            // \r
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Left;\r
+            this.panel1.Location = new System.Drawing.Point(0, 0);\r
+            this.panel1.Name = "panel1";\r
+            this.panel1.Size = new System.Drawing.Size(13, 234);\r
+            this.panel1.TabIndex = 75;\r
+            // \r
             // frmQueue\r
             // \r
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(779, 390);\r
+            this.ClientSize = new System.Drawing.Size(787, 390);\r
+            this.Controls.Add(this.splitContainer1);\r
             this.Controls.Add(this.statusStrip1);\r
-            this.Controls.Add(this.list_queue);\r
-            this.Controls.Add(this.btn_down);\r
-            this.Controls.Add(this.btn_up);\r
             this.Controls.Add(this.toolStrip1);\r
-            this.Controls.Add(this.label4);\r
-            this.Controls.Add(this.lbl_dest);\r
-            this.Controls.Add(this.btn_delete);\r
-            this.Controls.Add(this.lbl_vEnc);\r
-            this.Controls.Add(this.lbl_chapt);\r
-            this.Controls.Add(this.lbl_source);\r
-            this.Controls.Add(this.label3);\r
-            this.Controls.Add(this.lbl_aEnc);\r
-            this.Controls.Add(this.lbl_title);\r
-            this.Controls.Add(this.label1);\r
-            this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
-            this.MaximizeBox = false;\r
-            this.MinimumSize = new System.Drawing.Size(787, 417);\r
+            this.MinimumSize = new System.Drawing.Size(677, 417);\r
             this.Name = "frmQueue";\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "Encode Queue";\r
             this.toolStrip1.ResumeLayout(false);\r
             this.toolStrip1.PerformLayout();\r
+            this.mnu_queue.ResumeLayout(false);\r
             this.statusStrip1.ResumeLayout(false);\r
             this.statusStrip1.PerformLayout();\r
+            this.splitContainer1.Panel1.ResumeLayout(false);\r
+            this.splitContainer1.Panel1.PerformLayout();\r
+            this.splitContainer1.Panel2.ResumeLayout(false);\r
+            this.splitContainer1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.ResumeLayout(false);\r
+            this.tableLayoutPanel1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -442,7 +575,7 @@ namespace Handbrake
         private System.Windows.Forms.ToolStrip toolStrip1;\r
         private System.Windows.Forms.ToolStripButton btn_encode;\r
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;\r
-        private System.Windows.Forms.ToolStripButton btn_stop;\r
+        private System.Windows.Forms.ToolStripButton btn_pause;\r
         private System.Windows.Forms.SaveFileDialog SaveFile;\r
         private System.Windows.Forms.ListView list_queue;\r
         private System.Windows.Forms.ColumnHeader Title;\r
@@ -452,14 +585,23 @@ namespace Handbrake
         private System.Windows.Forms.ColumnHeader EncoderVideo;\r
         private System.Windows.Forms.ColumnHeader Audio;\r
         private System.Windows.Forms.StatusStrip statusStrip1;\r
-        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;\r
-        private System.Windows.Forms.ToolStripProgressBar progressBar;\r
-        private System.Windows.Forms.ToolStripStatusLabel lbl_progressValue;\r
         private System.Windows.Forms.ToolStripDropDownButton drop_button_queue;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_batch;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_import;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_export;\r
         private System.Windows.Forms.OpenFileDialog OpenFile;\r
         private System.Windows.Forms.ToolStripStatusLabel lbl_encodesPending;\r
+        private System.Windows.Forms.SplitContainer splitContainer1;\r
+        private System.Windows.Forms.Panel panel2;\r
+        private System.Windows.Forms.Panel panel1;\r
+        private System.Windows.Forms.Panel panel3;\r
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_readd;\r
+        private System.Windows.Forms.ContextMenuStrip mnu_queue;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_up;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_Down;\r
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;\r
+        private System.Windows.Forms.ToolStripMenuItem mnu_delete;\r
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
     }\r
-}
\ No newline at end of file
+}\r
index 88acf24..3529789 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
-using System.Collections;\r
 using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.Threading;\r
-using System.Diagnostics;\r
-using System.Runtime.InteropServices;\r
-using System.IO;\r
+using Handbrake.EncodeQueue;\r
+using System.Collections.ObjectModel;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmQueue : Form\r
     {\r
-        private delegate void ProgressUpdateHandler();\r
-        private delegate void setEncoding();\r
-        Functions.Encode cliObj = new Functions.Encode();\r
-        Boolean cancel = false;\r
-        Process hbProc = null;\r
-        Functions.Queue queue;\r
-        frmMain mainWindow = null;\r
-\r
-        public frmQueue(frmMain main)\r
+        private delegate void UpdateHandler();\r
+        private EncodeAndQueueHandler queue;\r
+\r
+        public frmQueue(EncodeAndQueueHandler q)\r
         {\r
             InitializeComponent();\r
-            mainWindow = main;\r
+\r
+            this.queue = q;\r
+            queue.NewJobStarted += new EventHandler(queueOnEncodeStart);\r
+            queue.QueueCompleted += new EventHandler(queueOnQueueFinished);\r
+            queue.QueuePauseRequested += new EventHandler(queueOnPaused);\r
+        }\r
+        void queueOnPaused(object sender, EventArgs e)\r
+        {\r
+            setUIEncodeFinished();\r
+            updateUIElements();\r
+        }\r
+        void queueOnQueueFinished(object sender, EventArgs e)\r
+        {\r
+            setUIEncodeFinished();\r
+            resetQueue(); // Reset the Queue Window\r
+        }\r
+        void queueOnEncodeStart(object sender, EventArgs e)\r
+        {\r
+            setUIEncodeStarted(); // make sure the UI is set correctly\r
+            setCurrentEncodeInformation();\r
+            updateUIElements(); // Redraw the Queue, a new encode has started.\r
         }\r
 \r
         /// <summary>\r
         /// Initializes the Queue list with the Arraylist from the Queue class\r
         /// </summary>\r
-        /// <param name="qw"></param>\r
-        public void setQueue(Functions.Queue qw)\r
+        public void setQueue()\r
         {\r
-            queue = qw;\r
-            redrawQueue();\r
-            lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
+            updateUIElements();\r
         }\r
 \r
         /// <summary>\r
-        /// Returns if there is currently an item being encoded by the queue\r
+        /// Initializes the Queue list, then shows and activates the window\r
         /// </summary>\r
-        /// <returns>Boolean true if encoding</returns>\r
-        public Boolean isEncoding()\r
+        public new void Show()\r
         {\r
-            if (hbProc == null)\r
-                return false;\r
-            else\r
-                return true;\r
+           Show(true);\r
         }\r
 \r
-        // Redraw's the queue with the latest data from the Queue class\r
-        private void redrawQueue()\r
+        /// <summary>\r
+        /// Initializes the Queue list only if doSetQueue is true, then shows and activates the window\r
+        /// </summary>\r
+        /// <param name="doSetQueue">Indicates whether to call setQueue() before showing the window</param>\r
+        public void Show(bool doSetQueue)\r
         {\r
-            list_queue.Items.Clear();\r
-            ArrayList theQueue = queue.getQueue();\r
-            foreach (ArrayList queue_item in theQueue)\r
-            {\r
-                string q_item = queue_item[1].ToString();\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
-\r
-                // Get the DVD Title\r
-                string title = "";\r
-                if (parsed.DVDTitle == 0)\r
-                    title = "Auto";\r
-                else\r
-                    title = parsed.DVDTitle.ToString();\r
-\r
-                // Get the DVD Chapters\r
-                string chapters = "";\r
-                if (parsed.DVDChapterStart == 0)\r
-                    chapters = "Auto";\r
-                else\r
-                {\r
-                    chapters = parsed.DVDChapterStart.ToString();\r
-                    if (parsed.DVDChapterFinish != 0)\r
-                        chapters = chapters + " - " + parsed.DVDChapterFinish;\r
-                }\r
-\r
-                ListViewItem item = new ListViewItem();\r
-                item.Text = title; // Title\r
-                item.SubItems.Add(chapters); // Chapters\r
-                item.SubItems.Add(parsed.Source); // Source\r
-                item.SubItems.Add(parsed.Destination); // Destination\r
-                item.SubItems.Add(parsed.VideoEncoder); // Video\r
-                item.SubItems.Add(parsed.AudioEncoder1); // Audio\r
+            if (doSetQueue) setQueue();\r
+            base.Show();\r
 \r
-                list_queue.Items.Add(item);\r
-            }\r
+            //Activate();\r
         }\r
 \r
-        // Initializes the encode process\r
+        // Start and Stop Controls\r
         private void btn_encode_Click(object sender, EventArgs e)\r
         {\r
-            mainWindow.setLastAction("encode");\r
-            \r
-            if (queue.count() != 0)\r
+            if (queue.PauseRequested)\r
             {\r
-                btn_encode.Enabled = false;\r
+                setUIEncodeStarted();\r
+                MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
             }\r
-            cancel = false;\r
 \r
-            // Start the encode\r
-            try\r
+            if (!queue.isEncoding)\r
+                queue.StartEncodeQueue();\r
+\r
+        }\r
+        private void btn_pause_Click(object sender, EventArgs e)\r
+        {\r
+            queue.RequestPause();\r
+            setUIEncodeFinished();\r
+            resetQueue();\r
+            MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+        }\r
+\r
+        // Window Display Management\r
+        private void setUIEncodeStarted()\r
+        {\r
+            if (InvokeRequired)\r
             {\r
-                if (queue.count() != 0)\r
-                {\r
-                    // Setup or reset some values\r
-                    btn_stop.Visible = true;\r
-                    progressBar.Value = 0;\r
-                    lbl_progressValue.Text = "0 %";\r
-                    progressBar.Step = 100 / queue.count();\r
-                    Thread theQ = new Thread(startProc);\r
-                    theQ.IsBackground = true;\r
-                    theQ.Start();\r
-                }\r
+                BeginInvoke(new UpdateHandler(setUIEncodeStarted));\r
+                return;\r
             }\r
-            catch (Exception exc)\r
+            btn_encode.Enabled = false;\r
+            btn_pause.Visible = true;\r
+        }\r
+        private void setUIEncodeFinished()\r
+        {\r
+            if (InvokeRequired)\r
             {\r
-                MessageBox.Show(exc.ToString());\r
+                BeginInvoke(new UpdateHandler(setUIEncodeFinished));\r
+                return;\r
             }\r
+            btn_pause.Visible = false;\r
+            btn_encode.Enabled = true;\r
         }\r
-\r
-        // Starts the encoding process\r
-        private void startProc(object state)\r
+        private void resetQueue()\r
         {\r
-            try\r
+            if (InvokeRequired)\r
             {\r
-                // Run through each item on the queue\r
-                while (queue.count() != 0)\r
-                {\r
-                    string query = queue.getNextItemForEncoding();\r
-                    queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
-\r
-                    setEncValue();\r
-                    updateUIElements();\r
-\r
-                    hbProc = cliObj.runCli(this, query);\r
-\r
-                    hbProc.WaitForExit();\r
-                    cliObj.addCLIQueryToLog(query);\r
-                    cliObj.copyLog(query);\r
-\r
-                    hbProc.Close();\r
-                    hbProc.Dispose();\r
-                    hbProc = null;\r
-                    query = "";\r
-\r
-                    if (cancel == true)\r
-                    {\r
-                        break;\r
-                    }\r
-                }\r
+                BeginInvoke(new UpdateHandler(resetQueue));\r
+                return;\r
+            }\r
+            btn_pause.Visible = false;\r
+            btn_encode.Enabled = true;\r
 \r
-                resetQueue();\r
+            lbl_source.Text = "-";\r
+            lbl_dest.Text = "-";\r
+            lbl_vEnc.Text = "-";\r
+            lbl_aEnc.Text = "-";\r
+            lbl_title.Text = "-";\r
+            lbl_chapt.Text = "-";\r
 \r
-                // After the encode is done, we may want to shutdown, suspend etc.\r
-                cliObj.afterEncodeAction();\r
-            }\r
-            catch (Exception exc)\r
+            lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
+        }\r
+        private void redrawQueue()\r
+        {\r
+            if (InvokeRequired)\r
             {\r
-                MessageBox.Show(exc.ToString());\r
+                BeginInvoke(new UpdateHandler(redrawQueue));\r
+                return;\r
             }\r
-        }\r
 \r
-        // Reset's the window to the default state.\r
-        private void resetQueue()\r
-        {\r
-            try\r
+            list_queue.Items.Clear();\r
+            ReadOnlyCollection<Job> theQueue = queue.CurrentQueue;\r
+            foreach (Job queue_item in theQueue)\r
             {\r
-                if (this.InvokeRequired)\r
-                {\r
-                    this.BeginInvoke(new ProgressUpdateHandler(resetQueue));\r
-                    return;\r
+                string q_item = queue_item.Query;\r
+                Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
 \r
-                }\r
-                btn_stop.Visible = false;\r
-                btn_encode.Enabled = true;\r
+                // Get the DVD Title\r
+                string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();\r
 \r
-                if (cancel == true)\r
-                {\r
-                    lbl_progressValue.Text = "Encode Queue Cancelled!";\r
-                }\r
+                // Get the DVD Chapters\r
+                string chapters;\r
+                if (parsed.DVDChapterStart == 0)\r
+                    chapters = "Auto";\r
                 else\r
                 {\r
-                    lbl_progressValue.Text = "Encode Queue Completed!";\r
+                    chapters = parsed.DVDChapterStart.ToString();\r
+                    if (parsed.DVDChapterFinish != 0)\r
+                        chapters = chapters + " - " + parsed.DVDChapterFinish;\r
                 }\r
 \r
-                progressBar.Value = 0;\r
+                ListViewItem item = new ListViewItem();\r
+                item.Text = title; // Title\r
+                item.SubItems.Add(chapters); // Chapters\r
+                item.SubItems.Add(queue_item.Source); // Source\r
+                item.SubItems.Add(queue_item.Destination); // Destination\r
+                item.SubItems.Add(parsed.VideoEncoder); // Video\r
 \r
-                lbl_source.Text = "-";\r
-                lbl_dest.Text = "-";\r
-                lbl_vEnc.Text = "-";\r
-                lbl_aEnc.Text = "-";\r
-                lbl_title.Text = "-";\r
-                lbl_chapt.Text = "-";\r
+                // Display The Audio Track Information\r
+                string audio = string.Empty;\r
+                foreach (Functions.AudioTrack track in parsed.AudioInformation)\r
+                {\r
+                    if (audio != "")\r
+                        audio += ", " + track.Encoder;\r
+                    else\r
+                        audio = track.Encoder;\r
+                }\r
+                item.SubItems.Add(audio); // Audio\r
 \r
-                lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
-            }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show(exc.ToString());\r
+                list_queue.Items.Add(item);\r
             }\r
         }\r
-\r
-        // Stop's the queue from continuing. \r
-        private void btn_stop_Click(object sender, EventArgs e)\r
-        {\r
-            cancel = true;\r
-            btn_stop.Visible = false;\r
-            btn_encode.Enabled = true;\r
-            MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
-        }\r
-\r
-        // Updates the progress bar and progress label for a new status.\r
         private void updateUIElements()\r
         {\r
-            try\r
-            {\r
-                if (this.InvokeRequired)\r
-                {\r
-                    this.BeginInvoke(new ProgressUpdateHandler(updateUIElements));\r
-                    return;\r
-                }\r
-\r
-                redrawQueue();\r
-\r
-                progressBar.PerformStep();\r
-                lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);\r
-                lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
-            }\r
-            catch (Exception exc)\r
+            if (InvokeRequired)\r
             {\r
-                MessageBox.Show(exc.ToString());\r
+                BeginInvoke(new UpdateHandler(updateUIElements));\r
+                return;\r
             }\r
-        }\r
 \r
-        // Set's the information lables about the current encode.\r
-        private void setEncValue()\r
+            redrawQueue();\r
+            lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
+        }\r
+        private void setCurrentEncodeInformation()\r
         {\r
             try\r
             {\r
-                if (this.InvokeRequired)\r
+                if (InvokeRequired)\r
                 {\r
-                    this.BeginInvoke(new setEncoding(setEncValue));\r
+                    BeginInvoke(new UpdateHandler(setCurrentEncodeInformation));\r
                 }\r
 \r
                 // found query is a global varible\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQuery());\r
-                lbl_source.Text = parsed.Source;\r
-                lbl_dest.Text = parsed.Destination;\r
+                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.LastEncode.Query);\r
+                lbl_source.Text = queue.LastEncode.Source;\r
+                lbl_dest.Text = queue.LastEncode.Destination;\r
 \r
+                lbl_title.Text = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();\r
 \r
-                if (parsed.DVDTitle == 0)\r
-                    lbl_title.Text = "Auto";\r
-                else\r
-                    lbl_title.Text = parsed.DVDTitle.ToString();\r
-\r
-                string chapters = "";\r
-                if (parsed.DVDChapterStart == 0)\r
-                {\r
+                if (Equals(parsed.DVDChapterStart, 0))\r
                     lbl_chapt.Text = "Auto";\r
-                }\r
                 else\r
                 {\r
-                    chapters = parsed.DVDChapterStart.ToString();\r
+                    string chapters = parsed.DVDChapterStart.ToString();\r
                     if (parsed.DVDChapterFinish != 0)\r
                         chapters = chapters + " - " + parsed.DVDChapterFinish;\r
                     lbl_chapt.Text = chapters;\r
                 }\r
 \r
                 lbl_vEnc.Text = parsed.VideoEncoder;\r
-                lbl_aEnc.Text = parsed.AudioEncoder1;\r
+\r
+                // Display The Audio Track Information\r
+                string audio = string.Empty;\r
+                foreach (Functions.AudioTrack track in parsed.AudioInformation)\r
+                {\r
+                    if (audio != "")\r
+                        audio += ", " + track.Encoder;\r
+                    else\r
+                        audio = track.Encoder;\r
+                }\r
+                lbl_aEnc.Text = audio;\r
             }\r
             catch (Exception)\r
             {\r
                 // Do Nothing\r
             }\r
         }\r
-\r
-        // Move an item up the Queue\r
-        private void btn_up_Click(object sender, EventArgs e)\r
+        private void deleteSelectedItems()\r
         {\r
-            if (list_queue.SelectedIndices.Count != 0)\r
+            // If there are selected items\r
+            if (list_queue.SelectedIndices.Count > 0)\r
             {\r
-                int selected = list_queue.SelectedIndices[0];\r
+                // Save the selected indices to select them after the move\r
+                List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);\r
+                foreach (int selectedIndex in list_queue.SelectedIndices)\r
+                    selectedIndices.Add(selectedIndex);\r
+\r
+                int firstSelectedIndex = selectedIndices[0];\r
+\r
+                // Reverse the list to delete the items from last to first (preserves indices)\r
+                selectedIndices.Reverse();\r
 \r
-                queue.moveUp(selected);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
-                redrawQueue();\r
+                // Remove each selected item\r
+                foreach (int selectedIndex in selectedIndices)\r
+                    queue.RemoveJob(selectedIndex);\r
 \r
-                if (selected - 1 > 0) \r
-                    list_queue.Items[selected -1].Selected = true;\r
+                updateUIElements();\r
 \r
-                list_queue.Select();\r
+                // Select the item where the first deleted item was previously\r
+                if (firstSelectedIndex < list_queue.Items.Count)\r
+                    list_queue.Items[firstSelectedIndex].Selected = true;\r
             }\r
+\r
+            list_queue.Select(); // Activate the control to show the selected items\r
         }\r
 \r
-        // Move an item down the Queue\r
+        // Queue Management\r
+        private void mnu_up_Click(object sender, EventArgs e)\r
+        {\r
+            moveUp();\r
+        }\r
+        private void mnu_Down_Click(object sender, EventArgs e)\r
+        {\r
+            moveDown();\r
+        }\r
+        private void mnu_delete_Click(object sender, EventArgs e)\r
+        {\r
+            deleteSelectedItems();\r
+        }\r
+        private void btn_up_Click(object sender, EventArgs e)\r
+        {\r
+            moveUp();\r
+        }\r
         private void btn_down_Click(object sender, EventArgs e)\r
         {\r
-            if (list_queue.SelectedIndices.Count != 0)\r
+            moveDown();\r
+        }\r
+        private void btn_delete_Click(object sender, EventArgs e)\r
+        {\r
+            deleteSelectedItems();\r
+        }\r
+        private void list_queue_deleteKey(object sender, KeyEventArgs e)\r
+        {\r
+            if (e.KeyCode == Keys.Delete)\r
+                deleteSelectedItems();\r
+        }\r
+        private void moveUp()\r
+        {\r
+            // If there are selected items and the first item is not selected\r
+            if (list_queue.SelectedIndices.Count > 0 && !list_queue.SelectedIndices.Contains(0))\r
             {\r
-                int selected = list_queue.SelectedIndices[0];\r
+                // Copy the selected indices to preserve them during the movement\r
+                List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);\r
+                foreach (int selectedIndex in list_queue.SelectedIndices)\r
+                    selectedIndices.Add(selectedIndex);\r
 \r
-                queue.moveDown(list_queue.SelectedIndices[0]);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
-                redrawQueue();\r
+                // Move up each selected item\r
+                foreach (int selectedIndex in selectedIndices)\r
+                    queue.MoveUp(selectedIndex);\r
 \r
-                if (selected +1 < list_queue.Items.Count) \r
-                    list_queue.Items[selected + 1].Selected = true;\r
+                updateUIElements();\r
 \r
-                list_queue.Select();\r
+                // Keep the selected item(s) selected, now moved up one index\r
+                foreach (int selectedIndex in selectedIndices)\r
+                    if (selectedIndex - 1 > -1) // Defensive programming: ensure index is good\r
+                        list_queue.Items[selectedIndex - 1].Selected = true;\r
             }\r
-        }\r
 \r
-        // Remove an item from the queue\r
-        private void btn_delete_Click(object sender, EventArgs e)\r
+            list_queue.Select(); // Activate the control to show the selected items\r
+        }\r
+        private void moveDown()\r
         {\r
-            if (list_queue.SelectedIndices.Count != 0)\r
+            // If there are selected items and the last item is not selected\r
+            if (list_queue.SelectedIndices.Count > 0 &&\r
+                !list_queue.SelectedIndices.Contains(list_queue.Items[list_queue.Items.Count - 1].Index))\r
             {\r
-                queue.remove(list_queue.SelectedIndices[0]);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
-                redrawQueue();\r
-                lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
+                // Copy the selected indices to preserve them during the movement\r
+                List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);\r
+                foreach (int selectedIndex in list_queue.SelectedIndices)\r
+                    selectedIndices.Add(selectedIndex);\r
+\r
+                // Reverse the indices to move the items down from last to first (preserves indices)\r
+                selectedIndices.Reverse();\r
+\r
+                // Move down each selected item\r
+                foreach (int selectedIndex in selectedIndices)\r
+                    queue.MoveDown(selectedIndex);\r
+\r
+                updateUIElements();\r
+\r
+                // Keep the selected item(s) selected, now moved down one index\r
+                foreach (int selectedIndex in selectedIndices)\r
+                    if (selectedIndex + 1 < list_queue.Items.Count) // Defensive programming: ensure index is good\r
+                        list_queue.Items[selectedIndex + 1].Selected = true;\r
             }\r
+\r
+            list_queue.Select(); // Activate the control to show the selected items\r
         }\r
 \r
-        // Generate a Saveable batch script on the users request\r
+        // Queue Import/Export Features\r
         private void mnu_batch_Click(object sender, EventArgs e)\r
         {\r
             SaveFile.FileName = "";\r
             SaveFile.Filter = "Batch|.bat";\r
             SaveFile.ShowDialog();\r
             if (SaveFile.FileName != String.Empty)\r
-                queue.writeBatchScript(SaveFile.FileName);\r
+                queue.WriteBatchScriptToFile(SaveFile.FileName);\r
         }\r
-\r
-        // Export the HandBrake Queue to a file.\r
         private void mnu_export_Click(object sender, EventArgs e)\r
         {\r
             SaveFile.FileName = "";\r
             SaveFile.Filter = "HandBrake Queue|*.queue";\r
             SaveFile.ShowDialog();\r
             if (SaveFile.FileName != String.Empty)\r
-                queue.write2disk(SaveFile.FileName);\r
+                queue.WriteQueueStateToFile(SaveFile.FileName);\r
         }\r
-\r
-        // Import an exported queue\r
         private void mnu_import_Click(object sender, EventArgs e)\r
         {\r
             OpenFile.FileName = "";\r
             OpenFile.ShowDialog();\r
             if (OpenFile.FileName != String.Empty)\r
-                queue.recoverQueue(OpenFile.FileName);\r
-            redrawQueue();\r
+                queue.LoadQueueFromFile(OpenFile.FileName);\r
+            updateUIElements();\r
         }\r
-\r
-        // Delete a selected item on the queue, if the delete key is pressed.\r
-        private void list_queue_deleteKey(object sender, KeyEventArgs e)\r
+        private void mnu_readd_Click(object sender, EventArgs e)\r
         {\r
-            if (e.KeyCode == Keys.Delete)\r
+            if (!queue.LastEncode.IsEmpty)\r
             {\r
-                if (list_queue.SelectedIndices.Count != 0)\r
-                {\r
-                    queue.remove(list_queue.SelectedIndices[0]);\r
-                    queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
-                    redrawQueue();\r
-                }\r
+                queue.AddJob(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination, queue.LastEncode.CustomQuery);\r
+                updateUIElements();\r
             }\r
         }\r
 \r
-        // Hide's the window from the users view.\r
-        private void btn_Close_Click(object sender, EventArgs e)\r
-        {\r
-            this.Hide();\r
-        }\r
-\r
         // Hide's the window when the user tries to "x" out of the window instead of closing it.\r
         protected override void OnClosing(CancelEventArgs e)\r
         {\r
@@ -393,6 +392,5 @@ namespace Handbrake
             base.OnClosing(e);\r
         }\r
 \r
-\r
     }\r
-}
\ No newline at end of file
+}\r
index 2575392..d4befb1 100644 (file)
     <value>17, 17</value>\r
   </metadata>\r
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>93, 17</value>\r
+    <value>114, 17</value>\r
   </metadata>\r
   <metadata name="SaveFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>176, 17</value>\r
+    <value>219, 17</value>\r
+  </metadata>\r
+  <metadata name="mnu_queue.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
+    <value>530, 17</value>\r
   </metadata>\r
   <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>324, 17</value>\r
+    <value>414, 17</value>\r
   </metadata>\r
   <metadata name="OpenFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>252, 17</value>\r
-  </metadata>\r
-  <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-    <value>True</value>\r
+    <value>314, 17</value>\r
   </metadata>\r
   <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />\r
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
index 51891e4..b447c38 100644 (file)
@@ -44,15 +44,18 @@ namespace Handbrake
             this.BackColor = System.Drawing.Color.White;\r
             this.BackgroundImage = global::Handbrake.Properties.Resources.SplashScreen;\r
             this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;\r
-            this.ClientSize = new System.Drawing.Size(496, 303);\r
+            this.ClientSize = new System.Drawing.Size(400, 180);\r
             this.ControlBox = false;\r
             this.Font = new System.Drawing.Font("Corbel", 8.25F);\r
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
+            this.MaximizeBox = false;\r
+            this.MinimizeBox = false;\r
             this.Name = "frmSplashScreen";\r
+            this.ShowIcon = false;\r
+            this.ShowInTaskbar = false;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
             this.Text = "SplashScreen";\r
-            this.TopMost = true;\r
             this.ResumeLayout(false);\r
 \r
         }\r
index 6525072..dca8bd2 100644 (file)
@@ -4,14 +4,7 @@
           Homepage: <http://handbrake.fr>.\r
           It may be used under the terms of the GNU General Public License. */\r
 \r
-using System;\r
-using System.Collections.Generic;\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Drawing;\r
-using System.Text;\r
 using System.Windows.Forms;\r
-using System.Threading;\r
 \r
 namespace Handbrake\r
 {\r
index 336b29b..26b5769 100644 (file)
@@ -63,20 +63,19 @@ namespace Handbrake
             // label1\r
             // \r
             this.label1.AutoSize = true;\r
-            this.label1.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label1.Location = new System.Drawing.Point(82, 12);\r
+            this.label1.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label1.Location = new System.Drawing.Point(84, 12);\r
             this.label1.Name = "label1";\r
-            this.label1.Size = new System.Drawing.Size(305, 16);\r
+            this.label1.Size = new System.Drawing.Size(273, 16);\r
             this.label1.TabIndex = 25;\r
             this.label1.Text = "A New Version of Handbrake is available!";\r
             // \r
             // label6\r
             // \r
             this.label6.AutoSize = true;\r
-            this.label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.label6.Location = new System.Drawing.Point(82, 49);\r
             this.label6.Name = "label6";\r
-            this.label6.Size = new System.Drawing.Size(208, 13);\r
+            this.label6.Size = new System.Drawing.Size(175, 13);\r
             this.label6.TabIndex = 30;\r
             this.label6.Text = "Would you like to download it now?";\r
             // \r
@@ -84,6 +83,7 @@ namespace Handbrake
             // \r
             this.btn_skip.AutoSize = true;\r
             this.btn_skip.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.btn_skip.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_skip.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_skip.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_skip.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
@@ -99,6 +99,7 @@ namespace Handbrake
             // \r
             this.btn_installUpdate.AutoSize = true;\r
             this.btn_installUpdate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.btn_installUpdate.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_installUpdate.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_installUpdate.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_installUpdate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
@@ -114,6 +115,7 @@ namespace Handbrake
             // \r
             this.btn_remindLater.AutoSize = true;\r
             this.btn_remindLater.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
+            this.btn_remindLater.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_remindLater.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_remindLater.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_remindLater.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
@@ -128,10 +130,10 @@ namespace Handbrake
             // label3\r
             // \r
             this.label3.AutoSize = true;\r
-            this.label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label3.Location = new System.Drawing.Point(82, 84);\r
+            this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label3.Location = new System.Drawing.Point(84, 87);\r
             this.label3.Name = "label3";\r
-            this.label3.Size = new System.Drawing.Size(103, 13);\r
+            this.label3.Size = new System.Drawing.Size(90, 13);\r
             this.label3.TabIndex = 57;\r
             this.label3.Text = "Release Notes:";\r
             // \r
@@ -148,10 +150,9 @@ namespace Handbrake
             // lbl_update_text\r
             // \r
             this.lbl_update_text.AutoSize = true;\r
-            this.lbl_update_text.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_update_text.Location = new System.Drawing.Point(82, 34);\r
+            this.lbl_update_text.Location = new System.Drawing.Point(84, 36);\r
             this.lbl_update_text.Name = "lbl_update_text";\r
-            this.lbl_update_text.Size = new System.Drawing.Size(489, 13);\r
+            this.lbl_update_text.Size = new System.Drawing.Size(409, 13);\r
             this.lbl_update_text.TabIndex = 58;\r
             this.lbl_update_text.Text = "HandBrake {0.0.0} (000000000) is now available. (You have: {0.0.0} (000000000))";\r
             // \r
index 271e17b..789a620 100644 (file)
@@ -6,40 +6,38 @@
 \r
 using System;\r
 using System.Windows.Forms;\r
-using System.IO;\r
-using System.Xml;\r
-using System.Net;\r
+using Handbrake.Functions;\r
 \r
 namespace Handbrake\r
 {\r
     public partial class frmUpdater : Form\r
     {\r
-        Functions.AppcastReader appcast = new Functions.AppcastReader();\r
-        public frmUpdater()\r
+        AppcastReader appcast;\r
+        public frmUpdater(AppcastReader reader)\r
         {\r
             InitializeComponent();\r
 \r
-            appcast.getInfo(); // Initializes the appcast\r
+            appcast = reader;\r
             getRss();\r
             setVersions();\r
         }\r
 \r
         private void getRss()\r
         {\r
-            wBrowser.DocumentText = "<font face=\"verdana\" size=\"1\">" + appcast.versionInfo() + "</font>";\r
+            wBrowser.Url = appcast.descriptionUrl;\r
         }\r
 \r
         private void setVersions()\r
         {\r
             string old = "(You have: " + Properties.Settings.Default.hb_version.Trim() + " / " + Properties.Settings.Default.hb_build.ToString().Trim() + ")";\r
-            string newBuild = appcast.version().Trim() + " (" + appcast.build() + ")";\r
+            string newBuild = appcast.version.Trim() + " (" + appcast.build + ")";\r
             lbl_update_text.Text = "HandBrake " + newBuild + " is now available. " + old;\r
         }\r
 \r
         private void btn_installUpdate_Click(object sender, EventArgs e)\r
         {\r
-            frmDownload download = new frmDownload(appcast.downloadFile());\r
-            download.Show();\r
+            frmDownload download = new frmDownload(appcast.downloadFile);\r
+            download.ShowDialog();\r
             this.Close();\r
         }\r
 \r
@@ -50,7 +48,7 @@ namespace Handbrake
 \r
         private void btn_skip_Click(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.skipversion = int.Parse(appcast.build());\r
+            Properties.Settings.Default.skipversion = int.Parse(appcast.build);\r
             Properties.Settings.Default.Save();\r
 \r
             this.Close();\r
diff --git a/win/C#/libraries/Growl.Connector.dll b/win/C#/libraries/Growl.Connector.dll
new file mode 100644 (file)
index 0000000..22ddf6c
Binary files /dev/null and b/win/C#/libraries/Growl.Connector.dll differ
diff --git a/win/C#/libraries/Growl.CoreLibrary.dll b/win/C#/libraries/Growl.CoreLibrary.dll
new file mode 100644 (file)
index 0000000..6a05d90
Binary files /dev/null and b/win/C#/libraries/Growl.CoreLibrary.dll differ