summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-16 21:04:28 +0100
committerwm4 <wm4@nowhere>2013-11-16 21:46:17 +0100
commita2a24b957ec7dae8b9d312af8292b5e5e82d77be (patch)
treec4d9ad9cd7196a5f3ea5f8d83b570e55fb27b3a9 /demux/demux_mkv.c
parent0cdbc6db6ea1ee6cdeedec6c8bd84e692d5f82d3 (diff)
downloadmpv-a2a24b957ec7dae8b9d312af8292b5e5e82d77be.tar.bz2
mpv-a2a24b957ec7dae8b9d312af8292b5e5e82d77be.tar.xz
demux: simplify handling of filepos field
demuxer->filepos contains the byte offset of the last read packet. This is so that the player can estimate the current playback position, if no proper timestamps are available. Simplify it to use demux_packet->pos in the generic demuxer code, instead of bothering every demuxer implementation about it. (Note that this is still a bit incorrect: it relfects the position of the last packet read by the demuxer, not that returned to the user. But that was already broken, and is not that trivial to fix.)
Diffstat (limited to 'demux/demux_mkv.c')
-rw-r--r--demux/demux_mkv.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 092b86fa62..5258bee5d5 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -2004,7 +2004,7 @@ static void handle_realvideo(demuxer_t *demuxer, mkv_track_t *track,
track->stream->video->bih->biCompression,
&track->rv_kf_base, &track->rv_kf_pts, NULL);
}
- dp->pos = demuxer->filepos;
+ dp->pos = mkv_d->last_filepos;
dp->keyframe = keyframe;
demuxer_add_packet(demuxer, track->stream, dp);
@@ -2083,7 +2083,7 @@ static void handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
(track->ra_pts == mkv_d->last_pts) ? 0 : (mkv_d->last_pts);
track->ra_pts = mkv_d->last_pts;
if (track->sub_packet_cnt == 0)
- track->audio_filepos = demuxer->filepos;
+ track->audio_filepos = mkv_d->last_filepos;
if (++(track->sub_packet_cnt) == sph) {
int apk_usize = track->stream->audio->wf->nBlockAlign;
track->sub_packet_cnt = 0;
@@ -2108,7 +2108,7 @@ static void handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
dp->pts = mkv_d->last_pts;
track->ra_pts = mkv_d->last_pts;
- dp->pos = demuxer->filepos;
+ dp->pos = mkv_d->last_filepos;
dp->keyframe = keyframe;
demuxer_add_packet(demuxer, track->stream, dp);
}
@@ -2225,6 +2225,7 @@ struct block_info {
mkv_track_t *track;
bstr data;
void *alloc;
+ int64_t filepos;
};
static void free_block(struct block_info *block)
@@ -2260,7 +2261,7 @@ static int read_block(demuxer_t *demuxer, struct block_info *block)
if (!block->alloc)
goto exit;
block->data = (bstr){block->alloc, length};
- demuxer->filepos = stream_tell(s);
+ block->filepos = stream_tell(s);
if (stream_read(s, block->data.start, block->data.len) != block->data.len)
goto exit;
@@ -2350,7 +2351,7 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
if (use_this_block) {
mkv_d->last_pts = current_pts;
- mkv_d->last_filepos = demuxer->filepos;
+ mkv_d->last_filepos = block_info->filepos;
for (int i = 0; i < laces; i++) {
bstr block = bstr_splice(data, 0, lace_size[i]);