mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 12:55:16 +00:00
demux: make start time a simple field
Simpler, especially for later changes.
This commit is contained in:
parent
7e209185f1
commit
8d40b1e8ab
@ -803,16 +803,6 @@ double demuxer_get_time_length(struct demuxer *demuxer)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double demuxer_get_start_time(struct demuxer *demuxer)
|
|
||||||
{
|
|
||||||
double time;
|
|
||||||
if (stream_control(demuxer->stream, STREAM_CTRL_GET_START_TIME, &time) > 0)
|
|
||||||
return time;
|
|
||||||
if (demux_control(demuxer, DEMUXER_CTRL_GET_START_TIME, &time) > 0)
|
|
||||||
return time;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int demuxer_angles_count(demuxer_t *demuxer)
|
int demuxer_angles_count(demuxer_t *demuxer)
|
||||||
{
|
{
|
||||||
int ris, angles = -1;
|
int ris, angles = -1;
|
||||||
|
@ -53,7 +53,6 @@ enum demuxer_type {
|
|||||||
enum demux_ctrl {
|
enum demux_ctrl {
|
||||||
DEMUXER_CTRL_SWITCHED_TRACKS = 1,
|
DEMUXER_CTRL_SWITCHED_TRACKS = 1,
|
||||||
DEMUXER_CTRL_GET_TIME_LENGTH,
|
DEMUXER_CTRL_GET_TIME_LENGTH,
|
||||||
DEMUXER_CTRL_GET_START_TIME,
|
|
||||||
DEMUXER_CTRL_RESYNC,
|
DEMUXER_CTRL_RESYNC,
|
||||||
DEMUXER_CTRL_IDENTIFY_PROGRAM,
|
DEMUXER_CTRL_IDENTIFY_PROGRAM,
|
||||||
DEMUXER_CTRL_STREAM_CTRL, // stupid workaround for legacy TV code
|
DEMUXER_CTRL_STREAM_CTRL, // stupid workaround for legacy TV code
|
||||||
@ -178,6 +177,7 @@ typedef struct demuxer {
|
|||||||
char *filename; // same as stream->url
|
char *filename; // same as stream->url
|
||||||
enum demuxer_type type;
|
enum demuxer_type type;
|
||||||
int seekable; // flag
|
int seekable; // flag
|
||||||
|
double start_time;
|
||||||
/* Set if using absolute seeks for small movements is OK (no pts resets
|
/* Set if using absolute seeks for small movements is OK (no pts resets
|
||||||
* that would make pts ambigious, preferably supports back/forward flags */
|
* that would make pts ambigious, preferably supports back/forward flags */
|
||||||
bool accurate_seek;
|
bool accurate_seek;
|
||||||
@ -263,7 +263,6 @@ int demuxer_add_chapter(struct demuxer *demuxer, struct bstr name,
|
|||||||
uint64_t start, uint64_t end, uint64_t demuxer_id);
|
uint64_t start, uint64_t end, uint64_t demuxer_id);
|
||||||
|
|
||||||
double demuxer_get_time_length(struct demuxer *demuxer);
|
double demuxer_get_time_length(struct demuxer *demuxer);
|
||||||
double demuxer_get_start_time(struct demuxer *demuxer);
|
|
||||||
|
|
||||||
/// Get current angle index.
|
/// Get current angle index.
|
||||||
int demuxer_get_current_angle(struct demuxer *demuxer);
|
int demuxer_get_current_angle(struct demuxer *demuxer);
|
||||||
|
@ -759,6 +759,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
|||||||
|
|
||||||
demuxer->ts_resets_possible = priv->avif->flags & AVFMT_TS_DISCONT;
|
demuxer->ts_resets_possible = priv->avif->flags & AVFMT_TS_DISCONT;
|
||||||
|
|
||||||
|
demuxer->start_time = priv->avfc->start_time == AV_NOPTS_VALUE ?
|
||||||
|
0 : (double)priv->avfc->start_time / AV_TIME_BASE;
|
||||||
|
|
||||||
|
double time;
|
||||||
|
if (stream_control(demuxer->stream, STREAM_CTRL_GET_START_TIME, &time) > 0)
|
||||||
|
demuxer->start_time = time;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,11 +920,6 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
|
|||||||
*((double *)arg) = (double)priv->avfc->duration / AV_TIME_BASE;
|
*((double *)arg) = (double)priv->avfc->duration / AV_TIME_BASE;
|
||||||
return DEMUXER_CTRL_OK;
|
return DEMUXER_CTRL_OK;
|
||||||
|
|
||||||
case DEMUXER_CTRL_GET_START_TIME:
|
|
||||||
*((double *)arg) = priv->avfc->start_time == AV_NOPTS_VALUE ?
|
|
||||||
0 : (double)priv->avfc->start_time / AV_TIME_BASE;
|
|
||||||
return DEMUXER_CTRL_OK;
|
|
||||||
|
|
||||||
case DEMUXER_CTRL_SWITCHED_TRACKS:
|
case DEMUXER_CTRL_SWITCHED_TRACKS:
|
||||||
{
|
{
|
||||||
select_tracks(demuxer, 0);
|
select_tracks(demuxer, 0);
|
||||||
|
@ -116,7 +116,7 @@ double get_start_time(struct MPContext *mpctx)
|
|||||||
// timestamp it finds as start PTS.
|
// timestamp it finds as start PTS.
|
||||||
if (mpctx->nav_state)
|
if (mpctx->nav_state)
|
||||||
return 0;
|
return 0;
|
||||||
return demuxer_get_start_time(demuxer);
|
return demuxer->start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
float mp_get_cache_percent(struct MPContext *mpctx)
|
float mp_get_cache_percent(struct MPContext *mpctx)
|
||||||
|
@ -203,7 +203,7 @@ static void resolve_timestamps(struct tl_part *part, struct demuxer *demuxer)
|
|||||||
part->length = length;
|
part->length = length;
|
||||||
}
|
}
|
||||||
if (!part->offset_set)
|
if (!part->offset_set)
|
||||||
part->offset = demuxer_get_start_time(demuxer);
|
part->offset = demuxer->start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
||||||
@ -223,7 +223,7 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
|||||||
|
|
||||||
double len = source_get_length(source);
|
double len = source_get_length(source);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
len += demuxer_get_start_time(source);
|
len += source->start_time;
|
||||||
} else {
|
} else {
|
||||||
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",
|
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",
|
||||||
part->filename);
|
part->filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user