Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
internal: rename skip to start_time
Browse files Browse the repository at this point in the history
  • Loading branch information
ubitux committed Mar 15, 2022
1 parent ed6f78a commit 50514b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
30 changes: 15 additions & 15 deletions src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ struct sxplayer_ctx {
#define OFFSET(x) offsetof(struct sxplayer_ctx, opts.x)
static const AVOption sxplayer_options[] = {
{ "avselect", NULL, OFFSET(avselect), AV_OPT_TYPE_INT, {.i64=SXPLAYER_SELECT_VIDEO}, 0, NB_SXPLAYER_MEDIA_SELECTION-1 },
{ "start_time", NULL, OFFSET(skip), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "start_time", NULL, OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "end_time", NULL, OFFSET(end_time), AV_OPT_TYPE_DOUBLE, {.dbl=-1}, -1, DBL_MAX },
{ "skip", NULL, OFFSET(skip), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "skip", NULL, OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "trim_duration", NULL, OFFSET(trim_duration), AV_OPT_TYPE_DOUBLE, {.dbl=-1}, -1, DBL_MAX },
{ "dist_time_seek_trigger", NULL, OFFSET(dist_time_seek_trigger), AV_OPT_TYPE_DOUBLE, {.dbl=1.5}, -1, DBL_MAX },
{ "max_nb_packets", NULL, OFFSET(max_nb_packets), AV_OPT_TYPE_INT, {.i64=5}, 1, 100 },
Expand Down Expand Up @@ -261,7 +261,7 @@ void sxplayer_free(struct sxplayer_ctx **ss)
*/
static int64_t get_media_time(const struct sxplayer_opts *o, int64_t t)
{
const int64_t mt = o->skip64 + t;
const int64_t mt = o->start_time64 + t;
return o->end_time64 == AV_NOPTS_VALUE ? mt : FFMIN(mt, o->end_time64);
}

Expand All @@ -285,34 +285,34 @@ static int set_context_fields(struct sxplayer_ctx *s)
o->auto_hwaccel = 0;
}

LOG(s, INFO, "avselect:%d skip:%f trim_duration:%f "
LOG(s, INFO, "avselect:%d start_time:%f trim_duration:%f "
"dist_time_seek_trigger:%f queues:[%d %d %d] filters:'%s'",
o->avselect, o->skip, o->trim_duration,
o->avselect, o->start_time, o->trim_duration,
o->dist_time_seek_trigger,
o->max_nb_packets, o->max_nb_frames, o->max_nb_sink,
o->filters ? o->filters : "");

o->skip64 = TIME2INT64(o->skip);
o->start_time64 = TIME2INT64(o->start_time);
o->dist_time_seek_trigger64 = TIME2INT64(o->dist_time_seek_trigger);
o->end_time64 = o->end_time < 0 ? AV_NOPTS_VALUE : TIME2INT64(o->end_time);

/* Translate trim_duration to end_time */
if (o->end_time64 == AV_NOPTS_VALUE) {
const int64_t trim_duration64 = o->trim_duration < 0 ? AV_NOPTS_VALUE : TIME2INT64(o->trim_duration);
if (trim_duration64 != AV_NOPTS_VALUE)
o->end_time64 = o->skip64 + trim_duration64;
o->end_time64 = o->start_time64 + trim_duration64;
} else if (o->trim_duration >= 0) {
LOG(s, ERROR, "trim_duration and end_time parameter are mutually exclusive");
return AVERROR(EINVAL);
}

if (o->end_time64 != AV_NOPTS_VALUE && o->end_time64 < 0) {
LOG(s, ERROR, "Invalid end time (%g): must be greater or equal to skip (%g)", o->end_time, o->skip);
LOG(s, ERROR, "Invalid end time (%g): must be greater or equal to start_time (%g)", o->end_time, o->start_time);
return AVERROR(EINVAL);
}

TRACE(s, "rescaled values: skip=%s dist:%s end_time:%s",
PTS2TIMESTR(o->skip64),
TRACE(s, "rescaled values: start_time=%s dist:%s end_time:%s",
PTS2TIMESTR(o->start_time64),
PTS2TIMESTR(o->dist_time_seek_trigger64),
PTS2TIMESTR(o->end_time64));

Expand Down Expand Up @@ -745,13 +745,13 @@ struct sxplayer_frame *sxplayer_get_frame_ms(struct sxplayer_ctx *s, int64_t t64
if (s->last_pushed_frame_ts == AV_NOPTS_VALUE) {

/* If prefetch wasn't done (async not started), and we requested a time
* that is beyond the initial skip, we request an appropriate seek
* that is beyond the initial start_time, we request an appropriate seek
* before we start the decoding process in order to save one seek and
* some decoding (a seek for the initial skip, then another one soon
* some decoding (a seek for the initial start_time, then another one soon
* after to reach the requested time). */
if (!sxpi_sxpi_async_started(s->actx) && vt > o->skip64) {
TRACE(s, "no prefetch, but requested time (%s) beyond initial skip (%s)",
PTS2TIMESTR(vt), PTS2TIMESTR(o->skip64));
if (!sxpi_sxpi_async_started(s->actx) && vt > o->start_time64) {
TRACE(s, "no prefetch, but requested time (%s) beyond initial start_time (%s)",
PTS2TIMESTR(vt), PTS2TIMESTR(o->start_time64));
sxpi_async_seek(s->actx, vt);
}

Expand Down
6 changes: 3 additions & 3 deletions src/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ static int op_start(struct async_context *actx)
if (actx->request_seek != AV_NOPTS_VALUE) {
TRACE(actx, "request seek is set to %s", PTS2TIMESTR(actx->request_seek));
seek_to = actx->request_seek;
} else if (o->skip64) {
TRACE(actx, "skip is set to %s", PTS2TIMESTR(actx->o->skip64));
seek_to = o->skip64;
} else if (o->start_time64) {
TRACE(actx, "start_time is set to %s", PTS2TIMESTR(actx->o->start_time64));
seek_to = o->start_time64;
}

if (seek_to != AV_NOPTS_VALUE && !is_seek_possible(actx)) {
Expand Down
4 changes: 2 additions & 2 deletions src/opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

struct sxplayer_opts {
int avselect; // select audio or video
double skip; // see public header
double start_time; // see public header
double end_time; // see public header
double trim_duration; // see public header
double dist_time_seek_trigger; // see public header
Expand All @@ -47,7 +47,7 @@ struct sxplayer_opts {
int stream_idx;
int use_pkt_duration;

int64_t skip64;
int64_t start_time64;
int64_t end_time64;
int64_t dist_time_seek_trigger64;
};
Expand Down

0 comments on commit 50514b6

Please sign in to comment.