Commit 233ac074 authored by Laurent Aimar's avatar Laurent Aimar

* avi: use stream_*, some clean and reordering.

parent 6b177dca
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.h : AVI file Stream input module for vlc * avi.h : AVI file Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: avi.h,v 1.11 2003/06/24 23:11:35 fenrir Exp $ * $Id: avi.h,v 1.12 2003/08/22 20:31:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -69,6 +69,8 @@ typedef struct avi_stream_s ...@@ -69,6 +69,8 @@ typedef struct avi_stream_s
struct demux_sys_t struct demux_sys_t
{ {
stream_t *s;
mtime_t i_time; mtime_t i_time;
mtime_t i_length; mtime_t i_length;
mtime_t i_pcr; mtime_t i_pcr;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libavi.c : * libavi.c :
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: libavi.c,v 1.22 2003/08/17 23:02:52 fenrir Exp $ * $Id: libavi.c,v 1.23 2003/08/22 20:31:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -21,12 +21,11 @@ ...@@ -21,12 +21,11 @@
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* malloc(), free() */ #include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <errno.h>
#include <sys/types.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include "ninput.h"
#include "codecs.h" /* BITMAPINFOHEADER */
#include "libavi.h" #include "libavi.h"
...@@ -41,207 +40,40 @@ static vlc_fourcc_t GetFOURCC( byte_t *p_buff ) ...@@ -41,207 +40,40 @@ 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
*
* AVI_TellAbsolute get file position
*
* AVI_SeekAbsolute seek in the file
*
* AVI_ReadData read data from the file in a buffer
*
* AVI_SkipBytes skip bytes
*
*****************************************************************************/
off_t AVI_TellAbsolute( input_thread_t *p_input )
{
off_t i_pos;
vlc_mutex_lock( &p_input->stream.stream_lock ); #define AVI_ChunkFree( a, b ) _AVI_ChunkFree( (a), (avi_chunk_t*)(b) )
void _AVI_ChunkFree( stream_t *, avi_chunk_t *p_chk );
i_pos= p_input->stream.p_selected_area->i_tell;
vlc_mutex_unlock( &p_input->stream.stream_lock );
return i_pos;
}
int AVI_SeekAbsolute( input_thread_t *p_input,
off_t i_pos)
{
off_t i_filepos;
if( p_input->stream.p_selected_area->i_size > 0 &&
i_pos >= p_input->stream.p_selected_area->i_size )
{
return VLC_EGENERIC;
}
i_filepos = AVI_TellAbsolute( p_input );
if( i_filepos == i_pos )
{
return VLC_SUCCESS;
}
if( p_input->stream.b_seekable &&
( p_input->stream.i_method == INPUT_METHOD_FILE ||
i_pos - i_filepos < 0 ||
i_pos - i_filepos > 1024 ) )
{
input_AccessReinit( p_input );
p_input->pf_seek( p_input, i_pos );
return VLC_SUCCESS;
}
else if( i_pos - i_filepos > 0 )
{
data_packet_t *p_data;
int i_skip = i_pos - i_filepos;
msg_Warn( p_input, "will skip %d bytes, slow", i_skip );
if( i_skip < 0 )
{
return VLC_EGENERIC; // failed
}
while (i_skip > 0 )
{
int i_read;
i_read = input_SplitBuffer( p_input, &p_data,
__MIN( 4096, i_skip ) );
if( i_read <= 0 )
{
/* Error or eof */
return VLC_EGENERIC;
}
i_skip -= i_read;
input_DeletePacket( p_input->p_method_data, p_data );
}
return VLC_SUCCESS;
}
else
{
return VLC_EGENERIC;
}
}
/* 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;
int i_count;
int i_read = 0;
if( !i_size )
{
return 0;
}
do
{
i_count = input_SplitBuffer(p_input, &p_data, __MIN( i_size, 1024 ) );
if( i_count <= 0 )
{
return i_read;
}
memcpy( p_buff, p_data->p_payload_start, i_count );
input_DeletePacket( p_input->p_method_data, p_data );
p_buff += i_count;
i_size -= i_count;
i_read += i_count;
} while( i_size );
return i_read;
}
int AVI_SkipBytes( input_thread_t *p_input, int64_t i_count )
{
/* broken with new use of i_tell */
#if 0
int i_buff_size;
vlc_mutex_lock( &p_input->stream.stream_lock );
i_buff_size = p_input->p_last_data - p_input->p_current_data;
vlc_mutex_unlock( &p_input->stream.stream_lock );
if( i_count > 0 && i_count + 1 < i_buff_size )
{
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 VLC_SUCCESS;
}
else
#endif
{
return AVI_SeekAbsolute( p_input,
AVI_TellAbsolute( p_input ) + i_count );
}
}
/*****************************************************************************
*
* AVI_TestFile: look at first bytes to see if it's a valid avi file
*
* unseekable: ok
*
*****************************************************************************/
int AVI_TestFile( input_thread_t *p_input )
{
uint8_t *p_peek;
if( input_Peek( p_input, &p_peek, 8 ) < 8 )
{
msg_Err( p_input, "cannot peek()" );
return VLC_EGENERIC;
}
if( GetFOURCC( p_peek ) == AVIFOURCC_RIFF &&
GetFOURCC( p_peek + 8 ) == AVIFOURCC_AVI )
{
return VLC_SUCCESS;
}
else
{
return VLC_EGENERIC;
}
}
/**************************************************************************** /****************************************************************************
* *
* Basics functions to manipulates chunks * Basics functions to manipulates chunks
* *
****************************************************************************/ ****************************************************************************/
static int AVI_ChunkReadCommon( input_thread_t *p_input, static int AVI_ChunkReadCommon( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
uint8_t *p_peek; uint8_t *p_peek;
int i_peek; int i_peek;
memset( p_chk, 0, sizeof( avi_chunk_t ) ); memset( p_chk, 0, sizeof( avi_chunk_t ) );
if( ( i_peek = input_Peek( p_input, &p_peek, 8 ) ) < 8 ) if( ( i_peek = stream_Peek( s, &p_peek, 8 ) ) < 8 )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_chk->common.i_chunk_fourcc = GetFOURCC( 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_size = GetDWLE( p_peek + 4 );
p_chk->common.i_chunk_pos = AVI_TellAbsolute( p_input ); p_chk->common.i_chunk_pos = stream_Tell( s );
p_chk->common.p_father = NULL; p_chk->common.p_father = NULL;
p_chk->common.p_next = NULL; p_chk->common.p_next = NULL;
p_chk->common.p_first = NULL; p_chk->common.p_first = NULL;
p_chk->common.p_next = NULL; p_chk->common.p_next = NULL;
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"Found Chunk fourcc:%8.8x (%4.4s) size:"I64Fd" pos:"I64Fd, "Found Chunk fourcc:%8.8x (%4.4s) size:"I64Fd" pos:"I64Fd,
p_chk->common.i_chunk_fourcc, p_chk->common.i_chunk_fourcc,
(char*)&p_chk->common.i_chunk_fourcc, (char*)&p_chk->common.i_chunk_fourcc,
...@@ -251,14 +83,13 @@ static int AVI_ChunkReadCommon( input_thread_t *p_input, ...@@ -251,14 +83,13 @@ static int AVI_ChunkReadCommon( input_thread_t *p_input,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int AVI_NextChunk( input_thread_t *p_input, static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
avi_chunk_t chk; avi_chunk_t chk;
if( !p_chk ) if( !p_chk )
{ {
if( AVI_ChunkReadCommon( p_input, &chk ) ) if( AVI_ChunkReadCommon( s, &chk ) )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -267,79 +98,68 @@ static int AVI_NextChunk( input_thread_t *p_input, ...@@ -267,79 +98,68 @@ static int AVI_NextChunk( input_thread_t *p_input,
if( p_chk->common.p_father ) if( p_chk->common.p_father )
{ {
if( p_chk->common.p_father->common.i_chunk_pos + if( p_chk->common.p_father->common.i_chunk_pos +
__EVEN( p_chk->common.p_father->common.i_chunk_size ) + 8 < __EVEN( p_chk->common.p_father->common.i_chunk_size ) + 8 <
p_chk->common.i_chunk_pos + p_chk->common.i_chunk_pos +
__EVEN( p_chk->common.i_chunk_size ) + 8 ) __EVEN( p_chk->common.i_chunk_size ) + 8 )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
return AVI_SeekAbsolute( p_input, return stream_Seek( s, p_chk->common.i_chunk_pos +
p_chk->common.i_chunk_pos +
__EVEN( p_chk->common.i_chunk_size ) + 8 ); __EVEN( p_chk->common.i_chunk_size ) + 8 );
} }
int _AVI_ChunkGoto( input_thread_t *p_input,
avi_chunk_t *p_chk )
{
if( !p_chk )
{
return VLC_EGENERIC;
}
return AVI_SeekAbsolute( p_input, p_chk->common.i_chunk_pos );
}
/**************************************************************************** /****************************************************************************
* *
* Functions to read chunks * Functions to read chunks
* *
****************************************************************************/ ****************************************************************************/
static int AVI_ChunkRead_list( input_thread_t *p_input, static int AVI_ChunkRead_list( stream_t *s, avi_chunk_t *p_container )
avi_chunk_t *p_container,
vlc_bool_t b_seekable )
{ {
avi_chunk_t *p_chk; avi_chunk_t *p_chk;
uint8_t *p_peek; uint8_t *p_peek;
vlc_bool_t b_seekable;
if( p_container->common.i_chunk_size < 8 ) if( p_container->common.i_chunk_size < 8 )
{ {
/* empty box */ /* empty box */
msg_Warn( p_input, "empty list chunk" ); msg_Warn( (vlc_object_t*)s, "empty list chunk" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( input_Peek( p_input, &p_peek, 12 ) < 12 ) if( stream_Peek( s, &p_peek, 12 ) < 12 )
{ {
msg_Warn( p_input, "cannot peek while reading list chunk" ); msg_Warn( (vlc_object_t*)s, "cannot peek while reading list chunk" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
stream_Control( s, STREAM_CAN_FASTSEEK, &b_seekable );
p_container->list.i_type = GetFOURCC( p_peek + 8 ); p_container->list.i_type = GetFOURCC( p_peek + 8 );
if( p_container->common.i_chunk_fourcc == AVIFOURCC_LIST && if( p_container->common.i_chunk_fourcc == AVIFOURCC_LIST &&
p_container->list.i_type == AVIFOURCC_movi ) p_container->list.i_type == AVIFOURCC_movi )
{ {
msg_Dbg( p_input, "Skipping movi chunk" ); msg_Dbg( (vlc_object_t*)s, "Skipping movi chunk" );
if( b_seekable ) if( b_seekable )
{ {
return AVI_NextChunk( p_input, p_container ); return AVI_NextChunk( s, p_container );
}
else
{
return VLC_SUCCESS; // point at begining of LIST-movi
} }
return VLC_SUCCESS; // point at begining of LIST-movi
} }
if( AVI_SkipBytes( p_input, 12 ) ) if( stream_Read( s, NULL, 12 ) != 12 )
{ {
msg_Warn( p_input, "cannot enter chunk" ); msg_Warn( (vlc_object_t*)s, "cannot enter chunk" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"found LIST chunk: \'%4.4s\'", "found LIST chunk: \'%4.4s\'",
(char*)&p_container->list.i_type ); (char*)&p_container->list.i_type );
#endif #endif
msg_Dbg( p_input, "<list \'%4.4s\'>", (char*)&p_container->list.i_type ); msg_Dbg( (vlc_object_t*)s, "<list \'%4.4s\'>", (char*)&p_container->list.i_type );
for( ; ; ) for( ; ; )
{ {
p_chk = malloc( sizeof( avi_chunk_t ) ); p_chk = malloc( sizeof( avi_chunk_t ) );
...@@ -354,8 +174,8 @@ static int AVI_ChunkRead_list( input_thread_t *p_input, ...@@ -354,8 +174,8 @@ static int AVI_ChunkRead_list( input_thread_t *p_input,
} }
p_container->common.p_last = p_chk; p_container->common.p_last = p_chk;
if( AVI_ChunkRead( p_input, p_chk, p_container, b_seekable ) || if( AVI_ChunkRead( s, p_chk, p_container ) ||
( AVI_TellAbsolute( p_input ) >= ( stream_Tell( s ) >=
(off_t)p_chk->common.p_father->common.i_chunk_pos + (off_t)p_chk->common.p_father->common.i_chunk_pos +
(off_t)__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) ) (off_t)__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) )
{ {
...@@ -369,7 +189,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input, ...@@ -369,7 +189,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input,
} }
} }
msg_Dbg( p_input, "</list \'%4.4s\'>", (char*)&p_container->list.i_type ); msg_Dbg( (vlc_object_t*)s, "</list \'%4.4s\'>", (char*)&p_container->list.i_type );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -381,7 +201,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input, ...@@ -381,7 +201,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input,
{ \ { \
return 0; \ return 0; \
} \ } \
i_read = AVI_ReadData( p_input, p_read, i_read ); \ i_read = stream_Read( s, p_read, i_read ); \
p_read += 8; \ p_read += 8; \
i_read -= 8 i_read -= 8
...@@ -389,7 +209,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input, ...@@ -389,7 +209,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input,
free( p_buff ); \ free( p_buff ); \
if( i_read < 0 ) \ if( i_read < 0 ) \
{ \ { \
msg_Warn( p_input, "not enough data" ); \ msg_Warn( (vlc_object_t*)s, "not enough data" ); \
} \ } \
return code return code
...@@ -418,9 +238,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input, ...@@ -418,9 +238,7 @@ static int AVI_ChunkRead_list( input_thread_t *p_input,
p_read += 4; \ p_read += 4; \
i_read -= 4 i_read -= 4
static int AVI_ChunkRead_avih( input_thread_t *p_input, static int AVI_ChunkRead_avih( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
AVI_READCHUNK_ENTER; AVI_READCHUNK_ENTER;
...@@ -439,21 +257,19 @@ static int AVI_ChunkRead_avih( input_thread_t *p_input, ...@@ -439,21 +257,19 @@ static int AVI_ChunkRead_avih( input_thread_t *p_input,
AVI_READ4BYTES( p_chk->avih.i_start ); AVI_READ4BYTES( p_chk->avih.i_start );
AVI_READ4BYTES( p_chk->avih.i_length ); AVI_READ4BYTES( p_chk->avih.i_length );
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"avih: streams:%d flags:%s%s%s%s %dx%d", "avih: streams:%d flags:%s%s%s%s %dx%d",
p_chk->avih.i_streams, p_chk->avih.i_streams,
p_chk->avih.i_flags&AVIF_HASINDEX?" HAS_INDEX":"", p_chk->avih.i_flags&AVIF_HASINDEX?" HAS_INDEX":"",
p_chk->avih.i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"", p_chk->avih.i_flags&AVIF_MUSTUSEINDEX?" MUST_USE_INDEX":"",
p_chk->avih.i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"", p_chk->avih.i_flags&AVIF_ISINTERLEAVED?" IS_INTERLEAVED":"",
p_chk->avih.i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"", p_chk->avih.i_flags&AVIF_TRUSTCKTYPE?" TRUST_CKTYPE":"",
p_chk->avih.i_width, p_chk->avih.i_height ); p_chk->avih.i_width, p_chk->avih.i_height );
#endif #endif
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static int AVI_ChunkRead_strh( input_thread_t *p_input, static int AVI_ChunkRead_strh( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
AVI_READCHUNK_ENTER; AVI_READCHUNK_ENTER;
...@@ -470,33 +286,31 @@ static int AVI_ChunkRead_strh( input_thread_t *p_input, ...@@ -470,33 +286,31 @@ static int AVI_ChunkRead_strh( input_thread_t *p_input,
AVI_READ4BYTES( p_chk->strh.i_quality ); AVI_READ4BYTES( p_chk->strh.i_quality );
AVI_READ4BYTES( p_chk->strh.i_samplesize ); AVI_READ4BYTES( p_chk->strh.i_samplesize );
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"strh: type:%4.4s handler:0x%8.8x samplesize:%d %.2ffps", "strh: type:%4.4s handler:0x%8.8x samplesize:%d %.2ffps",
(char*)&p_chk->strh.i_type, (char*)&p_chk->strh.i_type,
p_chk->strh.i_handler, p_chk->strh.i_handler,
p_chk->strh.i_samplesize, p_chk->strh.i_samplesize,
( p_chk->strh.i_scale ? ( p_chk->strh.i_scale ?
(float)p_chk->strh.i_rate / (float)p_chk->strh.i_scale : -1) ); (float)p_chk->strh.i_rate / (float)p_chk->strh.i_scale : -1) );
#endif #endif
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static int AVI_ChunkRead_strf( input_thread_t *p_input, static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
avi_chunk_t *p_strh; avi_chunk_t *p_strh;
AVI_READCHUNK_ENTER; AVI_READCHUNK_ENTER;
if( p_chk->common.p_father == NULL ) if( p_chk->common.p_father == NULL )
{ {
msg_Err( p_input, "malformed avi file" ); msg_Err( (vlc_object_t*)s, "malformed avi file" );
AVI_READCHUNK_EXIT( VLC_EGENERIC ); AVI_READCHUNK_EXIT( VLC_EGENERIC );
} }
if( !( p_strh = AVI_ChunkFind( p_chk->common.p_father, AVIFOURCC_strh, 0 ) ) ) if( !( p_strh = AVI_ChunkFind( p_chk->common.p_father, AVIFOURCC_strh, 0 ) ) )
{ {
msg_Err( p_input, "malformed avi file" ); msg_Err( (vlc_object_t*)s, "malformed avi file" );
AVI_READCHUNK_EXIT( VLC_EGENERIC ); AVI_READCHUNK_EXIT( VLC_EGENERIC );
} }
...@@ -534,7 +348,7 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input, ...@@ -534,7 +348,7 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input,
p_chk->strf.auds.p_wf->cbSize ); p_chk->strf.auds.p_wf->cbSize );
} }
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"strf: audio:0x%4.4x channels:%d %dHz %dbits/sample %dkb/s", "strf: audio:0x%4.4x channels:%d %dHz %dbits/sample %dkb/s",
p_chk->strf.auds.p_wf->wFormatTag, p_chk->strf.auds.p_wf->wFormatTag,
p_chk->strf.auds.p_wf->nChannels, p_chk->strf.auds.p_wf->nChannels,
...@@ -571,7 +385,7 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input, ...@@ -571,7 +385,7 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input,
sizeof(BITMAPINFOHEADER) ); sizeof(BITMAPINFOHEADER) );
} }
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, msg_Dbg( (vlc_object_t*)s,
"strf: video:%4.4s %dx%d planes:%d %dbpp", "strf: video:%4.4s %dx%d planes:%d %dbpp",
(char*)&p_chk->strf.vids.p_bih->biCompression, (char*)&p_chk->strf.vids.p_bih->biCompression,
p_chk->strf.vids.p_bih->biWidth, p_chk->strf.vids.p_bih->biWidth,
...@@ -581,32 +395,26 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input, ...@@ -581,32 +395,26 @@ static int AVI_ChunkRead_strf( input_thread_t *p_input,
#endif #endif
break; break;
default: default:
msg_Warn( p_input, "unknown stream type" ); msg_Warn( (vlc_object_t*)s, "unknown stream type" );
p_chk->strf.common.i_cat = UNKNOWN_ES; p_chk->strf.common.i_cat = UNKNOWN_ES;
break; break;
} }
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static void AVI_ChunkFree_strf( input_thread_t *p_input, static void AVI_ChunkFree_strf( avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
avi_chunk_strf_t *p_strf = (avi_chunk_strf_t*)p_chk; avi_chunk_strf_t *p_strf = (avi_chunk_strf_t*)p_chk;
switch( p_strf->common.i_cat ) if( p_strf->common.i_cat == AUDIO_ES )
{ {
case AUDIO_ES: FREE( p_strf->auds.p_wf );
FREE( p_strf->auds.p_wf ); }
break; else if( p_strf->common.i_cat == VIDEO_ES )
case VIDEO_ES: {
FREE( p_strf->vids.p_bih ); FREE( p_strf->vids.p_bih );
break;
default:
break;
} }
} }
static int AVI_ChunkRead_strd( input_thread_t *p_input, static int AVI_ChunkRead_strd( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
AVI_READCHUNK_ENTER; AVI_READCHUNK_ENTER;
p_chk->strd.p_data = malloc( p_chk->common.i_chunk_size ); p_chk->strd.p_data = malloc( p_chk->common.i_chunk_size );
...@@ -616,9 +424,7 @@ static int AVI_ChunkRead_strd( input_thread_t *p_input, ...@@ -616,9 +424,7 @@ static int AVI_ChunkRead_strd( input_thread_t *p_input,
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static int AVI_ChunkRead_idx1( input_thread_t *p_input, static int AVI_ChunkRead_idx1( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
unsigned int i_count, i_index; unsigned int i_count, i_index;
...@@ -645,13 +451,12 @@ static int AVI_ChunkRead_idx1( input_thread_t *p_input, ...@@ -645,13 +451,12 @@ static int AVI_ChunkRead_idx1( input_thread_t *p_input,
p_chk->idx1.entry = NULL; p_chk->idx1.entry = NULL;
} }
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, "idx1: index entry:%d", i_count ); msg_Dbg( (vlc_object_t*)s, "idx1: index entry:%d", i_count );
#endif #endif
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static void AVI_ChunkFree_idx1( input_thread_t *p_input, static void AVI_ChunkFree_idx1( avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
p_chk->idx1.i_entry_count = 0; p_chk->idx1.i_entry_count = 0;
p_chk->idx1.i_entry_max = 0; p_chk->idx1.i_entry_max = 0;
...@@ -660,9 +465,7 @@ static void AVI_ChunkFree_idx1( input_thread_t *p_input, ...@@ -660,9 +465,7 @@ static void AVI_ChunkFree_idx1( input_thread_t *p_input,
static int AVI_ChunkRead_indx( input_thread_t *p_input, static int AVI_ChunkRead_indx( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
unsigned int i_count, i; unsigned int i_count, i;
int32_t i_dummy; int32_t i_dummy;
...@@ -730,16 +533,15 @@ static int AVI_ChunkRead_indx( input_thread_t *p_input, ...@@ -730,16 +533,15 @@ static int AVI_ChunkRead_indx( input_thread_t *p_input,
} }
else else
{ {
msg_Warn( p_input, "unknow type/subtype index" ); msg_Warn( (vlc_object_t*)s, "unknow type/subtype index" );
} }
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, "indx: type=%d subtype=%d entry=%d", p_indx->i_indextype, p_indx->i_indexsubtype, p_indx->i_entriesinuse ); msg_Dbg( (vlc_object_t*)s, "indx: type=%d subtype=%d entry=%d", p_indx->i_indextype, p_indx->i_indexsubtype, p_indx->i_entriesinuse );
#endif #endif
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static void AVI_ChunkFree_indx( input_thread_t *p_input, static void AVI_ChunkFree_indx( avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
avi_chunk_indx_t *p_indx = (avi_chunk_indx_t*)p_chk; avi_chunk_indx_t *p_indx = (avi_chunk_indx_t*)p_chk;
...@@ -784,9 +586,7 @@ static struct ...@@ -784,9 +586,7 @@ static struct
{ AVIFOURCC_strn, "stream name" }, { AVIFOURCC_strn, "stream name" },
{ 0, "???" } { 0, "???" }
}; };
static int AVI_ChunkRead_strz( input_thread_t *p_input, static int AVI_ChunkRead_strz( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
int i_index; int i_index;
avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk; avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk;
...@@ -810,27 +610,23 @@ static int AVI_ChunkRead_strz( input_thread_t *p_input, ...@@ -810,27 +610,23 @@ static int AVI_ChunkRead_strz( input_thread_t *p_input,
p_strz->p_str[i_read] = 0; p_strz->p_str[i_read] = 0;
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, "%4.4s: %s : %s", msg_Dbg( (vlc_object_t*)s, "%4.4s: %s : %s",
(char*)&p_strz->i_chunk_fourcc, p_strz->p_type, p_strz->p_str); (char*)&p_strz->i_chunk_fourcc, p_strz->p_type, p_strz->p_str);
#endif #endif
AVI_READCHUNK_EXIT( VLC_SUCCESS ); AVI_READCHUNK_EXIT( VLC_SUCCESS );
} }
static void AVI_ChunkFree_strz( input_thread_t *p_input, static void AVI_ChunkFree_strz( avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk; avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk;
FREE( p_strz->p_type ); FREE( p_strz->p_type );
FREE( p_strz->p_str ); FREE( p_strz->p_str );
} }
static int AVI_ChunkRead_nothing( input_thread_t *p_input, static int AVI_ChunkRead_nothing( stream_t *s, avi_chunk_t *p_chk )
avi_chunk_t *p_chk,
vlc_bool_t b_seekable )
{ {
return AVI_NextChunk( p_input, p_chk ); return AVI_NextChunk( s, p_chk );
} }
static void AVI_ChunkFree_nothing( input_thread_t *p_input, static void AVI_ChunkFree_nothing( avi_chunk_t *p_chk )
avi_chunk_t *p_chk )
{ {
} }
...@@ -838,11 +634,8 @@ static void AVI_ChunkFree_nothing( input_thread_t *p_input, ...@@ -838,11 +634,8 @@ static void AVI_ChunkFree_nothing( input_thread_t *p_input,
static struct static struct
{ {
vlc_fourcc_t i_fourcc; vlc_fourcc_t i_fourcc;
int (*AVI_ChunkRead_function)( input_thread_t *p_input, int (*AVI_ChunkRead_function)( stream_t *s, avi_chunk_t *p_chk );
avi_chunk_t *p_chk, void (*AVI_ChunkFree_function)( avi_chunk_t *p_chk );
vlc_bool_t b_seekable );
void (*AVI_ChunkFree_function)( input_thread_t *p_input,
avi_chunk_t *p_chk );
} AVI_Chunk_Function [] = } AVI_Chunk_Function [] =
{ {
{ AVIFOURCC_RIFF, AVI_ChunkRead_list, AVI_ChunkFree_nothing }, { AVIFOURCC_RIFF, AVI_ChunkRead_list, AVI_ChunkFree_nothing },
...@@ -898,10 +691,7 @@ static int AVI_ChunkFunctionFind( vlc_fourcc_t i_fourcc ) ...@@ -898,10 +691,7 @@ static int AVI_ChunkFunctionFind( vlc_fourcc_t i_fourcc )
} }
} }
int _AVI_ChunkRead( input_thread_t *p_input, int _AVI_ChunkRead( stream_t *s, avi_chunk_t *p_chk, avi_chunk_t *p_father )
avi_chunk_t *p_chk,
avi_chunk_t *p_father,
vlc_bool_t b_seekable )
{ {
int i_index; int i_index;
...@@ -910,14 +700,14 @@ int _AVI_ChunkRead( input_thread_t *p_input, ...@@ -910,14 +700,14 @@ int _AVI_ChunkRead( input_thread_t *p_input,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( AVI_ChunkReadCommon( p_input, p_chk ) ) if( AVI_ChunkReadCommon( s, p_chk ) )
{ {
msg_Warn( p_input, "cannot read one chunk" ); msg_Warn( (vlc_object_t*)s, "cannot read one chunk" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( p_chk->common.i_chunk_fourcc == VLC_FOURCC( 0, 0, 0, 0 ) ) if( p_chk->common.i_chunk_fourcc == VLC_FOURCC( 0, 0, 0, 0 ) )
{ {
msg_Warn( p_input, "found null fourcc chunk (corrupted file?)" ); msg_Warn( (vlc_object_t*)s, "found null fourcc chunk (corrupted file?)" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_chk->common.p_father = p_father; p_chk->common.p_father = p_father;
...@@ -925,20 +715,19 @@ int _AVI_ChunkRead( input_thread_t *p_input, ...@@ -925,20 +715,19 @@ int _AVI_ChunkRead( input_thread_t *p_input,
i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc ); i_index = AVI_ChunkFunctionFind( p_chk->common.i_chunk_fourcc );
if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function ) if( AVI_Chunk_Function[i_index].AVI_ChunkRead_function )
{ {
return AVI_Chunk_Function[i_index]. return AVI_Chunk_Function[i_index].AVI_ChunkRead_function( s, p_chk );
AVI_ChunkRead_function( p_input, p_chk, b_seekable );
} }
else if( ((char*)&p_chk->common.i_chunk_fourcc)[0] == 'i' && else if( ((char*)&p_chk->common.i_chunk_fourcc)[0] == 'i' &&
((char*)&p_chk->common.i_chunk_fourcc)[1] == 'x' ) ((char*)&p_chk->common.i_chunk_fourcc)[1] == 'x' )
{ {
p_chk->common.i_chunk_fourcc = AVIFOURCC_indx; p_chk->common.i_chunk_fourcc = AVIFOURCC_indx;
return AVI_ChunkRead_indx( p_input, p_chk, b_seekable ); return AVI_ChunkRead_indx( s, p_chk );
} }
msg_Warn( p_input, "unknown chunk (not loaded)" ); msg_Warn( (vlc_object_t*)s, "unknown chunk (not loaded)" );
return AVI_NextChunk( p_input, p_chk ); return AVI_NextChunk( s, p_chk );
} }
void _AVI_ChunkFree( input_thread_t *p_input, void _AVI_ChunkFree( stream_t *s,
avi_chunk_t *p_chk ) avi_chunk_t *p_chk )
{ {
int i_index; int i_index;
...@@ -954,7 +743,7 @@ void _AVI_ChunkFree( input_thread_t *p_input, ...@@ -954,7 +743,7 @@ void _AVI_ChunkFree( input_thread_t *p_input,
while( p_child ) while( p_child )
{ {
p_next = p_child->common.p_next; p_next = p_child->common.p_next;
AVI_ChunkFree( p_input, p_child ); AVI_ChunkFree( s, p_child );
free( p_child ); free( p_child );
p_child = p_next; p_child = p_next;
} }
...@@ -963,14 +752,14 @@ void _AVI_ChunkFree( input_thread_t *p_input, ...@@ -963,14 +752,14 @@ void _AVI_ChunkFree( input_thread_t *p_input,
if( AVI_Chunk_Function[i_index].AVI_ChunkFree_function ) if( AVI_Chunk_Function[i_index].AVI_ChunkFree_function )
{ {
#ifdef AVI_DEBUG #ifdef AVI_DEBUG
msg_Dbg( p_input, "free chunk %4.4s", msg_Dbg( (vlc_object_t*)s, "free chunk %4.4s",
(char*)&p_chk->common.i_chunk_fourcc ); (char*)&p_chk->common.i_chunk_fourcc );
#endif #endif
AVI_Chunk_Function[i_index].AVI_ChunkFree_function( p_input, p_chk); AVI_Chunk_Function[i_index].AVI_ChunkFree_function( p_chk);
} }
else else
{ {
msg_Warn( p_input, "unknown chunk (not unloaded)" ); msg_Warn( (vlc_object_t*)s, "unknown chunk (not unloaded)" );
} }
p_chk->common.p_first = NULL; p_chk->common.p_first = NULL;
p_chk->common.p_last = NULL; p_chk->common.p_last = NULL;
...@@ -978,15 +767,18 @@ void _AVI_ChunkFree( input_thread_t *p_input, ...@@ -978,15 +767,18 @@ void _AVI_ChunkFree( input_thread_t *p_input,
return; return;
} }
int AVI_ChunkReadRoot( input_thread_t *p_input, static void AVI_ChunkDumpDebug( stream_t *, avi_chunk_t *);
avi_chunk_t *p_root,
vlc_bool_t b_seekable ) int AVI_ChunkReadRoot( stream_t *s, avi_chunk_t *p_root )
{ {
avi_chunk_list_t *p_list = (avi_chunk_list_t*)p_root; avi_chunk_list_t *p_list = (avi_chunk_list_t*)p_root;
avi_chunk_t *p_chk; avi_chunk_t *p_chk;
vlc_bool_t b_seekable;
stream_Control( s, STREAM_CAN_FASTSEEK, &b_seekable );
p_list->i_chunk_pos = 0; p_list->i_chunk_pos = 0;
p_list->i_chunk_size = p_input->stream.p_selected_area->i_size; p_list->i_chunk_size = stream_Size( s );
p_list->i_chunk_fourcc = AVIFOURCC_LIST; p_list->i_chunk_fourcc = AVIFOURCC_LIST;
p_list->p_father = NULL; p_list->p_father = NULL;
p_list->p_next = NULL; p_list->p_next = NULL;
...@@ -1009,8 +801,8 @@ int AVI_ChunkReadRoot( input_thread_t *p_input, ...@@ -1009,8 +801,8 @@ int AVI_ChunkReadRoot( input_thread_t *p_input,
} }
p_root->common.p_last = p_chk; p_root->common.p_last = p_chk;
if( AVI_ChunkRead( p_input, p_chk, p_root, b_seekable ) || if( AVI_ChunkRead( s, p_chk, p_root ) ||
( AVI_TellAbsolute( p_input ) >= ( stream_Tell( s ) >=
(off_t)p_chk->common.p_father->common.i_chunk_pos + (off_t)p_chk->common.p_father->common.i_chunk_pos +
(off_t)__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) ) (off_t)__EVEN( p_chk->common.p_father->common.i_chunk_size ) ) )
{ {
...@@ -1022,15 +814,16 @@ int AVI_ChunkReadRoot( input_thread_t *p_input, ...@@ -1022,15 +814,16 @@ int AVI_ChunkReadRoot( input_thread_t *p_input,
{ {
break; break;
} }
} }
AVI_ChunkDumpDebug( s, p_root );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
void AVI_ChunkFreeRoot( input_thread_t *p_input, void AVI_ChunkFreeRoot( stream_t *s,
avi_chunk_t *p_chk ) avi_chunk_t *p_chk )
{ {
AVI_ChunkFree( p_input, p_chk ); AVI_ChunkFree( s, p_chk );
} }
...@@ -1049,7 +842,7 @@ int _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc ) ...@@ -1049,7 +842,7 @@ int _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc )
while( p_child ) while( p_child )
{ {
if( p_child->common.i_chunk_fourcc == i_fourcc || if( p_child->common.i_chunk_fourcc == i_fourcc ||
( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST && ( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST &&
p_child->list.i_type == i_fourcc ) ) p_child->list.i_type == i_fourcc ) )
{ {
i_count++; i_count++;
...@@ -1059,8 +852,8 @@ int _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc ) ...@@ -1059,8 +852,8 @@ int _AVI_ChunkCount( avi_chunk_t *p_chk, vlc_fourcc_t i_fourcc )
return i_count; return i_count;
} }
avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk, void *_AVI_ChunkFind( avi_chunk_t *p_chk,
vlc_fourcc_t i_fourcc, int i_number ) vlc_fourcc_t i_fourcc, int i_number )
{ {
avi_chunk_t *p_child; avi_chunk_t *p_child;
if( !p_chk ) if( !p_chk )
...@@ -1072,7 +865,7 @@ avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk, ...@@ -1072,7 +865,7 @@ avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk,
while( p_child ) while( p_child )
{ {
if( p_child->common.i_chunk_fourcc == i_fourcc || if( p_child->common.i_chunk_fourcc == i_fourcc ||
( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST && ( p_child->common.i_chunk_fourcc == AVIFOURCC_LIST &&
p_child->list.i_type == i_fourcc ) ) p_child->list.i_type == i_fourcc ) )
{ {
if( i_number == 0 ) if( i_number == 0 )
...@@ -1088,13 +881,13 @@ avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk, ...@@ -1088,13 +881,13 @@ avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk,
return NULL; return NULL;
} }
static void AVI_ChunkDumpDebug_level( input_thread_t *p_input, static void AVI_ChunkDumpDebug_level( vlc_object_t *p_obj,
avi_chunk_t *p_chk, int i_level ) avi_chunk_t *p_chk, int i_level )
{ {
char str[1024]; char str[1024];
int i; int i;
avi_chunk_t *p_child; avi_chunk_t *p_child;
memset( str, ' ', sizeof( str ) ); memset( str, ' ', sizeof( str ) );
for( i = 1; i < i_level; i++ ) for( i = 1; i < i_level; i++ )
{ {
...@@ -1103,7 +896,7 @@ static void AVI_ChunkDumpDebug_level( input_thread_t *p_input, ...@@ -1103,7 +896,7 @@ static void AVI_ChunkDumpDebug_level( input_thread_t *p_input,
if( p_chk->common.i_chunk_fourcc == AVIFOURCC_RIFF|| if( p_chk->common.i_chunk_fourcc == AVIFOURCC_RIFF||
p_chk->common.i_chunk_fourcc == AVIFOURCC_LIST ) p_chk->common.i_chunk_fourcc == AVIFOURCC_LIST )
{ {
sprintf( str + i_level * 5, sprintf( str + i_level * 5,
"%c %4.4s-%4.4s size:"I64Fu" pos:"I64Fu, "%c %4.4s-%4.4s size:"I64Fu" pos:"I64Fu,
i_level ? '+' : '*', i_level ? '+' : '*',
(char*)&p_chk->common.i_chunk_fourcc, (char*)&p_chk->common.i_chunk_fourcc,
...@@ -1113,24 +906,25 @@ static void AVI_ChunkDumpDebug_level( input_thread_t *p_input, ...@@ -1113,24 +906,25 @@ static void AVI_ChunkDumpDebug_level( input_thread_t *p_input,
} }
else else
{ {
sprintf( str + i_level * 5, sprintf( str + i_level * 5,
"+ %4.4s size:"I64Fu" pos:"I64Fu, "+ %4.4s size:"I64Fu" pos:"I64Fu,
(char*)&p_chk->common.i_chunk_fourcc, (char*)&p_chk->common.i_chunk_fourcc,
p_chk->common.i_chunk_size, p_chk->common.i_chunk_size,
p_chk->common.i_chunk_pos ); p_chk->common.i_chunk_pos );
} }
msg_Dbg( p_input, "%s", str ); msg_Dbg( p_obj, "%s", str );
p_child = p_chk->common.p_first; p_child = p_chk->common.p_first;
while( p_child ) while( p_child )
{ {
AVI_ChunkDumpDebug_level( p_input, p_child, i_level + 1 ); AVI_ChunkDumpDebug_level( p_obj, p_child, i_level + 1 );
p_child = p_child->common.p_next; p_child = p_child->common.p_next;
} }
} }
void _AVI_ChunkDumpDebug( input_thread_t *p_input,
avi_chunk_t *p_chk ) static void AVI_ChunkDumpDebug( stream_t *s, avi_chunk_t *p_chk )
{ {
AVI_ChunkDumpDebug_level( p_input, p_chk, 0 ); AVI_ChunkDumpDebug_level( (vlc_object_t*)s, p_chk, 0 );
} }
/***************************************************************************** /*****************************************************************************
* libavi.h : LibAVI library * libavi.h : LibAVI library
****************************************************************************** ******************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: libavi.h,v 1.10 2003/04/27 13:55:51 fenrir Exp $ * $Id: libavi.h,v 1.11 2003/08/22 20:31:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#include "codecs.h" /* BITMAPINFOHEADER */
/* flags for use in <dwFlags> in AVIFileHdr */ /* flags for use in <dwFlags> in AVIFileHdr */
#define AVIF_HASINDEX 0x00000010 /* Index at end of file? */ #define AVIF_HASINDEX 0x00000010 /* Index at end of file? */
#define AVIF_MUSTUSEINDEX 0x00000020 #define AVIF_MUSTUSEINDEX 0x00000020
...@@ -40,135 +37,6 @@ ...@@ -40,135 +37,6 @@
the keyframe flag isn't a true flag the keyframe flag isn't a true flag
but have to be verified */ but have to be verified */
/* *** avi stuff *** */
#define AVIFOURCC_RIFF VLC_FOURCC('R','I','F','F')
#define AVIFOURCC_LIST VLC_FOURCC('L','I','S','T')
#define AVIFOURCC_JUNK VLC_FOURCC('J','U','N','K')
#define AVIFOURCC_AVI VLC_FOURCC('A','V','I',' ')
#define AVIFOURCC_AVIX VLC_FOURCC('A','V','I','X')
#define AVIFOURCC_WAVE VLC_FOURCC('W','A','V','E')
#define AVIFOURCC_INFO VLC_FOURCC('I','N','F','O')
#define AVIFOURCC_avih VLC_FOURCC('a','v','i','h')
#define AVIFOURCC_hdrl VLC_FOURCC('h','d','r','l')
#define AVIFOURCC_movi VLC_FOURCC('m','o','v','i')
#define AVIFOURCC_idx1 VLC_FOURCC('i','d','x','1')
#define AVIFOURCC_strl VLC_FOURCC('s','t','r','l')
#define AVIFOURCC_strh VLC_FOURCC('s','t','r','h')
#define AVIFOURCC_strf VLC_FOURCC('s','t','r','f')
#define AVIFOURCC_strd VLC_FOURCC('s','t','r','d')
#define AVIFOURCC_strn VLC_FOURCC('s','t','r','n')
#define AVIFOURCC_indx VLC_FOURCC('i','n','d','x')
#define AVIFOURCC_rec VLC_FOURCC('r','e','c',' ')
#define AVIFOURCC_auds VLC_FOURCC('a','u','d','s')
#define AVIFOURCC_vids VLC_FOURCC('v','i','d','s')
#define AVIFOURCC_IARL VLC_FOURCC('I','A','R','L')
#define AVIFOURCC_IART VLC_FOURCC('I','A','R','T')
#define AVIFOURCC_ICMS VLC_FOURCC('I','C','M','S')
#define AVIFOURCC_ICMT VLC_FOURCC('I','C','M','T')
#define AVIFOURCC_ICOP VLC_FOURCC('I','C','O','P')
#define AVIFOURCC_ICRD VLC_FOURCC('I','C','R','D')
#define AVIFOURCC_ICRP VLC_FOURCC('I','C','R','P')
#define AVIFOURCC_IDIM VLC_FOURCC('I','D','I','M')
#define AVIFOURCC_IDPI VLC_FOURCC('I','D','P','I')
#define AVIFOURCC_IENG VLC_FOURCC('I','E','N','G')
#define AVIFOURCC_IGNR VLC_FOURCC('I','G','N','R')
#define AVIFOURCC_IKEY VLC_FOURCC('I','K','E','Y')
#define AVIFOURCC_ILGT VLC_FOURCC('I','L','G','T')
#define AVIFOURCC_IMED VLC_FOURCC('I','M','E','D')
#define AVIFOURCC_INAM VLC_FOURCC('I','N','A','M')
#define AVIFOURCC_IPLT VLC_FOURCC('I','P','L','T')
#define AVIFOURCC_IPRD VLC_FOURCC('I','P','R','D')
#define AVIFOURCC_ISBJ VLC_FOURCC('I','S','B','J')
#define AVIFOURCC_ISFT VLC_FOURCC('I','S','F','T')
#define AVIFOURCC_ISHP VLC_FOURCC('I','S','H','P')
#define AVIFOURCC_ISRC VLC_FOURCC('I','S','R','C')
#define AVIFOURCC_ISRF VLC_FOURCC('I','S','R','F')
#define AVIFOURCC_ITCH VLC_FOURCC('I','T','C','H')
#define AVIFOURCC_ISMP VLC_FOURCC('I','S','M','P')
#define AVIFOURCC_IDIT VLC_FOURCC('I','D','I','T')
#define AVITWOCC_wb VLC_TWOCC('w','b')
#define AVITWOCC_db VLC_TWOCC('d','b')
#define AVITWOCC_dc VLC_TWOCC('d','c')
#define AVITWOCC_pc VLC_TWOCC('p','c')
/* *** codex stuff *** */
/* MPEG4 video */
#define FOURCC_DIVX VLC_FOURCC('D','I','V','X')
#define FOURCC_divx VLC_FOURCC('d','i','v','x')
#define FOURCC_DIV1 VLC_FOURCC('D','I','V','1')
#define FOURCC_div1 VLC_FOURCC('d','i','v','1')
#define FOURCC_MP4S VLC_FOURCC('M','P','4','S')
#define FOURCC_mp4s VLC_FOURCC('m','p','4','s')
#define FOURCC_M4S2 VLC_FOURCC('M','4','S','2')
#define FOURCC_m4s2 VLC_FOURCC('m','4','s','2')
#define FOURCC_xvid VLC_FOURCC('x','v','i','d')
#define FOURCC_XVID VLC_FOURCC('X','V','I','D')
#define FOURCC_XviD VLC_FOURCC('X','v','i','D')
#define FOURCC_DX50 VLC_FOURCC('D','X','5','0')
#define FOURCC_mp4v VLC_FOURCC('m','p','4','v')
#define FOURCC_4 VLC_FOURCC( 4, 0, 0, 0 )
/* MSMPEG4 v2 */
#define FOURCC_MPG4 VLC_FOURCC('M','P','G','4')
#define FOURCC_mpg4 VLC_FOURCC('m','p','g','4')
#define FOURCC_DIV2 VLC_FOURCC('D','I','V','2')
#define FOURCC_div2 VLC_FOURCC('d','i','v','2')
#define FOURCC_MP42 VLC_FOURCC('M','P','4','2')
#define FOURCC_mp42 VLC_FOURCC('m','p','4','2')
/* MSMPEG4 v3 / M$ mpeg4 v3 */
#define FOURCC_MPG3 VLC_FOURCC('M','P','G','3')
#define FOURCC_mpg3 VLC_FOURCC('m','p','g','3')
#define FOURCC_div3 VLC_FOURCC('d','i','v','3')
#define FOURCC_MP43 VLC_FOURCC('M','P','4','3')
#define FOURCC_mp43 VLC_FOURCC('m','p','4','3')
/* DivX 3.20 */
#define FOURCC_DIV3 VLC_FOURCC('D','I','V','3')
#define FOURCC_DIV4 VLC_FOURCC('D','I','V','4')
#define FOURCC_div4 VLC_FOURCC('d','i','v','4')
#define FOURCC_DIV5 VLC_FOURCC('D','I','V','5')
#define FOURCC_div5 VLC_FOURCC('d','i','v','5')
#define FOURCC_DIV6 VLC_FOURCC('D','I','V','6')
#define FOURCC_div6 VLC_FOURCC('d','i','v','6')
/* AngelPotion stuff */
#define FOURCC_AP41 VLC_FOURCC('A','P','4','1')
/* 3IVX */
#define FOURCC_3IV1 VLC_FOURCC('3','I','V','1')
#define FOURCC_3iv1 VLC_FOURCC('2','i','v','1')
#define FOURCC_3IV2 VLC_FOURCC('3','I','V','2')
#define FOURCC_3iv2 VLC_FOURCC('3','i','v','2')
#define FOURCC_3IVD VLC_FOURCC('3','I','V','D')
#define FOURCC_3ivd VLC_FOURCC('3','i','v','d')
#define FOURCC_3VID VLC_FOURCC('3','V','I','D')
#define FOURCC_3vid VLC_FOURCC('3','v','i','d')
/* H263 and H263i */
#define FOURCC_H263 VLC_FOURCC('H','2','6','3')
#define FOURCC_h263 VLC_FOURCC('h','2','6','3')
#define FOURCC_U263 VLC_FOURCC('U','2','6','3')
#define FOURCC_I263 VLC_FOURCC('I','2','6','3')
#define FOURCC_i263 VLC_FOURCC('i','2','6','3')
/* Sound formats */
#define WAVE_FORMAT_UNKNOWN 0x0000
#define WAVE_FORMAT_PCM 0x0001
#define WAVE_FORMAT_MPEG 0x0050
#define WAVE_FORMAT_MPEGLAYER3 0x0055
#define WAVE_FORMAT_A52 0x2000
#define WAVE_FORMAT_WMA1 0x0160
#define WAVE_FORMAT_WMA2 0x0161
#define AVI_CHUNK_COMMON \ #define AVI_CHUNK_COMMON \
vlc_fourcc_t i_chunk_fourcc; \ vlc_fourcc_t i_chunk_fourcc; \
uint64_t i_chunk_size; \ uint64_t i_chunk_size; \
...@@ -341,52 +209,23 @@ typedef union avi_chunk_u ...@@ -341,52 +209,23 @@ typedef union avi_chunk_u
avi_chunk_STRING_t strz; avi_chunk_STRING_t strz;
} avi_chunk_t; } avi_chunk_t;
/****************************************************************************
* AVI_TestFile : test file header to see if it's an avi file
****************************************************************************/
int AVI_TestFile( input_thread_t *p_input );
/**************************************************************************** /****************************************************************************
* Stream(input) access functions * Stream(input) access functions
****************************************************************************/ ****************************************************************************/
off_t AVI_TellAbsolute( input_thread_t *p_input ); int _AVI_ChunkRead( stream_t *,
int AVI_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
int AVI_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size );
int AVI_SkipBytes( input_thread_t *p_input, int64_t i_count );
int _AVI_ChunkRead( input_thread_t *p_input,
avi_chunk_t *p_chk, avi_chunk_t *p_chk,
avi_chunk_t *p_father, avi_chunk_t *p_father );
vlc_bool_t b_seekable );
void _AVI_ChunkFree( input_thread_t *p_input,
avi_chunk_t *p_chk );
int _AVI_ChunkGoto( input_thread_t *p_input,
avi_chunk_t *p_chk );
void _AVI_ChunkDumpDebug( input_thread_t *p_input,
avi_chunk_t *p_chk );
int _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t ); int _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t );
avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *, vlc_fourcc_t, int ); void *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int );
int AVI_ChunkReadRoot( input_thread_t *p_input, int AVI_ChunkReadRoot( stream_t *, avi_chunk_t *p_root );
avi_chunk_t *p_root, void AVI_ChunkFreeRoot( stream_t *, avi_chunk_t *p_chk );
vlc_bool_t b_seekable );
void AVI_ChunkFreeRoot( input_thread_t *p_input,
avi_chunk_t *p_chk );
#define AVI_ChunkRead( p_input, p_chk, p_father, b_seekable ) \
_AVI_ChunkRead( p_input, \
(avi_chunk_t*)p_chk, \
(avi_chunk_t*)p_father, \
b_seekable )
#define AVI_ChunkFree( p_input, p_chk ) \
_AVI_ChunkFree( p_input, (avi_chunk_t*)p_chk )
#define AVI_ChunkGoto( p_input, p_chk ) \
_AVI_ChunkGoto( p_input, (avi_chunk_t*)p_chk )
#define AVI_ChunkDumpDebug( p_input, p_chk ) \
_AVI_ChunkDumpDebug( p_input, (avi_chunk_t*)p_chk )
#define AVI_ChunkRead( s, p_chk, p_father ) \
_AVI_ChunkRead( s, \
(avi_chunk_t*)p_chk, \
(avi_chunk_t*)p_father )
#define AVI_ChunkCount( p_chk, i_fourcc ) \ #define AVI_ChunkCount( p_chk, i_fourcc ) \
_AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc ) _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
...@@ -394,4 +233,123 @@ void AVI_ChunkFreeRoot( input_thread_t *p_input, ...@@ -394,4 +233,123 @@ void AVI_ChunkFreeRoot( input_thread_t *p_input,
_AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number ) _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number )
/* *** avi stuff *** */
#define AVIFOURCC_RIFF VLC_FOURCC('R','I','F','F')
#define AVIFOURCC_LIST VLC_FOURCC('L','I','S','T')
#define AVIFOURCC_JUNK VLC_FOURCC('J','U','N','K')
#define AVIFOURCC_AVI VLC_FOURCC('A','V','I',' ')
#define AVIFOURCC_AVIX VLC_FOURCC('A','V','I','X')
#define AVIFOURCC_WAVE VLC_FOURCC('W','A','V','E')
#define AVIFOURCC_INFO VLC_FOURCC('I','N','F','O')
#define AVIFOURCC_avih VLC_FOURCC('a','v','i','h')
#define AVIFOURCC_hdrl VLC_FOURCC('h','d','r','l')
#define AVIFOURCC_movi VLC_FOURCC('m','o','v','i')
#define AVIFOURCC_idx1 VLC_FOURCC('i','d','x','1')
#define AVIFOURCC_strl VLC_FOURCC('s','t','r','l')
#define AVIFOURCC_strh VLC_FOURCC('s','t','r','h')
#define AVIFOURCC_strf VLC_FOURCC('s','t','r','f')
#define AVIFOURCC_strd VLC_FOURCC('s','t','r','d')
#define AVIFOURCC_strn VLC_FOURCC('s','t','r','n')
#define AVIFOURCC_indx VLC_FOURCC('i','n','d','x')
#define AVIFOURCC_rec VLC_FOURCC('r','e','c',' ')
#define AVIFOURCC_auds VLC_FOURCC('a','u','d','s')
#define AVIFOURCC_vids VLC_FOURCC('v','i','d','s')
#define AVIFOURCC_IARL VLC_FOURCC('I','A','R','L')
#define AVIFOURCC_IART VLC_FOURCC('I','A','R','T')
#define AVIFOURCC_ICMS VLC_FOURCC('I','C','M','S')
#define AVIFOURCC_ICMT VLC_FOURCC('I','C','M','T')
#define AVIFOURCC_ICOP VLC_FOURCC('I','C','O','P')
#define AVIFOURCC_ICRD VLC_FOURCC('I','C','R','D')
#define AVIFOURCC_ICRP VLC_FOURCC('I','C','R','P')
#define AVIFOURCC_IDIM VLC_FOURCC('I','D','I','M')
#define AVIFOURCC_IDPI VLC_FOURCC('I','D','P','I')
#define AVIFOURCC_IENG VLC_FOURCC('I','E','N','G')
#define AVIFOURCC_IGNR VLC_FOURCC('I','G','N','R')
#define AVIFOURCC_IKEY VLC_FOURCC('I','K','E','Y')
#define AVIFOURCC_ILGT VLC_FOURCC('I','L','G','T')
#define AVIFOURCC_IMED VLC_FOURCC('I','M','E','D')
#define AVIFOURCC_INAM VLC_FOURCC('I','N','A','M')
#define AVIFOURCC_IPLT VLC_FOURCC('I','P','L','T')
#define AVIFOURCC_IPRD VLC_FOURCC('I','P','R','D')
#define AVIFOURCC_ISBJ VLC_FOURCC('I','S','B','J')
#define AVIFOURCC_ISFT VLC_FOURCC('I','S','F','T')
#define AVIFOURCC_ISHP VLC_FOURCC('I','S','H','P')
#define AVIFOURCC_ISRC VLC_FOURCC('I','S','R','C')
#define AVIFOURCC_ISRF VLC_FOURCC('I','S','R','F')
#define AVIFOURCC_ITCH VLC_FOURCC('I','T','C','H')
#define AVIFOURCC_ISMP VLC_FOURCC('I','S','M','P')
#define AVIFOURCC_IDIT VLC_FOURCC('I','D','I','T')
#define AVITWOCC_wb VLC_TWOCC('w','b')
#define AVITWOCC_db VLC_TWOCC('d','b')
#define AVITWOCC_dc VLC_TWOCC('d','c')
#define AVITWOCC_pc VLC_TWOCC('p','c')
/* *** codex stuff *** */
/* MPEG4 video */
#define FOURCC_DIVX VLC_FOURCC('D','I','V','X')
#define FOURCC_divx VLC_FOURCC('d','i','v','x')
#define FOURCC_DIV1 VLC_FOURCC('D','I','V','1')
#define FOURCC_div1 VLC_FOURCC('d','i','v','1')
#define FOURCC_MP4S VLC_FOURCC('M','P','4','S')
#define FOURCC_mp4s VLC_FOURCC('m','p','4','s')
#define FOURCC_M4S2 VLC_FOURCC('M','4','S','2')
#define FOURCC_m4s2 VLC_FOURCC('m','4','s','2')
#define FOURCC_xvid VLC_FOURCC('x','v','i','d')
#define FOURCC_XVID VLC_FOURCC('X','V','I','D')
#define FOURCC_XviD VLC_FOURCC('X','v','i','D')
#define FOURCC_DX50 VLC_FOURCC('D','X','5','0')
#define FOURCC_mp4v VLC_FOURCC('m','p','4','v')
#define FOURCC_4 VLC_FOURCC( 4, 0, 0, 0 )
/* MSMPEG4 v2 */
#define FOURCC_MPG4 VLC_FOURCC('M','P','G','4')
#define FOURCC_mpg4 VLC_FOURCC('m','p','g','4')
#define FOURCC_DIV2 VLC_FOURCC('D','I','V','2')
#define FOURCC_div2 VLC_FOURCC('d','i','v','2')
#define FOURCC_MP42 VLC_FOURCC('M','P','4','2')
#define FOURCC_mp42 VLC_FOURCC('m','p','4','2')
/* MSMPEG4 v3 / M$ mpeg4 v3 */
#define FOURCC_MPG3 VLC_FOURCC('M','P','G','3')
#define FOURCC_mpg3 VLC_FOURCC('m','p','g','3')
#define FOURCC_div3 VLC_FOURCC('d','i','v','3')
#define FOURCC_MP43 VLC_FOURCC('M','P','4','3')
#define FOURCC_mp43 VLC_FOURCC('m','p','4','3')
/* DivX 3.20 */
#define FOURCC_DIV3 VLC_FOURCC('D','I','V','3')
#define FOURCC_DIV4 VLC_FOURCC('D','I','V','4')
#define FOURCC_div4 VLC_FOURCC('d','i','v','4')
#define FOURCC_DIV5 VLC_FOURCC('D','I','V','5')
#define FOURCC_div5 VLC_FOURCC('d','i','v','5')
#define FOURCC_DIV6 VLC_FOURCC('D','I','V','6')
#define FOURCC_div6 VLC_FOURCC('d','i','v','6')
/* AngelPotion stuff */
#define FOURCC_AP41 VLC_FOURCC('A','P','4','1')
/* 3IVX */
#define FOURCC_3IV1 VLC_FOURCC('3','I','V','1')
#define FOURCC_3iv1 VLC_FOURCC('2','i','v','1')
#define FOURCC_3IV2 VLC_FOURCC('3','I','V','2')
#define FOURCC_3iv2 VLC_FOURCC('3','i','v','2')
#define FOURCC_3IVD VLC_FOURCC('3','I','V','D')
#define FOURCC_3ivd VLC_FOURCC('3','i','v','d')
#define FOURCC_3VID VLC_FOURCC('3','V','I','D')
#define FOURCC_3vid VLC_FOURCC('3','v','i','d')
/* H263 and H263i */
#define FOURCC_H263 VLC_FOURCC('H','2','6','3')
#define FOURCC_h263 VLC_FOURCC('h','2','6','3')
#define FOURCC_U263 VLC_FOURCC('U','2','6','3')
#define FOURCC_I263 VLC_FOURCC('I','2','6','3')
#define FOURCC_i263 VLC_FOURCC('i','2','6','3')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment