Vector Optimized Library of Kernels 3.1.0
Architecture-tuned implementations of math kernels
volk_8u_x3_encodepolarpuppet_8u.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2015 Free Software Foundation, Inc.
4 *
5 * This file is part of VOLK
6 *
7 * SPDX-License-Identifier: LGPL-3.0-or-later
8 */
9
10/* For documentation see 'kernels/volk/volk_8u_x3_encodepolar_8u_x2.h'
11 * This file exists for test purposes only. Should not be used directly.
12 */
13
14#ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
15#define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
16#include <volk/volk.h>
18
19static inline unsigned int next_lower_power_of_two(const unsigned int val)
20{
21 // algorithm found and adopted from:
22 // http://acius2.blogspot.de/2007/11/calculating-next-power-of-2.html
23 unsigned int res = val;
24 res = (res >> 1) | res;
25 res = (res >> 2) | res;
26 res = (res >> 4) | res;
27 res = (res >> 8) | res;
28 res = (res >> 16) | res;
29 res += 1;
30 return res >> 1;
31}
32
33static inline void adjust_frozen_mask(unsigned char* mask, const unsigned int frame_size)
34{
35 // just like the rest of the puppet this function exists for test purposes only.
36 unsigned int i;
37 for (i = 0; i < frame_size; ++i) {
38 *mask = (*mask & 0x80) ? 0xFF : 0x00;
39 mask++;
40 }
41}
42
43#ifdef LV_HAVE_GENERIC
44static inline void
46 unsigned char* frozen_bit_mask,
47 const unsigned char* frozen_bits,
48 const unsigned char* info_bits,
49 unsigned int frame_size)
50{
51 if (frame_size < 1) {
52 return;
53 }
54
55 frame_size = next_lower_power_of_two(frame_size);
56 unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
57 volk_get_alignment());
58 adjust_frozen_mask(frozen_bit_mask, frame_size);
60 frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
61 volk_free(temp);
62}
63#endif /* LV_HAVE_GENERIC */
64
65
66#ifdef LV_HAVE_SSSE3
67static inline void
69 unsigned char* frozen_bit_mask,
70 const unsigned char* frozen_bits,
71 const unsigned char* info_bits,
72 unsigned int frame_size)
73{
74 if (frame_size < 1) {
75 return;
76 }
77
78 frame_size = next_lower_power_of_two(frame_size);
79 unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
80 volk_get_alignment());
81 adjust_frozen_mask(frozen_bit_mask, frame_size);
83 frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
84 volk_free(temp);
85}
86#endif /* LV_HAVE_SSSE3 */
87
88#ifdef LV_HAVE_AVX2
89static inline void
90volk_8u_x3_encodepolarpuppet_8u_u_avx2(unsigned char* frame,
91 unsigned char* frozen_bit_mask,
92 const unsigned char* frozen_bits,
93 const unsigned char* info_bits,
94 unsigned int frame_size)
95{
96 if (frame_size < 1) {
97 return;
98 }
99
100 frame_size = next_lower_power_of_two(frame_size);
101 unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
102 volk_get_alignment());
103 adjust_frozen_mask(frozen_bit_mask, frame_size);
104 volk_8u_x3_encodepolar_8u_x2_u_avx2(
105 frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
106 volk_free(temp);
107}
108#endif /* LV_HAVE_AVX2 */
109
110#endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_ */
111
112#ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
113#define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
114
115#ifdef LV_HAVE_SSSE3
116static inline void
118 unsigned char* frozen_bit_mask,
119 const unsigned char* frozen_bits,
120 const unsigned char* info_bits,
121 unsigned int frame_size)
122{
123 if (frame_size < 1) {
124 return;
125 }
126
127 frame_size = next_lower_power_of_two(frame_size);
128 unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
129 volk_get_alignment());
130 adjust_frozen_mask(frozen_bit_mask, frame_size);
132 frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
133 volk_free(temp);
134}
135#endif /* LV_HAVE_SSSE3 */
136
137#ifdef LV_HAVE_AVX2
138static inline void
139volk_8u_x3_encodepolarpuppet_8u_a_avx2(unsigned char* frame,
140 unsigned char* frozen_bit_mask,
141 const unsigned char* frozen_bits,
142 const unsigned char* info_bits,
143 unsigned int frame_size)
144{
145 if (frame_size < 1) {
146 return;
147 }
148
149 frame_size = next_lower_power_of_two(frame_size);
150 unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
151 volk_get_alignment());
152 adjust_frozen_mask(frozen_bit_mask, frame_size);
153 volk_8u_x3_encodepolar_8u_x2_a_avx2(
154 frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
155 volk_free(temp);
156}
157#endif /* LV_HAVE_AVX2 */
158
159
160#endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_ */