- else
- {
- (*pp_pes)->p_last->p_next =
- (*pp_pes)->p_last = p_data;
- (*pp_pes)->i_nb_data++;
- (*pp_pes)->i_pes_size += i_read;
- }
- } while( ((*pp_pes)->i_pes_size < i_size)&&( i_read ) );
-
- if( b_pad )
- {
- (*pp_pes)->i_pes_size--;
- (*pp_pes)->p_last->p_payload_end--;
- i_size--;
- }
-
- return( i_size );
-}
-
-static int __AVI_SeekAndGetChunk( input_thread_t *p_input,
- AVIStreamInfo_t *p_info )
-{
- pes_packet_t *p_pes;
- int i_length, i_ret;
-
- i_length = __MIN( p_info->p_index[p_info->i_idxposc].i_length
- - p_info->i_idxposb,
- BUFFER_MAXSPESSIZE );
-
- AVI_SeekAbsolute( p_input,
- (off_t)p_info->p_index[p_info->i_idxposc].i_pos +
- p_info->i_idxposb + 8);
-
- i_ret = __AVI_GetDataInPES( p_input, &p_pes, i_length , 0);
-
- if( i_ret != i_length )
- {
- return( 0 );
- }
- /* TODO test key frame if i_idxposb == 0*/
- AVI_PESBuffer_Add( p_input->p_method_data,
- p_info,
- p_pes,
- p_info->i_idxposc,
- p_info->i_idxposb );
- return( 1 );
-}
-/* TODO check if it's correct (humm...) and optimisation ... */
-/* return 0 if we choose to get only the ck we want
- * 1 if index is invalid
- * 2 if there is a ck_other before ck_info and the last proced ck_info*/
-/* XXX XXX XXX avi file is some BIG shit, and sometime index give
- * a refenrence to the same chunk BUT with a different size ( usually 0 )
- */
-
-static inline int __AVI_GetChunkMethod( input_thread_t *p_input,
- AVIStreamInfo_t *p_info,
- AVIStreamInfo_t *p_other )
-{
- int i_info_pos;
- int i_other_pos;
-
- int i_info_pos_last;
- int i_other_pos_last;
-
- /*If we don't have a valid entry we need to parse from last
- defined chunk and it's the only way that we return 1*/
- if( p_info->i_idxposc >= p_info->i_idxnb )
- {
- return( 1 );
- }
-
- /* KNOW we have a valid entry for p_info */
- /* we return 0 if we haven't an valid entry for p_other */
- if( ( !p_other )||( p_other->i_idxposc >= p_other->i_idxnb ) )
- {
- return( 0 );
- }
-
- /* KNOW there are 2 streams with valid entry */
-
- /* we return 0 if for one of the two streams we will not read
- chunk-aligned */
- if( ( p_info->i_idxposb )||( p_other->i_idxposb ) )
- {
- return( 0 );
- }
-
- /* KNOW we have a valid entry for the 2 streams
- and for the 2 we want an aligned chunk (given by i_idxposc )*/
- /* if in stream, the next chunk is back than the one we
- have just read, it's useless to parse */
- i_info_pos = p_info->p_index[p_info->i_idxposc].i_pos;
- i_other_pos = p_other->p_index[p_other->i_idxposc].i_pos ;
-
- i_info_pos_last = p_info->i_idxposc ?
- p_info->p_index[p_info->i_idxposc - 1].i_pos : 0;
- i_other_pos_last = p_other->i_idxposc ?
- p_other->p_index[p_other->i_idxposc - 1].i_pos : 0 ;
-
-
- if( ( ( p_info->i_idxposc )&&( i_info_pos <= i_info_pos_last ) ) ||
- ( ( p_other->i_idxposc )&&( i_other_pos <= i_other_pos_last ) ) )
- {
- return( 0 );