/work/libde265/libde265/fallback-motion.cc
Line | Count | Source |
1 | | /* |
2 | | * H.265 video codec. |
3 | | * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de> |
4 | | * |
5 | | * This file is part of libde265. |
6 | | * |
7 | | * libde265 is free software: you can redistribute it and/or modify |
8 | | * it under the terms of the GNU Lesser General Public License as |
9 | | * published by the Free Software Foundation, either version 3 of |
10 | | * the License, or (at your option) any later version. |
11 | | * |
12 | | * libde265 is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | * GNU Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public License |
18 | | * along with libde265. If not, see <http://www.gnu.org/licenses/>. |
19 | | */ |
20 | | |
21 | | #include "fallback-motion.h" |
22 | | #include "util.h" |
23 | | |
24 | | #if defined(_MSC_VER) || defined(__MINGW32__) |
25 | | # include <malloc.h> |
26 | | #elif defined(HAVE_ALLOCA_H) |
27 | | # include <alloca.h> |
28 | | #endif |
29 | | |
30 | | #include <assert.h> |
31 | | #include <algorithm> |
32 | | |
33 | | |
34 | | void put_unweighted_pred_8_fallback(uint8_t *dst, ptrdiff_t dststride, |
35 | | const int16_t *src, ptrdiff_t srcstride, |
36 | | int width, int height) |
37 | 0 | { |
38 | 0 | int offset8bit = 32; |
39 | 0 | int shift8bit = 6; |
40 | |
|
41 | 0 | assert((width&1)==0); |
42 | | |
43 | 0 | for (int y=0;y<height;y++) { |
44 | 0 | const int16_t* in = &src[y*srcstride]; |
45 | 0 | uint8_t* out = &dst[y*dststride]; |
46 | |
|
47 | 0 | for (int x=0;x<width;x+=2) { |
48 | 0 | out[0] = Clip1_8bit((in[0] + offset8bit)>>shift8bit); |
49 | 0 | out[1] = Clip1_8bit((in[1] + offset8bit)>>shift8bit); |
50 | 0 | out+=2; in+=2; |
51 | 0 | } |
52 | 0 | } |
53 | 0 | } |
54 | | |
55 | | |
56 | | void put_weighted_pred_8_fallback(uint8_t *dst, ptrdiff_t dststride, |
57 | | const int16_t *src, ptrdiff_t srcstride, |
58 | | int width, int height, |
59 | | int w,int o,int log2WD) |
60 | 528k | { |
61 | 528k | assert(log2WD>=1); // TODO |
62 | | |
63 | 528k | const int rnd = (1<<(log2WD-1)); |
64 | | |
65 | 3.22M | for (int y=0;y<height;y++) { |
66 | 2.69M | const int16_t* in = &src[y*srcstride]; |
67 | 2.69M | uint8_t* out = &dst[y*dststride]; |
68 | | |
69 | 20.1M | for (int x=0;x<width;x++) { |
70 | 17.4M | out[0] = Clip1_8bit(((in[0]*w + rnd)>>log2WD) + o); |
71 | 17.4M | out++; in++; |
72 | 17.4M | } |
73 | 2.69M | } |
74 | 528k | } |
75 | | |
76 | | void put_weighted_bipred_8_fallback(uint8_t *dst, ptrdiff_t dststride, |
77 | | const int16_t *src1, const int16_t *src2, ptrdiff_t srcstride, |
78 | | int width, int height, |
79 | | int w1,int o1, int w2,int o2, int log2WD) |
80 | 1.07M | { |
81 | 1.07M | assert(log2WD>=1); // TODO |
82 | | |
83 | 1.07M | const int rnd = static_cast<int>(static_cast<unsigned int>(o1+o2+1) << log2WD); |
84 | | |
85 | 8.66M | for (int y=0;y<height;y++) { |
86 | 7.59M | const int16_t* in1 = &src1[y*srcstride]; |
87 | 7.59M | const int16_t* in2 = &src2[y*srcstride]; |
88 | 7.59M | uint8_t* out = &dst[y*dststride]; |
89 | | |
90 | 87.7M | for (int x=0;x<width;x++) { |
91 | 80.1M | out[0] = Clip1_8bit((in1[0]*w1 + in2[0]*w2 + rnd)>>(log2WD+1)); |
92 | 80.1M | out++; in1++; in2++; |
93 | 80.1M | } |
94 | 7.59M | } |
95 | 1.07M | } |
96 | | |
97 | | |
98 | | void put_weighted_pred_avg_8_fallback(uint8_t *dst, ptrdiff_t dststride, |
99 | | const int16_t *src1, const int16_t *src2, |
100 | | ptrdiff_t srcstride, int width, |
101 | | int height) |
102 | 0 | { |
103 | 0 | int offset8bit = 64; |
104 | 0 | int shift8bit = 7; |
105 | |
|
106 | 0 | assert((width&1)==0); |
107 | | |
108 | | // I had a special case for 8-pixel parallel, unrolled code, |
109 | | // but I did not see any speedup. |
110 | | |
111 | | #if 0 |
112 | | for (int y=0;y<height;y++) { |
113 | | int16_t* in1 = &src1[y*srcstride]; |
114 | | int16_t* in2 = &src2[y*srcstride]; |
115 | | uint8_t* out = &dst[y*dststride]; |
116 | | |
117 | | for (int x=0;x<width;x++) { |
118 | | out[0] = Clip1_8bit((in1[0] + in2[0] + offset8bit)>>shift8bit); |
119 | | out++; in1++; in2++; |
120 | | } |
121 | | } |
122 | | #endif |
123 | | |
124 | | #if 0 |
125 | | if ((width&7)==0) { |
126 | | for (int y=0;y<height;y++) { |
127 | | int16_t* in1 = &src1[y*srcstride]; |
128 | | int16_t* in2 = &src2[y*srcstride]; |
129 | | uint8_t* out = &dst[y*dststride]; |
130 | | |
131 | | for (int x=0;x<width;x+=8) { |
132 | | out[0] = Clip1_8bit((in1[0] + in2[0] + offset8bit)>>shift8bit); |
133 | | out[1] = Clip1_8bit((in1[1] + in2[1] + offset8bit)>>shift8bit); |
134 | | out[2] = Clip1_8bit((in1[2] + in2[2] + offset8bit)>>shift8bit); |
135 | | out[3] = Clip1_8bit((in1[3] + in2[3] + offset8bit)>>shift8bit); |
136 | | out[4] = Clip1_8bit((in1[4] + in2[4] + offset8bit)>>shift8bit); |
137 | | out[5] = Clip1_8bit((in1[5] + in2[5] + offset8bit)>>shift8bit); |
138 | | out[6] = Clip1_8bit((in1[6] + in2[6] + offset8bit)>>shift8bit); |
139 | | out[7] = Clip1_8bit((in1[7] + in2[7] + offset8bit)>>shift8bit); |
140 | | out+=8; in1+=8; in2+=8; |
141 | | } |
142 | | } |
143 | | } |
144 | | else |
145 | | #endif |
146 | 0 | { |
147 | 0 | for (int y=0;y<height;y++) { |
148 | 0 | const int16_t* in1 = &src1[y*srcstride]; |
149 | 0 | const int16_t* in2 = &src2[y*srcstride]; |
150 | 0 | uint8_t* out = &dst[y*dststride]; |
151 | |
|
152 | 0 | for (int x=0;x<width;x+=2) { |
153 | 0 | out[0] = Clip1_8bit((in1[0] + in2[0] + offset8bit)>>shift8bit); |
154 | 0 | out[1] = Clip1_8bit((in1[1] + in2[1] + offset8bit)>>shift8bit); |
155 | 0 | out+=2; in1+=2; in2+=2; |
156 | 0 | } |
157 | 0 | } |
158 | 0 | } |
159 | 0 | } |
160 | | |
161 | | |
162 | | |
163 | | |
164 | | |
165 | | // The 16-bit pixel kernels are templates on the type of the intermediate |
166 | | // prediction samples (predSamplesLX in the spec): int16_t for BitDepth <= 12, |
167 | | // int32_t above (see acceleration.h). |
168 | | |
169 | | template <class inter_t> |
170 | | void put_unweighted_pred_16_fallback(uint16_t *dst, ptrdiff_t dststride, |
171 | | const inter_t *src, ptrdiff_t srcstride, |
172 | | int width, int height, int bit_depth) |
173 | 4.16M | { |
174 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(2, 14 - BitDepth). |
175 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; |
176 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. |
177 | 4.16M | int shift1 = std::max(2, 14-bit_depth); |
178 | 4.16M | int offset1 = 1<<(shift1-1); |
179 | | |
180 | 4.16M | assert((width&1)==0); |
181 | | |
182 | 39.2M | for (int y=0;y<height;y++) { |
183 | 35.1M | const inter_t* in = &src[y*srcstride]; |
184 | 35.1M | uint16_t* out = &dst[y*dststride]; |
185 | | |
186 | 184M | for (int x=0;x<width;x+=2) { |
187 | 149M | out[0] = Clip_BitDepth((in[0] + offset1)>>shift1, bit_depth); |
188 | 149M | out[1] = Clip_BitDepth((in[1] + offset1)>>shift1, bit_depth); |
189 | 149M | out+=2; in+=2; |
190 | 149M | } |
191 | 35.1M | } |
192 | 4.16M | } void put_unweighted_pred_16_fallback<short>(unsigned short*, long, short const*, long, int, int, int) Line | Count | Source | 173 | 2.93M | { | 174 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(2, 14 - BitDepth). | 175 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 176 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 177 | 2.93M | int shift1 = std::max(2, 14-bit_depth); | 178 | 2.93M | int offset1 = 1<<(shift1-1); | 179 | | | 180 | 2.93M | assert((width&1)==0); | 181 | | | 182 | 27.0M | for (int y=0;y<height;y++) { | 183 | 24.1M | const inter_t* in = &src[y*srcstride]; | 184 | 24.1M | uint16_t* out = &dst[y*dststride]; | 185 | | | 186 | 124M | for (int x=0;x<width;x+=2) { | 187 | 100M | out[0] = Clip_BitDepth((in[0] + offset1)>>shift1, bit_depth); | 188 | 100M | out[1] = Clip_BitDepth((in[1] + offset1)>>shift1, bit_depth); | 189 | 100M | out+=2; in+=2; | 190 | 100M | } | 191 | 24.1M | } | 192 | 2.93M | } |
void put_unweighted_pred_16_fallback<int>(unsigned short*, long, int const*, long, int, int, int) Line | Count | Source | 173 | 1.22M | { | 174 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(2, 14 - BitDepth). | 175 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 176 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 177 | 1.22M | int shift1 = std::max(2, 14-bit_depth); | 178 | 1.22M | int offset1 = 1<<(shift1-1); | 179 | | | 180 | 1.22M | assert((width&1)==0); | 181 | | | 182 | 12.2M | for (int y=0;y<height;y++) { | 183 | 11.0M | const inter_t* in = &src[y*srcstride]; | 184 | 11.0M | uint16_t* out = &dst[y*dststride]; | 185 | | | 186 | 60.3M | for (int x=0;x<width;x+=2) { | 187 | 49.3M | out[0] = Clip_BitDepth((in[0] + offset1)>>shift1, bit_depth); | 188 | 49.3M | out[1] = Clip_BitDepth((in[1] + offset1)>>shift1, bit_depth); | 189 | 49.3M | out+=2; in+=2; | 190 | 49.3M | } | 191 | 11.0M | } | 192 | 1.22M | } |
|
193 | | |
194 | | template void put_unweighted_pred_16_fallback<int16_t>(uint16_t*, ptrdiff_t, const int16_t*, ptrdiff_t, int, int, int); |
195 | | template void put_unweighted_pred_16_fallback<int32_t>(uint16_t*, ptrdiff_t, const int32_t*, ptrdiff_t, int, int, int); |
196 | | |
197 | | #include <stdlib.h> |
198 | | |
199 | | template <class inter_t> |
200 | | void put_weighted_pred_16_fallback(uint16_t *dst, ptrdiff_t dststride, |
201 | | const inter_t *src, ptrdiff_t srcstride, |
202 | | int width, int height, |
203 | | int w,int o,int log2WD, int bit_depth) |
204 | 625k | { |
205 | 625k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 |
206 | | |
207 | 625k | const int rnd = (1<<(log2WD-1)); |
208 | | |
209 | 4.73M | for (int y=0;y<height;y++) { |
210 | 4.11M | const inter_t* in = &src[y*srcstride]; |
211 | 4.11M | uint16_t* out = &dst[y*dststride]; |
212 | | |
213 | 31.4M | for (int x=0;x<width;x++) { |
214 | 27.3M | out[0] = Clip_BitDepth(((in[0]*w + rnd)>>log2WD) + o, bit_depth); |
215 | 27.3M | out++; in++; |
216 | 27.3M | } |
217 | 4.11M | } |
218 | 625k | } void put_weighted_pred_16_fallback<short>(unsigned short*, long, short const*, long, int, int, int, int, int, int) Line | Count | Source | 204 | 435k | { | 205 | 435k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 | 206 | | | 207 | 435k | const int rnd = (1<<(log2WD-1)); | 208 | | | 209 | 2.99M | for (int y=0;y<height;y++) { | 210 | 2.56M | const inter_t* in = &src[y*srcstride]; | 211 | 2.56M | uint16_t* out = &dst[y*dststride]; | 212 | | | 213 | 18.1M | for (int x=0;x<width;x++) { | 214 | 15.6M | out[0] = Clip_BitDepth(((in[0]*w + rnd)>>log2WD) + o, bit_depth); | 215 | 15.6M | out++; in++; | 216 | 15.6M | } | 217 | 2.56M | } | 218 | 435k | } |
void put_weighted_pred_16_fallback<int>(unsigned short*, long, int const*, long, int, int, int, int, int, int) Line | Count | Source | 204 | 190k | { | 205 | 190k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 | 206 | | | 207 | 190k | const int rnd = (1<<(log2WD-1)); | 208 | | | 209 | 1.74M | for (int y=0;y<height;y++) { | 210 | 1.55M | const inter_t* in = &src[y*srcstride]; | 211 | 1.55M | uint16_t* out = &dst[y*dststride]; | 212 | | | 213 | 13.2M | for (int x=0;x<width;x++) { | 214 | 11.7M | out[0] = Clip_BitDepth(((in[0]*w + rnd)>>log2WD) + o, bit_depth); | 215 | 11.7M | out++; in++; | 216 | 11.7M | } | 217 | 1.55M | } | 218 | 190k | } |
|
219 | | |
220 | | template void put_weighted_pred_16_fallback<int16_t>(uint16_t*, ptrdiff_t, const int16_t*, ptrdiff_t, int, int, int, int, int, int); |
221 | | template void put_weighted_pred_16_fallback<int32_t>(uint16_t*, ptrdiff_t, const int32_t*, ptrdiff_t, int, int, int, int, int, int); |
222 | | |
223 | | template <class inter_t> |
224 | | void put_weighted_bipred_16_fallback(uint16_t *dst, ptrdiff_t dststride, |
225 | | const inter_t *src1, const inter_t *src2, ptrdiff_t srcstride, |
226 | | int width, int height, |
227 | | int w1,int o1, int w2,int o2, int log2WD, int bit_depth) |
228 | 423k | { |
229 | 423k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 |
230 | | |
231 | | // Worst case at BitDepth 16 (int32_t intermediates): |predSample| < 2^20, |w| <= 255, |
232 | | // |o1+o2+1| <= 2^16, log2WD <= 9 -> the sum stays below 2^29 and fits into int. |
233 | 423k | const int rnd = static_cast<int>(static_cast<unsigned int>(o1+o2+1) << log2WD); |
234 | | |
235 | 4.67M | for (int y=0;y<height;y++) { |
236 | 4.25M | const inter_t* in1 = &src1[y*srcstride]; |
237 | 4.25M | const inter_t* in2 = &src2[y*srcstride]; |
238 | 4.25M | uint16_t* out = &dst[y*dststride]; |
239 | | |
240 | 61.9M | for (int x=0;x<width;x++) { |
241 | 57.7M | out[0] = Clip_BitDepth((in1[0]*w1 + in2[0]*w2 + rnd)>>(log2WD+1), bit_depth); |
242 | 57.7M | out++; in1++; in2++; |
243 | 57.7M | } |
244 | 4.25M | } |
245 | 423k | } void put_weighted_bipred_16_fallback<short>(unsigned short*, long, short const*, short const*, long, int, int, int, int, int, int, int, int) Line | Count | Source | 228 | 256k | { | 229 | 256k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 | 230 | | | 231 | | // Worst case at BitDepth 16 (int32_t intermediates): |predSample| < 2^20, |w| <= 255, | 232 | | // |o1+o2+1| <= 2^16, log2WD <= 9 -> the sum stays below 2^29 and fits into int. | 233 | 256k | const int rnd = static_cast<int>(static_cast<unsigned int>(o1+o2+1) << log2WD); | 234 | | | 235 | 2.42M | for (int y=0;y<height;y++) { | 236 | 2.17M | const inter_t* in1 = &src1[y*srcstride]; | 237 | 2.17M | const inter_t* in2 = &src2[y*srcstride]; | 238 | 2.17M | uint16_t* out = &dst[y*dststride]; | 239 | | | 240 | 29.9M | for (int x=0;x<width;x++) { | 241 | 27.7M | out[0] = Clip_BitDepth((in1[0]*w1 + in2[0]*w2 + rnd)>>(log2WD+1), bit_depth); | 242 | 27.7M | out++; in1++; in2++; | 243 | 27.7M | } | 244 | 2.17M | } | 245 | 256k | } |
void put_weighted_bipred_16_fallback<int>(unsigned short*, long, int const*, int const*, long, int, int, int, int, int, int, int, int) Line | Count | Source | 228 | 166k | { | 229 | 166k | assert(log2WD>=1); // log2WD = log2_weight_denom + Max(2, 14-BitDepth) >= 2 | 230 | | | 231 | | // Worst case at BitDepth 16 (int32_t intermediates): |predSample| < 2^20, |w| <= 255, | 232 | | // |o1+o2+1| <= 2^16, log2WD <= 9 -> the sum stays below 2^29 and fits into int. | 233 | 166k | const int rnd = static_cast<int>(static_cast<unsigned int>(o1+o2+1) << log2WD); | 234 | | | 235 | 2.24M | for (int y=0;y<height;y++) { | 236 | 2.08M | const inter_t* in1 = &src1[y*srcstride]; | 237 | 2.08M | const inter_t* in2 = &src2[y*srcstride]; | 238 | 2.08M | uint16_t* out = &dst[y*dststride]; | 239 | | | 240 | 32.0M | for (int x=0;x<width;x++) { | 241 | 29.9M | out[0] = Clip_BitDepth((in1[0]*w1 + in2[0]*w2 + rnd)>>(log2WD+1), bit_depth); | 242 | 29.9M | out++; in1++; in2++; | 243 | 29.9M | } | 244 | 2.08M | } | 245 | 166k | } |
|
246 | | |
247 | | template void put_weighted_bipred_16_fallback<int16_t>(uint16_t*, ptrdiff_t, const int16_t*, const int16_t*, ptrdiff_t, int, int, int, int, int, int, int, int); |
248 | | template void put_weighted_bipred_16_fallback<int32_t>(uint16_t*, ptrdiff_t, const int32_t*, const int32_t*, ptrdiff_t, int, int, int, int, int, int, int, int); |
249 | | |
250 | | |
251 | | template <class inter_t> |
252 | | void put_weighted_pred_avg_16_fallback(uint16_t *dst, ptrdiff_t dststride, |
253 | | const inter_t *src1, const inter_t *src2, |
254 | | ptrdiff_t srcstride, int width, |
255 | | int height, int bit_depth) |
256 | 1.69M | { |
257 | | // shift2 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(3, 15 - BitDepth). |
258 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; |
259 | | // the v1 (04/2013) formula was just (15 - BitDepth), valid only for BitDepth <= 14. |
260 | 1.69M | int shift2 = std::max(3, 15-bit_depth); |
261 | 1.69M | int offset2 = 1<<(shift2-1); |
262 | | |
263 | 1.69M | assert((width&1)==0); |
264 | | |
265 | 20.2M | for (int y=0;y<height;y++) { |
266 | 18.5M | const inter_t* in1 = &src1[y*srcstride]; |
267 | 18.5M | const inter_t* in2 = &src2[y*srcstride]; |
268 | 18.5M | uint16_t* out = &dst[y*dststride]; |
269 | | |
270 | 102M | for (int x=0;x<width;x+=2) { |
271 | 84.3M | out[0] = Clip_BitDepth((in1[0] + in2[0] + offset2)>>shift2, bit_depth); |
272 | 84.3M | out[1] = Clip_BitDepth((in1[1] + in2[1] + offset2)>>shift2, bit_depth); |
273 | 84.3M | out+=2; in1+=2; in2+=2; |
274 | 84.3M | } |
275 | 18.5M | } |
276 | 1.69M | } void put_weighted_pred_avg_16_fallback<short>(unsigned short*, long, short const*, short const*, long, int, int, int) Line | Count | Source | 256 | 1.44M | { | 257 | | // shift2 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(3, 15 - BitDepth). | 258 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 259 | | // the v1 (04/2013) formula was just (15 - BitDepth), valid only for BitDepth <= 14. | 260 | 1.44M | int shift2 = std::max(3, 15-bit_depth); | 261 | 1.44M | int offset2 = 1<<(shift2-1); | 262 | | | 263 | 1.44M | assert((width&1)==0); | 264 | | | 265 | 17.0M | for (int y=0;y<height;y++) { | 266 | 15.6M | const inter_t* in1 = &src1[y*srcstride]; | 267 | 15.6M | const inter_t* in2 = &src2[y*srcstride]; | 268 | 15.6M | uint16_t* out = &dst[y*dststride]; | 269 | | | 270 | 85.2M | for (int x=0;x<width;x+=2) { | 271 | 69.5M | out[0] = Clip_BitDepth((in1[0] + in2[0] + offset2)>>shift2, bit_depth); | 272 | 69.5M | out[1] = Clip_BitDepth((in1[1] + in2[1] + offset2)>>shift2, bit_depth); | 273 | 69.5M | out+=2; in1+=2; in2+=2; | 274 | 69.5M | } | 275 | 15.6M | } | 276 | 1.44M | } |
void put_weighted_pred_avg_16_fallback<int>(unsigned short*, long, int const*, int const*, long, int, int, int) Line | Count | Source | 256 | 248k | { | 257 | | // shift2 per HEVC v2 (10/2014) spec 8.5.3.3.4.2: Max(3, 15 - BitDepth). | 258 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 259 | | // the v1 (04/2013) formula was just (15 - BitDepth), valid only for BitDepth <= 14. | 260 | 248k | int shift2 = std::max(3, 15-bit_depth); | 261 | 248k | int offset2 = 1<<(shift2-1); | 262 | | | 263 | 248k | assert((width&1)==0); | 264 | | | 265 | 3.17M | for (int y=0;y<height;y++) { | 266 | 2.93M | const inter_t* in1 = &src1[y*srcstride]; | 267 | 2.93M | const inter_t* in2 = &src2[y*srcstride]; | 268 | 2.93M | uint16_t* out = &dst[y*dststride]; | 269 | | | 270 | 17.6M | for (int x=0;x<width;x+=2) { | 271 | 14.7M | out[0] = Clip_BitDepth((in1[0] + in2[0] + offset2)>>shift2, bit_depth); | 272 | 14.7M | out[1] = Clip_BitDepth((in1[1] + in2[1] + offset2)>>shift2, bit_depth); | 273 | 14.7M | out+=2; in1+=2; in2+=2; | 274 | 14.7M | } | 275 | 2.93M | } | 276 | 248k | } |
|
277 | | |
278 | | template void put_weighted_pred_avg_16_fallback<int16_t>(uint16_t*, ptrdiff_t, const int16_t*, const int16_t*, ptrdiff_t, int, int, int); |
279 | | template void put_weighted_pred_avg_16_fallback<int32_t>(uint16_t*, ptrdiff_t, const int32_t*, const int32_t*, ptrdiff_t, int, int, int); |
280 | | |
281 | | |
282 | | |
283 | | |
284 | | |
285 | | void put_epel_8_fallback(int16_t *out, ptrdiff_t out_stride, |
286 | | const uint8_t *src, ptrdiff_t src_stride, |
287 | | int width, int height, |
288 | | int mx, int my, int16_t* mcbuffer) |
289 | 0 | { |
290 | 0 | int shift3 = 6; |
291 | |
|
292 | 0 | for (int y=0;y<height;y++) { |
293 | 0 | int16_t* o = &out[y*out_stride]; |
294 | 0 | const uint8_t* i = &src[y*src_stride]; |
295 | |
|
296 | 0 | for (int x=0;x<width;x++) { |
297 | 0 | *o = *i << shift3; |
298 | 0 | o++; |
299 | 0 | i++; |
300 | 0 | } |
301 | 0 | } |
302 | 0 | } |
303 | | |
304 | | |
305 | | template <class inter_t> |
306 | | void put_epel_16_fallback(inter_t *out, ptrdiff_t out_stride, |
307 | | const uint16_t *src, ptrdiff_t src_stride, |
308 | | int width, int height, |
309 | | int mx, int my, inter_t* mcbuffer, int bit_depth) |
310 | 3.15M | { |
311 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Max(2, 14 - BitDepth). |
312 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; |
313 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. |
314 | 3.15M | int shift3 = std::max(2, 14 - bit_depth); |
315 | | |
316 | 32.2M | for (int y=0;y<height;y++) { |
317 | 29.1M | inter_t* o = &out[y*out_stride]; |
318 | 29.1M | const uint16_t* i = &src[y*src_stride]; |
319 | | |
320 | 223M | for (int x=0;x<width;x++) { |
321 | 194M | *o = *i << shift3; |
322 | 194M | o++; |
323 | 194M | i++; |
324 | 194M | } |
325 | 29.1M | } |
326 | 3.15M | } void put_epel_16_fallback<short>(short*, long, unsigned short const*, long, int, int, int, int, short*, int) Line | Count | Source | 310 | 2.76M | { | 311 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Max(2, 14 - BitDepth). | 312 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 313 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 314 | 2.76M | int shift3 = std::max(2, 14 - bit_depth); | 315 | | | 316 | 27.9M | for (int y=0;y<height;y++) { | 317 | 25.1M | inter_t* o = &out[y*out_stride]; | 318 | 25.1M | const uint16_t* i = &src[y*src_stride]; | 319 | | | 320 | 194M | for (int x=0;x<width;x++) { | 321 | 168M | *o = *i << shift3; | 322 | 168M | o++; | 323 | 168M | i++; | 324 | 168M | } | 325 | 25.1M | } | 326 | 2.76M | } |
void put_epel_16_fallback<int>(int*, long, unsigned short const*, long, int, int, int, int, int*, int) Line | Count | Source | 310 | 392k | { | 311 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Max(2, 14 - BitDepth). | 312 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 313 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 314 | 392k | int shift3 = std::max(2, 14 - bit_depth); | 315 | | | 316 | 4.36M | for (int y=0;y<height;y++) { | 317 | 3.97M | inter_t* o = &out[y*out_stride]; | 318 | 3.97M | const uint16_t* i = &src[y*src_stride]; | 319 | | | 320 | 29.5M | for (int x=0;x<width;x++) { | 321 | 25.5M | *o = *i << shift3; | 322 | 25.5M | o++; | 323 | 25.5M | i++; | 324 | 25.5M | } | 325 | 3.97M | } | 326 | 392k | } |
|
327 | | |
328 | | template void put_epel_16_fallback<int16_t>(int16_t*, ptrdiff_t, const uint16_t*, ptrdiff_t, int, int, int, int, int16_t*, int); |
329 | | template void put_epel_16_fallback<int32_t>(int32_t*, ptrdiff_t, const uint16_t*, ptrdiff_t, int, int, int, int, int32_t*, int); |
330 | | |
331 | | |
332 | | template <class pixel_t, class inter_t> |
333 | | void put_epel_hv_fallback(inter_t *dst, ptrdiff_t dst_stride, |
334 | | const pixel_t *src, ptrdiff_t src_stride, |
335 | | int nPbWC, int nPbHC, |
336 | | int xFracC, int yFracC, inter_t* mcbuffer, int bit_depth) |
337 | 2.68M | { |
338 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Min(4, BitDepth - 8). |
339 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the |
340 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). |
341 | 2.68M | const int shift1 = std::min(4, bit_depth-8); |
342 | 2.68M | const int shift2 = 6; |
343 | | //const int shift3 = 6; |
344 | | |
345 | 2.68M | int extra_left = 1; |
346 | 2.68M | int extra_top = 1; |
347 | | // int extra_right = 2; |
348 | 2.68M | int extra_bottom= 2; |
349 | | |
350 | | |
351 | 2.68M | int nPbH_extra = extra_top + nPbHC + extra_bottom; |
352 | | |
353 | 2.68M | inter_t* tmp2buf = (inter_t*)alloca( nPbWC * nPbH_extra * sizeof(inter_t) ); |
354 | | |
355 | | /* |
356 | | int nPbW_extra = extra_left + nPbWC + extra_right; |
357 | | |
358 | | |
359 | | printf("x,y FracC: %d/%d\n",xFracC,yFracC); |
360 | | |
361 | | printf("---IN---\n"); |
362 | | |
363 | | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { |
364 | | uint8_t* p = &src[y*src_stride -extra_left]; |
365 | | |
366 | | for (int x=-extra_left;x<nPbWC+extra_right;x++) { |
367 | | printf("%05d ",*p << 6); |
368 | | p++; |
369 | | } |
370 | | printf("\n"); |
371 | | } |
372 | | */ |
373 | | |
374 | | |
375 | | // H-filters |
376 | | |
377 | 2.68M | logtrace(LogMotion,"---H---\n"); |
378 | | //printf("---H---(%d)\n",xFracC); |
379 | | |
380 | 34.9M | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { |
381 | 32.2M | const pixel_t* p = &src[y*src_stride - extra_left]; |
382 | | |
383 | 229M | for (int x=0;x<nPbWC;x++) { |
384 | 197M | int v; |
385 | 197M | switch (xFracC) { |
386 | 29.0M | case 0: v = p[1]; break; |
387 | 35.2M | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>shift1; break; |
388 | 22.9M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>shift1; break; |
389 | 16.5M | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>shift1; break; |
390 | 24.5M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>shift1; break; |
391 | 22.2M | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>shift1; break; |
392 | 20.9M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>shift1; break; |
393 | 0 | default: |
394 | 25.9M | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>shift1; break; |
395 | 197M | } |
396 | | |
397 | | //printf("%d %d %d %d -> %d\n",p[0],p[1],p[2],p[3],v); |
398 | | |
399 | 197M | tmp2buf[y+extra_top + x*nPbH_extra] = v; |
400 | 197M | p++; |
401 | | |
402 | | //printf("%05d ",tmp2buf[y+extra_top + x*nPbH_extra]); |
403 | 197M | } |
404 | | //printf("\n"); |
405 | 32.2M | } |
406 | | |
407 | | // V-filters |
408 | | |
409 | 2.68M | int vshift = (xFracC==0 ? shift1 : shift2); |
410 | | |
411 | 15.9M | for (int x=0;x<nPbWC;x++) { |
412 | 13.2M | inter_t* p = &tmp2buf[x*nPbH_extra]; |
413 | | |
414 | 170M | for (int y=0;y<nPbHC;y++) { |
415 | 157M | int v; |
416 | | //logtrace(LogMotion,"%x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6]); |
417 | | |
418 | 157M | switch (yFracC) { |
419 | 41.7M | case 0: v = p[1]; break; |
420 | 2.47M | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>vshift; break; |
421 | 42.2M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>vshift; break; |
422 | 1.36M | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>vshift; break; |
423 | 31.4M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>vshift; break; |
424 | 889k | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>vshift; break; |
425 | 36.3M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>vshift; break; |
426 | 0 | default: |
427 | 1.26M | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>vshift; break; |
428 | 157M | } |
429 | | |
430 | 157M | dst[x + y*dst_stride] = v; |
431 | 157M | p++; |
432 | 157M | } |
433 | | |
434 | 13.2M | } |
435 | | |
436 | | /* |
437 | | printf("---V---\n"); |
438 | | for (int y=0;y<nPbHC;y++) { |
439 | | for (int x=0;x<nPbWC;x++) { |
440 | | printf("%05d ",dst[x+y*dst_stride]); |
441 | | } |
442 | | printf("\n"); |
443 | | } |
444 | | */ |
445 | 2.68M | } Unexecuted instantiation: void put_epel_hv_fallback<unsigned char, short>(short*, long, unsigned char const*, long, int, int, int, int, short*, int) void put_epel_hv_fallback<unsigned short, short>(short*, long, unsigned short const*, long, int, int, int, int, short*, int) Line | Count | Source | 337 | 1.79M | { | 338 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Min(4, BitDepth - 8). | 339 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the | 340 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). | 341 | 1.79M | const int shift1 = std::min(4, bit_depth-8); | 342 | 1.79M | const int shift2 = 6; | 343 | | //const int shift3 = 6; | 344 | | | 345 | 1.79M | int extra_left = 1; | 346 | 1.79M | int extra_top = 1; | 347 | | // int extra_right = 2; | 348 | 1.79M | int extra_bottom= 2; | 349 | | | 350 | | | 351 | 1.79M | int nPbH_extra = extra_top + nPbHC + extra_bottom; | 352 | | | 353 | 1.79M | inter_t* tmp2buf = (inter_t*)alloca( nPbWC * nPbH_extra * sizeof(inter_t) ); | 354 | | | 355 | | /* | 356 | | int nPbW_extra = extra_left + nPbWC + extra_right; | 357 | | | 358 | | | 359 | | printf("x,y FracC: %d/%d\n",xFracC,yFracC); | 360 | | | 361 | | printf("---IN---\n"); | 362 | | | 363 | | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { | 364 | | uint8_t* p = &src[y*src_stride -extra_left]; | 365 | | | 366 | | for (int x=-extra_left;x<nPbWC+extra_right;x++) { | 367 | | printf("%05d ",*p << 6); | 368 | | p++; | 369 | | } | 370 | | printf("\n"); | 371 | | } | 372 | | */ | 373 | | | 374 | | | 375 | | // H-filters | 376 | | | 377 | 1.79M | logtrace(LogMotion,"---H---\n"); | 378 | | //printf("---H---(%d)\n",xFracC); | 379 | | | 380 | 23.3M | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { | 381 | 21.5M | const pixel_t* p = &src[y*src_stride - extra_left]; | 382 | | | 383 | 157M | for (int x=0;x<nPbWC;x++) { | 384 | 136M | int v; | 385 | 136M | switch (xFracC) { | 386 | 23.6M | case 0: v = p[1]; break; | 387 | 26.1M | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>shift1; break; | 388 | 17.4M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>shift1; break; | 389 | 12.0M | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>shift1; break; | 390 | 14.3M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>shift1; break; | 391 | 9.73M | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>shift1; break; | 392 | 14.9M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>shift1; break; | 393 | 0 | default: | 394 | 17.8M | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>shift1; break; | 395 | 136M | } | 396 | | | 397 | | //printf("%d %d %d %d -> %d\n",p[0],p[1],p[2],p[3],v); | 398 | | | 399 | 136M | tmp2buf[y+extra_top + x*nPbH_extra] = v; | 400 | 136M | p++; | 401 | | | 402 | | //printf("%05d ",tmp2buf[y+extra_top + x*nPbH_extra]); | 403 | 136M | } | 404 | | //printf("\n"); | 405 | 21.5M | } | 406 | | | 407 | | // V-filters | 408 | | | 409 | 1.79M | int vshift = (xFracC==0 ? shift1 : shift2); | 410 | | | 411 | 10.9M | for (int x=0;x<nPbWC;x++) { | 412 | 9.12M | inter_t* p = &tmp2buf[x*nPbH_extra]; | 413 | | | 414 | 117M | for (int y=0;y<nPbHC;y++) { | 415 | 108M | int v; | 416 | | //logtrace(LogMotion,"%x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6]); | 417 | | | 418 | 108M | switch (yFracC) { | 419 | 26.1M | case 0: v = p[1]; break; | 420 | 2.08M | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>vshift; break; | 421 | 31.4M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>vshift; break; | 422 | 1.22M | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>vshift; break; | 423 | 23.6M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>vshift; break; | 424 | 783k | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>vshift; break; | 425 | 22.4M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>vshift; break; | 426 | 0 | default: | 427 | 964k | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>vshift; break; | 428 | 108M | } | 429 | | | 430 | 108M | dst[x + y*dst_stride] = v; | 431 | 108M | p++; | 432 | 108M | } | 433 | | | 434 | 9.12M | } | 435 | | | 436 | | /* | 437 | | printf("---V---\n"); | 438 | | for (int y=0;y<nPbHC;y++) { | 439 | | for (int x=0;x<nPbWC;x++) { | 440 | | printf("%05d ",dst[x+y*dst_stride]); | 441 | | } | 442 | | printf("\n"); | 443 | | } | 444 | | */ | 445 | 1.79M | } |
void put_epel_hv_fallback<unsigned short, int>(int*, long, unsigned short const*, long, int, int, int, int, int*, int) Line | Count | Source | 337 | 891k | { | 338 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.3 (chroma): Min(4, BitDepth - 8). | 339 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the | 340 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). | 341 | 891k | const int shift1 = std::min(4, bit_depth-8); | 342 | 891k | const int shift2 = 6; | 343 | | //const int shift3 = 6; | 344 | | | 345 | 891k | int extra_left = 1; | 346 | 891k | int extra_top = 1; | 347 | | // int extra_right = 2; | 348 | 891k | int extra_bottom= 2; | 349 | | | 350 | | | 351 | 891k | int nPbH_extra = extra_top + nPbHC + extra_bottom; | 352 | | | 353 | 891k | inter_t* tmp2buf = (inter_t*)alloca( nPbWC * nPbH_extra * sizeof(inter_t) ); | 354 | | | 355 | | /* | 356 | | int nPbW_extra = extra_left + nPbWC + extra_right; | 357 | | | 358 | | | 359 | | printf("x,y FracC: %d/%d\n",xFracC,yFracC); | 360 | | | 361 | | printf("---IN---\n"); | 362 | | | 363 | | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { | 364 | | uint8_t* p = &src[y*src_stride -extra_left]; | 365 | | | 366 | | for (int x=-extra_left;x<nPbWC+extra_right;x++) { | 367 | | printf("%05d ",*p << 6); | 368 | | p++; | 369 | | } | 370 | | printf("\n"); | 371 | | } | 372 | | */ | 373 | | | 374 | | | 375 | | // H-filters | 376 | | | 377 | 891k | logtrace(LogMotion,"---H---\n"); | 378 | | //printf("---H---(%d)\n",xFracC); | 379 | | | 380 | 11.5M | for (int y=-extra_top;y<nPbHC+extra_bottom;y++) { | 381 | 10.6M | const pixel_t* p = &src[y*src_stride - extra_left]; | 382 | | | 383 | 72.0M | for (int x=0;x<nPbWC;x++) { | 384 | 61.3M | int v; | 385 | 61.3M | switch (xFracC) { | 386 | 5.42M | case 0: v = p[1]; break; | 387 | 9.14M | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>shift1; break; | 388 | 5.50M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>shift1; break; | 389 | 4.52M | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>shift1; break; | 390 | 10.2M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>shift1; break; | 391 | 12.5M | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>shift1; break; | 392 | 5.94M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>shift1; break; | 393 | 0 | default: | 394 | 8.11M | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>shift1; break; | 395 | 61.3M | } | 396 | | | 397 | | //printf("%d %d %d %d -> %d\n",p[0],p[1],p[2],p[3],v); | 398 | | | 399 | 61.3M | tmp2buf[y+extra_top + x*nPbH_extra] = v; | 400 | 61.3M | p++; | 401 | | | 402 | | //printf("%05d ",tmp2buf[y+extra_top + x*nPbH_extra]); | 403 | 61.3M | } | 404 | | //printf("\n"); | 405 | 10.6M | } | 406 | | | 407 | | // V-filters | 408 | | | 409 | 891k | int vshift = (xFracC==0 ? shift1 : shift2); | 410 | | | 411 | 5.02M | for (int x=0;x<nPbWC;x++) { | 412 | 4.13M | inter_t* p = &tmp2buf[x*nPbH_extra]; | 413 | | | 414 | 53.1M | for (int y=0;y<nPbHC;y++) { | 415 | 48.9M | int v; | 416 | | //logtrace(LogMotion,"%x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6]); | 417 | | | 418 | 48.9M | switch (yFracC) { | 419 | 15.5M | case 0: v = p[1]; break; | 420 | 392k | case 1: v = (-2*p[0]+58*p[1]+10*p[2]-2*p[3])>>vshift; break; | 421 | 10.7M | case 2: v = (-4*p[0]+54*p[1]+16*p[2]-2*p[3])>>vshift; break; | 422 | 133k | case 3: v = (-6*p[0]+46*p[1]+28*p[2]-4*p[3])>>vshift; break; | 423 | 7.82M | case 4: v = (-4*p[0]+36*p[1]+36*p[2]-4*p[3])>>vshift; break; | 424 | 105k | case 5: v = (-4*p[0]+28*p[1]+46*p[2]-6*p[3])>>vshift; break; | 425 | 13.8M | case 6: v = (-2*p[0]+16*p[1]+54*p[2]-4*p[3])>>vshift; break; | 426 | 0 | default: | 427 | 304k | case 7: v = (-2*p[0]+10*p[1]+58*p[2]-2*p[3])>>vshift; break; | 428 | 48.9M | } | 429 | | | 430 | 48.9M | dst[x + y*dst_stride] = v; | 431 | 48.9M | p++; | 432 | 48.9M | } | 433 | | | 434 | 4.13M | } | 435 | | | 436 | | /* | 437 | | printf("---V---\n"); | 438 | | for (int y=0;y<nPbHC;y++) { | 439 | | for (int x=0;x<nPbWC;x++) { | 440 | | printf("%05d ",dst[x+y*dst_stride]); | 441 | | } | 442 | | printf("\n"); | 443 | | } | 444 | | */ | 445 | 891k | } |
|
446 | | |
447 | | |
448 | | template |
449 | | void put_epel_hv_fallback<uint8_t,int16_t>(int16_t *dst, ptrdiff_t dst_stride, |
450 | | const uint8_t *src, ptrdiff_t src_stride, |
451 | | int nPbWC, int nPbHC, |
452 | | int xFracC, int yFracC, int16_t* mcbuffer, int bit_depth); |
453 | | template |
454 | | void put_epel_hv_fallback<uint16_t,int16_t>(int16_t *dst, ptrdiff_t dst_stride, |
455 | | const uint16_t *src, ptrdiff_t src_stride, |
456 | | int nPbWC, int nPbHC, |
457 | | int xFracC, int yFracC, int16_t* mcbuffer, int bit_depth); |
458 | | template |
459 | | void put_epel_hv_fallback<uint16_t,int32_t>(int32_t *dst, ptrdiff_t dst_stride, |
460 | | const uint16_t *src, ptrdiff_t src_stride, |
461 | | int nPbWC, int nPbHC, |
462 | | int xFracC, int yFracC, int32_t* mcbuffer, int bit_depth); |
463 | | |
464 | | |
465 | | |
466 | | void put_qpel_0_0_fallback(int16_t *out, ptrdiff_t out_stride, |
467 | | const uint8_t *src, ptrdiff_t srcstride, |
468 | | int nPbW, int nPbH, int16_t* mcbuffer) |
469 | 0 | { |
470 | | //const int shift1 = 0; // sps->BitDepth_Y-8; |
471 | 0 | const int shift2 = 6; |
472 | | |
473 | | // straight copy |
474 | |
|
475 | 0 | for (int y=0;y<nPbH;y++) { |
476 | 0 | const uint8_t* p = src + srcstride*y; |
477 | 0 | int16_t* o = out + out_stride*y; |
478 | |
|
479 | 0 | for (int x=0;x<nPbW;x+=4) { |
480 | | |
481 | | // does not seem to be faster... |
482 | 0 | int16_t o0,o1,o2,o3; |
483 | 0 | o0 = p[0] << shift2; |
484 | 0 | o1 = p[1] << shift2; |
485 | 0 | o2 = p[2] << shift2; |
486 | 0 | o3 = p[3] << shift2; |
487 | 0 | o[0]=o0; |
488 | 0 | o[1]=o1; |
489 | 0 | o[2]=o2; |
490 | 0 | o[3]=o3; |
491 | |
|
492 | 0 | o+=4; |
493 | 0 | p+=4; |
494 | 0 | } |
495 | 0 | } |
496 | 0 | } |
497 | | |
498 | | |
499 | | template <class inter_t> |
500 | | void put_qpel_0_0_fallback_16(inter_t *out, ptrdiff_t out_stride, |
501 | | const uint16_t *src, ptrdiff_t srcstride, |
502 | | int nPbW, int nPbH, inter_t* mcbuffer, int bit_depth) |
503 | 1.65M | { |
504 | | //const int shift1 = bit_depth-8; |
505 | | //const int shift2 = 6; |
506 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Max(2, 14 - BitDepth). |
507 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; |
508 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. |
509 | 1.65M | const int shift3 = std::max(2, 14-bit_depth); |
510 | | |
511 | | // straight copy |
512 | | |
513 | 18.0M | for (int y=0;y<nPbH;y++) { |
514 | 16.3M | const uint16_t* p = src + srcstride*y; |
515 | 16.3M | inter_t* o = out + out_stride*y; |
516 | | |
517 | 240M | for (int x=0;x<nPbW;x++) { |
518 | 223M | *o++ = *p++ << shift3; |
519 | 223M | } |
520 | 16.3M | } |
521 | 1.65M | } void put_qpel_0_0_fallback_16<short>(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 503 | 1.16M | { | 504 | | //const int shift1 = bit_depth-8; | 505 | | //const int shift2 = 6; | 506 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Max(2, 14 - BitDepth). | 507 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 508 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 509 | 1.16M | const int shift3 = std::max(2, 14-bit_depth); | 510 | | | 511 | | // straight copy | 512 | | | 513 | 12.2M | for (int y=0;y<nPbH;y++) { | 514 | 11.0M | const uint16_t* p = src + srcstride*y; | 515 | 11.0M | inter_t* o = out + out_stride*y; | 516 | | | 517 | 159M | for (int x=0;x<nPbW;x++) { | 518 | 148M | *o++ = *p++ << shift3; | 519 | 148M | } | 520 | 11.0M | } | 521 | 1.16M | } |
void put_qpel_0_0_fallback_16<int>(int*, long, unsigned short const*, long, int, int, int*, int) Line | Count | Source | 503 | 485k | { | 504 | | //const int shift1 = bit_depth-8; | 505 | | //const int shift2 = 6; | 506 | | // shift3 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Max(2, 14 - BitDepth). | 507 | | // The Max() was added with the Range Extensions in v2 to handle BitDepth up to 16; | 508 | | // the v1 (04/2013) formula was just (14 - BitDepth), valid only for BitDepth <= 14. | 509 | 485k | const int shift3 = std::max(2, 14-bit_depth); | 510 | | | 511 | | // straight copy | 512 | | | 513 | 5.77M | for (int y=0;y<nPbH;y++) { | 514 | 5.29M | const uint16_t* p = src + srcstride*y; | 515 | 5.29M | inter_t* o = out + out_stride*y; | 516 | | | 517 | 80.1M | for (int x=0;x<nPbW;x++) { | 518 | 74.8M | *o++ = *p++ << shift3; | 519 | 74.8M | } | 520 | 5.29M | } | 521 | 485k | } |
|
522 | | |
523 | | template void put_qpel_0_0_fallback_16<int16_t>(int16_t*, ptrdiff_t, const uint16_t*, ptrdiff_t, int, int, int16_t*, int); |
524 | | template void put_qpel_0_0_fallback_16<int32_t>(int32_t*, ptrdiff_t, const uint16_t*, ptrdiff_t, int, int, int32_t*, int); |
525 | | |
526 | | |
527 | | |
528 | | static int extra_before[4] = { 0,3,3,2 }; |
529 | | static int extra_after [4] = { 0,3,4,4 }; |
530 | | |
531 | | template <class pixel_t, class inter_t> |
532 | | void put_qpel_fallback(inter_t *out, ptrdiff_t out_stride, |
533 | | const pixel_t *src, ptrdiff_t srcstride, |
534 | | int nPbW, int nPbH, inter_t* mcbuffer, |
535 | | int xFracL, int yFracL, int bit_depth) |
536 | 1.41M | { |
537 | 1.41M | int extra_left = extra_before[xFracL]; |
538 | | //int extra_right = extra_after [xFracL]; |
539 | 1.41M | int extra_top = extra_before[yFracL]; |
540 | 1.41M | int extra_bottom = extra_after [yFracL]; |
541 | | |
542 | | //int nPbW_extra = extra_left + nPbW + extra_right; |
543 | 1.41M | int nPbH_extra = extra_top + nPbH + extra_bottom; |
544 | | |
545 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Min(4, BitDepth - 8). |
546 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the |
547 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). |
548 | 1.41M | const int shift1 = std::min(4, bit_depth-8); |
549 | 1.41M | const int shift2 = 6; |
550 | | |
551 | | |
552 | | // H-filters |
553 | | |
554 | 1.41M | switch (xFracL) { |
555 | 346k | case 0: |
556 | 5.89M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { |
557 | 5.55M | const pixel_t* p = src + srcstride*y - extra_left; |
558 | 5.55M | inter_t* o = &mcbuffer[y+extra_top]; |
559 | | |
560 | 72.8M | for (int x=0;x<nPbW;x++) { |
561 | 67.3M | *o = *p; |
562 | 67.3M | o += nPbH_extra; |
563 | 67.3M | p++; |
564 | 67.3M | } |
565 | 5.55M | } |
566 | 346k | break; |
567 | 384k | case 1: |
568 | 5.82M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { |
569 | 5.44M | const pixel_t* p = src + srcstride*y - extra_left; |
570 | 5.44M | inter_t* o = &mcbuffer[y+extra_top]; |
571 | | |
572 | 77.5M | for (int x=0;x<nPbW;x++) { |
573 | 72.1M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>shift1; |
574 | 72.1M | o += nPbH_extra; |
575 | 72.1M | p++; |
576 | 72.1M | } |
577 | 5.44M | } |
578 | 384k | break; |
579 | 313k | case 2: |
580 | 4.95M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { |
581 | 4.64M | const pixel_t* p = src + srcstride*y - extra_left; |
582 | 4.64M | inter_t* o = &mcbuffer[y+extra_top]; |
583 | | |
584 | 60.4M | for (int x=0;x<nPbW;x++) { |
585 | 55.8M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>shift1; |
586 | 55.8M | o += nPbH_extra; |
587 | 55.8M | p++; |
588 | 55.8M | } |
589 | 4.64M | } |
590 | 313k | break; |
591 | 367k | case 3: |
592 | 5.70M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { |
593 | 5.33M | const pixel_t* p = src + srcstride*y - extra_left; |
594 | 5.33M | inter_t* o = &mcbuffer[y+extra_top]; |
595 | | |
596 | 70.9M | for (int x=0;x<nPbW;x++) { |
597 | 65.6M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>shift1; |
598 | 65.6M | o += nPbH_extra; |
599 | 65.6M | p++; |
600 | 65.6M | } |
601 | 5.33M | } |
602 | 367k | break; |
603 | 1.41M | } |
604 | | |
605 | | |
606 | 1.41M | logtrace(LogMotion,"---H---\n"); |
607 | | |
608 | 22.3M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { |
609 | 281M | for (int x=0;x<nPbW;x++) { |
610 | 260M | logtrace(LogMotion,"%04x ",mcbuffer[y+extra_top + x*nPbH_extra]); |
611 | 260M | } |
612 | 20.9M | logtrace(LogMotion,"\n"); |
613 | 20.9M | } |
614 | | |
615 | | // V-filters |
616 | | |
617 | 1.41M | int vshift = (xFracL==0 ? shift1 : shift2); |
618 | | |
619 | 1.41M | switch (yFracL) { |
620 | 288k | case 0: |
621 | 3.35M | for (int x=0;x<nPbW;x++) { |
622 | 3.06M | const inter_t* p = &mcbuffer[x*nPbH_extra]; |
623 | 3.06M | inter_t* o = &out[x]; |
624 | | |
625 | 45.8M | for (int y=0;y<nPbH;y++) { |
626 | 42.7M | *o = *p; |
627 | 42.7M | o+=out_stride; |
628 | 42.7M | p++; |
629 | 42.7M | } |
630 | 3.06M | } |
631 | 288k | break; |
632 | 366k | case 1: |
633 | 4.12M | for (int x=0;x<nPbW;x++) { |
634 | 3.75M | const inter_t* p = &mcbuffer[x*nPbH_extra]; |
635 | 3.75M | inter_t* o = &out[x]; |
636 | | |
637 | 53.6M | for (int y=0;y<nPbH;y++) { |
638 | 49.8M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>vshift; |
639 | 49.8M | o+=out_stride; |
640 | 49.8M | p++; |
641 | 49.8M | } |
642 | 3.75M | } |
643 | 366k | break; |
644 | 324k | case 2: |
645 | 3.53M | for (int x=0;x<nPbW;x++) { |
646 | 3.21M | const inter_t* p = &mcbuffer[x*nPbH_extra]; |
647 | 3.21M | inter_t* o = &out[x]; |
648 | | |
649 | 45.5M | for (int y=0;y<nPbH;y++) { |
650 | 42.3M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>vshift; |
651 | 42.3M | o+=out_stride; |
652 | 42.3M | p++; |
653 | 42.3M | } |
654 | 3.21M | } |
655 | 324k | break; |
656 | 433k | case 3: |
657 | 4.73M | for (int x=0;x<nPbW;x++) { |
658 | 4.30M | const inter_t* p = &mcbuffer[x*nPbH_extra]; |
659 | 4.30M | inter_t* o = &out[x]; |
660 | | |
661 | 59.3M | for (int y=0;y<nPbH;y++) { |
662 | 55.0M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>vshift; |
663 | 55.0M | o+=out_stride; |
664 | 55.0M | p++; |
665 | 55.0M | } |
666 | 4.30M | } |
667 | 433k | break; |
668 | 1.41M | } |
669 | | |
670 | | |
671 | 1.41M | logtrace(LogMotion,"---V---\n"); |
672 | 15.3M | for (int y=0;y<nPbH;y++) { |
673 | 203M | for (int x=0;x<nPbW;x++) { |
674 | 190M | logtrace(LogMotion,"%04x ",out[x+y*out_stride]); |
675 | 190M | } |
676 | 13.9M | logtrace(LogMotion,"\n"); |
677 | 13.9M | } |
678 | 1.41M | } void put_qpel_fallback<unsigned short, int>(int*, long, unsigned short const*, long, int, int, int*, int, int, int) Line | Count | Source | 536 | 438k | { | 537 | 438k | int extra_left = extra_before[xFracL]; | 538 | | //int extra_right = extra_after [xFracL]; | 539 | 438k | int extra_top = extra_before[yFracL]; | 540 | 438k | int extra_bottom = extra_after [yFracL]; | 541 | | | 542 | | //int nPbW_extra = extra_left + nPbW + extra_right; | 543 | 438k | int nPbH_extra = extra_top + nPbH + extra_bottom; | 544 | | | 545 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Min(4, BitDepth - 8). | 546 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the | 547 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). | 548 | 438k | const int shift1 = std::min(4, bit_depth-8); | 549 | 438k | const int shift2 = 6; | 550 | | | 551 | | | 552 | | // H-filters | 553 | | | 554 | 438k | switch (xFracL) { | 555 | 98.7k | case 0: | 556 | 1.90M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 557 | 1.80M | const pixel_t* p = src + srcstride*y - extra_left; | 558 | 1.80M | inter_t* o = &mcbuffer[y+extra_top]; | 559 | | | 560 | 27.9M | for (int x=0;x<nPbW;x++) { | 561 | 26.1M | *o = *p; | 562 | 26.1M | o += nPbH_extra; | 563 | 26.1M | p++; | 564 | 26.1M | } | 565 | 1.80M | } | 566 | 98.7k | break; | 567 | 142k | case 1: | 568 | 2.20M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 569 | 2.06M | const pixel_t* p = src + srcstride*y - extra_left; | 570 | 2.06M | inter_t* o = &mcbuffer[y+extra_top]; | 571 | | | 572 | 30.6M | for (int x=0;x<nPbW;x++) { | 573 | 28.6M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>shift1; | 574 | 28.6M | o += nPbH_extra; | 575 | 28.6M | p++; | 576 | 28.6M | } | 577 | 2.06M | } | 578 | 142k | break; | 579 | 86.2k | case 2: | 580 | 1.54M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 581 | 1.45M | const pixel_t* p = src + srcstride*y - extra_left; | 582 | 1.45M | inter_t* o = &mcbuffer[y+extra_top]; | 583 | | | 584 | 21.6M | for (int x=0;x<nPbW;x++) { | 585 | 20.1M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>shift1; | 586 | 20.1M | o += nPbH_extra; | 587 | 20.1M | p++; | 588 | 20.1M | } | 589 | 1.45M | } | 590 | 86.2k | break; | 591 | 111k | case 3: | 592 | 1.85M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 593 | 1.74M | const pixel_t* p = src + srcstride*y - extra_left; | 594 | 1.74M | inter_t* o = &mcbuffer[y+extra_top]; | 595 | | | 596 | 24.4M | for (int x=0;x<nPbW;x++) { | 597 | 22.7M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>shift1; | 598 | 22.7M | o += nPbH_extra; | 599 | 22.7M | p++; | 600 | 22.7M | } | 601 | 1.74M | } | 602 | 111k | break; | 603 | 438k | } | 604 | | | 605 | | | 606 | 438k | logtrace(LogMotion,"---H---\n"); | 607 | | | 608 | 7.50M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 609 | 104M | for (int x=0;x<nPbW;x++) { | 610 | 97.6M | logtrace(LogMotion,"%04x ",mcbuffer[y+extra_top + x*nPbH_extra]); | 611 | 97.6M | } | 612 | 7.06M | logtrace(LogMotion,"\n"); | 613 | 7.06M | } | 614 | | | 615 | | // V-filters | 616 | | | 617 | 438k | int vshift = (xFracL==0 ? shift1 : shift2); | 618 | | | 619 | 438k | switch (yFracL) { | 620 | 95.6k | case 0: | 621 | 1.17M | for (int x=0;x<nPbW;x++) { | 622 | 1.07M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 623 | 1.07M | inter_t* o = &out[x]; | 624 | | | 625 | 17.9M | for (int y=0;y<nPbH;y++) { | 626 | 16.9M | *o = *p; | 627 | 16.9M | o+=out_stride; | 628 | 16.9M | p++; | 629 | 16.9M | } | 630 | 1.07M | } | 631 | 95.6k | break; | 632 | 122k | case 1: | 633 | 1.38M | for (int x=0;x<nPbW;x++) { | 634 | 1.26M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 635 | 1.26M | inter_t* o = &out[x]; | 636 | | | 637 | 20.7M | for (int y=0;y<nPbH;y++) { | 638 | 19.4M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>vshift; | 639 | 19.4M | o+=out_stride; | 640 | 19.4M | p++; | 641 | 19.4M | } | 642 | 1.26M | } | 643 | 122k | break; | 644 | 106k | case 2: | 645 | 1.25M | for (int x=0;x<nPbW;x++) { | 646 | 1.14M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 647 | 1.14M | inter_t* o = &out[x]; | 648 | | | 649 | 19.7M | for (int y=0;y<nPbH;y++) { | 650 | 18.6M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>vshift; | 651 | 18.6M | o+=out_stride; | 652 | 18.6M | p++; | 653 | 18.6M | } | 654 | 1.14M | } | 655 | 106k | break; | 656 | 114k | case 3: | 657 | 1.35M | for (int x=0;x<nPbW;x++) { | 658 | 1.23M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 659 | 1.23M | inter_t* o = &out[x]; | 660 | | | 661 | 20.8M | for (int y=0;y<nPbH;y++) { | 662 | 19.5M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>vshift; | 663 | 19.5M | o+=out_stride; | 664 | 19.5M | p++; | 665 | 19.5M | } | 666 | 1.23M | } | 667 | 114k | break; | 668 | 438k | } | 669 | | | 670 | | | 671 | 438k | logtrace(LogMotion,"---V---\n"); | 672 | 5.34M | for (int y=0;y<nPbH;y++) { | 673 | 79.4M | for (int x=0;x<nPbW;x++) { | 674 | 74.5M | logtrace(LogMotion,"%04x ",out[x+y*out_stride]); | 675 | 74.5M | } | 676 | 4.90M | logtrace(LogMotion,"\n"); | 677 | 4.90M | } | 678 | 438k | } |
Unexecuted instantiation: void put_qpel_fallback<unsigned char, short>(short*, long, unsigned char const*, long, int, int, short*, int, int, int) void put_qpel_fallback<unsigned short, short>(short*, long, unsigned short const*, long, int, int, short*, int, int, int) Line | Count | Source | 536 | 973k | { | 537 | 973k | int extra_left = extra_before[xFracL]; | 538 | | //int extra_right = extra_after [xFracL]; | 539 | 973k | int extra_top = extra_before[yFracL]; | 540 | 973k | int extra_bottom = extra_after [yFracL]; | 541 | | | 542 | | //int nPbW_extra = extra_left + nPbW + extra_right; | 543 | 973k | int nPbH_extra = extra_top + nPbH + extra_bottom; | 544 | | | 545 | | // shift1 per HEVC v2 (10/2014) spec 8.5.3.3.3.2 (luma): Min(4, BitDepth - 8). | 546 | | // The Min() was added with the Range Extensions in v2 for BitDepth > 12: the | 547 | | // intermediate samples then keep BitDepth+2 bits instead of 14 (see shift3). | 548 | 973k | const int shift1 = std::min(4, bit_depth-8); | 549 | 973k | const int shift2 = 6; | 550 | | | 551 | | | 552 | | // H-filters | 553 | | | 554 | 973k | switch (xFracL) { | 555 | 248k | case 0: | 556 | 3.99M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 557 | 3.74M | const pixel_t* p = src + srcstride*y - extra_left; | 558 | 3.74M | inter_t* o = &mcbuffer[y+extra_top]; | 559 | | | 560 | 44.9M | for (int x=0;x<nPbW;x++) { | 561 | 41.2M | *o = *p; | 562 | 41.2M | o += nPbH_extra; | 563 | 41.2M | p++; | 564 | 41.2M | } | 565 | 3.74M | } | 566 | 248k | break; | 567 | 242k | case 1: | 568 | 3.62M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 569 | 3.38M | const pixel_t* p = src + srcstride*y - extra_left; | 570 | 3.38M | inter_t* o = &mcbuffer[y+extra_top]; | 571 | | | 572 | 46.9M | for (int x=0;x<nPbW;x++) { | 573 | 43.5M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>shift1; | 574 | 43.5M | o += nPbH_extra; | 575 | 43.5M | p++; | 576 | 43.5M | } | 577 | 3.38M | } | 578 | 242k | break; | 579 | 226k | case 2: | 580 | 3.41M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 581 | 3.18M | const pixel_t* p = src + srcstride*y - extra_left; | 582 | 3.18M | inter_t* o = &mcbuffer[y+extra_top]; | 583 | | | 584 | 38.8M | for (int x=0;x<nPbW;x++) { | 585 | 35.6M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>shift1; | 586 | 35.6M | o += nPbH_extra; | 587 | 35.6M | p++; | 588 | 35.6M | } | 589 | 3.18M | } | 590 | 226k | break; | 591 | 256k | case 3: | 592 | 3.84M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 593 | 3.58M | const pixel_t* p = src + srcstride*y - extra_left; | 594 | 3.58M | inter_t* o = &mcbuffer[y+extra_top]; | 595 | | | 596 | 46.4M | for (int x=0;x<nPbW;x++) { | 597 | 42.8M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>shift1; | 598 | 42.8M | o += nPbH_extra; | 599 | 42.8M | p++; | 600 | 42.8M | } | 601 | 3.58M | } | 602 | 256k | break; | 603 | 973k | } | 604 | | | 605 | | | 606 | 973k | logtrace(LogMotion,"---H---\n"); | 607 | | | 608 | 14.8M | for (int y=-extra_top;y<nPbH+extra_bottom;y++) { | 609 | 177M | for (int x=0;x<nPbW;x++) { | 610 | 163M | logtrace(LogMotion,"%04x ",mcbuffer[y+extra_top + x*nPbH_extra]); | 611 | 163M | } | 612 | 13.9M | logtrace(LogMotion,"\n"); | 613 | 13.9M | } | 614 | | | 615 | | // V-filters | 616 | | | 617 | 973k | int vshift = (xFracL==0 ? shift1 : shift2); | 618 | | | 619 | 973k | switch (yFracL) { | 620 | 192k | case 0: | 621 | 2.17M | for (int x=0;x<nPbW;x++) { | 622 | 1.98M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 623 | 1.98M | inter_t* o = &out[x]; | 624 | | | 625 | 27.8M | for (int y=0;y<nPbH;y++) { | 626 | 25.8M | *o = *p; | 627 | 25.8M | o+=out_stride; | 628 | 25.8M | p++; | 629 | 25.8M | } | 630 | 1.98M | } | 631 | 192k | break; | 632 | 244k | case 1: | 633 | 2.73M | for (int x=0;x<nPbW;x++) { | 634 | 2.49M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 635 | 2.49M | inter_t* o = &out[x]; | 636 | | | 637 | 32.8M | for (int y=0;y<nPbH;y++) { | 638 | 30.3M | *o = (-p[0]+4*p[1]-10*p[2]+58*p[3]+17*p[4] -5*p[5] +p[6])>>vshift; | 639 | 30.3M | o+=out_stride; | 640 | 30.3M | p++; | 641 | 30.3M | } | 642 | 2.49M | } | 643 | 244k | break; | 644 | 217k | case 2: | 645 | 2.28M | for (int x=0;x<nPbW;x++) { | 646 | 2.06M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 647 | 2.06M | inter_t* o = &out[x]; | 648 | | | 649 | 25.7M | for (int y=0;y<nPbH;y++) { | 650 | 23.7M | *o = (-p[0]+4*p[1]-11*p[2]+40*p[3]+40*p[4]-11*p[5]+4*p[6]-p[7])>>vshift; | 651 | 23.7M | o+=out_stride; | 652 | 23.7M | p++; | 653 | 23.7M | } | 654 | 2.06M | } | 655 | 217k | break; | 656 | 319k | case 3: | 657 | 3.38M | for (int x=0;x<nPbW;x++) { | 658 | 3.06M | const inter_t* p = &mcbuffer[x*nPbH_extra]; | 659 | 3.06M | inter_t* o = &out[x]; | 660 | | | 661 | 38.5M | for (int y=0;y<nPbH;y++) { | 662 | 35.4M | *o = ( p[0]-5*p[1]+17*p[2]+58*p[3]-10*p[4] +4*p[5] -p[6])>>vshift; | 663 | 35.4M | o+=out_stride; | 664 | 35.4M | p++; | 665 | 35.4M | } | 666 | 3.06M | } | 667 | 319k | break; | 668 | 973k | } | 669 | | | 670 | | | 671 | 973k | logtrace(LogMotion,"---V---\n"); | 672 | 9.97M | for (int y=0;y<nPbH;y++) { | 673 | 124M | for (int x=0;x<nPbW;x++) { | 674 | 115M | logtrace(LogMotion,"%04x ",out[x+y*out_stride]); | 675 | 115M | } | 676 | 8.99M | logtrace(LogMotion,"\n"); | 677 | 8.99M | } | 678 | 973k | } |
|
679 | | |
680 | | |
681 | | |
682 | | #define QPEL(x,y) void put_qpel_ ## x ## _ ## y ## _fallback(int16_t *out, ptrdiff_t out_stride, \ |
683 | | const uint8_t *src, ptrdiff_t srcstride, \ |
684 | | int nPbW, int nPbH, int16_t* mcbuffer) \ |
685 | 0 | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, 8 ); }Unexecuted instantiation: put_qpel_0_1_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_0_2_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_0_3_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_1_0_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_1_1_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_1_2_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_1_3_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_2_0_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_2_1_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_2_2_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_2_3_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_3_0_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_3_1_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_3_2_fallback(short*, long, unsigned char const*, long, int, int, short*) Unexecuted instantiation: put_qpel_3_3_fallback(short*, long, unsigned char const*, long, int, int, short*) |
686 | | |
687 | | |
688 | | // The int32_t variant (BitDepth > 12) is not performance critical: one generic |
689 | | // kernel for all fractional positions instead of 16 specialized copies. |
690 | | void put_qpel_fallback_16_32(int32_t *out, ptrdiff_t out_stride, |
691 | | const uint16_t *src, ptrdiff_t srcstride, |
692 | | int nPbW, int nPbH, int32_t* mcbuffer, |
693 | | int xFracL, int yFracL, int bit_depth) |
694 | 924k | { |
695 | 924k | if (xFracL==0 && yFracL==0) { |
696 | 485k | put_qpel_0_0_fallback_16(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer, bit_depth); |
697 | 485k | } |
698 | 438k | else { |
699 | 438k | put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer, xFracL,yFracL, bit_depth); |
700 | 438k | } |
701 | 924k | } |
702 | | |
703 | | #define QPEL16(x,y) void put_qpel_ ## x ## _ ## y ## _fallback_16(int16_t *out, ptrdiff_t out_stride, \ |
704 | | const uint16_t *src, ptrdiff_t srcstride, \ |
705 | 973k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ |
706 | 973k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); }put_qpel_0_1_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 60.1k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 60.1k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_0_2_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 49.2k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 49.2k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_0_3_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 138k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 138k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_1_0_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 73.3k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 73.3k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_1_1_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 84.3k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 84.3k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_1_2_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 30.3k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 30.3k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_1_3_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 54.1k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 54.1k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_2_0_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 57.6k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 57.6k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_2_1_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 41.9k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 41.9k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_2_2_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 80.7k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 80.7k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_2_3_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 46.4k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 46.4k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_3_0_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 61.6k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 61.6k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_3_1_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 57.4k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 57.4k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_3_2_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 57.5k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 57.5k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
put_qpel_3_3_fallback_16(short*, long, unsigned short const*, long, int, int, short*, int) Line | Count | Source | 705 | 79.7k | int nPbW, int nPbH, int16_t* mcbuffer, int bit_depth) \ | 706 | 79.7k | { put_qpel_fallback(out,out_stride, src,srcstride, nPbW,nPbH,mcbuffer,x,y, bit_depth ); } |
|
707 | | |
708 | | /* */ QPEL(0,1) QPEL(0,2) QPEL(0,3) |
709 | | QPEL(1,0) QPEL(1,1) QPEL(1,2) QPEL(1,3) |
710 | | QPEL(2,0) QPEL(2,1) QPEL(2,2) QPEL(2,3) |
711 | | QPEL(3,0) QPEL(3,1) QPEL(3,2) QPEL(3,3) |
712 | | |
713 | | /* */ QPEL16(0,1) QPEL16(0,2) QPEL16(0,3) |
714 | | QPEL16(1,0) QPEL16(1,1) QPEL16(1,2) QPEL16(1,3) |
715 | | QPEL16(2,0) QPEL16(2,1) QPEL16(2,2) QPEL16(2,3) |
716 | | QPEL16(3,0) QPEL16(3,1) QPEL16(3,2) QPEL16(3,3) |