/src/libavc/common/svc/isvc_mem_fns.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2022 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 | | * @file |
23 | | * isvc_mem_fns.c |
24 | | * |
25 | | * @brief |
26 | | * Functions used for memory operations |
27 | | * |
28 | | * @author |
29 | | * Ittiam |
30 | | * |
31 | | * @par List of Functions: |
32 | | * isvc_memcpy() |
33 | | * isvc_memcpy_mul_8() |
34 | | * isvc_memset() |
35 | | * isvc_memset_mul_8() |
36 | | * isvc_memset_16bit() |
37 | | * isvc_memset_16bit_mul_8() |
38 | | * isvc_memory_alloc() |
39 | | * isvc_memory_free() |
40 | | * |
41 | | * @remarks |
42 | | * None |
43 | | * |
44 | | ****************************************************************************** |
45 | | */ |
46 | | |
47 | | /*****************************************************************************/ |
48 | | /* File Includes */ |
49 | | /*****************************************************************************/ |
50 | | /* System include files */ |
51 | | #include <stdio.h> |
52 | | #include <stddef.h> |
53 | | #include <stdlib.h> |
54 | | #include <string.h> |
55 | | #include <assert.h> |
56 | | |
57 | | /* User include files */ |
58 | | #include "ih264_typedefs.h" |
59 | | #include "isvc_mem_fns.h" |
60 | | |
61 | | /** |
62 | | ******************************************************************************** |
63 | | * @brief copies a 2d blk from one location to another |
64 | | * |
65 | | * @param[out] pu1_dst : dst pointer |
66 | | * |
67 | | * @param[in] i4_dst_stride: stride of destination |
68 | | * |
69 | | * @param[in] pu1_src : src ptr |
70 | | * |
71 | | * @param[in] i4_src_stride: stride of src |
72 | | * |
73 | | * @param[in] i4_blk_wd : blk width |
74 | | * |
75 | | * @param[in] i4_blk_ht : blk height |
76 | | * |
77 | | * @return void |
78 | | ******************************************************************************** |
79 | | */ |
80 | | |
81 | | void isvc_copy_2d(UWORD8 *pu1_dst, WORD32 i4_dst_stride, UWORD8 *pu1_src, WORD32 i4_src_stride, |
82 | | WORD32 i4_blk_wd, WORD32 i4_blk_ht) |
83 | 2.26M | { |
84 | 2.26M | WORD32 i; |
85 | | |
86 | 31.5M | for(i = 0; i < i4_blk_ht; i++) |
87 | 29.3M | { |
88 | 29.3M | memmove(pu1_dst, pu1_src, i4_blk_wd * sizeof(pu1_dst[0])); |
89 | | |
90 | 29.3M | pu1_dst += i4_dst_stride; |
91 | 29.3M | pu1_src += i4_src_stride; |
92 | 29.3M | } |
93 | 2.26M | } |
94 | | |
95 | | /** |
96 | | ******************************************************************************** |
97 | | * @brief memsets a 2d blk |
98 | | * |
99 | | * @param[out] pu1_dst : dst pointer |
100 | | * |
101 | | * @param[in] i4_dst_stride: stride of destination |
102 | | * |
103 | | * @param[in] i4_blk_wd : blk width |
104 | | * |
105 | | * @param[in] i4_blk_ht : blk height |
106 | | * |
107 | | * @return void |
108 | | ******************************************************************************** |
109 | | */ |
110 | | void isvc_memset_2d(UWORD8 *pu1_dst, WORD32 i4_dst_stride, UWORD8 u1_val, WORD32 i4_blk_wd, |
111 | | WORD32 i4_blk_ht) |
112 | 209k | { |
113 | 209k | WORD32 i; |
114 | | |
115 | 2.82M | for(i = 0; i < i4_blk_ht; i++) |
116 | 2.62M | { |
117 | 2.62M | memset(pu1_dst, u1_val, i4_blk_wd); |
118 | | |
119 | 2.62M | pu1_dst += i4_dst_stride; |
120 | 2.62M | } |
121 | 209k | } |
122 | | |
123 | | /** |
124 | | ******************************************************************************* |
125 | | * |
126 | | * @brief |
127 | | * Checks if any pixel in a block is non-zero |
128 | | * |
129 | | * @param[in] pu1_data |
130 | | * UWORD8 pointer to the block to be checked |
131 | | * |
132 | | * @param[in] i4_data_strd |
133 | | * Stride of data buffer |
134 | | * |
135 | | * @param[in] u4_wd |
136 | | * Width of the block |
137 | | * |
138 | | * @param[in] u4_ht |
139 | | * Height of the block |
140 | | * |
141 | | ******************************************************************************* |
142 | | */ |
143 | | UWORD8 isvc_is_nonzero_blk(UWORD8 *pu1_data, WORD32 i4_data_strd, UWORD32 u4_wd, UWORD32 u4_ht) |
144 | 3.38M | { |
145 | 3.38M | UWORD32 i, j; |
146 | | |
147 | 13.5M | for(i = 0; i < u4_ht; i++) |
148 | 11.0M | { |
149 | 92.6M | for(j = 0; j < u4_wd; j++) |
150 | 82.4M | { |
151 | 82.4M | if(pu1_data[j + i * i4_data_strd]) |
152 | 841k | { |
153 | 841k | return 1; |
154 | 841k | } |
155 | 82.4M | } |
156 | 11.0M | } |
157 | | |
158 | 2.54M | return 0; |
159 | 3.38M | } |