Commit 9589dcb7 authored by Christophe Massiot's avatar Christophe Massiot

* Use of ptrdiff_t whenever necessary (IA-64 port) ;

* Changed behaviour of preparsing code, faster startup ;
* Fixed DecodePSM(), cannot test ;
* Cleaned up ParsePES(), fixed a bug which could reject very small but
  valid PES packets ;
* Fixed cosmetic bugs in vpar_synchro frame_rate display.
parent 19324a98
......@@ -3,6 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.19 2000/12/26 19:14:46 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -39,10 +40,23 @@ typedef u8 byte_t;
#ifndef SYS_SOLARIS
typedef int boolean_t;
#else
#include <sys/types.h>
# include <sys/types.h>
#endif
#ifdef SYS_GNU
#define _MACH_I386_BOOLEAN_H_
# define _MACH_I386_BOOLEAN_H_
#endif
/* ptrdiff_t definition */
#ifdef _HAVE_STDDEF_H
# include <stddef.h>
#else
# include <malloc.h>
#endif
#ifndef _PTRDIFF_T
# define _PTRDIFF_T
/* Not portable in a 64-bit environment. */
typedef int ptrdiff_t;
#endif
/* Counter for statistics and profiling */
......@@ -126,7 +140,7 @@ typedef struct video_parser_s * p_video_parser_t;
#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
/* MSB (big endian)/LSB (little endian) convertions - network order is always
/* MSB (big endian)/LSB (little endian) conversions - network order is always
* MSB, and should be used for both network communications and files. Note that
* byte orders other than little and big endians are not supported, but only
* the VAX seems to have such exotic properties - note that these 'functions'
......@@ -151,6 +165,6 @@ typedef struct video_parser_s * p_video_parser_t;
/* XXX??: cause a compilation error */
#endif
/* Macros used by input to access the TS buffer */
/* Macros with automatic casts */
#define U32_AT(p) ( ntohl ( *( (u32 *)(p) ) ) )
#define U16_AT(p) ( ntohs ( *( (u16 *)(p) ) ) )
......@@ -171,8 +171,8 @@
/* Maximum size of a data packet (128 kB) */
#define INPUT_MAX_PACKET_SIZE 131072
/* Maximum length of a pre-parsed chunk (32 MB) */
#define INPUT_PREPARSE_LENGTH 33554432
/* Maximum length of a pre-parsed chunk (4 MB) */
#define INPUT_PREPARSE_LENGTH 4194304
/* Maximum length of a hostname or source name */
#define INPUT_MAX_SOURCE_LENGTH 100
......
......@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-dec.h,v 1.5 2000/12/22 17:53:30 massiot Exp $
* $Id: input_ext-dec.h,v 1.6 2000/12/26 19:14:46 massiot Exp $
*
* Authors:
*
......@@ -400,7 +400,7 @@ static __inline__ void RealignBits( bit_stream_t * p_bit_stream )
static __inline__ void GetChunk( bit_stream_t * p_bit_stream,
byte_t * p_buffer, size_t i_buf_len )
{
int i_available;
ptrdiff_t i_available;
if( (i_available = p_bit_stream->p_end - p_bit_stream->p_byte)
>= i_buf_len )
......
......@@ -69,8 +69,7 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo )
void NextDataPacket( bit_stream_t * p_bit_stream )
{
WORD_TYPE buffer_left;
/* FIXME : not portable in a 64bit environment */
int i_bytes_left;
ptrdiff_t i_bytes_left;
decoder_fifo_t * p_fifo = p_bit_stream->p_decoder_fifo;
/* Buffer used at the end of a decoder thread, to give it zero
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.12 2000/12/22 13:04:45 sam Exp $
* $Id: input_ps.c,v 1.13 2000/12/26 19:14:47 massiot Exp $
*
* Authors:
*
......@@ -30,6 +30,7 @@
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
#include <malloc.h>
#include "config.h"
#include "common.h"
......@@ -38,6 +39,8 @@
#include "intf_msg.h"
#include "main.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
......@@ -106,16 +109,28 @@ static void PSInit( input_thread_t * p_input )
if( p_input->stream.b_seekable )
{
stream_ps_data_t * p_demux_data =
(stream_ps_data_t *)p_input->stream.pp_programs[0]->p_demux_data;
/* Pre-parse the stream to gather stream_descriptor_t. */
p_input->stream.pp_programs[0]->b_is_ok = 0;
/* FIXME: don't read all stream (it can be long !) */
while( !p_input->b_die && !p_input->b_error )
p_demux_data->i_PSM_version = EMPTY_PSM_VERSION;
while( !p_input->b_die && !p_input->b_error
&& !p_demux_data->b_has_PSM )
{
int i_result, i;
data_packet_t * pp_packets[INPUT_READ_ONCE];
i_result = PSRead( p_input, pp_packets );
if( i_result == 1 ) break;
if( i_result == 1 )
{
/* EOF */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.pp_programs[0]->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
break;
}
if( i_result == -1 )
{
p_input->b_error = 1;
......@@ -137,8 +152,66 @@ static void PSInit( input_thread_t * p_input )
}
fseek( p_method->stream, 0, SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.pp_programs[0]->b_is_ok = 1;
p_input->stream.i_tell = 0;
if( p_demux_data->b_has_PSM )
{
/* (The PSM decoder will care about spawning the decoders) */
p_input->stream.pp_programs[0]->b_is_ok = 1;
}
#ifdef AUTO_SPAWN
else
{
/* (We have to do it ourselves) */
int i_es;
/* FIXME: we should do multiple passes in case an audio type
* is not present */
for( i_es = 0;
i_es < p_input->stream.pp_programs[0]->i_es_number;
i_es++ )
{
#define p_es p_input->stream.pp_programs[0]->pp_es[i_es]
switch( p_es->i_type )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
input_SelectES( p_input, p_es );
break;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
if( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 )
== REQUESTED_MPEG
&& main_GetIntVariable( INPUT_DVD_CHANNEL_VAR, 0 )
== (p_es->i_id & 0x1F) )
{
input_SelectES( p_input, p_es );
}
break;
case AC3_AUDIO_ES:
if( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 )
== REQUESTED_AC3
&& main_GetIntVariable( INPUT_DVD_CHANNEL_VAR, 0 )
== ((p_es->i_id & 0xF00) >> 8) )
{
input_SelectES( p_input, p_es );
}
case DVD_SPU_ES:
if( main_GetIntVariable( INPUT_DVD_SUBTITLE_VAR, 0 )
== ((p_es->i_id & 0x1F00) >> 8) )
{
input_SelectES( p_input, p_es );
}
case LPCM_AUDIO_ES:
/* FIXME ! */
}
}
}
#endif
#ifdef STATS
input_DumpStream( p_input );
#endif
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
* and TS system layers
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: mpeg_system.h,v 1.3 2000/12/22 10:58:27 massiot Exp $
* $Id: mpeg_system.h,v 1.4 2000/12/26 19:14:47 massiot Exp $
*
* Authors:
*
......@@ -103,10 +103,14 @@ typedef struct stream_ts_data_s
*****************************************************************************/
typedef struct stream_ps_data_s
{
boolean_t b_has_PSM; /* very rare, in fact */
u8 i_PSM_version;
boolean_t b_is_PSM_complete;
} stream_ps_data_t;
/* PSM version is 5 bits, so -1 is not a valid value */
#define EMPTY_PSM_VERSION -1
/*****************************************************************************
* Prototypes
......
......@@ -2,7 +2,7 @@
* vpar_synchro.h : video parser blocks management
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_synchro.h,v 1.1 2000/12/21 17:19:52 massiot Exp $
* $Id: vpar_synchro.h,v 1.2 2000/12/26 19:14:47 massiot Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -66,7 +66,7 @@ typedef struct video_synchro_s
mtime_t backward_pts, current_pts;
#ifdef STATS
unsigned int i_trashed_pic;
unsigned int i_trashed_pic, i_pic;
#endif
} video_synchro_t;
......
......@@ -2,7 +2,7 @@
* vpar_synchro.c : frame dropping routines
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_synchro.c,v 1.63 2000/12/22 13:04:45 sam Exp $
* $Id: vpar_synchro.c,v 1.64 2000/12/26 19:14:47 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -271,7 +271,7 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
if( S.i_eta_b )
S.i_n_b = S.i_eta_b;
if( S.i_eta_p + 1 > S.i_n_p )
S.i_n_p++;
S.i_n_p = S.i_eta_p + 1;
if( S.backward_pts )
{
......@@ -310,7 +310,7 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
case B_CODING_TYPE:
/* Stream structure changes */
if( S.i_eta_b + 1 > S.i_n_b )
S.i_n_b++;
S.i_n_b = S.i_eta_b + 1;
pts = S.current_pts + period;
......@@ -495,6 +495,8 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
{
case I_CODING_TYPE:
p_vpar->synchro.i_eta_p = p_vpar->synchro.i_eta_b = 0;
if( p_vpar->synchro.i_eta_p )
p_vpar->synchro.i_n_p = p_vpar->synchro.i_eta_p;
#ifdef STATS
if( p_vpar->synchro.i_type == VPAR_SYNCHRO_DEFAULT )
{
......@@ -505,16 +507,19 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
p_vpar->synchro.p_tau[B_CODING_TYPE],
p_vpar->synchro.i_n_b,
p_vpar->p_vout->render_time,
1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) -
p_vpar->synchro.i_pic -
p_vpar->synchro.i_trashed_pic,
1 + p_vpar->synchro.i_n_p * (1 + p_vpar->synchro.i_n_b) );
p_vpar->synchro.i_pic );
p_vpar->synchro.i_trashed_pic = 0;
p_vpar->synchro.i_pic = 0;
}
#endif
break;
case P_CODING_TYPE:
p_vpar->synchro.i_eta_b = 0;
p_vpar->synchro.i_eta_p++;
if( p_vpar->synchro.i_eta_b )
p_vpar->synchro.i_n_b = p_vpar->synchro.i_eta_b;
p_vpar->synchro.i_eta_b = 0;
break;
case B_CODING_TYPE:
p_vpar->synchro.i_eta_b++;
......@@ -537,14 +542,16 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
}
else
{
p_vpar->synchro.current_pts += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
p_vpar->synchro.current_pts += 1000000
/ (p_vpar->sequence.i_frame_rate) * 1001;
}
}
else
{
if( p_vpar->synchro.backward_pts == 0 )
{
p_vpar->synchro.current_pts += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
p_vpar->synchro.current_pts += 1000000
/ (p_vpar->sequence.i_frame_rate) * 1001;
}
else
{
......@@ -564,4 +571,8 @@ static void SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
p_pes->b_has_pts = 0;
}
}
#ifdef STATS
p_vpar->synchro.i_pic++;
#endif
}
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