Coverage Report

Created: 2024-07-27 06:35

/src/libavc/common/ih264_padding.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2015 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
*/
20
21
/**
22
*******************************************************************************
23
* @file
24
*  ih264_padding.c
25
*
26
* @brief
27
*  Contains function definitions for Padding
28
*
29
* @author
30
*  ittiam
31
*
32
* @par List of Functions:
33
*  - ih264_pad_top
34
*  - ih264_pad_bottom
35
*  - ih264_pad_left_luma
36
*  - ih264_pad_left_chroma
37
*  - ih264_pad_right_luma
38
*  - ih264_pad_right_chroma
39
*
40
* @remarks
41
*  none
42
*
43
*******************************************************************************
44
*/
45
46
/*****************************************************************************/
47
/* File Includes                                                             */
48
/*****************************************************************************/
49
50
/* System Include Files */
51
#include <stddef.h>
52
#include <string.h>
53
54
/* User Include Files */
55
#include "ih264_typedefs.h"
56
#include "ih264_macros.h"
57
#include "ih264_padding.h"
58
59
60
/*****************************************************************************/
61
/* Function Definitions                                                      */
62
/*****************************************************************************/
63
64
/**
65
*******************************************************************************
66
*
67
* @brief pad at the top of a 2d array
68
*
69
* @par Description:
70
*  The top row of a 2d array is replicated for pad_size times at the top
71
*
72
* @param[in] pu1_src
73
*  pointer to the source
74
*
75
* @param[in] src_strd
76
*  source stride
77
*
78
* @param[in] wd
79
*  width of the array
80
*
81
* @param[in] pad_size
82
*  padding size of the array
83
*
84
* @returns none
85
*
86
* @remarks none
87
*
88
*******************************************************************************
89
*/
90
void ih264_pad_top(UWORD8 *pu1_src,
91
                   WORD32 src_strd,
92
                   WORD32 wd,
93
                   WORD32 pad_size)
94
666k
{
95
666k
    WORD32 row;
96
97
11.4M
    for(row = 1; row <= pad_size; row++)
98
10.8M
    {
99
10.8M
        memcpy(pu1_src - row * src_strd, pu1_src, wd);
100
10.8M
    }
101
666k
}
102
103
/**
104
*******************************************************************************
105
*
106
* @brief pad at the bottom of a 2d array
107
*
108
* @par Description:
109
*  The bottom row of a 2d array is replicated for pad_size times at the bottom
110
*
111
* @param[in] pu1_src
112
*  pointer to the source
113
*
114
* @param[in] src_strd
115
*  source stride
116
*
117
* @param[in] wd
118
*  width of the array
119
*
120
* @param[in] pad_size
121
*  padding size of the array
122
*
123
* @returns none
124
*
125
* @remarks none
126
*
127
*******************************************************************************
128
*/
129
void ih264_pad_bottom(UWORD8 *pu1_src,
130
                      WORD32 src_strd,
131
                      WORD32 wd,
132
                      WORD32 pad_size)
133
666k
{
134
666k
    WORD32 row;
135
136
11.4M
    for(row = 1; row <= pad_size; row++)
137
10.8M
    {
138
10.8M
        memcpy(pu1_src + (row - 1) * src_strd, pu1_src - 1 * src_strd, wd);
139
10.8M
    }
140
666k
}
141
142
/**
143
*******************************************************************************
144
*
145
* @brief pad (luma block) at the left of a 2d array
146
*
147
* @par Description:
148
*  The left column of a 2d array is replicated for pad_size times to the left
149
*
150
* @param[in] pu1_src
151
*  pointer to the source
152
*
153
* @param[in] src_strd
154
*  source stride
155
*
156
* @param[in] ht
157
*  height of the array
158
*
159
* @param[in] pad_size
160
*  padding size of the array
161
*
162
* @returns none
163
*
164
* @remarks none
165
*
166
*******************************************************************************
167
*/
168
void ih264_pad_left_luma(UWORD8 *pu1_src,
169
                         WORD32 src_strd,
170
                         WORD32 ht,
171
                         WORD32 pad_size)
172
203k
{
173
203k
    WORD32 row;
174
175
15.5M
    for(row = 0; row < ht; row++)
176
15.3M
    {
177
15.3M
        memset(pu1_src - pad_size, *pu1_src, pad_size);
178
15.3M
        pu1_src += src_strd;
179
15.3M
    }
180
203k
}
181
182
/**
183
*******************************************************************************
184
*
185
* @brief pad (chroma block) at the left of a 2d array
186
*
187
* @par Description:
188
*  The left column of a 2d array is replicated for pad_size times to the left
189
*
190
* @param[in] pu1_src
191
*  pointer to the source
192
*
193
* @param[in] src_strd
194
*  source stride
195
*
196
* @param[in] ht
197
*  height of the array
198
*
199
* @param[in] pad_size
200
*  padding size of the array
201
*
202
* @returns none
203
*
204
* @remarks none
205
*
206
*******************************************************************************
207
*/
208
void ih264_pad_left_chroma(UWORD8 *pu1_src,
209
                           WORD32 src_strd,
210
                           WORD32 ht,
211
                           WORD32 pad_size)
212
168k
{
213
168k
    WORD32 row, col;
214
168k
    UWORD16 u2_uv_val;
215
168k
    UWORD16 *pu2_src = (UWORD16 *)pu1_src;
216
217
168k
    src_strd >>= 1;
218
168k
    pad_size >>= 1;
219
220
7.76M
    for(row = 0; row < ht; row++)
221
7.60M
    {
222
7.60M
        u2_uv_val = pu2_src[0];
223
119M
        for(col = -pad_size; col < 0; col++)
224
112M
        {
225
112M
            pu2_src[col] = u2_uv_val;
226
112M
        }
227
7.60M
        pu2_src += src_strd;
228
7.60M
    }
229
168k
}
230
231
/**
232
*******************************************************************************
233
*
234
* @brief pad (luma block) at the right of a 2d array
235
*
236
* @par Description:
237
*  The right column of a 2d array is replicated for pad_size times at the right
238
*
239
* @param[in] pu1_src
240
*  pointer to the source
241
*
242
* @param[in] src_strd
243
*  source stride
244
*
245
* @param[in] ht
246
*  height of the array
247
*
248
* @param[in] pad_size
249
*  padding size of the array
250
*
251
* @returns none
252
*
253
* @remarks none
254
*
255
*******************************************************************************
256
*/
257
void ih264_pad_right_luma(UWORD8 *pu1_src,
258
                          WORD32 src_strd,
259
                          WORD32 ht,
260
                          WORD32 pad_size)
261
203k
{
262
203k
    WORD32 row;
263
264
15.5M
    for(row = 0; row < ht; row++)
265
15.3M
    {
266
15.3M
        memset(pu1_src, *(pu1_src -1), pad_size);
267
15.3M
        pu1_src += src_strd;
268
15.3M
    }
269
203k
}
270
271
/**
272
*******************************************************************************
273
*
274
* @brief pad (chroma block) at the right of a 2d array
275
*
276
* @par Description:
277
*  The right column of a 2d array is replicated for pad_size times at the right
278
*
279
* @param[in] pu1_src
280
*  pointer to the source
281
*
282
* @param[in] src_strd
283
*  source stride
284
*
285
* @param[in] ht
286
*  height of the array
287
*
288
* @param[in] pad_size
289
*  padding size of the array
290
*
291
* @returns none
292
*
293
* @remarks none
294
*
295
*******************************************************************************
296
*/
297
void ih264_pad_right_chroma(UWORD8 *pu1_src,
298
                            WORD32 src_strd,
299
                            WORD32 ht,
300
                            WORD32 pad_size)
301
168k
{
302
168k
    WORD32 row, col;
303
168k
    UWORD16 u2_uv_val;
304
168k
    UWORD16 *pu2_src = (UWORD16 *)pu1_src;
305
306
168k
    src_strd >>= 1;
307
168k
    pad_size >>= 1;
308
309
7.76M
    for(row = 0; row < ht; row++)
310
7.60M
    {
311
7.60M
        u2_uv_val = pu2_src[-1];
312
119M
        for(col = 0; col < pad_size; col++)
313
112M
        {
314
112M
            pu2_src[col] = u2_uv_val;
315
112M
        }
316
7.60M
        pu2_src += src_strd;
317
7.60M
    }
318
168k
}
319