예제 #1
0
Timestamp operator-(const Timestamp &left, const Timestamp &right) noexcept
{
    // Use more good precision
    auto tb = std::min(left.timebase(), right.timebase());
    auto tsleft  = left.timebase().rescale(left.timestamp(), tb);
    auto tsright = right.timebase().rescale(right.timestamp(), tb);

    auto ts = tsleft - tsright;

    return {ts, tb};
}
예제 #2
0
Timestamp operator+(const Timestamp &left, const Timestamp &right) noexcept
{
    // Use more good precision
    if (left.timebase() < right.timebase()) {
        auto ts = av_add_stable(left.timebase(), left.timestamp(),
                                right.timebase(), right.timestamp());
        return {ts, left.timebase()};
    } else {
        auto ts = av_add_stable(right.timebase(), right.timestamp(),
                                left.timebase(), left.timestamp());
        return {ts, right.timebase()};
    }
}
예제 #3
0
Timestamp operator/(const Timestamp &left, const Timestamp &right) noexcept
{
    int num, den;

    // Use more good precision
    auto tb = std::min(left.timebase(), right.timebase());
    auto tsleft  = left.timebase().rescale(left.timestamp(), tb);
    auto tsright = right.timebase().rescale(right.timestamp(), tb);

    int64_t ts = 1;
    if (tsleft > tsright) {
        ts = tsleft / tsright;
        tsleft %= tsright;
        if (tsleft == 0) {
            tsleft = 1;
            tsright = 1;
        }
    }

    av_reduce(&num, &den, tsleft, tsright, INT64_MAX);

    return {ts, {num, den}};
}
예제 #4
0
void FormatContext::seek(const Timestamp &timestamp, size_t streamIndex, bool anyFrame, OptionalErrorCode ec)
{
    auto st = stream(streamIndex);
    if (st.isValid())
        seek(timestamp.timestamp(st.timeBase()), static_cast<int>(streamIndex), anyFrame ? AVSEEK_FLAG_ANY : 0, ec);
}
예제 #5
0
void FormatContext::seek(const Timestamp& timestamp, bool anyFrame, OptionalErrorCode ec)
{
    seek(timestamp.timestamp(AV_TIME_BASE_Q), -1, anyFrame ? AVSEEK_FLAG_ANY : 0, ec);
}
예제 #6
0
void FormatContext::seek(const Timestamp& timestamp, size_t streamIndex, OptionalErrorCode ec)
{
    auto st = stream(streamIndex, ec);
    if (st.isValid())
        seek(timestamp.timestamp(st.timeBase()), static_cast<int>(streamIndex), 0, ec);
}
예제 #7
0
void FormatContext::seek(const Timestamp &timestamp, OptionalErrorCode ec)
{
    seek(timestamp.timestamp(AV_TIME_BASE_Q), -1, 0, ec);
}
예제 #8
0
파일: packet.cpp 프로젝트: brucechase/avcpp
void Packet::setDts(const Timestamp &dts)
{
    m_raw.dts = dts.timestamp(m_timeBase);
}
예제 #9
0
파일: packet.cpp 프로젝트: brucechase/avcpp
void Packet::setPts(const Timestamp &pts)
{
    m_raw.pts = pts.timestamp(m_timeBase);
}
예제 #10
0
Timestamp operator*(const Timestamp &left, const Timestamp &right) noexcept
{
    auto ts = left.timestamp() * right.timestamp();
    auto tb = left.timebase() * right.timebase();
    return {ts, tb};
}