コード例 #1
0
ファイル: misc.c プロジェクト: atomnuker/mpv
double get_play_end_pts(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    double end = MP_NOPTS_VALUE;
    if (opts->play_end.type) {
        end = rel_time_to_abs(mpctx, opts->play_end);
    }
    if (opts->play_length.type) {
        double start = get_play_start_pts(mpctx);
        if (start == MP_NOPTS_VALUE)
            start = 0;
        double length = rel_time_to_abs(mpctx, opts->play_length);
        if (length != MP_NOPTS_VALUE && (end == MP_NOPTS_VALUE || start + length < end))
            end = start + length;
    }
    if (opts->chapterrange[1] > 0) {
        double cend = chapter_start_time(mpctx, opts->chapterrange[1]);
        if (cend != MP_NOPTS_VALUE && (end == MP_NOPTS_VALUE || cend < end))
            end = cend;
    }
    // even though MP_NOPTS_VALUE is currently negative
    // it doesn't necessarily have to remain that way
    double ab_loop_start_time = get_ab_loop_start_time(mpctx);
    if (mpctx->ab_loop_clip && opts->ab_loop[1] != MP_NOPTS_VALUE &&
        (ab_loop_start_time == MP_NOPTS_VALUE || opts->ab_loop[1] > ab_loop_start_time))
    {
        if (end == MP_NOPTS_VALUE || end > opts->ab_loop[1])
            end = opts->ab_loop[1];
    }
    return end;
}
コード例 #2
0
ファイル: misc.c プロジェクト: Ionic/mpv
double get_play_end_pts(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    double end = MP_NOPTS_VALUE;
    if (opts->play_end.type) {
        end = rel_time_to_abs(mpctx, opts->play_end);
    } else if (opts->play_length.type) {
        double start = rel_time_to_abs(mpctx, opts->play_start);
        if (start == MP_NOPTS_VALUE)
            start = 0;
        double length = rel_time_to_abs(mpctx, opts->play_length);
        if (length != MP_NOPTS_VALUE)
            end = start + length;
    }
    if (opts->chapterrange[1] > 0) {
        double cend = chapter_start_time(mpctx, opts->chapterrange[1]);
        if (cend != MP_NOPTS_VALUE && (end == MP_NOPTS_VALUE || cend < end))
            end = cend;
    }
    if (mpctx->ab_loop_clip && opts->ab_loop[1] != MP_NOPTS_VALUE &&
        opts->ab_loop[1] > opts->ab_loop[0])
    {
        if (end == MP_NOPTS_VALUE || end > opts->ab_loop[1])
            end = opts->ab_loop[1];
    }
    return end;
}
コード例 #3
0
ファイル: misc.c プロジェクト: Deadsign/mpv
double get_play_end_pts(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    if (opts->play_end.type) {
        return rel_time_to_abs(mpctx, opts->play_end);
    } else if (opts->play_length.type) {
        double startpts = get_start_time(mpctx);
        double start = rel_time_to_abs(mpctx, opts->play_start);
        if (start == MP_NOPTS_VALUE)
            start = startpts;
        double length = rel_time_to_abs(mpctx, opts->play_length);
        if (start != MP_NOPTS_VALUE && length != MP_NOPTS_VALUE)
            return start + length;
    }
    return MP_NOPTS_VALUE;
}
コード例 #4
0
ファイル: misc.c プロジェクト: atomnuker/mpv
/**
 * Get the rebased PTS for which playback should start.
 * The order of priority is as follows:
 *   1. --start, if set.
 *   2. The start chapter, if set.
 *   3. MP_NOPTS_VALUE.
 * If unspecified, return MP_NOPTS_VALUE.
 * Does not return zero unless the start time is explicitly set to zero.
 */
double get_play_start_pts(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    double play_start_pts = rel_time_to_abs(mpctx, opts->play_start);
    if (play_start_pts == MP_NOPTS_VALUE && opts->chapterrange[0] > 0) {
        double chapter_start_pts = chapter_start_time(mpctx, opts->chapterrange[0] - 1);
        if (chapter_start_pts != MP_NOPTS_VALUE) {
            /*
             * get_play_start_pts always returns rebased timetamps,
             * even with --rebase-start-time=no. chapter_start_time
             * values are not rebased without --rebase-start-time=yes,
             * so we need to rebase them here to be consistent with
             * the rest of get_play_start_pts.
             */
            if (mpctx->demuxer && !mpctx->opts->rebase_start_time){
                chapter_start_pts -= mpctx->demuxer->start_time;
            }
            play_start_pts = chapter_start_pts;
        }
    }
    return play_start_pts;
}