Example #1
0
SharedPtr<VideoFrame> VaapiDecoderBase::getOutput()
{
    SharedPtr<VideoFrame> frame;
    DecSurfacePoolPtr pool = m_surfacePool;
    if (!pool)
        return frame;
    VideoRenderBuffer *buffer = pool->getOutput();
    if (buffer) {
        frame.reset(new VideoFrame, BufferRecycler(pool, buffer));
        frame->surface = (intptr_t)buffer->surface;
        frame->timeStamp = buffer->timeStamp;
        frame->crop.x = 0;
        frame->crop.y = 0;
        frame->crop.width = m_videoFormatInfo.width;
        frame->crop.height = m_videoFormatInfo.height;
    }
    return frame;
}
DecSurfacePoolPtr VaapiDecSurfacePool::create(const DisplayPtr& display, VideoConfigBuffer* config)
{
    DecSurfacePoolPtr pool;
    std::vector<SurfacePtr> surfaces;
    size_t size = config->surfaceNumber;
    surfaces.reserve(size);
    assert(!(config->flag & WANT_SURFACE_PROTECTION));
    assert(!(config->flag & USE_NATIVE_GRAPHIC_BUFFER));
    assert(!(config->flag & WANT_RAW_OUTPUT));
    for (size_t i = 0; i < size; ++i) {
        SurfacePtr s = VaapiSurface::create(display, VAAPI_CHROMA_TYPE_YUV420,
                                   config->width,config->height,NULL,0);
        if (!s)
            return pool;
        surfaces.push_back(s);
    }
    pool.reset(new VaapiDecSurfacePool(display, surfaces));
}
Example #3
0
SharedPtr<VideoFrame> VaapiDecoderBase::getOutput()
{
    SharedPtr<VideoFrame> frame;
    DecSurfacePoolPtr pool = m_surfacePool;
    if (!pool)
        return frame;
    VideoRenderBuffer *buffer = pool->getOutput();
    if (buffer) {
        frame.reset(new VideoFrame, BufferRecycler(pool, buffer));
        memset(frame.get(), 0, sizeof(VideoFrame));
        frame->surface = (intptr_t)buffer->surface;
        frame->timeStamp = buffer->timeStamp;
        frame->crop.x = 0;
        frame->crop.y = 0;
        frame->crop.width = m_videoFormatInfo.width;
        frame->crop.height = m_videoFormatInfo.height;
        //TODO: get fourcc directly from surface allocator
        frame->fourcc = YAMI_FOURCC_NV12;
    }
    return frame;
}