⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_avs_dec_slice.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
字号:
/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
//
*/

#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_DECODER)

#include "umc_avs_dec_slice.h"
#include "umc_avs_sequence_header.h"
#include "umc_avs_picture_header.h"
#include "umc_avs_dec_bit_stream.h"

namespace UMC
{

AVSSlice::AVSSlice(void)
{

} // AVSSlice::AVSSlice(void)

AVSSlice::~AVSSlice(void)
{

} // AVSSlice::~AVSSlice(void)

Status AVSSlice::Init(Ipp32u *pSrc,
                      size_t srcSize,
                      AVS_SEQUENCE_HEADER *pSeqHeader,
                      AVS_PICTURE_HEADER *pPicHeader)
{
    AVS_BIT_STREAM_CONTEXT ctx;
    Ipp32s MbYOffset;

    // check error(s)
    if ((NULL == pSrc) ||
        (NULL == pSeqHeader) ||
        (NULL == pPicHeader))
    {
        return UMC_ERR_NULL_PTR;
    }
    if ((VIDEO_SEQUENCE_START_CODE != pSeqHeader->video_sequence_start_code) &&
        (I_PICTURE_START_CODE != pPicHeader->picture_start_code) &&
        (BP_PICTURE_START_CODE != pPicHeader->picture_start_code))
    {
        return UMC_ERR_INVALID_PARAMS;
    }

    // initialize bit stream context
    ctx.src = pSrc;
    ctx.offset = 31;

    // decode slice header
    DecodeSlcHeader(&ctx, pSeqHeader, pPicHeader, &m_SlcHeader);
    if ((ctx.src > pSrc + srcSize) ||
        ((ctx.src == pSrc + srcSize) && (31 != ctx.offset)))
    {
         return UMC_ERR_FAILED;
    }

    // initialize decoding context
    memset(&m_decCtx, 0, sizeof(AVS_DECODING_CONTEXT));
    m_decCtx.MbFirst = m_SlcHeader.first_mb;
    m_decCtx.MbIndex = m_SlcHeader.first_mb;
    m_decCtx.MbWidth = (pSeqHeader->horizontal_size + 15) / 16;
    if (pPicHeader->picture_structure)
    {
        m_decCtx.MbHeight = (pSeqHeader->vertical_size + 15) / 16;
        MbYOffset = 0;
    }
    else
    {
        m_decCtx.MbHeight = ((pSeqHeader->vertical_size + 31) / 32);
        if (m_SlcHeader.isSecondField)
            MbYOffset = m_decCtx.MbHeight;
        else
            MbYOffset = 0;
    }
    m_decCtx.MbLast = m_decCtx.MbWidth * m_decCtx.MbHeight;
    m_decCtx.FixedQP = (pPicHeader->fixed_picture_qp) ?
                       (pPicHeader->fixed_picture_qp) :
                       (m_SlcHeader.fixed_slice_qp);
    m_decCtx.PreviousQP = (pPicHeader->fixed_picture_qp) ?
                          (pPicHeader->picture_qp) :
                          (m_SlcHeader.slice_qp);
    m_decCtx.SkipMbCount = -1;

    switch (pSeqHeader->chroma_format)
    {
    case AVS_CHROMA_422_FORMAT:
        m_decCtx.iNumberOfBlocks = 8;
        break;

    default:
        m_decCtx.iNumberOfBlocks = 6;
        break;
    }
    m_decCtx.isSecondField = m_SlcHeader.isSecondField;
    m_decCtx.m_pSlice = this;
    m_decCtx.m_pPicHeader = pPicHeader;
    m_decCtx.m_pSeqHeader = pSeqHeader;
    m_decCtx.m_pSlcHeader = &m_SlcHeader;
    m_decCtx.m_stream = ctx;
    if (0 == (pPicHeader->progressive_frame | pPicHeader->picture_structure))
    {
        m_decCtx.ScanType = 1;
    }
    m_bDecVacant = true;

    // initialize reconstructing context
    memset(&m_recCtx, 0, sizeof(AVS_RECONSTRUCTING_CONTEXT));
    m_recCtx.MbFirst = m_SlcHeader.first_mb;
    m_recCtx.MbIndex = m_SlcHeader.first_mb;
    m_recCtx.MbWidth = m_decCtx.MbWidth;
    m_recCtx.MbHeight = m_decCtx.MbHeight;
    m_recCtx.MbLast = m_decCtx.MbLast;

    m_recCtx.iNumberOfBlocks = m_decCtx.iNumberOfBlocks;
    m_recCtx.isSecondField = m_decCtx.isSecondField;
    m_recCtx.m_pSlice = this;
    m_recCtx.m_pPicHeader = pPicHeader;
    m_recCtx.m_pSeqHeader = pSeqHeader;
    m_recCtx.m_pSlcHeader = &m_SlcHeader;
    m_recCtx.MbX = 0;
    m_recCtx.MbY = ((m_SlcHeader.slice_vertical_position_extension << 7) |
                    (m_SlcHeader.slice_vertical_position)) - MbYOffset;
    m_bRecVacant = true;

    // initialize deblocking context
    memset(&m_debCtx, 0, sizeof(AVS_DEBLOCKING_CONTEXT));
    if (pPicHeader->loop_filter_disable)
    {
        m_debCtx.MbIndex = m_decCtx.MbLast;
        m_debCtx.MbLast = m_decCtx.MbLast;
    }
    else
    {
        m_debCtx.MbFirst = m_SlcHeader.first_mb;
        m_debCtx.MbIndex = m_SlcHeader.first_mb;
        m_debCtx.MbWidth = m_decCtx.MbWidth;
        m_debCtx.MbHeight = m_decCtx.MbHeight;
        m_debCtx.MbLast = m_decCtx.MbLast;

        m_debCtx.iNumberOfBlocks = m_decCtx.iNumberOfBlocks;
        m_debCtx.isSecondField = m_decCtx.isSecondField;
        m_debCtx.m_pSlice = this;
        m_debCtx.m_pPicHeader = pPicHeader;
        m_debCtx.m_pSeqHeader = pSeqHeader;
        m_debCtx.m_pSlcHeader = &m_SlcHeader;
        m_debCtx.MbX = 0;
        m_debCtx.MbY = m_recCtx.MbY;
    }
    m_bDebVacant = true;

    m_bError = false;

    return UMC_OK;

} // Status AVSSlice::Init(Ipp32u *pSrc,

Status AVSSlice::InitCoeffsBuffer(Ipp32s iMinPieceToWrite, Ipp32s iNumPieces)
{
    return m_coeffsBuf.Init(iMinPieceToWrite, iNumPieces);

} // Status AVSSlice::InitCoeffsBuffer(Ipp32s iMinPieceToWrite, Ipp32s iNumPieces)

size_t AVSSlice::GetCoeffsBufferSize(void)
{
    return m_coeffsBuf.GetBufferSize();

} // size_t AVSSlice::GetCoeffsBufferSize(void)

} // namespace UMC

#endif // #if defined(UMC_ENABLE_AVS_VIDEO_DECODER)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -