Commit 7518bb92 authored by Laurent Aimar's avatar Laurent Aimar

* ffmpeg/audio : removed an old error (anyway it was harmless).

 * mp4 : removed a bad initialisation. Erased all ending spaces.
 * mpeg/audio : send i_rate to decoder (not yet usefull but ...)
parent 0b8b405c
......@@ -2,7 +2,7 @@
* audio.c: audio decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.c,v 1.13 2003/01/25 16:59:49 fenrir Exp $
* $Id: audio.c,v 1.14 2003/02/07 01:22:55 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program 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
......@@ -66,34 +66,11 @@ static unsigned int pi_channels_maps[6] =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
};
};
/*****************************************************************************
* locales Functions
*****************************************************************************/
#if 0
static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
WAVEFORMATEX *p_wfdata = (WAVEFORMATEX*)p_data;
p_wh->i_formattag = p_wfdata->wFormatTag;
p_wh->i_nb_channels = p_wfdata->nChannels;
p_wh->i_samplespersec = p_wfdata->nSamplesPerSec;
p_wh->i_avgbytespersec= p_wfdata->nAvgBytesPerSec;
p_wh->i_blockalign = p_wfdata->nBlockAlign;
p_wh->i_bitspersample = p_wfdata->wBitsPerSample;
p_wh->i_size = p_wfdata->cbSize;
if( p_wh->i_size )
{
p_wh->p_data = malloc( p_wh->i_size );
memcpy( p_wh->p_data,
p_data + sizeof(WAVEFORMATEX) ,
p_wh->i_size );
}
}
#endif
/*****************************************************************************
*
......@@ -108,8 +85,8 @@ static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
/*****************************************************************************
* InitThread: initialize vdec output thread
*****************************************************************************
* This function is called from decoder_Run and performs the second step
* of the initialization. It returns 0 on success. Note that the thread's
* This function is called from decoder_Run and performs the second step
* of the initialization. It returns 0 on success. Note that the thread's
* flag are not modified inside this function.
*
* ffmpeg codec will be open, some memory allocated.
......@@ -158,14 +135,14 @@ int E_( InitThread_Audio )( adec_thread_t *p_adec )
p_adec->psz_namecodec );
}
p_adec->p_output = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
p_adec->p_output = malloc( 3 * AVCODEC_MAX_AUDIO_FRAME_SIZE );
p_adec->output_format.i_format = AOUT_FMT_S16_NE;
p_adec->output_format.i_rate = p_wf->nSamplesPerSec;
p_adec->output_format.i_physical_channels
= p_adec->output_format.i_original_channels
= p_wf->nChannels;
= pi_channels_maps[p_wf->nChannels];
p_adec->p_aout = NULL;
p_adec->p_aout_input = NULL;
......@@ -268,7 +245,7 @@ usenextdata:
i_output_size );
}
if( p_adec->p_context->channels <= 0 ||
if( p_adec->p_context->channels <= 0 ||
p_adec->p_context->channels > 5 )
{
msg_Warn( p_adec->p_fifo,
......@@ -281,7 +258,7 @@ usenextdata:
/ aout_FormatNbChannels( &p_adec->output_format );
/* **** First check if we have a valid output **** */
if( ( p_adec->p_aout_input == NULL )||
( p_adec->output_format.i_original_channels !=
( p_adec->output_format.i_original_channels !=
pi_channels_maps[p_adec->p_context->channels] ) )
{
if( p_adec->p_aout_input != NULL )
......@@ -291,8 +268,8 @@ usenextdata:
}
/* **** Create a new audio output **** */
p_adec->output_format.i_physical_channels =
p_adec->output_format.i_original_channels =
p_adec->output_format.i_physical_channels =
p_adec->output_format.i_original_channels =
pi_channels_maps[p_adec->p_context->channels];
aout_DateInit( &p_adec->date, p_adec->output_format.i_rate );
......
......@@ -2,7 +2,7 @@
* audio.h: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.h,v 1.3 2003/01/25 16:59:49 fenrir Exp $
* $Id: audio.h,v 1.4 2003/02/07 01:22:55 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program 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
......@@ -22,20 +22,6 @@
*****************************************************************************/
/* for an audio stream */
typedef struct waveformatex_s
{
u16 i_formattag;
u16 i_nb_channels;
u32 i_samplespersec;
u32 i_avgbytespersec;
u16 i_blockalign;
u16 i_bitspersample;
u16 i_size; /* the extra size in bytes */
u8 *p_data; /* The extra data */
} waveformatex_t;
typedef struct adec_thread_s
{
DECODER_THREAD_COMMON
......
......@@ -2,7 +2,7 @@
* libmp4.c : LibMP4 library for mp4 module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libmp4.c,v 1.13 2003/01/25 16:58:34 fenrir Exp $
* $Id: libmp4.c,v 1.14 2003/02/07 01:22:55 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -162,14 +162,14 @@ static uint64_t GetQWBE( uint8_t *p_buff )
static void GetUUID( UUID_t *p_uuid, uint8_t *p_buff )
{
memcpy( p_uuid,
memcpy( p_uuid,
p_buff,
16 );
}
static void CreateUUID( UUID_t *p_uuid, uint32_t i_fourcc )
{
/* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
/* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
where XXXXXXXX is the fourcc */
/* FIXME implement this */
}
......@@ -299,7 +299,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
/****************************************************************************
* MP4_MemoryStream create a memory stream
* if p_buffer == NULL, will allocate a buffer of i_size, else
* if p_buffer == NULL, will allocate a buffer of i_size, else
* it uses p_buffer XXX you have to unallocate it yourself !
*
****************************************************************************/
......@@ -343,7 +343,7 @@ int MP4_ReadStream( MP4_Stream_t *p_stream, uint8_t *p_buff, int i_size )
{
return( 0 );
}
memcpy( p_buff,
memcpy( p_buff,
p_stream->p_buffer + p_stream->i_start,
i_size );
p_stream->i_start += i_size;
......@@ -470,19 +470,18 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* FIXME how to write uint64_t ??? */
if( p_box->i_size )
{
msg_Dbg( p_stream->p_input, "Found Box: %c%c%c%c size %d",
(p_box->i_type)&0xff, (p_box->i_type>>8)&0xff,
(p_box->i_type>>16)&0xff, (p_box->i_type>>24)&0xff,
msg_Dbg( p_stream->p_input, "Found Box: %4.4s size %d",
(char*)&p_box->i_type,
(uint32_t)p_box->i_size );
}
#endif
return( 1 );
return( 1 );
}
/*****************************************************************************
* MP4_MP4_NextBox : Go to the next box
* MP4_MP4_NextBox : Go to the next box
*****************************************************************************
* if p_box == NULL, go to the next box in witch we are( at the begining ).
*****************************************************************************/
......@@ -504,7 +503,7 @@ int MP4_NextBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if( p_box->p_father )
{
/* check if it's within p-father */
if( p_box->i_size + p_box->i_pos >=
if( p_box->i_size + p_box->i_pos >=
p_box->p_father->i_size + p_box->p_father->i_pos )
{
return( 0 ); /* out of bound */
......@@ -533,7 +532,7 @@ int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
{
MP4_Box_t *p_box;
if( MP4_TellStream( p_stream ) + 8 >
if( MP4_TellStream( p_stream ) + 8 >
(off_t)(p_container->i_pos + p_container->i_size) )
{
/* there is no box to load */
......@@ -594,11 +593,8 @@ int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
/* Nothing to do */
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Skip box: \"%c%c%c%c\"",
(p_box->i_type)&0xff,
(p_box->i_type>>8)&0xff,
(p_box->i_type>>16)&0xff,
(p_box->i_type>>24)&0xff );
msg_Dbg( p_stream->p_input, "Skip box: \"%4.4s\"",
(char*)&p_box->i_type );
#endif
return( 1 );
}
......@@ -661,11 +657,11 @@ int MP4_ReadBox_mvhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_mvhd->i_timescale );
MP4_GET4BYTES( p_box->data.p_mvhd->i_duration );
}
MP4_GET4BYTES( p_box->data.p_mvhd->i_rate );
MP4_GET2BYTES( p_box->data.p_mvhd->i_volume );
MP4_GET4BYTES( p_box->data.p_mvhd->i_rate );
MP4_GET2BYTES( p_box->data.p_mvhd->i_volume );
MP4_GET2BYTES( p_box->data.p_mvhd->i_reserved1 );
for( i = 0; i < 2; i++ )
{
MP4_GET4BYTES( p_box->data.p_mvhd->i_reserved2[i] );
......@@ -678,23 +674,23 @@ int MP4_ReadBox_mvhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_GET4BYTES( p_box->data.p_mvhd->i_predefined[i] );
}
MP4_GET4BYTES( p_box->data.p_mvhd->i_next_track_id );
#ifdef MP4_VERBOSE
MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
MP4_ConvertDate2Str( s_modification_time,
MP4_ConvertDate2Str( s_modification_time,
p_box->data.p_mvhd->i_modification_time );
if( p_box->data.p_mvhd->i_rate )
{
MP4_ConvertDate2Str( s_duration,
MP4_ConvertDate2Str( s_duration,
p_box->data.p_mvhd->i_duration / p_box->data.p_mvhd->i_rate );
}
else
{
s_duration[0] = 0;
}
}
msg_Dbg( p_stream->p_input, "Read Box: \"mvhd\" creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d",
s_creation_time,
s_modification_time,
......@@ -716,7 +712,7 @@ int MP4_ReadBox_tkhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
char s_duration[128];
#endif
MP4_READBOX_ENTER( MP4_Box_data_tkhd_t );
MP4_GETVERSIONFLAGS( p_box->data.p_tkhd );
if( p_box->data.p_tkhd->i_version )
......@@ -735,7 +731,7 @@ int MP4_ReadBox_tkhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_tkhd->i_reserved );
MP4_GET4BYTES( p_box->data.p_tkhd->i_duration );
}
for( i = 0; i < 2; i++ )
{
MP4_GET4BYTES( p_box->data.p_tkhd->i_reserved2[i] );
......@@ -751,12 +747,12 @@ int MP4_ReadBox_tkhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
MP4_GET4BYTES( p_box->data.p_tkhd->i_width );
MP4_GET4BYTES( p_box->data.p_tkhd->i_height );
#ifdef MP4_VERBOSE
MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mvhd->i_modification_time );
MP4_ConvertDate2Str( s_duration, p_box->data.p_mvhd->i_duration );
msg_Dbg( p_stream->p_input, "Read Box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f",
s_creation_time,
s_modification_time,
......@@ -778,7 +774,7 @@ int MP4_ReadBox_tref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* container is empty, 8 stand for the first header in this box */
return( 1 );
}
if( !MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) ) )
{
return( 0 );
......@@ -822,15 +818,15 @@ int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_mdhd->i_timescale );
MP4_GET4BYTES( p_box->data.p_mdhd->i_duration );
}
i_language = GetWBE( p_peek );
i_language = GetWBE( p_peek );
for( i = 0; i < 3; i++ )
{
p_box->data.p_mdhd->i_language[i] =
p_box->data.p_mdhd->i_language[i] =
( ( i_language >> ( (2-i)*5 ) )&0x1f ) + 0x60;
}
MP4_GET2BYTES( p_box->data.p_mdhd->i_predefined );
#ifdef MP4_VERBOSE
MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mdhd->i_creation_time );
MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mdhd->i_modification_time );
......@@ -850,10 +846,10 @@ int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_hdlr_t );
MP4_READBOX_ENTER( MP4_Box_data_hdlr_t );
MP4_GETVERSIONFLAGS( p_box->data.p_hdlr );
MP4_GET4BYTES( p_box->data.p_hdlr->i_predefined );
MP4_GETFOURCC( p_box->data.p_hdlr->i_handler_type );
......@@ -861,11 +857,8 @@ int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"hdlr\" hanler type %c%c%c%c name %s",
( p_box->data.p_hdlr->i_handler_type )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 8 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 16 )&0xff,
( p_box->data.p_hdlr->i_handler_type >> 24 )&0xff,
msg_Dbg( p_stream->p_input, "Read Box: \"hdlr\" hanler type %4.4s name %s",
(char*)&p_box->data.p_hdlr->i_handler_type,
p_box->data.p_hdlr->psz_name );
#endif
......@@ -880,31 +873,30 @@ void MP4_FreeBox_hdlr( input_thread_t *p_input, MP4_Box_t *p_box )
int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_vmhd_t );
MP4_READBOX_ENTER( MP4_Box_data_vmhd_t );
MP4_GETVERSIONFLAGS( p_box->data.p_vmhd );
MP4_GET2BYTES( p_box->data.p_vmhd->i_graphics_mode );
for( i = 0; i < 3; i++ )
{
MP4_GET2BYTES( p_box->data.p_vmhd->i_opcolor[i] );
}
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"vmhd\" graphics-mode %d opcolor (%d, %d, %d)",
p_box->data.p_vmhd->i_graphics_mode,
p_box->data.p_vmhd->i_opcolor[0],
p_box->data.p_vmhd->i_opcolor[1],
p_box->data.p_vmhd->i_opcolor[2] );
#endif
MP4_READBOX_EXIT( 1 );
}
int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_smhd_t );
MP4_READBOX_ENTER( MP4_Box_data_smhd_t );
MP4_GETVERSIONFLAGS( p_box->data.p_smhd );
......@@ -913,11 +905,10 @@ int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_smhd->i_balance );
MP4_GET2BYTES( p_box->data.p_smhd->i_reserved );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"smhd\" balance %f",
(float)p_box->data.p_smhd->i_balance / 256 );
#endif
MP4_READBOX_EXIT( 1 );
}
......@@ -925,7 +916,7 @@ int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_hmhd_t );
MP4_READBOX_ENTER( MP4_Box_data_hmhd_t );
MP4_GETVERSIONFLAGS( p_box->data.p_hmhd );
......@@ -943,14 +934,13 @@ int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box->data.p_hmhd->i_avg_PDU_size,
p_box->data.p_hmhd->i_max_bitrate,
p_box->data.p_hmhd->i_avg_bitrate );
#endif
MP4_READBOX_EXIT( 1 );
}
int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_url_t );
MP4_READBOX_ENTER( MP4_Box_data_url_t );
MP4_GETVERSIONFLAGS( p_box->data.p_url );
MP4_GETSTRINGZ( p_box->data.p_url->psz_location );
......@@ -976,8 +966,8 @@ int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GETVERSIONFLAGS( p_box->data.p_urn );
MP4_GETSTRINGZ( p_box->data.p_urn->psz_name );
MP4_GETSTRINGZ( p_box->data.p_urn->psz_location );
MP4_GETSTRINGZ( p_box->data.p_urn->psz_location );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"urn\" name %s location %s",
p_box->data.p_urn->psz_name,
......@@ -995,11 +985,11 @@ void MP4_FreeBox_urn( input_thread_t *p_input, MP4_Box_t *p_box )
int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_dref_t );
MP4_GETVERSIONFLAGS( p_box->data.p_dref );
MP4_GET4BYTES( p_box->data.p_dref->i_entry_count );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
MP4_ReadBoxContainerRaw( p_stream, p_box );
......@@ -1015,23 +1005,22 @@ int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_stts_t );
MP4_READBOX_ENTER( MP4_Box_data_stts_t );
MP4_GETVERSIONFLAGS( p_box->data.p_stts );
MP4_GET4BYTES( p_box->data.p_stts->i_entry_count );
p_box->data.p_stts->i_sample_count =
p_box->data.p_stts->i_sample_count =
calloc( sizeof( uint32_t ), p_box->data.p_stts->i_entry_count );
p_box->data.p_stts->i_sample_delta =
calloc( sizeof( uint32_t ), p_box->data.p_stts->i_entry_count );
for( i = 0; (i < p_box->data.p_stts->i_entry_count )&&( i_read >=8 ); i++ )
{
MP4_GET4BYTES( p_box->data.p_stts->i_sample_count[i] );
MP4_GET4BYTES( p_box->data.p_stts->i_sample_delta[i] );
}
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"stts\" entry-count %d",
p_box->data.p_stts->i_entry_count );
......@@ -1044,30 +1033,28 @@ void MP4_FreeBox_stts( input_thread_t *p_input, MP4_Box_t *p_box )
{
FREE( p_box->data.p_stts->i_sample_count );
FREE( p_box->data.p_stts->i_sample_delta );
}
int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_ctts_t );
MP4_GETVERSIONFLAGS( p_box->data.p_ctts );
MP4_GET4BYTES( p_box->data.p_ctts->i_entry_count );
p_box->data.p_ctts->i_sample_count =
p_box->data.p_ctts->i_sample_count =
calloc( sizeof( uint32_t ), p_box->data.p_ctts->i_entry_count );
p_box->data.p_ctts->i_sample_offset =
calloc( sizeof( uint32_t ), p_box->data.p_ctts->i_entry_count );
for( i = 0; (i < p_box->data.p_ctts->i_entry_count )&&( i_read >=8 ); i++ )
{
MP4_GET4BYTES( p_box->data.p_ctts->i_sample_count[i] );
MP4_GET4BYTES( p_box->data.p_ctts->i_sample_offset[i] );
}
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"ctts\" entry-count %d",
p_box->data.p_ctts->i_entry_count );
......@@ -1094,7 +1081,7 @@ static int MP4_ReadLengthDescriptor( uint8_t **pp_peek, int64_t *i_read )
(*i_read)--;
i_len = ( i_len << 7 ) + ( i_b&0x7f );
} while( i_b&0x80 );
return( i_len );
return( i_len );
}
int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
......@@ -1128,7 +1115,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
if( es_descriptor.b_url )
{
unsigned int i_len;
MP4_GET1BYTE( i_len );
es_descriptor.psz_URL = calloc( sizeof(char), i_len + 1 );
memcpy( es_descriptor.psz_URL, p_peek, i_len );
......@@ -1153,7 +1140,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
}
i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
es_descriptor.p_decConfigDescr =
es_descriptor.p_decConfigDescr =
malloc( sizeof( MP4_descriptor_decoder_config_t ));
MP4_GET1BYTE( es_descriptor.p_decConfigDescr->i_objectTypeIndication );
......@@ -1172,7 +1159,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
es_descriptor.p_decConfigDescr->i_decoder_specific_info_len = i_len;
es_descriptor.p_decConfigDescr->p_decoder_specific_info = malloc( i_len );
memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info,
memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info,
p_peek, i_len );
MP4_READBOX_EXIT( 1 );
......@@ -1222,7 +1209,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
msg_Dbg( p_stream->p_input, "Read Box: \"soun\" in stsd channel %d sample size %d sampl rate %f",
p_box->data.p_sample_soun->i_channelcount,
p_box->data.p_sample_soun->i_samplesize,
(float)p_box->data.p_sample_soun->i_sampleratehi +
(float)p_box->data.p_sample_soun->i_sampleratehi +
(float)p_box->data.p_sample_soun->i_sampleratelo / 65536 );
#endif
......@@ -1232,7 +1219,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
#if 0
int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_sample_mp4a_t );
......@@ -1254,7 +1241,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_reserved3 );
MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_sampleratehi );
MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_sampleratelo );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 );
MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */
......@@ -1262,7 +1249,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
msg_Dbg( p_stream->p_input, "Read Box: \"mp4a\" in stsd channel %d sample size %d sampl rate %f",
p_box->data.p_sample_mp4a->i_channelcount,
p_box->data.p_sample_mp4a->i_samplesize,
(float)p_box->data.p_sample_mp4a->i_sampleratehi +
(float)p_box->data.p_sample_mp4a->i_sampleratehi +
(float)p_box->data.p_sample_mp4a->i_sampleratelo / 65536 );
#endif
......@@ -1272,7 +1259,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_sample_vide_t );
......@@ -1293,7 +1280,7 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_sample_vide->i_width );
MP4_GET2BYTES( p_box->data.p_sample_vide->i_height );
MP4_GET4BYTES( p_box->data.p_sample_vide->i_horizresolution );
MP4_GET4BYTES( p_box->data.p_sample_vide->i_vertresolution );
......@@ -1305,10 +1292,10 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES( p_box->data.p_sample_vide->i_depth );
MP4_GET2BYTES( p_box->data.p_sample_vide->i_predefined4 );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 78);
MP4_ReadBoxContainerRaw( p_stream, p_box );
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"vide\" in stsd %dx%d depth %d",
p_box->data.p_sample_vide->i_width,
......@@ -1329,7 +1316,7 @@ int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_stsd->i_entry_count );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
MP4_ReadBoxContainerRaw( p_stream, p_box );
......@@ -1347,16 +1334,16 @@ int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_stsz_t );
MP4_GETVERSIONFLAGS( p_box->data.p_stsz );
MP4_GET4BYTES( p_box->data.p_stsz->i_sample_size );
MP4_GET4BYTES( p_box->data.p_stsz->i_sample_count );
p_box->data.p_stsz->i_entry_size =
p_box->data.p_stsz->i_entry_size =
calloc( sizeof( uint32_t ), p_box->data.p_stsz->i_sample_count );
if( !p_box->data.p_stsz->i_sample_size )
{
for( i=0; (i<p_box->data.p_stsz->i_sample_count)&&(i_read >= 4 ); i++ )
......@@ -1364,9 +1351,8 @@ int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_stsz->i_entry_size[i] );
}
}
#ifdef MP4_VERBOSE
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"stsz\" sample-size %d sample-count %d",
p_box->data.p_stsz->i_sample_size,
p_box->data.p_stsz->i_sample_count );
......@@ -1383,18 +1369,18 @@ void MP4_FreeBox_stsz( input_thread_t *p_input, MP4_Box_t *p_box )
int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_stsc_t );
MP4_GETVERSIONFLAGS( p_box->data.p_stsc );
MP4_GET4BYTES( p_box->data.p_stsc->i_entry_count );
p_box->data.p_stsc->i_first_chunk =
p_box->data.p_stsc->i_first_chunk =
calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
p_box->data.p_stsc->i_samples_per_chunk =
p_box->data.p_stsc->i_samples_per_chunk =
calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
p_box->data.p_stsc->i_sample_description_index =
p_box->data.p_stsc->i_sample_description_index =
calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
for( i = 0; (i < p_box->data.p_stsc->i_entry_count )&&( i_read >= 12 );i++ )
......@@ -1403,9 +1389,8 @@ int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET4BYTES( p_box->data.p_stsc->i_samples_per_chunk[i] );
MP4_GET4BYTES( p_box->data.p_stsc->i_sample_description_index[i] );
}
#ifdef MP4_VERBOSE
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"stsc\" entry-count %d",
p_box->data.p_stsc->i_entry_count );
......@@ -1423,14 +1408,14 @@ void MP4_FreeBox_stsc( input_thread_t *p_input, MP4_Box_t *p_box )
int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
unsigned int i;
MP4_READBOX_ENTER( MP4_Box_data_co64_t );
MP4_GETVERSIONFLAGS( p_box->data.p_co64 );
MP4_GET4BYTES( p_box->data.p_co64->i_entry_count );
p_box->data.p_co64->i_chunk_offset =
p_box->data.p_co64->i_chunk_offset =
calloc( sizeof( uint64_t ), p_box->data.p_co64->i_entry_count );
for( i = 0; i < p_box->data.p_co64->i_entry_count; i++ )
......@@ -1452,9 +1437,8 @@ int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET8BYTES( p_box->data.p_co64->i_chunk_offset[i] );
}
}
#ifdef MP4_VERBOSE
#ifdef MP4_VERBOSE
msg_Dbg( p_stream->p_input, "Read Box: \"co64\" entry-count %d",
p_box->data.p_co64->i_entry_count );