Home | History | Annotate | Download | only in src
      1 /* ----------------------------------------------------------------
      2  *
      3  *
      4  * File Name:  omxVCM4P10_TransformDequantChromaDCFromPair.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 inverse quantize and transform module
     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  * Description:
     26  * Dequantize Chroma 2x2 DC block
     27  */
     28 
     29 static void DequantChromaDC2x2(
     30      OMX_S16* pDst,
     31      OMX_INT QP
     32 )
     33 {
     34     int Shift = (QP/6)-1 ;
     35     int Scale = armVCM4P10_VMatrix[QP%6][0];
     36     int i, Value;
     37 
     38     if (Shift >= 0)
     39     {
     40         for (i=0; i<4; i++)
     41         {
     42             Value = (pDst[i] * Scale) << Shift;
     43             pDst[i] = (OMX_S16)Value;
     44         }
     45     }
     46     else
     47     {
     48         for (i=0; i<4; i++)
     49         {
     50             Value = (pDst[i] * Scale) >> 1;
     51             pDst[i] = (OMX_S16)Value;
     52         }
     53     }
     54 }
     55 
     56 
     57 /*
     58  * Description:
     59  * Inverse Transform DC 2x2 Coefficients
     60  */
     61 
     62 static void InvTransformDC2x2(OMX_S16* pData)
     63 {
     64     int c00 = pData[0];
     65     int c01 = pData[1];
     66     int c10 = pData[2];
     67     int c11 = pData[3];
     68 
     69     int d00 = c00 + c01;
     70     int d01 = c00 - c01;
     71     int d10 = c10 + c11;
     72     int d11 = c10 - c11;
     73 
     74     pData[0] = (OMX_S16)(d00 + d10);
     75     pData[1] = (OMX_S16)(d01 + d11);
     76     pData[2] = (OMX_S16)(d00 - d10);
     77     pData[3] = (OMX_S16)(d01 - d11);
     78 }
     79 
     80 
     81 /**
     82  * Function:  omxVCM4P10_TransformDequantChromaDCFromPair   (6.3.4.2.2)
     83  *
     84  * Description:
     85  * Reconstruct the 2x2 ChromaDC block from coefficient-position pair buffer,
     86  * perform integer inverse transformation, and dequantization for 2x2 chroma
     87  * DC coefficients, and update the pair buffer pointer to next non-empty
     88  * block.
     89  *
     90  * Input Arguments:
     91  *
     92  *   ppSrc - Double pointer to residual coefficient-position pair buffer
     93  *            output by CALVC decoding
     94  *   QP - Quantization parameter QpC
     95  *
     96  * Output Arguments:
     97  *
     98  *   ppSrc - *ppSrc is updated to the start of next non empty block
     99  *   pDst - Pointer to the reconstructed 2x2 ChromaDC coefficients buffer;
    100  *            must be aligned on a 4-byte boundary.
    101  *
    102  * Return Value:
    103  *    OMX_Sts_NoErr, if the function runs without error.
    104  *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
    105  *    -    ppSrc or pDst is NULL.
    106  *    -    pDst is not 4-byte aligned.
    107  *    -    QP is not in the range of [0-51].
    108  *
    109  */
    110 
    111 OMXResult omxVCM4P10_TransformDequantChromaDCFromPair(
    112      const OMX_U8 **ppSrc,
    113      OMX_S16* pDst,
    114      OMX_INT QP
    115  )
    116 {
    117     armRetArgErrIf(ppSrc  == NULL,           OMX_Sts_BadArgErr);
    118     armRetArgErrIf(*ppSrc == NULL,           OMX_Sts_BadArgErr);
    119     armRetArgErrIf(pDst   == NULL,           OMX_Sts_BadArgErr);
    120     armRetArgErrIf(armNot4ByteAligned(pDst), OMX_Sts_BadArgErr);
    121     armRetArgErrIf(QP<0,                     OMX_Sts_BadArgErr);
    122     armRetArgErrIf(QP>51,                    OMX_Sts_BadArgErr);
    123 
    124     armVCM4P10_UnpackBlock2x2(ppSrc, pDst);
    125     InvTransformDC2x2(pDst);
    126     DequantChromaDC2x2(pDst, QP);
    127 
    128     return OMX_Sts_NoErr;
    129 }
    130 
    131 /* End of file */
    132