Home | History | Annotate | Download | only in src
      1 /**
      2  *
      3  * File Name:  omxVCM4P2_DecodeBlockCoef_Intra.c
      4  * OpenMAX DL: v1.0.2
      5  * Revision:   9641
      6  * Date:       Thursday, February 7, 2008
      7  *
      8  * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
      9  *
     10  *
     11  *
     12  * Description:
     13  * Contains modules for intra reconstruction
     14  *
     15  */
     16 
     17 #include "omxtypes.h"
     18 #include "armOMX.h"
     19 #include "omxVC.h"
     20 
     21 #include "armCOMM.h"
     22 #include "armVC.h"
     23 
     24 /**
     25  * Function: omxVCM4P2_DecodeBlockCoef_Intra
     26  *
     27  * Description:
     28  * Decodes the INTRA block coefficients. Inverse quantization, inversely zigzag
     29  * positioning, and IDCT, with appropriate clipping on each step, are performed
     30  * on the coefficients. The results are then placed in the output frame/plane on
     31  * a pixel basis. For INTRA block, the output values are clipped to [0, 255] and
     32  * written to corresponding block buffer within the destination plane.
     33  *
     34  * Remarks:
     35  *
     36  * Parameters:
     37  * [in]	ppBitStream		pointer to the pointer to the current byte in
     38  *								the bit stream buffer. There is no boundary
     39  *								check for the bit stream buffer.
     40  * [in]	pBitOffset		pointer to the bit position in the byte pointed
     41  *								to by *ppBitStream. *pBitOffset is valid within
     42  *								[0-7].
     43  * [in]	step			width of the destination plane
     44  * [in/out]	pCoefBufRow		[in]  pointer to the coefficient row buffer
     45  *                        [out] updated coefficient rwo buffer
     46  * [in/out]	pCoefBufCol		[in]  pointer to the coefficient column buffer
     47  *                        [out] updated coefficient column buffer
     48  * [in]	curQP			quantization parameter of the macroblock which
     49  *								the current block belongs to
     50  * [in]	pQpBuf		 Pointer to a 2-element QP array. pQpBuf[0] holds the QP of the 8x8 block left to
     51  *                   the current block(QPa). pQpBuf[1] holds the QP of the 8x8 block just above the
     52  *                   current block(QPc).
     53  *                   Note, in case the corresponding block is out of VOP bound, the QP value will have
     54  *                   no effect to the intra-prediction process. Refer to subclause  "7.4.3.3 Adaptive
     55  *                   ac coefficient prediction" of ISO/IEC 14496-2(MPEG4 Part2) for accurate description.
     56  * [in]	blockIndex		block index indicating the component type and
     57  *								position as defined in subclause 6.1.3.8,
     58  *								Figure 6-5 of ISO/IEC 14496-2.
     59  * [in]	intraDCVLC		a code determined by intra_dc_vlc_thr and QP.
     60  *								This allows a mechanism to switch between two VLC
     61  *								for coding of Intra DC coefficients as per Table
     62  *								6-21 of ISO/IEC 14496-2.
     63  * [in]	ACPredFlag		a flag equal to ac_pred_flag (of luminance) indicating
     64  *								if the ac coefficients of the first row or first
     65  *								column are differentially coded for intra coded
     66  *								macroblock.
     67  * [in] shortVideoHeader    a flag indicating presence of short_video_header;
     68  *                           shortVideoHeader==1 selects linear intra DC mode,
     69  *							and shortVideoHeader==0 selects nonlinear intra DC mode.
     70  * [out]	ppBitStream		*ppBitStream is updated after the block is
     71  *								decoded, so that it points to the current byte
     72  *								in the bit stream buffer
     73  * [out]	pBitOffset		*pBitOffset is updated so that it points to the
     74  *								current bit position in the byte pointed by
     75  *								*ppBitStream
     76  * [out]	pDst			pointer to the block in the destination plane.
     77  *								pDst should be 16-byte aligned.
     78  * [out]	pCoefBufRow		pointer to the updated coefficient row buffer.
     79  *
     80  * Return Value:
     81  * OMX_Sts_NoErr - no error
     82  * OMX_Sts_BadArgErr - bad arguments
     83  *   -	At least one of the following pointers is NULL: ppBitStream, *ppBitStream, pBitOffset,
     84  *                                                      pCoefBufRow, pCoefBufCol, pQPBuf, pDst.
     85  *      or
     86  *   -  At least one of the below case: *pBitOffset exceeds [0,7], curQP exceeds (1, 31),
     87  *      blockIndex exceeds [0,9], step is not the multiple of 8, intraDCVLC is zero while
     88  *      blockIndex greater than 5.
     89  *      or
     90  *   -	pDst is not 16-byte aligned
     91  * OMX_Sts_Err - status error
     92  *
     93  */
     94 
     95 OMXResult omxVCM4P2_DecodeBlockCoef_Intra(
     96      const OMX_U8 ** ppBitStream,
     97      OMX_INT *pBitOffset,
     98      OMX_U8 *pDst,
     99      OMX_INT step,
    100      OMX_S16 *pCoefBufRow,
    101      OMX_S16 *pCoefBufCol,
    102      OMX_U8 curQP,
    103      const OMX_U8 *pQPBuf,
    104      OMX_INT blockIndex,
    105      OMX_INT intraDCVLC,
    106      OMX_INT ACPredFlag,
    107 	 OMX_INT shortVideoHeader
    108  )
    109 {
    110     OMX_S16 tempBuf1[79], tempBuf2[79];
    111     OMX_S16 *pTempBuf1, *pTempBuf2;
    112     OMX_INT predDir, predACDir;
    113     OMX_INT  predQP;
    114     OMXVCM4P2VideoComponent videoComp;
    115     OMXResult errorCode;
    116 
    117 
    118     /* Aligning the local buffers */
    119     pTempBuf1 = armAlignTo16Bytes(tempBuf1);
    120     pTempBuf2 = armAlignTo16Bytes(tempBuf2);
    121 
    122     /* Setting the AC prediction direction and prediction direction */
    123     armVCM4P2_SetPredDir(
    124         blockIndex,
    125         pCoefBufRow,
    126         pCoefBufCol,
    127         &predDir,
    128         &predQP,
    129         pQPBuf);
    130 
    131     predACDir = predDir;
    132 
    133 
    134     if (ACPredFlag == 0)
    135     {
    136         predACDir = OMX_VC_NONE;
    137     }
    138 
    139     /* Setting the videoComp */
    140     if (blockIndex <= 3)
    141     {
    142         videoComp = OMX_VC_LUMINANCE;
    143     }
    144     else
    145     {
    146         videoComp = OMX_VC_CHROMINANCE;
    147     }
    148 
    149 
    150     /* VLD and zigzag */
    151     if (intraDCVLC == 1)
    152     {
    153         errorCode = omxVCM4P2_DecodeVLCZigzag_IntraDCVLC(
    154             ppBitStream,
    155             pBitOffset,
    156             pTempBuf1,
    157             predACDir,
    158             shortVideoHeader,
    159             videoComp);
    160         armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
    161     }
    162     else
    163     {
    164         errorCode = omxVCM4P2_DecodeVLCZigzag_IntraACVLC(
    165             ppBitStream,
    166             pBitOffset,
    167             pTempBuf1,
    168             predACDir,
    169             shortVideoHeader);
    170         armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
    171     }
    172 
    173     /* AC DC prediction */
    174     errorCode = omxVCM4P2_PredictReconCoefIntra(
    175         pTempBuf1,
    176         pCoefBufRow,
    177         pCoefBufCol,
    178         curQP,
    179         predQP,
    180         predDir,
    181         ACPredFlag,
    182         videoComp);
    183     armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
    184 
    185     /* Dequantization */
    186     errorCode = omxVCM4P2_QuantInvIntra_I(
    187      pTempBuf1,
    188      curQP,
    189      videoComp,
    190      shortVideoHeader);
    191     armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
    192 
    193     /* Inverse transform */
    194     errorCode = omxVCM4P2_IDCT8x8blk (pTempBuf1, pTempBuf2);
    195     armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
    196 
    197     /* Placing the linear array into the destination plane and clipping
    198        it to 0 to 255 */
    199 
    200 	armVCM4P2_Clip8(pTempBuf2,pDst,step);
    201 
    202 
    203     return OMX_Sts_NoErr;
    204 }
    205 
    206 /* End of file */
    207 
    208 
    209