Decode_Status VaapiDecoderH264::decodeSlice(H264NalUnit * nalu)
{
    Decode_Status status;
    VaapiPictureH264 *picture;
    VaapiSliceH264 *slice = NULL;
    H264SliceHdr *sliceHdr;
    H264SliceHdr tmpSliceHdr;
    H264ParserResult result;

    /* parser the slice header info */
    memset((void *) &tmpSliceHdr, 0, sizeof(tmpSliceHdr));
    result = h264_parser_parse_slice_hdr(&m_parser, nalu,
                                         &tmpSliceHdr, true, true);
    if (result != H264_PARSER_OK) {
        status = getStatus(result);
        goto error;
    }

    /* check info and reset VA resource if necessary */
    status = ensureContext(tmpSliceHdr.pps);
    if (status != DECODE_SUCCESS)
        return status;

    /* construct slice and parsing slice header */
    slice = new VaapiSliceH264(m_VADisplay,
                               m_VAContext,
                               nalu->data + nalu->offset, nalu->size);
    sliceHdr = &(slice->m_sliceHdr);

    memcpy((void *) sliceHdr, (void *) &tmpSliceHdr, sizeof(*sliceHdr));

    if (isNewPicture(nalu, sliceHdr)) {
        status = decodePicture(nalu, sliceHdr);
        if (status != DECODE_SUCCESS)
            goto error;
    }

    if (!fillSlice(slice, nalu)) {
        status = DECODE_FAIL;
        goto error;
    }

    m_currentPicture->addSlice((VaapiSlice *) slice);

    return DECODE_SUCCESS;

  error:
    if (slice)
        delete slice;
    return status;
}
Exemplo n.º 2
0
Decode_Status VaapiDecoderH265::decodeSlice(H265NalUnit *nalu)
{
    SharedPtr<H265SliceHdr> currSlice(new H265SliceHdr(), h265SliceHdrFree);
    H265SliceHdr* slice = currSlice.get();
    H265ParserResult result;
    Decode_Status status;

    memset(slice, 0, sizeof(H265SliceHdr));
    result = h265_parser_parse_slice_hdr(m_parser, nalu, slice);
    if (result == H265_PARSER_ERROR) {
        return DECODE_INVALID_DATA;
    }
    if (result == H265_PARSER_BROKEN_LINK) {
        return DECODE_SUCCESS;
    }
    status = ensureContext(slice->pps->sps);
    if (status != DECODE_SUCCESS) {
        return status;
    }
    if (slice->first_slice_segment_in_pic_flag) {
        status = decodeCurrent();
        if (status != DECODE_SUCCESS)
            return status;
        m_current = createPicture(slice, nalu);
        if (m_noRaslOutputFlag && isRasl(nalu))
            return DECODE_SUCCESS;
        if (!m_current || !m_dpb.init(m_current, slice, nalu, m_newStream))
            return DECODE_INVALID_DATA;
        if (!fillPicture(m_current, slice) || !fillIqMatrix(m_current, slice))
            return DECODE_FAIL;
    }
    if (!m_current)
        return DECODE_FAIL;
    if (!fillSlice(m_current, slice, nalu))
        return DECODE_FAIL;
    if (!slice->dependent_slice_segment_flag)
        std::swap(currSlice, m_prevSlice);
    return status;

}
Exemplo n.º 3
0
void TumblerWindow::newData(TumblerStruct *xtum)
{
  setSteps(xtum);
  fillSlice(xtum);
  return;
}