xref: /aosp_15_r20/external/libdav1d/src/ppc/dav1d_types.h (revision c09093415860a1c2373dacd84c4fde00c507cdfd)
1 /*
2  * Copyright © 2019, VideoLAN and dav1d authors
3  * Copyright © 2019, Luca Barbato
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  *    list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef DAV1D_SRC_PPC_TYPES_H
29 #define DAV1D_SRC_PPC_TYPES_H
30 
31 #include <altivec.h>
32 #undef pixel
33 
34 #define u8x16 vector unsigned char
35 #define i8x16 vector signed char
36 #define b8x16 vector bool char
37 #define u16x8 vector unsigned short
38 #define i16x8 vector signed short
39 #define b16x8 vector bool short
40 #define u32x4 vector unsigned int
41 #define i32x4 vector signed int
42 #define b32x4 vector bool int
43 #define u64x2 vector unsigned long long
44 #define i64x2 vector signed long long
45 #define b64x2 vector bool long long
46 
47 #define i8h_to_i16(v) ((i16x8) vec_unpackh((i8x16)v))
48 #define i8l_to_i16(v) ((i16x8) vec_unpackl((i8x16)v))
49 #define u8h_to_i16(v) ((i16x8) vec_mergeh((u8x16) v, vec_splat_u8(0)))
50 #define u8l_to_i16(v) ((i16x8) vec_mergel((u8x16) v, vec_splat_u8(0)))
51 #define u8h_to_u16(v) ((u16x8) vec_mergeh((u8x16) v, vec_splat_u8(0)))
52 #define u8l_to_u16(v) ((u16x8) vec_mergel((u8x16) v, vec_splat_u8(0)))
53 #define u16h_to_i32(v) ((i32x4) vec_mergeh((u16x8) v, vec_splat_u16(0)))
54 #define i16h_to_i32(v) ((i32x4) vec_unpackh((i16x8)v))
55 #define u16l_to_i32(v) ((i32x4) vec_mergel((u16x8) v, vec_splat_u16(0)))
56 #define i16l_to_i32(v) ((i32x4) vec_unpackl((i16x8)v))
57 
58 #endif /* DAV1D_SRC_PPC_TYPES_H */
59