summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 13:05:49 +0000
committerhandbrake <[email protected]>2006-01-14 13:05:49 +0000
commit5824c4979fbc54ae3d3015c07cbf6fa4aea7516d (patch)
tree49ba3bbe1f8d8166fa4f7f964055d4011d2deca0 /test
parentf013e3544c0bdf17348d617a467af0e4fde0f545 (diff)
HandBrake 0.5
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test')
-rw-r--r--test/Test.cpp265
-rw-r--r--test/test.c237
2 files changed, 237 insertions, 265 deletions
diff --git a/test/Test.cpp b/test/Test.cpp
deleted file mode 100644
index 4567f74b6..000000000
--- a/test/Test.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/* $Id: Test.cpp,v 1.8 2003/10/13 10:58:24 titer Exp $
-
- This file is part of the HandBrake source code.
- Homepage: <http://beos.titer.org/handbrake/>.
- It may be used under the terms of the GNU General Public License. */
-
-#include <signal.h>
-
-#include "Manager.h"
-
-volatile bool die;
-
-void SigHandler( int signal )
-{
- die = true;
-}
-
-int main( int argc, char ** argv )
-{
- die = false;
-
- /* Exit ASAP on Ctrl-C */
- signal( SIGINT, SigHandler );
-
- /* Default values */
- bool debug = false;
- char * device = NULL;
- char * outputFile = NULL;
- int titleIdx = 1;
- int audio1Idx = 1;
- int audio2Idx = 0;
- bool twoPass = false;
- bool deinterlace = false;
- int width = 0;
- int topCrop = 0;
- int bottomCrop = 0;
- int leftCrop = 0;
- int rightCrop = 0;
- int cpuCount = 0;
- int vBitrate = 1024;
- int aBitrate = 128;
-
- /* Parse command line */
- int c;
- while( ( c = getopt( argc, argv, "vd:o:t:a:b:piw:j:k:l:m:c:e:f:" ) ) != -1 )
- {
- switch( c )
- {
- case 'v':
- debug = true;
- break;
-
- case 'd':
- device = strdup( optarg );
- break;
-
- case 'o':
- outputFile = strdup( optarg );
- break;
-
- case 't':
- titleIdx = atoi( optarg );
- break;
-
- case 'a':
- audio1Idx = atoi( optarg );
- break;
-
- case 'b':
- audio2Idx = atoi( optarg );
- break;
-
- case 'p':
- twoPass = true;
- break;
-
- case 'i':
- deinterlace = true;
- break;
-
- case 'w':
- width = atoi( optarg );
- break;
-
- case 'j':
- topCrop = atoi( optarg );
- break;
-
- case 'k':
- bottomCrop = atoi( optarg );
- break;
-
- case 'l':
- leftCrop = atoi( optarg );
- break;
-
- case 'm':
- rightCrop = atoi( optarg );
- break;
-
- case 'c':
- cpuCount = atoi( optarg );
- break;
-
- case 'e':
- vBitrate = atoi( optarg );
- break;
-
- case 'f':
- aBitrate = atoi( optarg );
- break;
-
- default:
- break;
- }
- }
-
- /* Check parsed options */
- if( !device || !outputFile )
- {
- fprintf( stderr,
- "Syntax: HBTest [options] -d <device> -o <file>\n"
- "Possible options are :\n"
- " -v verbose output\n"
- " -t <value> select a title (default is 1)\n"
- " -a <value> primary audio channel (default is 1)\n"
- " -b <value> secondary audio channel (default is none)\n"
- " -p 2-pass encoding\n"
- " -i deinterlace picture\n"
- " -w output width\n"
- " -j <value> top cropping\n"
- " -k <value> bottom cropping\n"
- " -l <value> left cropping\n"
- " -m <value> right cropping\n"
- " -c <value> CPU count\n"
- " -e <value> Video bitrate (default is 1024)\n"
- " -f <value> Audio bitrate (default is 128)\n" );
- return 1;
- }
-
- /* Create the manager thread */
- HBManager * manager = new HBManager( debug, cpuCount );
-
- /* Tell the manager to scan the specified volume */
- manager->ScanVolumes( device );
-
- HBStatus status;
- while( !die )
- {
- if( !manager->NeedUpdate() )
- {
- Snooze( 10000 );
- continue;
- }
-
- status = manager->GetStatus();
-
- switch( status.fMode )
- {
- case HB_MODE_UNDEF:
- break;
-
- case HB_MODE_SCANNING:
- if( !status.fScannedTitle )
- {
- fprintf( stderr, "Scanning %s\n",
- status.fScannedVolume );
- }
- else
- {
- fprintf( stderr, "Scanning %s, title %d\n",
- status.fScannedVolume,
- status.fScannedTitle );
- }
- break;
-
- case HB_MODE_READY_TO_RIP:
- {
- /* Find the title */
- HBTitle * title = NULL;
- for( uint32_t i = 0; i < status.fTitleList->CountItems(); i++ )
- {
- title = (HBTitle*) status.fTitleList->ItemAt( i );
- if( title->fIndex == titleIdx )
- {
- break;
- }
- else
- {
- title = NULL;
- }
- }
-
- if( !title )
- {
- fprintf( stderr, "Error: unvalid title. Possible "
- "choices are: " );
- for( uint32_t i = 0;
- i < status.fTitleList->CountItems(); i++ )
- {
- title = (HBTitle*) status.fTitleList->ItemAt( i );
- fprintf( stderr, "%d%s", title->fIndex,
- ( i == status.fTitleList->CountItems() - 1 )
- ? ".\n" : ", " );
- }
- die = true;
- break;
- }
- title->fTwoPass = twoPass;
- title->fDeinterlace = deinterlace;
- if( width ) title->fOutWidth = width;
- title->fTopCrop = topCrop;
- title->fBottomCrop = bottomCrop;
- title->fLeftCrop = leftCrop;
- title->fRightCrop = rightCrop;
- title->fBitrate = vBitrate;
-
- HBAudio * audio1 =
- (HBAudio*) title->fAudioList->ItemAt( audio1Idx - 1 );
- HBAudio * audio2 =
- (HBAudio*) title->fAudioList->ItemAt( audio2Idx - 1 );
- if( audio1 ) audio1->fOutBitrate = aBitrate;
- if( audio2 ) audio2->fOutBitrate = aBitrate;
-
- manager->StartRip( title, audio1, audio2, outputFile );
- break;
- }
-
- case HB_MODE_ENCODING:
- fprintf( stderr, "Progress = %.2f %%, %.2f fps "
- "(%02d:%02d:%02d remaining)\n",
- 100 * status.fPosition, status.fFrameRate,
- status.fRemainingTime / 3600,
- ( status.fRemainingTime % 3600 ) / 60,
- status.fRemainingTime % 60 );
- break;
-
- case HB_MODE_DONE:
- fprintf( stderr, "Done\n" );
- die = true;
- break;
-
- case HB_MODE_CANCELED:
- fprintf( stderr, "Canceled\n" );
- die = true;
- break;
-
- case HB_MODE_ERROR:
- fprintf( stderr, "Error\n" );
- die = true;
- break;
-
- default:
- break;
- }
- }
-
- delete manager;
-
- if( device ) free( device );
- if( outputFile ) free( outputFile );
-
- return 0;
-}
-
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 000000000..ec576cbb3
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,237 @@
+/* $Id: test.c,v 1.5 2003/11/06 13:28:07 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.m0k.org/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#include <signal.h>
+
+#include "HandBrake.h"
+
+volatile int die;
+
+void SigHandler( int signal )
+{
+ die = 1;
+}
+
+int main( int argc, char ** argv )
+{
+ int c;
+ HBHandle * h;
+ HBStatus s;
+
+ /* Default values */
+ int debug = 1;
+ char * device = NULL;
+ char * file = NULL;
+ int titleIdx = 1;
+ int audio1Idx = 1;
+ int audio2Idx = 0;
+ int twoPass = 0;
+ int deinterlace = 0;
+ int width = 0;
+ int topCrop = 0;
+ int bottomCrop = 0;
+ int leftCrop = 0;
+ int rightCrop = 0;
+ int cpuCount = 0;
+ int vBitrate = 1024;
+ int aBitrate = 128;
+ int xvid = 0;
+
+ die = 0;
+
+ /* Exit ASAP on Ctrl-C */
+ signal( SIGINT, SigHandler );
+
+ /* Parse command line */
+ while( ( c = getopt( argc, argv, "qd:o:t:a:b:piw:j:k:l:m:c:e:f:x" ) ) != -1 )
+ {
+ switch( c )
+ {
+ case 'q':
+ debug = 0;
+ break;
+
+ case 'd':
+ device = strdup( optarg );
+ break;
+
+ case 'o':
+ file = strdup( optarg );
+ break;
+
+ case 't':
+ titleIdx = atoi( optarg );
+ break;
+
+ case 'a':
+ audio1Idx = atoi( optarg );
+ break;
+
+ case 'b':
+ audio2Idx = atoi( optarg );
+ break;
+
+ case 'p':
+ twoPass = 1;
+ break;
+
+ case 'i':
+ deinterlace = 1;
+ break;
+
+ case 'w':
+ width = atoi( optarg );
+ break;
+
+ case 'j':
+ topCrop = atoi( optarg );
+ break;
+
+ case 'k':
+ bottomCrop = atoi( optarg );
+ break;
+
+ case 'l':
+ leftCrop = atoi( optarg );
+ break;
+
+ case 'm':
+ rightCrop = atoi( optarg );
+ break;
+
+ case 'c':
+ cpuCount = atoi( optarg );
+ break;
+
+ case 'e':
+ vBitrate = atoi( optarg );
+ break;
+
+ case 'f':
+ aBitrate = atoi( optarg );
+ break;
+
+ case 'x':
+ xvid = 1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* Check parsed options */
+ if( !device || !file )
+ {
+ fprintf( stderr,
+ "Syntax: HBTest [options] -d <device> -o <file>\n"
+ "Possible options are :\n"
+ " -q quiet output\n"
+ " -t <value> select a title (default is 1)\n"
+ " -a <value> primary audio channel (default is 1)\n"
+ " -b <value> secondary audio channel (default is none)\n"
+ " -p 2-pass encoding\n"
+ " -i deinterlace picture\n"
+ " -w output width\n"
+ " -j <value> top cropping\n"
+ " -k <value> bottom cropping\n"
+ " -l <value> left cropping\n"
+ " -m <value> right cropping\n"
+ " -c <value> CPU count (default: autodetected)\n"
+ " -e <value> Video bitrate (default is 1024)\n"
+ " -f <value> Audio bitrate (default is 128)\n"
+ " -x Use XviD instead of Ffmpeg\n" );
+ return 1;
+ }
+
+ /* Create the manager thread */
+ h = HBInit( debug, cpuCount );
+
+ while( !die )
+ {
+ HBSnooze( 100000 );
+
+ if( !HBGetStatus( h, &s ) )
+ continue;
+
+ switch( s.mode )
+ {
+ case HB_MODE_UNDEF:
+ /* Will never happen */
+ break;
+
+ case HB_MODE_NEED_DEVICE:
+ /* Feed libhb with a DVD to scan */
+ HBScanDevice( h, device, titleIdx );
+ break;
+
+ case HB_MODE_SCANNING:
+ /* s.scannedTitle: title scanned at the moment */
+ break;
+
+ case HB_MODE_INVALID_DEVICE:
+ die = 1;
+ break;
+
+ case HB_MODE_READY_TO_RIP:
+ {
+ HBAudio * audio1, * audio2;
+ HBTitle * title = HBListItemAt( s.titleList, 0 );
+
+ title->file = strdup( file );
+ title->twoPass = twoPass;
+ title->deinterlace = deinterlace;
+ if( width ) title->outWidth = width;
+ title->topCrop = topCrop;
+ title->bottomCrop = bottomCrop;
+ title->leftCrop = leftCrop;
+ title->rightCrop = rightCrop;
+ title->bitrate = vBitrate;
+ title->codec = xvid ? HB_CODEC_XVID : HB_CODEC_FFMPEG;
+
+ audio1 = HBListItemAt( title->audioList,
+ audio1Idx - 1 );
+ audio2 = HBListItemAt( title->audioList,
+ audio2Idx - 1 );
+ if( audio1 ) audio1->outBitrate = aBitrate;
+ if( audio2 ) audio2->outBitrate = aBitrate;
+
+ HBStartRip( h, title, audio1, audio2 );
+ break;
+ }
+
+ case HB_MODE_ENCODING:
+ /* s.position : current progress (0.0->1.0)
+ s.frameRate : average framerate
+ s.remainingTime: ... (in seconds) */
+ break;
+
+ case HB_MODE_DONE:
+ die = 1;
+ break;
+
+ case HB_MODE_CANCELED:
+ die = 1;
+ break;
+
+ case HB_MODE_ERROR:
+ /* s.error: error code */
+ die = 1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ HBClose( &h );
+
+ if( device ) free( device );
+ if( file ) free( file );
+
+ return 0;
+}
+