Home | History | Annotate | Download | only in src
      1 /* ----------------------------------------------------------------
      2  *
      3  *
      4  * File Name:  omxVCM4P10_FilterDeblockingChroma_VerEdge_I.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 deblocking 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  * Function:  omxVCM4P10_FilterDeblockingChroma_VerEdge_I   (6.3.3.3.3)
     26  *
     27  * Description:
     28  * Performs in-place deblock filtering on four vertical edges of the chroma
     29  * macroblock (8x8).
     30  *
     31  * Input Arguments:
     32  *
     33  *   pSrcDst - Pointer to the input macroblock; must be 8-byte aligned.
     34  *   srcdstStep - Step of the arrays; must be a multiple of 8.
     35  *   pAlpha - Array of size 2 of alpha thresholds (the first item is alpha
     36  *            threshold for external vertical edge, and the second item is for
     37  *            internal vertical edge); per [ISO14496-10] alpha values must be
     38  *            in the range [0,255].
     39  *   pBeta - Array of size 2 of beta thresholds (the first item is the beta
     40  *            threshold for the external vertical edge, and the second item is
     41  *            for the internal vertical edge); per [ISO14496-10] beta values
     42  *            must be in the range [0,18].
     43  *   pThresholds - Array of size 8 containing thresholds, TC0, for the left
     44  *            vertical edge of each 4x2 chroma block, arranged in vertical
     45  *            block order; must be aligned on a 4-byte boundary.  Per
     46  *            [ISO14496-10] values must be in the range [0,25].
     47  *   pBS - Array of size 16 of BS parameters (values for each 2x2 chroma
     48  *            block, arranged in vertical block order). This parameter is the
     49  *            same as the pBSparameter passed into FilterDeblockLuma_VerEdge;
     50  *            valid in the range [0,4] with the following restrictions: i)
     51  *            pBS[i]== 4 may occur only for 0<=i<=3, ii) pBS[i]== 4 if and
     52  *            only if pBS[i^3]== 4.  Must be 4 byte aligned.
     53  *
     54  * Output Arguments:
     55  *
     56  *   pSrcDst -Pointer to filtered output macroblock.
     57  *
     58  * Return Value:
     59  *
     60  *    OMX_Sts_NoErr, if the function runs without error.
     61  *
     62  *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
     63  *    -    one or more of the following pointers is NULL: pSrcDst, pAlpha,
     64  *              pBeta, pThresholds, or pBS.
     65  *    -    pSrcDst is not 8-byte aligned.
     66  *    -    srcdstStep is not a multiple of 8.
     67  *    -    pThresholds is not 4-byte aligned.
     68  *    -    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
     69  *    -    pBeta[0] and/or pBeta[1] is outside the range [0,18].
     70  *    -    One or more entries in the table pThresholds[0..7] is outside
     71  *         of the range [0,25].
     72  *    -    pBS is out of range, i.e., one of the following conditions is true:
     73  *         pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
     74  *         (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
     75  *    -    pBS is not 4-byte aligned.
     76  *
     77  */
     78 
     79 OMXResult omxVCM4P10_FilterDeblockingChroma_VerEdge_I(
     80      OMX_U8* pSrcDst,
     81      OMX_S32 srcdstStep,
     82      const OMX_U8* pAlpha,
     83      const OMX_U8* pBeta,
     84      const OMX_U8* pThresholds,
     85      const OMX_U8 *pBS
     86  )
     87 {
     88     int I, X, Y, Internal=0;
     89 
     90     armRetArgErrIf(pSrcDst == NULL,                 OMX_Sts_BadArgErr);
     91     armRetArgErrIf(armNot8ByteAligned(pSrcDst),     OMX_Sts_BadArgErr);
     92     armRetArgErrIf(srcdstStep & 7,                  OMX_Sts_BadArgErr);
     93     armRetArgErrIf(pAlpha == NULL,                  OMX_Sts_BadArgErr);
     94     armRetArgErrIf(pBeta == NULL,                   OMX_Sts_BadArgErr);
     95     armRetArgErrIf(pThresholds == NULL,             OMX_Sts_BadArgErr);
     96     armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
     97     armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
     98     armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
     99     armRetArgErrIf(pBeta[0] > 18,  OMX_Sts_BadArgErr);
    100     armRetArgErrIf(pBeta[1] > 18,  OMX_Sts_BadArgErr);
    101 
    102     for (X=0; X<8; X+=4, Internal=1)
    103     {
    104         for (Y=0; Y<8; Y++)
    105         {
    106             I = (Y>>1)+4*(X>>1);
    107 
    108             armRetArgErrIf(pBS[I] > 4, OMX_Sts_BadArgErr);
    109 
    110             armRetArgErrIf( (I > 3) && (pBS[I] == 4),
    111                             OMX_Sts_BadArgErr);
    112 
    113             armRetArgErrIf( ( (pBS[I] == 4) && (pBS[I^3] != 4) ),
    114                             OMX_Sts_BadArgErr);
    115             armRetArgErrIf(pThresholds[Y] > 25, OMX_Sts_BadArgErr);
    116 
    117 
    118             /* Filter vertical edge with q0 at (X,Y) */
    119             armVCM4P10_DeBlockPixel(
    120                 pSrcDst + Y*srcdstStep + X,
    121                 1,
    122                 pThresholds[(Y>>1)+4*(X>>2)],
    123                 pAlpha[Internal],
    124                 pBeta[Internal],
    125                 pBS[I],
    126                 1);
    127         }
    128     }
    129 
    130     return OMX_Sts_NoErr;
    131 }
    132