* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.7 2002/10/27 15:37:16 fenrir Exp $
+ * $Id: avi.c,v 1.8 2002/10/28 01:51:37 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
p_avi->i_pcr = 0;
p_avi->b_seekable = ( ( p_input->stream.b_seekable )
&&( p_input->stream.i_method == INPUT_METHOD_FILE ) );
+ p_avi->i_movi_lastchunk_pos = 0;
+
/* *** for unseekable stream, automaticaly use AVIDemux_interleaved *** */
if( !p_avi->b_seekable || config_GetInt( p_input, "avi-interleaved" ) )
{
AVI_SkipBytes( p_input, 12 ); // enter in p_movi
p_avi->i_movi_begin = p_movi->i_chunk_pos;
- p_avi->i_movi_lastchunk_pos = 0;
return( 0 );
}
p_stream->i_idxposc = i_ck;
p_stream->i_idxposb = 0;
- if( i_ck < p_stream->i_idxnb )
- {
- return( 1 );
- }
- else
+ if( i_ck >= p_stream->i_idxnb )
{
p_stream->i_idxposc = p_stream->i_idxnb - 1;
do
}
} while( p_stream->i_idxposc < i_ck );
-
- return( 1 );
}
+
+ return( 1 );
}
if( toread[i].i_posf > 0 )
{
- i_stream = i;
- if( i_pos == -1 )
+ if( i_pos == -1 || i_pos > toread[i_stream].i_posf )
{
- i_pos = toread[i_stream].i_posf;
- }
- else
- {
- i_pos = __MIN( i_pos, toread[i_stream].i_posf );
+ i_stream = i;
+ i_pos = toread[i].i_posf;
}
}
}
if( b_done )
{
- return( b_stream ? 1 : 0 );
+// return( b_stream ? 1 : 0 );
+ return( 1 );
}
if( i_pos == -1 )
+++ /dev/null
-/*****************************************************************************
- * libioRIFF.c : AVI file Stream input module for vlc
- *****************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: libioRIFF.c,v 1.4 2002/10/26 19:14:45 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 <vlc/vlc.h>
-#include <vlc/input.h>
-
-#include "video.h"
-
-#include "libioRIFF.h"
-static inline u16 __GetWLE( byte_t *p_buff )
-{
- return( (*p_buff) + ( *(p_buff+1) <<8 ) );
-}
-
-static inline u32 __GetDWLE( byte_t *p_buff )
-{
- return( *(p_buff) + ( *(p_buff+1) <<8 ) +
- ( *(p_buff+2) <<16 ) + ( *(p_buff+3) <<24 ) );
-}
-
-static inline u32 __EVEN( u32 i )
-{
- return( (i & 1) ? ++i : i );
-}
-
-int __RIFF_TellPos( input_thread_t *p_input, u32 *pos )
-{
- vlc_mutex_lock( &p_input->stream.stream_lock );
- *pos= p_input->stream.p_selected_area->i_tell;
-// - ( p_input->p_last_data - p_input->p_current_data );
- vlc_mutex_unlock( &p_input->stream.stream_lock );
- return 0;
-}
-
-int __RIFF_SkipBytes(input_thread_t * p_input,int nb)
-{
- data_packet_t *p_pack;
- int i;
- int i_rest;
- if( ( p_input->stream.b_seekable )&&( p_input->stream.i_method == INPUT_METHOD_FILE ) )
- {
- u32 i_pos;
- __RIFF_TellPos( p_input, &i_pos);
- p_input->pf_seek( p_input, (off_t)(i_pos + nb) );
- input_AccessReinit( p_input );
- }
- else
- {
- msg_Warn( p_input, "cannot seek, it will take times" );
- if( nb < 0 ) { return( -1 ); }
- i_rest = nb;
- while (i_rest != 0 )
- {
- if ( i_rest >= 4096 )
- {
- i = input_SplitBuffer( p_input, &p_pack, 4096);
- }
- else
- {
- i = input_SplitBuffer( p_input, &p_pack, i_rest);
- }
-
- if ( i < 0 ) { return ( -1 ); }
- i_rest-=i;
- input_DeletePacket( p_input->p_method_data, p_pack);
- if( ( i == 0 )&&( i_rest != 0 )) { return( -1 ); }
- }
- }
- return ( 0 );
-}
-
-
-void RIFF_DeleteChunk( input_thread_t *p_input, riffchunk_t *p_chunk )
-{
- if( p_chunk != NULL)
- {
- if( p_chunk->p_data != NULL )
- {
- input_DeletePacket( p_input->p_method_data, p_chunk->p_data );
- }
- free( p_chunk );
- }
-}
-
-riffchunk_t * RIFF_ReadChunk(input_thread_t * p_input)
-{
- riffchunk_t * p_riff;
- int count;
- byte_t * p_peek;
-
- if( !(p_riff = malloc( sizeof(riffchunk_t))) )
- {
- return( NULL );
- }
-
- p_riff->p_data = NULL;
- /* peek to have the begining, 8+8 get i_8bytes */
-
- if( ( count = input_Peek( p_input, &p_peek, 16 ) ) < 8 )
- {
- msg_Err( p_input, "cannot peek()" );
- free(p_riff);
- return( NULL );
- }
-
- p_riff->i_id = __GetDWLE( p_peek );
- p_riff->i_size =__GetDWLE( p_peek + 4 );
- p_riff->i_type = ( count >= 12 ) ? __GetDWLE( p_peek + 8 ) : 0 ;
- memset( &p_riff->i_8bytes, 0, 8 );
- if( count >= 12 )
- {
- memcpy( &p_riff->i_8bytes, p_peek + 8, count - 8 );
- }
- __RIFF_TellPos(p_input, &p_riff->i_pos );
-
- return( p_riff );
-}
-
-/**************************************************
- * Va au chunk juste d'apres si il en a encore *
- * -1 si erreur , 1 si y'en a plus *
- **************************************************/
-int RIFF_NextChunk( input_thread_t * p_input,riffchunk_t *p_rifffather)
-{
- int i_len;
- int i_lenfather;
- riffchunk_t *p_riff;
-
- if( ( p_riff = RIFF_ReadChunk( p_input ) ) == NULL )
- {
- msg_Err( p_input, "cannot read chunk" );
- return( -1 );
- }
- i_len = __EVEN( p_riff->i_size );
-
- if ( p_rifffather != NULL )
- {
- i_lenfather = __EVEN( p_rifffather->i_size );
- if ( p_rifffather->i_pos + i_lenfather <= p_riff->i_pos + i_len + 8 )
- {
- msg_Err( p_input, "next chunk out of bounds" );
- free( p_riff );
- return( 1 ); /* pas dans nos frontiere */
- }
- }
- if ( __RIFF_SkipBytes( p_input,i_len + 8 ) != 0 )
- {
- free( p_riff );
- msg_Err( p_input, "cannot go to the next chunk" );
- return( -1 );
- }
- free( p_riff );
- return( 0 );
-}
-
+++ /dev/null
-/*****************************************************************************
- * libioRIFF.h : AVI file Stream input module for vlc
- *****************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: libioRIFF.h,v 1.3 2002/10/15 00:55:07 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.
- *****************************************************************************/
-#define MKFOURCC( a, b, c, d ) \
- ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
-typedef struct riffchunk_s
-{
- vlc_fourcc_t i_id;
- u32 i_size;
- vlc_fourcc_t i_type;
- u32 i_pos;
- data_packet_t *p_data;
- u64 i_8bytes; /* it's the first 8 bytes after header
- used for key frame generation */
-} riffchunk_t;
-
-int __RIFF_TellPos( input_thread_t *p_input, u32 *pos );
-int __RIFF_SkipBytes(input_thread_t * p_input,int nb);
-void RIFF_DeleteChunk( input_thread_t *p_input, riffchunk_t *p_chunk );
-riffchunk_t *RIFF_ReadChunk(input_thread_t * p_input);
-int RIFF_NextChunk( input_thread_t * p_input,riffchunk_t *p_rifffather);
-