diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-09 22:05:30 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-09 22:05:30 +0000 |
commit | 31201aff8dbc2c2bb1dadaffb0166f00e9f65b78 (patch) | |
tree | a56aba94f6e405f7df69a9f2efe74385a003a1ae | |
parent | 09898acbad0c3b16ea7d0d14210b986123d491f8 (diff) | |
download | xine-lib-31201aff8dbc2c2bb1dadaffb0166f00e9f65b78.tar.gz xine-lib-31201aff8dbc2c2bb1dadaffb0166f00e9f65b78.tar.bz2 |
introducing present buffers
CVS patchset: 141
CVS date: 2001/06/09 22:05:30
-rw-r--r-- | src/demuxers/demux_mpeg.c | 64 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 35 | ||||
-rw-r--r-- | src/libmpeg2/decode.c | 4 | ||||
-rw-r--r-- | src/libmpeg2/xine_decoder.c | 10 |
4 files changed, 92 insertions, 21 deletions
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 24e6666ef..a933fd2c4 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg.c,v 1.14 2001/05/31 22:54:39 guenter Exp $ + * $Id: demux_mpeg.c,v 1.15 2001/06/09 22:05:30 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -42,6 +42,8 @@ #include "demux.h" #include "utils.h" +#define NUM_PREVIEW_BUFFERS 50 + static uint32_t xine_debug; typedef struct demux_mpeg_s { @@ -58,6 +60,7 @@ typedef struct demux_mpeg_s { unsigned char dummy_space[100000]; int status; + int preview_mode; } demux_mpeg_t ; static uint32_t read_bytes (demux_mpeg_t *this, int n) { @@ -157,6 +160,11 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { buf->type = BUF_AUDIO_AC3 + track; buf->PTS = pts; buf->DTS = 0 ; /* FIXME */ + if (this->preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; + buf->input_pos = this->input->get_current_pos (this->input); if(this->audio_fifo) @@ -202,6 +210,10 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { buf->type = BUF_AUDIO_MPEG + track; buf->PTS = pts; buf->DTS = 0; /* FIXME */ + if (this->preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; buf->input_pos = this->input->get_current_pos(this->input); if(this->audio_fifo) @@ -248,6 +260,10 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { buf->type = BUF_VIDEO_MPEG; buf->PTS = pts; buf->DTS = 0; + if (this->preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; buf->input_pos = this->input->get_current_pos(this->input); this->video_fifo->put (this->video_fifo, buf); @@ -362,6 +378,10 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID) buf->type = BUF_AUDIO_MPEG + track ; buf->PTS = pts; buf->DTS = 0; /* FIXME */ + if (this->preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; buf->input_pos = this->input->get_current_pos(this->input); if(this->audio_fifo) @@ -381,6 +401,10 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID) buf->type = BUF_VIDEO_MPEG; buf->PTS = pts; buf->DTS = 0; /* FIXME */ + if (this->preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; buf->input_pos = this->input->get_current_pos(this->input); this->video_fifo->put (this->video_fifo, buf); @@ -478,6 +502,8 @@ static void *demux_mpeg_loop (void *this_gen) { buf_element_t *buf; uint32_t w; + this->status = DEMUX_OK; + do { w = parse_pack (this); @@ -532,14 +558,6 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; - this->status = DEMUX_OK; - - if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) { - xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos); - this->input->seek (this->input, pos+4, SEEK_SET); - } else - read_bytes(this, 4); - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); @@ -550,6 +568,34 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, this->audio_fifo->put (this->audio_fifo, buf); } + if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) { + + uint32_t w; + int num_buffers = NUM_PREVIEW_BUFFERS; + + this->preview_mode = 1; + + this->input->seek (this->input, 0, SEEK_SET); + + this->status = DEMUX_OK ; + + do { + w = parse_pack (this); + + if (w != 0x000001ba) + demux_mpeg_resync (this, w); + + num_buffers --; + + } while ( (this->status == DEMUX_OK) && (num_buffers>0)) ; + + xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos); + this->input->seek (this->input, pos+4, SEEK_SET); + } else + read_bytes(this, 4); + + this->preview_mode = 0; + pthread_create (&this->thread, NULL, demux_mpeg_loop, this) ; } diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index ce1215038..b823e671b 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg_block.c,v 1.12 2001/06/03 20:16:33 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.13 2001/06/09 22:05:30 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -38,6 +38,8 @@ #include "demux.h" #include "utils.h" +#define NUM_PREVIEW_BUFFERS 50 + static uint32_t xine_debug; typedef struct demux_mpeg_block_s { @@ -57,7 +59,7 @@ typedef struct demux_mpeg_block_s { } demux_mpeg_block_t ; -static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { +static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_mode) { buf_element_t *buf = NULL; unsigned char *p; @@ -77,6 +79,10 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { } p = buf->content; /* len = this->mnBlocksize; */ + if (preview_mode) + buf->decoder_info[0] = 0; + else + buf->decoder_info[0] = 1; if (p[3] == 0xBA) { /* program stream pack header */ @@ -329,7 +335,7 @@ static void *demux_mpeg_block_loop (void *this_gen) { do { - demux_mpeg_block_parse_pack(this); + demux_mpeg_block_parse_pack(this, 0); } while (this->status == DEMUX_OK) ; @@ -388,11 +394,6 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, pos /= (off_t) this->blocksize; pos *= (off_t) this->blocksize; - if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { - xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos); - this->input->seek (this->input, pos, SEEK_SET); - } - /* * send start buffer */ @@ -406,6 +407,24 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, buf->type = BUF_CONTROL_START; this->audio_fifo->put (this->audio_fifo, buf); } + + if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { + + int num_buffers = NUM_PREVIEW_BUFFERS; + + this->input->seek (this->input, 0, SEEK_SET); + + this->status = DEMUX_OK ; + while ( (num_buffers>0) && (this->status == DEMUX_OK) ) { + + demux_mpeg_block_parse_pack(this, 1); + num_buffers --; + } + + xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos); + this->input->seek (this->input, pos, SEEK_SET); + } + /* * now start demuxing */ diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c index ed15bbddf..66594fd86 100644 --- a/src/libmpeg2/decode.c +++ b/src/libmpeg2/decode.c @@ -339,11 +339,13 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec, if (code == 0xb3) { /* sequence_header_code */ if (header_process_sequence_header (picture, mpeg2dec->chunk_buffer)) { - fprintf (stderr, "bad sequence header\n"); + printf ("libmpeg2: bad sequence header\n"); return; } if (mpeg2dec->is_sequence_needed) { + printf ("libmpeg2: found sequence header! :-)\n"); + mpeg2dec->is_sequence_needed = 0; picture->forward_reference_frame = mpeg2dec->output->get_frame (mpeg2dec->output, diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c index ce4788d85..6783f7d20 100644 --- a/src/libmpeg2/xine_decoder.c +++ b/src/libmpeg2/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.6 2001/06/07 20:23:54 guenter Exp $ + * $Id: xine_decoder.c,v 1.7 2001/06/09 22:05:31 guenter Exp $ * * stuff needed to turn libmpeg2 into a xine decoder plugin */ @@ -55,8 +55,12 @@ static void mpeg2dec_init (video_decoder_t *this_gen, vo_instance_t *video_out) static void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen; - mpeg2_decode_data (&this->mpeg2, buf->content, buf->content + buf->size, - buf->PTS); + if (buf->decoder_info[0] == 0) { + mpeg2_find_sequence_header (&this->mpeg2, buf->content, buf->content + buf->size); + } else { + mpeg2_decode_data (&this->mpeg2, buf->content, buf->content + buf->size, + buf->PTS); + } } static void mpeg2dec_close (video_decoder_t *this_gen) { |