* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.9 2002/11/05 10:07:56 gbazin Exp $
+ * $Id: avi.c,v 1.10 2002/11/06 14:44:30 sam Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
vlc_module_end();
/*****************************************************************************
- * Some usefull functions to manipulate memory
+ * Some useful functions to manipulate memory
*****************************************************************************/
-static u16 GetWLE( byte_t *p_buff )
+static uint16_t GetWLE( uint8_t *p_buff )
{
- return( p_buff[0] + ( p_buff[1] << 8 ) );
+ return (uint16_t)p_buff[0] | ( ((uint16_t)p_buff[1]) << 8 );
}
-static u32 GetDWLE( byte_t *p_buff )
+
+static uint32_t GetDWLE( uint8_t *p_buff )
{
- return( p_buff[0] + ( p_buff[1] << 8 ) +
- ( p_buff[2] << 16 ) + ( p_buff[3] << 24 ) );
+ return (uint32_t)p_buff[0] | ( ((uint32_t)p_buff[1]) << 8 ) |
+ ( ((uint32_t)p_buff[2]) << 16 ) | ( ((uint32_t)p_buff[3]) << 24 );
}
-static u32 GetDWBE( byte_t *p_buff )
+
+static uint32_t GetDWBE( uint8_t *p_buff )
{
- return( p_buff[3] + ( p_buff[2] << 8 ) +
- ( p_buff[1] << 16 ) + ( p_buff[0] << 24 ) );
+ return (uint32_t)p_buff[3] | ( ((uint32_t)p_buff[2]) << 8 ) |
+ ( ((uint32_t)p_buff[1]) << 16 ) | ( ((uint32_t)p_buff[0]) << 24 );
}
static vlc_fourcc_t GetFOURCC( byte_t *p_buff )
{
- return( VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] ) );
+ return VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] );
}
static inline off_t __EVEN( off_t i )
{
- return( (i & 1) ? i+1 : i );
+ return (i & 1) ? i + 1 : i;
}
#define __ABS( x ) ( (x) < 0 ? (-(x)) : (x) )
if( !(p_pes = input_NewPES( p_input->p_method_data ) ) )
{
pp_pes = NULL;
- return( -1 );
+ return -1;
}
*pp_pes = p_pes;
input_NewPacket( p_input->p_method_data, 0 );
p_pes->i_nb_data = 1;
p_pes->i_pes_size = 0;
- return( 0 );
+ return 0;
}
p_pes->i_nb_data = 0;
p_pes->i_pes_size, 1024 ) );
if( i_read <= 0 )
{
- return( p_pes->i_pes_size );
+ return p_pes->i_pes_size;
}
if( !p_pes->p_first )
}
- return( p_pes->i_pes_size );
+ return p_pes->i_pes_size;
}
/* Test if it seems that it's a key frame */
-static int AVI_GetKeyFlag( vlc_fourcc_t i_fourcc, u8 *p_byte )
+static int AVI_GetKeyFlag( vlc_fourcc_t i_fourcc, uint8_t *p_byte )
{
switch( i_fourcc )
{
case FOURCC_DIV1:
/* we have:
- startcode: 0x00000100 32bits
- framenumber ? 5bits
- piture type 0(I),1(P) 2bits
+ * startcode: 0x00000100 32bits
+ * framenumber ? 5bits
+ * piture type 0(I),1(P) 2bits
*/
if( GetDWBE( p_byte ) != 0x00000100 )
{
- /* it's not an msmpegv1 stream, strange...*/
- return( AVIIF_KEYFRAME );
+ /* it's not an msmpegv1 stream, strange...*/
+ return AVIIF_KEYFRAME;
}
else
{
- return( p_byte[4]&0x06 ? 0 : AVIIF_KEYFRAME);
+ return p_byte[4] & 0x06 ? 0 : AVIIF_KEYFRAME;
}
case FOURCC_DIV2:
case FOURCC_DIV3: // wmv1 also
/* we have
- picture type 0(I),1(P) 2bits
+ * picture type 0(I),1(P) 2bits
*/
- return( p_byte[0]&0xC0 ? 0 : AVIIF_KEYFRAME );
+ return p_byte[0] & 0xC0 ? 0 : AVIIF_KEYFRAME;
case FOURCC_mp4v:
/* we should find first occurence of 0x000001b6 (32bits)
- startcode: 0x000001b6 32bits
- piture type 0(I),1(P) 2bits
- */
+ * startcode: 0x000001b6 32bits
+ * piture type 0(I),1(P) 2bits
+ */
if( GetDWBE( p_byte ) != 0x000001b6 )
{
/* not true , need to find the first VOP header */
- return( AVIIF_KEYFRAME );
+ return AVIIF_KEYFRAME;
}
else
{
- return( p_byte[4]&0xC0 ? 0 : AVIIF_KEYFRAME );
+ return p_byte[4] & 0xC0 ? 0 : AVIIF_KEYFRAME;
}
default:
- /* I can't do it, so said yes */
- return( AVIIF_KEYFRAME );
+ /* I can't do it, so say yes */
+ return AVIIF_KEYFRAME;
}
}
{
switch( i_cat )
{
- case( AUDIO_ES ):
+ case AUDIO_ES:
switch( i_codec )
{
- case( WAVE_FORMAT_PCM ):
- return( VLC_FOURCC( 'a', 'r', 'a', 'w' ) );
- case( WAVE_FORMAT_MPEG ):
- case( WAVE_FORMAT_MPEGLAYER3 ):
- return( VLC_FOURCC( 'm', 'p', 'g', 'a' ) );
- case( WAVE_FORMAT_A52 ):
- return( VLC_FOURCC( 'a', '5', '2', ' ' ) );
- case( WAVE_FORMAT_WMA1 ):
- return( VLC_FOURCC( 'w', 'm', 'a', '1' ) );
- case( WAVE_FORMAT_WMA2 ):
- return( VLC_FOURCC( 'w', 'm', 'a', '2' ) );
+ case WAVE_FORMAT_PCM:
+ return VLC_FOURCC( 'a', 'r', 'a', 'w' );
+ case WAVE_FORMAT_MPEG:
+ case WAVE_FORMAT_MPEGLAYER3:
+ return VLC_FOURCC( 'm', 'p', 'g', 'a' );
+ case WAVE_FORMAT_A52:
+ return VLC_FOURCC( 'a', '5', '2', ' ' );
+ case WAVE_FORMAT_WMA1:
+ return VLC_FOURCC( 'w', 'm', 'a', '1' );
+ case WAVE_FORMAT_WMA2:
+ return VLC_FOURCC( 'w', 'm', 'a', '2' );
default:
- return( VLC_FOURCC( 'm', 's',
- ( i_codec >> 8 )&0xff,
- i_codec&0xff ) );
+ return VLC_FOURCC( 'm', 's',
+ ((uint8_t *)&i_codec)[2],
+ ((uint8_t *)&i_codec)[3] );
}
- case( VIDEO_ES ):
+ case VIDEO_ES:
// XXX DIV1 <- msmpeg4v1, DIV2 <- msmpeg4v2, DIV3 <- msmpeg4v3, mp4v for mpeg4
switch( i_codec )
{
case FOURCC_div1:
case FOURCC_MPG4:
case FOURCC_mpg4:
- return( FOURCC_DIV1 );
+ return FOURCC_DIV1;
case FOURCC_DIV2:
case FOURCC_div2:
case FOURCC_MP42:
case FOURCC_mp42:
case FOURCC_MPG3:
case FOURCC_mpg3:
- return( FOURCC_DIV2 );
+ return FOURCC_DIV2;
case FOURCC_div3:
case FOURCC_MP43:
case FOURCC_mp43:
case FOURCC_div6:
case FOURCC_AP41:
case FOURCC_3IV1:
- return( FOURCC_DIV3 );
+ return FOURCC_DIV3;
case FOURCC_DIVX:
case FOURCC_divx:
case FOURCC_MP4S:
case FOURCC_DX50:
case FOURCC_mp4v:
case FOURCC_4:
- return( FOURCC_mp4v );
+ return FOURCC_mp4v;
}
default:
- return( VLC_FOURCC( 'u', 'n', 'd', 'f' ) );
+ return VLC_FOURCC( 'u', 'n', 'd', 'f' );
}
}
-static void AVI_ParseStreamHeader( u32 i_id, int *pi_number, int *pi_type )
+static void AVI_ParseStreamHeader( vlc_fourcc_t i_id,
+ int *pi_number, int *pi_type )
{
#define SET_PTR( p, v ) if( p ) *(p) = (v);
- int c1,c2;
-/* XXX i_id have to be read using MKFOURCC and NOT VLC_FOURCC */
- c1 = ( i_id ) & 0xFF;
- c2 = ( i_id >> 8 ) & 0xFF;
+ int c1, c2;
+
+ c1 = ((uint8_t *)&i_id)[0];
+ c2 = ((uint8_t *)&i_id)[1];
if( c1 < '0' || c1 > '9' || c2 < '0' || c2 > '9' )
{
- SET_PTR( pi_number, 100); /* > max stream number */
- SET_PTR( pi_type, UNKNOWN_ES);
+ SET_PTR( pi_number, 100 ); /* > max stream number */
+ SET_PTR( pi_type, UNKNOWN_ES );
}
else
{
SET_PTR( pi_number, (c1 - '0') * 10 + (c2 - '0' ) );
- switch( ( i_id >> 16 ) & 0xFFFF )
+ switch( VLC_TWOCC( ((uint8_t *)&i_id)[2], ((uint8_t *)&i_id)[3] ) )
{
- case( AVITWOCC_wb ):
+ case AVITWOCC_wb:
SET_PTR( pi_type, AUDIO_ES );
break;
- case( AVITWOCC_dc ):
- case( AVITWOCC_db ):
- SET_PTR( pi_type, VIDEO_ES);
+ case AVITWOCC_dc:
+ case AVITWOCC_db:
+ SET_PTR( pi_type, VIDEO_ES );
break;
- default:
+ default:
SET_PTR( pi_type, UNKNOWN_ES );
break;
}
static int AVI_PacketGetHeader( input_thread_t *p_input, avi_packet_t *p_pk )
{
- u8 *p_peek;
+ uint8_t *p_peek;
if( input_Peek( p_input, &p_peek, 16 ) < 16 )
{
- return( 0 );
+ return VLC_EGENERIC;
}
- p_pk->i_fourcc = GetDWLE( p_peek );
+ p_pk->i_fourcc = GetFOURCC( p_peek );
p_pk->i_size = GetDWLE( p_peek + 4 );
p_pk->i_pos = AVI_TellAbsolute( p_input );
if( p_pk->i_fourcc == AVIFOURCC_LIST )
{
- p_pk->i_type = GetDWLE( p_peek + 8 );
+ p_pk->i_type = GetFOURCC( p_peek + 8 );
}
else
{
memcpy( p_pk->i_peek, p_peek + 8, 8 );
AVI_ParseStreamHeader( p_pk->i_fourcc, &p_pk->i_stream, &p_pk->i_cat );
- return( 1 );
+ return VLC_SUCCESS;
}
static int AVI_PacketNext( input_thread_t *p_input )
{
avi_packet_t avi_ck;
- if( !AVI_PacketGetHeader( p_input, &avi_ck ) )
+ if( AVI_PacketGetHeader( p_input, &avi_ck ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
if( avi_ck.i_fourcc == AVIFOURCC_LIST && avi_ck.i_type == AVIFOURCC_rec )
{
- return( AVI_SkipBytes( p_input, 12 ) );
+ return AVI_SkipBytes( p_input, 12 );
}
else
{
- return( AVI_SkipBytes( p_input, __EVEN( avi_ck.i_size ) + 8 ));
+ return AVI_SkipBytes( p_input, __EVEN( avi_ck.i_size ) + 8 );
}
}
static int AVI_PacketRead( input_thread_t *p_input,
pes_packet_t **pp_pes )
{
int i_size;
- int b_pad;
+ vlc_bool_t b_pad;
i_size = __EVEN( p_pk->i_size + 8 );
b_pad = ( i_size != p_pk->i_size + 8 );
if( input_ReadInPES( p_input, pp_pes, i_size ) != i_size )
{
- return( 0 );
+ return VLC_EGENERIC;
}
(*pp_pes)->p_first->p_payload_start += 8;
(*pp_pes)->i_pes_size -= 8;
(*pp_pes)->i_pes_size--;
}
- return( 1 );
+ return VLC_SUCCESS;
}
static int AVI_PacketSearch( input_thread_t *p_input )
avi_packet_t avi_pk;
for( ;; )
{
- if( !AVI_SkipBytes( p_input, 1 ) )
+ if( AVI_SkipBytes( p_input, 1 ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
AVI_PacketGetHeader( p_input, &avi_pk );
if( avi_pk.i_stream < p_avi->i_streams &&
( avi_pk.i_cat == AUDIO_ES || avi_pk.i_cat == VIDEO_ES ) )
{
- return( 1 );
+ return VLC_SUCCESS;
}
switch( avi_pk.i_fourcc )
{
case AVIFOURCC_JUNK:
case AVIFOURCC_LIST:
case AVIFOURCC_idx1:
- return( 1 );
+ return VLC_SUCCESS;
}
}
}
{
avi_packet_t pk;
- if( !AVI_PacketGetHeader( p_input, &pk ) )
+ if( AVI_PacketGetHeader( p_input, &pk ) )
{
break;
}
break;
default:
msg_Warn( p_input, "need resync, probably broken avi" );
- if( !AVI_PacketSearch( p_input ) )
+ if( AVI_PacketSearch( p_input ) )
{
msg_Warn( p_input, "lost sync, abord index creation" );
goto print_stat;
}
}
if( pk.i_pos + pk.i_size >= i_movi_end ||
- !AVI_PacketNext( p_input ) )
+ AVI_PacketNext( p_input ) )
{
break;
}
/*****************************************************************************
- * Stream managment
+ * Stream management
*****************************************************************************/
-static int AVI_StreamStart ( input_thread_t *, demux_sys_t *, int );
+static vlc_bool_t AVI_StreamStart ( input_thread_t *, demux_sys_t *, int );
static int AVI_StreamSeek ( input_thread_t *, demux_sys_t *, int, mtime_t );
static void AVI_StreamStop ( input_thread_t *, demux_sys_t *, int );
-static int AVI_StreamStart( input_thread_t *p_input,
- demux_sys_t *p_avi, int i_stream )
+static vlc_bool_t AVI_StreamStart( input_thread_t *p_input,
+ demux_sys_t *p_avi, int i_stream )
{
#define p_stream p_avi->pp_info[i_stream]
if( !p_stream->p_es )
{
msg_Warn( p_input, "stream[%d] unselectable", i_stream );
- return( 0 );
+ return VLC_FALSE;
}
- if( p_stream->i_activated )
+ if( p_stream->b_activated )
{
msg_Warn( p_input, "stream[%d] already selected", i_stream );
- return( 1 );
+ return VLC_TRUE;
}
if( !p_stream->p_es->p_decoder_fifo )
input_SelectES( p_input, p_stream->p_es );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
- p_stream->i_activated = p_stream->p_es->p_decoder_fifo ? 1 : 0;
- if( p_stream->i_activated )
+ p_stream->b_activated = p_stream->p_es->p_decoder_fifo ? VLC_TRUE
+ : VLC_FALSE;
+ if( p_stream->b_activated )
{
AVI_StreamSeek( p_input, p_avi, i_stream, p_avi->i_time );
}
- return( p_stream->i_activated );
+ return p_stream->b_activated;
#undef p_stream
}
{
#define p_stream p_avi->pp_info[i_stream]
- if( !p_stream->i_activated )
+ if( !p_stream->b_activated )
{
msg_Warn( p_input, "stream[%d] already unselected", i_stream );
return;
}
- p_stream->i_activated = 0;
+ p_stream->b_activated = VLC_FALSE;
#undef p_stream
}
#undef p_stream
}
- return( i_maxlength );
+ return i_maxlength;
}
/*****************************************************************************
es_descriptor_t *p_es = NULL; /* avoid warning */
int i;
- int b_stream_audio, b_stream_video;
+ vlc_bool_t b_stream_audio, b_stream_video;
p_input->pf_demux = AVIDemux_Seekable;
- if( !AVI_TestFile( p_input ) )
+ if( AVI_TestFile( p_input ) )
{
msg_Warn( p_input, "avi module discarded (invalid headr)" );
- return( -1 );
+ return VLC_EGENERIC;
}
/* Initialize access plug-in structures. */
p_avi = malloc( sizeof(demux_sys_t) ) ) )
{
msg_Err( p_input, "out of memory" );
- return( -1 );
+ return VLC_ENOMEM;
}
memset( p_avi, 0, sizeof( demux_sys_t ) );
p_avi->i_time = 0;
p_input->pf_demux = AVIDemux_UnSeekable;
}
- if( !AVI_ChunkReadRoot( p_input, &p_avi->ck_root, p_avi->b_seekable ) )
+ if( AVI_ChunkReadRoot( p_input, &p_avi->ck_root, p_avi->b_seekable ) )
{
msg_Err( p_input, "avi module discarded (invalid file)" );
- return( -1 );
+ return VLC_EGENERIC;
}
AVI_ChunkDumpDebug( p_input, &p_avi->ck_root );
if( !p_hdrl || !p_movi )
{
msg_Err( p_input, "avi module discarded (invalid file)" );
- return( -1 );
+ return VLC_EGENERIC;
}
if( !( p_avih = (avi_chunk_avih_t*)AVI_ChunkFind( p_hdrl,
AVIFOURCC_avih, 0 ) ) )
{
msg_Err( p_input, "cannot find avih chunk" );
- return( -1 );
+ return VLC_EGENERIC;
}
p_avi->i_streams = AVI_ChunkCount( p_hdrl, AVIFOURCC_strl );
if( p_avih->i_streams != p_avi->i_streams )
{
AVIEnd( p_input );
msg_Err( p_input, "no stream defined!" );
- return( -1 );
+ return VLC_EGENERIC;
}
/* create one program */
vlc_mutex_unlock( &p_input->stream.stream_lock );
AVIEnd( p_input );
msg_Err( p_input, "cannot init stream" );
- return( -1 );
+ return VLC_EGENERIC;
}
if( input_AddProgram( p_input, 0, 0) == NULL )
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
AVIEnd( p_input );
msg_Err( p_input, "cannot add program" );
- return( -1 );
+ return VLC_EGENERIC;
}
p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
vlc_mutex_unlock( &p_input->stream.stream_lock );
p_init_data = NULL;
break;
}
- p_info->i_activated = 0;
+ p_info->b_activated = VLC_FALSE;
/* add one ES */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_info->p_es =
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
- b_stream_audio = 0;
- b_stream_video = 0;
+ b_stream_audio = VLC_FALSE;
+ b_stream_video = VLC_FALSE;
for( i = 0; i < p_avi->i_streams; i++ )
{
AVI_SkipBytes( p_input, 12 ); // enter in p_movi
p_avi->i_movi_begin = p_movi->i_chunk_pos;
- return( 0 );
+ return VLC_SUCCESS;
}
static inline mtime_t AVI_PTSToChunk( avi_stream_t *p_info,
mtime_t i_pts )
{
- return( (mtime_t)((s64)i_pts *
- (s64)p_info->i_rate /
- (s64)p_info->i_scale /
- (s64)1000000 ) );
+ return (mtime_t)((int64_t)i_pts *
+ (int64_t)p_info->i_rate /
+ (int64_t)p_info->i_scale /
+ (int64_t)1000000 );
}
static inline mtime_t AVI_PTSToByte( avi_stream_t *p_info,
mtime_t i_pts )
{
- return( (mtime_t)((s64)i_pts *
- (s64)p_info->i_samplesize *
- (s64)p_info->i_rate /
- (s64)p_info->i_scale /
- (s64)1000000 ) );
+ return (mtime_t)((int64_t)i_pts *
+ (int64_t)p_info->i_samplesize *
+ (int64_t)p_info->i_rate /
+ (int64_t)p_info->i_scale /
+ (int64_t)1000000 );
}
{
if( p_stream->i_samplesize )
{
- return( (mtime_t)( (s64)1000000 *
- (s64)i_count *
- (s64)p_stream->i_scale /
- (s64)p_stream->i_rate /
- (s64)p_stream->i_samplesize ) );
+ return (mtime_t)( (int64_t)1000000 *
+ (int64_t)i_count *
+ (int64_t)p_stream->i_scale /
+ (int64_t)p_stream->i_rate /
+ (int64_t)p_stream->i_samplesize );
}
else
{
- return( (mtime_t)( (s64)1000000 *
- (s64)i_count *
- (s64)p_stream->i_scale /
- (s64)p_stream->i_rate) );
+ return (mtime_t)( (int64_t)1000000 *
+ (int64_t)i_count *
+ (int64_t)p_stream->i_scale /
+ (int64_t)p_stream->i_rate);
}
}
i_len = p_info->p_index[p_info->i_idxposc].i_lengthtotal
+ p_info->i_idxposb;
}
- return( (mtime_t)( (s64)1000000 *
- (s64)i_len *
- (s64)p_info->i_scale /
- (s64)p_info->i_rate /
- (s64)p_info->i_samplesize ) );
+ return (mtime_t)( (int64_t)1000000 *
+ (int64_t)i_len *
+ (int64_t)p_info->i_scale /
+ (int64_t)p_info->i_rate /
+ (int64_t)p_info->i_samplesize );
}
else
{
/* even if p_info->i_idxposc isn't valid, there isn't any problem */
- return( (mtime_t)( (s64)1000000 *
- (s64)(p_info->i_idxposc ) *
- (s64)p_info->i_scale /
- (s64)p_info->i_rate) );
+ return (mtime_t)( (int64_t)1000000 *
+ (int64_t)(p_info->i_idxposc ) *
+ (int64_t)p_info->i_scale /
+ (int64_t)p_info->i_rate);
}
}
if( p_avi->i_movi_lastchunk_pos >= p_avi->i_movi_begin )
{
AVI_SeekAbsolute( p_input, p_avi->i_movi_lastchunk_pos );
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
else
for( ;; )
{
- if( !AVI_PacketGetHeader( p_input, &avi_pk ) )
+ if( AVI_PacketGetHeader( p_input, &avi_pk ) )
{
msg_Err( p_input, "cannot get packet header" );
- return( 0 );
+ return VLC_EGENERIC;
}
if( avi_pk.i_stream >= p_avi->i_streams ||
( avi_pk.i_cat != AUDIO_ES && avi_pk.i_cat != VIDEO_ES ) )
AVI_SkipBytes( p_input, 12 );
break;
default:
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
break;
}
if( avi_pk.i_stream == i_stream )
{
- return( 1 );
+ return VLC_SUCCESS;
}
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
}
do
{
p_stream->i_idxposc++;
- if( !AVI_StreamChunkFind( p_input, i_stream ) )
+ if( AVI_StreamChunkFind( p_input, i_stream ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
} while( p_stream->i_idxposc < i_ck );
}
- return( 1 );
+ return VLC_SUCCESS;
}
p_stream->i_idxposc = i_idxposc;
p_stream->i_idxposb = i_byte -
p_stream->p_index[i_idxposc].i_lengthtotal;
- return( 1 );
+ return VLC_SUCCESS;
}
}
}
do
{
p_stream->i_idxposc++;
- if( !AVI_StreamChunkFind( p_input, i_stream ) )
+ if( AVI_StreamChunkFind( p_input, i_stream ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
} while( p_stream->p_index[p_stream->i_idxposc].i_lengthtotal +
p_stream->i_idxposb = i_byte -
p_stream->p_index[p_stream->i_idxposc].i_lengthtotal;
- return( 1 );
+ return VLC_SUCCESS;
}
}
if( !p_stream->i_samplesize )
{
- if( !AVI_SetStreamChunk( p_input,
- i_stream,
- AVI_PTSToChunk( p_stream, i_date ) ) )
+ if( AVI_SetStreamChunk( p_input,
+ i_stream,
+ AVI_PTSToChunk( p_stream, i_date ) ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
/* search key frame */
!( p_stream->p_index[p_stream->i_idxposc].i_flags &
AVIIF_KEYFRAME ) )
{
- if( !AVI_SetStreamChunk( p_input,
- i_stream,
- p_stream->i_idxposc - 1 ) )
+ if( AVI_SetStreamChunk( p_input,
+ i_stream,
+ p_stream->i_idxposc - 1 ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
}
!( p_stream->p_index[p_stream->i_idxposc].i_flags &
AVIIF_KEYFRAME ) )
{
- if( !AVI_SetStreamChunk( p_input,
- i_stream,
- p_stream->i_idxposc + 1 ) )
+ if( AVI_SetStreamChunk( p_input,
+ i_stream,
+ p_stream->i_idxposc + 1 ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
}
}
else
{
- if( !AVI_SetStreamBytes( p_input,
- i_stream,
- AVI_PTSToByte( p_stream, i_date ) ) )
+ if( AVI_SetStreamBytes( p_input,
+ i_stream,
+ AVI_PTSToByte( p_stream, i_date ) ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
- return( 1 );
+ return VLC_SUCCESS;
#undef p_stream
}
if( !p_avi->i_length )
{
avi_stream_t *p_stream;
- u64 i_pos;
+ uint64_t i_pos;
/* use i_percent to create a true i_date */
msg_Warn( p_input,
i_stream < p_avi->i_streams; i_stream++ )
{
p_stream = p_avi->pp_info[i_stream];
- if( p_stream->i_activated )
+ if( p_stream->b_activated )
{
break;
}
}
- if( !p_stream || !p_stream->i_activated )
+ if( !p_stream || !p_stream->b_activated )
{
msg_Err( p_input, "cannot find any selected stream" );
return( -1 );
}
/* be sure that the index exit */
- if( !AVI_SetStreamChunk( p_input,
- i_stream,
- 0 ) )
+ if( AVI_SetStreamChunk( p_input,
+ i_stream,
+ 0 ) )
{
msg_Err( p_input, "cannot seek" );
return( -1 );
p_stream->p_index[p_stream->i_idxposc].i_length + 8 )
{
/* search after i_idxposc */
- if( !AVI_SetStreamChunk( p_input,
- i_stream, p_stream->i_idxposc + 1 ) )
+ if( AVI_SetStreamChunk( p_input,
+ i_stream, p_stream->i_idxposc + 1 ) )
{
msg_Err( p_input, "cannot seek" );
return( -1 );
/* seek for chunk based streams */
for( i_stream = 0; i_stream < p_avi->i_streams; i_stream++ )
{
- if( p_stream->i_activated && !p_stream->i_samplesize )
-// if( p_stream->i_activated )
+ if( p_stream->b_activated && !p_stream->i_samplesize )
+// if( p_stream->b_activated )
{
AVI_StreamSeek( p_input, p_avi, i_stream, i_date );
p_avi->i_time = __MAX( AVI_GetPTS( p_stream ),
/* seek for bytes based streams */
for( i_stream = 0; i_stream < p_avi->i_streams; i_stream++ )
{
- if( p_stream->i_activated && p_stream->i_samplesize )
+ if( p_stream->b_activated && p_stream->i_samplesize )
{
AVI_StreamSeek( p_input, p_avi, i_stream, i_date );
// p_avi->i_time = __MAX( AVI_GetPTS( p_stream ), p_avi->i_time );
*****************************************************************************/
typedef struct avi_stream_toread_s
{
- int i_ok;
+ vlc_bool_t b_ok;
int i_toread;
static int AVIDemux_Seekable( input_thread_t *p_input )
{
int i_stream;
- int b_stream;
+ vlc_bool_t b_stream;
// cannot be more than 100 stream (dcXX or wbXX)
avi_stream_toread_t toread[100];
if( p_stream->p_es )
{
if( p_stream->p_es->p_decoder_fifo &&
- !p_stream->i_activated )
+ !p_stream->b_activated )
{
AVI_StreamStart( p_input, p_avi, i_stream );
}
else
if( !p_stream->p_es->p_decoder_fifo &&
- p_stream->i_activated )
+ p_stream->b_activated )
{
AVI_StreamStop( p_input, p_avi, i_stream );
}
#define p_stream p_avi->pp_info[i_stream]
mtime_t i_dpts;
- toread[i_stream].i_ok = p_stream->i_activated;
+ toread[i_stream].b_ok = p_stream->b_activated;
if( p_stream->i_idxposc < p_stream->i_idxnb )
{
#undef p_stream
}
- b_stream = 0;
+ b_stream = VLC_FALSE;
for( ;; )
{
#define p_stream p_avi->pp_info[i_stream]
- int b_done;
+ vlc_bool_t b_done;
pes_packet_t *p_pes;
off_t i_pos;
int i;
int i_size;
/* search for first chunk to be read */
- for( i = 0, b_done = 1, i_pos = -1; i < p_avi->i_streams; i++ )
+ for( i = 0, b_done = VLC_TRUE, i_pos = -1; i < p_avi->i_streams; i++ )
{
- if( !toread[i].i_ok ||
+ if( !toread[i].b_ok ||
AVI_GetDPTS( p_avi->pp_info[i],
toread[i].i_toread ) <= -25 * 1000 )
{
if( toread[i].i_toread > 0 )
{
- b_done = 0; // not yet finished
+ b_done = VLC_FALSE; // not yet finished
}
if( toread[i].i_posf > 0 )
if( p_avi->i_movi_lastchunk_pos >= p_avi->i_movi_begin )
{
AVI_SeekAbsolute( p_input, p_avi->i_movi_lastchunk_pos );
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
return( 0 );
}
{
avi_packet_t avi_pk;
- if( !AVI_PacketGetHeader( p_input, &avi_pk ) )
+ if( AVI_PacketGetHeader( p_input, &avi_pk ) )
{
msg_Err( p_input, "cannot get packet header" );
return( 0 );
AVI_SkipBytes( p_input, 12 );
break;
default:
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
msg_Err( p_input, "cannot skip packet" );
return( 0 );
}
else
{
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
msg_Err( p_input, "cannot skip packet" );
return( 0 );
if( input_ReadInPES( p_input, &p_pes, __EVEN( i_size ) ) < 0 )
{
msg_Err( p_input, "failled reading data" );
- toread[i_stream].i_ok = 0;
+ toread[i_stream].b_ok = VLC_FALSE;
continue;
}
toread[i_stream].i_posf = -1;
}
- b_stream = 1; // at least one read succeed
+ b_stream = VLC_TRUE; // at least one read succeed
if( p_stream->p_es && p_stream->p_es->p_decoder_fifo )
{
input_DeletePES( p_input->p_method_data, p_pes );
}
}
-
}
/*****************************************************************************
- * AVIDemux_UnSeekable: reads and demuxes data packets for unseekable
- * file
+ * AVIDemux_UnSeekable: reads and demuxes data packets for unseekable file
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
{
demux_sys_t *p_avi = p_input->p_demux_data;
avi_stream_t *p_stream_master;
+ vlc_bool_t b_audio;
int i_stream;
- int b_audio;
int i_packet;
/* *** send audio data to decoder only if rate == DEFAULT_RATE *** */
avi_packet_t avi_pk;
- if( !AVI_PacketGetHeader( p_input, &avi_pk ) )
+ if( AVI_PacketGetHeader( p_input, &avi_pk ) )
{
return( 0 );
}
( avi_pk.i_cat != AUDIO_ES && avi_pk.i_cat != VIDEO_ES ) )
{
/* we haven't found an audio or video packet:
- - we have seek, found first next packet
- - others packets could be found, skip them
- */
+ * - we have seek, found first next packet
+ * - others packets could be found, skip them
+ */
switch( avi_pk.i_fourcc )
{
case AVIFOURCC_JUNK:
case AVIFOURCC_LIST:
- return( AVI_PacketNext( p_input ) ? 1 : 0 );
+ return( !AVI_PacketNext( p_input ) ? 1 : 0 );
case AVIFOURCC_idx1:
return( 0 ); // eof
default:
msg_Warn( p_input,
"seems to have lost position, resync" );
- if( !AVI_PacketSearch( p_input ) )
+ if( AVI_PacketSearch( p_input ) )
{
msg_Err( p_input, "resync failed" );
return( -1 );
!p_stream->p_es ||
!p_stream->p_es->p_decoder_fifo )
{
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
return( 0 );
}
{
/* load it and send to decoder */
pes_packet_t *p_pes;
- if( !AVI_PacketRead( p_input, &avi_pk, &p_pes ) || !p_pes)
+ if( AVI_PacketRead( p_input, &avi_pk, &p_pes ) || !p_pes)
{
return( -1 );
}
}
else
{
- if( !AVI_PacketNext( p_input ) )
+ if( AVI_PacketNext( p_input ) )
{
return( 0 );
}
* libavi.c :
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: libavi.c,v 1.5 2002/11/05 23:48:46 gbazin Exp $
+ * $Id: libavi.c,v 1.6 2002/11/06 14:44:30 sam Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
#define AVI_DEBUG 1
#define AVIFOURCC_PRINT( x ) \
- ((u8 *)&x)[0], \
- ((u8 *)&x)[1], \
- ((u8 *)&x)[2], \
- ((u8 *)&x)[3]
-
+ (x)&0xff, \
+ ( (x) >> 8 )&0xff, \
+ ( (x) >> 16 )&0xff, \
+ ( (x) >> 24 )&0xff
+
#define FREE( p ) \
if( p ) {free( p ); p = NULL; }
#define __EVEN( x ) ( (x)&0x01 ? (x)+1 : (x) )
/* Some functions to manipulate memory */
-static u16 GetWLE( u8 *p_buff )
+static uint16_t GetWLE( uint8_t *p_buff )
{
- return( (p_buff[0]) + ( p_buff[1] <<8 ) );
+ return (uint16_t)p_buff[0] | ( ((uint16_t)p_buff[1]) << 8 );
}
-static u32 GetDWLE( u8 *p_buff )
+static uint32_t GetDWLE( uint8_t *p_buff )
{
- return( p_buff[0] + ( p_buff[1] <<8 ) +
- ( p_buff[2] <<16 ) + ( p_buff[3] <<24 ) );
+ return (uint32_t)p_buff[0] | ( ((uint32_t)p_buff[1]) << 8 ) |
+ ( ((uint32_t)p_buff[2]) << 16 ) | ( ((uint32_t)p_buff[3]) << 24 );
}
static vlc_fourcc_t GetFOURCC( byte_t *p_buff )
{
- return( VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] ) );
+ return VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] );
}
/*****************************************************************************
* Some basic functions to manipulate stream more easily in vlc
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return( i_pos );
+ return i_pos;
}
int AVI_SeekAbsolute( input_thread_t *p_input,
if( i_pos >= p_input->stream.p_selected_area->i_size )
{
- return( 0 );
+ return VLC_EGENERIC;
}
i_filepos = AVI_TellAbsolute( p_input );
if( i_filepos == i_pos )
{
- return( 1 );
+ return VLC_SUCCESS;
}
if( p_input->stream.b_seekable &&
{
p_input->pf_seek( p_input, i_pos );
input_AccessReinit( p_input );
- return( 1 );
+ return VLC_SUCCESS;
}
else
{
msg_Warn( p_input, "will skip %d bytes, slow", i_skip );
if( i_skip < 0 )
{
- return( 0 ); // failed
+ return VLC_EGENERIC; // failed
}
while (i_skip > 0 )
{
__MIN( 4096, i_skip ) );
if( i_read < 0 )
{
- return( 0 );
+ return VLC_EGENERIC;
}
i_skip -= i_read;
input_DeletePacket( p_input->p_method_data, p_data );
if( i_read == 0 && i_skip > 0 )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
#if 0
vlc_mutex_unlock( &p_input->stream.stream_lock );
if( i_peek <= 0 )
{
- return( 0);
+ return VLC_EGENERIC;
}
}
#endif
- return( 1 );
+ return VLC_SUCCESS;
}
}
-/* return 1 if success, 0 if fail */
-int AVI_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size )
+/* return amount read if success, 0 if failed */
+int AVI_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size )
{
data_packet_t *p_data;
if( !i_size )
{
- return( 0 );
+ return 0;
}
do
i_count = input_SplitBuffer(p_input, &p_data, __MIN( i_size, 1024 ) );
if( i_count <= 0 )
{
- return( i_read );
+ return i_read;
}
memcpy( p_buff, p_data->p_payload_start, i_count );
input_DeletePacket( p_input->p_method_data, p_data );
} while( i_size );
- return( i_read );
+ return i_read;
}
int AVI_SkipBytes( input_thread_t *p_input, int i_count )
if( i_count > 0 && i_count + 1 < i_buff_size )
{
- u8 *p_peek;
+ uint8_t *p_peek;
input_Peek( p_input, &p_peek, i_count + 1 );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->p_current_data += i_count; // skip them
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return( 1 );
+ return VLC_SUCCESS;
}
else
#endif
{
- return( AVI_SeekAbsolute( p_input,
- AVI_TellAbsolute( p_input ) + i_count ) );
+ return AVI_SeekAbsolute( p_input,
+ AVI_TellAbsolute( p_input ) + i_count );
}
}
*****************************************************************************/
int AVI_TestFile( input_thread_t *p_input )
{
- u8 *p_peek;
+ uint8_t *p_peek;
if( input_Peek( p_input, &p_peek, 8 ) < 8 )
{
msg_Err( p_input, "cannot peek()" );
- return( 0 );
+ return VLC_EGENERIC;
}
- if( GetDWLE( p_peek ) == AVIFOURCC_RIFF &&
- GetDWLE( p_peek + 8 ) == AVIFOURCC_AVI )
+ if( GetFOURCC( p_peek ) == AVIFOURCC_RIFF &&
+ GetFOURCC( p_peek + 8 ) == AVIFOURCC_AVI )
{
- return( 1 );
+ return VLC_SUCCESS;
}
else
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
/****************************************************************************
static int AVI_ChunkReadCommon( input_thread_t *p_input,
avi_chunk_t *p_chk )
{
- u8 *p_peek;
+ uint8_t *p_peek;
int i_peek;
memset( p_chk, 0, sizeof( avi_chunk_t ) );
if( ( i_peek = input_Peek( p_input, &p_peek, 8 ) ) < 8 )
{
- return( 0 );
+ return VLC_EGENERIC;
}
- p_chk->common.i_chunk_fourcc = GetDWLE( p_peek );
+ p_chk->common.i_chunk_fourcc = GetFOURCC( p_peek );
p_chk->common.i_chunk_size = GetDWLE( p_peek + 4 );
p_chk->common.i_chunk_pos = AVI_TellAbsolute( p_input );
p_chk->common.i_chunk_size,
p_chk->common.i_chunk_pos );
#endif
- return( 1 );
+ return VLC_SUCCESS;
}
static int AVI_NextChunk( input_thread_t *p_input,
if( !p_chk )
{
- if( !AVI_ChunkReadCommon( p_input, &chk ) )
+ if( AVI_ChunkReadCommon( p_input, &chk ) )
{
- return( 0 );
+ return VLC_EGENERIC;
}
p_chk = &chk;
}
p_chk->common.i_chunk_pos +
__EVEN( p_chk->common.i_chunk_size ) + 8 )
{
- return( 0 );
+ return VLC_EGENERIC;
}
}
- return( AVI_SeekAbsolute( p_input,
- p_chk->common.i_chunk_pos +
- __EVEN( p_chk->common.i_chunk_size ) + 8 ) );
+ return AVI_SeekAbsolute( p_input,
+ p_chk->common.i_chunk_pos +
+ __EVEN( p_chk->common.i_chunk_size ) + 8 );
}
int _AVI_ChunkGoto( input_thread_t *p_input,
{
if( !p_chk )
{
- return( 0 );
+ return VLC_EGENERIC;
}
- return( AVI_SeekAbsolute( p_input, p_chk->common.i_chunk_pos ) );
+ return AVI_SeekAbsolute( p_input, p_chk->common.i_chunk_pos );
}
/****************************************************************************
****************************************************************************/
static int AVI_ChunkRead_list( input_thread_t *p_input,
avi_chunk_t *p_container,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
avi_chunk_t *p_chk;
- u8 *p_peek;
+ uint8_t *p_peek;
if( p_container->common.i_chunk_size < 8 )
{
/* empty box */
msg_Warn( p_input, "empty list chunk" );
- return( 0 );
+ return VLC_EGENERIC;
}
if( input_Peek( p_input, &p_peek, 12 ) < 12 )
{
msg_Warn( p_input, "cannot peek while reading list chunk" );
- return( 0 );
+ return VLC_EGENERIC;
}
- p_container->list.i_type = GetDWLE( p_peek + 8 );
+ p_container->list.i_type = GetFOURCC( p_peek + 8 );
if( p_container->common.i_chunk_fourcc == AVIFOURCC_LIST &&
p_container->list.i_type == AVIFOURCC_movi )
msg_Dbg( p_input, "Skipping movi chunk" );
if( b_seekable )
{
- return( AVI_NextChunk( p_input, p_container ) );
+ return AVI_NextChunk( p_input, p_container );
}
else
{
- return( 1 ); // point at begining of LIST-movi
+ return VLC_SUCCESS; // point at begining of LIST-movi
}
}
}
p_container->common.p_last = p_chk;
- if( !AVI_ChunkRead( p_input, p_chk, p_container, b_seekable ) ||
+ if( AVI_ChunkRead( p_input, p_chk, p_container, b_seekable ) ||
( AVI_TellAbsolute( p_input ) >=
p_chk->common.p_father->common.i_chunk_pos +
__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) )
}
- return( 1 );
+ return VLC_SUCCESS;
}
#define AVI_READCHUNK_ENTER \
- s64 i_read = __EVEN(p_chk->common.i_chunk_size ) + 8; \
- u8 *p_read, *p_buff; \
+ int64_t i_read = __EVEN(p_chk->common.i_chunk_size ) + 8; \
+ uint8_t *p_read, *p_buff; \
if( !( p_read = p_buff = malloc(i_read ) ) ) \
{ \
- return( 0 ); \
+ return 0; \
} \
i_read = AVI_ReadData( p_input, p_read, i_read ); \
p_read += 8; \
free( p_buff ); \
if( i_read < 0 ) \
{ \
- msg_Warn( p_input, "not enougth data" ); \
+ msg_Warn( p_input, "not enough data" ); \
} \
- return( code )
+ return code
#define AVI_READ2BYTES( i_word ) \
i_word = GetWLE( p_read ); \
p_read += 2; \
static int AVI_ChunkRead_avih( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
AVI_READCHUNK_ENTER;
p_chk->avih.i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"",
p_chk->avih.i_width, p_chk->avih.i_height );
#endif
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static int AVI_ChunkRead_strh( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
AVI_READCHUNK_ENTER;
(float)p_chk->strh.i_rate / (float)p_chk->strh.i_scale : -1) );
#endif
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static int AVI_ChunkRead_strf( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
avi_chunk_t *p_strh;
if( p_chk->common.p_father == NULL )
{
msg_Err( p_input, "malformed avi file" );
- AVI_READCHUNK_EXIT( 0 );
+ AVI_READCHUNK_EXIT( VLC_EGENERIC );
}
if( !( p_strh = AVI_ChunkFind( p_chk->common.p_father, AVIFOURCC_strh, 0 ) ) )
{
msg_Err( p_input, "malformed avi file" );
- AVI_READCHUNK_EXIT( 0 );
+ AVI_READCHUNK_EXIT( VLC_EGENERIC );
}
switch( p_strh->strh.i_type )
msg_Warn( p_input, "unknown stream type" );
break;
}
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static void AVI_ChunkFree_strf( input_thread_t *p_input,
avi_chunk_t *p_chk )
static int AVI_ChunkRead_strd( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
AVI_READCHUNK_ENTER;
p_chk->strd.p_data = malloc( p_chk->common.i_chunk_size );
memcpy( p_chk->strd.p_data,
p_buff,
p_chk->common.i_chunk_size );
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static int AVI_ChunkRead_idx1( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
int i_count, i_index;
for( i_index = 0; i_index < i_count ; i_index++ )
{
- AVI_READ4BYTES( p_chk->idx1.entry[i_index].i_fourcc );
+ AVI_READFOURCC( p_chk->idx1.entry[i_index].i_fourcc );
AVI_READ4BYTES( p_chk->idx1.entry[i_index].i_flags );
AVI_READ4BYTES( p_chk->idx1.entry[i_index].i_pos );
AVI_READ4BYTES( p_chk->idx1.entry[i_index].i_length );
#ifdef AVI_DEBUG
msg_Dbg( p_input, "idx1: index entry:%d", i_count );
#endif
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static void AVI_ChunkFree_idx1( input_thread_t *p_input,
static struct
{
- u32 i_fourcc;
+ vlc_fourcc_t i_fourcc;
char *psz_type;
} AVI_strz_type[] =
{
};
static int AVI_ChunkRead_strz( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
int i_index;
avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk;
msg_Dbg( p_input, "%c%c%c%c: %s : %s",
AVIFOURCC_PRINT( p_strz->i_chunk_fourcc), p_strz->p_type, p_strz->p_str);
#endif
- AVI_READCHUNK_EXIT( 1 );
+ AVI_READCHUNK_EXIT( VLC_SUCCESS );
}
static void AVI_ChunkFree_strz( input_thread_t *p_input,
avi_chunk_t *p_chk )
static int AVI_ChunkRead_nothing( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
- return( AVI_NextChunk( p_input, p_chk ) );
+ return AVI_NextChunk( p_input, p_chk );
}
static void AVI_ChunkFree_nothing( input_thread_t *p_input,
avi_chunk_t *p_chk )
static struct
{
- u32 i_fourcc;
+ vlc_fourcc_t i_fourcc;
int (*AVI_ChunkRead_function)( input_thread_t *p_input,
avi_chunk_t *p_chk,
- int b_seekable );
+ vlc_bool_t b_seekable );
void (*AVI_ChunkFree_function)( input_thread_t *p_input,
avi_chunk_t *p_chk );
} AVI_Chunk_Function [] =
if( ( AVI_Chunk_Function[i_index].i_fourcc == i_fourcc )||
( AVI_Chunk_Function[i_index].i_fourcc == 0 ) )
{
- return( i_index );
+ return i_index;
}
}
}
int _AVI_ChunkRead( input_thread_t *p_input,
avi_chunk_t *p_chk,
avi_chunk_t *p_father,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
int i_index;
- int i_result;
-
if( !p_chk )
{
- return( 0 );
+ return VLC_EGENERIC;
}
- if( !AVI_ChunkReadCommon( p_input, p_chk ) )
+ if( AVI_ChunkReadCommon( p_input, p_chk ) )
{
msg_Warn( p_input, "cannot read one chunk" );
- return( 0 );
+ return VLC_EGENERIC;
}
p_chk->common.p_father = p_father;
i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc );
if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function )
{
- i_result =
- AVI_Chunk_Function[i_index].AVI_ChunkRead_function( p_input,
- p_chk,
- b_seekable );
- }
- else
- {
- msg_Warn( p_input, "unknown chunk (not loaded)" );
- i_result = AVI_NextChunk( p_input, p_chk );
+ return AVI_Chunk_Function[i_index].
+ AVI_ChunkRead_function( p_input, p_chk, b_seekable );
}
- return( i_result );
+ msg_Warn( p_input, "unknown chunk (not loaded)" );
+ return AVI_NextChunk( p_input, p_chk );
}
void _AVI_ChunkFree( input_thread_t *p_input,
int AVI_ChunkReadRoot( input_thread_t *p_input,
avi_chunk_t *p_root,
- int b_seekable )
+ vlc_bool_t b_seekable )
{
avi_chunk_list_t *p_list = (avi_chunk_list_t*)p_root;
avi_chunk_t *p_chk;
}
p_root->common.p_last = p_chk;
- if( !AVI_ChunkRead( p_input, p_chk, p_root, b_seekable ) ||
+ if( AVI_ChunkRead( p_input, p_chk, p_root, b_seekable ) ||
( AVI_TellAbsolute( p_input ) >=
p_chk->common.p_father->common.i_chunk_pos +
__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) )
}
}
- return( 1 );
+ return VLC_SUCCESS;
}
void AVI_ChunkFreeRoot( input_thread_t *p_input,
}
-int _AVI_ChunkCount( avi_chunk_t *p_chk, u32 i_fourcc )
+int _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc )
{
int i_count;
avi_chunk_t *p_child;
if( !p_chk )
{
- return( 0 );
+ return 0;
}
i_count = 0;
}
p_child = p_child->common.p_next;
}
- return( i_count );
+ return i_count;
}
-avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk, u32 i_fourcc, int i_number )
+avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk,
+ vlc_fourcc_t i_fourcc, int i_number )
{
avi_chunk_t *p_child;
if( !p_chk )
{
- return( NULL );
+ return NULL;
}
p_child = p_chk->common.p_first;
if( i_number == 0 )
{
/* We found it */
- return( p_child );
+ return p_child;
}
i_number--;
}
p_child = p_child->common.p_next;
}
- return( NULL );
+ return NULL;
}
static void AVI_ChunkDumpDebug_level( input_thread_t *p_input,