Commit 4144b604 authored by Laurent Aimar's avatar Laurent Aimar

* ./plugins/ac3_adec/* use _M to avoid conflict with libavcodec.a

* ./plugins/avi a light  avi demux
* ./plugins/ffmpeg a video decoder for divx v3 and opendivx
parent 76e16cfd
......@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-dec.h,v 1.54 2002/03/14 01:35:28 stef Exp $
* $Id: input_ext-dec.h,v 1.55 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -31,6 +31,8 @@
/* These ones might violate the norm : */
#define DVD_SPU_ES 0x82
#define LPCM_AUDIO_ES 0x83
#define MSMPEG4_VIDEO_ES 0x90
#define MPEG4_VIDEO_ES 0x91
#define UNKNOWN_ES 0xFF
/* Structures exported to the decoders */
......
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.27 2002/04/23 14:16:20 sam Exp $
* $Id: ac3_adec.c,v 1.28 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -214,7 +214,7 @@ static int InitThread( ac3dec_thread_t * p_ac3thread )
IMDCT->w_64 = vlc_memalign( 16, 64 * sizeof(complex_t),
&IMDCT->w_64_orig );
ac3_init( p_ac3thread->ac3_decoder );
_M( ac3_init )( p_ac3thread->ac3_decoder );
/*
* Initialize the output properties
......
......@@ -2,7 +2,7 @@
* ac3_decoder.c: core ac3 decoder
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_decoder.c,v 1.6 2001/12/30 07:09:54 sam Exp $
* $Id: ac3_decoder.c,v 1.7 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@zoy.org>
......@@ -45,10 +45,10 @@
static const float cmixlev_lut[4] = { 0.707, 0.595, 0.500, 0.707 };
static const float smixlev_lut[4] = { 0.707, 0.500, 0.0 , 0.500 };
int ac3_init (ac3dec_t * p_ac3dec)
int _M( ac3_init )(ac3dec_t * p_ac3dec)
{
p_ac3dec->mantissa.lfsr_state = 1; /* dither_gen initialization */
imdct_init(p_ac3dec->imdct);
_M( imdct_init )(p_ac3dec->imdct) ;
return 0;
}
......
......@@ -2,7 +2,7 @@
* ac3_decoder.h : ac3 decoder interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder.h,v 1.3 2002/04/05 01:05:22 gbazin Exp $
* $Id: ac3_decoder.h,v 1.4 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org>
......@@ -35,7 +35,7 @@ typedef struct ac3_sync_info_s {
/**** ac3 decoder API - functions publically provided by the ac3 decoder ****/
int ac3_init (ac3dec_t * p_ac3dec);
int _M( ac3_init )(ac3dec_t * p_ac3dec);
int ac3_sync_frame (ac3dec_t * p_ac3dec, ac3_sync_info_t * p_sync_info);
int ac3_decode_frame (ac3dec_t * p_ac3dec, s16 * buffer);
......
......@@ -2,7 +2,7 @@
* ac3_imdct.c: ac3 DCT
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_imdct.c,v 1.7 2001/12/30 07:09:54 sam Exp $
* $Id: ac3_imdct.c,v 1.8 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca>
......@@ -44,7 +44,7 @@
# define M_PI 3.14159265358979323846
#endif
void imdct_init(imdct_t * p_imdct)
void _M( imdct_init )(imdct_t * p_imdct)
{
int i;
float scale = 181.019;
......
......@@ -2,7 +2,7 @@
* ac3_internals.h: needed by the ac3 decoder
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: ac3_internal.h,v 1.1 2001/11/13 12:09:17 henri Exp $
* $Id: ac3_internal.h,v 1.2 2002/04/23 23:44:36 fenrir Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -40,7 +40,7 @@ void bit_allocate (ac3dec_t *);
int exponent_unpack (ac3dec_t *);
/* ac3_imdct.c */
void imdct_init (imdct_t * p_imdct);
void _M( imdct_init )(imdct_t * p_imdct);
void imdct (ac3dec_t * p_ac3dec, s16 * buffer);
/* ac3_mantissa.c */
......
avi_SOURCES =
avi_SOURCES = avi.c
/*****************************************************************************
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.1 2002/04/23 23:44:36 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <errno.h>
#include <sys/types.h>
#include <videolan/vlc.h>
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
/*****************************************************************************
* Constants
*****************************************************************************/
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void input_getfunctions( function_list_t * p_function_list );
static int AVIDemux ( struct input_thread_s * );
static int AVIInit ( struct input_thread_s * );
static void AVIEnd ( struct input_thread_s * );
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "RIFF-AVI Stream input" )
ADD_CAPABILITY( DEMUX, 150 )
ADD_SHORTCUT( "avi" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
input_getfunctions( &p_module->p_functions->demux );
MODULE_ACTIVATE_STOP
MODULE_DEACTIVATE_START
MODULE_DEACTIVATE_STOP
/*****************************************************************************
* Definition of structures and libraries for this plugins
*****************************************************************************/
#include "fourcc.h"
#include "libLE.c"
#include "libioRIFF.c"
#include "avi.h"
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
static void input_getfunctions( function_list_t * p_function_list )
{
#define input p_function_list->functions.demux
input.pf_init = AVIInit;
input.pf_end = AVIEnd;
input.pf_demux = AVIDemux;
input.pf_rewind = NULL;
#undef input
}
/********************************************************************/
static void __AVIFreeDemuxData( input_thread_t *p_input )
{
int i;
demux_data_avi_file_t *p_avi_demux;
p_avi_demux = (demux_data_avi_file_t*)p_input->p_demux_data ;
if( p_avi_demux->p_riff != NULL )
RIFF_DeleteChunk( p_input->p_demux_data, p_avi_demux->p_riff );
if( p_avi_demux->p_hdrl != NULL )
RIFF_DeleteChunk( p_input->p_demux_data, p_avi_demux->p_hdrl );
if( p_avi_demux->p_movi != NULL )
RIFF_DeleteChunk( p_input->p_demux_data, p_avi_demux->p_movi );
if( p_avi_demux->p_idx1 != NULL )
RIFF_DeleteChunk( p_input->p_demux_data, p_avi_demux->p_idx1 );
return;
if( p_avi_demux->pp_info != NULL )
{
for( i = 0; i < p_avi_demux->i_streams; i++ )
{
if( p_avi_demux->pp_info[i] != NULL )
{
#define p_info p_avi_demux->pp_info[i]
if( p_info->p_strl != NULL )
RIFF_DeleteChunk( p_input->p_demux_data, p_info->p_strl );
if( p_info->p_strh != NULL )
RIFF_DeleteChunk( p_input->p_demux_data,p_info->p_strh );
if( p_info->p_strf != NULL )
RIFF_DeleteChunk( p_input->p_demux_data,p_info->p_strf );
if( p_info->p_strd != NULL )
RIFF_DeleteChunk( p_input->p_demux_data,p_info->p_strd );
if( p_info->p_index != NULL )
free( p_info->p_index );
free( p_info );
#undef p_info
}
}
free( p_avi_demux->pp_info );
}
}
static void __AVI_Parse_avih( MainAVIHeader_t *p_avih, byte_t *p_buff )
{
p_avih->i_microsecperframe = __GetDoubleWordLittleEndianFromBuff( p_buff );
p_avih->i_maxbytespersec = __GetDoubleWordLittleEndianFromBuff( p_buff + 4);
p_avih->i_reserved1 = __GetDoubleWordLittleEndianFromBuff( p_buff + 8);
p_avih->i_flags = __GetDoubleWordLittleEndianFromBuff( p_buff + 12);
p_avih->i_totalframes = __GetDoubleWordLittleEndianFromBuff( p_buff + 16);
p_avih->i_initialframes = __GetDoubleWordLittleEndianFromBuff( p_buff + 20);
p_avih->i_streams = __GetDoubleWordLittleEndianFromBuff( p_buff + 24);
p_avih->i_suggestedbuffersize =
__GetDoubleWordLittleEndianFromBuff( p_buff + 28);
p_avih->i_width = __GetDoubleWordLittleEndianFromBuff( p_buff + 32 );
p_avih->i_height = __GetDoubleWordLittleEndianFromBuff( p_buff + 36 );
p_avih->i_scale = __GetDoubleWordLittleEndianFromBuff( p_buff + 40 );
p_avih->i_rate = __GetDoubleWordLittleEndianFromBuff( p_buff + 44 );
p_avih->i_start = __GetDoubleWordLittleEndianFromBuff( p_buff + 48);
p_avih->i_length = __GetDoubleWordLittleEndianFromBuff( p_buff + 52);
}
static void __AVI_Parse_Header( AVIStreamHeader_t *p_strh, byte_t *p_buff )
{
p_strh->i_type = __GetDoubleWordLittleEndianFromBuff( p_buff );
p_strh->i_handler = __GetDoubleWordLittleEndianFromBuff( p_buff + 4 );
p_strh->i_flags = __GetDoubleWordLittleEndianFromBuff( p_buff + 8 );
p_strh->i_reserved1 = __GetDoubleWordLittleEndianFromBuff( p_buff + 12);
p_strh->i_initialframes = __GetDoubleWordLittleEndianFromBuff( p_buff + 16);
p_strh->i_scale = __GetDoubleWordLittleEndianFromBuff( p_buff + 20);
p_strh->i_rate = __GetDoubleWordLittleEndianFromBuff( p_buff + 24);
p_strh->i_start = __GetDoubleWordLittleEndianFromBuff( p_buff + 28);
p_strh->i_length = __GetDoubleWordLittleEndianFromBuff( p_buff + 32);
p_strh->i_suggestedbuffersize =
__GetDoubleWordLittleEndianFromBuff( p_buff + 36);
p_strh->i_quality = __GetDoubleWordLittleEndianFromBuff( p_buff + 40);
p_strh->i_samplesize = __GetDoubleWordLittleEndianFromBuff( p_buff + 44);
}
int avi_ParseBitMapInfoHeader( bitmapinfoheader_t *h, byte_t *p_data )
{
h->i_size = __GetDoubleWordLittleEndianFromBuff( p_data );
h->i_width = __GetDoubleWordLittleEndianFromBuff( p_data + 4 );
h->i_height = __GetDoubleWordLittleEndianFromBuff( p_data + 8 );
h->i_planes = __GetWordLittleEndianFromBuff( p_data + 12 );
h->i_bitcount = __GetWordLittleEndianFromBuff( p_data + 14 );
h->i_compression = __GetDoubleWordLittleEndianFromBuff( p_data + 16 );
h->i_sizeimage = __GetDoubleWordLittleEndianFromBuff( p_data + 20 );
h->i_xpelspermeter = __GetDoubleWordLittleEndianFromBuff( p_data + 24 );
h->i_ypelspermeter = __GetDoubleWordLittleEndianFromBuff( p_data + 28 );
h->i_clrused = __GetDoubleWordLittleEndianFromBuff( p_data + 32 );
h->i_clrimportant = __GetDoubleWordLittleEndianFromBuff( p_data + 36 );
return( 0 );
}
int avi_ParseWaveFormatEx( waveformatex_t *h, byte_t *p_data )
{
h->i_formattag = __GetWordLittleEndianFromBuff( p_data );
h->i_channels = __GetWordLittleEndianFromBuff( p_data + 2 );
h->i_samplespersec = __GetDoubleWordLittleEndianFromBuff( p_data + 4 );
h->i_avgbytespersec= __GetDoubleWordLittleEndianFromBuff( p_data + 8 );
h->i_blockalign = __GetWordLittleEndianFromBuff( p_data + 12 );
h->i_bitspersample = __GetWordLittleEndianFromBuff( p_data + 14 );
h->i_size = __GetWordLittleEndianFromBuff( p_data + 16 );
return( 0 );
}
static int __AVI_ParseStreamHeader( u32 i_id, int *i_number, u16 *i_type )
{
int c1,c2,c3,c4;
char str[3];
c1 = ( i_id ) & 0xFF;
c2 = ( i_id >> 8 ) & 0xFF;
c3 = ( i_id >> 16 ) & 0xFF;
c4 = ( i_id >> 24 ) & 0xFF;
if( c1 < '0' || c1 > '9' || c2 < '0' || c2 > '9' )
{
return( -1 );
}
str[0] = c1;
str[1] = c2;
str[2] = 0;
*i_number = atoi( str );
*i_type = ( c3 << 8) + c4;
return( 0 );
}
static int __AVI_HeaderMoviValid( u32 i_header )
{
switch( i_header&0xFFFF0000 )
{
case( TWOCC_wb ):
case( TWOCC_db ):
case( TWOCC_dc ):
case( TWOCC_pc ):
return( 1 );
break;
}
switch( i_header )
{
case( FOURCC_LIST ):
case( FOURCC_JUNK ):
return( 1 );
break;
}
return( 0 );
}
static void __AVI_AddEntryIndex( AVIStreamInfo_t *p_info,
AVIIndexEntry_t *p_index)
{
if( p_info->p_index == NULL )
{
p_info->i_idxmax = 4096;
p_info->i_idxnb = 0;
p_info->p_index = calloc( p_info->i_idxmax,
sizeof( AVIIndexEntry_t ) );
}
if( p_info->i_idxnb >= p_info->i_idxmax )
{
p_info->i_idxmax += 4096;
p_info->p_index = realloc( (void*)p_info->p_index,
p_info->i_idxmax *
sizeof( AVIIndexEntry_t ) );
}
/* calculate cumulate length */
if( p_info->i_idxnb > 0 )
{
p_index->i_lengthtotal = p_index->i_length +
p_info->p_index[p_info->i_idxnb-1].i_lengthtotal;
}
else
{
p_index->i_lengthtotal = 0;
}
p_info->p_index[p_info->i_idxnb] = *p_index;
p_info->i_idxnb++;
}
static void __AVI_GetIndex( input_thread_t *p_input )
{
demux_data_avi_file_t *p_avi_demux;
AVIIndexEntry_t index;
byte_t *p_buff;
riffchunk_t *p_idx1;
int i_read;
int i;
int i_number;
u16 i_type;
p_avi_demux = (demux_data_avi_file_t*)p_input->p_demux_data ;
if( RIFF_FindAndGotoDataChunk( p_input,
p_avi_demux->p_riff,
&p_idx1,
FOURCC_idx1)!=0 )
{
intf_WarnMsg( 1, "input init: cannot find index" );
RIFF_GoToChunk( p_input, p_avi_demux->p_hdrl );
return;
}
p_avi_demux->p_idx1 = p_idx1;
intf_WarnMsg( 1, "input init: loading index" );
for(;;)
{
if( (i_read = input_Peek( p_input, &p_buff, 16*1024 )) < 16 )
{
for( i = 0, i_read = 0; i < p_avi_demux->i_streams; i++ )
{
i_read += p_avi_demux->pp_info[i]->i_idxnb;
}
intf_WarnMsg( 1,"input info: read %d idx chunk", i_read );
return;
}
i_read /= 16 ;
/* try to verify if we are beyond end of p_idx1 */
for( i = 0; i < i_read; i++ )
{
byte_t *p_peek = p_buff + i * 16;
index.i_id = __GetDoubleWordLittleEndianFromBuff( p_peek );
index.i_flags = __GetDoubleWordLittleEndianFromBuff( p_peek+4);
index.i_offset = __GetDoubleWordLittleEndianFromBuff( p_peek+8);
index.i_length = __GetDoubleWordLittleEndianFromBuff(p_peek+12);
if( (__AVI_ParseStreamHeader( index.i_id, &i_number, &i_type ) != 0)
||(i_number > p_avi_demux->i_streams))
{
continue;
}
__AVI_AddEntryIndex( p_avi_demux->pp_info[i_number],
&index );
}
__RIFF_SkipBytes( p_input, 16 * i_read );
}
}
static int __AVI_SeekToChunk( input_thread_t *p_input, AVIStreamInfo_t *p_info )
{
demux_data_avi_file_t *p_avi_demux;
p_avi_demux = (demux_data_avi_file_t*)p_input->p_demux_data;
if( (p_info->p_index != NULL)&&(p_info->i_idxpos < p_info->i_idxnb) )
{
/* perfect */
off_t i_pos;
i_pos = (off_t)p_info->p_index[p_info->i_idxpos].i_offset +
p_info->i_idxoffset;
p_input->pf_seek( p_input, i_pos );
input_AccessReinit( p_input );
return( 0 );
}
/* index are no longer valid */
if( p_info->p_index != NULL )
{
return( -1 );
}
/* no index */
return( -1 );
}
/* XXX call after get p_movi */
static int __AVI_GetIndexOffset( input_thread_t *p_input )
{
riffchunk_t *p_chunk;
demux_data_avi_file_t *p_avi_demux;
int i;
p_avi_demux = (demux_data_avi_file_t*)p_input->p_demux_data;
for( i = 0; i < p_avi_demux->i_streams; i++ )
{
#define p_info p_avi_demux->pp_info[i]
if( p_info->p_index == NULL ) {continue;}
p_info->i_idxoffset = 0;
__AVI_SeekToChunk( p_input, p_info );
p_chunk = RIFF_ReadChunk( p_input );
if( (p_chunk == NULL)||(p_chunk->i_id != p_info->p_index[0].i_id) )
{
p_info->i_idxoffset = p_avi_demux->p_movi->i_pos + 8;
__AVI_SeekToChunk( p_input, p_info );
p_chunk = RIFF_ReadChunk( p_input );
if( (p_chunk == NULL)||(p_chunk->i_id != p_info->p_index[0].i_id) )
{
intf_WarnMsg( 1, "input demux: can't find offset for stream %d",
i);
continue; /* TODO: search manually from p_movi */
}
}
#undef p_info
}
return( 0 );
}
static int __AVI_AudioGetType( u32 i_type )
{
switch( i_type )
{
/* case( WAVE_FORMAT_PCM ):
return( WAVE_AUDIO_ES ); */
case( WAVE_FORMAT_AC3 ):
return( AC3_AUDIO_ES );
case( WAVE_FORMAT_MPEG):
case( WAVE_FORMAT_MPEGLAYER3):
return( MPEG2_AUDIO_ES ); /* 2 for mpeg-2 layer 1 2 ou 3 */
default:
return( 0 );
}
}
static int __AVI_VideoGetType( u32 i_type )
{
switch( i_type )
{
case( FOURCC_DIV3 ):
case( FOURCC_div3 ):
case( FOURCC_DIV4 ):
case( FOURCC_div4 ):
case( FOURCC_DIV5 ):
case( FOURCC_div5 ):
case( FOURCC_DIV6 ):
case( FOURCC_div6 ):
case( FOURCC_3IV1 ):
case( FOURCC_AP41 ):
case( FOURCC_MP43 ):
case( FOURCC_mp43 ):
return( MSMPEG4_VIDEO_ES );
case( FOURCC_DIVX ):
case( FOURCC_divx ):
case( FOURCC_DX50 ):
case( FOURCC_MP4S ):
case( FOURCC_MPG4 ):
case( FOURCC_mpg4 ):
case( FOURCC_mp4v ):
return( MPEG4_VIDEO_ES );
default:
return( 0 );
}
}
/**************************************************************************/
/* Tention: bcp de test ajouter mais aussi beaucoup de MEMOIRE a DESALLOUER pas fait */
static int AVIInit( input_thread_t *p_input )
{
riffchunk_t *p_riff,*p_hdrl,*p_movi;
riffchunk_t *p_avih;
riffchunk_t *p_strl,*p_strh,*p_strf/* ,*p_strd */;
demux_data_avi_file_t *p_avi_demux;
es_descriptor_t *p_es = NULL; /* for not warning */
es_descriptor_t *p_es_video = NULL;
es_descriptor_t *p_es_audio = NULL;
int i,j;
p_avi_demux = malloc( sizeof(demux_data_avi_file_t) );
memset( p_avi_demux, 0, sizeof( demux_data_avi_file_t ) );
p_input->p_demux_data = p_avi_demux;
/* FIXME FIXME Je sais pas trop a quoi ca sert juste copi de ESInit */
/* Initialize access plug-in structures. */
if( p_input->i_mtu == 0 )
{
/* Improve speed. */
p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
}
if( RIFF_TestFileHeader( p_input, &p_riff, FOURCC_AVI ) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input: RIFF-AVI plug-in discarded (avi_file)" );
return( -1 );
}
p_avi_demux->p_riff = p_riff;
if ( RIFF_DescendChunk(p_input) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot look for subchunk (avi_file)" );
return ( -1 );
}
/* it's a riff-avi file, so search for LIST-hdrl */
if( RIFF_FindListChunk(p_input ,&p_hdrl,p_riff, FOURCC_hdrl) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot find \"LIST-hdrl\" (avi_file)" );
return( -1 );
}
p_avi_demux->p_hdrl = p_hdrl;
if( RIFF_DescendChunk(p_input) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot look for subchunk (avi_file)" );
return ( -1 );
}
/* ds LIST-hdrl cherche avih */
if( RIFF_FindAndLoadChunk( p_input, p_hdrl,
&p_avih, FOURCC_avih ) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot find \"avih\" chunk (avi_file)" );
return( -1 );
}
__AVI_Parse_avih( &p_avi_demux->avih, p_avih->p_data->p_payload_start );
RIFF_DeleteChunk( p_input, p_avih );
if( p_avi_demux->avih.i_streams == 0 )
/* aucun flux defini, peut etre essayer de trouver ss connaitre */
/* le nombre serait pas mal, a voir */
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: no defined stream !" );
return( -1 );
}
/* On creer les tableau pr les flux */
p_avi_demux->i_streams = p_avi_demux->avih.i_streams;
p_avi_demux->pp_info = calloc( p_avi_demux->i_streams,
sizeof( AVIStreamInfo_t* ) );
memset( p_avi_demux->pp_info, 0,
sizeof( AVIStreamInfo_t* ) * p_avi_demux->i_streams );
for( i = 0 ; i < p_avi_demux->i_streams; i++ )
{
p_avi_demux->pp_info[i] = malloc( sizeof(AVIStreamInfo_t ) );
memset( p_avi_demux->pp_info[i], 0, sizeof( AVIStreamInfo_t ) );
/* pour chaque flux on cherche ses infos */
if( RIFF_FindListChunk(p_input,
&p_strl,p_hdrl, FOURCC_strl) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot find \"LIST-strl\" (avi_file)" );
return( -1 );
}
p_avi_demux->pp_info[i]->p_strl = p_strl;
if( RIFF_DescendChunk(p_input) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot look for subchunk (avi_file)" );
return ( -1 );
}
/* ds LIST-strl cherche strh */
if( RIFF_FindAndLoadChunk( p_input, p_hdrl,
&p_strh, FOURCC_strh ) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot find \"strh\" (avi_file)" );
return( -1 );
}
p_avi_demux->pp_info[i]->p_strh = p_strh;
/* ds LIST-strl cherche strf */
if( RIFF_FindAndLoadChunk( p_input, p_hdrl,
&p_strf, FOURCC_strf ) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot find \"strf\" (avi_file)" );
return( -1 );
}
p_avi_demux->pp_info[i]->p_strf = p_strf;
/* FIXME faudrait cherche et charger strd */
/* mais a priori pas vraiment utile pr divx */
if( RIFF_AscendChunk(p_input, p_strl) != 0 )
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot go out (\"strl\") (avi_file)" );
return( -1 );
}
}
if( RIFF_AscendChunk(p_input, p_hdrl) != 0)
{
__AVIFreeDemuxData( p_input );
intf_ErrMsg( "input error: cannot go out (\"hdrl\") (avi_file)" );
return( -1 );
}
intf_Msg( "input init: AVIH: %d stream, flags %s%s%s%s%s%s ",
p_avi_demux->i_streams,
p_avi_demux->avih.i_flags&AVIF_HASINDEX?" HAS_INDEX":"",
p_avi_demux->avih.i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"",
p_avi_demux->avih.i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
p_avi_demux->avih.i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"",
p_avi_demux->avih.i_flags&AVIF_WASCAPTUREFILE?" CAPTUREFILE":"",
p_avi_demux->avih.i_flags&AVIF_COPYRIGHTED?" COPYRIGHTED":"" );
/* go to movi chunk */
if( RIFF_FindListChunk(p_input ,&p_movi,p_riff, FOURCC_movi) != 0 )
{
intf_ErrMsg( "input error: cannot find \"LIST-movi\" (avi_file)" );
__AVIFreeDemuxData( p_input );
return( -1 );
}
p_avi_demux->p_movi = p_movi;
/* get index */
if( (p_input->stream.b_seekable)
&&((p_avi_demux->avih.i_flags&AVIF_HASINDEX) != 0) )