YamiStatus VaapiDecoderBase::outputPicture(const PicturePtr& picture)
{
    //TODO: reorder poc
    return m_surfacePool->output(picture->getSurface(),
               picture->m_timeStamp)
        ? YAMI_SUCCESS
        : YAMI_FAIL;
}
void VaapiDecoderVP9::updateReference(const PicturePtr& picture, const Vp9FrameHdr* hdr)
{
    uint8_t flag  = 1;
    uint8_t refresh_frame_flags;
    if (hdr->frame_type == VP9_KEY_FRAME) {
        refresh_frame_flags = 0xff;
    } else {
        refresh_frame_flags = hdr->refresh_frame_flags;
    }

    for (int i = 0; i < VP9_REF_FRAMES; i++) {
        if (refresh_frame_flags & flag) {
            m_reference[i] = picture->getSurface();
        }
        flag <<= 1;
    }
}
Decode_Status VaapiDecoderVP9::decode(const Vp9FrameHdr* hdr, const uint8_t* data, uint32_t size, uint64_t timeStamp)
{


    Decode_Status ret;
    ret = ensureContext(hdr);
    if (ret != DECODE_SUCCESS)
        return ret;

    PicturePtr picture = createPicture(timeStamp);
    if (!picture)
        return DECODE_MEMORY_FAIL;
    if (!picture->getSurface()->resize(hdr->width, hdr->height)) {
        ERROR("resize to %dx%d failed", hdr->width, hdr->height);
        return DECODE_MEMORY_FAIL;
    }

    if (hdr->show_existing_frame) {
        SurfacePtr& surface = m_reference[hdr->frame_to_show];
        if (!surface) {
            ERROR("frame to show is invalid, idx = %d", hdr->frame_to_show);
            return DECODE_SUCCESS;
        }
        picture->setSurface(surface);
        return outputPicture(picture);
    }

    if (!ensurePicture(picture, hdr))
        return DECODE_FAIL;
    if (!ensureSlice(picture, data, size))
        return DECODE_FAIL;
    ret = picture->decode();
    if (ret != DECODE_SUCCESS)
        return ret;
    updateReference(picture, hdr);
    if (hdr->show_frame)
        return outputPicture(picture);
    return DECODE_SUCCESS;
}