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

📄 umc_mpeg2_dec_mc.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  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;static short zero_mem[256];void MPEG2VideoDecoderBase::mc_mp2_420b_frame(short* diff, int threadID){  IppVideoContext*   video = &Video[threadID];  sMacroblock       *pMacro = &Video[threadID].macroblock;  Ipp8u *ref_Y_data1, *ref_U_data1;  Ipp8u *ref_Y_data2, *ref_U_data2;  Ipp8u *ref_Y_data3, *ref_U_data3;  Ipp8u *ref_Y_data4, *ref_U_data4;  Ipp8u *ref_V_data1 = 0, *ref_V_data2 = 0, *ref_V_data3 = 0, *ref_V_data4 = 0;  Ipp8u *cur_Y_data = pMacro->blkCurrYUV[0];  Ipp8u *cur_U_data = pMacro->blkCurrYUV[1];  Ipp8u *cur_V_data = pMacro->blkCurrYUV[2];  unsigned int        flag1, flag2, flag3, flag4;  int                 offs_uv1, offs_uv2, offs_y1, offs_y2;  unsigned int        pitch_Y, pitch_UV;  unsigned int        pitch_Y_2, pitch_UV_2;  ref_Y_data1 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].Y_comp_data;  ref_U_data1 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].U_comp_data;  ref_Y_data2 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].Y_comp_data;  ref_U_data2 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].U_comp_data;  ref_Y_data3 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].Y_comp_data;  ref_U_data3 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].U_comp_data;  ref_Y_data4 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].Y_comp_data;  ref_U_data4 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].U_comp_data;  ref_V_data1 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].V_comp_data;  ref_V_data2 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].V_comp_data;  ref_V_data3 = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].V_comp_data;  ref_V_data4 = video->frame_buffer.frame_p_c_n[video->frame_buffer.next_index].V_comp_data;  pitch_Y   =  video->frame_buffer.Y_comp_pitch;  pitch_UV  =  video->frame_buffer.U_comp_pitch;  pitch_Y_2   =  video->frame_buffer.Y_comp_pitch << 1;  pitch_UV_2  =  video->frame_buffer.U_comp_pitch << 1;  if(pMacro->prediction_type == IPPVC_MC_FRAME)  {    CALC_OFFSETS_FRAME(offs_y1, offs_uv1, flag1, flag2, pMacro->vector[0], pMacro->vector[1], HP_FLAG_MC)    CALC_OFFSETS_FRAME(offs_y2, offs_uv2, flag3, flag4, pMacro->vector[2], pMacro->vector[3], HP_FLAG_MC)    FUNC_MCB(16, 16, Frame, ref_Y_data1 + offs_y1, pitch_Y, flag1,      ref_Y_data2 + offs_y2, pitch_Y, flag3,      diff, 32,      cur_Y_data,      pitch_Y, 0);    FUNC_MCB(8, 8, Frame, ref_U_data1 + offs_uv1, pitch_UV, flag2,        ref_U_data2 + offs_uv2, pitch_UV, flag4,        diff + 256, 16,        cur_U_data,        pitch_UV, 0);    FUNC_MCB(8, 8, Frame, ref_V_data1 + offs_uv1, pitch_UV, flag2,        ref_V_data2 + offs_uv2, pitch_UV, flag4,        diff + 320, 16,        cur_V_data,        pitch_UV, 0);  }  else  {    CALC_OFFSETS_FIELD(offs_y1, offs_uv1, flag1, flag2, pMacro->vector[0], pMacro->vector[1], pMacro->motion_vertical_field_select[0], HP_FLAG_MC)    CALC_OFFSETS_FIELD(offs_y2, offs_uv2, flag3, flag4, pMacro->vector[2], pMacro->vector[3], pMacro->motion_vertical_field_select[1], HP_FLAG_MC)    FUNC_MCB(16, 8, FieldDCT, ref_Y_data1 + offs_y1, pitch_Y_2, flag1,      ref_Y_data2 + offs_y2, pitch_Y_2, flag3,      diff, 64,      cur_Y_data, pitch_Y_2,  0);    FUNC_MCB(8, 4, FieldDCT, ref_U_data1 + offs_uv1, pitch_UV_2, flag2,        ref_U_data2 + offs_uv2, pitch_UV_2, flag4,        diff + 256, 32,        cur_U_data, pitch_UV_2, 0);    FUNC_MCB(8, 4, FieldDCT, ref_V_data1 + offs_uv1, pitch_UV_2, flag2,        ref_V_data2 + offs_uv2, pitch_UV_2, flag4,        diff + 320, 32,        cur_V_data, pitch_UV_2,  0);    if( pMacro->motion_vector_count == 2)    {      CALC_OFFSETS_FIELD(offs_y1, offs_uv1, flag1, flag2, pMacro->vector[4], pMacro->vector[5], pMacro->motion_vertical_field_select[2], HP_FLAG_MC)      CALC_OFFSETS_FIELD(offs_y2, offs_uv2, flag3, flag4, pMacro->vector[6], pMacro->vector[7], pMacro->motion_vertical_field_select[3], HP_FLAG_MC)      FUNC_MCB(16, 8, FieldDCT, ref_Y_data1 + offs_y1, pitch_Y_2, flag1,        ref_Y_data2 + offs_y2, pitch_Y_2, flag3,        diff + 16, 64,        cur_Y_data  + pitch_Y, pitch_Y_2,  0);      FUNC_MCB(8, 4, FieldDCT, ref_U_data1 + offs_uv1, pitch_UV_2, flag2,          ref_U_data2 + offs_uv2, pitch_UV_2, flag4,          diff + 256 + 8, 32,          cur_U_data  + pitch_UV , pitch_UV_2, 0);      FUNC_MCB(8, 4, FieldDCT, ref_V_data1 + offs_uv1, pitch_UV_2, flag2,          ref_V_data2 + offs_uv2, pitch_UV_2, flag4,          diff + 320 + 8, 32,          cur_V_data  + pitch_UV, pitch_UV_2,  0);    }  }}void MPEG2VideoDecoderBase::mc_mp2_420_frame_zero(int threadID){  IppVideoContext *video = &Video[threadID];  sMacroblock *pMacro = &Video[threadID].macroblock;  int ref_index = (pMacro->macroblock_motion_backward) ? video->frame_buffer.next_index : video->frame_buffer.prev_index;  Ipp8u *ref_Y_data = video->frame_buffer.frame_p_c_n[ref_index].Y_comp_data;  Ipp8u *ref_U_data = video->frame_buffer.frame_p_c_n[ref_index].U_comp_data;  Ipp8u *ref_V_data = video->frame_buffer.frame_p_c_n[ref_index].V_comp_data;  Ipp8u *cur_Y_data = pMacro->blkCurrYUV[0];  Ipp8u *cur_U_data = pMacro->blkCurrYUV[1];  Ipp8u *cur_V_data = pMacro->blkCurrYUV[2];  unsigned int pitch_Y  = video->frame_buffer.Y_comp_pitch;  unsigned int pitch_UV = video->frame_buffer.U_comp_pitch;  unsigned int pitch_Y_2  = video->frame_buffer.Y_comp_pitch << 1;  unsigned int pitch_UV_2 = video->frame_buffer.U_comp_pitch << 1;  unsigned int flag1, flag2;  int offs_uv1, offs_y1;  short *vector = pMacro->vector;  if (pMacro->macroblock_motion_backward) vector += 2;  if(pMacro->prediction_type == IPPVC_MC_FRAME)  {    CALC_OFFSETS_FRAME(offs_y1, offs_uv1, flag1, flag2, vector[0], vector[1], HP_FLAG_CP)    MCZERO_FRAME(ref_Y_data + offs_y1, ref_U_data + offs_uv1, ref_V_data + offs_uv1, flag1, flag2)  }  else  {    int *motion_vertical_field_select = pMacro->motion_vertical_field_select;    if (pMacro->macroblock_motion_backward) motion_vertical_field_select++;    CALC_OFFSETS_FIELD(offs_y1, offs_uv1, flag1, flag2, vector[0], vector[1], motion_vertical_field_select[0], HP_FLAG_CP)    MCZERO_FIELD0(ref_Y_data + offs_y1, ref_U_data + offs_uv1, ref_V_data + offs_uv1, flag1, flag2)    if(pMacro->motion_vector_count == 2) {      CALC_OFFSETS_FIELD(offs_y1, offs_uv1, flag1, flag2, vector[4], vector[5], motion_vertical_field_select[2], HP_FLAG_CP)      MCZERO_FIELD1(ref_Y_data + offs_y1, ref_U_data + offs_uv1, ref_V_data + offs_uv1, flag1, flag2)    }  }}void MPEG2VideoDecoderBase::mc_mp2_420_field(short* diff, int threadID){  IppVideoContext *video = &Video[threadID];  sMacroblock *pMacro = &Video[threadID].macroblock;  int offs_uv, offs_y;  unsigned int pitch_Y  = video->frame_buffer.Y_comp_pitch;  unsigned int pitch_UV = video->frame_buffer.U_comp_pitch;  Ipp8u *ref_Y_data;  Ipp8u *ref_U_data;  Ipp8u *ref_V_data;  Ipp8u *cur_Y_data;  Ipp8u *cur_U_data;  Ipp8u *cur_V_data;  unsigned int flag1, flag2;  int ref_index;  cur_Y_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].Y_comp_data;  cur_U_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].U_comp_data;  cur_V_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].V_comp_data;  if(pMacro->prediction_type == IPPVC_MC_FIELD)  {    ref_index = video->frame_buffer.prev_index;    if (PictureHeader.field_buffer_index)    {      if(PictureHeader.picture_structure + pMacro->motion_vertical_field_select[0] == BOTTOM_FIELD)      {        ref_index = video->frame_buffer.curr_index;      }    }    ref_Y_data = video->frame_buffer.frame_p_c_n[ref_index].Y_comp_data;    ref_U_data = video->frame_buffer.frame_p_c_n[ref_index].U_comp_data;    ref_V_data = video->frame_buffer.frame_p_c_n[ref_index].V_comp_data;    cur_Y_data += pMacro->offset_l;    cur_U_data += pMacro->offset_c;    cur_V_data += pMacro->offset_c;    pMacro->offset_l = 2*pMacro->row_l * pitch_Y  + pMacro->col_l;    pMacro->offset_c = 2*pMacro->row_c * pitch_UV + pMacro->col_c;    short *vector = pMacro->vector;    if (pMacro->macroblock_motion_backward) vector += 2;    int *motion_vertical_field_select = pMacro->motion_vertical_field_select;    if (pMacro->macroblock_motion_backward) motion_vertical_field_select++;    CALC_OFFSETS_FIELD(offs_y, offs_uv, flag1, flag2, vector[0], vector[1], motion_vertical_field_select[0], HP_FLAG_MC)    pitch_Y *= 2;    pitch_UV *= 2;    MC_16x16(Field, ref_Y_data + offs_y, ref_U_data + offs_uv, ref_V_data + offs_uv, flag1, flag2)  }  else  {    int i, r;    pitch_Y *= 2;    pitch_UV *= 2;    for(r = 0; r < pMacro->motion_vector_count; r++)    {      ref_Y_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].Y_comp_data;      ref_U_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].U_comp_data;      ref_V_data = video->frame_buffer.frame_p_c_n[video->frame_buffer.prev_index].V_comp_data;      if(PictureHeader.field_buffer_index)      {        //if(PictureHeader.top_field_first)        if(PictureHeader.picture_structure == BOTTOM_FIELD)        {          if(!pMacro->motion_vertical_field_select[2*r])          {            ref_Y_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].Y_comp_data;            ref_U_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].U_comp_data;            ref_V_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].V_comp_data;          }        }        else        {          if(pMacro->motion_vertical_field_select[2*r])          {            ref_Y_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].Y_comp_data;            ref_U_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].U_comp_data;            ref_V_data  = video->frame_buffer.frame_p_c_n[video->frame_buffer.curr_index].V_comp_data;          }        }      }//if(field_buffer_index)      offs_uv = (pMacro->vector_chroma[4*r + 1]  + pMacro->row_c + 4*r)* (pitch_UV) +        pMacro->vector_chroma[4*r] + pMacro->col_c + pMacro->motion_vertical_field_select[2*r]*(pitch_UV>>1);      offs_y = (pMacro->vector_luma[4*r + 1]  + pMacro->row_l + 8 * r)*(pitch_Y) +        pMacro->vector_luma[4*r] + pMacro->col_l + pMacro->motion_vertical_field_select[2*r]*(pitch_Y>>1);      flag1 = ((pMacro->vector[4*r]  & 1) << 3) | ((pMacro->vector[4*r + 1]  & 1) << 2);      flag2 = ((pMacro->vector[4*r]/2 & 1) << 3) | ((pMacro->vector[4*r + 1]/2 & 1) << 2);      i = ippiMC16x8_8u_C1(   ref_Y_data + offs_y, pitch_Y,        video->block.idct+128*r,32,        cur_Y_data + pMacro->offset_l + (pitch_Y)*r*8,        pitch_Y, flag1, 0);      VM_ASSERT(i == ippStsOk);      i = ippiMC8x4_8u_C1(    ref_U_data + offs_uv, pitch_UV,        video->block.idct+256+32*r,16,        cur_U_data + pMacro->offset_c + (pitch_UV)*r*4,        pitch_UV, flag2, 0);      VM_ASSERT(i == ippStsOk);      i = ippiMC8x4_8u_C1(    ref_V_data + offs_uv, pitch_UV,        video->block.idct+320+32*r,16,        cur_V_data + pMacro->offset_c + (pitch_UV)*r*4,        pitch_UV, flag2, 0);      VM_ASSERT(i == ippStsOk);    }//for(r)  }}void MPEG2VideoDecoderBase::mc_mp2_422(short* diff, int threadID){    IppVideoContext* video = &Video[threadID];    sMacroblock       *pMacro = &Video[threadID].macroblock;    int r, i;    Ipp8u *ref_Y_data, *ref_U_data, *ref_V_data = 0;    Ipp8u *ref_Y_data1, *ref_U_data1, *ref_V_data1 = 0;    Ipp8u *ref_Y_data2, *ref_U_data2, *ref_V_data2 = 0;

⌨️ 快捷键说明

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