/*****************************************************************************
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.68 2003/11/16 15:51:59 titer Exp $
+ * Copyright (C) 2001-2004 VideoLAN
+ * $Id$
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
#include <vlc/vlc.h>
#include <vlc/input.h>
+
+#include "vlc_meta.h"
#include "codecs.h"
#include "libavi.h"
-#include "avi.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+
+#define INTERLEAVE_TEXT N_("Force interleaved method" )
+#define INTERLEAVE_LONGTEXT N_( "Force interleaved method" )
+
+#define INDEX_TEXT N_("Force index creation")
+#define INDEX_LONGTEXT N_( \
+ "Recreate a index for the AVI file so we can seek trough it more reliably." )
+
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
vlc_module_begin();
- add_category_hint( N_("avi-demuxer"), NULL, VLC_TRUE );
- add_bool( "avi-interleaved", 0, NULL,
- N_("force interleaved method"),
- N_("force interleaved method"), VLC_TRUE );
- add_bool( "avi-index", 0, NULL,
- N_("force index creation"),
- N_("force index creation"), VLC_TRUE );
-
- set_description( N_("AVI demuxer") );
+ set_description( _("AVI demuxer") );
set_capability( "demux", 212 );
+
+ add_bool( "avi-interleaved", 0, NULL,
+ INTERLEAVE_TEXT, INTERLEAVE_LONGTEXT, VLC_TRUE );
+ add_bool( "avi-index", 0, NULL,
+ INDEX_TEXT, INDEX_LONGTEXT, VLC_TRUE );
+
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Control ( input_thread_t *, int, va_list );
-static int Seek ( input_thread_t *, mtime_t, int );
-static int Demux_Seekable ( input_thread_t * );
-static int Demux_UnSeekable( input_thread_t *p_input );
+static int Control ( input_thread_t *, int, va_list );
+static int Seek ( input_thread_t *, mtime_t, int );
+static int Demux_Seekable ( input_thread_t * );
+static int Demux_UnSeekable( input_thread_t * );
#define FREE( p ) if( p ) { free( p ); (p) = NULL; }
#define __ABS( x ) ( (x) < 0 ? (-(x)) : (x) )
+typedef struct
+{
+ vlc_fourcc_t i_fourcc;
+ off_t i_pos;
+ uint32_t i_size;
+ vlc_fourcc_t i_type; /* only for AVIFOURCC_LIST */
+
+ uint8_t i_peek[8]; /* first 8 bytes */
+
+ unsigned int i_stream;
+ unsigned int i_cat;
+} avi_packet_t;
+
+
+typedef struct
+{
+ vlc_fourcc_t i_id;
+ uint32_t i_flags;
+ off_t i_pos;
+ uint32_t i_length;
+ uint32_t i_lengthtotal;
+
+} avi_entry_t;
+
+typedef struct
+{
+ vlc_bool_t b_activated;
+
+ unsigned int i_cat; /* AUDIO_ES, VIDEO_ES */
+ vlc_fourcc_t i_codec;
+
+ int i_rate;
+ int i_scale;
+ int i_samplesize;
+
+ es_out_id_t *p_es;
+
+ avi_entry_t *p_index;
+ unsigned int i_idxnb;
+ unsigned int i_idxmax;
+
+ unsigned int i_idxposc; /* numero of chunk */
+ unsigned int i_idxposb; /* byte in the current chunk */
+
+ /* For VBR audio only */
+ unsigned int i_blockno;
+ unsigned int i_blocksize;
+} avi_track_t;
+
+struct demux_sys_t
+{
+ mtime_t i_time;
+ mtime_t i_length;
+ mtime_t i_pcr;
+
+ vlc_bool_t b_seekable;
+ avi_chunk_t ck_root;
+
+ vlc_bool_t b_odml;
+
+ off_t i_movi_begin;
+ off_t i_movi_lastchunk_pos; /* XXX position of last valid chunk */
+
+ /* number of streams and information */
+ unsigned int i_track;
+ avi_track_t **track;
+
+ /* meta */
+ vlc_meta_t *meta;
+};
+
static inline off_t __EVEN( off_t i )
{
return (i & 1) ? i + 1 : i;
static int AVI_PacketGetHeader( input_thread_t *, avi_packet_t *p_pk );
static int AVI_PacketNext ( input_thread_t * );
-static int AVI_PacketRead ( input_thread_t *, avi_packet_t *, pes_packet_t **);
+static int AVI_PacketRead ( input_thread_t *, avi_packet_t *, block_t **);
static int AVI_PacketSearch ( input_thread_t * );
static void AVI_IndexLoad ( input_thread_t * );
static void AVI_IndexCreate ( input_thread_t * );
-static void AVI_IndexAddEntry( demux_sys_t *, int, AVIIndexEntry_t * );
+static void AVI_IndexAddEntry( demux_sys_t *, int, avi_entry_t * );
static mtime_t AVI_MovieGetLength( input_thread_t * );
static int AVI_TrackSeek ( input_thread_t *, int, mtime_t );
static int AVI_TrackStopFinishedStreams( input_thread_t *);
+/* Remarks:
+ - For VBR mp3 stream:
+ count blocks by rounded-up chunksizes instead of chunks
+ we need full emulation of dshow avi demuxer bugs :(
+ fixes silly nandub-style a-v delaying in avi with vbr mp3...
+ (from mplayer 2002/08/02)
+ - to complete....
+ */
+
/*****************************************************************************
* Open: check file and initializes AVI structures
*****************************************************************************/
p_sys->b_odml = VLC_FALSE;
p_sys->i_track = 0;
p_sys->track = NULL;
+ p_sys->meta = NULL;
stream_Control( p_input->s, STREAM_CAN_FASTSEEK, &p_sys->b_seekable );
p_avih->i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"",
p_avih->i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
p_avih->i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"" );
+ if( ( p_sys->meta = vlc_meta_New() ) )
{
- input_info_category_t *p_cat = input_InfoCategory( p_input, _("Avi") );
- input_AddInfo( p_cat, _("Number of Streams"), "%d", i_track );
- input_AddInfo( p_cat, _("Flags"), "%s%s%s%s",
- p_avih->i_flags&AVIF_HASINDEX?" HAS_INDEX":"",
- p_avih->i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"",
- p_avih->i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
- p_avih->i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"" );
+ char buffer[200];
+ sprintf( buffer, "%s%s%s%s",
+ p_avih->i_flags&AVIF_HASINDEX?" HAS_INDEX":"",
+ p_avih->i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"",
+ p_avih->i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
+ p_avih->i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"" );
+ vlc_meta_Add( p_sys->meta, VLC_META_SETTING, buffer );
}
/* now read info on each stream and create ES */
tk->i_idxposc = 0;
tk->i_idxposb = 0;
+ tk->i_blockno = 0;
+ tk->i_blocksize = 0;
+
p_auds = (void*)p_vids = (void*)AVI_ChunkFind( p_strl, AVIFOURCC_strf, 0 );
if( p_strl == NULL || p_strh == NULL || p_auds == NULL || p_vids == NULL )
tk->i_cat = AUDIO_ES;
tk->i_codec = AVI_FourccGetCodec( AUDIO_ES,
p_auds->p_wf->wFormatTag );
+ if( ( tk->i_blocksize = p_auds->p_wf->nBlockAlign ) == 0 )
+ {
+ if( p_auds->p_wf->wFormatTag == 1 )
+ {
+ tk->i_blocksize = p_auds->p_wf->nChannels * (p_auds->p_wf->wBitsPerSample/8);
+ }
+ else
+ {
+ tk->i_blocksize = 1;
+ }
+ }
es_format_Init( &fmt, AUDIO_ES, tk->i_codec );
fmt.audio.i_channels = p_auds->p_wf->nChannels;
- fmt.audio.i_samplerate = p_auds->p_wf->nSamplesPerSec;
- fmt.audio.i_bitrate = p_auds->p_wf->nAvgBytesPerSec * 8;
+ fmt.audio.i_rate = p_auds->p_wf->nSamplesPerSec;
+ fmt.i_bitrate = p_auds->p_wf->nAvgBytesPerSec*8;
fmt.audio.i_blockalign = p_auds->p_wf->nBlockAlign;
fmt.audio.i_bitspersample = p_auds->p_wf->wBitsPerSample;
- if( ( fmt.i_extra = __MIN( p_auds->p_wf->cbSize,
- p_auds->i_chunk_size - sizeof(WAVEFORMATEX) ) ) > 0 )
- {
- fmt.i_extra_type = ES_EXTRA_TYPE_WAVEFORMATEX;
- fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra );
- }
+ fmt.i_extra = __MIN( p_auds->p_wf->cbSize,
+ p_auds->i_chunk_size - sizeof(WAVEFORMATEX) );
+ fmt.p_extra = &p_auds->p_wf[1];
msg_Dbg( p_input, "stream[%d] audio(0x%x) %d channels %dHz %dbits",
- i,
- p_auds->p_wf->wFormatTag, p_auds->p_wf->nChannels,
+ i, p_auds->p_wf->wFormatTag, p_auds->p_wf->nChannels,
p_auds->p_wf->nSamplesPerSec, p_auds->p_wf->wBitsPerSample);
break;
tk->i_cat = VIDEO_ES;
tk->i_codec = AVI_FourccGetCodec( VIDEO_ES,
p_vids->p_bih->biCompression );
- es_format_Init( &fmt, VIDEO_ES, p_vids->p_bih->biCompression );
+ if( p_vids->p_bih->biCompression == 0x00 )
+ {
+ switch( p_vids->p_bih->biBitCount )
+ {
+ case 32:
+ tk->i_codec = VLC_FOURCC('R','V','3','2');
+ break;
+ case 24:
+ tk->i_codec = VLC_FOURCC('R','V','2','4');
+ break;
+ case 16:
+ /* tk->i_codec = VLC_FOURCC('R','V','1','6');*/
+ /* break;*/
+ case 15:
+ tk->i_codec = VLC_FOURCC('R','V','1','5');
+ break;
+ case 9:
+ tk->i_codec = VLC_FOURCC( 'Y', 'V', 'U', '9' ); /* <- TODO check that */
+ break;
+ }
+ es_format_Init( &fmt, VIDEO_ES, tk->i_codec );
+ }
+ else
+ {
+ es_format_Init( &fmt, VIDEO_ES, p_vids->p_bih->biCompression );
+ }
tk->i_samplesize = 0;
fmt.video.i_width = p_vids->p_bih->biWidth;
fmt.video.i_height = p_vids->p_bih->biHeight;
- if( ( fmt.i_extra = __MIN( p_vids->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
- p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER) ) ) > 0 )
- {
- fmt.i_extra_type = ES_EXTRA_TYPE_BITMAPINFOHEADER;
- fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_vids->p_bih[1], fmt.i_extra );
- }
+ fmt.video.i_bits_per_pixel = p_vids->p_bih->biBitCount;
+ fmt.i_extra =
+ __MIN( p_vids->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
+ p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER) );
+ fmt.p_extra = &p_vids->p_bih[1];
msg_Dbg( p_input, "stream[%d] video(%4.4s) %dx%d %dbpp %ffps",
i,
(char*)&p_vids->p_bih->biCompression,
if( p_sys->i_track <= 0 )
{
- msg_Err( p_input, "No valid track" );
+ msg_Err( p_input, "no valid track" );
goto error;
}
return VLC_SUCCESS;
error:
+ if( p_sys->meta )
+ {
+ vlc_meta_Delete( p_sys->meta );
+ }
AVI_ChunkFreeRoot( p_input->s, &p_sys->ck_root );
free( p_sys );
return VLC_EGENERIC;
}
FREE( p_sys->track );
AVI_ChunkFreeRoot( p_input->s, &p_sys->ck_root );
+ vlc_meta_Delete( p_sys->meta );
free( p_sys );
}
unsigned int i_track_count = 0;
unsigned int i_track;
vlc_bool_t b_stream;
- vlc_bool_t b_play_audio;
/* cannot be more than 100 stream (dcXX or wbXX) */
avi_track_toread_t toread[100];
avi_track_t *tk = p_sys->track[i_track];
vlc_bool_t b;
- es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk->p_es, &b );
+ es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk->p_es, &b );
if( b && !tk->b_activated )
{
if( p_sys->b_seekable)
p_sys->i_time += 25*1000; /* read 25ms */
- /* Check if we need to send the audio data to decoder */
- b_play_audio = !p_input->stream.control.b_mute;
-
/* init toread */
for( i_track = 0; i_track < p_sys->i_track; i_track++ )
{
{
avi_track_t *tk;
vlc_bool_t b_done;
- pes_packet_t *p_pes;
+ block_t *p_frame;
off_t i_pos;
unsigned int i;
size_t i_size;
else
{
/* add this chunk to the index */
- AVIIndexEntry_t index;
+ avi_entry_t index;
index.i_id = avi_pk.i_fourcc;
index.i_flags =
i_size += 8; /* need to read and skip header */
}
- if( ( p_pes = stream_PesPacket( p_input->s, __EVEN( i_size ) ) )==NULL )
+ if( ( p_frame = stream_Block( p_input->s, __EVEN( i_size ) ) )==NULL )
{
msg_Warn( p_input, "failled reading data" );
tk->b_activated = VLC_FALSE;
}
if( i_size % 2 ) /* read was padded on word boundary */
{
- p_pes->p_last->p_payload_end--;
- p_pes->i_pes_size--;
+ p_frame->i_buffer--;
}
/* skip header */
if( tk->i_idxposb == 0 )
{
- p_pes->p_first->p_payload_start += 8;
- p_pes->i_pes_size -= 8;
+ p_frame->p_buffer += 8;
+ p_frame->i_buffer -= 8;
}
-
- p_pes->i_pts = AVI_GetPTS( tk );
-
-#if 0
- /* fix pts for audio: ie pts sould be for the first byte of the first frame */
- if( tk->i_samplesize == 1 )
+ p_frame->i_pts = AVI_GetPTS( tk );
+ if( tk->p_index[tk->i_idxposc].i_flags&AVIIF_KEYFRAME )
{
- AVI_FixPTS( p_stream, p_pes );
+ p_frame->i_flags = BLOCK_FLAG_TYPE_I;
+ }
+ else
+ {
+ p_frame->i_flags = BLOCK_FLAG_TYPE_PB;
}
-#endif
/* read data */
if( tk->i_samplesize )
}
else
{
- toread[i_track].i_toread--;
+ int i_length = tk->p_index[tk->i_idxposc].i_length;
+
tk->i_idxposc++;
+ if( tk->i_cat == AUDIO_ES )
+ {
+ tk->i_blockno += tk->i_blocksize > 0 ? ( i_length + tk->i_blocksize - 1 ) / tk->i_blocksize : 1;
+ }
+ toread[i_track].i_toread--;
}
if( tk->i_idxposc < tk->i_idxnb)
b_stream = VLC_TRUE; /* at least one read succeed */
- p_pes->i_dts =
- p_pes->i_pts =
+ p_frame->i_pts =
input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
- p_pes->i_pts * 9/100);
- p_pes->i_rate = p_input->stream.control.i_rate;
- if( b_play_audio || tk->i_cat != AUDIO_ES )
- {
- es_out_Send( p_input->p_es_out, tk->p_es, p_pes );
- }
+ p_frame->i_pts * 9/100);
+
+ if( tk->i_cat != VIDEO_ES )
+ p_frame->i_dts = p_frame->i_pts;
else
{
- input_DeletePES( p_input->p_method_data, p_pes );
+ p_frame->i_dts = p_frame->i_pts;
+ p_frame->i_pts = 0;
}
+
+ //p_pes->i_rate = p_input->stream.control.i_rate;
+ es_out_Send( p_input->p_es_out, tk->p_es, p_frame );
}
}
avi_track_t *tk = p_sys->track[i_stream];
vlc_bool_t b;
- es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk->p_es, &b );
+ es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk->p_es, &b );
if( b && tk->i_cat == VIDEO_ES )
{
AVI_GetPTS( p_stream_master ) )< 600*1000 )
{
/* load it and send to decoder */
- pes_packet_t *p_pes;
- if( AVI_PacketRead( p_input, &avi_pk, &p_pes ) || !p_pes)
+ block_t *p_frame;
+ if( AVI_PacketRead( p_input, &avi_pk, &p_frame ) || p_frame == NULL )
{
return( -1 );
}
- p_pes->i_dts =
- p_pes->i_pts =
- input_ClockGetTS( p_input,
+ p_frame->i_pts =
+ input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
AVI_GetPTS( p_stream ) * 9/100);
- p_pes->i_rate = p_input->stream.control.i_rate;
- es_out_Send( p_input->p_es_out, p_stream->p_es, p_pes );
+ if( avi_pk.i_cat != VIDEO_ES )
+ p_frame->i_dts = p_frame->i_pts;
+ else
+ {
+ p_frame->i_dts = p_frame->i_pts;
+ p_frame->i_pts = 0;
+ }
+
+ //p_pes->i_rate = p_input->stream.control.i_rate;
+ es_out_Send( p_input->p_es_out, p_stream->p_es, p_frame );
}
else
{
}
else
{
+ if( p_stream->i_cat == AUDIO_ES )
+ {
+ p_stream->i_blockno += p_stream->i_blocksize > 0 ? ( avi_pk.i_size + p_stream->i_blocksize - 1 ) / p_stream->i_blocksize : 1;
+ }
p_stream->i_idxposc++;
}
/* p_sys->i_time = __MAX( AVI_GetPTS( p_stream ), p_sys->i_time );*/
}
}
- msg_Dbg( p_input, "seek: "I64Fd" secondes", p_sys->i_time /1000000 );
+ msg_Dbg( p_input, "seek: "I64Fd" seconds", p_sys->i_time /1000000 );
/* set true movie time */
#endif
if( !p_sys->i_time )
int i;
double f, *pf;
int64_t i64, *pi64;
+ vlc_meta_t **pp_meta;
switch( i_query )
{
{
f = (double)va_arg( args, double );
i64 = (mtime_t)(1000000.0 * p_sys->i_length * f );
- return Seek( p_input, i64, (int)(f * 100) );
+ return Seek( p_input, i64, (int)(f * 100) ) < 0 ? VLC_EGENERIC : VLC_SUCCESS;
}
return demux_vaControlDefault( p_input, i_query, args );
i64 = (int64_t)va_arg( args, int64_t );
if( p_sys->i_length > 0 )
{
- i_percent = 100 * i64 / (p_sys->i_length*1000000ULL);
+ i_percent = 100 * i64 / (p_sys->i_length*1000000);
}
else if( p_sys->i_time > 0 )
{
}
}
return VLC_SUCCESS;
+ case DEMUX_GET_META:
+ pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
+ *pp_meta = vlc_meta_Duplicate( p_sys->meta );
+ return VLC_SUCCESS;
default:
return demux_vaControlDefault( p_input, i_query, args );
}
else
{
- return AVI_GetDPTS( tk, tk->i_idxposc );
- }
-}
-
-#if 0
-static void AVI_FixPTS( avi_track_t *p_stream, pes_packet_t *p_pes )
-{
- data_packet_t *p_data;
- uint8_t *p;
- int i_pos = 0;
-
- switch( p_stream->i_fourcc )
- {
- case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
- p_data = p_pes->p_first;
- while( p_data )
- {
- p = p_data->p_payload_start;
- while( p < p_data->p_payload_end - 2 )
- {
- if( p[0] == 0xff && ( p[1]&0xe0) == 0xe0 )
- {
- mtime_t i_diff = AVI_GetDPTS( p_stream, i_pos );
- p_pes->i_dts += i_diff;
- p_pes->i_pts += i_diff;
- return;
- }
- p++; i_pos++;
- }
- p_data = p_data->p_next;
- }
- return;
- case VLC_FOURCC( 'a', '5', '2', ' ' ):
- p_data = p_pes->p_first;
- while( p_data )
- {
- p = p_data->p_payload_start;
- while( p < p_data->p_payload_end - 2 )
- {
- if( p[0] == 0x0b && p[1] == 0x77 )
- {
- mtime_t i_diff = AVI_GetDPTS( p_stream, i_pos );
- p_pes->i_dts += i_diff;
- p_pes->i_pts += i_diff;
- }
- p++; i_pos++;
- }
- p_data = p_data->p_next;
- }
- return;
- default:
- /* we can't fix :( */
- return;
+ if( tk->i_cat == AUDIO_ES )
+ {
+ return AVI_GetDPTS( tk, tk->i_blockno );
+ }
+ else
+ {
+ return AVI_GetDPTS( tk, tk->i_idxposc );
+ }
}
}
-#endif
static int AVI_StreamChunkFind( input_thread_t *p_input,
unsigned int i_stream )
for( ;; )
{
+ if( p_input->b_die )
+ {
+ return VLC_EGENERIC;
+ }
if( AVI_PacketGetHeader( p_input, &avi_pk ) )
{
else
{
/* add this chunk to the index */
- AVIIndexEntry_t index;
+ avi_entry_t index;
index.i_id = avi_pk.i_fourcc;
index.i_flags =
mtime_t i_date )
{
demux_sys_t *p_sys = p_input->p_demux_data;
+ avi_track_t *tk = p_sys->track[i_stream];
+
#define p_stream p_sys->track[i_stream]
mtime_t i_oldpts;
return VLC_EGENERIC;
}
+ if( p_stream->i_cat == AUDIO_ES )
+ {
+ unsigned int i;
+ tk->i_blockno = 0;
+ for( i = 0; i < tk->i_idxposc; i++ )
+ {
+ if( tk->i_blocksize > 0 )
+ {
+ tk->i_blockno += ( tk->p_index[i].i_length + tk->i_blocksize - 1 ) / tk->i_blocksize;
+ }
+ else
+ {
+ tk->i_blockno++;
+ }
+ }
+ }
+
msg_Dbg( p_input,
"old:"I64Fd" %s new "I64Fd,
i_oldpts,
/* 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
/* not true , need to find the first VOP header */
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 say yes */
return AVIIF_KEYFRAME;
/* XXX DIV1 <- msmpeg4v1, DIV2 <- msmpeg4v2, DIV3 <- msmpeg4v3, mp4v for mpeg4 */
switch( i_codec )
{
+ case FOURCC_1:
+ return VLC_FOURCC('m','r','l','e');
case FOURCC_DIV1:
case FOURCC_div1:
case FOURCC_MPG4:
case FOURCC_XVID:
case FOURCC_XviD:
case FOURCC_DX50:
+ case FOURCC_dx50:
case FOURCC_mp4v:
case FOURCC_4:
case FOURCC_3IV2:
}
static int AVI_PacketRead( input_thread_t *p_input,
avi_packet_t *p_pk,
- pes_packet_t **pp_pes )
+ block_t **pp_frame )
{
size_t i_size;
i_size = __EVEN( p_pk->i_size + 8 );
- if( ( *pp_pes = stream_PesPacket( p_input->s, i_size ) ) == NULL )
+ if( ( *pp_frame = stream_Block( p_input->s, i_size ) ) == NULL )
{
return VLC_EGENERIC;
}
- (*pp_pes)->p_first->p_payload_start += 8;
- (*pp_pes)->i_pes_size -= 8;
+ (*pp_frame)->p_buffer += 8;
+ (*pp_frame)->i_buffer -= 8;
if( i_size != p_pk->i_size + 8 )
{
- (*pp_pes)->p_last->p_payload_end--;
- (*pp_pes)->i_pes_size--;
+ (*pp_frame)->i_buffer--;
}
return VLC_SUCCESS;
static int AVI_PacketSearch( input_thread_t *p_input )
{
demux_sys_t *p_sys = p_input->p_demux_data;
-
avi_packet_t avi_pk;
+ int i_count = 0;
+
for( ;; )
{
if( stream_Read( p_input->s, NULL, 1 ) != 1 )
case AVIFOURCC_idx1:
return VLC_SUCCESS;
}
+
+ /* Prevents from eating all the CPU with broken files.
+ * This value should be low enough so that it doesn't affect the
+ * reading speed too much (not that we care much anyway because
+ * this code is called only on broken files). */
+ if( !(++i_count % 1024) )
+ {
+ if( p_input->b_die ) return VLC_EGENERIC;
+
+ msleep( 10000 );
+ if( !(i_count % (1024 * 10)) )
+ msg_Warn( p_input, "trying to resync..." );
+ }
}
}
****************************************************************************/
static void AVI_IndexAddEntry( demux_sys_t *p_sys,
int i_stream,
- AVIIndexEntry_t *p_index)
+ avi_entry_t *p_index)
{
avi_track_t *tk = p_sys->track[i_stream];
{
tk->i_idxmax += 16384;
tk->p_index = realloc( tk->p_index,
- tk->i_idxmax * sizeof( AVIIndexEntry_t ) );
+ tk->i_idxmax * sizeof( avi_entry_t ) );
if( tk->p_index == NULL )
{
return;
}
/* *** calculate offset *** */
- /* Well, avi is __SHIT__ so test more than one entry
+ /* Well, avi is __SHIT__ so test more than one entry
* (needed for some avi files) */
i_offset = 0;
for( i = 0; i < __MIN( p_idx1->i_entry_count, 10 ); i++ )
if( i_stream < p_sys->i_track &&
i_cat == p_sys->track[i_stream]->i_cat )
{
- AVIIndexEntry_t index;
+ avi_entry_t index;
index.i_id = p_idx1->entry[i_index].i_fourcc;
index.i_flags =
p_idx1->entry[i_index].i_flags&(~AVIIF_FIXKEYFRAME);
avi_chunk_indx_t *p_indx )
{
demux_sys_t *p_sys = p_input->p_demux_data;
- AVIIndexEntry_t index;
+ avi_entry_t index;
int32_t i;
msg_Dbg( p_input, "loading subindex(0x%x) %d entries", p_indx->i_indextype, p_indx->i_entriesinuse );
{
avi_packet_t pk;
+ if( p_input->b_die )
+ {
+ return;
+ }
+
if( AVI_PacketGetHeader( p_input, &pk ) )
{
break;
if( pk.i_stream < p_sys->i_track &&
pk.i_cat == p_sys->track[pk.i_stream]->i_cat )
{
- AVIIndexEntry_t index;
+ avi_entry_t index;
index.i_id = pk.i_fourcc;
index.i_flags =
AVI_GetKeyFlag(p_sys->track[pk.i_stream]->i_codec, pk.i_peek);
if( tk->i_idxposc >= tk->i_idxnb )
{
tk->b_activated = VLC_FALSE;
+ es_out_Control( p_input->p_es_out, ES_OUT_SET_ES_STATE, tk->p_es, VLC_FALSE );
}
else
{