Home | History | Annotate | Download | only in src
      1 /* ----------------------------------------------------------------
      2  *
      3  *
      4  * File Name:  omxVCM4P10_DecodeCoeffsToPairCAVLC.c
      5  * OpenMAX DL: v1.0.2
      6  * Revision:   9641
      7  * Date:       Thursday, February 7, 2008
      8  *
      9  * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
     10  *
     11  *
     12  *
     13  * H.264 decode coefficients module
     14  *
     15  */
     16 
     17 #include "omxtypes.h"
     18 #include "armOMX.h"
     19 #include "omxVC.h"
     20 #include "armCOMM.h"
     21 #include "armVC.h"
     22 
     23 /**
     24  * Function:  omxVCM4P10_DecodeCoeffsToPairCAVLC   (6.3.4.1.2)
     25  *
     26  * Description:
     27  * Performs CAVLC decoding and inverse zigzag scan for 4x4 block of
     28  * Intra16x16DCLevel, Intra16x16ACLevel, LumaLevel, and ChromaACLevel. Inverse
     29  * field scan is not supported. The decoded coefficients in the packed
     30  * position-coefficient buffer are stored in reverse zig-zag order, i.e., the
     31  * first buffer element contains the last non-zero postion-coefficient pair of
     32  * the block. Within each position-coefficient pair, the position entry
     33  * indicates the raster-scan position of the coefficient, while the
     34  * coefficient entry contains the coefficient value.
     35  *
     36  * Input Arguments:
     37  *
     38  *   ppBitStream -Double pointer to current byte in bit stream buffer
     39  *   pOffset - Pointer to current bit position in the byte pointed to by
     40  *            *ppBitStream; valid in the range [0,7].
     41  *   sMaxNumCoeff - Maximum the number of non-zero coefficients in current
     42  *            block
     43  *   sVLCSelect - VLC table selector, obtained from the number of non-zero
     44  *            coefficients contained in the above and left 4x4 blocks.  It is
     45  *            equivalent to the variable nC described in H.264 standard table
     46  *            9 5, except its value can t be less than zero.
     47  *
     48  * Output Arguments:
     49  *
     50  *   ppBitStream - *ppBitStream is updated after each block is decoded.
     51  *            Buffer position (*ppPosCoefBuf) is updated upon return, unless
     52  *            there are only zero coefficients in the currently decoded block.
     53  *             In this case the caller is expected to bypass the
     54  *            transform/dequantization of the empty blocks.
     55  *   pOffset - *pOffset is updated after each block is decoded
     56  *   pNumCoeff - Pointer to the number of nonzero coefficients in this block
     57  *   ppPosCoefBuf - Double pointer to destination residual
     58  *            coefficient-position pair buffer
     59  *
     60  * Return Value:
     61  *    OMX_Sts_NoErr, if the function runs without error.
     62  *
     63  *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
     64  *    -    ppBitStream or pOffset is NULL.
     65  *    -    ppPosCoefBuf or pNumCoeff is NULL.
     66  *    -    sMaxNumCoeff is not equal to either 15 or 16.
     67  *    -    sVLCSelect is less than 0.
     68  *
     69  *    OMX_Sts_Err - if one of the following is true:
     70  *    -    an illegal code is encountered in the bitstream
     71  *
     72  */
     73 
     74 OMXResult omxVCM4P10_DecodeCoeffsToPairCAVLC(
     75      const OMX_U8** ppBitStream,
     76      OMX_S32* pOffset,
     77      OMX_U8* pNumCoeff,
     78      OMX_U8**ppPosCoefbuf,
     79      OMX_INT sVLCSelect,
     80      OMX_INT sMaxNumCoeff
     81  )
     82 {
     83     int nTable;
     84 
     85     armRetArgErrIf(ppBitStream==NULL   , OMX_Sts_BadArgErr);
     86     armRetArgErrIf(*ppBitStream==NULL  , OMX_Sts_BadArgErr);
     87     armRetArgErrIf(pOffset==NULL       , OMX_Sts_BadArgErr);
     88     armRetArgErrIf(*pOffset<0          , OMX_Sts_BadArgErr);
     89     armRetArgErrIf(*pOffset>7          , OMX_Sts_BadArgErr);
     90     armRetArgErrIf(pNumCoeff==NULL     , OMX_Sts_BadArgErr);
     91     armRetArgErrIf(ppPosCoefbuf==NULL  , OMX_Sts_BadArgErr);
     92     armRetArgErrIf(*ppPosCoefbuf==NULL , OMX_Sts_BadArgErr);
     93     armRetArgErrIf(sVLCSelect<0        , OMX_Sts_BadArgErr);
     94     armRetArgErrIf(sMaxNumCoeff<15     , OMX_Sts_BadArgErr);
     95     armRetArgErrIf(sMaxNumCoeff>16     , OMX_Sts_BadArgErr);
     96 
     97     /* Find VLC table number */
     98     if (sVLCSelect<2)
     99     {
    100         nTable = 0;
    101     }
    102     else if (sVLCSelect<4)
    103     {
    104         nTable = 1;
    105     }
    106     else if (sVLCSelect<8)
    107     {
    108         nTable = 2;
    109     }
    110     else /* sVLCSelect >= 8 */
    111     {
    112         nTable = 3;
    113     }
    114 
    115     return armVCM4P10_DecodeCoeffsToPair(ppBitStream, pOffset, pNumCoeff,
    116                                          ppPosCoefbuf, nTable, sMaxNumCoeff);
    117 }
    118