summaryrefslogtreecommitdiffstats
path: root/core/XvidEnc.c
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 13:24:23 +0000
committerhandbrake <[email protected]>2006-01-14 13:24:23 +0000
commit951be4e0b69aa652c992124025c862c4f1660937 (patch)
tree82935838e945a8aad290741b71aeeecc09058184 /core/XvidEnc.c
parentdc8de40de13c3f3e643b980a95ef48ccafb542e3 (diff)
HandBrake 0.6.0-test2
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@11 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'core/XvidEnc.c')
-rw-r--r--core/XvidEnc.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/core/XvidEnc.c b/core/XvidEnc.c
index fe9e8ddbc..8bf841f36 100644
--- a/core/XvidEnc.c
+++ b/core/XvidEnc.c
@@ -1,4 +1,4 @@
-/* $Id: XvidEnc.c,v 1.18 2004/01/08 22:02:29 titer Exp $
+/* $Id: XvidEnc.c,v 1.20 2004/03/01 21:36:36 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.m0k.org/>.
@@ -65,6 +65,12 @@ void HBXvidEncClose( HBWork ** _x )
x->pass );
xvid_encore( x->xvid, XVID_ENC_DESTROY, NULL, NULL);
}
+ if( x->title->esConfig )
+ {
+ free( x->title->esConfig );
+ x->title->esConfig = NULL;
+ x->title->esConfigLength = 0;
+ }
if( x->frames )
{
float bitrate = (float) x->bytes * x->title->rate / x->frames /
@@ -138,11 +144,10 @@ static int XvidEncWork( HBWork * w )
{
HBLog( "HBXvidEnc: closing libxvidcore (pass %d)",
x->pass );
-
xvid_encore( x->xvid, XVID_ENC_DESTROY, NULL, NULL);
}
- x->pass = scaledBuffer->pass;;
+ x->pass = scaledBuffer->pass;
HBLog( "HBXvidEnc: opening libxvidcore (pass %d)", x->pass );
memset( &xvid_gbl_init, 0, sizeof( xvid_gbl_init ) );
@@ -242,10 +247,33 @@ static int XvidEncWork( HBWork * w )
{
if( !title->esConfig )
{
- /* KLUDGE */
- title->esConfig = malloc( 15 );
- title->esConfigLength = 15;
- memcpy( title->esConfig, mpeg4Buffer->data + 4, 15 );
+ int volStart, vopStart;
+ for( volStart = 0; ; volStart++ )
+ {
+ if( mpeg4Buffer->data[volStart] == 0x0 &&
+ mpeg4Buffer->data[volStart+1] == 0x0 &&
+ mpeg4Buffer->data[volStart+2] == 0x1 &&
+ mpeg4Buffer->data[volStart+3] == 0x20 )
+ {
+ break;
+ }
+ }
+ for( vopStart = volStart + 4; ; vopStart++ )
+ {
+ if( mpeg4Buffer->data[vopStart] == 0x0 &&
+ mpeg4Buffer->data[vopStart+1] == 0x0 &&
+ mpeg4Buffer->data[vopStart+2] == 0x1 &&
+ mpeg4Buffer->data[vopStart+3] == 0xB6 )
+ {
+ break;
+ }
+ }
+
+ HBLog( "XvidEnc: VOL size is %d bytes", vopStart - volStart );
+ title->esConfig = malloc( vopStart - volStart );
+ title->esConfigLength = vopStart - volStart;
+ memcpy( title->esConfig, mpeg4Buffer->data + volStart,
+ vopStart - volStart );
}
x->frames++;
x->bytes += mpeg4Buffer->size;