From 6e5df7fe3e8eb27e159898a0eefb1ca1f384e9c2 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Mon, 17 Oct 2011 15:19:03 +0300 Subject: Fixed warnings --- src/demuxers/asfheader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index 1482ac982..7a1397d73 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -234,7 +234,7 @@ static int asf_header_get_stream_id(asf_header_t *header_pub, uint16_t stream_nu static int asf_header_parse_file_properties(asf_header_t *header, uint8_t *buffer, int buffer_len) { asf_reader_t reader; asf_file_t *asf_file; - uint32_t flags; + uint32_t flags = 0; if (buffer_len < 80) { lprintf("invalid asf file properties object\n"); @@ -287,7 +287,7 @@ static int asf_header_parse_file_properties(asf_header_t *header, uint8_t *buffe static int asf_header_parse_stream_properties(asf_header_t *header, uint8_t *buffer, int buffer_len) { asf_reader_t reader; - uint16_t flags; + uint16_t flags = 0; uint32_t junk; GUID guid; asf_stream_t *asf_stream = NULL; @@ -357,7 +357,7 @@ exit_error: static int asf_header_parse_stream_extended_properties(asf_header_t *header, uint8_t *buffer, int buffer_len) { asf_reader_t reader; - uint32_t flags; + uint32_t flags = 0; uint16_t stream_number; int i; int stream_id; -- cgit v1.2.3 From a9e9f6fab09d5cee4d8561feea3f06ec6f4d2e45 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 09:35:21 +0300 Subject: Fixed incorrect aliasing --- src/demuxers/demux_idcin.c | 22 ++++++++++++++-------- src/demuxers/demux_vmd.c | 22 +++++++++++----------- src/demuxers/demux_vqa.c | 27 +++++++++++++-------------- 3 files changed, 38 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_idcin.c b/src/demuxers/demux_idcin.c index 46d4c284b..7fbc89ca5 100644 --- a/src/demuxers/demux_idcin.c +++ b/src/demuxers/demux_idcin.c @@ -105,7 +105,8 @@ typedef struct { int status; off_t filesize; - unsigned char bih[sizeof(xine_bmiheader) + HUFFMAN_TABLE_SIZE]; + xine_bmiheader bih; + unsigned char huffman_table[HUFFMAN_TABLE_SIZE]; xine_waveformatex wave; int audio_chunk_size1; @@ -273,8 +274,7 @@ static int demux_idcin_send_chunk(demux_plugin_t *this_gen) { /* returns 1 if the CIN file was opened successfully, 0 otherwise */ static int open_idcin_file(demux_idcin_t *this) { unsigned char header[IDCIN_HEADER_SIZE]; - xine_bmiheader *bih = (xine_bmiheader *)this->bih; - unsigned char *huffman_table = this->bih + sizeof(xine_bmiheader); + xine_bmiheader *bih = &this->bih; if (_x_demux_read_header(this->input, header, IDCIN_HEADER_SIZE) != IDCIN_HEADER_SIZE) return 0; @@ -328,7 +328,7 @@ static int open_idcin_file(demux_idcin_t *this) { this->input->seek(this->input, IDCIN_HEADER_SIZE, SEEK_SET); /* read the Huffman table */ - if (this->input->read(this->input, huffman_table, HUFFMAN_TABLE_SIZE) != + if (this->input->read(this->input, this->huffman_table, HUFFMAN_TABLE_SIZE) != HUFFMAN_TABLE_SIZE) return 0; @@ -356,7 +356,6 @@ static int open_idcin_file(demux_idcin_t *this) { static void demux_idcin_send_headers(demux_plugin_t *this_gen) { demux_idcin_t *this = (demux_idcin_t *) this_gen; buf_element_t *buf; - xine_bmiheader *bih = (xine_bmiheader *)this->bih; uint32_t i, size; this->video_fifo = this->stream->video_fifo; @@ -368,8 +367,8 @@ static void demux_idcin_send_headers(demux_plugin_t *this_gen) { _x_demux_control_start(this->stream); /* send init info to decoders */ - bih->biSize = sizeof(xine_bmiheader) + HUFFMAN_TABLE_SIZE; - size = bih->biSize; + this->bih.biSize = sizeof(xine_bmiheader) + HUFFMAN_TABLE_SIZE; + size = this->bih.biSize; i = 0; do { @@ -384,7 +383,14 @@ static void demux_idcin_send_headers(demux_plugin_t *this_gen) { buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER| BUF_FLAG_FRAMERATE|BUF_FLAG_FRAME_END; } - memcpy(buf->content, this->bih + i, buf->size); + + if (i == 0) { + memcpy(buf->content, &this->bih, sizeof(xine_bmiheader)); + memcpy(buf->content + sizeof(xine_bmiheader), this->huffman_table, buf->size - sizeof(xine_bmiheader)); + } else { + memcpy(buf->content, this->huffman_table + i - sizeof(xine_bmiheader), buf->size); + } + buf->type = BUF_VIDEO_IDCIN; this->video_fifo->put (this->video_fifo, buf); diff --git a/src/demuxers/demux_vmd.c b/src/demuxers/demux_vmd.c index 6aec12580..b3d7c95b8 100644 --- a/src/demuxers/demux_vmd.c +++ b/src/demuxers/demux_vmd.c @@ -76,7 +76,8 @@ typedef struct { off_t data_start; off_t data_size; - unsigned char bih[sizeof(xine_bmiheader) + VMD_HEADER_SIZE]; + xine_bmiheader bih; + unsigned char vmd_header[VMD_HEADER_SIZE]; xine_waveformatex wave; unsigned int audio_frames; @@ -89,7 +90,7 @@ typedef struct { int64_t video_pts_inc; int64_t total_pts; -} demux_vmd_t ; +} demux_vmd_t; typedef struct { demux_class_t demux_class; @@ -98,8 +99,7 @@ typedef struct { /* returns 1 if the VMD file was opened successfully, 0 otherwise */ static int open_vmd_file(demux_vmd_t *this) { - xine_bmiheader *bih = (xine_bmiheader *)this->bih; - unsigned char *vmd_header = this->bih + sizeof(xine_bmiheader); + unsigned char *vmd_header = this->vmd_header; off_t toc_offset; unsigned char *raw_frame_table; unsigned int raw_frame_table_size; @@ -122,9 +122,9 @@ static int open_vmd_file(demux_vmd_t *this) { if ( !(this->data_size = this->input->get_length(this->input)) ) this->data_size = 1; - bih->biSize = sizeof(xine_bmiheader) + VMD_HEADER_SIZE; - bih->biWidth = _X_LE_16(&vmd_header[12]); - bih->biHeight = _X_LE_16(&vmd_header[14]); + this->bih.biSize = sizeof(xine_bmiheader) + VMD_HEADER_SIZE; + this->bih.biWidth = _X_LE_16(&vmd_header[12]); + this->bih.biHeight = _X_LE_16(&vmd_header[14]); this->wave.nSamplesPerSec = _X_LE_16(&vmd_header[804]); this->wave.nChannels = (vmd_header[811] & 0x80) ? 2 : 1; this->wave.nBlockAlign = _X_LE_16(&vmd_header[806]); @@ -323,7 +323,6 @@ static int demux_vmd_send_chunk(demux_plugin_t *this_gen) { static void demux_vmd_send_headers(demux_plugin_t *this_gen) { demux_vmd_t *this = (demux_vmd_t *) this_gen; buf_element_t *buf; - xine_bmiheader *bih = (xine_bmiheader *)this->bih; this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; @@ -335,9 +334,9 @@ static void demux_vmd_send_headers(demux_plugin_t *this_gen) { _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, (this->wave.nSamplesPerSec) ? 1 : 0); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, - bih->biWidth); + this->bih.biWidth); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, - bih->biHeight); + this->bih.biHeight); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, this->wave.nChannels); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, @@ -353,7 +352,8 @@ static void demux_vmd_send_headers(demux_plugin_t *this_gen) { buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; buf->decoder_info[0] = this->video_pts_inc; /* initial duration */ - memcpy(buf->content, this->bih, sizeof(xine_bmiheader) + VMD_HEADER_SIZE); + memcpy(buf->content, &this->bih, sizeof(xine_bmiheader)); + memcpy(buf->content + sizeof(xine_bmiheader), this->vmd_header, VMD_HEADER_SIZE); buf->size = sizeof(xine_bmiheader) + VMD_HEADER_SIZE; buf->type = BUF_VIDEO_VMD; this->video_fifo->put (this->video_fifo, buf); diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c index 578be14ee..7582eea0e 100644 --- a/src/demuxers/demux_vqa.c +++ b/src/demuxers/demux_vqa.c @@ -73,13 +73,14 @@ typedef struct { off_t data_start; off_t filesize; - unsigned char bih[sizeof(xine_bmiheader) + VQA_HEADER_SIZE]; + xine_bmiheader bih; + unsigned char vqa_header[VQA_HEADER_SIZE]; xine_waveformatex wave; int64_t video_pts; unsigned int audio_frames; unsigned int iteration; -} demux_vqa_t ; +} demux_vqa_t; typedef struct { demux_class_t demux_class; @@ -89,8 +90,6 @@ typedef struct { static int open_vqa_file(demux_vqa_t *this) { unsigned char scratch[12]; unsigned int chunk_size; - xine_bmiheader *bih = (xine_bmiheader *)this->bih; - unsigned char *vqa_header = this->bih + sizeof(xine_bmiheader); if (_x_demux_read_header(this->input, scratch, 12) != 12) return 0; @@ -108,15 +107,15 @@ static int open_vqa_file(demux_vqa_t *this) { this->filesize = 1; /* load the VQA header */ - if (this->input->read(this->input, vqa_header, VQA_HEADER_SIZE) != + if (this->input->read(this->input, this->vqa_header, VQA_HEADER_SIZE) != VQA_HEADER_SIZE) return 0; - bih->biSize = sizeof(xine_bmiheader) + VQA_HEADER_SIZE; - bih->biWidth = _X_LE_16(&vqa_header[6]); - bih->biHeight = _X_LE_16(&vqa_header[8]); - this->wave.nSamplesPerSec = _X_LE_16(&vqa_header[24]); - this->wave.nChannels = vqa_header[26]; + this->bih.biSize = sizeof(xine_bmiheader) + VQA_HEADER_SIZE; + this->bih.biWidth = _X_LE_16(&this->vqa_header[6]); + this->bih.biHeight = _X_LE_16(&this->vqa_header[8]); + this->wave.nSamplesPerSec = _X_LE_16(&this->vqa_header[24]); + this->wave.nChannels = this->vqa_header[26]; this->wave.wBitsPerSample = 16; /* skip the FINF chunk */ @@ -240,7 +239,6 @@ static int demux_vqa_send_chunk(demux_plugin_t *this_gen) { static void demux_vqa_send_headers(demux_plugin_t *this_gen) { demux_vqa_t *this = (demux_vqa_t *) this_gen; buf_element_t *buf; - xine_bmiheader *bih = (xine_bmiheader *)this->bih; this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; @@ -252,9 +250,9 @@ static void demux_vqa_send_headers(demux_plugin_t *this_gen) { _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, (this->wave.nChannels) ? 1 : 0); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, - bih->biWidth); + this->bih.biWidth); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, - bih->biHeight); + this->bih.biHeight); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, this->wave.nChannels); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, @@ -270,7 +268,8 @@ static void demux_vqa_send_headers(demux_plugin_t *this_gen) { buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; buf->decoder_info[0] = VQA_PTS_INC; /* initial video_step */ - memcpy(buf->content, this->bih, sizeof(xine_bmiheader) + VQA_HEADER_SIZE); + memcpy(buf->content, &this->bih, sizeof(xine_bmiheader)); + memcpy(buf->content + sizeof(xine_bmiheader), this->vqa_header, VQA_HEADER_SIZE); buf->size = sizeof(xine_bmiheader) + VQA_HEADER_SIZE; buf->type = BUF_VIDEO_VQA; this->video_fifo->put (this->video_fifo, buf); -- cgit v1.2.3 From 7fa0e8ce9a31512dbc2ef4c6963ca727142bde6f Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 09:41:31 +0300 Subject: input_dvb: fixed check for recording file handle --- src/input/input_dvb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 145abc773..fc3c88862 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -2578,7 +2578,7 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, ts_rewrite_packets (this, buf,total); - if ((this->record_fd)&&(!this->record_paused)) + if ((this->record_fd > -1) && (!this->record_paused)) write (this->record_fd, buf, total); pthread_mutex_unlock( &this->channel_change_mutex ); -- cgit v1.2.3 From 165a7d69600daae3a5501569a8805e84d3122daf Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 09:44:08 +0300 Subject: input_dvb: if write() fails, stop recording and log a message --- src/input/input_dvb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index fc3c88862..f7fa51e16 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -2579,7 +2579,11 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, ts_rewrite_packets (this, buf,total); if ((this->record_fd > -1) && (!this->record_paused)) - write (this->record_fd, buf, total); + if (write (this->record_fd, buf, total) != total) { + do_record(this); + xprintf(this->class->xine, XINE_VERBOSITY_LOG, + "input_dvb: Recording failed\n"); + } pthread_mutex_unlock( &this->channel_change_mutex ); -- cgit v1.2.3 From a3e08d2839de1a6529286d106376a74f8e62c6ad Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 09:45:26 +0300 Subject: Removed unused variable --- src/input/input_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/input/input_v4l2.c b/src/input/input_v4l2.c index 5396594f4..8411b8cc3 100644 --- a/src/input/input_v4l2.c +++ b/src/input/input_v4l2.c @@ -350,7 +350,7 @@ static uint32_t v4l2_input_get_capabilities(input_plugin_t* this_gen) { } static const char* v4l2_input_get_mrl(input_plugin_t* this_gen) { - v4l2_input_plugin_t* this = (v4l2_input_plugin_t*)this_gen; + /*v4l2_input_plugin_t* this = (v4l2_input_plugin_t*)this_gen;*/ /* HACK HACK HACK HACK */ /* So far, the only way to get the yuv_frames demuxer to work with this */ return "v4l:/"; -- cgit v1.2.3 From 5ae44fd6e69481c8b2779857a7231cf1c5dc74a5 Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Tue, 18 Oct 2011 11:18:54 +0300 Subject: net_buf_ctrl: dvb sync: observe a/v buffers only. Dont get fooled by subtitle buffers with pts seconds away from video for example. --- src/input/net_buf_ctrl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 30db0e6e4..d06d8133f 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -190,12 +190,13 @@ static void dvbspeed_put (nbc_t *this, fifo_buffer_t * fifo, buf_element_t *b) { int used, mode; const char *name; /* select vars */ - if (fifo == this->video_fifo) { + mode = b->type & BUF_MAJOR_MASK; + if (mode == BUF_VIDEO_BASE) { last = &this->dvbs_video_in; fill = &this->dvbs_video_fill; mode = 0x71; name = "video"; - } else if (fifo == this->audio_fifo) { + } else if (mode == BUF_AUDIO_BASE) { last = &this->dvbs_audio_in; fill = &this->dvbs_audio_fill; mode = 0x0f; @@ -265,12 +266,13 @@ static void dvbspeed_get (nbc_t *this, fifo_buffer_t * fifo, buf_element_t *b) { int used, mode; const char *name; /* select vars */ - if (fifo == this->video_fifo) { + mode = b->type & BUF_MAJOR_MASK; + if (mode == BUF_VIDEO_BASE) { last = &this->dvbs_video_out; fill = &this->dvbs_video_fill; mode = 0x71; name = "video"; - } else if (fifo == this->audio_fifo) { + } else if (mode == BUF_AUDIO_BASE) { last = &this->dvbs_audio_out; fill = &this->dvbs_audio_fill; mode = 0x0f; -- cgit v1.2.3 From 5c160b93ade6a07e3bcc084f4552dcd1eb70b5b4 Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Tue, 18 Oct 2011 11:19:32 +0300 Subject: net_buf_ctrl: dvb sync: dont rely on demuxer sending BUF_FLAG_FRAME_START (eg for streams that send PES payloads not aligned to frame boundaries). --- src/input/net_buf_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index d06d8133f..d187b5c2b 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -203,7 +203,7 @@ static void dvbspeed_put (nbc_t *this, fifo_buffer_t * fifo, buf_element_t *b) { name = "audio"; } else return; /* update fifo fill time */ - if (b->pts && (b->decoder_flags & BUF_FLAG_FRAME_START)) { + if (b->pts) { if (*last) { diff = b->pts - *last; if ((diff > -220000) && (diff < 220000)) *fill += diff; @@ -279,7 +279,7 @@ static void dvbspeed_get (nbc_t *this, fifo_buffer_t * fifo, buf_element_t *b) { name = "audio"; } else return; /* update fifo fill time */ - if (b->pts && (b->decoder_flags & BUF_FLAG_FRAME_START)) { + if (b->pts) { if (*last) { diff = b->pts - *last; if ((diff > -220000) && (diff < 220000)) *fill -= diff; -- cgit v1.2.3 From 6fa4eea31e772669253d1c474abba11e2ab78837 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 15:34:44 +0300 Subject: demux_ts.c: fixed seeking to time offset --- src/demuxers/demux_ts.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 65007fda4..99c2074d0 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -2295,7 +2295,6 @@ static int demux_ts_seek (demux_plugin_t *this_gen, demux_ts_t *this = (demux_ts_t *) this_gen; int i; - start_time /= 1000; start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); -- cgit v1.2.3 From 720c9e8623e64466c419a48506822d527f149715 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 15:35:19 +0300 Subject: demux_ts.c: Use input->seek_time() when available. --- src/demuxers/demux_ts.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 99c2074d0..98808ec62 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -2301,10 +2301,17 @@ static int demux_ts_seek (demux_plugin_t *this_gen, if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) { if ((!start_pos) && (start_time)) { - start_pos = (int64_t)start_time * this->rate / 1000; - } - this->input->seek (this->input, start_pos, SEEK_SET); + if (this->input->seek_time) { + this->input->seek_time(this->input, start_time, SEEK_SET); + } else { + start_pos = (int64_t)start_time * this->rate / 1000; + this->input->seek (this->input, start_pos, SEEK_SET); + } + + } else { + this->input->seek (this->input, start_pos, SEEK_SET); + } } this->send_newpts = 1; -- cgit v1.2.3 From 84348c0e245c7867bdbfebc3d57bf8f3bc1a9b9f Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 15:17:44 +0300 Subject: demux_ts: eliminated unneeded variable --- src/demuxers/demux_ts.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 98808ec62..65ec7859d 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -293,7 +293,6 @@ typedef struct { unsigned int counter; uint16_t descriptor_tag; /* +0x100 for PES stream IDs (no available TS descriptor tag?) */ int corrupted_pes; - uint32_t buffered_bytes; int input_normpos; int input_time; @@ -605,14 +604,12 @@ static void demux_ts_flush_media(demux_ts_media *m) { if (m->buf) { m->buf->content = m->buf->mem; - m->buf->size = m->buffered_bytes; m->buf->type = m->type; m->buf->decoder_flags |= BUF_FLAG_FRAME_END; m->buf->pts = m->pts; m->buf->extra_info->input_normpos = m->input_normpos; m->buf->extra_info->input_time = m->input_time; m->fifo->put(m->fifo, m->buf); - m->buffered_bytes = 0; m->buf = NULL; } } @@ -1100,10 +1097,9 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->counter++; if (pus) { /* new PES packet */ - if (m->buffered_bytes) { + if (m->buf && m->buf->size) { m->buf->content = m->buf->mem; - m->buf->size = m->buffered_bytes; m->buf->type = m->type; m->buf->decoder_flags |= BUF_FLAG_FRAME_END; m->buf->pts = m->pts; @@ -1111,7 +1107,6 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->buf->extra_info->input_normpos = m->input_normpos; m->buf->extra_info->input_time = m->input_time; m->fifo->put(m->fifo, m->buf); - m->buffered_bytes = 0; m->buf = NULL; /* forget about buf -- not our responsibility anymore */ #ifdef TS_LOG printf ("demux_ts: produced buffer, pts=%lld\n", m->pts); @@ -1131,7 +1126,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->corrupted_pes = 0; memcpy(m->buf->mem, ts+len-m->size, m->size); - m->buffered_bytes = m->size; + m->buf->size = m->size; /* cache frame position */ off_t length = this->input->get_length (this->input); @@ -1151,16 +1146,14 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, } else if (!m->corrupted_pes) { /* no pus -- PES packet continuation */ - if ((m->buffered_bytes + len) > MAX_PES_BUF_SIZE) { + if ((m->buf->size + len) > MAX_PES_BUF_SIZE) { m->buf->content = m->buf->mem; - m->buf->size = m->buffered_bytes; m->buf->type = m->type; m->buf->pts = m->pts; m->buf->decoder_info[0] = 1; m->buf->extra_info->input_normpos = m->input_normpos; m->buf->extra_info->input_time = m->input_time; m->fifo->put(m->fifo, m->buf); - m->buffered_bytes = 0; m->buf = m->fifo->buffer_pool_alloc(m->fifo); #ifdef TS_LOG @@ -1168,8 +1161,8 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, #endif } - memcpy(m->buf->mem + m->buffered_bytes, ts, len); - m->buffered_bytes += len; + memcpy(m->buf->mem + m->buf->size, ts, len); + m->buf->size += len; } } @@ -1193,7 +1186,6 @@ static void demux_ts_pes_new(demux_ts_t*this, m->counter = INVALID_CC; m->descriptor_tag = descriptor; m->corrupted_pes = 1; - m->buffered_bytes = 0; } @@ -2324,7 +2316,6 @@ static int demux_ts_seek (demux_plugin_t *this_gen, m->buf = NULL; m->counter = INVALID_CC; m->corrupted_pes = 1; - m->buffered_bytes = 0; } if( !playing ) { -- cgit v1.2.3 From fd021ba10d26c185cc6a536d69aad832ff77569a Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 15:41:54 +0300 Subject: demux_ts: factorized buffer sending --- src/demuxers/demux_ts.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 65ec7859d..44c46c3f3 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -600,20 +600,31 @@ static void demux_ts_update_spu_channel(demux_ts_t *this) this->video_fifo->put(this->video_fifo, buf); } -static void demux_ts_flush_media(demux_ts_media *m) +static void demux_ts_send_buffer(demux_ts_media *m, int flags) { if (m->buf) { m->buf->content = m->buf->mem; m->buf->type = m->type; - m->buf->decoder_flags |= BUF_FLAG_FRAME_END; + m->buf->decoder_flags |= flags; m->buf->pts = m->pts; + m->buf->decoder_info[0] = 1; m->buf->extra_info->input_normpos = m->input_normpos; m->buf->extra_info->input_time = m->input_time; + m->fifo->put(m->fifo, m->buf); m->buf = NULL; + +#ifdef TS_LOG + printf ("demux_ts: produced buffer, pts=%lld\n", m->pts); +#endif } } +static void demux_ts_flush_media(demux_ts_media *m) +{ + demux_ts_send_buffer(m, BUF_FLAG_FRAME_END); +} + static void demux_ts_flush(demux_ts_t *this) { unsigned int i; @@ -1098,19 +1109,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, if (pus) { /* new PES packet */ if (m->buf && m->buf->size) { - - m->buf->content = m->buf->mem; - m->buf->type = m->type; - m->buf->decoder_flags |= BUF_FLAG_FRAME_END; - m->buf->pts = m->pts; - m->buf->decoder_info[0] = 1; - m->buf->extra_info->input_normpos = m->input_normpos; - m->buf->extra_info->input_time = m->input_time; - m->fifo->put(m->fifo, m->buf); - m->buf = NULL; /* forget about buf -- not our responsibility anymore */ -#ifdef TS_LOG - printf ("demux_ts: produced buffer, pts=%lld\n", m->pts); -#endif + demux_ts_flush_media(m); } /* allocate the buffer here, as pes_header needs a valid buf for dvbsubs */ m->buf = m->fifo->buffer_pool_alloc(m->fifo); @@ -1147,19 +1146,8 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, } else if (!m->corrupted_pes) { /* no pus -- PES packet continuation */ if ((m->buf->size + len) > MAX_PES_BUF_SIZE) { - m->buf->content = m->buf->mem; - m->buf->type = m->type; - m->buf->pts = m->pts; - m->buf->decoder_info[0] = 1; - m->buf->extra_info->input_normpos = m->input_normpos; - m->buf->extra_info->input_time = m->input_time; - m->fifo->put(m->fifo, m->buf); + demux_ts_send_buffer(m, 0); m->buf = m->fifo->buffer_pool_alloc(m->fifo); - -#ifdef TS_LOG - printf ("demux_ts: produced buffer, pts=%lld\n", m->pts); -#endif - } memcpy(m->buf->mem + m->buf->size, ts, len); m->buf->size += len; -- cgit v1.2.3 From 42ebbb0788b0b6a480ea9b0d76dfa54f82f18df0 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Tue, 18 Oct 2011 15:44:06 +0300 Subject: demux_ts: fixed buffer leak. (buffer was lost if PES packet had no payload) --- src/demuxers/demux_ts.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 44c46c3f3..f1943275e 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -1108,11 +1108,11 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->counter++; if (pus) { /* new PES packet */ - if (m->buf && m->buf->size) { - demux_ts_flush_media(m); - } + + demux_ts_flush_media(m); + /* allocate the buffer here, as pes_header needs a valid buf for dvbsubs */ - m->buf = m->fifo->buffer_pool_alloc(m->fifo); + m->buf = m->fifo->buffer_pool_alloc(m->fifo); if (!demux_ts_parse_pes_header(this->stream->xine, m, ts, len)) { m->buf->free_buffer(m->buf); -- cgit v1.2.3 From b651d31627601d854a39e49f8ddde5c6b7ea5688 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 19 Oct 2011 13:54:49 +0300 Subject: demux_ts: pid and media_num are unsigned. --- src/demuxers/demux_ts.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index f1943275e..69b65549e 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -303,16 +303,16 @@ typedef struct { typedef struct { spu_dvb_descriptor_t desc; - int pid; - int media_index; + unsigned int pid; + unsigned int media_index; } demux_ts_spu_lang; /* Audio Channels */ #define MAX_AUDIO_TRACKS 32 typedef struct { - int pid; - int media_index; + unsigned int pid; + unsigned int media_index; char lang[4]; } demux_ts_audio_track; @@ -338,7 +338,7 @@ typedef struct { int pkt_offset; /* TS packet offset */ int rate; - int media_num; + unsigned int media_num; demux_ts_media media[MAX_PIDS]; /* PAT */ @@ -416,7 +416,7 @@ static void demux_ts_tbre_reset (demux_ts_t *this) { } } -static void demux_ts_tbre_update (demux_ts_t *this, int mode, int64_t now) { +static void demux_ts_tbre_update (demux_ts_t *this, unsigned int mode, int64_t now) { /* select best available timesource on the fly */ if ((mode < this->tbre_mode) || (now <= 0)) return; -- cgit v1.2.3 From 7991c3891d62ccbcfe8fc9670b03907444e7910d Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Wed, 19 Oct 2011 13:56:33 +0300 Subject: demux_ts: added missing HDMV spu channel --- src/demuxers/demux_ts.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 69b65549e..f2276b93e 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -595,6 +595,7 @@ static void demux_ts_update_spu_channel(demux_ts_t *this) if ((this->media[this->spu_media].type & BUF_MAJOR_MASK) == BUF_SPU_HDMV) { buf->type = BUF_SPU_HDMV; + buf->type |= this->current_spu_channel; } this->video_fifo->put(this->video_fifo, buf); -- cgit v1.2.3