summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 12:58:25 +0000
committerhandbrake <[email protected]>2006-01-14 12:58:25 +0000
commitf013e3544c0bdf17348d617a467af0e4fde0f545 (patch)
tree9809a1bcb40b4e83294a31dc16c96af6fda21232
parent452f36599a1ea52f3bd42361b534594568c428fd (diff)
HandBrake 0.4.1
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--Jamfile4
-rw-r--r--core/Ac3Decoder.cpp114
-rw-r--r--core/Ac3Decoder.h4
-rw-r--r--core/DVDReader.cpp5
-rw-r--r--core/Manager.cpp16
-rw-r--r--core/Mp3Encoder.cpp52
-rw-r--r--core/Mpeg2Decoder.cpp71
-rw-r--r--core/Mpeg2Decoder.h5
-rw-r--r--core/Mpeg4Encoder.cpp37
-rw-r--r--core/MpegDemux.cpp200
-rw-r--r--core/Resizer.cpp41
-rw-r--r--core/Thread.cpp10
-rw-r--r--core/Worker.cpp36
-rw-r--r--core/Worker.h15
-rw-r--r--macosx/English.lproj/InfoPlist.stringsbin488 -> 496 bytes
-rw-r--r--macosx/HandBrake.pbproj/project.pbxproj6
16 files changed, 313 insertions, 303 deletions
diff --git a/Jamfile b/Jamfile
index a900913d9..471473592 100644
--- a/Jamfile
+++ b/Jamfile
@@ -1,10 +1,10 @@
-# $Id: Jamfile,v 1.38 2003/10/13 23:46:41 titer Exp $
+# $Id: Jamfile,v 1.41 2003/10/16 13:46:32 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.
-HB_VERSION = 0.4 ;
+HB_VERSION = 0.4.1 ;
# Compilers
C++ = g++ ;
diff --git a/core/Ac3Decoder.cpp b/core/Ac3Decoder.cpp
index 95030d810..663184e40 100644
--- a/core/Ac3Decoder.cpp
+++ b/core/Ac3Decoder.cpp
@@ -1,4 +1,4 @@
-/* $Id: Ac3Decoder.cpp,v 1.20 2003/10/13 10:58:24 titer Exp $
+/* $Id: Ac3Decoder.cpp,v 1.21 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -32,7 +32,7 @@ HBAc3Decoder::HBAc3Decoder( HBManager * manager, HBAudio * audio )
fAc3Frame = new HBBuffer( 3840 );
fAc3Frame->fSize = 0;
fAc3Buffer = NULL;
- fPosInBuffer = 0;
+ fPosInAc3Buffer = 0;
fRawBuffer = NULL;
}
@@ -51,74 +51,74 @@ bool HBAc3Decoder::Work()
{
return false;
}
-
- bool didSomething = false;
-
- sample_t * samples;
- for( ;; )
+
+ /* Push the latest decoded buffer */
+ if( fRawBuffer )
{
- /* Try to push the latest decoded buffer */
- if( fRawBuffer )
+ if( fAudio->fRawFifo->Push( fRawBuffer ) )
{
- if( fAudio->fRawFifo->Push( fRawBuffer ) )
- {
- fRawBuffer = NULL;
- }
- else
- {
- break;
- }
+ fRawBuffer = NULL;
}
-
- /* Get a new frame */
- if( fAc3Frame->fSize < 7 )
+ else
{
- /* Get a frame header (7 bytes) */
- if( !( GetBytes( 7 ) ) )
- {
- break;
- }
+ Unlock();
+ return false;
+ }
+ }
- /* Get the size of the current frame */
+ /* Get a frame header (7 bytes) */
+ if( fAc3Frame->fSize < 7 )
+ {
+ if( GetBytes( 7 ) )
+ {
+ /* Get the size of the coming frame */
fFrameSize = a52_syncinfo( fAc3Frame->fData, &fInFlags,
&fAudio->fInSampleRate,
&fAudio->fInBitrate );
if( !fFrameSize )
{
- Log( "HBAc3Decoder : a52_syncinfo failed" );
+ Log( "HBAc3Decoder: a52_syncinfo failed" );
fManager->Error( HB_ERROR_A52_SYNC );
return false;
}
}
-
- /* In case the audio should start later than the video,
- insert some silence */
- if( fAudio->fDelay > 3 * 256 * 1000 / fAudio->fInSampleRate )
+ else
{
- fRawBuffer = new HBBuffer( 12 * 256 * sizeof( float ) );
- for( uint32_t i = 0; i < 12 * 256; i++ )
- {
- ((float*)fRawBuffer->fData)[i] = 0;
- }
- fAudio->fDelay -= 6 * 256 * 1000 / fAudio->fInSampleRate;
- continue;
+ Unlock();
+ return false;
}
-
- if( fAc3Frame->fSize >= 7 )
+ }
+
+ /* In case the audio should start later than the video,
+ insert some silence */
+ if( fAudio->fDelay > 3 * 256 * 1000 / fAudio->fInSampleRate )
+ {
+ fRawBuffer = new HBBuffer( 12 * 256 * sizeof( float ) );
+ for( uint32_t i = 0; i < 12 * 256; i++ )
{
- /* Get the whole frame */
- if( !( GetBytes( (uint32_t) fFrameSize ) ) )
- {
- break;
- }
+ ((float*)fRawBuffer->fData)[i] = 0;
+ }
+ fAudio->fDelay -= 6 * 256 * 1000 / fAudio->fInSampleRate;
+ Unlock();
+ return true;
+ }
+
+ if( fAc3Frame->fSize >= 7 )
+ {
+ /* Get the whole frame */
+ if( GetBytes( (uint32_t) fFrameSize ) )
+ {
/* Feed liba52 */
a52_frame( fState, fAc3Frame->fData, &fOutFlags,
&fSampleLevel, 0 );
+ fAc3Frame->fSize = 0;
/* 6 blocks per frame, 256 samples per block */
fRawBuffer = new HBBuffer( 12 * 256 * sizeof( float ) );
fRawBuffer->fPosition = fPosition;
+
+ sample_t * samples;
for( int i = 0; i < 6; i++ )
{
/* Decode a block */
@@ -137,16 +137,16 @@ bool HBAc3Decoder::Work()
samples + 256,
256 * sizeof( float ) );
}
-
- fAc3Frame->fSize = 0;
-
- didSomething = true;
+ }
+ else
+ {
+ Unlock();
+ return false;
}
}
Unlock();
-
- return didSomething;
+ return true;
}
bool HBAc3Decoder::Lock()
@@ -181,19 +181,19 @@ bool HBAc3Decoder::GetBytes( uint32_t size )
{
return false;
}
- fPosInBuffer = 0;
- fPosition = fAc3Buffer->fPosition;
+ fPosInAc3Buffer = 0;
+ fPosition = fAc3Buffer->fPosition;
}
int willCopy = MIN( size - fAc3Frame->fSize,
- fAc3Buffer->fSize - fPosInBuffer );
+ fAc3Buffer->fSize - fPosInAc3Buffer );
memcpy( fAc3Frame->fData + fAc3Frame->fSize,
- fAc3Buffer->fData + fPosInBuffer,
+ fAc3Buffer->fData + fPosInAc3Buffer,
willCopy );
fAc3Frame->fSize += willCopy;
- fPosInBuffer += willCopy;
+ fPosInAc3Buffer += willCopy;
- if( fAc3Buffer->fSize == fPosInBuffer )
+ if( fAc3Buffer->fSize == fPosInAc3Buffer )
{
delete fAc3Buffer;
fAc3Buffer = NULL;
diff --git a/core/Ac3Decoder.h b/core/Ac3Decoder.h
index 41ac48395..f63206b12 100644
--- a/core/Ac3Decoder.h
+++ b/core/Ac3Decoder.h
@@ -1,4 +1,4 @@
-/* $Id: Ac3Decoder.h,v 1.10 2003/10/07 20:58:12 titer Exp $
+/* $Id: Ac3Decoder.h,v 1.11 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -37,7 +37,7 @@ class HBAc3Decoder
/* buffers */
HBBuffer * fAc3Frame;
HBBuffer * fAc3Buffer;
- uint32_t fPosInBuffer;
+ uint32_t fPosInAc3Buffer;
HBBuffer * fRawBuffer;
float fPosition;
diff --git a/core/DVDReader.cpp b/core/DVDReader.cpp
index 8f7835f51..c3c0e6f3e 100644
--- a/core/DVDReader.cpp
+++ b/core/DVDReader.cpp
@@ -1,4 +1,4 @@
-/* $Id: DVDReader.cpp,v 1.17 2003/10/09 23:33:36 titer Exp $
+/* $Id: DVDReader.cpp,v 1.18 2003/10/16 13:39:13 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -69,9 +69,10 @@ void HBDVDReader::DoWork()
if( dvdplay_read( vmg, dvdBuffer->fData, 1 ) < 0 )
{
- Log( "HBDVDReader: could not dvdplay_read()" );
+ Log( "HBDVDReader: dvdplay_read() failed" );
delete dvdBuffer;
fManager->Error( HB_ERROR_DVD_READ );
+ die = true;
break;
}
diff --git a/core/Manager.cpp b/core/Manager.cpp
index 826ceea58..908aa08fd 100644
--- a/core/Manager.cpp
+++ b/core/Manager.cpp
@@ -1,4 +1,4 @@
-/* $Id: Manager.cpp,v 1.68 2003/10/13 23:42:03 titer Exp $
+/* $Id: Manager.cpp,v 1.70 2003/10/16 13:36:17 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -143,12 +143,14 @@ void HBManager::DoWork()
{
if( fRipDone )
{
- /* Wait a bit to avoid trashing frames in fifos -
- That's kinda ugly */
- while( fCurTitle->fPSFifo->Size() ||
- ( fCurTitle->fMpeg2Fifo->Size() &&
- ( !fCurAudio1 || fCurAudio1->fAc3Fifo->Size() ) &&
- ( !fCurAudio2 || fCurAudio2->fAc3Fifo->Size() ) ) )
+ /* Wait a bit */
+ while( fCurTitle->fPSFifo->Size() )
+ {
+ Snooze( 10000 );
+ }
+ while( fCurTitle->fMpeg2Fifo->Size() &&
+ ( !fCurAudio1 || fCurAudio1->fAc3Fifo->Size() ) &&
+ ( !fCurAudio2 || fCurAudio2->fAc3Fifo->Size() ) )
{
Snooze( 10000 );
}
diff --git a/core/Mp3Encoder.cpp b/core/Mp3Encoder.cpp
index 06d96af29..96ae8c568 100644
--- a/core/Mp3Encoder.cpp
+++ b/core/Mp3Encoder.cpp
@@ -1,4 +1,4 @@
-/* $Id: Mp3Encoder.cpp,v 1.13 2003/10/08 15:00:20 titer Exp $
+/* $Id: Mp3Encoder.cpp,v 1.14 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -73,39 +73,33 @@ bool HBMp3Encoder::Work()
fInitDone = true;
}
- bool didSomething = false;
-
- for( ;; )
+ if( fMp3Buffer )
{
- if( fMp3Buffer )
+ if( fAudio->fMp3Fifo->Push( fMp3Buffer ) )
{
- if( fAudio->fMp3Fifo->Push( fMp3Buffer ) )
- {
- fMp3Buffer = NULL;
- }
- else
- {
- break;
- }
+ fMp3Buffer = NULL;
}
-
- /* Get new samples */
- if( !GetSamples() )
+ else
{
- break;
+ Unlock();
+ return false;
}
+ }
+
+ /* Get new samples */
+ if( GetSamples() )
+ {
+ fSamplesNb = 0;
- int ret;
fMp3Buffer = new HBBuffer( LAME_MAXMP3BUFFER );
- ret = lame_encode_buffer_float( fGlobalFlags, fLeftSamples,
- fRightSamples, fCount,
- fMp3Buffer->fData,
- fMp3Buffer->fSize );
+ int ret = lame_encode_buffer_float( fGlobalFlags, fLeftSamples,
+ fRightSamples, fCount,
+ fMp3Buffer->fData,
+ fMp3Buffer->fSize );
if( ret < 0 )
{
- /* Something wrong happened */
- Log( "HBMp3Encoder : lame_encode_buffer_float() failed "
+ Log( "HBMp3Encoder: lame_encode_buffer_float() failed "
"(%d)", ret );
fManager->Error( HB_ERROR_MP3_ENCODE );
return false;
@@ -122,13 +116,15 @@ bool HBMp3Encoder::Work()
delete fMp3Buffer;
fMp3Buffer = NULL;
}
- fSamplesNb = 0;
-
- didSomething = true;
+ }
+ else
+ {
+ Unlock();
+ return false;
}
Unlock();
- return didSomething;
+ return true;
}
bool HBMp3Encoder::Lock()
diff --git a/core/Mpeg2Decoder.cpp b/core/Mpeg2Decoder.cpp
index 3149931e8..a9b6a5373 100644
--- a/core/Mpeg2Decoder.cpp
+++ b/core/Mpeg2Decoder.cpp
@@ -1,4 +1,4 @@
-/* $Id: Mpeg2Decoder.cpp,v 1.21 2003/10/09 14:21:21 titer Exp $
+/* $Id: Mpeg2Decoder.cpp,v 1.22 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -29,44 +29,29 @@ HBMpeg2Decoder::HBMpeg2Decoder( HBManager * manager, HBTitle * title )
bool HBMpeg2Decoder::Work()
{
- fLock->Lock();
- if( fUsed )
+ if( !Lock() )
{
- fLock->Unlock();
- return true;
+ return false;
}
- fUsed = true;
- fLock->Unlock();
-
- bool didSomething = false;
- for( ;; )
+ /* Push decoded buffers */
+ while( ( fRawBuffer =
+ (HBBuffer*) fRawBufferList->ItemAt( 0 ) ) )
{
- /* Push decoded buffers */
- while( ( fRawBuffer =
- (HBBuffer*) fRawBufferList->ItemAt( 0 ) ) )
+ if( fTitle->fRawFifo->Push( fRawBuffer ) )
{
- if( fTitle->fRawFifo->Push( fRawBuffer ) )
- {
- fRawBufferList->RemoveItem( fRawBuffer );
- }
- else
- {
- break;
- }
- }
-
- if( fRawBufferList->CountItems() )
- {
- break;
+ fRawBufferList->RemoveItem( fRawBuffer );
}
-
- /* Get a new buffer to decode */
- if( !( fMpeg2Buffer = fTitle->fMpeg2Fifo->Pop() ) )
+ else
{
- break;
+ Unlock();
+ return false;
}
+ }
+ /* Get a new buffer to decode */
+ if( ( fMpeg2Buffer = fTitle->fMpeg2Fifo->Pop() ) )
+ {
/* (Re)init if needed */
if( fMpeg2Buffer->fPass != fPass )
{
@@ -76,15 +61,35 @@ bool HBMpeg2Decoder::Work()
/* Do the job */
DecodeBuffer();
+ }
+ else
+ {
+ Unlock();
+ return false;
+ }
- didSomething = true;
+ Unlock();
+ return true;
+}
+
+bool HBMpeg2Decoder::Lock()
+{
+ fLock->Lock();
+ if( fUsed )
+ {
+ fLock->Unlock();
+ return false;
}
+ fUsed = true;
+ fLock->Unlock();
+ return true;
+}
+void HBMpeg2Decoder::Unlock()
+{
fLock->Lock();
fUsed = false;
fLock->Unlock();
-
- return didSomething;
}
void HBMpeg2Decoder::Init()
diff --git a/core/Mpeg2Decoder.h b/core/Mpeg2Decoder.h
index 9d1f27f8f..6e20509a2 100644
--- a/core/Mpeg2Decoder.h
+++ b/core/Mpeg2Decoder.h
@@ -1,4 +1,4 @@
-/* $Id: Mpeg2Decoder.h,v 1.15 2003/10/09 14:21:21 titer Exp $
+/* $Id: Mpeg2Decoder.h,v 1.16 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -17,6 +17,9 @@ class HBMpeg2Decoder
bool Work();
private:
+ bool Lock();
+ void Unlock();
+
void Init();
void DecodeBuffer();
diff --git a/core/Mpeg4Encoder.cpp b/core/Mpeg4Encoder.cpp
index 4ef0a4c3f..bf5821a4c 100644
--- a/core/Mpeg4Encoder.cpp
+++ b/core/Mpeg4Encoder.cpp
@@ -1,4 +1,4 @@
-/* $Id: Mpeg4Encoder.cpp,v 1.23 2003/10/09 13:24:48 titer Exp $
+/* $Id: Mpeg4Encoder.cpp,v 1.25 2003/10/14 15:23:56 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -32,27 +32,21 @@ bool HBMpeg4Encoder::Work()
return false;
}
- bool didSomething = false;
-
- for( ;; )
+ if( fMpeg4Buffer )
{
- if( fMpeg4Buffer )
+ if( fTitle->fMpeg4Fifo->Push( fMpeg4Buffer ) )
{
- if( fTitle->fMpeg4Fifo->Push( fMpeg4Buffer ) )
- {
- fMpeg4Buffer = NULL;
- }
- else
- {
- break;
- }
+ fMpeg4Buffer = NULL;
}
-
- if( !( fResizedBuffer = fTitle->fResizedFifo->Pop() ) )
+ else
{
- break;
+ Unlock();
+ return false;
}
+ }
+ if( ( fResizedBuffer = fTitle->fResizedFifo->Pop() ) )
+ {
if( fResizedBuffer->fPass != fPass )
{
fPass = fResizedBuffer->fPass;
@@ -61,12 +55,15 @@ bool HBMpeg4Encoder::Work()
fManager->SetPosition( fResizedBuffer->fPosition );
EncodeBuffer();
-
- didSomething = true;
+ }
+ else
+ {
+ Unlock();
+ return false;
}
Unlock();
- return didSomething;
+ return true;
}
bool HBMpeg4Encoder::Lock()
@@ -107,7 +104,7 @@ void HBMpeg4Encoder::Init()
fContext = avcodec_alloc_context();
fContext->bit_rate = 1024 * fTitle->fBitrate;
- fContext->bit_rate_tolerance = 1024 * fTitle->fBitrate;
+ fContext->bit_rate_tolerance = 10240 * fTitle->fBitrate;
fContext->width = fTitle->fOutWidth;
fContext->height = fTitle->fOutHeight;
fContext->frame_rate = fTitle->fRate;
diff --git a/core/MpegDemux.cpp b/core/MpegDemux.cpp
index c01647a3a..249ee2738 100644
--- a/core/MpegDemux.cpp
+++ b/core/MpegDemux.cpp
@@ -1,4 +1,4 @@
-/* $Id: MpegDemux.cpp,v 1.18 2003/10/13 15:14:01 titer Exp $
+/* $Id: MpegDemux.cpp,v 1.20 2003/10/16 13:36:17 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -53,117 +53,114 @@ bool HBMpegDemux::Work()
return false;
}
- bool didSomething = false;
-
- for( ;; )
+ /* Push waiting buffers */
+ if( fESBufferList )
{
- /* If we have buffers waiting, try to push them */
- if( fESBufferList )
+ for( uint32_t i = 0; i < fESBufferList->CountItems(); )
{
- for( uint32_t i = 0; i < fESBufferList->CountItems(); )
+ fESBuffer = (HBBuffer*) fESBufferList->ItemAt( i );
+
+ if( fESBuffer->fPass == 1 && fESBuffer->fStreamId != 0xE0 )
{
- fESBuffer = (HBBuffer*) fESBufferList->ItemAt( i );
-
- if( fESBuffer->fPass == 1 && fESBuffer->fStreamId != 0xE0 )
+ fESBufferList->RemoveItem( fESBuffer );
+ delete fESBuffer;
+ continue;
+ }
+
+ /* Look for a decoder for this ES */
+
+ if( fESBuffer->fStreamId == 0xE0 )
+ {
+ if( fFirstVideoPTS < 0 )
+ {
+ fFirstVideoPTS = fESBuffer->fPTS;
+ Log( "HBMpegDemux: got first 0xE0 packet (%lld)",
+ fFirstVideoPTS );
+ }
+ if( fTitle->fMpeg2Fifo->Push( fESBuffer ) )
{
fESBufferList->RemoveItem( fESBuffer );
- delete fESBuffer;
- continue;
}
-
- /* Look for a decoder for this ES */
-
- if( fESBuffer->fStreamId == 0xE0 )
+ else
{
- if( fFirstVideoPTS < 0 )
- {
- fFirstVideoPTS = fESBuffer->fPTS;
- Log( "HBMpegDemux: got first 0xE0 packet (%lld)",
- fFirstVideoPTS );
- }
- if( fTitle->fMpeg2Fifo->Push( fESBuffer ) )
- {
- fESBufferList->RemoveItem( fESBuffer );
- }
- else
- {
- i++;
- }
+ i++;
}
- else if( fAudio1 &&
- fESBuffer->fStreamId == fAudio1->fId )
+ }
+ else if( fAudio1 &&
+ fESBuffer->fStreamId == fAudio1->fId )
+ {
+ if( fFirstAudio1PTS < 0 )
{
- if( fFirstAudio1PTS < 0 )
- {
- fFirstAudio1PTS = fESBuffer->fPTS;
- Log( "HBMpegDemux: got first 0x%x packet (%lld)",
- fAudio1->fId, fFirstAudio1PTS );
-
- fAudio1->fDelay =
- ( fFirstAudio1PTS - fFirstVideoPTS ) / 90;
- }
- if( fAudio1->fAc3Fifo->Push( fESBuffer ) )
- {
- fESBufferList->RemoveItem( fESBuffer );
- }
- else
- {
- i++;
- }
+ fFirstAudio1PTS = fESBuffer->fPTS;
+ Log( "HBMpegDemux: got first 0x%x packet (%lld)",
+ fAudio1->fId, fFirstAudio1PTS );
+
+ fAudio1->fDelay =
+ ( fFirstAudio1PTS - fFirstVideoPTS ) / 90;
}
- else if( fAudio2 &&
- fESBuffer->fStreamId == fAudio2->fId )
+ if( fAudio1->fAc3Fifo->Push( fESBuffer ) )
{
- if( fFirstAudio2PTS < 0 )
- {
- fFirstAudio2PTS = fESBuffer->fPTS;
- Log( "HBMpegDemux: got first 0x%x packet (%lld)",
- fAudio2->fId, fFirstAudio2PTS );
-
- fAudio2->fDelay =
- ( fFirstAudio2PTS - fFirstVideoPTS ) / 90;
- }
- if( fAudio2->fAc3Fifo->Push( fESBuffer ) )
- {
- fESBufferList->RemoveItem( fESBuffer );
- }
- else
- {
- i++;
- }
+ fESBufferList->RemoveItem( fESBuffer );
}
else
{
- fESBufferList->RemoveItem( fESBuffer );
- delete fESBuffer;
+ i++;
}
}
-
- if( !fESBufferList->CountItems() )
+ else if( fAudio2 &&
+ fESBuffer->fStreamId == fAudio2->fId )
{
- delete fESBufferList;
- fESBufferList = NULL;
+ if( fFirstAudio2PTS < 0 )
+ {
+ fFirstAudio2PTS = fESBuffer->fPTS;
+ Log( "HBMpegDemux: got first 0x%x packet (%lld)",
+ fAudio2->fId, fFirstAudio2PTS );
+
+ fAudio2->fDelay =
+ ( fFirstAudio2PTS - fFirstVideoPTS ) / 90;
+ }
+ if( fAudio2->fAc3Fifo->Push( fESBuffer ) )
+ {
+ fESBufferList->RemoveItem( fESBuffer );
+ }
+ else
+ {
+ i++;
+ }
}
else
{
- break;
+ fESBufferList->RemoveItem( fESBuffer );
+ delete fESBuffer;
}
}
- /* Get a PS packet */
- if( !( fPSBuffer = fTitle->fPSFifo->Pop() ) )
+ if( !fESBufferList->CountItems() )
+ {
+ delete fESBufferList;
+ fESBufferList = NULL;
+ }
+ else
{
- break;
+ Unlock();
+ return false;
}
+ }
+ /* Get a PS packet */
+ if( ( fPSBuffer = fTitle->fPSFifo->Pop() ) )
+ {
/* Get the ES data in it */
PStoES( fPSBuffer, &fESBufferList );
-
- didSomething = true;
+ }
+ else
+ {
+ Unlock();
+ return false;
}
Unlock();
- return didSomething;
+ return true;
}
bool HBMpegDemux::Lock()
@@ -190,15 +187,13 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
{
#define psData (psBuffer->fData)
- HBList * esBufferList = new HBList();
- HBBuffer * esBuffer;
- uint32_t pos = 0;
+ uint32_t pos = 0;
/* pack_header */
if( psData[pos] != 0 || psData[pos+1] != 0 ||
psData[pos+2] != 0x1 || psData[pos+3] != 0xBA )
{
- Log( "PStoES : not a PS packet (%02x%02x%02x%02x)",
+ Log( "PStoES: not a PS packet (%02x%02x%02x%02x)",
psData[pos] << 24, psData[pos+1] << 16,
psData[pos+2] << 8, psData[pos+3] );
delete psBuffer;
@@ -220,8 +215,11 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
pos += 2 + header_length;
}
+ HBList * esBufferList = new HBList();
+ HBBuffer * esBuffer;
+
/* PES */
- while( pos + 2 < psBuffer->fSize &&
+ while( pos + 6 < psBuffer->fSize &&
psData[pos] == 0 && psData[pos+1] == 0 && psData[pos+2] == 0x1 )
{
uint32_t streamId;
@@ -233,12 +231,20 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
uint64_t PTS = 0;
pos += 3; /* packet_start_code_prefix */
- streamId = psData[pos++];
+ streamId = psData[pos];
+ pos += 1;
PES_packet_length = ( psData[pos] << 8 ) + psData[pos+1];
pos += 2; /* PES_packet_length */
PES_packet_end = pos + PES_packet_length;
+ if( streamId != 0xE0 && streamId != 0xBD )
+ {
+ /* Not interesting */
+ pos = PES_packet_end;
+ continue;
+ }
+
hasPTS = ( ( psData[pos+1] >> 6 ) & 0x2 );
pos += 2; /* Required headers */
@@ -248,7 +254,7 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
if( hasPTS )
{
- PTS = ( ( ( psData[pos] >> 1 ) & 0x7 ) << 30 ) +
+ PTS = ( ( ( (uint64_t) psData[pos] >> 1 ) & 0x7 ) << 30 ) +
( psData[pos+1] << 22 ) +
( ( psData[pos+2] >> 1 ) << 15 ) +
( psData[pos+3] << 7 ) +
@@ -257,19 +263,21 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
pos = PES_header_end;
- if( streamId != 0xE0 && streamId != 0xBD )
- {
- /* Not interesting */
- continue;
- }
-
if( streamId == 0xBD )
{
- /* A52 : don't ask */
+ /* A52: don't ask */
streamId |= ( psData[pos] << 8 );
pos += 4;
}
+ /* Sanity check */
+ if( pos >= PES_packet_end )
+ {
+ Log( "PStoES: pos >= PES_packet_end" );
+ pos = PES_packet_end;
+ continue;
+ }
+
/* Here we hit we ES payload */
esBuffer = new HBBuffer( PES_packet_end - pos );
@@ -287,7 +295,7 @@ bool PStoES( HBBuffer * psBuffer, HBList ** _esBufferList )
delete psBuffer;
- if( esBufferList && !esBufferList->CountItems() )
+ if( !esBufferList->CountItems() )
{
delete esBufferList;
esBufferList = NULL;
diff --git a/core/Resizer.cpp b/core/Resizer.cpp
index 0b9c794db..c49a39bf3 100644
--- a/core/Resizer.cpp
+++ b/core/Resizer.cpp
@@ -1,4 +1,4 @@
-/* $Id: Resizer.cpp,v 1.8 2003/10/09 13:24:48 titer Exp $
+/* $Id: Resizer.cpp,v 1.9 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -59,29 +59,23 @@ bool HBResizer::Work()
return false;
}
- bool didSomething = false;
-
- for( ;; )
+ /* Push the latest resized buffer */
+ if( fResizedBuffer )
{
- /* Push the latest resized buffer */
- if( fResizedBuffer )
+ if( fTitle->fResizedFifo->Push( fResizedBuffer ) )
{
- if( fTitle->fResizedFifo->Push( fResizedBuffer ) )
- {
- fResizedBuffer = NULL;
- }
- else
- {
- break;
- }
+ fResizedBuffer = NULL;
}
-
- /* Get a new raw picture */
- if( !( fRawBuffer = fTitle->fRawFifo->Pop() ) )
+ else
{
- break;
+ Unlock();
+ return false;
}
-
+ }
+
+ /* Get a new raw picture */
+ if( ( fRawBuffer = fTitle->fRawFifo->Pop() ) )
+ {
/* Do the job */
avpicture_fill( fRawPicture, fRawBuffer->fData,
PIX_FMT_YUV420P, fTitle->fInWidth,
@@ -111,12 +105,15 @@ bool HBResizer::Work()
}
delete fRawBuffer;
fRawBuffer = NULL;
-
- didSomething = true;
+ }
+ else
+ {
+ Unlock();
+ return false;
}
Unlock();
- return didSomething;
+ return true;
}
bool HBResizer::Lock()
diff --git a/core/Thread.cpp b/core/Thread.cpp
index 8f7e6c971..c52f7506a 100644
--- a/core/Thread.cpp
+++ b/core/Thread.cpp
@@ -1,4 +1,4 @@
-/* $Id: Thread.cpp,v 1.23 2003/10/09 23:33:36 titer Exp $
+/* $Id: Thread.cpp,v 1.24 2003/10/14 14:35:20 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -63,6 +63,9 @@ void HBThread::Run()
pthread_create( &fThread, NULL,
(void * (*)(void *)) ThreadFunc, this );
#endif
+
+ Log( "HBThread: thread %d started (\"%s\")",
+ fThread, fName );
}
bool HBThread::Push( HBFifo * fifo, HBBuffer * buffer )
@@ -104,7 +107,7 @@ void HBThread::ThreadFunc( HBThread * _this )
struct sched_param param;
memset( &param, 0, sizeof( struct sched_param ) );
param.sched_priority = _this->fPriority;
- if ( pthread_setschedparam( _this->fThread, SCHED_OTHER, &param ) )
+ if ( pthread_setschedparam( pthread_self(), SCHED_OTHER, &param ) )
{
Log( "HBThread: couldn't set thread priority" );
}
@@ -112,9 +115,6 @@ void HBThread::ThreadFunc( HBThread * _this )
_this->fPid = (int) getpid();
- Log( "HBThread: thread %d started (\"%s\")",
- _this->fThread, _this->fName );
-
_this->DoWork();
}
diff --git a/core/Worker.cpp b/core/Worker.cpp
index 5f1352026..4310e46f4 100644
--- a/core/Worker.cpp
+++ b/core/Worker.cpp
@@ -1,4 +1,4 @@
-/* $Id: Worker.cpp,v 1.9 2003/10/13 17:59:40 titer Exp $
+/* $Id: Worker.cpp,v 1.11 2003/10/16 13:36:17 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -16,9 +16,9 @@ HBWorker::HBWorker( HBTitle * title, HBAudio * audio1,
HBAudio * audio2 )
: HBThread( "worker")
{
- fTitle = title;
- fAudio1 = audio1;
- fAudio2 = audio2;
+ fTitle = title;
+ fAudio1 = audio1;
+ fAudio2 = audio2;
Run();
}
@@ -36,8 +36,13 @@ void HBWorker::DoWork()
uint64_t mp3Encoder2 = 0;
uint64_t tmpDate;
- while( !fDie )
+ for( ;; )
{
+ while( fSuspend )
+ {
+ Snooze( 10000 );
+ }
+
didSomething = false;
tmpDate = GetDate();
@@ -122,29 +127,24 @@ void HBWorker::DoWork()
{
Snooze( 10000 );
}
-
- while( fSuspend )
- {
- Snooze( 10000 );
- }
}
tmpDate = mpegDemux + mpeg2Decoder + resizer + mpeg4Encoder +
ac3Decoder1 + mp3Encoder1 + ac3Decoder2 + mp3Encoder2;
Log( "HBWorker stopped. CPU utilization:" );
- Log( "- MPEG demuxer: %.2f %%", 100 * (float) mpegDemux / tmpDate );
- Log( "- MPEG-2 decoder: %.2f %%", 100 * (float) mpeg2Decoder / tmpDate );
- Log( "- Resizer: %.2f %%", 100 * (float) resizer / tmpDate );
- Log( "- MPEG-4 encoder: %.2f %%", 100 * (float) mpeg4Encoder / tmpDate );
+ Log( "- MPEG demuxer: %.2f %%", 100.0 * mpegDemux / tmpDate );
+ Log( "- MPEG-2 decoder: %.2f %%", 100.0 * mpeg2Decoder / tmpDate );
+ Log( "- Resizer: %.2f %%", 100.0 * resizer / tmpDate );
+ Log( "- MPEG-4 encoder: %.2f %%", 100.0 * mpeg4Encoder / tmpDate );
if( fAudio1 )
{
- Log( "- AC3 decoder 1: %.2f %%", 100 * (float) ac3Decoder1 / tmpDate );
- Log( "- MP3 encoder 1: %.2f %%", 100 * (float) mp3Encoder1 / tmpDate );
+ Log( "- AC3 decoder 1: %.2f %%", 100.0 * ac3Decoder1 / tmpDate );
+ Log( "- MP3 encoder 1: %.2f %%", 100.0 * mp3Encoder1 / tmpDate );
}
if( fAudio2 )
{
- Log( "- AC3 decoder 2: %.2f %%", 100 * (float) ac3Decoder2 / tmpDate );
- Log( "- MP3 encoder 2: %.2f %%", 100 * (float) mp3Encoder2 / tmpDate );
+ Log( "- AC3 decoder 2: %.2f %%", 100.0 * ac3Decoder2 / tmpDate );
+ Log( "- MP3 encoder 2: %.2f %%", 100.0 * mp3Encoder2 / tmpDate );
}
}
diff --git a/core/Worker.h b/core/Worker.h
index d2d0324d8..5df8f648b 100644
--- a/core/Worker.h
+++ b/core/Worker.h
@@ -1,4 +1,4 @@
-/* $Id: Worker.h,v 1.1 2003/10/07 17:40:06 titer Exp $
+/* $Id: Worker.h,v 1.3 2003/10/16 13:36:17 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
@@ -13,15 +13,16 @@
class HBWorker : public HBThread
{
public:
- HBWorker( HBTitle * title, HBAudio * audio1,
- HBAudio * audio2 );
+ HBWorker( HBTitle * title, HBAudio * audio1,
+ HBAudio * audio2 );
+ void WaitUntilDone();
private:
- void DoWork();
+ void DoWork();
- HBTitle * fTitle;
- HBAudio * fAudio1;
- HBAudio * fAudio2;
+ HBTitle * fTitle;
+ HBAudio * fAudio1;
+ HBAudio * fAudio2;
};
#endif
diff --git a/macosx/English.lproj/InfoPlist.strings b/macosx/English.lproj/InfoPlist.strings
index 5ed7ca9e2..7690c78ef 100644
--- a/macosx/English.lproj/InfoPlist.strings
+++ b/macosx/English.lproj/InfoPlist.strings
Binary files differ
diff --git a/macosx/HandBrake.pbproj/project.pbxproj b/macosx/HandBrake.pbproj/project.pbxproj
index 5f4045553..2cc6e1054 100644
--- a/macosx/HandBrake.pbproj/project.pbxproj
+++ b/macosx/HandBrake.pbproj/project.pbxproj
@@ -263,7 +263,7 @@
<key>CFBundleExecutable</key>
<string>HandBrake</string>
<key>CFBundleGetInfoString</key>
- <string>HandBrake 0.4 - By Eric Petit &lt;[email protected]&gt;</string>
+ <string>HandBrake 0.4.1 - By Eric Petit &lt;[email protected]&gt;</string>
<key>CFBundleIconFile</key>
<string>HandBrake.icns</string>
<key>CFBundleIdentifier</key>
@@ -275,11 +275,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.4</string>
+ <string>0.4.1</string>
<key>CFBundleSignature</key>
<string>HB##</string>
<key>CFBundleVersion</key>
- <string>0.4</string>
+ <string>0.4.1</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>