Commit 551607d3 authored by Jean-Marc Dressler's avatar Jean-Marc Dressler

Portage du client sous BeOS. Il manque encore l'audio mais �a marche.

En cadeau bonux un nouvel input_file qui permet de lire les vob. Il
faur rajouter la ligne suivante dans vlc.init:
spawn-input method=10 filename=braindead
parent 9a726693
......@@ -29,7 +29,7 @@ default:
$(dependancies): .dep/%.d: %.c
@test -d .dep/$(dir $*) || mkdir -p .dep/$(dir $*)
@echo "generating dependancies for $*.c"
@$(SHELL) -ec '$(CC) $(DCFLAGS) $(CFLAGS) $< \
@$(SHELL) -ec '$(CC) $(DCFLAGS) $(CFLAGS) $(DEFINE) $< \
| sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
.dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
# Generated automatically from Makefile.in by configure.
# Generated automatically from Makefile.in by configure.
################################################################################
# vlc (VideoLAN Client) main makefile
# (c)1998 VideoLAN
......@@ -19,7 +20,7 @@ AOUT += dsp
AOUT += dummy
# Video output settings
VOUT += x11
#VOUT += x11
#VOUT += fb
#VOUT += ggi
#VOUT += glide
......@@ -68,8 +69,8 @@ DEBUG=0
#----------------- do not change anything below this line ----------------------
prefix=@prefix@
INSTALL=@INSTALL@
prefix=/usr/local
INSTALL=/bin/install -c
################################################################################
# Configuration pre-processing
......@@ -127,11 +128,11 @@ ifeq ($(SYS),LINUX)
LIB += -lpthread -ldl
endif
ifeq ($SYS),BEOS)
LIB += -llibroot -llibgame -llibbe
endif
ifeq ($(SYS),BEOS)
LIB += -lbe -lroot -lgame
else
LIB += -lm
endif
#
# C compiler flags: compilation
......@@ -141,6 +142,9 @@ CCFLAGS += -Wall
CCFLAGS += -D_REENTRANT
CCFLAGS += -D_GNU_SOURCE
# flags needed for clean beos compilation
CCFLAGS += -Wno-multichar -Wno-ctor-dtor-privacy -Woverloaded-virtual
# Optimizations : don't compile debug versions with them
CCFLAGS += -O6
CCFLAGS += -ffast-math -funroll-loops -fargument-noalias-global
......@@ -192,7 +196,7 @@ LCFLAGS += -Wall
# Debugging support
ifeq ($(DEBUG),1)
CFLAGS += -g
#CFLAGS += -pg
CFLAGS += -pg
endif
#################################################################################
......@@ -276,6 +280,7 @@ misc_obj = misc/mtime.o \
misc/plugins.o \
misc/decoder_fifo.o
C_OBJ = $(interface_obj) \
$(input_obj) \
$(audio_output_obj) \
......@@ -289,6 +294,10 @@ C_OBJ = $(interface_obj) \
$(vlan_obj) \
$(misc_obj)
ifeq ($(SYS), BEOS)
CPP_OBJ = misc/beos_specific.o
endif
#
# Assembler Objects
#
......@@ -317,9 +326,10 @@ PLUGIN_OBJ = $(intf_plugin) $(aout_plugin) $(vout_plugin)
# Other lists of files
#
C_OBJ := $(C_OBJ:%.o=src/%.o)
CPP_OBJ := $(CPP_OBJ:%.o=src/%.o)
ASM_OBJ := $(ASM_OBJ:%.o=src/%.o)
sources := $(C_OBJ:%.o=%.c) $(PLUGIN_OBJ:%.so=%.c)
dependancies := $(sources:%.c=.dep/%.d)
sources_c := $(C_OBJ:%.o=%.c)
dependancies := $(sources_c:%.c=.dep/%.d)
# All symbols must be exported
export
......@@ -331,10 +341,10 @@ export
#
# Virtual targets
#
all: vlc
all: vlc plugins
clean:
rm -f $(C_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
rm -f $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
distclean: clean
rm -f **/*.o **/*.so **/*~ *.log
......@@ -376,8 +386,15 @@ FORCE:
#
# Real targets
#
vlc: $(C_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
$(CC) $(CCFLAGS) $(LCFLAGS) $(CFLAGS) --export-dynamic -rdynamic -o $@ $(C_OBJ) $(ASM_OBJ)
vlc: $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
ifeq ($(SYS), BEOS)
$(CC) $(CCFLAGS) $(LCFLAGS) $(CFLAGS) -Xlinker -soname=_APP_ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
# ln -s ../vlc ./plugins/_APP_
else
$(CC) $(CCFLAGS) $(LCFLAGS) $(CFLAGS) --export-dynamic -rdynamic -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
endif
plugins: $(PLUGIN_OBJ)
#
# Generic rules (see below)
......@@ -391,19 +408,23 @@ $(C_OBJ): %.o: %.c
@echo "compiling $*.o from $*.c"
@$(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
$(CPP_OBJ): %.o: %.cpp
@echo "compiling $*.o from $*.cpp"
@$(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
$(ASM_OBJ): %.o: Makefile.dep
$(ASM_OBJ): %.o: %.S
@echo "assembling $*.o from $*.S"
@$(CC) $(CFLAGS) -c -o $@ $<
$(PLUGIN_OBJ): %.so: Makefile.dep
$(PLUGIN_OBJ): %.so: .dep/%.d
#$(PLUGIN_OBJ): %.so: Makefile.dep
#$(PLUGIN_OBJ): %.so: .dep/%.d
# audio plugins
plugins/aout/aout_dummy.so plugins/aout/aout_dsp.so: %.so: %.c
@echo "compiling $*.so from $*.c"
ifeq ($(SYS), BEOS)
@$(CC) $(CCFLAGS) $(CFLAGS) -nostart -o $@ $<
@$(CC) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $< plugins/_APP_
else
@$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $<
endif
......@@ -421,7 +442,7 @@ plugins/intf/intf_dummy.so plugins/vout/vout_dummy.so \
plugins/intf/intf_fb.so plugins/vout/vout_fb.so: %.so: %.c
@echo "compiling $*.so from $*.c"
ifeq ($(SYS), BEOS)
@$(CC) $(CCFLAGS) $(CFLAGS) -nostart -o $@ $<
@$(CC) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $< plugins/_APP_
else
@$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $<
endif
......@@ -446,6 +467,14 @@ plugins/intf/intf_ggi.so plugins/vout/vout_ggi.so: %.so: %.c
@echo "compiling $*.so from $*.c"
@$(CC) $(CCFLAGS) $(CFLAGS) -lggi -shared -o $@ $<
plugins/intf/intf_beos.so: %.so: %.cpp
@echo "compiling $*.so from $*.cpp"
@$(CC) $(LCFLAGS) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $< plugins/_APP_
plugins/vout/vout_beos.so: %.so: %.cpp
@echo "compiling $*.so from $*.cpp"
@$(CC) $(LCFLAGS) $(CCFLAGS) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $< plugins/_APP_
################################################################################
# Note on generic rules and dependancies
......
/*****************************************************************************
* beos_init.h: Initialization for BeOS specific features
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Jean-Marc Dressler
*
* 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-1307, USA.
*****************************************************************************/
/*****************************************************************************
* Prototypes
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
void beos_Init( void );
void beos_Clean( void );
char * beos_GetProgramPath( void );
#ifdef __cplusplus
}
#endif
\ No newline at end of file
/*****************************************************************************
* beos_window.h: beos window class prototype
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Jean-Marc Dressler
*
* 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-1307, USA.
*****************************************************************************/
class VideoWindow : public BDirectWindow
{
public:
// standard constructor and destructor
VideoWindow(BRect frame, const char *name, vout_thread_t *p_video_output);
~VideoWindow();
// standard window member
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
// this is the hook controling direct screen connection
virtual void DirectConnected(direct_buffer_info *info);
int32 i_bytes_per_pixel;
int32 i_screen_depth;
vout_thread_t *p_vout;
uint8 *fBits;
int32 fRowBytes;
color_space fFormat;
clipping_rect fBounds;
uint32 fNumClipRects;
clipping_rect *fClipList;
bool fDirty;
bool fReady;
bool fConnected;
bool fConnectionDisabled;
BLocker *locker;
thread_id fDrawThreadID;
};
class InterfaceWindow : public BWindow
{
public:
InterfaceWindow( BRect frame, const char *name, intf_thread_t *p_intf );
~InterfaceWindow();
// standard window member
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
intf_thread_t *p_interface;
};
class InterfaceView : public BView
{
public:
InterfaceView();
~InterfaceView();
virtual void MessageReceived(BMessage *message);
};
\ No newline at end of file
......@@ -103,12 +103,14 @@ typedef struct video_parser_s * p_video_parser_t;
#define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
/* MAX and MIN: self explanatory */
//#ifndef SYS_BEOS
#ifndef MAX
#define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
#endif
#ifndef MIN
#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
//#endif
/* MSB (big endian)/LSB (little endian) convertions - network order is always
* MSB, and should be used for both network communications and files. Note that
......
......@@ -23,6 +23,8 @@
* Boston, MA 02111-1307, USA.
*****************************************************************************/
#include <stdio.h>
#if defined(HAVE_PTHREAD_H) /* pthreads (Linux & BSD for example) */
#include <pthread.h>
......@@ -30,9 +32,10 @@
#include <cthreads.h>
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H) /* BeOS */
#undef MAX
#undef MIN
#include <kernel/OS.h>
#include <kernel/scheduler.h>
#else
#error no threads available on your system !
#endif
......@@ -228,12 +231,11 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
return 0;
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
/*
// check the arguments and whether it's already been initialized
if( !p_mutex )
return B_BAD_VALUE;
if( p_mutex->init == 9999 )
return EALREADY;
if( !p_mutex ) return B_BAD_VALUE;
if( p_mutex->init == 9999 ) return EALREADY;
*/
p_mutex->lock = create_sem( 1, "BeMutex" );
p_mutex->owner = -1;
......@@ -257,18 +259,16 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
status_t err;
if( !p_mutex )
return B_BAD_VALUE;
if( p_mutex->init < 2000 )
return B_NO_INIT;
/*
if( !p_mutex ) return B_BAD_VALUE;
if( p_mutex->init < 2000 ) return B_NO_INIT;
lazy_init_mutex( p_mutex );
*/
err = acquire_sem( p_mutex->lock );
if( !err )
p_mutex->owner = find_thread( NULL );
/*
if( !err ) p_mutex->owner = find_thread( NULL );
*/
return err;
......@@ -288,11 +288,9 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
return 0;
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
if(! p_mutex)
return B_BAD_VALUE;
if( p_mutex->init < 2000 )
return B_NO_INIT;
/*
if(! p_mutex) return B_BAD_VALUE;
if( p_mutex->init < 2000 ) return B_NO_INIT;
lazy_init_mutex( p_mutex );
......@@ -300,6 +298,7 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
return ENOLCK;
p_mutex->owner = -1;
*/
release_sem( p_mutex->lock );
return B_OK;
......
......@@ -95,7 +95,6 @@ aout_thread_t *aout_CreateThread( int *pi_status )
/* Request an interface plugin */
psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
if( RequestPlugin( &p_aout->aout_plugin, "aout", psz_method ) )
{
intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method );
......
......@@ -26,24 +26,940 @@
*****************************************************************************/
#include "defs.h"
#include <stdio.h>
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "input.h" */
#include <sys/stat.h> /* fstat, off_t ... */
#include <byteorder.h> /* ntohl ... */
#include <malloc.h> /* malloc, read ... */
#include <string.h>
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "intf_msg.h"
#include "input.h"
#include "input_file.h"
#define BUF_SIZE (797*3)
#define PS_METHOD 1
#define TS_METHOD 2
#define TS_PACKET_SIZE 188
#define TS_IN_UDP 7
#define PS_BUFFER_SIZE 16384
#define NO_PES 0
#define AUDIO_PES 1
#define VIDEO_PES 2
#define AC3_PES 3
#define SUBTITLE_PES 4
#define PRIVATE_PES 5
#define UNKNOWN_PES 12
#define PCR_PID 0x20 /* 0x20 == first video stream
* 0x40 == first audio stream */
typedef u8 file_ts_packet[TS_PACKET_SIZE];
typedef file_ts_packet udp_packet[TS_IN_UDP];
typedef struct synchro_struct
{
mtime_t delta_clock;
mtime_t slope;
mtime_t last_pcr_time;
file_ts_packet *last_pcr;
} synchro_t;
typedef struct in_data_s
{
int start, end;
vlc_mutex_t lock;
vlc_cond_t notfull;
vlc_cond_t notempty;
udp_packet buf[BUF_SIZE+1];
} in_data_t;
typedef struct own_pcr_s
{
int start, end;
vlc_mutex_t lock;
file_ts_packet *buf[(BUF_SIZE+1)*TS_IN_UDP+1];
} own_pcr_t;
typedef struct options_s
{
unsigned int pcr_pid;
u8 i_file_type;
int in;
} options_t;
typedef struct s_ps
{
unsigned int pat_counter;
unsigned int pmt_counter;
/*
* 16 audio mpeg streams
* 16 audio AV3 streams
* 16 video mpeg streams
* 32 subtitle streams
*/
unsigned int media_counter[0x100];
unsigned int association_table[0x100];
unsigned int found_streams;
unsigned int found_pts;
unsigned int ts_to_write;
unsigned int ts_written;
unsigned int sent_ts;
unsigned char *ps_data;
unsigned char *ps_end;
unsigned char *ps_buffer;
unsigned int pes_id;
unsigned int private_id;
unsigned int has_pts;
unsigned int pcr_pid;
unsigned int pes_type;
unsigned int pes_size;
unsigned int to_skip;
unsigned int offset;
} ps_t;
typedef struct input_file_s
{
boolean_t b_die; /* b_die flag for the disk thread */
vlc_thread_t disk_thread;
synchro_t synchro;
ps_t ps;
in_data_t in_data;
options_t options;
own_pcr_t own_pcr;
} input_file_t;
/* local prototypes */
void ps_fill( input_file_t * p_if, boolean_t wait );
ssize_t safe_read(int fd, unsigned char *buf, int count);
void input_DiskThread( input_file_t * p_if );
int init_synchro( input_file_t * p_if );
input_file_t input_file;
/******************************************************************************
* ConvertPCRTime : extracts and converts the PCR time in microseconds
******************************************************************************/
s64 ConvertPCRTime(file_ts_packet *pcr_buff)
{
return( (((((s64)U32_AT(((u8*)pcr_buff)+6)) << 1) | (((u8*)pcr_buff)[10] >> 7)) * 300) / 27 );
}
/******************************************************************************
* wait_a_moment : Compute how long we must wait before sending a TS packet
******************************************************************************/
static void wait_a_moment( input_file_t * p_if, file_ts_packet *ts)
{
synchro_t * p_synchro = &input_file.synchro;
static int retard_count = 0;
static s64 wait_max = 0;
s64 sendtime; /* the date at which the TS packet should be sent */
s64 wait;
sendtime = p_synchro->last_pcr_time + p_synchro->delta_clock +
p_synchro->slope * ((ts - p_synchro->last_pcr + (BUF_SIZE+1)*TS_IN_UDP) % ((BUF_SIZE+1)*TS_IN_UDP));
wait = sendtime - mdate();
//fprintf(stderr,"last PCR Time : %Ld\n", p_synchro->last_pcr_time );
if( wait > 0 )
{
retard_count = 0;
if(wait > 100000)
{
fprintf( stderr, "Warning : wait time may be too long : %Ld\n", wait );
return;
}
msleep( wait );
}
else
{
if( wait < wait_max )
{
wait_max = wait;
}
retard_count++;
if( retard_count == 16 )
{
retard_count = 0;
//fprintf( stderr, "delay : %Ldms, max delay : %Ldms\n", -wait/1000, -wait_max/1000 );
fflush(stdout);
}
}
}
/******************************************************************************
* adjust : Adjust the encoder clock & remove the PCR from own_pcr
******************************************************************************/
static void adjust( input_file_t * p_if, file_ts_packet *ts )
{
synchro_t * p_synchro = &p_if->synchro;
own_pcr_t * p_own_pcr = &p_if->own_pcr;
file_ts_packet *next_pcr;
int no_discontinuity = 1;
if( ((u8*)ts)[5] & 0x80 )
{
/* There is a discontinuity - I recalculate the delta */
p_synchro->delta_clock = mdate() - ConvertPCRTime(ts);
intf_DbgMsg( "input warning: clock discontinuity\n" );
no_discontinuity = 0;
}
else
{
p_synchro->last_pcr = ts;
p_synchro->last_pcr_time = ConvertPCRTime( ts );
}
vlc_mutex_lock(&p_own_pcr->lock);
p_own_pcr->start++;
p_own_pcr->start %= (BUF_SIZE+1)*TS_IN_UDP+1;
/* If we have 2 consecutiv PCR, we can reevaluate slope */
if( (p_own_pcr->start != p_own_pcr->end) &&
no_discontinuity &&
!((((u8*) next_pcr = p_own_pcr->buf[p_own_pcr->start]))[5] & 0x80))
{
s64 current_pcr_time = ConvertPCRTime(ts);
s64 next_pcr_time = ConvertPCRTime(next_pcr);
if( (next_pcr_time - current_pcr_time < 0) || (next_pcr_time - current_pcr_time > 700000))
{
fprintf( stderr, "Warning: possible discontinuity\n" );
p_synchro->delta_clock = mdate() - next_pcr_time;
}
else
{
//fprintf(stderr,"next - current : %Ld\n", next_pcr_time - current_pcr_time);
p_synchro->slope = (next_pcr_time - current_pcr_time) /
((next_pcr - ts + (BUF_SIZE+1)*TS_IN_UDP) % ((BUF_SIZE+1)*TS_IN_UDP));
//fprintf(stderr,"slope : %Ld\n", p_synchro->slope);
}
}
vlc_mutex_unlock(&p_own_pcr->lock);
}
/******************************************************************************
* safe_read : Buffered reading method
******************************************************************************/
ssize_t safe_read(int fd, unsigned char *buf, int count)
{
int ret, cnt=0;
while(cnt < count)
{
ret = read(fd, buf+cnt, count-cnt);
if(ret < 0)
return ret;
if(ret == 0)
break;
cnt += ret;
}
return cnt;
}
/******************************************************************************
* keep_pcr : Put a TS packet in the fifo if it owns a PCR
******************************************************************************/
int keep_pcr(int pcr_pid, file_ts_packet *ts)
{
own_pcr_t * p_own_pcr = &input_file.own_pcr;
#define p ((u8 *)ts)
if ((p[3] & 0x20) && p[4] && (p[5] & 0x10)
&& ((((p[1]<<8)+p[2]) & 0x1FFF) == pcr_pid))
{
/* adaptation_field_control is set, adaptation_field_lenght is not 0,
* PCR_flag is set, pid == pcr_pid */
vlc_mutex_lock(&p_own_pcr->lock);
p_own_pcr->buf[p_own_pcr->end++] = ts;
p_own_pcr->end %= (BUF_SIZE+1)*TS_IN_UDP+1;
vlc_mutex_unlock(&p_own_pcr->lock);
return 1;
}
else
return 0;
#undef p
}
/******************************************************************************
* get_pid : gets a pid from a PES type
******************************************************************************/
int get_pid (ps_t *p_ps)
{
int i, tofind, delta;
switch( p_ps->pes_type )
{
case VIDEO_PES:
delta = 0x20;
tofind = p_ps->pes_id;
break;
case AUDIO_PES:
delta = 0x40;
tofind = p_ps->pes_id;
break;
case SUBTITLE_PES:
delta = 0x60;
tofind = p_ps->private_id;
break;
case AC3_PES:
delta = 0x80;
tofind = p_ps->private_id;
break;
default:
return(-1);
}
/* look in the table if we can find one */
for ( i=delta; i < delta + 0x20; i++ )
{
if ( p_ps->association_table[i] == tofind )
return (i);
if( !p_ps->association_table[i] )
break;
}
/* we must allocate a new entry */
if (i == delta + 0x20)
return(-1);
p_ps->association_table[i] = tofind;
p_ps->media_counter[i] = 0;
fprintf( stderr, "allocated new PID 0x%.2x to stream ID 0x%.2x\n", i, tofind );
return ( i );
}
/******************************************************************************
* write_media_ts : writes a ts packet from a ps stream
******************************************************************************/
void write_media_ts(ps_t *ps, unsigned char *ts, unsigned int pid)
{
int i,j;
s64 clock;
long int extclock;
/* if offset == 0, it means we haven't examined the PS yet */
if (ps->offset == 0)
{
if (ps->pes_size < 184) {
//fprintf(stderr,"[WARNING: small PES]\n");
ts[0] = 0x47; /* sync_byte */
ts[1] = 0x40; /* payload_unit_