1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "./vpx_config.h"
12 #include "./vpx_dsp_rtcd.h"
13 #include "vpx/vpx_integer.h"
14 #include "vpx_ports/mem.h"
15
16 #if HAVE_MEDIA
17 static const int16_t bilinear_filters_media[8][2] = {
18 { 128, 0 },
19 { 112, 16 },
20 { 96, 32 },
21 { 80, 48 },
22 { 64, 64 },
23 { 48, 80 },
24 { 32, 96 },
25 { 16, 112 }
26 };
27
28 extern void vpx_filter_block2d_bil_first_pass_media(const uint8_t *src_ptr,
29 uint16_t *dst_ptr,
30 uint32_t src_pitch,
31 uint32_t height,
32 uint32_t width,
33 const int16_t *filter);
34
35 extern void vpx_filter_block2d_bil_second_pass_media(const uint16_t *src_ptr,
36 uint8_t *dst_ptr,
37 int32_t src_pitch,
38 uint32_t height,
39 uint32_t width,
40 const int16_t *filter);
41
42
vpx_sub_pixel_variance8x8_media(const uint8_t * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,const uint8_t * dst_ptr,int dst_pixels_per_line,unsigned int * sse)43 unsigned int vpx_sub_pixel_variance8x8_media(const uint8_t *src_ptr,
44 int src_pixels_per_line,
45 int xoffset, int yoffset,
46 const uint8_t *dst_ptr,
47 int dst_pixels_per_line,
48 unsigned int *sse) {
49 uint16_t first_pass[10*8];
50 uint8_t second_pass[8*8];
51 const int16_t *HFilter, *VFilter;
52
53 HFilter = bilinear_filters_media[xoffset];
54 VFilter = bilinear_filters_media[yoffset];
55
56 vpx_filter_block2d_bil_first_pass_media(src_ptr, first_pass,
57 src_pixels_per_line,
58 9, 8, HFilter);
59 vpx_filter_block2d_bil_second_pass_media(first_pass, second_pass,
60 8, 8, 8, VFilter);
61
62 return vpx_variance8x8_media(second_pass, 8, dst_ptr,
63 dst_pixels_per_line, sse);
64 }
65
vpx_sub_pixel_variance16x16_media(const uint8_t * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,const uint8_t * dst_ptr,int dst_pixels_per_line,unsigned int * sse)66 unsigned int vpx_sub_pixel_variance16x16_media(const uint8_t *src_ptr,
67 int src_pixels_per_line,
68 int xoffset,
69 int yoffset,
70 const uint8_t *dst_ptr,
71 int dst_pixels_per_line,
72 unsigned int *sse) {
73 uint16_t first_pass[36*16];
74 uint8_t second_pass[20*16];
75 const int16_t *HFilter, *VFilter;
76 unsigned int var;
77
78 if (xoffset == 4 && yoffset == 0) {
79 var = vpx_variance_halfpixvar16x16_h_media(src_ptr, src_pixels_per_line,
80 dst_ptr, dst_pixels_per_line,
81 sse);
82 } else if (xoffset == 0 && yoffset == 4) {
83 var = vpx_variance_halfpixvar16x16_v_media(src_ptr, src_pixels_per_line,
84 dst_ptr, dst_pixels_per_line,
85 sse);
86 } else if (xoffset == 4 && yoffset == 4) {
87 var = vpx_variance_halfpixvar16x16_hv_media(src_ptr, src_pixels_per_line,
88 dst_ptr, dst_pixels_per_line,
89 sse);
90 } else {
91 HFilter = bilinear_filters_media[xoffset];
92 VFilter = bilinear_filters_media[yoffset];
93
94 vpx_filter_block2d_bil_first_pass_media(src_ptr, first_pass,
95 src_pixels_per_line,
96 17, 16, HFilter);
97 vpx_filter_block2d_bil_second_pass_media(first_pass, second_pass,
98 16, 16, 16, VFilter);
99
100 var = vpx_variance16x16_media(second_pass, 16, dst_ptr,
101 dst_pixels_per_line, sse);
102 }
103 return var;
104 }
105 #endif // HAVE_MEDIA
106