diff options
Diffstat (limited to 'src/demuxers/demux_mpeg_pes.c')
-rw-r--r-- | src/demuxers/demux_mpeg_pes.c | 124 |
1 files changed, 43 insertions, 81 deletions
diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 51706a7fe..d1753d907 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.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_pes.c,v 1.17 2003/11/16 23:33:43 f1rmb Exp $ + * $Id: demux_mpeg_pes.c,v 1.18 2003/11/26 19:43:30 f1rmb Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -38,14 +38,16 @@ #include <unistd.h> #include <string.h> -#include "xine_internal.h" -#include "xineutils.h" -#include "demux.h" - +#define LOG_MODULE "demux_mpeg_pes" +#define LOG_VERBOSE /* #define LOG */ +#include "xine_internal.h" +#include "xineutils.h" +#include "demux.h" + #define NUM_PREVIEW_BUFFERS 250 #define DISC_TRESHOLD 90000 @@ -140,9 +142,8 @@ static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video ) /* check if pts is outside nav pts range. any stream without nav must enter here. */ if( pts > this->nav_last_end_pts || pts < this->nav_last_start_pts ) { -#ifdef LOG - printf("demux_mpeg_pes: discontinuity detected by pts wrap\n"); -#endif + lprintf("discontinuity detected by pts wrap\n"); + if (this->buf_flag_seek) { _x_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK); this->buf_flag_seek = 0; @@ -151,9 +152,7 @@ static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video ) } this->send_newpts = 0; } else { -#ifdef LOG - printf("demux_mpeg_pes: no wrap detected\n" ); -#endif + lprintf("no wrap detected\n" ); } this->last_pts[1-video] = 0; @@ -236,9 +235,8 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) #endif this->packet_len = p[4] << 8 | p[5]; -#ifdef LOG - printf("demux_pes: stream_id=0x%x, packet_len=%d\n",this->stream_id, this->packet_len); -#endif + lprintf("stream_id=0x%x, packet_len=%d\n",this->stream_id, this->packet_len); + if (this->packet_len <= (buf->max_size - 6)) { i = this->input->read (this->input, buf->mem+6, (off_t) this->packet_len); if (i != this->packet_len) { @@ -248,9 +246,8 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) } buf->size = this->packet_len + 6; } else { -#ifdef LOG - printf("Jumbo PES packet length=%d, stream_id=0x%x\n",this->packet_len, this->stream_id); -#endif + lprintf("Jumbo PES packet length=%d, stream_id=0x%x\n",this->packet_len, this->stream_id); + i = this->input->read (this->input, buf->mem+6, (off_t) (buf->max_size - 6)); if (i != ( buf->max_size - 6)) { buf->free_buffer (buf); @@ -461,9 +458,7 @@ static int32_t parse_program_stream_pack_header(demux_mpeg_pes_t *this, uint8_t this->scr += ( (p[8] & 0x03 << 7) | (p[9] & 0xFE >> 1) ); */ -#ifdef LOG - printf ("demux_mpeg_pes: SCR=%lld\n", this->scr); -#endif + lprintf ("SCR=%lld\n", this->scr); /* mux_rate */ @@ -540,16 +535,13 @@ static int32_t parse_private_stream_2(demux_mpeg_pes_t *this, uint8_t *p, buf_el this->last_begin_time = buf->extra_info->input_time; } -#ifdef LOG - printf ("demux_mpeg_pes: NAV packet, start pts = %lld, end_pts = %lld\n", + lprintf ("NAV packet, start pts = %lld, end_pts = %lld\n", start_pts, end_pts); -#endif if (this->nav_last_end_pts != start_pts && !this->preview_mode) { -#ifdef LOG - printf("demux_mpeg_pes: discontinuity detected by nav packet\n" ); -#endif + lprintf("discontinuity detected by nav packet\n" ); + if (this->buf_flag_seek) { _x_demux_control_newpts(this->stream, start_pts, BUF_FLAG_SEEK); this->buf_flag_seek = 0; @@ -689,9 +681,7 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element this->pts |= (int64_t) p[12] << 7 ; this->pts |= (int64_t) (p[13] & 0xFE) >> 1 ; -#ifdef LOG - printf ("demux_mpeg_pes: pts = %lld\n", this->pts); -#endif + lprintf ("pts = %lld\n", this->pts); } else this->pts = 0; @@ -740,9 +730,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el buf->pts = this->pts; this->video_fifo->put (this->video_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: SPU PACK put on fifo\n"); -#endif + lprintf ("SPU PACK put on fifo\n"); return this->packet_len + result; } @@ -760,9 +748,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el check_newpts( this, this->pts, PTS_VIDEO ); */ this->video_fifo->put (this->video_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: SPU SVCD PACK (%lld, %d) put on fifo\n", this->pts, spu_id); -#endif + lprintf ("SPU SVCD PACK (%lld, %d) put on fifo\n", this->pts, spu_id); return this->packet_len + result; } @@ -780,9 +766,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el check_newpts( this, this->pts, PTS_VIDEO ); */ this->video_fifo->put (this->video_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: SPU CVD PACK (%lld, %d) put on fifo\n", this->pts, spu_id); -#endif + lprintf ("SPU CVD PACK (%lld, %d) put on fifo\n", this->pts, spu_id); return this->packet_len + result; } @@ -806,9 +790,8 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: A52 PACK put on fifo\n"); -#endif + lprintf ("A52 PACK put on fifo\n"); + } else { buf->free_buffer(buf); } @@ -872,9 +855,8 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: LPCM PACK put on fifo\n"); -#endif + lprintf ("LPCM PACK put on fifo\n"); + } else { buf->free_buffer(buf); } @@ -903,9 +885,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: A52 PACK put on fifo\n"); -#endif + lprintf ("A52 PACK put on fifo\n"); } else { buf->free_buffer(buf); } @@ -969,11 +949,7 @@ static int32_t parse_video_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen todo_length -= chunk_length; } - - -#ifdef LOG - printf ("demux_mpeg_pes: MPEG Video PACK put on fifo\n"); -#endif + lprintf ("MPEG Video PACK put on fifo\n"); return this->packet_len + result; } @@ -999,9 +975,7 @@ static int32_t parse_audio_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); -#ifdef LOG - printf ("demux_mpeg_pes: MPEG Audio PACK put on fifo\n"); -#endif + lprintf ("MPEG Audio PACK put on fifo\n"); } else { buf->free_buffer(buf); } @@ -1173,9 +1147,7 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { } } -#ifdef LOG - printf("demux_mpeg_pes:est_rate=%d\n",rate); -#endif + lprintf("est_rate=%d\n",rate); return rate; } @@ -1305,17 +1277,13 @@ static void demux_mpeg_pes_accept_input (demux_mpeg_pes_t *this, strncpy (this->cur_mrl, input->get_mrl(input), 256); -#ifdef LOG - printf ("demux_mpeg_pes: mrl %s is new\n", - this->cur_mrl); -#endif + lprintf ("mrl %s is new\n", this->cur_mrl); - } else -#ifdef LOG - printf ("demux_mpeg_pes: mrl %s is known, bitrate: %d\n", - this->cur_mrl, this->rate * 50 * 8) -#endif - ; + } + else { + lprintf ("mrl %s is known, bitrate: %d\n", + this->cur_mrl, this->rate * 50 * 8); + } } static int demux_mpeg_pes_get_stream_length (demux_plugin_t *this_gen) { @@ -1367,10 +1335,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str /* We need to system header in order to identify is the stream is mpeg1 or mpeg2. */ this->wait_for_program_stream_pack_header=1; -#ifdef LOG - printf ("demux_mpeg_pes:open_plugin:detection_method=%d\n", - stream->content_detection_method); -#endif + lprintf ("open_plugin:detection_method=%d\n", + stream->content_detection_method); switch (stream->content_detection_method) { @@ -1387,15 +1353,12 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str input->seek(input, 0, SEEK_SET); if (input->read(input, this->scratch, 6)) { -#ifdef LOG - printf("demux_mpeg_pes:open_plugin:read worked\n"); -#endif + lprintf("open_plugin:read worked\n"); if (this->scratch[0] || this->scratch[1] || (this->scratch[2] != 0x01) ) { -#ifdef LOG - printf("demux_mpeg_pes:open_plugin:scratch failed\n"); -#endif + lprintf("open_plugin:scratch failed\n"); + free (this->scratch_base); free (this); return NULL; @@ -1416,9 +1379,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str input->seek(input, 0, SEEK_SET); demux_mpeg_pes_accept_input (this, input); -#ifdef LOG - printf("demux_mpeg_pes:open_plugin:Accepting detection_method XINE_DEMUX_CONTENT_STRATEGY \n"); -#endif + lprintf("open_plugin:Accepting detection_method XINE_DEMUX_CONTENT_STRATEGY \n"); + break; } } |