summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Jager <t.jager@gmx.de>2011-10-13 21:54:11 +0300
committerTorsten Jager <t.jager@gmx.de>2011-10-13 21:54:11 +0300
commit82eccdbd9a348225c04d2e3c7caa7830eb5da08a (patch)
treec9f2ba85d67aeefa5321922654a8b6c2b0ef7cde
parent031efcfba644acddec5fb45c096afcdd5559b2ea (diff)
downloadxine-lib-82eccdbd9a348225c04d2e3c7caa7830eb5da08a.tar.gz
xine-lib-82eccdbd9a348225c04d2e3c7caa7830eb5da08a.tar.bz2
demux_ts: Fixed frame normpos. Cache current PES packet position in input stream.
-rw-r--r--src/demuxers/demux_ts.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c
index e891a5cbe..5d6b8cb8c 100644
--- a/src/demuxers/demux_ts.c
+++ b/src/demuxers/demux_ts.c
@@ -274,6 +274,8 @@ typedef struct {
int corrupted_pes;
uint32_t buffered_bytes;
+ int input_normpos;
+ int input_time;
} demux_ts_media;
/* DVBSUB */
@@ -368,6 +370,8 @@ typedef struct {
uint8_t buf[BUF_SIZE]; /* == PKT_SIZE * NPKT_PER_READ */
+ off_t frame_pos; /* current ts packet position in input stream (bytes from beginning) */
+
} demux_ts_t;
typedef struct {
@@ -1019,13 +1023,8 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->buf->decoder_flags |= BUF_FLAG_FRAME_END;
m->buf->pts = m->pts;
m->buf->decoder_info[0] = 1;
-
- if( this->input->get_length (this->input) )
- m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) *
- 65535 / this->input->get_length (this->input) );
- if (this->rate)
- m->buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input)
- * 1000 / (this->rate * 50));
+ 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 */
@@ -1048,6 +1047,15 @@ 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;
+
+ /* cache frame position */
+ off_t length = this->input->get_length (this->input);
+ if (length > 0) {
+ m->input_normpos = (double)this->frame_pos * 65535.0 / length;
+ }
+ if (this->rate) {
+ m->input_time = this->frame_pos * 1000 / (this->rate * 50);
+ }
}
} else if (!m->corrupted_pes) { /* no pus -- PES packet continuation */
@@ -1058,13 +1066,8 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->buf->type = m->type;
m->buf->pts = m->pts;
m->buf->decoder_info[0] = 1;
- if( this->input->get_length (this->input) )
- m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) *
- 65535 / this->input->get_length (this->input) );
- if (this->rate)
- m->buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input)
- * 1000 / (this->rate * 50));
-
+ 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);
@@ -1732,10 +1735,15 @@ static unsigned char * demux_synchronise(demux_ts_t* this) {
uint8_t *return_pointer = NULL;
int32_t read_length;
+
+ this->frame_pos += this->pkt_size;
+
if ( (this->packet_number) >= this->npkt_read) {
/* NEW: handle read returning less packets than NPKT_PER_READ... */
do {
+ this->frame_pos = this->input->get_current_pos (this->input);
+
read_length = this->input->read(this->input, this->buf,
this->pkt_size * NPKT_PER_READ);
if (read_length < 0 || read_length % this->pkt_size) {