[MPlayer-dev-eng] [PATCH] Clean up demuxers
Daniel Egger
degger at fhm.edu
Thu Feb 21 12:07:38 CET 2002
Hija,
in the sincere hope to get the demuxer system off the radar
in profiles I rewrote the code in demuxer.c to not use
a dispatching system based on select but to create a table
which is used as jumping carpet.
Two things I had to do though: Convert all *_fill_* routines
to take exactly the same two parameters [demuxer_t *demux] and
[demux_stream_t* ds]. Since some of the demuxers derive ds from
demux and the other way round I wondered if this couldn't generally
be made as it saves a lot of overhead.
I also had to fix the return type to unsigned int and the declarations
to be extern because it annoyed me to death.
I'm still thinking about what to do with the tv demux special case which
takes an if clause because the parameters are by no means equalized.
Now to the good parts: By applying this simple and straight-forward
patch I was already able to get a small improvement in both
final code size and execution speed on Linux PPC with gcc-3.0.4 and
think that this patch is a good base for a lot bigger improvement
as soon as I understand that freshly added demux_demuxers and the
rest of the system.
On the other hand by using a table one can simply have several different
hooks doing the same job in different ways and drive comparisons between
them; heck if someone wants a mmx based demuxer it'd be really simple
to activate it at runtime.
Please consider this patch and give me some hints about the parameter
situation so I can optimize the shit out of mplayer.
--
Servus,
Daniel
-------------- next part --------------
Index: libmpdemux/demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_asf.c,v
retrieving revision 1.20
diff -u -r1.20 demux_asf.c
--- libmpdemux/demux_asf.c 16 Jan 2002 14:54:56 -0000 1.20
+++ libmpdemux/demux_asf.c 21 Feb 2002 10:52:54 -0000
@@ -138,8 +138,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_asf_fill_buffer(demuxer_t *demux){
-
+unsigned int demux_asf_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
+{
demux->filepos=stream_tell(demux->stream);
// Brodcast stream have movi_start==movi_end
// Better test ?
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.6
diff -u -r1.6 demux_audio.c
--- libmpdemux/demux_audio.c 20 Feb 2002 16:55:11 -0000 1.6
+++ libmpdemux/demux_audio.c 21 Feb 2002 10:53:01 -0000
@@ -185,7 +185,8 @@
}
-int demux_audio_fill_buffer(demux_stream_t *ds) {
+unsigned int demux_audio_fill_buffer(demuxer_t *dummy, demux_stream_t *ds)
+{
sh_audio_t* sh_audio;
demuxer_t* demux;
da_priv_t* priv;
Index: libmpdemux/demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.38
diff -u -r1.38 demux_avi.c
--- libmpdemux/demux_avi.c 12 Feb 2002 08:27:49 -0000 1.38
+++ libmpdemux/demux_avi.c 21 Feb 2002 10:53:09 -0000
@@ -154,7 +154,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer(demuxer_t *demux){
+unsigned int demux_avi_fill_buffer(demuxer_t *demux,demux_stream_t *ds)
+{
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -254,7 +255,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t* ds){
+unsigned int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds)
+{
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
@@ -333,7 +335,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t* ds){
+unsigned int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds)
+{
avi_priv_t *priv=demux->priv;
unsigned int id=0;
unsigned int len;
Index: libmpdemux/demux_demuxers.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_demuxers.c,v
retrieving revision 1.1
diff -u -r1.1 demux_demuxers.c
--- libmpdemux/demux_demuxers.c 20 Feb 2002 16:59:25 -0000 1.1
+++ libmpdemux/demux_demuxers.c 21 Feb 2002 10:53:09 -0000
@@ -38,7 +38,7 @@
return ret;
}
-int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds) {
+unsigned int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds) {
dd_priv_t* priv;
priv=demux->priv;
Index: libmpdemux/demux_film.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_film.c,v
retrieving revision 1.4
diff -u -r1.4 demux_film.c
--- libmpdemux/demux_film.c 10 Feb 2002 01:23:36 -0000 1.4
+++ libmpdemux/demux_film.c 21 Feb 2002 10:53:12 -0000
@@ -72,14 +72,14 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_film_fill_buffer(demuxer_t *demuxer)
+unsigned int demux_film_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
{
int i;
unsigned char byte_swap;
int cvid_size;
- sh_video_t *sh_video = demuxer->video->sh;
- sh_audio_t *sh_audio = demuxer->audio->sh;
- film_data_t *film_data = (film_data_t *)demuxer->priv;
+ sh_video_t *sh_video = demux->video->sh;
+ sh_audio_t *sh_audio = demux->audio->sh;
+ film_data_t *film_data = (film_data_t *)demux->priv;
film_chunk_t film_chunk;
// see if the end has been reached
@@ -89,7 +89,7 @@
film_chunk = film_data->chunks[film_data->current_chunk];
// position stream and fetch chunk
- stream_seek(demuxer->stream, film_chunk.chunk_offset);
+ stream_seek(demux->stream, film_chunk.chunk_offset);
// load the chunks manually (instead of using ds_read_packet()), since
// they require some adjustment
@@ -97,7 +97,7 @@
if (film_chunk.flags1 == 0xFFFFFFFF)
{
demux_packet_t* dp=new_demux_packet(film_chunk.chunk_size);
- stream_read(demuxer->stream, dp->buffer, film_chunk.chunk_size);
+ stream_read(demux->stream, dp->buffer, film_chunk.chunk_size);
dp->pts = 0;
dp->pos = film_chunk.chunk_offset;
dp->flags = 0;
@@ -117,7 +117,7 @@
}
// append packet to DS stream
- ds_add_packet(demuxer->audio, dp);
+ ds_add_packet(demux->audio, dp);
film_data->current_chunk++;
}
else
@@ -130,7 +130,7 @@
dp->pts = 0;
dp->pos = 0;
dp->flags = 0;
- ds_add_packet(demuxer->video, dp);
+ ds_add_packet(demux->video, dp);
}
// if the demuxer is dealing with CVID data, deal with it a special way
else if (sh_video->format == mmioFOURCC('c', 'v', 'i', 'd'))
@@ -139,9 +139,9 @@
demux_packet_t* dp=new_demux_packet(film_chunk.chunk_size - 2);
// these CVID data chunks appear to have 2 extra bytes; skip them
- stream_read(demuxer->stream, dp->buffer, 10);
- stream_skip(demuxer->stream, 2);
- stream_read(demuxer->stream, dp->buffer + 10, film_chunk.chunk_size - 12);
+ stream_read(demux->stream, dp->buffer, 10);
+ stream_skip(demux->stream, 2);
+ stream_read(demux->stream, dp->buffer + 10, film_chunk.chunk_size - 12);
dp->pts = film_chunk.video_chunk_number / sh_video->fps;
dp->pos = film_chunk.chunk_offset;
dp->flags = (film_chunk.flags1 & 0x80000000) ? 1 : 0;
@@ -154,12 +154,12 @@
dp->buffer[3] = (cvid_size >> 0) & 0xFF;
// append packet to DS stream
- ds_add_packet(demuxer->video, dp);
+ ds_add_packet(demux->video, dp);
film_data->current_chunk++;
}
else
{
- ds_read_packet(demuxer->video, demuxer->stream, film_chunk.chunk_size,
+ ds_read_packet(demux->video, demux->stream, film_chunk.chunk_size,
film_chunk.video_chunk_number / sh_video->fps, /* pts */
film_chunk.chunk_offset, (film_chunk.flags1 & 0x80000000) ? 1 : 0);
film_data->current_chunk++;
Index: libmpdemux/demux_fli.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_fli.c,v
retrieving revision 1.7
diff -u -r1.7 demux_fli.c
--- libmpdemux/demux_fli.c 17 Dec 2001 00:24:03 -0000 1.7
+++ libmpdemux/demux_fli.c 21 Feb 2002 10:53:12 -0000
@@ -41,9 +41,9 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_fli_fill_buffer(demuxer_t *demuxer){
- fli_frames_t *frames = (fli_frames_t *)demuxer->priv;
- sh_video_t *sh_video = demuxer->video->sh;
+unsigned int demux_fli_fill_buffer(demuxer_t *demux,demux_stream_t* ds){
+ fli_frames_t *frames = (fli_frames_t *)demux->priv;
+ sh_video_t *sh_video = demux->video->sh;
// see if the end has been reached
if (frames->current_frame >= frames->num_frames)
@@ -52,9 +52,9 @@
// fetch the frame from the file
// first, position the file properly since ds_read_packet() doesn't
// seem to do it, even though it takes a file offset as a parameter
- stream_seek(demuxer->stream, frames->filepos[frames->current_frame]);
- ds_read_packet(demuxer->video,
- demuxer->stream,
+ stream_seek(demux->stream, frames->filepos[frames->current_frame]);
+ ds_read_packet(demux->video,
+ demux->stream,
frames->frame_size[frames->current_frame],
frames->current_frame/sh_video->fps,
frames->filepos[frames->current_frame],
Index: libmpdemux/demux_mf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mf.c,v
retrieving revision 1.5
diff -u -r1.5 demux_mf.c
--- libmpdemux/demux_mf.c 11 Feb 2002 09:15:32 -0000 1.5
+++ libmpdemux/demux_mf.c 21 Feb 2002 10:53:12 -0000
@@ -36,29 +36,29 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_mf_fill_buffer(demuxer_t *demuxer){
+unsigned int demux_mf_fill_buffer(demuxer_t *demux,demux_stream_t* ds){
mf_t * mf;
demuxer_mf_t * dmf;
struct stat fs;
FILE * f;
- dmf=(demuxer_mf_t*)demuxer->priv;
+ dmf=(demuxer_mf_t*)demux->priv;
if ( dmf->curr_frame >= dmf->nr_of_frames ) return 0;
- mf=(mf_t*)demuxer->stream->priv;
+ mf=(mf_t*)demux->stream->priv;
stat( mf->names[dmf->curr_frame],&fs );
// printf( "[demux_mf] frame: %d (%s,%d)\n",dmf->curr_frame,mf->names[dmf->curr_frame],fs.st_size );
if ( !( f=fopen( mf->names[dmf->curr_frame],"r" ) ) ) return 0;
{
- sh_video_t * sh_video = demuxer->video->sh;
+ sh_video_t * sh_video = demux->video->sh;
demux_packet_t * dp = new_demux_packet( fs.st_size );
if ( !fread( dp->buffer,fs.st_size,1,f ) ) return 0;
dp->pts=dmf->curr_frame / sh_video->fps;
dp->pos=dmf->curr_frame;
dp->flags=0;
// append packet to DS stream:
- ds_add_packet( demuxer->video,dp );
+ ds_add_packet( demux->video,dp );
}
fclose( f );
Index: libmpdemux/demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.37
diff -u -r1.37 demux_mov.c
--- libmpdemux/demux_mov.c 10 Feb 2002 19:06:08 -0000 1.37
+++ libmpdemux/demux_mov.c 21 Feb 2002 10:53:14 -0000
@@ -938,8 +938,9 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_mov_fill_buffer(demuxer_t *demuxer,demux_stream_t* ds){
- mov_priv_t* priv=demuxer->priv;
+unsigned int demux_mov_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
+{
+ mov_priv_t* priv=demux->priv;
mov_track_t* trak=NULL;
float pts;
@@ -950,7 +951,7 @@
// read chunk:
int x;
if(trak->pos>=trak->chunks_size) return 0; // EOF
- stream_seek(demuxer->stream,trak->chunks[trak->pos].pos);
+ stream_seek(demux->stream,trak->chunks[trak->pos].pos);
pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale;
if(trak->samplesize!=1)
{
@@ -978,14 +979,14 @@
}
}
} /* MOV_TRAK_AUDIO */
- ds_read_packet(ds,demuxer->stream,x,pts,trak->chunks[trak->pos].pos,0);
- if(ds==demuxer->audio) mp_msg(MSGT_DEMUX, MSGL_DBG2, "sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts);
+ ds_read_packet(ds,demux->stream,x,pts,trak->chunks[trak->pos].pos,0);
+ if(ds==demux->audio) mp_msg(MSGT_DEMUX, MSGL_DBG2, "sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts);
} else {
// read sample:
if(trak->pos>=trak->samples_size) return 0; // EOF
- stream_seek(demuxer->stream,trak->samples[trak->pos].pos);
+ stream_seek(demux->stream,trak->samples[trak->pos].pos);
pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale;
- ds_read_packet(ds,demuxer->stream,trak->samples[trak->pos].size,pts,trak->samples[trak->pos].pos,0);
+ ds_read_packet(ds,demux->stream,trak->samples[trak->pos].size,pts,trak->samples[trak->pos].pos,0);
}
++trak->pos;
Index: libmpdemux/demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.40
diff -u -r1.40 demux_mpg.c
--- libmpdemux/demux_mpg.c 14 Feb 2002 23:41:34 -0000 1.40
+++ libmpdemux/demux_mpg.c 21 Feb 2002 10:53:18 -0000
@@ -241,7 +241,7 @@
int num_elementary_packetsPES=0;
int num_mp3audio_packets=0;
-int demux_mpg_es_fill_buffer(demuxer_t *demux){
+unsigned int demux_mpg_es_fill_buffer(demuxer_t *demux,demux_stream_t* ds){
// Elementary video stream
if(demux->stream->eof) return 0;
demux->filepos=stream_tell(demux->stream);
@@ -249,7 +249,8 @@
return 1;
}
-int demux_mpg_fill_buffer(demuxer_t *demux){
+unsigned int demux_mpg_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
+{
unsigned int head=0;
int skipped=0;
int max_packs=128;
Index: libmpdemux/demux_nuv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_nuv.c,v
retrieving revision 1.5
diff -u -r1.5 demux_nuv.c
--- libmpdemux/demux_nuv.c 9 Jan 2002 17:09:21 -0000 1.5
+++ libmpdemux/demux_nuv.c 21 Feb 2002 10:53:19 -0000
@@ -135,14 +135,14 @@
}
-int demux_nuv_fill_buffer ( demuxer_t *demuxer )
+unsigned int demux_nuv_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
{
struct rtframeheader rtjpeg_frameheader;
int orig_pos;
- nuv_priv_t* priv = demuxer->priv;
+ nuv_priv_t* priv = demux->priv;
- orig_pos = stream_tell ( demuxer->stream );
- if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
+ orig_pos = stream_tell ( demux->stream );
+ if (stream_read ( demux->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
return 0; /* EOF */
#if 0
@@ -172,19 +172,19 @@
priv->current_position->next = NULL;
}
/* put RTjpeg tables, Video info to video buffer */
- stream_seek ( demuxer->stream, orig_pos );
- ds_read_packet ( demuxer->video, demuxer->stream, rtjpeg_frameheader.packetlength + 12,
+ stream_seek ( demux->stream, orig_pos );
+ ds_read_packet ( demux->video, demux->stream, rtjpeg_frameheader.packetlength + 12,
rtjpeg_frameheader.timecode / 1000, orig_pos, 0 );
} else
/* copy PCM only */
- if (demuxer->audio && (rtjpeg_frameheader.frametype == 'A') &&
+ if (demux->audio && (rtjpeg_frameheader.frametype == 'A') &&
(rtjpeg_frameheader.comptype == '0'))
{
priv->current_audio_frame++;
/* put Audio to audio buffer */
- ds_read_packet ( demuxer->audio, demuxer->stream, rtjpeg_frameheader.packetlength,
+ ds_read_packet ( demux->audio, demux->stream, rtjpeg_frameheader.packetlength,
rtjpeg_frameheader.timecode / 1000, orig_pos + 12, 0 );
}
Index: libmpdemux/demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.8
diff -u -r1.8 demux_real.c
--- libmpdemux/demux_real.c 23 Jan 2002 19:41:01 -0000 1.8
+++ libmpdemux/demux_real.c 21 Feb 2002 10:53:21 -0000
@@ -193,7 +193,7 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_real_fill_buffer(demuxer_t *demuxer)
+unsigned int demux_real_fill_buffer(demuxer_t *demuxer, demux_stream_t* dummy)
{
real_priv_t *priv = demuxer->priv;
demux_stream_t *ds = NULL;
Index: libmpdemux/demux_roq.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_roq.c,v
retrieving revision 1.4
diff -u -r1.4 demux_roq.c
--- libmpdemux/demux_roq.c 18 Feb 2002 16:50:16 -0000 1.4
+++ libmpdemux/demux_roq.c 21 Feb 2002 10:53:21 -0000
@@ -63,10 +63,10 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_roq_fill_buffer(demuxer_t *demuxer)
+unsigned int demux_roq_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
{
- sh_video_t *sh_video = demuxer->video->sh;
- roq_data_t *roq_data = (roq_data_t *)demuxer->priv;
+ sh_video_t *sh_video = demux->video->sh;
+ roq_data_t *roq_data = (roq_data_t *)demux->priv;
roq_chunk_t roq_chunk;
if (roq_data->current_chunk >= roq_data->total_chunks)
@@ -75,14 +75,14 @@
roq_chunk = roq_data->chunks[roq_data->current_chunk];
// make sure we're at the right place in the stream and fetch the chunk
- stream_seek(demuxer->stream, roq_chunk.chunk_offset);
+ stream_seek(demux->stream, roq_chunk.chunk_offset);
if (roq_chunk.chunk_type == CHUNK_TYPE_AUDIO)
- ds_read_packet(demuxer->audio, demuxer->stream, roq_chunk.chunk_size,
+ ds_read_packet(demux->audio, demux->stream, roq_chunk.chunk_size,
roq_chunk.running_audio_sample_count / 22050,
roq_chunk.chunk_offset, 0);
else
- ds_read_packet(demuxer->video, demuxer->stream, roq_chunk.chunk_size,
+ ds_read_packet(demux->video, demux->stream, roq_chunk.chunk_size,
roq_chunk.video_chunk_number / sh_video->fps,
roq_chunk.chunk_offset, 0);
Index: libmpdemux/demux_viv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_viv.c,v
retrieving revision 1.21
diff -u -r1.21 demux_viv.c
--- libmpdemux/demux_viv.c 29 Jan 2002 12:11:52 -0000 1.21
+++ libmpdemux/demux_viv.c 21 Feb 2002 10:53:22 -0000
@@ -292,7 +292,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_vivo_fill_buffer(demuxer_t *demux){
+unsigned int demux_vivo_fill_buffer(demuxer_t *demux,demux_stream_t* ds)
+{
demux_stream_t *ds=NULL;
int c;
int len=0;
Index: libmpdemux/demux_y4m.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_y4m.c,v
retrieving revision 1.5
diff -u -r1.5 demux_y4m.c
--- libmpdemux/demux_y4m.c 28 Dec 2001 22:58:00 -0000 1.5
+++ libmpdemux/demux_y4m.c 21 Feb 2002 10:53:22 -0000
@@ -60,7 +60,8 @@
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
-int demux_y4m_fill_buffer(demuxer_t *demux) {
+unsigned int demux_y4m_fill_buffer(demuxer_t *demux, demux_stream_t* dummy)
+{
demux_stream_t *ds=demux->video;
demux_packet_t *dp;
y4m_priv_t *priv=demux->priv;
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.78
diff -u -r1.78 demuxer.c
--- libmpdemux/demuxer.c 20 Feb 2002 16:59:25 -0000 1.78
+++ libmpdemux/demuxer.c 21 Feb 2002 10:53:27 -0000
@@ -166,67 +166,31 @@
ds_add_packet(ds,dp);
}
-// return value:
-// 0 = EOF or no stream found or invalid type
-// 1 = successfully read a packet
-int demux_mf_fill_buffer( demuxer_t *demux);
-int demux_roq_fill_buffer(demuxer_t *demux);
-int demux_film_fill_buffer(demuxer_t *demux);
-int demux_fli_fill_buffer(demuxer_t *demux);
-int demux_mpg_es_fill_buffer(demuxer_t *demux);
-int demux_mpg_fill_buffer(demuxer_t *demux);
-int demux_avi_fill_buffer(demuxer_t *demux);
-int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds);
-int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds);
-int demux_asf_fill_buffer(demuxer_t *demux);
-int demux_mov_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
-int demux_vivo_fill_buffer(demuxer_t *demux);
-int demux_real_fill_buffer(demuxer_t *demuxer);
-int demux_nuv_fill_buffer(demuxer_t *demux);
#ifdef USE_TV
#include "tv.h"
extern tvi_handle_t *tv_handler;
extern int tv_param_on;
extern int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh);
-extern int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
+extern unsigned int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh);
#endif
-int demux_y4m_fill_buffer(demuxer_t *demux);
-int demux_audio_fill_buffer(demux_stream_t *ds);
-extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
-int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
- // Note: parameter 'ds' can be NULL!
-// printf("demux->type=%d\n",demux->type);
- switch(demux->type){
- case DEMUXER_TYPE_MF: return demux_mf_fill_buffer(demux);
- case DEMUXER_TYPE_ROQ: return demux_roq_fill_buffer(demux);
- case DEMUXER_TYPE_FILM: return demux_film_fill_buffer(demux);
- case DEMUXER_TYPE_FLI: return demux_fli_fill_buffer(demux);
- case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
- case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
- case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
- case DEMUXER_TYPE_AVI_NI: return demux_avi_fill_buffer_ni(demux,ds);
- case DEMUXER_TYPE_AVI_NINI: return demux_avi_fill_buffer_nini(demux,ds);
- case DEMUXER_TYPE_ASF: return demux_asf_fill_buffer(demux);
- case DEMUXER_TYPE_MOV: return demux_mov_fill_buffer(demux,ds);
- case DEMUXER_TYPE_VIVO: return demux_vivo_fill_buffer(demux);
- case DEMUXER_TYPE_REAL: return demux_real_fill_buffer(demux);
- case DEMUXER_TYPE_NUV: return demux_nuv_fill_buffer(demux);
+inline
+unsigned int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
#ifdef USE_TV
- case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, tv_handler);
+ if (demux->type == DEMUXER_TYPE_TV)
+ return demux_tv_fill_buffer(demux, tv_handler);
#endif
- case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
- case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
- case DEMUXER_TYPE_DEMUXERS: return demux_demuxers_fill_buffer(demux,ds);
- }
+ // Note: parameter 'ds' can be NULL!
+// printf("demux->type=%d\n",demux->type);
+ return demuxer[demux->type] (demux, ds);
return 0;
}
// return value:
// 0 = EOF
// 1 = succesfull
-int ds_fill_buffer(demux_stream_t *ds){
+unsigned int ds_fill_buffer(demux_stream_t *ds){
demuxer_t *demux=ds->demuxer;
if(ds->buffer) free(ds->buffer);
if(verbose>2){
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.31
diff -u -r1.31 demuxer.h
--- libmpdemux/demuxer.h 20 Feb 2002 16:59:25 -0000 1.31
+++ libmpdemux/demuxer.h 21 Feb 2002 10:53:28 -0000
@@ -1,35 +1,41 @@
-#define MAX_PACKS 4096
+#define MAX_PACKS 4096
#define MAX_PACK_BYTES 0x800000
-#define DEMUXER_TYPE_UNKNOWN 0
-#define DEMUXER_TYPE_MPEG_ES 1
-#define DEMUXER_TYPE_MPEG_PS 2
-#define DEMUXER_TYPE_AVI 3
-#define DEMUXER_TYPE_AVI_NI 4
-#define DEMUXER_TYPE_AVI_NINI 5
-#define DEMUXER_TYPE_ASF 6
-#define DEMUXER_TYPE_MOV 7
-#define DEMUXER_TYPE_VIVO 8
-#define DEMUXER_TYPE_TV 9
-#define DEMUXER_TYPE_FLI 10
-#define DEMUXER_TYPE_REAL 11
-#define DEMUXER_TYPE_Y4M 12
-#define DEMUXER_TYPE_NUV 13
-#define DEMUXER_TYPE_FILM 14
-#define DEMUXER_TYPE_ROQ 15
-#define DEMUXER_TYPE_MF 16
-#define DEMUXER_TYPE_AUDIO 17
+typedef enum
+{
+ DEMUXER_TYPE_UNKNOWN = 0,
+ DEMUXER_TYPE_MPEG_ES = 1,
+ DEMUXER_TYPE_MPEG_PS = 2,
+ DEMUXER_TYPE_AVI = 3,
+ DEMUXER_TYPE_AVI_NI = 4,
+ DEMUXER_TYPE_AVI_NINI = 5,
+ DEMUXER_TYPE_ASF = 6,
+ DEMUXER_TYPE_MOV = 7,
+ DEMUXER_TYPE_VIVO = 8,
+ DEMUXER_TYPE_FLI = 9,
+ DEMUXER_TYPE_REAL = 10,
+ DEMUXER_TYPE_Y4M = 11,
+ DEMUXER_TYPE_NUV = 12,
+ DEMUXER_TYPE_FILM = 13,
+ DEMUXER_TYPE_ROQ = 14,
+ DEMUXER_TYPE_MF = 15,
+ DEMUXER_TYPE_AUDIO = 16,
+ DEMUXER_TYPE_DEMUXERS = 17,
// This should always match the higest demuxer type number.
// Unless you want to disallow users to force the demuxer to some types
-#define DEMUXER_TYPE_MAX 17
-
-#define DEMUXER_TYPE_DEMUXERS (1<<16)
+ DEMUXER_TYPE_MAX = 18,
+
+ DEMUXER_TYPE_TV = 1000,
+} DemuxType;
-#define DEMUXER_TIME_NONE 0
-#define DEMUXER_TIME_PTS 1
-#define DEMUXER_TIME_FILE 2
-#define DEMUXER_TIME_BPS 3
+enum
+{
+ DEMUXER_TIME_NONE = 0,
+ DEMUXER_TIME_PTS = 1,
+ DEMUXER_TIME_FILE = 2,
+ DEMUXER_TIME_BPS = 3
+};
// Holds one packet/frame/whatever
@@ -84,7 +90,7 @@
stream_t *stream;
int synced; // stream synced (used by mpeg)
off_t filepos; // input stream current pos.
- int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
+ DemuxType type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
int file_format; // file format: mpeg/avi/asf
off_t movi_start;
off_t movi_end;
@@ -127,8 +133,7 @@
void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp);
void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags);
-int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
-int ds_fill_buffer(demux_stream_t *ds);
+unsigned int ds_fill_buffer(demux_stream_t *ds);
inline static off_t ds_tell(demux_stream_t *ds){
return (ds->dpos-ds->buffer_size)+ds->buffer_pos;
@@ -187,3 +192,53 @@
int demux_info_add(demuxer_t *demuxer, char *opt, char *param);
char* demux_info_get(demuxer_t *demuxer, char *opt);
int demux_info_print(demuxer_t *demuxer);
+
+// return value:
+// 0 = EOF or no stream found or invalid type
+// 1 = successfully read a packet
+static inline unsigned int demux_null (demuxer_t *demux,demux_stream_t* ds)
+{
+ return 0;
+}
+
+extern unsigned int demux_mf_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_roq_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_film_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_fli_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_mpg_es_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_mpg_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_avi_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds);
+extern unsigned int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds);
+extern unsigned int demux_asf_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_mov_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_vivo_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_real_fill_buffer(demuxer_t *demuxer, demux_stream_t* ds);
+extern unsigned int demux_nuv_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
+extern unsigned int demux_y4m_fill_buffer(demuxer_t *demux, demux_stream_t* ds);
+extern unsigned int demux_audio_fill_buffer(demuxer_t *demux, demux_stream_t *ds);
+extern unsigned int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
+
+typedef unsigned int (* demuxer_func) (demuxer_t *demux,demux_stream_t* ds);
+
+static demuxer_func demuxer[] =
+{
+ demux_null,
+ demux_mpg_es_fill_buffer,
+ demux_mpg_fill_buffer,
+ demux_avi_fill_buffer,
+ demux_avi_fill_buffer_ni,
+ demux_avi_fill_buffer_nini,
+ demux_asf_fill_buffer,
+ demux_mov_fill_buffer,
+ demux_vivo_fill_buffer,
+ demux_fli_fill_buffer,
+ demux_real_fill_buffer,
+ demux_y4m_fill_buffer,
+ demux_nuv_fill_buffer,
+ demux_film_fill_buffer,
+ demux_roq_fill_buffer,
+ demux_mf_fill_buffer,
+ demux_audio_fill_buffer,
+ demux_demuxers_fill_buffer
+};
Index: libmpdemux/mf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/mf.h,v
retrieving revision 1.1
diff -u -r1.1 mf.h
--- libmpdemux/mf.h 6 Feb 2002 19:23:49 -0000 1.1
+++ libmpdemux/mf.h 21 Feb 2002 10:53:28 -0000
@@ -14,4 +14,5 @@
char ** names;
} mf_t;
-#endif
\ No newline at end of file
+#endif
+
More information about the MPlayer-dev-eng
mailing list