Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2007-2008 ARM Limited
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  *
     16  */
     17 /* ----------------------------------------------------------------
     18  *
     19  *
     20  * File Name:  omxVCM4P10_FilterDeblockingChroma_VerEdge_I.c
     21  * OpenMAX DL: v1.0.2
     22  * Revision:   9641
     23  * Date:       Thursday, February 7, 2008
     24  *
     25  *
     26  *
     27  *
     28  * H.264 deblocking module
     29  *
     30  */
     31 
     32 #include "omxtypes.h"
     33 #include "armOMX.h"
     34 #include "omxVC.h"
     35 
     36 #include "armCOMM.h"
     37 #include "armVC.h"
     38 
     39 /**
     40  * Function:  omxVCM4P10_FilterDeblockingChroma_VerEdge_I   (6.3.3.3.3)
     41  *
     42  * Description:
     43  * Performs in-place deblock filtering on four vertical edges of the chroma
     44  * macroblock (8x8).
     45  *
     46  * Input Arguments:
     47  *
     48  *   pSrcDst - Pointer to the input macroblock; must be 8-byte aligned.
     49  *   srcdstStep - Step of the arrays; must be a multiple of 8.
     50  *   pAlpha - Array of size 2 of alpha thresholds (the first item is alpha
     51  *            threshold for external vertical edge, and the second item is for
     52  *            internal vertical edge); per [ISO14496-10] alpha values must be
     53  *            in the range [0,255].
     54  *   pBeta - Array of size 2 of beta thresholds (the first item is the beta
     55  *            threshold for the external vertical edge, and the second item is
     56  *            for the internal vertical edge); per [ISO14496-10] beta values
     57  *            must be in the range [0,18].
     58  *   pThresholds - Array of size 8 containing thresholds, TC0, for the left
     59  *            vertical edge of each 4x2 chroma block, arranged in vertical
     60  *            block order; must be aligned on a 4-byte boundary.  Per
     61  *            [ISO14496-10] values must be in the range [0,25].
     62  *   pBS - Array of size 16 of BS parameters (values for each 2x2 chroma
     63  *            block, arranged in vertical block order). This parameter is the
     64  *            same as the pBSparameter passed into FilterDeblockLuma_VerEdge;
     65  *            valid in the range [0,4] with the following restrictions: i)
     66  *            pBS[i]== 4 may occur only for 0<=i<=3, ii) pBS[i]== 4 if and
     67  *            only if pBS[i^3]== 4.  Must be 4 byte aligned.
     68  *
     69  * Output Arguments:
     70  *
     71  *   pSrcDst -Pointer to filtered output macroblock.
     72  *
     73  * Return Value:
     74  *
     75  *    OMX_Sts_NoErr, if the function runs without error.
     76  *
     77  *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
     78  *    -    one or more of the following pointers is NULL: pSrcDst, pAlpha,
     79  *              pBeta, pThresholds, or pBS.
     80  *    -    pSrcDst is not 8-byte aligned.
     81  *    -    srcdstStep is not a multiple of 8.
     82  *    -    pThresholds is not 4-byte aligned.
     83  *    -    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
     84  *    -    pBeta[0] and/or pBeta[1] is outside the range [0,18].
     85  *    -    One or more entries in the table pThresholds[0..7] is outside
     86  *         of the range [0,25].
     87  *    -    pBS is out of range, i.e., one of the following conditions is true:
     88  *         pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
     89  *         (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
     90  *    -    pBS is not 4-byte aligned.
     91  *
     92  */
     93 
     94 OMXResult omxVCM4P10_FilterDeblockingChroma_VerEdge_I(
     95      OMX_U8* pSrcDst,
     96      OMX_S32 srcdstStep,
     97      const OMX_U8* pAlpha,
     98      const OMX_U8* pBeta,
     99      const OMX_U8* pThresholds,
    100      const OMX_U8 *pBS
    101  )
    102 {
    103     int I, X, Y, Internal=0;
    104 
    105     armRetArgErrIf(pSrcDst == NULL,                 OMX_Sts_BadArgErr);
    106     armRetArgErrIf(armNot8ByteAligned(pSrcDst),     OMX_Sts_BadArgErr);
    107     armRetArgErrIf(srcdstStep & 7,                  OMX_Sts_BadArgErr);
    108     armRetArgErrIf(pAlpha == NULL,                  OMX_Sts_BadArgErr);
    109     armRetArgErrIf(pBeta == NULL,                   OMX_Sts_BadArgErr);
    110     armRetArgErrIf(pThresholds == NULL,             OMX_Sts_BadArgErr);
    111     armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
    112     armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
    113     armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
    114     armRetArgErrIf(pBeta[0] > 18,  OMX_Sts_BadArgErr);
    115     armRetArgErrIf(pBeta[1] > 18,  OMX_Sts_BadArgErr);
    116 
    117     for (X=0; X<8; X+=4, Internal=1)
    118     {
    119         for (Y=0; Y<8; Y++)
    120         {
    121             I = (Y>>1)+4*(X>>1);
    122 
    123             armRetArgErrIf(pBS[I] > 4, OMX_Sts_BadArgErr);
    124 
    125             armRetArgErrIf( (I > 3) && (pBS[I] == 4),
    126                             OMX_Sts_BadArgErr);
    127 
    128             armRetArgErrIf( ( (pBS[I] == 4) && (pBS[I^3] != 4) ),
    129                             OMX_Sts_BadArgErr);
    130             armRetArgErrIf(pThresholds[Y] > 25, OMX_Sts_BadArgErr);
    131 
    132 
    133             /* Filter vertical edge with q0 at (X,Y) */
    134             armVCM4P10_DeBlockPixel(
    135                 pSrcDst + Y*srcdstStep + X,
    136                 1,
    137                 pThresholds[(Y>>1)+4*(X>>2)],
    138                 pAlpha[Internal],
    139                 pBeta[Internal],
    140                 pBS[I],
    141                 1);
    142         }
    143     }
    144 
    145     return OMX_Sts_NoErr;
    146 }
    147