2 #[derive(Debug,Clone,Copy)]
22 #[derive(Debug,Clone,Copy)]
23 pub enum PredType8x8 {
33 type IPred4x4Func = fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]);
35 pub struct RV34CommonDSP {
36 pub ipred4x4: [IPred4x4Func; 15],
37 pub ipred8x8: [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
38 pub ipred16x16: [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
41 #[allow(clippy::erasing_op)]
42 fn row_transform(src: &[i16], dst: &mut [i32]) {
44 let z0 = 13 * ((src[i + 4*0] as i32) + (src[i + 4*2] as i32));
45 let z1 = 13 * ((src[i + 4*0] as i32) - (src[i + 4*2] as i32));
46 let z2 = 7 * (src[i + 4*1] as i32) - 17 * (src[i + 4*3] as i32);
47 let z3 = 17 * (src[i + 4*1] as i32) + 7 * (src[i + 4*3] as i32);
48 dst[4 * i + 0] = z0 + z3;
49 dst[4 * i + 1] = z1 + z2;
50 dst[4 * i + 2] = z1 - z2;
51 dst[4 * i + 3] = z0 - z3;
55 fn clip8(a: i16) -> u8 {
57 else if a > 255 { 255 }
62 fn mclip8(a: i32) -> u8 {
63 if (a as u32) > 255 { !(a >> 16) as u8 }
67 #[allow(clippy::erasing_op)]
69 pub fn new() -> Self {
71 ipred4x4: IPRED_FUNCS4X4,
72 ipred8x8: IPRED_FUNCS8X8,
73 ipred16x16: IPRED_FUNCS16X16,
76 pub fn add_coeffs(&self, dst: &mut [u8], idx: usize, stride: usize, coeffs: &[i16]) {
77 let out = &mut dst[idx..][..stride * 3 + 4];
78 let mut sidx: usize = 0;
79 for el in out.chunks_mut(stride).take(4) {
80 assert!(el.len() >= 4);
81 el[0] = mclip8((el[0] as i32) + (coeffs[0 + sidx] as i32));
82 el[1] = mclip8((el[1] as i32) + (coeffs[1 + sidx] as i32));
83 el[2] = mclip8((el[2] as i32) + (coeffs[2 + sidx] as i32));
84 el[3] = mclip8((el[3] as i32) + (coeffs[3 + sidx] as i32));
88 pub fn transform(&self, coeffs: &mut [i16]) {
89 let mut tmp: [i32; 16] = [0; 16];
90 row_transform(coeffs, &mut tmp);
92 let z0 = 13*(tmp[4*0+i] + tmp[4*2+i]) + 0x200;
93 let z1 = 13*(tmp[4*0+i] - tmp[4*2+i]) + 0x200;
94 let z2 = 7* tmp[4*1+i] - 17*tmp[4*3+i];
95 let z3 = 17* tmp[4*1+i] + 7*tmp[4*3+i];
96 coeffs[i * 4 + 0] = ((z0 + z3) >> 10) as i16;
97 coeffs[i * 4 + 1] = ((z1 + z2) >> 10) as i16;
98 coeffs[i * 4 + 2] = ((z1 - z2) >> 10) as i16;
99 coeffs[i * 4 + 3] = ((z0 - z3) >> 10) as i16;
102 pub fn transform_dc(&self, coeffs: &mut [i16]) {
103 let val = (((coeffs[0] as i32) * 13 * 13 + 0x200) >> 10) as i16;
104 for i in 0..16 { coeffs[i] = val; }
106 pub fn transform16(&self, coeffs: &mut [i16]) {
107 let mut tmp: [i32; 16] = [0; 16];
108 row_transform(coeffs, &mut tmp);
110 let z0 = 39*(tmp[4*0+i] + tmp[4*2+i]);
111 let z1 = 39*(tmp[4*0+i] - tmp[4*2+i]);
112 let z2 = 21* tmp[4*1+i] - 51*tmp[4*3+i];
113 let z3 = 51* tmp[4*1+i] + 21*tmp[4*3+i];
115 coeffs[i * 4 + 0] = ((z0 + z3) >> 11) as i16;
116 coeffs[i * 4 + 1] = ((z1 + z2) >> 11) as i16;
117 coeffs[i * 4 + 2] = ((z1 - z2) >> 11) as i16;
118 coeffs[i * 4 + 3] = ((z0 - z3) >> 11) as i16;
121 pub fn transform16_dc(&self, coeffs: &mut [i16]) {
122 let val = (((coeffs[0] as i32) * 13 * 13 * 3) >> 11) as i16;
123 for i in 0..16 { coeffs[i] = val; }
125 pub fn weight(&self, dst: &mut [u8], mut didx: usize, dstride: usize,
126 src: &[u8], mut sidx: usize, sstride: usize, ratio1: u32, ratio2: u32,
130 dst[didx + x] = (((((dst[didx + x] as u32) * ratio1) >> 9)
131 + (((src[sidx + x] as u32) * ratio2) >> 9) + 0x10) >> 5) as u8;
137 pub fn avg(&self, dst: &mut [u8], mut didx: usize, dstride: usize,
138 src: &[u8], mut sidx: usize, sstride: usize,
142 dst[didx + x] = (((dst[didx + x] as u16) + (src[sidx + x] as u16) + 1) >> 1) as u8;
150 fn ipred_dc128(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize) {
152 for x in 0..bsize { buf[idx + x] = 128; }
156 fn ipred_ver(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize) {
157 let oidx = idx - stride;
159 for x in 0..bsize { buf[idx + x] = buf[oidx + x]; }
163 fn ipred_hor(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize) {
165 for x in 0..bsize { buf[idx + x] = buf[idx - 1]; }
169 fn ipred_dc(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize, shift: u8) {
170 let mut adc: u16 = 0;
171 for i in 0..bsize { adc += buf[idx - stride + i] as u16; }
172 for i in 0..bsize { adc += buf[idx - 1 + i * stride] as u16; }
173 let dc = ((adc + (1 << (shift - 1))) >> shift) as u8;
176 for x in 0..bsize { buf[idx + x] = dc; }
180 fn ipred_left_dc(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize, shift: u8) {
181 let mut adc: u16 = 0;
182 for i in 0..bsize { adc += buf[idx - 1 + i * stride] as u16; }
183 let dc = ((adc + (1 << (shift - 1))) >> shift) as u8;
186 for x in 0..bsize { buf[idx + x] = dc; }
190 fn ipred_top_dc(buf: &mut [u8], mut idx: usize, stride: usize, bsize: usize, shift: u8) {
191 let mut adc: u16 = 0;
192 for i in 0..bsize { adc += buf[idx - stride + i] as u16; }
193 let dc = ((adc + (1 << (shift - 1))) >> shift) as u8;
196 for x in 0..bsize { buf[idx + x] = dc; }
201 fn load_top(dst: &mut [u16], buf: &mut [u8], idx: usize, stride: usize, len: usize) {
202 for i in 0..len { dst[i] = buf[idx - stride + i] as u16; }
204 fn load_left(dst: &mut [u16], buf: &mut [u8], idx: usize, stride: usize, len: usize) {
205 for i in 0..len { dst[i] = buf[idx - 1 + i * stride] as u16; }
208 fn ipred_4x4_ver(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
209 ipred_ver(buf, idx, stride, 4);
211 fn ipred_4x4_hor(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
212 ipred_hor(buf, idx, stride, 4);
214 fn ipred_4x4_diag_down_left(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
215 let mut t: [u16; 8] = [0; 8];
216 let mut l: [u16; 8] = [0; 8];
217 load_top(&mut t, buf, idx, stride, 4);
218 for i in 0..4 { t[i + 4] = tr[i] as u16; }
219 load_left(&mut l, buf, idx, stride, 8);
220 let dst = &mut buf[idx..];
222 dst[0 + 0 * stride] = ((t[0] + t[2] + 2*t[1] + 2 + l[0] + l[2] + 2*l[1] + 2) >> 3) as u8;
223 let pix = ((t[1] + t[3] + 2*t[2] + 2 + l[1] + l[3] + 2*l[2] + 2) >> 3) as u8;
224 dst[1 + 0 * stride] = pix;
225 dst[0 + 1 * stride] = pix;
226 let pix = ((t[2] + t[4] + 2*t[3] + 2 + l[2] + l[4] + 2*l[3] + 2) >> 3) as u8;
227 dst[2 + 0 * stride] = pix;
228 dst[1 + 1 * stride] = pix;
229 dst[0 + 2 * stride] = pix;
230 let pix = ((t[3] + t[5] + 2*t[4] + 2 + l[3] + l[5] + 2*l[4] + 2) >> 3) as u8;
231 dst[3 + 0 * stride] = pix;
232 dst[2 + 1 * stride] = pix;
233 dst[1 + 2 * stride] = pix;
234 dst[0 + 3 * stride] = pix;
235 let pix = ((t[4] + t[6] + 2*t[5] + 2 + l[4] + l[6] + 2*l[5] + 2) >> 3) as u8;
236 dst[3 + 1 * stride] = pix;
237 dst[2 + 2 * stride] = pix;
238 dst[1 + 3 * stride] = pix;
239 let pix = ((t[5] + t[7] + 2*t[6] + 2 + l[5] + l[7] + 2*l[6] + 2) >> 3) as u8;
240 dst[3 + 2 * stride] = pix;
241 dst[2 + 3 * stride] = pix;
242 dst[3 + 3 * stride] = ((t[6] + t[7] + 1 + l[6] + l[7] + 1) >> 2) as u8;
244 fn ipred_4x4_diag_down_left_nodown(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
245 let mut t: [u16; 8] = [0; 8];
246 let mut l: [u16; 4] = [0; 4];
247 load_top(&mut t, buf, idx, stride, 4);
248 for i in 0..4 { t[i + 4] = tr[i] as u16; }
249 load_left(&mut l, buf, idx, stride, 4);
250 let dst = &mut buf[idx..];
252 dst[0 + 0 * stride] = ((t[0] + t[2] + 2*t[1] + 2 + l[0] + l[2] + 2*l[1] + 2) >> 3) as u8;
253 let pix = ((t[1] + t[3] + 2*t[2] + 2 + l[1] + l[3] + 2*l[2] + 2) >> 3) as u8;
254 dst[1 + 0 * stride] = pix;
255 dst[0 + 1 * stride] = pix;
256 let pix = ((t[2] + t[4] + 2*t[3] + 2 + l[2] + 3*l[3] + 2) >> 3) as u8;
257 dst[2 + 0 * stride] = pix;
258 dst[1 + 1 * stride] = pix;
259 dst[0 + 2 * stride] = pix;
260 let pix = ((t[3] + t[5] + 2*t[4] + 2 + l[3]*4 + 2) >> 3) as u8;
261 dst[3 + 0 * stride] = pix;
262 dst[2 + 1 * stride] = pix;
263 dst[1 + 2 * stride] = pix;
264 dst[0 + 3 * stride] = pix;
265 let pix = ((t[4] + t[6] + 2*t[5] + 2 + l[3]*4 + 2) >> 3) as u8;
266 dst[3 + 1 * stride] = pix;
267 dst[2 + 2 * stride] = pix;
268 dst[1 + 3 * stride] = pix;
269 let pix = ((t[5] + t[7] + 2*t[6] + 2 + l[3]*4 + 2) >> 3) as u8;
270 dst[3 + 2 * stride] = pix;
271 dst[2 + 3 * stride] = pix;
272 dst[3 + 3 * stride] = ((t[6] + t[7] + 1 + 2*l[3] + 1) >> 2) as u8;
274 fn ipred_4x4_diag_down_right(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
275 let mut t: [u16; 5] = [0; 5];
276 let mut l: [u16; 5] = [0; 5];
277 load_top(&mut t, buf, idx - 1, stride, 5);
278 load_left(&mut l, buf, idx - stride, stride, 5);
279 let dst = &mut buf[idx..];
283 dst[i + j * stride] = ((l[j - i - 1] + 2 * l[j - i] + l[j - i + 1] + 2) >> 2) as u8;
285 dst[j + j * stride] = ((l[1] + 2 * l[0] + t[1] + 2) >> 2) as u8;
287 dst[i + j * stride] = ((t[i - j - 1] + 2 * t[i - j] + t[i - j + 1] + 2) >> 2) as u8;
291 fn ipred_4x4_ver_right(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
292 let mut t: [u16; 5] = [0; 5];
293 let mut l: [u16; 5] = [0; 5];
294 load_top(&mut t, buf, idx - 1, stride, 5);
295 load_left(&mut l, buf, idx - stride, stride, 5);
296 let dst = &mut buf[idx..];
300 let zvr = ((2 * i) as i8) - (j as i8);
304 pix = (t[i - (j >> 1)] + t[i - (j >> 1) + 1] + 1) >> 1;
306 pix = (t[i - (j >> 1) - 1] + 2 * t[i - (j >> 1)] + t[i - (j >> 1) + 1] + 2) >> 2;
310 pix = (l[1] + 2 * l[0] + t[1] + 2) >> 2;
312 pix = (l[j] + 2 * l[j - 1] + l[j - 2] + 2) >> 2;
315 dst[i + j * stride] = pix as u8;
319 fn ipred_4x4_ver_left_common(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8], no_down: bool) {
320 let mut t: [u16; 8] = [0; 8];
321 let mut l: [u16; 5] = [0; 5];
322 load_top(&mut t, buf, idx, stride, 4);
323 for i in 0..4 { t[i + 4] = tr[i] as u16; }
324 load_left(&mut l, buf, idx, stride, 4);
325 l[4] = if no_down { l[3] } else { buf[idx - 1 + 4 * stride] as u16 };
326 let dst = &mut buf[idx..];
328 dst[0 + 0 * stride] = ((2*t[0] + 2*t[1] + l[1] + 2*l[2] + l[3] + 4) >> 3) as u8;
329 let pix = ((t[1] + t[2] + 1) >> 1) as u8;
330 dst[1 + 0 * stride] = pix;
331 dst[0 + 2 * stride] = pix;
332 let pix = ((t[2] + t[3] + 1) >> 1) as u8;
333 dst[2 + 0 * stride] = pix;
334 dst[1 + 2 * stride] = pix;
335 let pix = ((t[3] + t[4] + 1) >> 1) as u8;
336 dst[3 + 0 * stride] = pix;
337 dst[2 + 2 * stride] = pix;
338 dst[3 + 2 * stride] = ((t[4] + t[5] + 1) >> 1) as u8;
339 dst[0 + 1 * stride] = ((t[0] + 2*t[1] + t[2] + l[2] + 2*l[3] + l[4] + 4) >> 3) as u8;
340 let pix = ((t[1] + 2*t[2] + t[3] + 2) >> 2) as u8;
341 dst[1 + 1 * stride] = pix;
342 dst[0 + 3 * stride] = pix;
343 let pix = ((t[2] + 2*t[3] + t[4] + 2) >> 2) as u8;
344 dst[2 + 1 * stride] = pix;
345 dst[1 + 3 * stride] = pix;
346 let pix = ((t[3] + 2*t[4] + t[5] + 2) >> 2) as u8;
347 dst[3 + 1 * stride] = pix;
348 dst[2 + 3 * stride] = pix;
349 dst[3 + 3 * stride] = ((t[4] + 2*t[5] + t[6] + 2) >> 2) as u8;
352 fn ipred_4x4_ver_left(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
353 ipred_4x4_ver_left_common(buf, idx, stride, tr, false);
355 fn ipred_4x4_ver_left_nodown(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
356 ipred_4x4_ver_left_common(buf, idx, stride, tr, true);
358 fn ipred_4x4_hor_down(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
359 let mut t: [u16; 5] = [0; 5];
360 let mut l: [u16; 5] = [0; 5];
361 load_top(&mut t, buf, idx - 1, stride, 5);
362 load_left(&mut l, buf, idx - stride, stride, 5);
363 let dst = &mut buf[idx..];
367 let zhd = ((2 * j) as i8) - (i as i8);
371 pix = (l[j - (i >> 1)] + l[j - (i >> 1) + 1] + 1) >> 1;
373 pix = (l[j - (i >> 1) - 1] + 2 * l[j - (i >> 1)] + l[j - (i >> 1) + 1] + 2) >> 2;
377 pix = (l[1] + 2 * l[0] + t[1] + 2) >> 2;
379 pix = (t[i - 2] + 2 * t[i - 1] + t[i] + 2) >> 2;
382 dst[i + j * stride] = pix as u8;
386 fn ipred_4x4_hor_up(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
387 let mut t: [u16; 8] = [0; 8];
388 let mut l: [u16; 8] = [0; 8];
389 load_top(&mut t, buf, idx, stride, 4);
390 for i in 0..4 { t[i + 4] = tr[i] as u16; }
391 load_left(&mut l, buf, idx, stride, 8);
392 let dst = &mut buf[idx..];
394 dst[0 + 0 * stride] = ((t[1] + 2*t[2] + t[3] + 2*l[0] + 2*l[1] + 4) >> 3) as u8;
395 dst[1 + 0 * stride] = ((t[2] + 2*t[3] + t[4] + l[0] + 2*l[1] + l[2] + 4) >> 3) as u8;
396 let pix = ((t[3] + 2*t[4] + t[5] + 2*l[1] + 2*l[2] + 4) >> 3) as u8;
397 dst[2 + 0 * stride] = pix;
398 dst[0 + 1 * stride] = pix;
399 let pix = ((t[4] + 2*t[5] + t[6] + l[1] + 2*l[2] + l[3] + 4) >> 3) as u8;
400 dst[3 + 0 * stride] = pix;
401 dst[1 + 1 * stride] = pix;
402 let pix = ((t[5] + 2*t[6] + t[7] + 2*l[2] + 2*l[3] + 4) >> 3) as u8;
403 dst[2 + 1 * stride] = pix;
404 dst[0 + 2 * stride] = pix;
405 let pix = ((t[6] + 3*t[7] + l[2] + 3*l[3] + 4) >> 3) as u8;
406 dst[3 + 1 * stride] = pix;
407 dst[1 + 2 * stride] = pix;
408 let pix = ((l[3] + 2*l[4] + l[5] + 2) >> 2) as u8;
409 dst[3 + 2 * stride] = pix;
410 dst[1 + 3 * stride] = pix;
411 let pix = ((t[6] + t[7] + l[3] + l[4] + 2) >> 2) as u8;
412 dst[0 + 3 * stride] = pix;
413 dst[2 + 2 * stride] = pix;
414 dst[2 + 3 * stride] = ((l[4] + l[5] + 1) >> 1) as u8;
415 dst[3 + 3 * stride] = ((l[4] + 2*l[5] + l[6] + 2) >> 2) as u8;
417 fn ipred_4x4_hor_up_nodown(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]) {
418 let mut t: [u16; 8] = [0; 8];
419 let mut l: [u16; 4] = [0; 4];
420 load_top(&mut t, buf, idx, stride, 4);
421 for i in 0..4 { t[i + 4] = tr[i] as u16; }
422 load_left(&mut l, buf, idx, stride, 4);
423 let dst = &mut buf[idx..];
425 dst[0 + 0 * stride] = ((t[1] + 2*t[2] + t[3] + 2*l[0] + 2*l[1] + 4) >> 3) as u8;
426 dst[1 + 0 * stride] = ((t[2] + 2*t[3] + t[4] + l[0] + 2*l[1] + l[2] + 4) >> 3) as u8;
427 let pix = ((t[3] + 2*t[4] + t[5] + 2*l[1] + 2*l[2] + 4) >> 3) as u8;
428 dst[2 + 0 * stride] = pix;
429 dst[0 + 1 * stride] = pix;
430 let pix = ((t[4] + 2*t[5] + t[6] + l[1] + 2*l[2] + l[3] + 4) >> 3) as u8;
431 dst[3 + 0 * stride] = pix;
432 dst[1 + 1 * stride] = pix;
433 let pix = ((t[5] + 2*t[6] + t[7] + 2*l[2] + 2*l[3] + 4) >> 3) as u8;
434 dst[2 + 1 * stride] = pix;
435 dst[0 + 2 * stride] = pix;
436 let pix = ((t[6] + 3*t[7] + l[2] + 3*l[3] + 4) >> 3) as u8;
437 dst[3 + 1 * stride] = pix;
438 dst[1 + 2 * stride] = pix;
439 dst[3 + 2 * stride] = l[3] as u8;
440 dst[1 + 3 * stride] = l[3] as u8;
441 let pix = ((t[6] + t[7] + 2*l[3] + 2) >> 2) as u8;
442 dst[0 + 3 * stride] = pix;
443 dst[2 + 2 * stride] = pix;
444 dst[2 + 3 * stride] = l[3] as u8;
445 dst[3 + 3 * stride] = l[3] as u8;
447 fn ipred_4x4_dc(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
448 ipred_dc(buf, idx, stride, 4, 3);
450 fn ipred_4x4_left_dc(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
451 ipred_left_dc(buf, idx, stride, 4, 2);
453 fn ipred_4x4_top_dc(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
454 ipred_top_dc(buf, idx, stride, 4, 2);
456 fn ipred_4x4_dc128(buf: &mut [u8], idx: usize, stride: usize, _tr: &[u8]) {
457 ipred_dc128(buf, idx, stride, 4);
460 fn ipred_8x8_ver(buf: &mut [u8], idx: usize, stride: usize) {
461 ipred_ver(buf, idx, stride, 8);
463 fn ipred_8x8_hor(buf: &mut [u8], idx: usize, stride: usize) {
464 ipred_hor(buf, idx, stride, 8);
466 fn ipred_8x8_dc(buf: &mut [u8], idx: usize, stride: usize) {
467 ipred_dc(buf, idx, stride, 8, 4);
469 fn ipred_8x8_left_dc(buf: &mut [u8], idx: usize, stride: usize) {
470 ipred_left_dc(buf, idx, stride, 8, 3);
472 fn ipred_8x8_top_dc(buf: &mut [u8], idx: usize, stride: usize) {
473 ipred_top_dc(buf, idx, stride, 8, 3);
475 fn ipred_8x8_dc128(buf: &mut [u8], idx: usize, stride: usize) {
476 ipred_dc128(buf, idx, stride, 8);
478 fn ipred_8x8_plane(_buf: &mut [u8], _idx: usize, _stride: usize) {
480 /* let mut h: i16 = 0;
483 let i1 = (i + 1) as i16;
484 h += i1 * ((buf[idx + (4 + i) - stride] as i16) - (buf[idx + (2 - i) - stride] as i16));
485 v += i1 * ((buf[idx + (4 + i) * stride - 1] as i16) - (buf[idx + (2 - i) * stride - 1] as i16));
487 let a = 16 * ((buf[idx - 1 + 7 * stride] as i16) + (buf[idx + 7 - stride] as i16));
488 let b = (17 * h + 16) >> 5;
489 let c = (17 * v + 16) >> 5;
491 let j3 = (y as i16) - 3;
493 let i3 = (x as i16) - 3;
494 buf[idx + x] = clip8((a + b * i3 + c * j3 + 16) >> 5);
500 fn ipred_16x16_ver(buf: &mut [u8], idx: usize, stride: usize) {
501 ipred_ver(buf, idx, stride, 16);
503 fn ipred_16x16_hor(buf: &mut [u8], idx: usize, stride: usize) {
504 ipred_hor(buf, idx, stride, 16);
506 fn ipred_16x16_dc(buf: &mut [u8], idx: usize, stride: usize) {
507 ipred_dc(buf, idx, stride, 16, 5);
509 fn ipred_16x16_left_dc(buf: &mut [u8], idx: usize, stride: usize) {
510 ipred_left_dc(buf, idx, stride, 16, 4);
512 fn ipred_16x16_top_dc(buf: &mut [u8], idx: usize, stride: usize) {
513 ipred_top_dc(buf, idx, stride, 16, 4);
515 fn ipred_16x16_dc128(buf: &mut [u8], idx: usize, stride: usize) {
516 ipred_dc128(buf, idx, stride, 16);
518 fn ipred_16x16_plane(buf: &mut [u8], mut idx: usize, stride: usize) {
519 let idx0 = idx + 7 - stride;
520 let mut idx1 = idx + 8*stride - 1;
521 let mut idx2 = idx1 - 2*stride;
523 let mut h = (buf[idx0 + 1] as i16) - (buf[idx0 - 1] as i16);
524 let mut v = (buf[idx1 + 0] as i16) - (buf[idx2 + 0] as i16);
529 h += (k as i16) * ((buf[idx0 + k] as i16) - (buf[idx0 - k] as i16));
530 v += (k as i16) * ((buf[idx1 + 0] as i16) - (buf[idx2 + 0] as i16));
532 h = (h + (h >> 2)) >> 4;
533 v = (v + (v >> 2)) >> 4;
535 let mut a = 16 * ((buf[idx1 + 0] as i16) + (buf[idx2 + 16] as i16) + 1) - 7 * (v + h);
542 buf[idx + x * 4 + 0] = clip8((b ) >> 5);
543 buf[idx + x * 4 + 1] = clip8((b + h) >> 5);
544 buf[idx + x * 4 + 2] = clip8((b + 2*h) >> 5);
545 buf[idx + x * 4 + 3] = clip8((b + 3*h) >> 5);
552 const IPRED_FUNCS4X4: [IPred4x4Func; 15] = [
553 ipred_4x4_ver, ipred_4x4_hor, ipred_4x4_dc,
554 ipred_4x4_diag_down_left, ipred_4x4_diag_down_right,
555 ipred_4x4_ver_right, ipred_4x4_hor_down, ipred_4x4_ver_left, ipred_4x4_hor_up,
556 ipred_4x4_left_dc, ipred_4x4_top_dc, ipred_4x4_dc128,
557 ipred_4x4_diag_down_left_nodown, ipred_4x4_hor_up_nodown, ipred_4x4_ver_left_nodown
560 const IPRED_FUNCS8X8: [fn(buf: &mut [u8], idx: usize, stride: usize); 7] = [
561 ipred_8x8_dc, ipred_8x8_hor, ipred_8x8_ver, ipred_8x8_plane,
562 ipred_8x8_left_dc, ipred_8x8_top_dc, ipred_8x8_dc128
565 const IPRED_FUNCS16X16: [fn(buf: &mut [u8], idx: usize, stride: usize); 7] = [
566 ipred_16x16_dc, ipred_16x16_hor, ipred_16x16_ver, ipred_16x16_plane,
567 ipred_16x16_left_dc, ipred_16x16_top_dc, ipred_16x16_dc128