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

📄 h263decframeb.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ///////////////////////////////////////////////////////////////////////////               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) 2005 Intel Corporation. All Rights Reserved.////  Description:    Decodes B-Frames//*/#include "h263.h"#include "h263dec.h"static h263_Status h263_PredictDecodeMV_B(h263_Info *pInfo, IppMotionVector *mvPred, IppMotionVector *mvCurr, int frGOB, int y, int x){  IppMotionVector *mvLeft, *mvTop, *mvRight;  h263_Status status;  h263_VideoPicture *VPic = &pInfo->VideoSequence.VideoPicture;  int  mbInRow = VPic->MacroBlockPerRow;  mvLeft  = &mvPred[x-1];  mvTop   = &mvPred[x];  mvRight = &mvPred[x+1];  if (y == frGOB && x == 0) {    mvCurr->dx = mvCurr->dy = 0;  } else if (x == 0) {    mvCurr->dx = h263_Median(0, mvTop->dx, mvRight->dx);    mvCurr->dy = h263_Median(0, mvTop->dy, mvRight->dy);  } else if (y == frGOB) {    *mvCurr = *mvLeft;  } else if (x == mbInRow - 1) {    mvCurr->dx = h263_Median(0, mvLeft->dx, mvTop->dx);    mvCurr->dy = h263_Median(0, mvLeft->dy, mvTop->dy);  } else {    mvCurr->dx = h263_Median(mvLeft->dx, mvTop->dx, mvRight->dx);    mvCurr->dy = h263_Median(mvLeft->dy, mvTop->dy, mvRight->dy);  }  if (!VPic->oppmodes.UMV && !VPic->modes.UMV) {    status = h263_DecodeMV(pInfo, mvCurr, -32, 31);  } else if (!VPic->oppmodes.UMV) {    status = h263_DecodeMV(pInfo, mvCurr, -63, 63);  } else {    int mvdx, mvdy;    status = h263_DecodeMVD_umvplus(pInfo, &mvdx, &mvdy);    mvCurr->dx = mvCurr->dx + (Ipp16s)mvdx;    mvCurr->dy = mvCurr->dy + (Ipp16s)mvdy;  }  *mvTop = *mvCurr; /* updating the predictor */  return status;}static void h263_CalculateMV_Direct(IppMotionVector *mvC, IppMotionVector *mvF, IppMotionVector *mvB,                                    IppMotionVector *mvCbCrF, IppMotionVector *mvCbCrB,                                    int trd, int trb, int mb_typeC, int dx, int dy,                                    IppiRect *limitRectL, IppiRect *limitRectC){  int i;  if (mb_typeC == IPPVC_MBTYPE_INTER4V || mb_typeC == IPPVC_MBTYPE_INTER4V_Q) {    for (i = 0; i < 4; i++) {      mvF[i].dx = (Ipp16s)(mvC[i].dx * trb / trd);      mvF[i].dy = (Ipp16s)(mvC[i].dy * trb / trd);      mvB[i].dx = (Ipp16s)((trb - trd) * mvC[i].dx / trd);      mvB[i].dy = (Ipp16s)((trb - trd) * mvC[i].dy / trd);    }    h263_Limit4MV(mvF, mvF, limitRectL, dx, dy, 8);    h263_Limit4MV(mvB, mvB, limitRectL, dx, dy, 8);    h263_ComputeChroma4MV(mvF, mvCbCrF);    h263_ComputeChroma4MV(mvB, mvCbCrB);    h263_LimitMV(mvCbCrF, mvCbCrF, limitRectC, dx >> 1, dy >> 1, 8);    h263_LimitMV(mvCbCrB, mvCbCrB, limitRectC, dx >> 1, dy >> 1, 8);  } else {    mvF[0].dx = (Ipp16s)(mvC[0].dx * trb / trd);    mvF[0].dy = (Ipp16s)(mvC[0].dy * trb / trd);    mvB[0].dx = (Ipp16s)((trb - trd) * mvC[0].dx / trd);    mvB[0].dy = (Ipp16s)((trb - trd) * mvC[0].dy / trd);    h263_LimitMV(mvF, mvF, limitRectL, dx, dy, 16);    h263_LimitMV(mvB, mvB, limitRectL, dx, dy, 16);    h263_ComputeChromaMV(mvF, mvCbCrF);    h263_ComputeChromaMV(mvB, mvCbCrB);  }}/*//  Purpose:  decode H.263 B-Frame*/h263_Status h263_DecodeFrame_B(h263_Info* pInfo, h263_EnhancedLayer *Layer, h263_Frame *rFrame){  __ALIGN16(Ipp16s, coeffMB, 64*2);  __ALIGN16(Ipp8u, tmpMB, 64*4*2);  Ipp8u           *pYc, *pCbc, *pCrc, *pYn, *pCbn, *pCrn, *pYr, *pCbr, *pCrr, *pF[6];  int             stepYc, stepYn, stepCbc, stepCbn, stepCrc, stepCrn;  int             stepYr, stepCbr, stepCrr, mbPerRow, mbPerCol, stepF[6];  int             dx, dy, TRB, TRD, colNum, rowNum;  IppiRect        limitRectL, limitRectC;  int             mb_type, cbpy, cbpc;  int             quant, quant_c;  h263_MacroBlock *pMBinfo;  int             frGOB;  int             rt;  h263_VideoPicture *VPic = &pInfo->VideoSequence.VideoPicture;  int gob_header_present = 1;  int predMode = 0;  h263_Status status;  int num_rows_per_gob, num_gobs, row;  int i, k;  int cbpFlag, dquantFlag;  IppMotionVector mvCbCrF, mvCbCrB, mvForw[4], mvBack[4];  IppMotionVector *predMVF, *predMVB;  h263_IntraPredBlock  *b = pInfo->VideoSequence.IntraPredBuff.block;  int mb_not_coded;  IppiSize roiSize;  mbPerRow = pInfo->VideoSequence.VideoPicture.MacroBlockPerRow;  mbPerCol = pInfo->VideoSequence.VideoPicture.MacroBlockPerCol;  predMVF = &pInfo->VideoSequence.Bmv[0];  predMVB = &pInfo->VideoSequence.Bmv[mbPerRow];  /* B-frame in n, next (in displaying order) P - c, previous - r */  if (VPic->enh_layer_num == 1) {    stepYn = pInfo->VideoSequence.nFrame.stepY;    stepCbn = pInfo->VideoSequence.nFrame.stepCb;    stepCrn = pInfo->VideoSequence.nFrame.stepCr;    pYn = pInfo->VideoSequence.nFrame.pY;    pCbn = pInfo->VideoSequence.nFrame.pCb;    pCrn = pInfo->VideoSequence.nFrame.pCr;  } else {    stepYn = Layer->n_Frame.stepY;    stepCbn = Layer->n_Frame.stepCb;    stepCrn = Layer->n_Frame.stepCr;    pYn = Layer->n_Frame.pY;    pCbn = Layer->n_Frame.pCb;    pCrn = Layer->n_Frame.pCr;  }  if (VPic->ref_layer_num == 1) {    stepYc = pInfo->VideoSequence.cFrame.stepY;    stepCbc = pInfo->VideoSequence.cFrame.stepCb;    stepCrc = pInfo->VideoSequence.cFrame.stepCr;    pYc = pInfo->VideoSequence.cFrame.pY;    pCbc = pInfo->VideoSequence.cFrame.pCb;    pCrc = pInfo->VideoSequence.cFrame.pCr;  } else {    h263_EnhancedLayer *refLayer = pInfo->VideoSequence.enhLayers[VPic->ref_layer_num - 2];    stepYc = refLayer->c_Frame.stepY;    stepCbc = refLayer->c_Frame.stepCb;    stepCrc = refLayer->c_Frame.stepCr;    pYc = refLayer->c_Frame.pY;    pCbc = refLayer->c_Frame.pCb;    pCrc = refLayer->c_Frame.pCr;  }  stepYr = rFrame->stepY;  stepCbr = rFrame->stepCb;  stepCrr = rFrame->stepCr;  pYr = rFrame->pY;  pCbr = rFrame->pCb;  pCrr = rFrame->pCr;  stepF[0] = stepF[1] = stepF[2] = stepF[3] = stepYc; stepF[4] = stepCbc; stepF[5] = stepCrc;  // Bounding rectangles for MV limitation  limitRectL.x = -16;  limitRectL.y = -16;  limitRectL.width = pInfo->VideoSequence.VideoPicture.MacroBlockPerRow * 16 + 32;  limitRectL.height = pInfo->VideoSequence.VideoPicture.MacroBlockPerCol * 16 + 32;  limitRectC.x = -8;  limitRectC.y = -8;  limitRectC.width = pInfo->VideoSequence.VideoPicture.MacroBlockPerRow * 8 + 16;  limitRectC.height = pInfo->VideoSequence.VideoPicture.MacroBlockPerCol * 8 + 16;  quant = pInfo->VideoSequence.VideoPicture.pic_quant;  colNum = rowNum = 0;  TRD = pInfo->VideoSequence.TRD;  TRB = pInfo->VideoSequence.TRB;  pMBinfo = pInfo->VideoSequence.MBinfo;  quant = VPic->pic_quant;  pInfo->VideoSequence.VideoPicture.gob_number = 0;  num_gobs = pInfo->VideoSequence.VideoPicture.num_gobs_in_pic;  num_rows_per_gob = pInfo->VideoSequence.VideoPicture.RowsPerGOB;  rt = VPic->rtype;  dy = 0;  frGOB = 0;  for (i = 0; i < num_gobs; i++) {    VPic->gob_number = i;    if (i) {      gob_header_present = h263_ParseGOBHeader(pInfo);      if (gob_header_present < 0) {        h263_Error("Error: Invalid GOB header");        return H263_STATUS_PARSE_ERROR;      }      if (VPic->gob_number > 30)        return H263_STATUS_OK; /* EOS or EOSBS */      if (VPic->gob_number - i > 0) {        pYc += (stepYc << 4) * num_rows_per_gob * (VPic->gob_number - i);        pCbc += (stepCbc << 3) * num_rows_per_gob * (VPic->gob_number - i);        pCrc += (stepCrc << 3) * num_rows_per_gob * (VPic->gob_number - i);        pYr += (stepYr << 4) * num_rows_per_gob * (VPic->gob_number - i);        pCbr += (stepCbr << 3) * num_rows_per_gob * (VPic->gob_number - i);        pCrr += (stepCrr << 3) * num_rows_per_gob * (VPic->gob_number - i);        pYn += (stepYn << 4) * num_rows_per_gob * (VPic->gob_number - i);        pCbn += (stepCbn << 3) * num_rows_per_gob * (VPic->gob_number - i);        pCrn += (stepCrn << 3) * num_rows_per_gob * (VPic->gob_number - i);        pMBinfo += (VPic->gob_number - i) * num_rows_per_gob * mbPerRow;        ippsSet_8u(127, pInfo->VideoSequence.GOBboundary + i*num_rows_per_gob, (VPic->gob_number - i) * num_rows_per_gob);        i = VPic->gob_number;      }      if (gob_header_present) {        frGOB = i*num_rows_per_gob;        pInfo->VideoSequence.GOBboundary[frGOB] = 1;      }    }

⌨️ 快捷键说明

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