Esempio n. 1
0
QByteArray Frame::data(int plane) const
{
    if (plane < 0 || plane >= planeCount()) {
        qWarning("Invalid plane! Valid range is [0, %d)", planeCount());
        return QByteArray();
    }
    return QByteArray((char*)d_func()->planes[plane], bytesPerLine(plane));
}
Esempio n. 2
0
const uchar* Frame::bits(int plane) const
{
    if (plane < 0 || plane >= planeCount()) {
        qWarning("Invalid plane! Valid range is [0, %d)", planeCount());
        return 0;
    }
    return d_func()->planes[plane];
}
Esempio n. 3
0
int Frame::bytesPerLine(int plane) const
{
    if (plane < 0 || plane >= planeCount()) {
        qWarning("Invalid plane! Valid range is [0, %d)", planeCount());
        return 0;
    }
    return d_func()->line_sizes[plane];
}
Esempio n. 4
0
void* VideoFrame::createInteropHandle(void* handle, SurfaceType type, int plane)
{
    Q_D(VideoFrame);
    const QVariant v = d->metadata.value(QStringLiteral("surface_interop"));
    if (!v.isValid())
        return 0;
    d->surface_interop = v.value<VideoSurfaceInteropPtr>();
    if (!d->surface_interop)
        return 0;
    if (plane > planeCount())
        return 0;
    return d->surface_interop->createHandle(handle, type, format(), plane, planeWidth(plane), planeHeight(plane));
}
Esempio n. 5
0
void *VideoFrame::map(SurfaceType type, void *handle, int plane)
{
    Q_D(VideoFrame);
    const QVariant v = d->metadata.value(QStringLiteral("surface_interop"));
    if (!v.isValid())
        return 0;
    d->surface_interop = v.value<VideoSurfaceInteropPtr>();
    if (!d->surface_interop)
        return 0;
    if (plane > planeCount())
        return 0;
    return d->surface_interop->map(type, format(), handle, plane);
}
Esempio n. 6
0
AudioFrame AudioFrame::clone() const
{
    Q_D(const AudioFrame);
    if (d->format.sampleFormatFFmpeg() == AV_SAMPLE_FMT_NONE
            || d->format.channels() <= 0)
        return AudioFrame();
    if (d->samples_per_ch <= 0 || bytesPerLine(0) <= 0)
        return AudioFrame(format());
    QByteArray buf(bytesPerLine()*planeCount(), 0);
    AudioFrame f(buf, d->format);
    f.setSamplesPerChannel(samplesPerChannel());
    char *dst = buf.data(); //must before buf is shared, otherwise data will be detached.
    for (int i = 0; i < f.planeCount(); ++i) {
        const int plane_size = f.bytesPerLine(i);
        memcpy(dst, f.constBits(i), plane_size);
        dst += plane_size;
    }
    f.setTimestamp(timestamp());
    // meta data?
    return f;
}
Esempio n. 7
0
void Frame::setBits(quint8 *slice[])
{
    for (int i = 0; i < planeCount(); ++i ) {
        setBits(slice[i], i);
    }
}
Esempio n. 8
0
void Frame::setBytesPerLine(int stride[])
{
    for (int i = 0; i < planeCount(); ++i ) {
        setBytesPerLine(stride[i], i);
    }
}