static void unref_image(struct gl_hwdec *hw) { struct priv *p = hw->priv; VAStatus status; for (int n = 0; n < 4; n++) { if (p->images[n]) p->DestroyImageKHR(eglGetCurrentDisplay(), p->images[n]); p->images[n] = 0; } va_lock(p->ctx); if (p->buffer_acquired) { status = vaReleaseBufferHandle(p->display, p->current_image.buf); CHECK_VA_STATUS(p, "vaReleaseBufferHandle()"); p->buffer_acquired = false; } if (p->current_image.image_id != VA_INVALID_ID) { status = vaDestroyImage(p->display, p->current_image.image_id); CHECK_VA_STATUS(p, "vaDestroyImage()"); p->current_image.image_id = VA_INVALID_ID; } mp_image_unrefp(&p->current_ref); va_unlock(p->ctx); }
bool VaapiImage::unmap() { VAStatus status; if (!m_isMapped) return true; switch(m_rawImage.memoryType) { case VIDEO_DATA_MEMORY_TYPE_RAW_POINTER: case VIDEO_DATA_MEMORY_TYPE_RAW_COPY: status = vaUnmapBuffer(m_display->getID(), m_image->buf); if (!checkVaapiStatus(status, "vaUnmapBuffer()")) return false; break; case VIDEO_DATA_MEMORY_TYPE_DRM_NAME: case VIDEO_DATA_MEMORY_TYPE_DMA_BUF: status = vaReleaseBufferHandle(m_display->getID(), m_image->buf); if (!checkVaapiStatus(status, "vaReleaseBufferHandle()")) return false; break; default: ASSERT(0); break; } m_isMapped = false; return true; }
EglVaapiImage::~EglVaapiImage() { if (m_inited) { if (m_acquired) vaReleaseBufferHandle(m_display, m_image.buf); vaDestroyImage(m_display, m_image.image_id); } }
bool EglVaapiImage::blt(const VideoFrameRawData& src) { if (!m_inited) { ERROR("call init before blt!"); return false; } if (m_acquired) vaReleaseBufferHandle(m_display, m_image.buf); VAStatus vaStatus = vaGetImage(m_display, src.internalID, 0, 0, src.width, src.height, m_image.image_id); // incomplete data yet m_frameInfo.timeStamp = src.timeStamp; m_frameInfo.flags = src.flags; return checkVaapiStatus(vaStatus, "vaGetImage"); }
bool EglVaapiImage::blt(const SharedPtr<VideoFrame>& src) { if (!m_inited) { ERROR("call init before blt!"); return false; } if (m_acquired) vaReleaseBufferHandle(m_display, m_image.buf); VAStatus vaStatus = vaGetImage(m_display, (VASurfaceID)src->surface, src->crop.x, src->crop.y, src->crop.width, src->crop.height, m_image.image_id); // incomplete data yet m_frameInfo.timeStamp = src->timeStamp; m_frameInfo.flags = src->flags; return checkVaapiStatus(vaStatus, "vaGetImage"); }