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