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

📄 umc_mpeg2_dec_slice.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 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) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include "umc_mpeg2_dec_base.h"#pragma warning(disable: 4244)using namespace UMC;Status MPEG2VideoDecoderBase::DecodeSliceHeader(int threadID){    unsigned int    extra_bit_slice;    unsigned int    code;    IppVideoContext *video  = &Video[threadID];    sMacroblock     *pMacro = &Video[threadID].macroblock;    sSlice          *pSlice = &Video[threadID].slice;    GET_START_CODE(video->bs, code)    if(code == (Ipp32u)UMC_NOT_ENOUGH_DATA) {      SKIP_BITS_32(video->bs);    }    if(code == (Ipp32u)UMC_NOT_ENOUGH_DATA ||       code == PICTURE_START_CODE ||       code > 0x1AF)    {      return UMC_NOT_ENOUGH_DATA;    }    pSlice->slice_vertical_position = (code & 0xff);    if(sequenceHeader.vertical_size > 2800)    {        if(pSlice->slice_vertical_position > 0x80)          return UMC_BAD_STREAM;        GET_TO9BITS(video->bs, 3, /*pSlice->slice_vertical_position_extension*/code)        pSlice->slice_vertical_position += code << 7;    }    if( pSlice->slice_vertical_position > PictureHeader.max_slice_vert_pos)      return UMC_BAD_STREAM;    if((sequenceHeader.extension_start_code_ID == SEQUENCE_SCALABLE_EXTENSION_ID) &&        (sequenceHeader.scalable_mode == DATA_PARTITIONING))    {        GET_TO9BITS(video->bs, 7, code)        return UMC_UNSUPPORTED;    }    RESET_PMV(pMacro->PMV)    pSlice->macroblock_motion_forward_prev  =  0;    pSlice->macroblock_motion_backward_prev =  0;    GET_TO9BITS(video->bs, 5, pSlice->quantizer_scale)    if(pSlice->quantizer_scale == 0)    {        return UMC_BAD_STREAM;    }    pSlice->cur_q_scale = q_scale[PictureHeader.q_scale_type][pSlice->quantizer_scale];    GET_1BIT(video->bs,extra_bit_slice)    while(extra_bit_slice)    {        GET_TO9BITS(video->bs, 9, code)        extra_bit_slice = code & 1;    }    video->slice.m_bNewSlice = true;    return UMC_OK;}Status MPEG2VideoDecoderBase::GetMBposition(int threadID){    unsigned int     code;    IppVideoContext *video  = &Video[threadID];    int macroblock_address_increment = 0;    SHOW_BITS(video->bs,11,code)    if(code == 0)      return UMC_BAD_STREAM; // end of slice or bad code. Anyway, stop slice    while(code == 0x008)    {        macroblock_address_increment += 33;//macroblock_escape        GET_BITS(video->bs, 11, code);        SHOW_BITS(video->bs,11,code)    }    DECODE_VLC(code, video->bs, vlcMBAdressing);    if (GET_REMAINED_BYTES(video->bs) <= 0)      return UMC_BAD_STREAM;    macroblock_address_increment += code;    if(macroblock_address_increment > 1 || video->slice.m_bNewSlice)      video->slice.dct_dc_y_past  =      video->slice.dct_dc_cb_past =      video->slice.dct_dc_cr_past = PictureHeader.curr_reset_dc;    if(video->slice.m_bNewSlice) {      video->slice.mb_row = video->slice.slice_vertical_position - 1;      video->slice.mb_col = macroblock_address_increment - 1;      video->slice.mb_address_increment = 1;      video->slice.mb_row_prev = video->slice.mb_row;      video->slice.mb_col_prev = video->slice.mb_col;      video->slice.m_bNewSlice = false;    } else {      video->slice.mb_address_increment = macroblock_address_increment;      video->slice.mb_row_prev = video->slice.mb_row;      video->slice.mb_col_prev = video->slice.mb_col+1;      video->slice.mb_col += macroblock_address_increment;      if(video->slice.mb_col >= sequenceHeader.mb_width) {        if(sequenceHeader.stream_type != MPEG1_VIDEO)          return UMC_BAD_STREAM;        video->slice.mb_row += video->slice.mb_col / sequenceHeader.mb_width;        if(video->slice.mb_row >= sequenceHeader.mb_height)           return UMC_BAD_STREAM;        video->slice.mb_col %= sequenceHeader.mb_width;        // prev points to this or first skipped, could change row in mpeg1        video->slice.mb_row_prev += video->slice.mb_col_prev / sequenceHeader.mb_width;        video->slice.mb_col_prev %= sequenceHeader.mb_width;      }    }    return UMC_OK;}Status MPEG2VideoDecoderBase::DecodeSlice(int threadID){    unsigned int     code;    IppVideoContext *video  = &Video[threadID];    sSlice          *pSlice = &Video[threadID].slice;    Status           umcRes = UMC_OK;    if(sequenceHeader.stream_type == MPEG1_VIDEO) {      pSlice->dct_dc_y_past      = 1024;      pSlice->dct_dc_cb_past     = 1024;      pSlice->dct_dc_cr_past     = 1024;      do {          //stuffing is here for a while          SHOW_BITS(video->bs,11,code)          while(code == 0x00f) {              GET_BITS(video->bs, 11, code);//macroblock_stuffing              SHOW_BITS(video->bs,11,code)          }          if(UMC_OK != GetMBposition(threadID))            return UMC_OK;          umcRes = Macroblock_mpeg1(threadID);      } while (UMC_OK == umcRes);      return umcRes;    }    switch(sequenceHeader.chroma_format)    {    case CHROMA_420:        if(PictureHeader.picture_structure == IPPVC_FRAME_PICTURE)        {            switch(PictureHeader.picture_coding_type)            {            case I_FRAME:                do {                    if(UMC_OK != GetMBposition(threadID))                      return UMC_OK;                    umcRes = Macroblock_420_I_frame(threadID);                } while (UMC_OK == umcRes);                break;            case P_FRAME:            case B_FRAME:                do {                    if(UMC_OK != GetMBposition(threadID))                      return UMC_OK;                    umcRes = Macroblock_420_frame(threadID);                } while (UMC_OK == umcRes);                break;            default:                VM_ASSERT(0);                umcRes =  UMC_BAD_STREAM;            }        }        else        {            switch(PictureHeader.picture_coding_type)            {            case I_FRAME:                do {                    if(UMC_OK != GetMBposition(threadID))                      return UMC_OK;                    umcRes = Macroblock_420_I_field(threadID);                } while (UMC_OK == umcRes);                break;            case P_FRAME:                do {                    if(UMC_OK != GetMBposition(threadID))                      return UMC_OK;                    umcRes = Macroblock_420_P_field(threadID);                } while (UMC_OK == umcRes);                break;            case B_FRAME:                do {                    if(UMC_OK != GetMBposition(threadID))                      return UMC_OK;                    umcRes = Macroblock_420_B_field(threadID);                } while (UMC_OK == umcRes);                break;            default:                VM_ASSERT(0);                return UMC_BAD_STREAM;            }        }        break;    case CHROMA_422:        do {            if(UMC_OK != GetMBposition(threadID))              return UMC_OK;            umcRes = Macroblock_422(threadID);        } while (UMC_OK == umcRes);        break;      case CHROMA_444:        do {            if(UMC_OK != GetMBposition(threadID))              return UMC_OK;            umcRes = Macroblock_444(threadID);        } while (UMC_OK == umcRes);        break;      default:          VM_ASSERT(0);          return UMC_BAD_STREAM;    }    return umcRes;}

⌨️ 快捷键说明

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