omxVCM4P10_FilterDeblockingLuma_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_FilterDeblockingLuma_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 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_HorEdge_I   (6.3.3.3.2)
41 *
42 * Description:
43 * Performs in-place deblock filtering on four horizontal 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 -s tep 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 horizontal edge); per [ISO14496-10] alpha
53 *            values 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 horizontal edge, and the second item
56 *            is for the internal horizontal edge). Per [ISO14496-10] beta
57 *            values must be in the range [0,18].
58 *   pThresholds - array of size 16 containing thresholds, TC0, for the top
59 *            horizontal edge of each 4x4 block, arranged in horizontal block
60 *            order; must be aligned on a 4-byte boundary.  Per [ISO14496 10]
61 *            values must be in the range [0,25].
62 *   pBS - array of size 16 of BS parameters (arranged in horizontal 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 *
73 *    OMX_Sts_NoErr, if the function runs without error.
74 *
75 *    OMX_Sts_BadArgErr, if one of the following cases occurs:
76 *    -    one or more of the following pointers is NULL: pSrcDst, pAlpha,
77 *              pBeta, pThresholds, or pBS.
78 *    -    either pThresholds or pBS is not aligned on a 4-byte boundary.
79 *    -    pSrcDst is not 16-byte aligned.
80 *    -    srcdstStep is not a multiple of 16.
81 *    -    pAlpha[0] and/or pAlpha[1] is outside the range [0,255].
82 *    -    pBeta[0] and/or pBeta[1] is outside the range [0,18].
83 *    -    One or more entries in the table pThresholds[0..15] is
84 *         outside of the range [0,25].
85 *    -    pBS is out of range, i.e., one of the following conditions is true:
86 *              pBS[i]<0, pBS[i]>4, pBS[i]==4 for i>=4, or
87 *              (pBS[i]==4 && pBS[i^3]!=4) for 0<=i<=3.
88 *
89 */
90
91OMXResult omxVCM4P10_FilterDeblockingLuma_HorEdge_I(
92     OMX_U8* pSrcDst,
93     OMX_S32 srcdstStep,
94     const OMX_U8* pAlpha,
95     const OMX_U8* pBeta,
96     const OMX_U8* pThresholds,
97     const OMX_U8 *pBS
98 )
99{
100    int I, X, Y, Internal=0;
101
102    armRetArgErrIf(pSrcDst == NULL,             OMX_Sts_BadArgErr);
103    armRetArgErrIf(armNot8ByteAligned(pSrcDst), OMX_Sts_BadArgErr);
104    armRetArgErrIf(srcdstStep & 7,              OMX_Sts_BadArgErr);
105    armRetArgErrIf(pAlpha == NULL,              OMX_Sts_BadArgErr);
106    armRetArgErrIf(pBeta == NULL,               OMX_Sts_BadArgErr);
107    armRetArgErrIf(pThresholds == NULL,         OMX_Sts_BadArgErr);
108    armRetArgErrIf(armNot4ByteAligned(pThresholds), OMX_Sts_BadArgErr);
109    armRetArgErrIf(pBS == NULL,                     OMX_Sts_BadArgErr);
110    armRetArgErrIf(armNot4ByteAligned(pBS),         OMX_Sts_BadArgErr);
111
112    for (Y=0; Y<16; Y+=4, Internal=1)
113    {
114        for (X=0; X<16; X++)
115        {
116            I = (X>>2)+4*(Y>>2);
117
118            armRetArgErrIf(pBS[I] > 4, OMX_Sts_BadArgErr)
119
120            armRetArgErrIf( (I > 3) && (pBS[I] == 4),
121                            OMX_Sts_BadArgErr)
122
123            armRetArgErrIf( (I < 4)       &&
124                          ( (pBS[I] == 4) && (pBS[I^1] != 4) ),
125                            OMX_Sts_BadArgErr)
126
127            /* Filter horizontal edge with q0 at (X,Y) */
128            armVCM4P10_DeBlockPixel(
129                pSrcDst + Y*srcdstStep + X,
130                srcdstStep,
131                pThresholds[I],
132                pAlpha[Internal],
133                pBeta[Internal],
134                pBS[I],
135                0);
136        }
137    }
138
139    return OMX_Sts_NoErr;
140}
141