*****************************************************************************/
#include <vlc/vlc.h>
-#include <stdio.h>
-#include <stdlib.h> /* malloc(), free() */
#include <vlc_demux.h>
*/
-static uint32_t Get24bBE( uint8_t *p )
+static uint32_t Get24bBE( const uint8_t *p )
{
return( ( p[0] <<16 ) + ( p[1] <<8 ) + p[2] );
}
-static void GetUUID( UUID_t *p_uuid, uint8_t *p_buff )
+static void GetUUID( UUID_t *p_uuid, const uint8_t *p_buff )
{
memcpy( p_uuid, p_buff, 16 );
}
int MP4_ReadBoxCommon( stream_t *p_stream, MP4_Box_t *p_box )
{
int i_read;
- uint8_t *p_peek;
+ const uint8_t *p_peek;
if( ( ( i_read = stream_Peek( p_stream, &p_peek, 32 ) ) < 8 ) )
{
if( p_box->p_father )
{
+ const int i_box_end = p_box->i_size + p_box->i_pos;
+ const int i_father_end = p_box->p_father->i_size + p_box->p_father->i_pos;
+
/* check if it's within p-father */
- if( p_box->i_size + p_box->i_pos >=
- p_box->p_father->i_size + p_box->p_father->i_pos )
+ if( i_box_end >= i_father_end )
{
- msg_Dbg( p_stream, "out of bound child" );
+ if( i_box_end > i_father_end )
+ msg_Dbg( p_stream, "out of bound child" );
return 0; /* out of bound */
}
}
p_box->p_father->i_type == VLC_FOURCC( 'r', 'o', 'o', 't' ) &&
p_box->i_type == FOURCC_free )
{
- uint8_t *p_peek;
+ const uint8_t *p_peek;
int i_read;
vlc_fourcc_t i_fcc;
{
/* SoundDescriptionV2 */
double f_sample_rate;
- int64_t dummy;
+ int64_t dummy;
uint32_t i_channel;
MP4_GET4BYTES( p_box->data.p_sample_soun->i_sample_per_packet );
MP4_GET8BYTES( dummy );
- memcpy( &f_sample_rate, &dummy, 8 );
+ memcpy( &f_sample_rate, &dummy, 8 );
msg_Dbg( p_stream, "read box: %f Hz", f_sample_rate );
p_box->data.p_sample_soun->i_sampleratehi = (int)f_sample_rate % 65536;
}
#ifdef MP4_VERBOSE
- msg_Dbg( p_stream, "read box: \"elst\" entry-count "I64Fd, p_box->data.p_elst->i_entry_count );
+ msg_Dbg( p_stream, "read box: \"elst\" entry-count %lu",
+ (unsigned long)p_box->data.p_elst->i_entry_count );
#endif
MP4_READBOX_EXIT( 1 );
}
#ifdef MP4_VERBOSE
msg_Dbg( p_stream,
- "read box: \"%4.4s\" text=`%s'",
- (char*)&p_box->i_type,
+ "read box: \"c%3.3s\" text=`%s'",
+ ((char*)&p_box->i_type + 1),
p_box->data.p_0xa9xxx->psz_text );
#endif
}
p_box->data.p_0xa9xxx->psz_text[i_data_len] = '\0';
#ifdef MP4_VERBOSE
msg_Dbg( p_stream,
- "read box: \"%4.4s\" text=`%s'",
- (char*)&p_box->i_type,
+ "read box: \"c%3.3s\" text=`%s'",
+ ((char*)&p_box->i_type+1),
p_box->data.p_0xa9xxx->psz_text );
#endif
}
free( p_chpl->chapter[i].psz_name );
}
+static int MP4_ReadBox_tref_generic( stream_t *p_stream, MP4_Box_t *p_box )
+{
+ unsigned int i;
+ MP4_READBOX_ENTER( MP4_Box_data_tref_generic_t );
+
+ p_box->data.p_tref_generic->i_track_ID = NULL;
+ p_box->data.p_tref_generic->i_entry_count = i_read / sizeof(uint32_t);
+ if( p_box->data.p_tref_generic->i_entry_count > 0 )
+ p_box->data.p_tref_generic->i_track_ID = malloc( p_box->data.p_tref_generic->i_entry_count * sizeof(uint32_t) );
+
+ for( i = 0; i < p_box->data.p_tref_generic->i_entry_count; i++ )
+ {
+ MP4_GET4BYTES( p_box->data.p_tref_generic->i_track_ID[i] );
+ }
+#ifdef MP4_VERBOSE
+ msg_Dbg( p_stream, "read box: \"chap\" %d references",
+ p_box->data.p_tref_generic->i_entry_count );
+#endif
+
+ MP4_READBOX_EXIT( 1 );
+}
+static void MP4_FreeBox_tref_generic( MP4_Box_t *p_box )
+{
+ FREENULL( p_box->data.p_tref_generic->i_track_ID );
+}
+
static int MP4_ReadBox_meta( stream_t *p_stream, MP4_Box_t *p_box )
{
uint8_t meta_data[8];
{ FOURCC_dpnd, MP4_ReadBox_default, NULL },
{ FOURCC_ipir, MP4_ReadBox_default, NULL },
{ FOURCC_mpod, MP4_ReadBox_default, NULL },
+ { FOURCC_chap, MP4_ReadBox_tref_generic, MP4_FreeBox_tref_generic },
/* found in hnti */
{ FOURCC_rtp, MP4_ReadBox_default, NULL },