omxVCM4P10_FilterDeblockingLuma_VerEdge_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_FilterDeblockingLuma_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 luma 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_FilterDeblockingLuma_VerEdge_I   (6.3.3.3.1)
41 *
42 * Description:
43 * Performs in-place deblock filtering on four vertical edges of the luma
44 * macroblock (16x16).
45 *
46 * Input Arguments:
47 *
48 *   pSrcDst - Pointer to the input macroblock; must be 16-byte aligned.
49 *   srcdstStep -Step of the arrays; must be a multiple of 16.
50 *   pAlpha -Array of size 2 of alpha thresholds (the first item is the alpha
51 *            threshold for the external vertical edge, and the second item is
52 *            for the internal vertical edge); per [ISO14496-10] alpha values
53 *            must be 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 16 of Thresholds (TC0) (values for the left
59 *            edge of each 4x4 block, arranged in vertical block order); must
60 *            be aligned on a 4-byte boundary..  Per [ISO14496-10] values must
61 *            be in the range [0,25].
62 *   pBS -Array of size 16 of BS parameters (arranged in vertical block
63 *            order); valid in the range [0,4] with the following
64 *            restrictions: i) pBS[i]== 4 may occur only for 0<=i<=3, ii)
65 *            pBS[i]== 4 if and only if pBS[i^3]== 4.  Must be 4-byte aligned.
66 *
67 * Output Arguments:
68 *
69 *   pSrcDst -Pointer to filtered output macroblock.
70 *
71 * Return Value:
72 *    If the function runs without error, it returns OMX_Sts_NoErr.
73 *    If one of the following cases occurs, the function returns
74 *              OMX_Sts_BadArgErr:
75 *    Either of the pointers in pSrcDst, pAlpha, pBeta, pThresholds, or pBS
76 *              is NULL.
77 *    Either pThresholds or pBS is not aligned on a 4-byte boundary.
78 *    pSrcDst is not 16-byte aligned.
79 *    srcdstStep is not a multiple of 16.
80 *    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
81 *    pBeta[0] and/or pBeta[1] is outside the range [0,18].
82 *    One or more entries in the table pThresholds[0..15]is outside of the
83 *              range [0,25].
84 *    pBS is out of range, i.e., one of the following conditions is true:
85 *              pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or (pBS[i]==4 &&
86 *              pBS[i^3]!=4) for 0<=i<=3.
87 *
88 */
89
90OMXResult omxVCM4P10_FilterDeblockingLuma_VerEdge_I(
91     OMX_U8* pSrcDst,
92     OMX_S32 srcdstStep,
93     const OMX_U8* pAlpha,
94     const OMX_U8* pBeta,
95     const OMX_U8* pThresholds,
96     const OMX_U8 *pBS
97 )
98{
99    int X, Y, I, Internal=0;
100
101    armRetArgErrIf(pSrcDst == NULL,             OMX_Sts_BadArgErr);
102    armRetArgErrIf(armNot16ByteAligned(pSrcDst),OMX_Sts_BadArgErr);
103    armRetArgErrIf(srcdstStep & 15,             OMX_Sts_BadArgErr);
104    armRetArgErrIf(pAlpha == NULL,              OMX_Sts_BadArgErr);
105    armRetArgErrIf(pBeta == NULL,               OMX_Sts_BadArgErr);
106    armRetArgErrIf(pThresholds == NULL,         OMX_Sts_BadArgErr);
107    armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
108    armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
109    armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
110    armRetArgErrIf(pBeta[0] > 18,  OMX_Sts_BadArgErr);
111    armRetArgErrIf(pBeta[1] > 18,  OMX_Sts_BadArgErr);
112
113
114    for (X=0; X<16; X+=4, Internal=1)
115    {
116        for (Y=0; Y<16; Y++)
117        {
118            I = (Y>>2)+4*(X>>2);
119
120            armRetArgErrIf(pBS[Y] > 4, OMX_Sts_BadArgErr);
121
122            armRetArgErrIf((pBS[Y] == 4) && (Y > 3),
123                            OMX_Sts_BadArgErr);
124
125            armRetArgErrIf(( (pBS[Y] == 4) && (pBS[Y^3] != 4) ),
126                            OMX_Sts_BadArgErr);
127
128            armRetArgErrIf(pThresholds[Y] > 25, OMX_Sts_BadArgErr);
129
130            /* Filter vertical edge with q0 at (X,Y) */
131            armVCM4P10_DeBlockPixel(
132                pSrcDst + Y*srcdstStep + X,
133                1,
134                pThresholds[I],
135                pAlpha[Internal],
136                pBeta[Internal],
137                pBS[I],
138                0);
139        }
140    }
141
142    return OMX_Sts_NoErr;
143}
144