delaycut: cuts and corrects delay in ac3 and dts files
Copyright (C) 2004 by jsoto
Copyright (C) 2007 by madshi
Copyright (C) 2009 by Chumbo
Copyright (C) 2010 by Adam Thomas-Murphy

DelayCut 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 3 of the License, or
(at your option) any later version.

DelayCut 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 DelayCut.  If not, see <http://www.gnu.org/licenses/>.

====================================================================
=============Changelog==============================================

v1.4.3.7
BugFix:      Fix logic for checking valid inputtype when using CLI.
BugFix:      Fixed README and output of -help switch so the updated
             switches are shown properly.

v1.4.3.6
Added:       Added support to specify delay/cut values in audio frames.
Added:       Added "-help" switch to display the options available from CLI.
BugFix:      Fixed so that delay field in GUI worked properly.
BugFix:      Fixed CLI parser for to detect new switches.

v1.4.3.5
Added:       Logging of progress and error messages when using the CLI have been added back.
Changed:     "-console" switch has been removed.  Switches to specify cut points have been renamed to 
             "-startcut" and "-endcut" respectively.  Switches to specify delay values have been renmaed 
             to "-startdelay" and "-enddelay" respectively.  "-i" switch introduced to allow the specifying 
             of the input file path anywhere in the CLI arguments.  "-version" switches introduced to get 
             the current version of the software.

v1.4.3.4
BugFix:      Fix rounding when converting between input types to a round half up scheme.  Also changed
             the calculations for start and end frame to use the same.
BugFix:      Fixed check for enabling the CRC group edit so it enables properly.
BugFix:      Fix bug that where a pathological file caused the processing to never finish and UI hang.
BugFix:      Calculated end frame is capped to the total frames in cases where end split value specified
             exceeds length of file.
Changed:     Renamed "original length" field to "preserve length".
Changed:     End cut value of 0 is treated as end of file when calculating end frame.
Changed:     End cut and start cut values no longer cause the other field to be overwritten.  All checks to make
             sure that end cut is not smaller than start cut, except for the case of 0, happens when process
             button is clicked.

v1.4.3.2
BugFix:      Fix autodelay detection so that it converts ms value in fileName to the selected input type.
BugFix:      Fixed bugs in converting values between different input types.
BugFix:      Fixed math errors when specifying delay in frames.
BugFix:      Fixed bug where output file path wasn't updated when using 'Save As' dialog.

v1.4.3.1
BugFix:      Fix delay fields to properly accept negative delay.
BugFix:      Fix for math when using frames as input type.

v1.4.3.0     
Added:       Add option to select type of input values you want to use for times (millseconds, seconds, frames).
Added:       Added CLI switches to support new input value types.
BugFix:      Stopped debug messagebox from appearing anymore.

v1.4.2.0
BugFix:      Fix for crash when opening files with Unicode characters.

v1.4.1.0
Added:       Add back CLI support.

v1.4.0.0     
BugFix:      Fix automatic delay detection.
Improvement: Fix information text box to use look correct on all platforms.

v1.4.0.0b3
Changed:     Fix so that text in information text box is spaced properly when font size changes.

v1.4.0.0b3
Changed:     Changed UI to use layouts to fix rendering issues when different fonts/font sizes are used.

v1.4.0.0b2
Changed:     Fixed filter passed to filedialogs that caused no files to appear in Linux.

v1.4.0.0b1
Changed:     Rewrite in Qt.  License upgrade to GPLv3.

v1.3.1.0
Changed:     Add support to autofill delay values from filename.

v1.3.0.0
Changed:     Add eac3 support.

v1.2.1.2
BugFix:      Error in duration of Wav files

v1.2.1.1
Changed:     Maximum number of char changed to 8 in delay edit boxes
BugFix:      Spaces in output path (CLI mode)

v1.2.1.0
Added:       44.1kHz and 32 kHz  ac3 support (suggested by tebasuna51)
Improvement: In case of unsynchronized frame, rewind one frame more to look for the synch word inside the previous
             frame. (suggested by tebasuna51)
Changed:     AC3 silence frames are now calculated from only two patterns (2/0 and 5.1)

v1.2.0.4
Added:       Linear PCM (wav) support
Added:       mpa checksum calculation and fixing.
Added:       44.100 mpa minimum support. (short delays)
BugFix:      Percentage dlg refresh 
BugFix:      Different rate frames in dts caused delaycut to hang

v1.2.0.3
BugFix:      -auto option in CLI mode was broken

v1.2.0.2
BugFix:      mpa was broken in 1.2.0.1
BugFix:      Info dlg refresh.

v1.2.0.1
Added:       mpa (fsample=48k) support.
Added:       drag/drop files
Added:       -auto option in CLI mode: autodetect the delay in input filename 
Added:       -out option in CLI mode to specify the output filename.

v1.1.0.4
BugFix:      dts has been completely broken in 1.1.0.3 but nobody reported it????

v1.1.0.3
Improvement: Using fread and fwrite functions, delaycut is much faster than before.
Changed:     Log window automaticaly scrolls to the end

v1.1.0.2
BugFix:      Some erroneous files can hang delaycut

v1.1
Bugfix:      Makelower in file extensions 
Bugfix:      Only one message in the case of basic parameters change


====================================================================

Command Line Instructions
Output and log files will be in the same path than the input file.

Options:
-help:                 List options.
-version:              Get current version.
-info:                 Outputs info about input file in log file
-inputtype <string>:   Input type of delay/cut values. (default millseconds 
                       when not specified) [milliseconds, seconds, videoframes]
-fps <float|rational>: Specify frame rate.
                       Needed when inputtype is set to frames. 
-fixcrc <string>:      Specify action to take in the case of crc errors
                       [ignore, skip, fix, silence]
-startdelay <integer>: Specify the needed frames added at the beginning of the file
-enddelay <integer>:   Specify the needed frames added at the end of the file
-same:                 file length will be the same after adding delay
-auto:                 detect start delay in filename (assuming DVD2AVI style)
-startcut <integer>:   Specify cut start point
-cutEnd <integer>:     Specify cut end point
-o <string>:           specify output file
-i <string>:           specify inputfile

Return values
0: Success
1: Something went wrong.

Examples:
Get info: Log file will be myfile_log.txt
    delaycut -info -i myfile.ac3

Adds 100 msec of silence at the begining. File lenght will be the same
    delaycut -startdelay 100 -same -i myfile.ac3

Adds 100 msec of silence at the begining. File lenght will be 100 msecs more
    delaycut -startdelay 100 -i myfile.ac3

Cuts start at 10.32 sec and ends at 15.20 sec.
    delaycut -inputtype seconds -startcut 10.32 -endcut 15.20 -i myfile.ac3

Cuts start at 10320 msec and ends at 15200 msec. Delay correction of 100 msec.
    delaycut -startdelay 100 -startcut 10320 -endcut 15200 -i myfile.ac3
