summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 13:27:00 +0000
committerhandbrake <[email protected]>2006-01-14 13:27:00 +0000
commitb69e82fd960103c41979e00beb9b1c9fac78083b (patch)
tree264c5b637fd261c67d17e1d3649d4526c585e663 /core
parent951be4e0b69aa652c992124025c862c4f1660937 (diff)
HandBrake 0.6.0-test3
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@12 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'core')
-rw-r--r--core/Ac3Dec.c8
-rw-r--r--core/Fifo.c17
-rw-r--r--core/HBInternal.h4
-rw-r--r--core/HandBrake.c42
-rw-r--r--core/Jamfile3
-rw-r--r--core/LpcmDec.c148
-rw-r--r--core/Mp4Mux.c4
-rw-r--r--core/OgmMux.c4
-rw-r--r--core/Scale.c114
-rw-r--r--core/Scan.c19
-rw-r--r--core/Thread.c4
-rw-r--r--core/Utils.c20
-rw-r--r--core/Utils.h14
-rw-r--r--core/VorbisEnc.c17
14 files changed, 351 insertions, 67 deletions
diff --git a/core/Ac3Dec.c b/core/Ac3Dec.c
index e1b027887..3fb4cc0ae 100644
--- a/core/Ac3Dec.c
+++ b/core/Ac3Dec.c
@@ -1,4 +1,4 @@
-/* $Id: Ac3Dec.c,v 1.12 2004/01/16 19:04:03 titer Exp $
+/* $Id: Ac3Dec.c,v 1.13 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -58,13 +58,13 @@ HBWork * HBAc3DecInit( HBHandle * handle, HBAudio * audio )
/* Let it do the downmixing */
a->outFlags = A52_STEREO;
- if( audio->codec == HB_CODEC_MP3 )
+ if( audio->outCodec == HB_CODEC_MP3 )
/* Lame wants 16 bits samples */
a->sampleLevel = 32768.0;
- else if( audio->codec == HB_CODEC_AAC )
+ else if( audio->outCodec == HB_CODEC_AAC )
/* Faac wants 24 bits samples */
a->sampleLevel = 8388608.0;
- else if( audio->codec == HB_CODEC_VORBIS )
+ else if( audio->outCodec == HB_CODEC_VORBIS )
/* Vorbis wants FIXME bits samples */
a->sampleLevel = 32768.0;
diff --git a/core/Fifo.c b/core/Fifo.c
index 06aed08cb..7e7433e01 100644
--- a/core/Fifo.c
+++ b/core/Fifo.c
@@ -1,10 +1,13 @@
-/* $Id: Fifo.c,v 1.9 2004/02/24 21:55:53 titer Exp $
+/* $Id: Fifo.c,v 1.12 2004/03/04 17:35:52 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 "Fifo.h"
+#if defined( HB_BEOS ) || defined( HB_LINUX )
+#include <malloc.h>
+#endif
HBBuffer * HBBufferInit( int size )
{
@@ -45,15 +48,19 @@ HBBuffer * HBBufferInit( int size )
void HBBufferReAlloc( HBBuffer * b, int size )
{
- b->alloc = size;
#if defined( HB_BEOS ) || defined( HB_LINUX )
b->data = realloc( b->data, size );
#elif defined( HB_MACOSX )
- b->dataOrig = realloc( b->dataOrig, size );
- b->data = b->dataOrig;
+ /* Ugly */
+ uint8_t * new = malloc( size );
+ memcpy( new, b->data, b->size );
+ free( b->dataOrig );
+ b->dataOrig = new;
+ b->data = new;
#elif defined( HB_CYGWIN )
/* TODO */
#endif
+ b->alloc = size;
if( !b->data )
{
@@ -106,8 +113,10 @@ HBFifo * HBFifoInit( int capacity )
void HBFifoDie( HBFifo * f )
{
+ HBLockLock( f->lock );
f->die = 1;
HBCondSignal( f->cond );
+ HBLockUnlock( f->lock );
}
void HBFifoClose( HBFifo ** _f )
diff --git a/core/HBInternal.h b/core/HBInternal.h
index 169451980..a8adb4d44 100644
--- a/core/HBInternal.h
+++ b/core/HBInternal.h
@@ -1,4 +1,4 @@
-/* $Id: HBInternal.h,v 1.4 2004/01/16 20:55:21 titer Exp $
+/* $Id: HBInternal.h,v 1.5 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -21,6 +21,8 @@ HBWork * HBMpeg2DecInit( HBHandle *, HBTitle * );
void HBMpeg2DecClose( HBWork ** );
HBWork * HBAc3DecInit( HBHandle *, HBAudio * );
void HBAc3DecClose( HBWork ** );
+HBWork * HBLpcmDecInit( HBHandle *, HBAudio * );
+void HBLpcmDecClose( HBWork ** );
HBWork * HBMadDecInit( HBHandle *, HBAudio * );
void HBMadDecClose( HBWork ** );
diff --git a/core/HandBrake.c b/core/HandBrake.c
index 010f1a3cf..5eca5a78d 100644
--- a/core/HandBrake.c
+++ b/core/HandBrake.c
@@ -1,4 +1,4 @@
-/* $Id: HandBrake.c,v 1.42 2004/02/18 17:07:20 titer Exp $
+/* $Id: HandBrake.c,v 1.44 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -147,12 +147,16 @@ void HBStartRip( HBHandle * h, HBTitle * title )
audio->outFifo = HBFifoInit( 4 ); /* At least 4 for Vorbis */
/* Audio work objects */
- audio->decoder = HBAc3DecInit( h, audio );
- if( audio->codec == HB_CODEC_MP3 )
+ if( audio->inCodec == HB_CODEC_AC3 )
+ audio->decoder = HBAc3DecInit( h, audio );
+ else if( audio->inCodec == HB_CODEC_LPCM )
+ audio->decoder = HBLpcmDecInit( h, audio );
+
+ if( audio->outCodec == HB_CODEC_MP3 )
audio->encoder = HBMp3EncInit( h, audio );
- else if( audio->codec == HB_CODEC_AAC )
+ else if( audio->outCodec == HB_CODEC_AAC )
audio->encoder = HBFaacEncInit( h, audio );
- else if( audio->codec == HB_CODEC_VORBIS )
+ else if( audio->outCodec == HB_CODEC_VORBIS )
audio->encoder = HBVorbisEncInit( h, audio );
}
@@ -551,6 +555,13 @@ static void _StopRip( HBHandle * h )
HBAudio * audio;
int i;
+ /* Stop input and work threads */
+ HBDVDReadClose( &title->dvdRead );
+ for( i = 0; i < h->cpuCount; i++ )
+ {
+ HBWorkThreadClose( &title->workThreads[h->cpuCount-i-1] );
+ }
+
/* Invalidate fifos */
HBFifoDie( title->outFifo );
for( i = 0; i < HBListCount( title->ripAudioList ); i++ )
@@ -559,9 +570,7 @@ static void _StopRip( HBHandle * h )
HBFifoDie( audio->outFifo );
}
- /* Stop threads */
- HBDVDReadClose( &title->dvdRead );
-
+ /* Stop mux thread */
if( title->mux == HB_MUX_AVI )
HBAviMuxClose( &title->aviMux );
else if( title->mux == HB_MUX_MP4 )
@@ -569,11 +578,6 @@ static void _StopRip( HBHandle * h )
else if( title->mux == HB_MUX_OGM )
HBOgmMuxClose( &title->ogmMux );
- for( i = 0; i < h->cpuCount; i++ )
- {
- HBWorkThreadClose( &title->workThreads[h->cpuCount-i-1] );
- }
-
/* Clean up */
HBMpeg2DecClose( &title->decoder );
HBScaleClose( &title->scale );
@@ -595,12 +599,16 @@ static void _StopRip( HBHandle * h )
audio = HBListItemAt( title->ripAudioList, i );
/* Audio work objects */
- HBAc3DecClose( &audio->decoder );
- if( audio->codec == HB_CODEC_MP3 )
+ if( audio->inCodec == HB_CODEC_AC3 )
+ HBAc3DecClose( &audio->decoder );
+ else if( audio->inCodec == HB_CODEC_LPCM )
+ HBLpcmDecClose( &audio->decoder );
+
+ if( audio->outCodec == HB_CODEC_MP3 )
HBMp3EncClose( &audio->encoder );
- else if( audio->codec == HB_CODEC_AAC )
+ else if( audio->outCodec == HB_CODEC_AAC )
HBFaacEncClose( &audio->encoder );
- else if( audio->codec == HB_CODEC_VORBIS )
+ else if( audio->outCodec == HB_CODEC_VORBIS )
HBVorbisEncClose( &audio->encoder );
/* Audio fifos */
diff --git a/core/Jamfile b/core/Jamfile
index d33688722..949e24388 100644
--- a/core/Jamfile
+++ b/core/Jamfile
@@ -1,4 +1,4 @@
-# $Id: Jamfile,v 1.5 2004/01/16 19:04:04 titer Exp $
+# $Id: Jamfile,v 1.6 2004/03/08 11:32:48 titer Exp $
#
# This file is part of the HandBrake source code.
# Homepage: <http://handbrake.m0k.org/>.
@@ -14,6 +14,7 @@ FaacEnc.c
FfmpegEnc.c
Fifo.c
HandBrake.c
+LpcmDec.c
MadDec.c
Mp3Enc.c
Mp4Mux.c
diff --git a/core/LpcmDec.c b/core/LpcmDec.c
new file mode 100644
index 000000000..53b56d8f2
--- /dev/null
+++ b/core/LpcmDec.c
@@ -0,0 +1,148 @@
+/* $Id: LpcmDec.c,v 1.1 2004/03/08 11:32:48 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 "HBInternal.h"
+
+typedef struct HBLpcmDec
+{
+ HB_WORK_COMMON_MEMBERS
+
+ HBHandle * handle;
+ HBAudio * audio;
+
+ int initDone;
+ int channels;
+ float sampleLevel;
+ HBBuffer * rawBuffer;
+} HBLpcmDec;
+
+/* Local prototypes */
+static int LpcmDecWork( HBWork * );
+
+HBWork * HBLpcmDecInit( HBHandle * handle, HBAudio * audio )
+{
+ HBLpcmDec * l;
+ if( !( l = calloc( sizeof( HBLpcmDec ), 1 ) ) )
+ {
+ HBLog( "HBLpcmDecInit: malloc() failed, gonna crash" );
+ return NULL;
+ }
+
+ l->name = strdup( "LpcmDec" );
+ l->work = LpcmDecWork;
+
+ l->handle = handle;
+ l->audio = audio;
+
+ if( audio->outCodec & ( HB_CODEC_MP3 | HB_CODEC_VORBIS ) )
+ {
+ /* 16 bits samples */
+ l->sampleLevel = 1.0;
+ }
+ else if( audio->outCodec & HB_CODEC_AAC )
+ {
+ /* 24 bits samples */
+ l->sampleLevel = 256.0;
+ }
+
+ return (HBWork*) l;
+}
+
+void HBLpcmDecClose( HBWork ** _l )
+{
+ HBLpcmDec * l = (HBLpcmDec*) *_l;
+
+ /* Clean up */
+ if( l->rawBuffer )
+ {
+ HBBufferClose( &l->rawBuffer );
+ }
+ free( l->name );
+ free( l );
+
+ *_l = NULL;
+}
+
+static int LpcmDecWork( HBWork * w )
+{
+ HBLpcmDec * l = (HBLpcmDec*) w;
+ HBAudio * audio = l->audio;
+ HBBuffer * lpcmBuffer;
+ int16_t * int16data;
+
+ int i;
+ int samples;
+ int didSomething = 0;
+
+ /* Push decoded buffer */
+ if( l->rawBuffer )
+ {
+ if( HBFifoPush( audio->rawFifo, &l->rawBuffer ) )
+ {
+ didSomething = 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ /* Get a new LPCM buffer */
+ lpcmBuffer = HBFifoPop( audio->inFifo );
+ if( !lpcmBuffer )
+ {
+ return didSomething;
+ }
+
+ if( !l->initDone )
+ {
+ /* SampleRate */
+ switch( ( lpcmBuffer->data[4] >> 4 ) & 0x3 )
+ {
+ case 0:
+ audio->inSampleRate = 48000;
+ break;
+ case 1:
+ audio->inSampleRate = 32000;
+ break;
+ default:
+ HBLog( "LpcmDec: unknown samplerate (%d)",
+ ( lpcmBuffer->data[4] >> 4 ) & 0x3 );
+ }
+ HBLog( "LpcmDec: samplerate = %d Hz", audio->inSampleRate );
+
+ /* Channels */
+ HBLog( "LpcmDec: %d channels",
+ ( lpcmBuffer->data[4] & 0x7 ) + 1 );
+
+ l->initDone = 1;
+ }
+
+ if( lpcmBuffer->data[5] != 0x80 )
+ {
+ HBLog( "LpcmDec: no frame synx (%02x�", lpcmBuffer->data[5] );
+ }
+
+ samples = ( lpcmBuffer->size - 6 ) / sizeof( int16_t ) / 2;
+ int16data = (int16_t*) ( lpcmBuffer->data + 6 );
+
+ l->rawBuffer = HBBufferInit( samples * sizeof( float ) * 2 );
+ l->rawBuffer->left = (float*) l->rawBuffer->data;
+ l->rawBuffer->right = l->rawBuffer->left + samples;
+ l->rawBuffer->position = lpcmBuffer->position;
+ l->rawBuffer->samples = samples;
+
+ for( i = 0; i < samples; i++ )
+ {
+ l->rawBuffer->left[i] = (float) int16data[2*i] * l->sampleLevel;
+ l->rawBuffer->right[i] = (float) int16data[2*i+1] * l->sampleLevel;
+ }
+
+ HBBufferClose( &lpcmBuffer );
+
+ return 1;
+}
+
diff --git a/core/Mp4Mux.c b/core/Mp4Mux.c
index e1b8e9e64..c545c96fc 100644
--- a/core/Mp4Mux.c
+++ b/core/Mp4Mux.c
@@ -1,4 +1,4 @@
-/* $Id: Mp4Mux.c,v 1.23 2004/02/18 19:36:35 titer Exp $
+/* $Id: Mp4Mux.c,v 1.24 2004/03/08 13:42:29 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -195,11 +195,13 @@ static void Mp4MuxThread( void * _m )
MP4Close( file );
+ HBLog( "HBMp4Mux: making the file ISMA compliant" );
if( !MP4MakeIsmaCompliant( title->file, 0 /*MP4_DETAILS_ALL*/, 1 ) )
{
HBLog( "HBMp4Mux: MP4MakeIsmaCompliant() failed" );
}
+ HBLog( "HBMp4Mux: optimizing" );
sprintf( tmpFile, "%s.tmp", title->file );
tmpFile[strlen( title->file ) + 4] = '\0';
if( !MP4Optimize( title->file, tmpFile, 0 /*MP4_DETAILS_ALL*/ ) )
diff --git a/core/OgmMux.c b/core/OgmMux.c
index d4712594b..fef1ae01b 100644
--- a/core/OgmMux.c
+++ b/core/OgmMux.c
@@ -1,4 +1,4 @@
-/* $Id: OgmMux.c,v 1.6 2004/02/13 15:12:09 titer Exp $
+/* $Id: OgmMux.c,v 1.7 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -303,7 +303,7 @@ static int OgmStart( HBOgmMux *ogm )
{
HBAudio *audio = HBListItemAt( title->ripAudioList, i - 1 );
- ogm->tk[i].codec = audio->codec;
+ ogm->tk[i].codec = audio->outCodec;
ogm->tk[i].fifo = audio->outFifo;
ogm->tk[i].i_packet_no = 0;
ogg_stream_init (&ogm->tk[i].os, i );
diff --git a/core/Scale.c b/core/Scale.c
index 464623c1e..527882539 100644
--- a/core/Scale.c
+++ b/core/Scale.c
@@ -1,4 +1,4 @@
-/* $Id: Scale.c,v 1.9 2004/01/16 19:39:23 titer Exp $
+/* $Id: Scale.c,v 1.10 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -6,7 +6,11 @@
#include "HBInternal.h"
+#define USE_FFMPEG
+
+#ifdef USE_FFMPEG
#include "ffmpeg/avcodec.h"
+#endif
typedef struct HBScale
{
@@ -15,16 +19,25 @@ typedef struct HBScale
HBHandle * handle;
HBTitle * title;
+ HBBuffer * deintBuffer;
+ HBList * scaledBufferList;
+#ifdef USE_FFMPEG
ImgReSampleContext * context;
AVPicture rawPicture;
- HBBuffer * deintBuffer;
AVPicture deintPicture;
- HBList * scaledBufferList;
AVPicture scaledPicture;
+#endif
} HBScale;
/* Local prototypes */
static int ScaleWork( HBWork * );
+#ifndef USE_FFMPEG
+static void Deinterlace( uint8_t * in, uint8_t * out, int w, int h,
+ int tcrop, int bcrop, int lcrop, int rcrop );
+static void Resample( uint8_t * in, uint8_t * out, int oldw, int oldh,
+ int neww, int newh, int tcrop, int bcrop,
+ int lcrop, int rcrop );
+#endif
HBWork * HBScaleInit( HBHandle * handle, HBTitle * title )
{
@@ -41,18 +54,21 @@ HBWork * HBScaleInit( HBHandle * handle, HBTitle * title )
s->handle = handle;
s->title = title;
+ /* Allocate a constant buffer used for deinterlacing */
+ s->deintBuffer = HBBufferInit( 3 * title->inWidth *
+ title->inHeight / 2 );
+
+#ifdef USE_FFMPEG
+ avpicture_fill( &s->deintPicture, s->deintBuffer->data,
+ PIX_FMT_YUV420P, title->inWidth, title->inHeight );
+
/* Init libavcodec */
s->context =
img_resample_full_init( title->outWidth, title->outHeight,
title->inWidth, title->inHeight,
title->topCrop, title->bottomCrop,
title->leftCrop, title->rightCrop );
-
- /* Allocate a constant buffer used for deinterlacing */
- s->deintBuffer = HBBufferInit( 3 * title->inWidth *
- title->inHeight / 2 );
- avpicture_fill( &s->deintPicture, s->deintBuffer->data,
- PIX_FMT_YUV420P, title->inWidth, title->inHeight );
+#endif
s->scaledBufferList = HBListInit();
@@ -63,7 +79,9 @@ void HBScaleClose( HBWork ** _s )
{
HBScale * s = (HBScale*) *_s;
+#ifdef USE_FFMPEG
img_resample_close( s->context );
+#endif
HBListClose( &s->scaledBufferList );
HBBufferClose( &s->deintBuffer );
free( s->name );
@@ -79,6 +97,10 @@ static int ScaleWork( HBWork * w )
HBBuffer * rawBuffer;
HBBuffer * scaledBuffer;
HBBuffer * tmpBuffer;
+#ifndef USE_FFMPEG
+ uint8_t * in, * out;
+ int plane, shift;
+#endif
int didSomething = 0;
@@ -114,6 +136,7 @@ static int ScaleWork( HBWork * w )
scaledBuffer->position = rawBuffer->position;
scaledBuffer->pass = rawBuffer->pass;
+#ifdef USE_FFMPEG
/* libavcodec stuff */
avpicture_fill( &s->rawPicture, rawBuffer->data, PIX_FMT_YUV420P,
title->inWidth, title->inHeight );
@@ -134,6 +157,39 @@ static int ScaleWork( HBWork * w )
{
img_resample( s->context, &s->scaledPicture, &s->rawPicture );
}
+#else
+ if( title->deinterlace )
+ {
+ in = rawBuffer->data;
+ out = s->deintBuffer->data;
+ for( plane = 0; plane < 3; plane++ )
+ {
+ shift = plane ? 1 : 0;
+ Deinterlace( in, out, title->inWidth >> shift,
+ title->inHeight >> shift,
+ title->topCrop >> shift,
+ title->bottomCrop >> shift,
+ title->leftCrop >> shift,
+ title->rightCrop >> shift );
+ in += title->inWidth * title->inHeight >> ( 2 * shift );
+ out += title->inWidth * title->inHeight >> ( 2 * shift );
+ }
+ }
+
+ in = title->deinterlace ? s->deintBuffer->data : rawBuffer->data;
+ out = scaledBuffer->data;
+ for( plane = 0; plane < 3; plane++ )
+ {
+ shift = plane ? 1 : 0;
+ Resample( in, out, title->inWidth >> shift,
+ title->inHeight >> shift, title->outWidth >> shift,
+ title->outHeight >> shift, title->topCrop >> shift,
+ title->bottomCrop >> shift, title->leftCrop >> shift,
+ title->rightCrop >> shift );
+ in += title->inWidth * title->inHeight >> ( 2 * shift );
+ out += title->outWidth * title->outHeight >> ( 2 * shift );;
+ }
+#endif
HBListAdd( s->scaledBufferList, scaledBuffer );
@@ -154,3 +210,43 @@ static int ScaleWork( HBWork * w )
return didSomething;
}
+#ifndef USE_FFMPEG
+static void Deinterlace( uint8_t * in, uint8_t * out, int w, int h,
+ int tcrop, int bcrop, int lcrop, int rcrop )
+{
+ int i, j;
+
+ /* First line */
+ if( !tcrop )
+ {
+ memcpy( out, in + lcrop, w - lcrop - rcrop );
+ }
+
+ /* Merge lines */
+ for( i = MAX( 1, tcrop ); i < h - bcrop; i++ )
+ {
+ for( j = lcrop; j < w - rcrop; j++ )
+ {
+ out[i*w+j] = ( in[(i-1)*w+j] + in[i*w+j] ) / 2;
+ }
+ }
+}
+
+static void Resample( uint8_t * in, uint8_t * out, int oldw, int oldh,
+ int neww, int newh, int tcrop, int bcrop,
+ int lcrop, int rcrop )
+{
+ int i, j;
+ int cropw = oldw - lcrop - rcrop;
+ int croph = oldh - tcrop - bcrop;
+ for( i = 0; i < newh; i++ )
+ {
+ for( j = 0; j < neww; j++ )
+ {
+ out[i*neww+j] = in[(tcrop+i*croph/newh)*oldw +
+ lcrop+j*cropw/neww];
+ }
+ }
+}
+#endif
+
diff --git a/core/Scan.c b/core/Scan.c
index f2afd5e6c..8f19a138d 100644
--- a/core/Scan.c
+++ b/core/Scan.c
@@ -1,4 +1,4 @@
-/* $Id: Scan.c,v 1.14 2004/01/18 13:21:12 titer Exp $
+/* $Id: Scan.c,v 1.15 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -149,7 +149,7 @@ static HBTitle * ScanTitle( HBScan * s, dvdplay_ptr vmg, int index )
for( i = 0; i < audio_nr; i++ )
{
- int id, j;
+ int id, j, codec;
if( s->die )
{
@@ -163,10 +163,18 @@ static HBTitle * ScanTitle( HBScan * s, dvdplay_ptr vmg, int index )
continue;
}
- if( ( id & 0xF0FF ) != 0x80BD )
+ if( ( id & 0xF0FF ) == 0x80BD )
{
- HBLog( "HBScan: title %d: non-AC3 audio track detected, "
- "ignoring", index );
+ codec = HB_CODEC_AC3;
+ }
+ else if( ( id & 0xF0FF ) == 0xA0BD )
+ {
+ codec = HB_CODEC_LPCM;
+ }
+ else
+ {
+ HBLog( "HBScan: title %d: unknown audio codec (%x), "
+ "ignoring", index, id );
continue;
}
@@ -194,6 +202,7 @@ static HBTitle * ScanTitle( HBScan * s, dvdplay_ptr vmg, int index )
attr = dvdplay_audio_attr( vmg, j );
audio = HBAudioInit( id, LanguageForCode( attr->lang_code ) );
+ audio->inCodec = codec;
HBLog( "HBScan: title %d: new language (%x, %s)", index, id,
audio->language );
HBListAdd( title->audioList, audio );
diff --git a/core/Thread.c b/core/Thread.c
index 413ff8b6e..b5635116e 100644
--- a/core/Thread.c
+++ b/core/Thread.c
@@ -1,4 +1,4 @@
-/* $Id: Thread.c,v 1.11 2004/02/19 17:59:13 titer Exp $
+/* $Id: Thread.c,v 1.12 2004/03/04 17:57:17 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -33,7 +33,7 @@ struct HBThread
/* HBThreadInit actually starts this routine because
pthread_setschedparam() might fail if called from an external
- thread (typically, because the thread exited immediatly. This isn't
+ thread (typically, because the thread exited immediatly). This isn't
really necessary, but I find it nicer that way */
static void ThreadFunc( void * _t )
{
diff --git a/core/Utils.c b/core/Utils.c
index f9451bb9a..81aeebea5 100644
--- a/core/Utils.c
+++ b/core/Utils.c
@@ -1,4 +1,4 @@
-/* $Id: Utils.c,v 1.14 2004/01/16 19:04:04 titer Exp $
+/* $Id: Utils.c,v 1.16 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -38,7 +38,6 @@ void HBLog( char * log, ... )
time_t _now;
struct tm * now;
va_list args;
- int ret;
if( !getenv( "HB_DEBUG" ) )
{
@@ -53,12 +52,11 @@ void HBLog( char * log, ... )
/* Convert the message to a string */
va_start( args, log );
- ret = vsnprintf( string + 11, 67, log, args );
+ vsnprintf( string + 11, 67, log, args );
va_end( args );
/* Add the end of line */
- string[ret+11] = '\n';
- string[ret+12] = '\0';
+ strcat( string, "\n" );
/* Print it */
fprintf( stderr, "%s", string );
@@ -155,9 +153,17 @@ int HBPStoES( HBBuffer ** _psBuffer, HBList * esBufferList )
if( streamId == 0xBD )
{
- /* A52: don't ask */
streamId |= ( d[pos] << 8 );
- pos += 4;
+ if( ( streamId & 0xF0FF ) == 0x80BD )
+ {
+ /* A52 */
+ pos += 4;
+ }
+ else if( ( streamId & 0xF0FF ) == 0xA0BD )
+ {
+ /* LPCM */
+ pos += 1;
+ }
}
/* Sanity check */
diff --git a/core/Utils.h b/core/Utils.h
index a83c36c65..2d1a06b92 100644
--- a/core/Utils.h
+++ b/core/Utils.h
@@ -1,4 +1,4 @@
-/* $Id: Utils.h,v 1.22 2004/01/21 18:40:36 titer Exp $
+/* $Id: Utils.h,v 1.23 2004/03/08 11:32:48 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -100,10 +100,11 @@ void HBAudioClose( HBAudio ** );
#define HB_CODEC_FFMPEG 0x01
#define HB_CODEC_XVID 0x02
#define HB_CODEC_AC3 0x04
-#define HB_CODEC_MP3 0x08
-#define HB_CODEC_AAC 0x10
-#define HB_CODEC_X264 0x20
-#define HB_CODEC_VORBIS 0x40
+#define HB_CODEC_LPCM 0x08
+#define HB_CODEC_MP3 0x10
+#define HB_CODEC_AAC 0x20
+#define HB_CODEC_X264 0x40
+#define HB_CODEC_VORBIS 0x80
/* Possible muxers */
#define HB_MUX_AVI 0x00
@@ -191,7 +192,8 @@ struct HBAudio
char * language;
/* Settings */
- int codec;
+ int inCodec;
+ int outCodec;
int inSampleRate;
int outSampleRate;
int inBitrate;
diff --git a/core/VorbisEnc.c b/core/VorbisEnc.c
index a4f305720..c75b36850 100644
--- a/core/VorbisEnc.c
+++ b/core/VorbisEnc.c
@@ -1,4 +1,4 @@
-/* $Id: VorbisEnc.c,v 1.4 2003/12/26 20:03:27 titer Exp $
+/* $Id: VorbisEnc.c,v 1.5 2004/03/08 11:32:49 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -119,16 +119,17 @@ static int VorbisEncWork( HBWork *w )
/* init */
vorbis_info_init( &enc->vi );
- if( vorbis_encode_setup_vbr( &enc->vi, 2 /* channel */, audio->inSampleRate, 1.0/* quality 0.0 -> 1.0*/ ) )
+ if( vorbis_encode_setup_managed( &enc->vi, 2,
+ audio->inSampleRate, -1, 1000 * audio->outBitrate, -1 ) ||
+ vorbis_encode_ctl( &enc->vi, OV_ECTL_RATEMANAGE_AVG, NULL ) ||
+ vorbis_encode_setup_init( &enc->vi ) )
{
- HBLog( "VorbisEnc: vorbis_encode_setup_vbr failed" );
+ HBLog( "VorbisEnc: vorbis_encode_setup_managed failed" );
return 0;
}
- vorbis_encode_setup_init( &enc->vi );
-
/* add a comment */
vorbis_comment_init( &enc->vc );
- vorbis_comment_add_tag( &enc->vc, "ENCODER", "Handbrake");
+ vorbis_comment_add_tag( &enc->vc, "ENCODER", "HandBrake");
/* set up the analysis state and auxiliary encoding storage */
vorbis_analysis_init( &enc->vd, &enc->vi);
@@ -197,14 +198,14 @@ static int VorbisEncWork( HBWork *w )
}
}
- didSomething = 1;
-
/* FUCK -Werror ! */
if( !GetSamples( enc ) )
{
return didSomething;
}
+ didSomething = 1;
+
buffer = vorbis_analysis_buffer( &enc->vd, OGGVORBIS_FRAME_SIZE );
for( i = 0; i < OGGVORBIS_FRAME_SIZE; i++ )
{