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 ******************************************************************************
21 * @file ihevc_sao.h
22 *
23 * @brief
24 *  This file contains enumerations, macros and extern declarations of HEVC
25 *  SAO
26 *
27 * @author
28 *  Ittiam
29 ******************************************************************************
30 */
31 
32 #ifndef _IHEVC_SAO_H_
33 #define _IHEVC_SAO_H_
34 
35 enum
36 {
37     SAO_NONE,
38 
39     SAO_BAND,
40 
41     SAO_EDGE_0_DEG,
42 
43     SAO_EDGE_90_DEG,
44 
45     SAO_EDGE_135_DEG,
46 
47     SAO_EDGE_45_DEG
48 };
49 
50 static const WORD32 gi4_ihevc_hbd_table_edge_idx[5] = { 1, 2, 0, 3, 4 };
51 
52 typedef void ihevc_sao_band_offset_luma_ft(UWORD8 *pu1_src,
53                                            WORD32 src_strd,
54                                            UWORD8 *pu1_src_left,
55                                            UWORD8 *pu1_src_top,
56                                            UWORD8 *pu1_src_top_left,
57                                            WORD32 sao_band_pos,
58                                            WORD8 *pi4_sao_offset,
59                                            WORD32 wd,
60                                            WORD32 ht);
61 
62 typedef void ihevc_hbd_sao_band_offset_luma_ft(UWORD16 *pu2_src,
63                                                WORD32 src_strd,
64                                                UWORD16 *pu2_src_left,
65                                                UWORD16 *pu2_src_top,
66                                                UWORD16 *pu2_src_top_left,
67                                                WORD32 sao_band_pos,
68                                                WORD8 *pi1_sao_offset,
69                                                WORD32 wd,
70                                                WORD32 ht,
71                                                UWORD32 bitdepth);
72 
73 typedef void ihevc_sao_band_offset_chroma_ft(UWORD8 *pu1_src,
74                                              WORD32 src_strd,
75                                              UWORD8 *pu1_src_left,
76                                              UWORD8 *pu1_src_top,
77                                              UWORD8 *pu1_src_top_left,
78                                              WORD32 sao_band_pos_u,
79                                              WORD32 sao_band_pos_v,
80                                              WORD8 *pi4_sao_offset_u,
81                                              WORD8 *pi4_sao_offset_v,
82                                              WORD32 wd,
83                                              WORD32 ht);
84 
85 typedef void ihevc_hbd_sao_band_offset_chroma_ft(UWORD16 *pu2_src,
86                                                  WORD32 src_strd,
87                                                  UWORD16 *pu2_src_left,
88                                                  UWORD16 *pu2_src_top,
89                                                  UWORD16 *pu2_src_top_left,
90                                                  WORD32 sao_band_pos_u,
91                                                  WORD32 sao_band_pos_v,
92                                                  WORD8 *pi1_sao_offset_u,
93                                                  WORD8 *pi1_sao_offset_v,
94                                                  WORD32 wd,
95                                                  WORD32 ht,
96                                                  UWORD32 bit_depth);
97 
98 typedef void ihevc_sao_edge_offset_class0_ft(UWORD8 *pu1_src,
99                                              WORD32 src_strd,
100                                              UWORD8 *pu1_src_left,
101                                              UWORD8 *pu1_src_top,
102                                              UWORD8 *pu1_src_top_left,
103                                              UWORD8 *pu1_src_top_right,
104                                              UWORD8 *pu1_src_bot_left,
105                                              UWORD8 *pu1_avail,
106                                              WORD8 *pi4_sao_offset,
107                                              WORD32 wd,
108                                              WORD32 ht);
109 
110 typedef void ihevc_hbd_sao_edge_offset_class0_ft(UWORD16 *pu2_src,
111                                                  WORD32 src_strd,
112                                                  UWORD16 *pu2_src_left,
113                                                  UWORD16 *pu2_src_top,
114                                                  UWORD16 *pu2_src_top_left,
115                                                  UWORD16 *pu2_src_top_right,
116                                                  UWORD16 *pu2_src_bot_left,
117                                                  UWORD8 *pu1_avail,
118                                                  WORD8 *pi1_sao_offset,
119                                                  WORD32 wd,
120                                                  WORD32 ht,
121                                                  UWORD32 bit_depth);
122 
123 typedef void ihevc_sao_edge_offset_class0_chroma_ft(UWORD8 *pu1_src,
124                                                     WORD32 src_strd,
125                                                     UWORD8 *pu1_src_left,
126                                                     UWORD8 *pu1_src_top,
127                                                     UWORD8 *pu1_src_top_left,
128                                                     UWORD8 *pu1_src_top_right,
129                                                     UWORD8 *pu1_src_bot_left,
130                                                     UWORD8 *pu1_avail,
131                                                     WORD8 *pi4_sao_offset_u,
132                                                     WORD8 *pi4_sao_offset_v,
133                                                     WORD32 wd,
134                                                     WORD32 ht);
135 
136 typedef void ihevc_hbd_sao_edge_offset_class0_chroma_ft(UWORD16 *pu2_src,
137                                                         WORD32 src_strd,
138                                                         UWORD16 *pu2_src_left,
139                                                         UWORD16 *pu2_src_top,
140                                                         UWORD16 *pu2_src_top_left,
141                                                         UWORD16 *pu2_src_top_right,
142                                                         UWORD16 *pu2_src_bot_left,
143                                                         UWORD8 *pu1_avail,
144                                                         WORD8 *pi1_sao_offset_u,
145                                                         WORD8 *pi1_sao_offset_v,
146                                                         WORD32 wd,
147                                                         WORD32 ht,
148                                                         UWORD32 bit_depth);
149 
150 typedef void ihevc_sao_edge_offset_class1_ft(UWORD8 *pu1_src,
151                                              WORD32 src_strd,
152                                              UWORD8 *pu1_src_left,
153                                              UWORD8 *pu1_src_top,
154                                              UWORD8 *pu1_src_top_left,
155                                              UWORD8 *pu1_src_top_right,
156                                              UWORD8 *pu1_src_bot_left,
157                                              UWORD8 *pu1_avail,
158                                              WORD8 *pi4_sao_offset,
159                                              WORD32 wd,
160                                              WORD32 ht);
161 
162 typedef void ihevc_hbd_sao_edge_offset_class1_ft(UWORD16 *pu2_src,
163                                                  WORD32 src_strd,
164                                                  UWORD16 *pu2_src_left,
165                                                  UWORD16 *pu2_src_top,
166                                                  UWORD16 *pu2_src_top_left,
167                                                  UWORD16 *pu2_src_top_right,
168                                                  UWORD16 *pu2_src_bot_left,
169                                                  UWORD8 *pu1_avail,
170                                                  WORD8 *pi1_sao_offset,
171                                                  WORD32 wd,
172                                                  WORD32 ht,
173                                                  UWORD32 bit_depth);
174 
175 typedef void ihevc_sao_edge_offset_class1_chroma_ft(UWORD8 *pu1_src,
176                                                     WORD32 src_strd,
177                                                     UWORD8 *pu1_src_left,
178                                                     UWORD8 *pu1_src_top,
179                                                     UWORD8 *pu1_src_top_left,
180                                                     UWORD8 *pu1_src_top_right,
181                                                     UWORD8 *pu1_src_bot_left,
182                                                     UWORD8 *pu1_avail,
183                                                     WORD8 *pi4_sao_offset_u,
184                                                     WORD8 *pi4_sao_offset_v,
185                                                     WORD32 wd,
186                                                     WORD32 ht);
187 
188 typedef void ihevc_hbd_sao_edge_offset_class1_chroma_ft(UWORD16 *pu2_src,
189                                                         WORD32 src_strd,
190                                                         UWORD16 *pu2_src_left,
191                                                         UWORD16 *pu2_src_top,
192                                                         UWORD16 *pu2_src_top_left,
193                                                         UWORD16 *pu2_src_top_right,
194                                                         UWORD16 *pu2_src_bot_left,
195                                                         UWORD8 *pu1_avail,
196                                                         WORD8 *pi1_sao_offset_u,
197                                                         WORD8 *pi1_sao_offset_v,
198                                                         WORD32 wd,
199                                                         WORD32 ht,
200                                                         UWORD32 bit_depth);
201 
202 typedef void ihevc_sao_edge_offset_class2_ft(UWORD8 *pu1_src,
203                                              WORD32 src_strd,
204                                              UWORD8 *pu1_src_left,
205                                              UWORD8 *pu1_src_top,
206                                              UWORD8 *pu1_src_top_left,
207                                              UWORD8 *pu1_src_top_right,
208                                              UWORD8 *pu1_src_bot_left,
209                                              UWORD8 *pu1_avail,
210                                              WORD8 *pi4_sao_offset,
211                                              WORD32 wd,
212                                              WORD32 ht);
213 
214 typedef void ihevc_hbd_sao_edge_offset_class2_ft(UWORD16 *pu2_src,
215                                                  WORD32 src_strd,
216                                                  UWORD16 *pu2_src_left,
217                                                  UWORD16 *pu2_src_top,
218                                                  UWORD16 *pu2_src_top_left,
219                                                  UWORD16 *pu2_src_top_right,
220                                                  UWORD16 *pu2_src_bot_left,
221                                                  UWORD8 *pu1_avail,
222                                                  WORD8 *pi1_sao_offset,
223                                                  WORD32 wd,
224                                                  WORD32 ht,
225                                                  UWORD32 bit_depth);
226 
227 typedef void ihevc_sao_edge_offset_class2_chroma_ft(UWORD8 *pu1_src,
228                                                     WORD32 src_strd,
229                                                     UWORD8 *pu1_src_left,
230                                                     UWORD8 *pu1_src_top,
231                                                     UWORD8 *pu1_src_top_left,
232                                                     UWORD8 *pu1_src_top_right,
233                                                     UWORD8 *pu1_src_bot_left,
234                                                     UWORD8 *pu1_avail,
235                                                     WORD8 *pi4_sao_offset_u,
236                                                     WORD8 *pi4_sao_offset_v,
237                                                     WORD32 wd,
238                                                     WORD32 ht);
239 
240 typedef void ihevc_hbd_sao_edge_offset_class2_chroma_ft(UWORD16 *pu2_src,
241                                                         WORD32 src_strd,
242                                                         UWORD16 *pu2_src_left,
243                                                         UWORD16 *pu2_src_top,
244                                                         UWORD16 *pu2_src_top_left,
245                                                         UWORD16 *pu2_src_top_right,
246                                                         UWORD16 *pu2_src_bot_left,
247                                                         UWORD8 *pu1_avail,
248                                                         WORD8 *pi1_sao_offset_u,
249                                                         WORD8 *pi1_sao_offset_v,
250                                                         WORD32 wd,
251                                                         WORD32 ht,
252                                                         UWORD32 bit_depth);
253 
254 typedef void ihevc_sao_edge_offset_class3_ft(UWORD8 *pu1_src,
255                                              WORD32 src_strd,
256                                              UWORD8 *pu1_src_left,
257                                              UWORD8 *pu1_src_top,
258                                              UWORD8 *pu1_src_top_left,
259                                              UWORD8 *pu1_src_top_right,
260                                              UWORD8 *pu1_src_bot_left,
261                                              UWORD8 *pu1_avail,
262                                              WORD8 *pi4_sao_offset,
263                                              WORD32 wd,
264                                              WORD32 ht);
265 
266 typedef void ihevc_hbd_sao_edge_offset_class3_ft(UWORD16 *pu2_src,
267                                                  WORD32 src_strd,
268                                                  UWORD16 *pu2_src_left,
269                                                  UWORD16 *pu2_src_top,
270                                                  UWORD16 *pu2_src_top_left,
271                                                  UWORD16 *pu2_src_top_right,
272                                                  UWORD16 *pu2_src_bot_left,
273                                                  UWORD8 *pu1_avail,
274                                                  WORD8 *pi1_sao_offset,
275                                                  WORD32 wd,
276                                                  WORD32 ht,
277                                                  UWORD32 bit_depth);
278 typedef void ihevc_sao_edge_offset_class3_chroma_ft(UWORD8 *pu1_src,
279                                                     WORD32 src_strd,
280                                                     UWORD8 *pu1_src_left,
281                                                     UWORD8 *pu1_src_top,
282                                                     UWORD8 *pu1_src_top_left,
283                                                     UWORD8 *pu1_src_top_right,
284                                                     UWORD8 *pu1_src_bot_left,
285                                                     UWORD8 *pu1_avail,
286                                                     WORD8 *pi4_sao_offset_u,
287                                                     WORD8 *pi4_sao_offset_v,
288                                                     WORD32 wd,
289                                                     WORD32 ht);
290 
291 typedef void ihevc_hbd_sao_edge_offset_class3_chroma_ft(UWORD16 *pu2_src,
292                                                         WORD32 src_strd,
293                                                         UWORD16 *pu2_src_left,
294                                                         UWORD16 *pu2_src_top,
295                                                         UWORD16 *pu2_src_top_left,
296                                                         UWORD16 *pu2_src_top_right,
297                                                         UWORD16 *pu2_src_bot_left,
298                                                         UWORD8 *pu1_avail,
299                                                         WORD8 *pi1_sao_offset_u,
300                                                         WORD8 *pi1_sao_offset_v,
301                                                         WORD32 wd,
302                                                         WORD32 ht,
303                                                         UWORD32 bit_depth);
304 /* C function declarations */
305 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma;
306 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma;
307 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0;
308 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma;
309 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1;
310 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma;
311 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2;
312 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma;
313 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3;
314 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma;
315 
316 /* NEONINTR function declarations */
317 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma_neonintr;
318 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma_neonintr;
319 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0_neonintr;
320 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma_neonintr;
321 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1_neonintr;
322 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma_neonintr;
323 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2_neonintr;
324 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma_neonintr;
325 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3_neonintr;
326 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma_neonintr;
327 
328 /* A9Q function declarations */
329 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma_a9q;
330 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma_a9q;
331 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0_a9q;
332 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma_a9q;
333 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1_a9q;
334 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma_a9q;
335 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2_a9q;
336 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma_a9q;
337 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3_a9q;
338 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma_a9q;
339 
340 /* A9A (Apple) function declarations */
341 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma_a9a;
342 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma_a9a;
343 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0_a9a;
344 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma_a9a;
345 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1_a9a;
346 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma_a9a;
347 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2_a9a;
348 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma_a9a;
349 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3_a9a;
350 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma_a9a;
351 
352 /* SSSE31 function declarations */
353 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma_ssse3;
354 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma_ssse3;
355 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0_ssse3;
356 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma_ssse3;
357 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1_ssse3;
358 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma_ssse3;
359 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2_ssse3;
360 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma_ssse3;
361 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3_ssse3;
362 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma_ssse3;
363 
364 /* SSE4 function declarations */
365 
366 /* C high bit depth function declarations */
367 ihevc_hbd_sao_band_offset_luma_ft ihevc_hbd_sao_band_offset_luma;
368 ihevc_hbd_sao_band_offset_chroma_ft ihevc_hbd_sao_band_offset_chroma;
369 ihevc_hbd_sao_edge_offset_class0_ft ihevc_hbd_sao_edge_offset_class0;
370 ihevc_hbd_sao_edge_offset_class0_chroma_ft ihevc_hbd_sao_edge_offset_class0_chroma;
371 ihevc_hbd_sao_edge_offset_class1_ft ihevc_hbd_sao_edge_offset_class1;
372 ihevc_hbd_sao_edge_offset_class1_chroma_ft ihevc_hbd_sao_edge_offset_class1_chroma;
373 ihevc_hbd_sao_edge_offset_class2_ft ihevc_hbd_sao_edge_offset_class2;
374 ihevc_hbd_sao_edge_offset_class2_chroma_ft ihevc_hbd_sao_edge_offset_class2_chroma;
375 ihevc_hbd_sao_edge_offset_class3_ft ihevc_hbd_sao_edge_offset_class3;
376 ihevc_hbd_sao_edge_offset_class3_chroma_ft ihevc_hbd_sao_edge_offset_class3_chroma;
377 
378 /* SSE4.2 HBD function Declarations*/
379 ihevc_hbd_sao_band_offset_luma_ft ihevc_hbd_sao_band_offset_luma_sse42;
380 ihevc_hbd_sao_band_offset_chroma_ft ihevc_hbd_sao_band_offset_chroma_sse42;
381 ihevc_hbd_sao_edge_offset_class0_ft ihevc_hbd_sao_edge_offset_class0_sse42;
382 ihevc_hbd_sao_edge_offset_class0_chroma_ft ihevc_hbd_sao_edge_offset_class0_chroma_sse42;
383 ihevc_hbd_sao_edge_offset_class1_ft ihevc_hbd_sao_edge_offset_class1_sse42;
384 ihevc_hbd_sao_edge_offset_class1_chroma_ft ihevc_hbd_sao_edge_offset_class1_chroma_sse42;
385 ihevc_hbd_sao_edge_offset_class2_ft ihevc_hbd_sao_edge_offset_class2_sse42;
386 ihevc_hbd_sao_edge_offset_class2_chroma_ft ihevc_hbd_sao_edge_offset_class2_chroma_sse42;
387 ihevc_hbd_sao_edge_offset_class3_ft ihevc_hbd_sao_edge_offset_class3_sse42;
388 ihevc_hbd_sao_edge_offset_class3_chroma_ft ihevc_hbd_sao_edge_offset_class3_chroma_sse42;
389 
390 /* armv8 function declarations */
391 ihevc_sao_band_offset_luma_ft ihevc_sao_band_offset_luma_av8;
392 ihevc_sao_band_offset_chroma_ft ihevc_sao_band_offset_chroma_av8;
393 ihevc_sao_edge_offset_class0_ft ihevc_sao_edge_offset_class0_av8;
394 ihevc_sao_edge_offset_class0_chroma_ft ihevc_sao_edge_offset_class0_chroma_av8;
395 ihevc_sao_edge_offset_class1_ft ihevc_sao_edge_offset_class1_av8;
396 ihevc_sao_edge_offset_class1_chroma_ft ihevc_sao_edge_offset_class1_chroma_av8;
397 ihevc_sao_edge_offset_class2_ft ihevc_sao_edge_offset_class2_av8;
398 ihevc_sao_edge_offset_class2_chroma_ft ihevc_sao_edge_offset_class2_chroma_av8;
399 ihevc_sao_edge_offset_class3_ft ihevc_sao_edge_offset_class3_av8;
400 ihevc_sao_edge_offset_class3_chroma_ft ihevc_sao_edge_offset_class3_chroma_av8;
401 
402 #endif /* _IHEVC_SAO_H_ */
403