summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/input.rst5
-rw-r--r--DOCS/man/en/options.rst4
-rw-r--r--demux/demux.c3
-rw-r--r--demux/demux_lavf.c8
-rw-r--r--demux/demux_raw.c10
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--player/command.c14
-rw-r--r--player/discnav.c2
-rw-r--r--player/loadfile.c6
-rw-r--r--player/misc.c4
-rw-r--r--player/playloop.c4
-rw-r--r--stream/stream.c1
-rw-r--r--stream/stream.h2
-rw-r--r--stream/stream_cdda.c6
-rw-r--r--stream/stream_dvd.c1
-rw-r--r--stream/stream_vcd.c12
-rw-r--r--stream/vcd_read.h1
-rw-r--r--stream/vcd_read_darwin.h1
-rw-r--r--stream/vcd_read_fbsd.h1
-rw-r--r--stream/vcd_read_win32.h1
21 files changed, 34 insertions, 55 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst
index e32f1ea657..84491164f0 100644
--- a/DOCS/man/en/input.rst
+++ b/DOCS/man/en/input.rst
@@ -583,7 +583,7 @@ Property list
``file-size``
Length in bytes of the source file/stream. (This is the same as
- ``${stream-end} - ${stream-start}``. For ordered chapters and such, the
+ ``${stream-end}``. For ordered chapters and such, the
size of the currently played segment is returned.)
``path``
@@ -610,9 +610,6 @@ Property list
``stream-pos`` (RW)
Raw byte position in source stream.
-``stream-start``
- Raw start byte offset in source stream (rarely different from 0).
-
``stream-end``
Raw end position in bytes in source stream.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 2aa148a70a..9a24d3f01f 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1832,10 +1832,6 @@ OPTIONS
This behavior is disabled by default, but is always available when quitting
the player with Shift+Q.
-``--sb=<n>``
- Seek to byte position. Useful for playback from CD-ROM images or VOB files
- with junk at the beginning. See also ``--start``.
-
``--screen=<default|0-32>``
In multi-monitor configurations (i.e. a single desktop that spans across
multiple displays), this option tells mpv which screen to display the
diff --git a/demux/demux.c b/demux/demux.c
index 5dcd7a31ea..4da1adb134 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -599,7 +599,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
.metadata = talloc_zero(demuxer, struct mp_tags),
};
demuxer->params = params; // temporary during open()
- stream_seek(stream, stream->start_pos);
+ int64_t start_pos = stream_tell(stream);
mp_verbose(log, "Trying demuxer: %s (force-level: %s)\n",
desc->name, d_level(check));
@@ -634,6 +634,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
}
free_demuxer(demuxer);
+ stream_seek(stream, start_pos);
return NULL;
}
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index d493e9f631..b5a6ef998c 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -140,10 +140,10 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
else if (whence == SEEK_END && stream->end_pos > 0)
pos += stream->end_pos;
else if (whence == SEEK_SET)
- pos += stream->start_pos;
+ /* ok */;
else if (whence == AVSEEK_SIZE && stream->end_pos > 0) {
stream_update_size(stream);
- return stream->end_pos - stream->start_pos;
+ return stream->end_pos;
} else
return -1;
@@ -155,7 +155,7 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
return -1;
}
- return pos - stream->start_pos;
+ return pos;
}
static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags)
@@ -828,7 +828,7 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags)
!(priv->avif->flags & AVFMT_NO_BYTE_SEEK))
{
avsflags |= AVSEEK_FLAG_BYTE;
- priv->last_pts = (s->end_pos - s->start_pos) * rel_seek_secs;
+ priv->last_pts = s->end_pos * rel_seek_secs;
} else if (priv->avfc->duration != 0 &&
priv->avfc->duration != AV_NOPTS_VALUE)
{
diff --git a/demux/demux_raw.c b/demux/demux_raw.c
index 63674cea0c..9d649c07a0 100644
--- a/demux/demux_raw.c
+++ b/demux/demux_raw.c
@@ -200,7 +200,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->stream->start_pos;
+ dp->pos = stream_tell(demuxer->stream);
dp->pts = (dp->pos / p->frame_size) / p->frame_rate;
int len = stream_read(demuxer->stream, dp->buffer, dp->len);
@@ -215,11 +215,10 @@ static void raw_seek(demuxer_t *demuxer, float rel_seek_secs, int flags)
struct priv *p = demuxer->priv;
stream_t *s = demuxer->stream;
stream_update_size(s);
- int64_t start = s->start_pos;
int64_t end = s->end_pos;
- int64_t pos = (flags & SEEK_ABSOLUTE) ? start : stream_tell(s);
+ int64_t pos = (flags & SEEK_ABSOLUTE) ? 0 : stream_tell(s);
if (flags & SEEK_FACTOR)
- pos += (end - start) * rel_seek_secs;
+ pos += end * rel_seek_secs;
else
pos += rel_seek_secs * p->frame_rate * p->frame_size;
if (pos < 0)
@@ -237,12 +236,11 @@ static int raw_control(demuxer_t *demuxer, int cmd, void *arg)
case DEMUXER_CTRL_GET_TIME_LENGTH: {
stream_t *s = demuxer->stream;
stream_update_size(s);
- int64_t start = s->start_pos;
int64_t end = s->end_pos;
if (!end)
return DEMUXER_CTRL_DONTKNOW;
- *((double *) arg) = ((end - start) / p->frame_size) / p->frame_rate;
+ *((double *) arg) = (end / p->frame_size) / p->frame_rate;
return DEMUXER_CTRL_OK;
}
default:
diff --git a/options/options.c b/options/options.c
index 3b9347ebb8..7377f666d9 100644
--- a/options/options.c
+++ b/options/options.c
@@ -281,8 +281,6 @@ const m_option_t mp_opts[] = {
OPT_CHOICE_OR_INT("frames", play_frames, M_OPT_FIXED, 0, INT_MAX,
({"all", -1})),
- // seek to byte/seconds position
- OPT_INT64("sb", seek_to_byte, 0),
OPT_REL_TIME("start", play_start, 0),
OPT_REL_TIME("end", play_end, 0),
OPT_REL_TIME("length", play_length, 0),
diff --git a/options/options.h b/options/options.h
index 5da933d41d..6b482e2665 100644
--- a/options/options.h
+++ b/options/options.h
@@ -149,7 +149,6 @@ typedef struct MPOpts {
struct m_rel_time play_length;
int play_frames;
double step_sec;
- int64_t seek_to_byte;
int position_resume;
int position_save_on_quit;
int pause;
diff --git a/player/command.c b/player/command.c
index be5d215300..9c690d38ae 100644
--- a/player/command.c
+++ b/player/command.c
@@ -206,7 +206,7 @@ static int mp_property_file_size(m_option_t *prop, int action, void *arg,
if (!mpctx->stream)
return M_PROPERTY_UNAVAILABLE;
- int64_t size = mpctx->stream->end_pos - mpctx->stream->start_pos;
+ int64_t size = mpctx->stream->end_pos;
switch (action) {
case M_PROPERTY_GET: {
@@ -297,16 +297,6 @@ static int mp_property_stream_pos(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-/// Stream start offset (RO)
-static int mp_property_stream_start(m_option_t *prop, int action,
- void *arg, MPContext *mpctx)
-{
- struct stream *stream = mpctx->stream;
- if (!stream)
- return M_PROPERTY_UNAVAILABLE;
- return m_property_int64_ro(prop, action, arg, stream->start_pos);
-}
-
/// Stream end offset (RO)
static int mp_property_stream_end(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -2345,8 +2335,6 @@ static const m_option_t mp_properties[] = {
0, 0, 0, NULL },
{ "stream-pos", mp_property_stream_pos, CONF_TYPE_INT64,
M_OPT_MIN, 0, 0, NULL },
- { "stream-start", mp_property_stream_start, CONF_TYPE_INT64,
- M_OPT_MIN, 0, 0, NULL },
{ "stream-end", mp_property_stream_end, CONF_TYPE_INT64,
M_OPT_MIN, 0, 0, NULL },
{ "stream-time-pos", mp_property_stream_time_pos, CONF_TYPE_TIME,
diff --git a/player/discnav.c b/player/discnav.c
index 60b83bcd3c..d6d0618a80 100644
--- a/player/discnav.c
+++ b/player/discnav.c
@@ -123,8 +123,6 @@ void mp_nav_reset(struct MPContext *mpctx)
nav->nav_draining = false;
nav->nav_still_frame = 0;
mp_input_disable_section(mpctx->input, "discnav-menu");
- // Prevent demuxer init code to seek to the "start"
- mpctx->stream->start_pos = stream_tell(mpctx->stream);
stream_control(mpctx->stream, STREAM_CTRL_RESUME_CACHE, NULL);
update_state(mpctx);
}
diff --git a/player/loadfile.c b/player/loadfile.c
index ccf4b6e33c..d79e82911c 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1110,8 +1110,6 @@ static void play_current_file(struct MPContext *mpctx)
}
mpctx->initialized_flags |= INITIALIZED_STREAM;
- mpctx->stream->start_pos += opts->seek_to_byte;
-
if (opts->stream_dump && opts->stream_dump[0]) {
stream_dump(mpctx);
goto terminate_playback;
@@ -1267,10 +1265,8 @@ goto_reopen_demuxer: ;
else
dir = DVB_CHANNEL_LOWER;
- if (dvb_step_channel(mpctx->stream, dir)) {
+ if (dvb_step_channel(mpctx->stream, dir))
mpctx->stop_play = PT_RELOAD_DEMUXER;
- mpctx->stream->start_pos = stream_tell(mpctx->stream);
- }
}
#endif
goto terminate_playback;
diff --git a/player/misc.c b/player/misc.c
index c1b7d98182..e3cf70f81e 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -173,8 +173,8 @@ void stream_dump(struct MPContext *mpctx)
while (mpctx->stop_play == KEEP_PLAYING && !stream->eof) {
if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) {
- uint64_t pos = stream->pos - stream->start_pos;
- uint64_t end = stream->end_pos - stream->start_pos;
+ uint64_t pos = stream->pos;
+ uint64_t end = stream->end_pos;
MP_MSG(mpctx, MSGL_STATUS, "Dumping %lld/%lld...",
(long long int)pos, (long long int)end);
}
diff --git a/player/playloop.c b/player/playloop.c
index 3488abe9d1..dea78c5571 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -472,11 +472,11 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
ans = MPCLAMP((pos - start) / len, 0, 1);
} else {
struct stream *s = demuxer->stream;
- int64_t size = s->end_pos - s->start_pos;
+ int64_t size = s->end_pos;
int64_t fpos = demuxer->filepos >= 0 ?
demuxer->filepos : stream_tell(demuxer->stream);
if (size > 0)
- ans = MPCLAMP((double)(fpos - s->start_pos) / size, 0, 1);
+ ans = MPCLAMP(fpos / (double)size, 0, 1);
}
if (use_range) {
if (mpctx->opts->play_frames > 0)
diff --git a/stream/stream.c b/stream/stream.c
index b6fec81eb8..0acabe3f52 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -815,7 +815,6 @@ int stream_enable_cache(stream_t **stream, struct mp_cache_opts *opts)
cache->safe_origin = orig->safe_origin;
cache->opts = orig->opts;
cache->global = orig->global;
- cache->start_pos = orig->start_pos;
cache->end_pos = orig->end_pos;
cache->log = mp_log_new(cache, cache->global->log, "cache");
diff --git a/stream/stream.h b/stream/stream.h
index 3675ea9732..2182de2526 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -147,7 +147,7 @@ typedef struct stream {
int sector_size; // sector size (seek will be aligned on this size if non 0)
int read_chunk; // maximum amount of data to read at once to limit latency
unsigned int buf_pos, buf_len;
- int64_t pos, start_pos, end_pos;
+ int64_t pos, end_pos;
int eof;
int mode; //STREAM_READ or STREAM_WRITE
bool streaming; // known to be a network stream if true
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 1b81bfc6fb..6f1c747483 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -202,6 +202,8 @@ static int seek(stream_t *s, int64_t newpos)
int seek_to_track = 0;
int i;
+ newpos += priv->start_sector * CDIO_CD_FRAMESIZE_RAW;
+
sec = newpos / CDIO_CD_FRAMESIZE_RAW;
if (newpos < 0 || sec > p->end_sector) {
p->sector = p->end_sector + 1;
@@ -388,8 +390,8 @@ static int open_cdda(stream_t *st, int m)
priv->sector = priv->start_sector;
st->priv = priv;
- st->start_pos = priv->start_sector * CDIO_CD_FRAMESIZE_RAW;
- st->end_pos = (priv->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW;
+ st->end_pos =
+ (priv->end_sector + 1 - priv->start_sector) * CDIO_CD_FRAMESIZE_RAW;
st->sector_size = CDIO_CD_FRAMESIZE_RAW;
st->fill_buffer = fill_buffer;
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index 0394a2640c..c393915ffd 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -918,7 +918,6 @@ static int open_s(stream_t *stream, int mode)
stream->fill_buffer = fill_buffer;
stream->control = control;
stream->close = stream_dvd_close;
- stream->start_pos = (int64_t)d->cur_pack*2048;
stream->end_pos = (int64_t)(d->cur_pgc->cell_playback[d->last_cell-1].last_sector)*2048;
MP_VERBOSE(stream, "DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector);
stream->priv = (void*)d;
diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c
index c0da02a324..a61fc04376 100644
--- a/stream/stream_vcd.c
+++ b/stream/stream_vcd.c
@@ -59,7 +59,7 @@
#include "osdep/io.h"
static int fill_buffer(stream_t *s, char* buffer, int max_len){
- if(s->pos > s->end_pos) /// don't past end of current track
+ if(s->pos > s->end_pos) /// don't read past end of current track
return 0;
if (max_len < VCD_SECTOR_DATA)
return -1;
@@ -67,7 +67,9 @@ static int fill_buffer(stream_t *s, char* buffer, int max_len){
}
static int seek(stream_t *s,int64_t newpos) {
- vcd_set_msf(s->priv,newpos/VCD_SECTOR_DATA);
+ mp_vcd_priv_t *vcd = s->priv;
+ newpos += vcd->start;
+ vcd_set_msf(vcd,newpos/VCD_SECTOR_DATA);
return 1;
}
@@ -162,8 +164,7 @@ static int open_s(stream_t *stream,int mode)
#endif
stream->sector_size = VCD_SECTOR_DATA;
- stream->start_pos=ret;
- stream->end_pos=ret2;
+ stream->end_pos=ret2-ret;
stream->priv = vcd;
stream->fill_buffer = fill_buffer;
@@ -171,6 +172,9 @@ static int open_s(stream_t *stream,int mode)
stream->close = close_s;
stream->demuxer = "lavf"; // mpegps ( or "vcd"?)
+ vcd->start = ret;
+ seek(stream, 0);
+
return STREAM_OK;
}
diff --git a/stream/vcd_read.h b/stream/vcd_read.h
index ccb176ff97..5a5d033f4b 100644
--- a/stream/vcd_read.h
+++ b/stream/vcd_read.h
@@ -42,6 +42,7 @@ static int sun_vcd_read(mp_vcd_priv_t*, int*);
#endif
struct mp_vcd_priv_st {
+ int start;
stream_t *stream;
int fd;
struct cdrom_tocentry entry;
diff --git a/stream/vcd_read_darwin.h b/stream/vcd_read_darwin.h
index ecfe596f51..f35717856a 100644
--- a/stream/vcd_read_darwin.h
+++ b/stream/vcd_read_darwin.h
@@ -50,6 +50,7 @@ typedef struct
typedef struct mp_vcd_priv_st
{
+ int start;
stream_t *stream;
int fd;
cdsector_t buf;
diff --git a/stream/vcd_read_fbsd.h b/stream/vcd_read_fbsd.h
index ffa9ae7f6d..8f7f2a585a 100644
--- a/stream/vcd_read_fbsd.h
+++ b/stream/vcd_read_fbsd.h
@@ -61,6 +61,7 @@ typedef struct ioc_read_toc_single_entry vcd_tocentry;
#endif
typedef struct mp_vcd_priv_st {
+ int start;
int fd;
vcd_tocentry entry;
#ifdef VCD_NETBSD
diff --git a/stream/vcd_read_win32.h b/stream/vcd_read_win32.h
index ac6466c2a1..a01290eeb9 100644
--- a/stream/vcd_read_win32.h
+++ b/stream/vcd_read_win32.h
@@ -34,6 +34,7 @@ typedef struct mp_vcd_priv_st mp_vcd_priv_t;
we cache the information in mp_vcd_priv_st.
*/
struct mp_vcd_priv_st {
+ int start;
HANDLE hd;
CDROM_TOC toc;
unsigned sect;