omxVCM4P10_FilterDeblockingChroma_HorEdge_I.c revision 78e52bfac041d71ce53b5b13c2abf78af742b09d
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_HorEdge_I.c
21 * OpenMAX DL: v1.0.2
22 * Revision:   9641
23 * Date:       Thursday, February 7, 2008
24 *
25 *
26 *
27 *
28 * H.264 chroma deblock 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_HorEdge_I   (6.3.3.3.4)
41 *
42 * Description:
43 * Performs in-place deblock filtering on the horizontal 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 - array step; must be a multiple of 8.
50 *   pAlpha - array of size 2 containing alpha thresholds; the first element
51 *            contains the threshold for the external horizontal edge, and the
52 *            second element contains the threshold for internal horizontal
53 *            edge.  Per [ISO14496-10] alpha values must be in the range
54 *            [0,255].
55 *   pBeta - array of size 2 containing beta thresholds; the first element
56 *            contains the threshold for the external horizontal edge, and the
57 *            second element contains the threshold for the internal
58 *            horizontal edge.  Per [ISO14496-10] beta values must be in the
59 *            range [0,18].
60 *   pThresholds - array of size 8 containing thresholds, TC0, for the top
61 *            horizontal edge of each 2x4 chroma block, arranged in horizontal
62 *            block order; must be aligned on a 4-byte boundary.  Per
63 *            [ISO14496-10] values must be in the range [0,25].
64 *   pBS - array of size 16 containing BS parameters for each 2x2 chroma
65 *            block, arranged in horizontal block order; valid in the range
66 *            [0,4] with the following restrictions: i) pBS[i]== 4 may occur
67 *            only for 0<=i<=3, ii) pBS[i]== 4 if and only if pBS[i^3]== 4.
68 *            Must be 4-byte aligned.
69 *
70 * Output Arguments:
71 *
72 *   pSrcDst -Pointer to filtered output macroblock.
73 *
74 * Return Value:
75 *
76 *    OMX_Sts_NoErr, if the function runs without error.
77 *
78 *    OMX_Sts_BadArgErr, if one of the following cases occurs:
79 *    -    any of the following pointers is NULL:
80 *         pSrcDst, pAlpha, pBeta, pThresholds, or pBS.
81 *    -    pSrcDst is not 8-byte aligned.
82 *    -    srcdstStep is not a multiple of 8.
83 *    -    pThresholds is not 4-byte aligned.
84 *    -    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
85 *    -    pBeta[0] and/or pBeta[1] is outside the range [0,18].
86 *    -    One or more entries in the table pThresholds[0..7] is outside
87 *         of the range [0,25].
88 *    -    pBS is out of range, i.e., one of the following conditions is true:
89 *              pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
90 *              (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
91 *    -    pBS is not 4-byte aligned.
92 *
93 */
94
95OMXResult omxVCM4P10_FilterDeblockingChroma_HorEdge_I(
96     OMX_U8* pSrcDst,
97     OMX_S32 srcdstStep,
98     const OMX_U8* pAlpha,
99     const OMX_U8* pBeta,
100     const OMX_U8* pThresholds,
101     const OMX_U8 *pBS
102 )
103{
104    int I, X, Y, Internal=0;
105
106    armRetArgErrIf(pSrcDst == NULL,                 OMX_Sts_BadArgErr);
107    armRetArgErrIf(armNot8ByteAligned(pSrcDst),     OMX_Sts_BadArgErr);
108    armRetArgErrIf(srcdstStep & 7,                  OMX_Sts_BadArgErr);
109    armRetArgErrIf(pAlpha == NULL,                  OMX_Sts_BadArgErr);
110    armRetArgErrIf(pBeta == NULL,                   OMX_Sts_BadArgErr);
111    armRetArgErrIf(pThresholds == NULL,             OMX_Sts_BadArgErr);
112    armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
113    armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
114    armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
115
116    for (Y=0; Y<8; Y+=4, Internal=1)
117    {
118        for (X=0; X<8; X++)
119        {
120            I = (X>>1)+4*(Y>>1);
121
122            armRetArgErrIf(pBS[I] > 4, OMX_Sts_BadArgErr)
123
124            armRetArgErrIf( (I > 3) && (pBS[I] == 4),
125                            OMX_Sts_BadArgErr)
126
127            armRetArgErrIf( (I < 4)       &&
128                          ( (pBS[I] == 4) && (pBS[I^1] != 4) ),
129                            OMX_Sts_BadArgErr)
130
131
132            /* Filter horizontal edge with q0 at (X,Y) */
133            armVCM4P10_DeBlockPixel(
134                pSrcDst + Y*srcdstStep + X,
135                srcdstStep,
136                pThresholds[(X>>1)+4*(Y>>2)],
137                pAlpha[Internal],
138                pBeta[Internal],
139                pBS[I],
140                1);
141        }
142    }
143
144    return OMX_Sts_NoErr;
145}
146