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

📄 vopsedec.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    iPicWidthUV_2   = iPicWidthUV_1 << 1;    iPicHeightUV_2  = iPicHeightUV_1 << 1;#endif#ifndef NEW_MAE_DRIVER    // Initialize to zero    memset (pMAERegs, 0, sizeof(reg_info));    m_iSizeYPlane		= iPicWidth * iPicHeight;     m_iSizeUVPlane	= (m_iSizeYPlane/4);#endif#ifdef ENABLE_INTERLACING    // Initialize the flip array (needed while writing back the final data)    nNumMBs = iPicWidth/16 * iPicHeight/16 * sizeof(char);    nFlipArray = (char *) malloc(nNumMBs);    // Calculate the correct offsets (Y & UV) for the InFrame reference frames    nIFYLoc	= ((iPicWidth + EXPANDY_REF_FRAMEx2) * EXPANDY_REF_FRAME) + EXPANDY_REF_FRAME;    nIFUVLoc	= ((iPicWidth/2 + EXPANDUV_REF_FRAMEx2) * EXPANDUV_REF_FRAME) + EXPANDUV_REF_FRAME;    // Allocate memory for the Out Of Frame reference frames    m_OOFFlipQ0_Y = (PixelC*) malloc ((iPicWidth + EXPANDY_REF_FRAMEx2)	* (iPicHeight + EXPANDY_REF_FRAMEx2) * sizeof(unsigned char));    m_OOFFlipQ0_U = (PixelC*) malloc ((iPicWidth/2 + EXPANDUV_REF_FRAMEx2) * (iPicHeight/2 + EXPANDUV_REF_FRAMEx2) * sizeof(unsigned char));    m_OOFFlipQ0_V = (PixelC*) malloc ((iPicWidth/2 + EXPANDUV_REF_FRAMEx2) * (iPicHeight/2 + EXPANDUV_REF_FRAMEx2) * sizeof(unsigned char));    m_OOFFlipQ1_Y = (PixelC*) malloc ((iPicWidth + EXPANDY_REF_FRAMEx2)	* (iPicHeight + EXPANDY_REF_FRAMEx2) * sizeof(unsigned char));    m_OOFFlipQ1_U = (PixelC*) malloc ((iPicWidth/2 + EXPANDUV_REF_FRAMEx2) * (iPicHeight/2 + EXPANDUV_REF_FRAMEx2) * sizeof(unsigned char));    m_OOFFlipQ1_V = (PixelC*) malloc ((iPicWidth/2 + EXPANDUV_REF_FRAMEx2) * (iPicHeight/2 + EXPANDUV_REF_FRAMEx2) * sizeof(unsigned char));    // Move to the correct location within the Out Of Frame reference frames to get to the In Frame reference pointers    m_IFFlipQ0_Y  = m_OOFFlipQ0_Y + nIFYLoc;    m_IFFlipQ0_U  = m_OOFFlipQ0_U + nIFUVLoc;    m_IFFlipQ0_V  = m_OOFFlipQ0_V + nIFUVLoc;    m_IFFlipQ1_Y  = m_OOFFlipQ1_Y + nIFYLoc;    m_IFFlipQ1_U  = m_OOFFlipQ1_U + nIFUVLoc;    m_IFFlipQ1_V  = m_OOFFlipQ1_V + nIFUVLoc;    // Assign the correct values for the CRct structs    m_FlipRctVOPY0.left		= -16;    m_FlipRctVOPY0.top		= -16;    m_FlipRctVOPY0.right	= iPicWidth + 16;    m_FlipRctVOPY0.bottom	= iPicHeight + 16;    m_FlipRctVOPY0.width	= iPicWidth + 32;    m_FlipRctVOPY1.left		= -16;    m_FlipRctVOPY1.top		= -16;    m_FlipRctVOPY1.right	= iPicWidth + 16;    m_FlipRctVOPY1.bottom	= iPicHeight + 16;    m_FlipRctVOPY1.width	= iPicWidth + 32;    m_rctRefVOPY0.left		= -16;    m_rctRefVOPY0.top		= -16;    m_rctRefVOPY0.right	    = iPicWidth + 16;    m_rctRefVOPY0.bottom	= iPicHeight + 16;    m_rctRefVOPY0.width	    = iPicWidth + 32;    m_rctRefVOPY1.left		= -16;    m_rctRefVOPY1.top		= -16;    m_rctRefVOPY1.right	    = iPicWidth + 16;    m_rctRefVOPY1.bottom	= iPicHeight + 16;    m_rctRefVOPY1.width	    = iPicWidth + 32;#endif#ifdef ENABLE_INTERLACING    nDoPadding = 0;    m_ActiveRef = FORWARD_REFERENCES;    memset (nFlipArray, NO_FLIP, nNumMBs);#endif#ifndef NEW_MAE_DRIVER    // Picture Size    pMAERegs->picture_size.linesiz = iPicWidth;    pMAERegs->picture_size.height = iPicHeight;        // The MPEG4 Reference model supports only 4:2:0 format    pMAERegs->config0.bc = MAE_BC_420;        // Mismatch control    if (g_pVOL->fQuantizer == Q_H263)      pMAERegs->config0.mis = MAE_MISMATCH_OFF;    else      pMAERegs->config0.mis = MAE_MISMATCH_ON;        // Saturation.  Turn it on for MPEG4    pMAERegs->config0.satiq = 1;        // Reset IQMUL1    pMAERegs->config0.iqmul1 = 0;        // We are always MPEG    pMAERegs->config0.codstyl = CODSTYL_MPEG;#endif    // This is not perfect, so as of now this flag is NOT defined. We are directly using the PTS that the demux is sending#ifdef USE_INTERPOLATED_PTS     // This case is for the very first time we assign the PTS or when we roll over (the VOP increment value read from the    // bit stream seems to roll over back to 0 after some VOPs are decoded)    if (!g_tVopIncr)    {        g_nMP4VPTS +=  g_PTSInterval;    }        // Keep a count of the immediate previous interval and use that to update the final PTS    else    {        g_PTSInterval =  g_tVopIncr - g_tempPTS;        g_nMP4VPTS +=  g_PTSInterval;    }        // Store the increment temporarily    g_tempPTS = g_tVopIncr;#endif  // ~Pulled up from decodeVOP ()    return 0;}// NBIT: added functionVoid setClipTab(CVideoObject *pVO, VOLMode *pVOL){	Int TabSize = 1<<(pVOL->nBits+2);	Int maxVal = (1<<pVOL->nBits)-1;  Int i;	pVO->m_iOffset = TabSize/2;	pVO->m_rgiClipTab = (PixelC*) malloc (TabSize * sizeof(PixelC));	pVO->m_rgiClipTab += pVO->m_iOffset;	for (i = -pVO->m_iOffset; i < pVO->m_iOffset; i++)		pVO->m_rgiClipTab [i] = (i < 0) ? 0 : (i > maxVal) ? maxVal : i;}Void allocateVOLMembers (CVideoObject *pVO, VOLMode *pVOL, Int iSessionWidth, Int iSessionHeight){  Int k, nBlk = 6, iBlk, iNumMBX, iNumMBY, iNumMB, iCnt;  Int iScaleMB	= (pVOL->breduced_resolution_vop_enable) ? (2) : (1);    // MB data	  pVO->m_rgpiCoefQ = (Int **) malloc (nBlk * sizeof (Int));  for(iBlk=0; iBlk<nBlk; iBlk++)    pVO->m_rgpiCoefQ[iBlk] = (Int *) malloc (BLOCK_SQUARE_SIZE * sizeof (Int));    pVO->m_rgiQPpred = (Int *) malloc (sizeof(Int) * nBlk);    // motion vectors and MBMode  iNumMBX = iSessionWidth / MB_SIZE;   if (iSessionWidth  % MB_SIZE != 0)				//round up    iNumMBX++;  iNumMBY = iSessionHeight / MB_SIZE;  if (iSessionHeight % MB_SIZE != 0)				//deal with frational MB    iNumMBY++;  iNumMB = pVO->m_iSessNumMB = iNumMBX * iNumMBY;    pVO->m_rgmbmd = (CMBMode *) malloc (sizeof(CMBMode) * iNumMB);  for(k=0; k<iNumMB; k++)  {    CMBMode_Init(&pVO->m_rgmbmd[k]);  }    iCnt = max(PVOP_MV_PER_REF_PER_MB, 2*BVOP_MV_PER_REF_PER_MB) * iNumMB;  pVO->m_rgmv = (CMotionVector *) malloc (iCnt * sizeof(CMotionVector));  for(k=0; k<iCnt; k++)  { // these begin/end braces are important since we're calling a macro    CMOTIONVECTOR_INIT2((&pVO->m_rgmv[k]));  }    pVO->m_rgmvBackward = pVO->m_rgmv + BVOP_MV_PER_REF_PER_MB * pVO->m_iSessNumMB;  pVO->m_rgmvRef = (CMotionVector *) malloc (iCnt * sizeof(CMotionVector));  for(k=0; k<iCnt; k++)  { // these begin/end braces are important since we're calling a macro    CMOTIONVECTOR_INIT2((&pVO->m_rgmvRef[k]));  }    pVO->m_rgmvBY = (CMotionVector *) malloc (iNumMB * sizeof(CMotionVector));  for(k=0; k<iNumMB; k++)  { // these begin/end braces are important since we're calling a macro    CMOTIONVECTOR_INIT2((&pVO->m_rgmvBY[k]));  }    // Memory leak?  pVO->m_rgmbmdRef = (CMBMode *) malloc (sizeof(CMBMode) * iNumMB);  for(k=0; k<iNumMB; k++)  {    CMBMode_Init(&pVO->m_rgmbmdRef[k]);  }}Void computeVOLConstMembers (CVideoObject *pVO, VOLMode *pVOL){    Int iMB, iBlk, nBlk = 6;	pVO->m_iOffsetForPadY = RCT_OFFSET((&pVO->m_rctRefFrameY), m_rctCurrVOPY.left, m_rctCurrVOPY.top);	pVO->m_iOffsetForPadUV = RCT_OFFSET((&pVO->m_rctRefFrameUV), pVO->m_rctCurrVOPUV.left, pVO->m_rctCurrVOPUV.top);	pVO->m_rctPrevNoExpandY = m_rctCurrVOPY;	pVO->m_rctPrevNoExpandUV = pVO->m_rctCurrVOPUV;	pVO->m_iVOPWidthY = m_rctCurrVOPY.width;	pVO->m_iVOPWidthUV = pVO->m_rctCurrVOPUV.width;	pVO->m_iNumMBX = pVO->m_iNumMBXRef = pVO->m_iVOPWidthY / MB_SIZE; 	pVO->m_iNumMBY = pVO->m_iNumMBYRef = RCT_HEIGHT((&m_rctCurrVOPY)) / MB_SIZE;	pVO->m_iNumMB = pVO->m_iNumMBRef = pVO->m_iNumMBX * pVO->m_iNumMBY;	pVO->m_iNumOfTotalMVPerRow = PVOP_MV_PER_REF_PER_MB * pVO->m_iNumMBX;	setRefStartingPointers (pVO);    pVO->m_rgpmbmAbove = (MacroBlockMemory**) malloc (pVO->m_iNumMBX * sizeof(MacroBlockMemory));    pVO->m_rgpmbmCurr = (MacroBlockMemory**) malloc (pVO->m_iNumMBX * sizeof(MacroBlockMemory));    for (iMB = 0; iMB < pVO->m_iNumMBX; iMB++)	    {        pVO->m_rgpmbmAbove [iMB] = (MacroBlockMemory*) malloc (sizeof(MacroBlockMemory));        pVO->m_rgpmbmAbove [iMB]->rgblkm = (BlockMemory*) malloc (nBlk * sizeof(BlockMemory));        pVO->m_rgpmbmCurr  [iMB] = (MacroBlockMemory*) malloc (sizeof(MacroBlockMemory));        pVO->m_rgpmbmCurr  [iMB]->rgblkm = (BlockMemory*) malloc (nBlk * sizeof(BlockMemory));        for (iBlk = 0; iBlk < nBlk; iBlk++)	        {            (pVO->m_rgpmbmAbove [iMB]->rgblkm) [iBlk] = (Int*) malloc (((BLOCK_SIZE << 1) - 1) * sizeof(Int));            (pVO->m_rgpmbmCurr  [iMB]->rgblkm) [iBlk] = (Int*) malloc (((BLOCK_SIZE << 1) - 1) * sizeof(Int));        }    }}Void setRefStartingPointers (CVideoObject *pVO){	pVO->m_iStartInRefToCurrRctY = RCT_OFFSET((&pVO->m_rctRefFrameY), m_rctCurrVOPY.left, m_rctCurrVOPY.top);	pVO->m_iStartInRefToCurrRctUV = RCT_OFFSET((&pVO->m_rctRefFrameUV), pVO->m_rctCurrVOPUV.left, pVO->m_rctCurrVOPUV.top);}INLINE Int decode (){  UInt uiCheck;  Bool bCoded, bPrevRefVopWasCoded;    TmpVOLType = g_pVOL->volType;	g_pVO->m_iRRVScale	= 1;	// default value#ifndef NO_ASSERTS	//sprite piece should not come here	assert ((g_pVOP->SpriteXmitMode == STOP) || ( g_pVOP->SpriteXmitMode == PAUSE));#endifnext_VOP:  if (findStartCode () == EOF)    return EOF;#ifdef ENABLE_MULTIPLE_VOL_SUPPORT  // Check to see if the clip (this can happen only in the XviD graph) has  // multiple VOLs. This is done mainly to detect a change in the MotionComp  // precision (say HPEL to QPEL) and appropriately send that down to MAE-FE  // Also, make sure that we check for extra VOLs only in normal mode  if((g_MP4VDecodeMode == DECODE_NORMAL) && (peekBits(NUMBITS_START_CODE_SUFFIX)==VSS_START_CODE))  {#ifdef ENABLE_PRINTS      printf("Multiple VSS_START_CODEs detected\n");#endif    if (decodeVOHead_Stripped (g_pDecoder)==0) // also decodes vss, vso headers if present    {#ifdef ENABLE_PRINTS      printf("decodeVOHead_Stripped success\n");#endif      /* successfully decoded VO header */      if(decodeVOLHead_Stripped (g_pDecoder, g_pVOL, g_pVOP) != 0)      {#ifdef ENABLE_PRINTS        printf("decodeVOLHead_Stripped returned an error\n");#endif        return -1;      }#ifdef ENABLE_PRINTS      printf("decodeVOLHead_Stripped success\n");#endif    }  }#endif // ENABLE_MULTIPLE_VOL_SUPPORT  uiCheck =  peekBits (NUMBITS_VOP_START_CODE);	if(uiCheck==VSS_END_CODE)		return EOF;	bCoded = decodeVOPHead (); // set the bounding box here	#ifdef ENABLE_PRINTS	if(bCoded == FALSE)		printf("Not coded\n");#endif    if (MP4V_EOF())    {        return EOF;    }#ifdef USE_MAI    if(g_uiWaitForIFrame == TRUE)    {        if (g_pVOP->vopPredType==IVOP)        {            set_mode(g_MP4VDecodeMode, g_NextSpeed);            g_uiWaitForIFrame = FALSE;        }        else        {            MAICompBase_NewFrame(g_hComp, 0, MAI_FRAMETYPE_VIDEO, COMPBASE_NEWFRAME_FLAG_INPUT|COMPBASE_NEWFRAME_FLAG_SKIPPED);            goto next_VOP;        }    }    // Check if are in I or IP mode and if so, let us just keep reading the bitstream until we get to the next frame    if (g_MP4VDecodeMode != DECODE_NORMAL)     {          if ((g_pVOP->vopPredType == PVOP && g_MP4VDecodeMode == DECODE_I_ONLY) || (g_pVOP->vopPredType == BVOP))          {              // count skipped frames              MAICompBase_NewFrame(g_hComp, 0, MAI_FRAMETYPE_VIDEO, COMPBASE_NEWFRAME_FLAG_INPUT|COMPBASE_NEWFRAME_FLAG_SKIPPED);              goto next_VOP;          }    }  /* for stats collection - count each input frame */  MAICompBase_NewFrame(g_hComp, 0, MAI_FRAMETYPE_VIDEO, COMPBASE_NEWFRAME_FLAG_INPUT);#endif // USE_MAI    // As of now, this flag is NOT defined. So, we shall     // exit out on clips that have this ENABLED#ifndef ENABLE_SPRITE    // Check if this clip has SPRITE enabled. If so, just exit out    if (g_pVOP->vopPredType == SPRITE)    {      MP4V_FATAL_ERROR("Sprite coding detected : Exiting (not supported at this time)");    }#endif#ifndef ENABLE_INTERLACING    // Throw an error & exit decoding if we detect interlaced clips    if (g_pVOP->bInterlace == 1)     {      MP4V_FATAL_ERROR("Interlaced content detected : Exiting (not supported at this time)");    }#endif	bPrevRefVopWasCoded = g_pVO->m_bCodedFutureRef;	if(g_pVOP->vopPredType==IVOP || g_pVOP->vopPredType==PVOP) // GMC		g_pVO->m_bCodedFutureRef = bCoded; // flag used by bvop prediction	// set time stamps for Base/Temporal-Enhc/Spatial-Enhc Layer	Modified by Sharp(1998-02-10)  if(TmpVOLType == BASE_LAYER)   {    if(g_pVOP->vopPredType==IVOP || g_pVOP->vopPredType==PVOP) { // GMC      if(bPrevRefVopWasCoded)        g_pVO->m_tPastRef = g_pVO->m_tFutureRef;      g_pVO->m_tFutureRef = g_pVO->m_t;      g_pVO->m_iBCount = 0;    }    // count B-VOPs    if(g_pVOP->vopPredType==BVOP)        g_pVO->m_iBCount++;  }  #ifdef DUAL_MODE  else if (pvopcBVOPQuant != NULL) // Spatial Scalability Enhancement Layer /* (98/03/30) modified by SONY */  {    if(g_pVOP->vopPredType == BVOP && g_pVOP->iRefSelectCode == 0)     {      if(bPrevRefVopWasCoded)        m_tPastRef = m_tFutureRef;      m_tFutureRef = m_t;      m_iBCount = 0;    }         if(g_pVOP->vopPredType == PVOP && g_pVOP->iRefSelectCode == 3)     {      m_tPastRef = m_t;      m_tFutureRef = m_t;      m_iBCount = 0;    }    /* (98/03/30) modified by SONY */        // count B-VOPs    if(g_pVOP->vopPredType==BVOP)        m_iBCount++;  }#endif  // set time stamps for Base/Temporal-Enhc/Spatial-Enhc Layer	End 	    Sharp(1998-02-10)#ifndef NEW_MAE_DRIVER	if(bPrevRefVopWasCoded)	{		if(TmpVOLType == BASE_LAYER) 			updateAllRefVOPs ();            // update all reconstructed VOP's	}#endif#ifdef ENABLE_PRINTS  if(bCoded)  {      switch(g_pVOP->vopPredType)      {        case IVOP:            printf("IVOP : ");        break;                case PVOP:            printf("PVOP : ");        break;                // GMC        case SPRITE:            printf("SVOP : ");        break;        // ~GMC                case BVOP:            printf("BVOP : ");        break;                default:        break;      }  }#endif    if(bCoded==FALSE)  {#ifdef ENABLE_NON_RECTANGLE_USAGE    if (g_pVOP->vopPredType != BVOP && g_pVOL->fAUsage != RECTANGLE && bPrevRefVopWasCoded)    {      // give the current object a dummy size      m_iNumMBX = m_iNumMBY = m_iNumMB = 1;      saveShapeMode(); // save the previous reference vop shape mode    }        if (g_pVOL->fAUsage != RECTANGLE)    {      // give the current object a dummy size						      m_iNumMBX = m_iNumMBY = m_iNumMB = 1;						      saveBaseShapeMode(); // save the base layer shape mode		    }																    //~OBSS_SAIT_991015#endif        // Increment the frame count        nFrames++;		return FALSE;	}#ifdef ENABLE_NON_RECTANGLE_USAGE	if (g_pVOL->fAUsage != RECTANGLE)		resetBYPlane ();	if (g_pVOL->fAUsage != RECTANGLE)   {

⌨️ 快捷键说明

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