summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-03 18:50:00 +0100
committerwm4 <wm4@nowhere>2013-11-03 18:50:00 +0100
commit847cbe9d5d03c77491f3139dde6e163426283ccb (patch)
tree76acc956c53b97410b366c2f6f10a9eb0561a621
parent22274f7982e01784a27daac371fe2a1607433425 (diff)
downloadmpv-847cbe9d5d03c77491f3139dde6e163426283ccb.tar.bz2
mpv-847cbe9d5d03c77491f3139dde6e163426283ccb.tar.xz
demux: remove movi_start/movi_end fields
Pointless, using stream->start_pos/end_pos instead. demux_mf was the only place where this was used specially, but we can rely on timestamps instead for this case.
-rw-r--r--demux/demux.c2
-rw-r--r--demux/demux.h2
-rw-r--r--demux/demux_lavf.c12
-rw-r--r--demux/demux_mf.c4
-rw-r--r--demux/demux_mkv.c8
-rw-r--r--demux/demux_raw.c8
-rw-r--r--mpvcore/player/playloop.c5
7 files changed, 13 insertions, 28 deletions
diff --git a/demux/demux.c b/demux/demux.c
index ba632218ec..1ce61da396 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -533,8 +533,6 @@ static struct demuxer *open_given_type(struct MPOpts *opts,
.type = desc->type,
.stream = stream,
.stream_pts = MP_NOPTS_VALUE,
- .movi_start = stream->start_pos,
- .movi_end = stream->end_pos,
.seekable = 1,
.accurate_seek = true,
.filepos = -1,
diff --git a/demux/demux.h b/demux/demux.h
index 0c8f9cb3f8..1c8562eb63 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -166,8 +166,6 @@ typedef struct demuxer {
const demuxer_desc_t *desc; ///< Demuxer description structure
const char *filetype; // format name when not identified by demuxer (libavformat)
int64_t filepos; // input stream current pos.
- int64_t movi_start;
- int64_t movi_end;
struct stream *stream;
double stream_pts; // current stream pts, if applicable (e.g. dvd)
char *filename; // same as stream->url
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index e80db5aed4..117dcd48ed 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -857,12 +857,12 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags)
avsflags = AVSEEK_FLAG_BACKWARD;
if (flags & SEEK_FACTOR) {
- if (demuxer->movi_end > 0 && demuxer->ts_resets_possible &&
+ struct stream *s = demuxer->stream;
+ if (s->end_pos > 0 && demuxer->ts_resets_possible &&
!(priv->avif->flags & AVFMT_NO_BYTE_SEEK))
{
avsflags |= AVSEEK_FLAG_BYTE;
- priv->last_pts = (demuxer->movi_end - demuxer->movi_start) *
- rel_seek_secs;
+ priv->last_pts = (s->end_pos - s->start_pos) * rel_seek_secs;
} else if (priv->avfc->duration != 0 &&
priv->avfc->duration != AV_NOPTS_VALUE)
{
@@ -923,12 +923,12 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
switch (cmd) {
case DEMUXER_CTRL_GET_TIME_LENGTH:
if (priv->seek_by_bytes) {
+ struct stream *s = demuxer->stream;
/* Our bitrate estimate may be better than would be used in
* otherwise similar fallback code at higher level */
- if (demuxer->movi_end <= 0)
+ if (s->end_pos <= 0)
return DEMUXER_CTRL_DONTKNOW;
- *(double *)arg = (demuxer->movi_end - demuxer->movi_start) * 8 /
- priv->bitrate;
+ *(double *)arg = (s->end_pos - s->start_pos) * 8 / priv->bitrate;
return DEMUXER_CTRL_GUESS;
}
if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
diff --git a/demux/demux_mf.c b/demux/demux_mf.c
index 0d7b2ece8a..fe8a249320 100644
--- a/demux/demux_mf.c
+++ b/demux/demux_mf.c
@@ -85,7 +85,6 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer)
demux_packet_t *dp = new_demux_packet(data.len);
memcpy(dp->buffer, data.start, data.len);
dp->pts = mf->curr_frame / mf->sh->fps;
- dp->pos = mf->curr_frame;
dp->keyframe = true;
demuxer_add_packet(demuxer, demuxer->streams[0], dp);
}
@@ -200,9 +199,6 @@ static int demux_open_mf(demuxer_t* demuxer, enum demux_check check)
mf->curr_frame = 0;
- demuxer->movi_start = 0;
- demuxer->movi_end = mf->nr_of_files - 1;
-
// create a new video stream header
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_VIDEO);
sh_video = sh->video;
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index b26cba5a29..d6948e9979 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -1029,7 +1029,7 @@ static int demux_mkv_read_seekhead(demuxer_t *demuxer)
continue;
}
uint64_t pos = seek->seek_position + mkv_d->segment_start;
- if (pos >= demuxer->movi_end) {
+ if (pos >= s->end_pos) {
mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] SeekHead position beyond "
"end of file - incomplete file?\n");
continue;
@@ -1847,8 +1847,6 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
if (s->end_pos == 0) {
demuxer->seekable = 0;
} else {
- demuxer->movi_start = s->start_pos;
- demuxer->movi_end = s->end_pos;
demuxer->seekable = 1;
}
@@ -2713,7 +2711,7 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
}
demux_mkv_fill_buffer(demuxer);
- } else if ((demuxer->movi_end <= 0) || !(flags & SEEK_ABSOLUTE))
+ } else if (!(flags & SEEK_ABSOLUTE))
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
else {
stream_t *s = demuxer->stream;
@@ -2729,7 +2727,7 @@ static void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
return;
}
- target_filepos = (uint64_t) (demuxer->movi_end * rel_seek_secs);
+ target_filepos = (uint64_t) (s->end_pos * rel_seek_secs);
for (i = 0; i < mkv_d->num_indexes; i++)
if (mkv_d->indexes[i].tnum == v_tnum)
if ((index == NULL)
diff --git a/demux/demux_raw.c b/demux/demux_raw.c
index 4d6e171ad4..01cf3574a0 100644
--- a/demux/demux_raw.c
+++ b/demux/demux_raw.c
@@ -100,9 +100,6 @@ static int demux_rawaudio_open(demuxer_t *demuxer, enum demux_check check)
w->wBitsPerSample = 8 * samplesize;
w->cbSize = 0;
- demuxer->movi_start = demuxer->stream->start_pos;
- demuxer->movi_end = demuxer->stream->end_pos;
-
struct priv *p = talloc_ptrtype(demuxer, p);
demuxer->priv = p;
*p = (struct priv) {
@@ -185,9 +182,6 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
sh_video->disp_h = height;
sh_video->i_bps = fps * imgsize;
- demuxer->movi_start = demuxer->stream->start_pos;
- demuxer->movi_end = demuxer->stream->end_pos;
-
struct priv *p = talloc_ptrtype(demuxer, p);
demuxer->priv = p;
*p = (struct priv) {
@@ -207,7 +201,7 @@ static int raw_fill_buffer(demuxer_t *demuxer)
return 0;
struct demux_packet *dp = new_demux_packet(p->frame_size * p->read_frames);
- dp->pos = stream_tell(demuxer->stream) - demuxer->movi_start;
+ dp->pos = stream_tell(demuxer->stream) - demuxer->stream->start_pos;
dp->pts = (dp->pos / p->frame_size) / p->frame_rate;
int len = stream_read(demuxer->stream, dp->buffer, dp->len);
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c
index 8efb6d6693..9e5aa1e0b4 100644
--- a/mpvcore/player/playloop.c
+++ b/mpvcore/player/playloop.c
@@ -452,11 +452,12 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
if (len > 0 && !demuxer->ts_resets_possible) {
ans = MPCLAMP((pos - start) / len, 0, 1);
} else {
- int64_t size = (demuxer->movi_end - demuxer->movi_start);
+ struct stream *s = demuxer->stream;
+ int64_t size = s->end_pos - s->start_pos;
int64_t fpos = demuxer->filepos > 0 ?
demuxer->filepos : stream_tell(demuxer->stream);
if (size > 0)
- ans = MPCLAMP((double)(fpos - demuxer->movi_start) / size, 0, 1);
+ ans = MPCLAMP((double)(fpos - s->start_pos) / size, 0, 1);
}
if (use_range) {
if (mpctx->opts->play_frames > 0)