• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 #include <math.h>
13 #include "subpixel.h"
14 
15 #define BLOCK_HEIGHT_WIDTH 4
16 #define VP8_FILTER_WEIGHT 128
17 #define VP8_FILTER_SHIFT  7
18 
19 static const short bilinear_filters[8][2] =
20 {
21     { 128,   0 },
22     { 112,  16 },
23     {  96,  32 },
24     {  80,  48 },
25     {  64,  64 },
26     {  48,  80 },
27     {  32,  96 },
28     {  16, 112 }
29 };
30 
31 
32 extern void vp8_filter_block2d_bil_first_pass_armv6
33 (
34     unsigned char *src_ptr,
35     unsigned short *output_ptr,
36     unsigned int src_pixels_per_line,
37     unsigned int output_height,
38     unsigned int output_width,
39     const short *vp8_filter
40 );
41 
42 extern void vp8_filter_block2d_bil_second_pass_armv6
43 (
44     unsigned short *src_ptr,
45     unsigned char  *output_ptr,
46     int output_pitch,
47     unsigned int  output_height,
48     unsigned int  output_width,
49     const short *vp8_filter
50 );
51 
52 #if 0
53 void vp8_filter_block2d_bil_first_pass_6
54 (
55     unsigned char *src_ptr,
56     unsigned short *output_ptr,
57     unsigned int src_pixels_per_line,
58     unsigned int output_height,
59     unsigned int output_width,
60     const short *vp8_filter
61 )
62 {
63     unsigned int i, j;
64 
65     for ( i=0; i<output_height; i++ )
66     {
67         for ( j=0; j<output_width; j++ )
68         {
69             /* Apply bilinear filter */
70             output_ptr[j] = ( ( (int)src_ptr[0]          * vp8_filter[0]) +
71                                ((int)src_ptr[1] * vp8_filter[1]) +
72                                 (VP8_FILTER_WEIGHT/2) ) >> VP8_FILTER_SHIFT;
73             src_ptr++;
74         }
75 
76         /* Next row... */
77         src_ptr    += src_pixels_per_line - output_width;
78         output_ptr += output_width;
79     }
80 }
81 
82 void vp8_filter_block2d_bil_second_pass_6
83 (
84     unsigned short *src_ptr,
85     unsigned char  *output_ptr,
86     int output_pitch,
87     unsigned int  output_height,
88     unsigned int  output_width,
89     const short *vp8_filter
90 )
91 {
92     unsigned int  i,j;
93     int  Temp;
94 
95     for ( i=0; i<output_height; i++ )
96     {
97         for ( j=0; j<output_width; j++ )
98         {
99             /* Apply filter */
100             Temp =  ((int)src_ptr[0]         * vp8_filter[0]) +
101                     ((int)src_ptr[output_width] * vp8_filter[1]) +
102                     (VP8_FILTER_WEIGHT/2);
103             output_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
104             src_ptr++;
105         }
106 
107         /* Next row... */
108         /*src_ptr    += src_pixels_per_line - output_width;*/
109         output_ptr += output_pitch;
110     }
111 }
112 #endif
113 
vp8_filter_block2d_bil_armv6(unsigned char * src_ptr,unsigned char * output_ptr,unsigned int src_pixels_per_line,unsigned int dst_pitch,const short * HFilter,const short * VFilter,int Width,int Height)114 void vp8_filter_block2d_bil_armv6
115 (
116     unsigned char *src_ptr,
117     unsigned char *output_ptr,
118     unsigned int   src_pixels_per_line,
119     unsigned int   dst_pitch,
120     const short      *HFilter,
121     const short      *VFilter,
122     int            Width,
123     int            Height
124 )
125 {
126 
127     unsigned short FData[36*16]; /* Temp data bufffer used in filtering */
128 
129     /* First filter 1-D horizontally... */
130     /* pixel_step = 1; */
131     vp8_filter_block2d_bil_first_pass_armv6(src_ptr, FData, src_pixels_per_line, Height + 1, Width, HFilter);
132 
133     /* then 1-D vertically... */
134     vp8_filter_block2d_bil_second_pass_armv6(FData, output_ptr, dst_pitch, Height, Width, VFilter);
135 }
136 
137 
vp8_bilinear_predict4x4_armv6(unsigned char * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,unsigned char * dst_ptr,int dst_pitch)138 void vp8_bilinear_predict4x4_armv6
139 (
140     unsigned char  *src_ptr,
141     int   src_pixels_per_line,
142     int  xoffset,
143     int  yoffset,
144     unsigned char *dst_ptr,
145     int dst_pitch
146 )
147 {
148     const short  *HFilter;
149     const short  *VFilter;
150 
151     HFilter = bilinear_filters[xoffset];
152     VFilter = bilinear_filters[yoffset];
153 
154     vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
155 }
156 
vp8_bilinear_predict8x8_armv6(unsigned char * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,unsigned char * dst_ptr,int dst_pitch)157 void vp8_bilinear_predict8x8_armv6
158 (
159     unsigned char  *src_ptr,
160     int  src_pixels_per_line,
161     int  xoffset,
162     int  yoffset,
163     unsigned char *dst_ptr,
164     int  dst_pitch
165 )
166 {
167     const short  *HFilter;
168     const short  *VFilter;
169 
170     HFilter = bilinear_filters[xoffset];
171     VFilter = bilinear_filters[yoffset];
172 
173     vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
174 }
175 
vp8_bilinear_predict8x4_armv6(unsigned char * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,unsigned char * dst_ptr,int dst_pitch)176 void vp8_bilinear_predict8x4_armv6
177 (
178     unsigned char  *src_ptr,
179     int  src_pixels_per_line,
180     int  xoffset,
181     int  yoffset,
182     unsigned char *dst_ptr,
183     int  dst_pitch
184 )
185 {
186     const short  *HFilter;
187     const short  *VFilter;
188 
189     HFilter = bilinear_filters[xoffset];
190     VFilter = bilinear_filters[yoffset];
191 
192     vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
193 }
194 
vp8_bilinear_predict16x16_armv6(unsigned char * src_ptr,int src_pixels_per_line,int xoffset,int yoffset,unsigned char * dst_ptr,int dst_pitch)195 void vp8_bilinear_predict16x16_armv6
196 (
197     unsigned char  *src_ptr,
198     int  src_pixels_per_line,
199     int  xoffset,
200     int  yoffset,
201     unsigned char *dst_ptr,
202     int  dst_pitch
203 )
204 {
205     const short  *HFilter;
206     const short  *VFilter;
207 
208     HFilter = bilinear_filters[xoffset];
209     VFilter = bilinear_filters[yoffset];
210 
211     vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
212 }
213