Coverage Report

Created: 2026-08-31 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libhevc/common/ihevc_padding.c
Line
Count
Source
1
/******************************************************************************
2
*
3
* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
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
/**
19
*******************************************************************************
20
* @file
21
*  ihevc_padding.c
22
*
23
* @brief
24
*  Contains function definitions for Padding
25
*
26
* @author
27
*  Srinivas T
28
*
29
* @par List of Functions:
30
*   - ihevc_pad_horz_luma()
31
*   - ihevc_pad_horz_chroma()
32
*   - ihevc_pad_vert()
33
*   - ihevc_pad_left_luma()
34
*   - ihevc_pad_left_chroma()
35
*   - ihevc_pad_right_luma()
36
*   - ihevc_pad_right_chroma()
37
*   - ihevc_pad_top()
38
*   - ihevc_pad_bottom()
39
*
40
* @remarks
41
*  None
42
*
43
*******************************************************************************
44
*/
45
46
#include <string.h>
47
#include "ihevc_typedefs.h"
48
#include "ihevc_platform_macros.h"
49
#include "ihevc_mem_fns.h"
50
/**
51
*******************************************************************************
52
*
53
* @brief
54
*       Padding function for horizontal input variable
55
*
56
* @par Description:
57
*
58
*
59
* @param[in] pu1_src
60
*  UWORD8 pointer to the source
61
*
62
* @param[in] src_strd
63
*  integer source stride
64
*
65
* @param[in] ht
66
*  integer height of the array
67
*
68
* @param[in] wd
69
*  integer width of the array
70
*
71
* @param[in] pad_size
72
*  integer -padding size of the array
73
*
74
* @param[in] ht
75
*  integer height of the array
76
*
77
* @param[in] wd
78
*  integer width of the array
79
*
80
* @returns
81
*
82
* @remarks
83
*  None
84
*
85
*******************************************************************************
86
*/
87
88
void ihevc_pad_vert(UWORD8 *pu1_src,
89
                    WORD32 src_strd,
90
                    WORD32 ht,
91
                    WORD32 wd,
92
                    WORD32 pad_size)
93
0
{
94
0
    WORD32 row;
95
96
0
    for(row = 1; row <= pad_size; row++)
97
0
    {
98
0
        memcpy(pu1_src - row * src_strd, pu1_src, wd);
99
0
        memcpy(pu1_src + (ht + row - 1) * src_strd,
100
0
               pu1_src + (ht - 1) * src_strd, wd);
101
0
    }
102
0
}
103
104
/**
105
*******************************************************************************
106
*
107
* @brief
108
*   Padding function for vertical input variable
109
*
110
* @par Description:
111
*
112
*
113
* @param[in] pu1_src
114
*  UWORD8 pointer to the source
115
*
116
* @param[in] src_strd
117
*  integer source stride
118
*
119
* @param[in] ht
120
*  integer height of the array
121
*
122
* @param[in] wd
123
*  integer width of the array
124
*
125
* @param[in] pad_size
126
*  integer -padding size of the array
127
*
128
* @param[in] ht
129
*  integer height of the array
130
*
131
* @param[in] wd
132
*  integer width of the array
133
*
134
* @returns
135
*
136
* @remarks
137
*  None
138
*
139
*******************************************************************************
140
*/
141
142
void ihevc_pad_horz_chroma(UWORD8 *pu1_src,
143
                           WORD32 src_strd,
144
                           WORD32 ht,
145
                           WORD32 wd,
146
                           WORD32 pad_size)
147
0
{
148
0
    WORD32 row;
149
    //WORD32 col;
150
0
    UWORD16 *pu2_src = (UWORD16 *)pu1_src;
151
152
0
    src_strd >>= 1;
153
0
    wd >>= 1;
154
0
    pad_size >>= 1;
155
156
0
    for(row = 0; row < ht; row++)
157
0
    {
158
0
        UWORD16 u2_uv_val;
159
160
0
        u2_uv_val = pu2_src[0];
161
0
        ihevc_memset_16bit(&pu2_src[-pad_size], u2_uv_val, pad_size);
162
163
0
        u2_uv_val = pu2_src[wd - 1];
164
0
        ihevc_memset_16bit(&pu2_src[wd], u2_uv_val, pad_size);
165
166
0
        pu2_src += src_strd;
167
0
    }
168
0
}
169
170
171
/**
172
*******************************************************************************
173
*
174
* @brief
175
*   Padding function for vertical input variable
176
*
177
* @par Description:
178
*
179
*
180
* @param[in] pu1_src
181
*  UWORD8 pointer to the source
182
*
183
* @param[in] src_strd
184
*  integer source stride
185
*
186
* @param[in] ht
187
*  integer height of the array
188
*
189
* @param[in] wd
190
*  integer width of the array
191
*
192
* @param[in] pad_size
193
*  integer -padding size of the array
194
*
195
* @param[in] ht
196
*  integer height of the array
197
*
198
* @param[in] wd
199
*  integer width of the array
200
*
201
* @returns
202
*
203
* @remarks
204
*  None
205
*
206
*******************************************************************************
207
*/
208
209
void ihevc_pad_horz_luma(UWORD8 *pu1_src,
210
                         WORD32 src_strd,
211
                         WORD32 ht,
212
                         WORD32 wd,
213
                         WORD32 pad_size)
214
0
{
215
0
    WORD32 row;
216
217
0
    for(row = 0; row < ht; row++)
218
0
    {
219
0
        memset(pu1_src - pad_size, *pu1_src, pad_size);
220
0
        memset(pu1_src + wd, *(pu1_src + wd - 1), pad_size);
221
222
0
        pu1_src += src_strd;
223
0
    }
224
0
}
225
226
227
228
/**
229
*******************************************************************************
230
*
231
* @brief
232
*       Padding at the top of a 2d array
233
*
234
* @par Description:
235
*       The top row of a 2d array is replicated for pad_size times at the top
236
*
237
*
238
* @param[in] pu1_src
239
*  UWORD8 pointer to the source
240
*
241
* @param[in] src_strd
242
*  integer source stride
243
*
244
* @param[in] ht
245
*  integer height of the array
246
*
247
* @param[in] wd
248
*  integer width of the array
249
*
250
* @param[in] pad_size
251
*  integer -padding size of the array
252
*
253
* @param[in] ht
254
*  integer height of the array
255
*
256
* @param[in] wd
257
*  integer width of the array
258
*
259
* @returns
260
*
261
* @remarks
262
*  None
263
*
264
*******************************************************************************
265
*/
266
267
void ihevc_pad_top(UWORD8 *pu1_src,
268
                   WORD32 src_strd,
269
                   WORD32 wd,
270
                   WORD32 pad_size)
271
0
{
272
0
    WORD32 row;
273
274
0
    for(row = 1; row <= pad_size; row++)
275
0
    {
276
0
        memcpy(pu1_src - row * src_strd, pu1_src, wd);
277
0
    }
278
0
}
279
280
281
282
/**
283
*******************************************************************************
284
*
285
* @brief
286
*   Padding at the bottom of a 2d array
287
*
288
* @par Description:
289
*   The bottom row of a 2d array is replicated for pad_size times at the bottom
290
*
291
*
292
* @param[in] pu1_src
293
*  UWORD8 pointer to the source
294
*
295
* @param[in] src_strd
296
*  integer source stride
297
*
298
* @param[in] ht
299
*  integer height of the array
300
*
301
* @param[in] wd
302
*  integer width of the array
303
*
304
* @param[in] pad_size
305
*  integer -padding size of the array
306
*
307
* @param[in] ht
308
*  integer height of the array
309
*
310
* @param[in] wd
311
*  integer width of the array
312
*
313
* @returns
314
*
315
* @remarks
316
*  None
317
*
318
*******************************************************************************
319
*/
320
321
void ihevc_pad_bottom(UWORD8 *pu1_src,
322
                      WORD32 src_strd,
323
                      WORD32 wd,
324
                      WORD32 pad_size)
325
0
{
326
0
    WORD32 row;
327
328
0
    for(row = 1; row <= pad_size; row++)
329
0
    {
330
0
        memcpy(pu1_src + (row - 1) * src_strd,
331
0
               pu1_src - 1 * src_strd, wd);
332
0
    }
333
0
}
334
335
336
337
/**
338
*******************************************************************************
339
*
340
* @brief
341
*   Padding (luma block) at the left of a 2d array
342
*
343
* @par Description:
344
*   The left column of a 2d array is replicated for pad_size times at the left
345
*
346
*
347
* @param[in] pu1_src
348
*  UWORD8 pointer to the source
349
*
350
* @param[in] src_strd
351
*  integer source stride
352
*
353
* @param[in] ht
354
*  integer height of the array
355
*
356
* @param[in] wd
357
*  integer width of the array
358
*
359
* @param[in] pad_size
360
*  integer -padding size of the array
361
*
362
* @param[in] ht
363
*  integer height of the array
364
*
365
* @param[in] wd
366
*  integer width of the array
367
*
368
* @returns
369
*
370
* @remarks
371
*  None
372
*
373
*******************************************************************************
374
*/
375
376
void ihevc_pad_left_luma(UWORD8 *pu1_src,
377
                         WORD32 src_strd,
378
                         WORD32 ht,
379
                         WORD32 pad_size)
380
0
{
381
0
    WORD32 row;
382
383
0
    for(row = 0; row < ht; row++)
384
0
    {
385
0
        memset(pu1_src - pad_size, *pu1_src, pad_size);
386
387
0
        pu1_src += src_strd;
388
0
    }
389
0
}
390
391
392
393
/**
394
*******************************************************************************
395
*
396
* @brief
397
*   Padding (chroma block) at the left of a 2d array
398
*
399
* @par Description:
400
*   The left column of a 2d array is replicated for pad_size times at the left
401
*
402
*
403
* @param[in] pu1_src
404
*  UWORD8 pointer to the source
405
*
406
* @param[in] src_strd
407
*  integer source stride
408
*
409
* @param[in] ht
410
*  integer height of the array
411
*
412
* @param[in] wd
413
*  integer width of the array (each colour component)
414
*
415
* @param[in] pad_size
416
*  integer -padding size of the array
417
*
418
* @param[in] ht
419
*  integer height of the array
420
*
421
* @param[in] wd
422
*  integer width of the array
423
*
424
* @returns
425
*
426
* @remarks
427
*  None
428
*
429
*******************************************************************************
430
*/
431
432
void ihevc_pad_left_chroma(UWORD8 *pu1_src,
433
                           WORD32 src_strd,
434
                           WORD32 ht,
435
                           WORD32 pad_size)
436
0
{
437
0
    WORD32 row;
438
0
    WORD32 col;
439
0
    UWORD16 *pu2_src = (UWORD16 *)pu1_src;
440
441
0
    src_strd >>= 1;
442
0
    pad_size >>= 1;
443
444
0
    for(row = 0; row < ht; row++)
445
0
    {
446
0
        UWORD16 u2_uv_val;
447
448
0
        u2_uv_val = pu2_src[0];
449
0
        for(col = -pad_size; col < 0; col++)
450
0
            pu2_src[col] = u2_uv_val;
451
452
0
        pu2_src += src_strd;
453
0
    }
454
0
}
455
456
457
458
/**
459
*******************************************************************************
460
*
461
* @brief
462
* Padding (luma block) at the right of a 2d array
463
*
464
* @par Description:
465
* The right column of a 2d array is replicated for pad_size times at the right
466
*
467
*
468
* @param[in] pu1_src
469
*  UWORD8 pointer to the source
470
*
471
* @param[in] src_strd
472
*  integer source stride
473
*
474
* @param[in] ht
475
*  integer height of the array
476
*
477
* @param[in] wd
478
*  integer width of the array
479
*
480
* @param[in] pad_size
481
*  integer -padding size of the array
482
*
483
* @param[in] ht
484
*  integer height of the array
485
*
486
* @param[in] wd
487
*  integer width of the array
488
*
489
* @returns
490
*
491
* @remarks
492
*  None
493
*
494
*******************************************************************************
495
*/
496
497
void ihevc_pad_right_luma(UWORD8 *pu1_src,
498
                          WORD32 src_strd,
499
                          WORD32 ht,
500
                          WORD32 pad_size)
501
0
{
502
0
    WORD32 row;
503
504
0
    for(row = 0; row < ht; row++)
505
0
    {
506
0
        memset(pu1_src, *(pu1_src - 1), pad_size);
507
508
0
        pu1_src += src_strd;
509
0
    }
510
0
}
511
512
513
514
/**
515
*******************************************************************************
516
*
517
* @brief
518
* Padding (chroma block) at the right of a 2d array
519
*
520
* @par Description:
521
* The right column of a 2d array is replicated for pad_size times at the right
522
*
523
*
524
* @param[in] pu1_src
525
*  UWORD8 pointer to the source
526
*
527
* @param[in] src_strd
528
*  integer source stride
529
*
530
* @param[in] ht
531
*  integer height of the array
532
*
533
* @param[in] wd
534
*  integer width of the array (each colour component)
535
*
536
* @param[in] pad_size
537
*  integer -padding size of the array
538
*
539
* @param[in] ht
540
*  integer height of the array
541
*
542
* @param[in] wd
543
*  integer width of the array
544
*
545
* @returns
546
*
547
* @remarks
548
*  None
549
*
550
*******************************************************************************
551
*/
552
553
void ihevc_pad_right_chroma(UWORD8 *pu1_src,
554
                            WORD32 src_strd,
555
                            WORD32 ht,
556
                            WORD32 pad_size)
557
0
{
558
0
    WORD32 row;
559
0
    WORD32 col;
560
0
    UWORD16 *pu2_src = (UWORD16 *)pu1_src;
561
562
0
    src_strd >>= 1;
563
0
    pad_size >>= 1;
564
565
0
    for(row = 0; row < ht; row++)
566
0
    {
567
0
        UWORD16 u2_uv_val;
568
569
0
        u2_uv_val = pu2_src[-1];
570
0
        for(col = 0; col < pad_size; col++)
571
0
            pu2_src[col] = u2_uv_val;
572
573
0
        pu2_src += src_strd;
574
0
    }
575
0
}
576