mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 09:29:29 +00:00
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.
This commit is contained in:
parent
22274f7982
commit
847cbe9d5d
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user