void fillV4L2InputBuffer(struct v4l2_buffer& buf, const VideoFrameRawData& frame)
{
    if (inputMemoryType == V4L2_MEMORY_USERPTR) {
        uint32_t width[3];
        uint32_t height[3];
        uint32_t planes;
        bool ret;

        ret = getPlaneResolution(frame.fourcc, frame.width, frame.height, width, height, planes);
        ASSERT(ret && "get planes resolution failed");
        unsigned long data = (unsigned long)frame.handle;
        for (uint32_t i = 0; i < planes; i++) {
            buf.m.planes[i].bytesused = width[i] * height[i];
            buf.m.planes[i].m.userptr = data + frame.offset[i];
        }
    }
#if ANDROID
    else if (inputMemoryType == V4L2_MEMORY_ANDROID_BUFFER_HANDLE) {
        // !!! FIXME, v4l2 use long for userptr. so bad
        DEBUG("ANativeWindowBuffer->handle: %p", (void*)frame.handle);
        buf.m.planes[0].m.userptr = (long)((intptr_t)frame.handle);
        buf.m.planes[0].bytesused = sizeof(buf.m.planes[0].m.userptr);
    }
#endif
    else
        ASSERT(0 && "unknown memory type");
}
Exemple #2
0
bool VaapiImageRaw::copy(uint8_t* destBase, const uint32_t destOffsets[3], const uint32_t destPitches[3],
    const uint8_t* srcBase, const uint32_t srcOffsets[3], const uint32_t srcPitches[3])
{
    ASSERT(srcBase && destBase);
    if (m_memoryType != VIDEO_DATA_MEMORY_TYPE_RAW_COPY)
        return false;

    uint32_t width[3];
    uint32_t height[3];
    uint32_t planes;
    getPlaneResolution(width,height, planes);
    return copy(destBase, destOffsets, destPitches, srcBase, srcOffsets, srcPitches, width, height, planes);
}
Exemple #3
0
    VideoFrameRawData* convert(VideoFrameRawData* frame)
    {
        if (frame->fourcc == m_destFourcc) {
            //pass through
            return frame;
        }
        assert(m_destFourcc == VA_FOURCC_I420 && frame->fourcc == VA_FOURCC_NV12);

        uint32_t width[3];
        uint32_t height[3];
        uint32_t planes;
        if (!getPlaneResolution(frame->fourcc, frame->width, frame->height, width, height, planes))
            return NULL;
        return NV12ToI420(frame, width, height);
    }
Exemple #4
0
bool VaapiImageRaw::copyFrom(const uint8_t* src, uint32_t size)
{
    if (!src || !size)
        return false;

    uint32_t width[3];
    uint32_t height[3];
    uint32_t offset[3];
    uint32_t off = 0;
    uint32_t planes;
    getPlaneResolution(width, height, planes);
    for (int i = 0; i < planes; i++) {
        offset[i] = off;
        off += width[i] * height[i];
    }
    if (size != off)
        return false;
    VAImagePtr& image =  m_image->m_image;
    uint8_t* dest = reinterpret_cast<uint8_t*>(m_handle);
    return copy(dest, image->offsets, image->pitches,
        (uint8_t*)src, offset, width, width, height, planes);
}