Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: source/libvpx/vp9/common/vp9_subpelvar.h

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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 "vp9/common/vp9_filter.h"
13
14
15
16 static void variance(const unsigned char *src_ptr,
17 int source_stride,
18 const unsigned char *ref_ptr,
19 int recon_stride,
20 int w,
21 int h,
22 unsigned int *sse,
23 int *sum) {
24 int i, j;
25 int diff;
26
27 *sum = 0;
28 *sse = 0;
29
30 for (i = 0; i < h; i++) {
31 for (j = 0; j < w; j++) {
32 diff = src_ptr[j] - ref_ptr[j];
33 *sum += diff;
34 *sse += diff * diff;
35 }
36
37 src_ptr += source_stride;
38 ref_ptr += recon_stride;
39 }
40 }
41
42 /****************************************************************************
43 *
44 * ROUTINE : filter_block2d_bil_first_pass
45 *
46 * INPUTS : UINT8 *src_ptr : Pointer to source block.
47 * UINT32 src_pixels_per_line : Stride of input block.
48 * UINT32 pixel_step : Offset between filter input sampl es (see notes).
49 * UINT32 output_height : Input block height.
50 * UINT32 output_width : Input block width.
51 * INT32 *vp9_filter : Array of 2 bi-linear filter ta ps.
52 *
53 * OUTPUTS : INT32 *output_ptr : Pointer to filtered block.
54 *
55 * RETURNS : void
56 *
57 * FUNCTION : Applies a 1-D 2-tap bi-linear filter to the source block in
58 * either horizontal or vertical direction to produce the
59 * filtered output block. Used to implement first-pass
60 * of 2-D separable filter.
61 *
62 * SPECIAL NOTES : Produces INT32 output to retain precision for next pass.
63 * Two filter taps should sum to VP9_FILTER_WEIGHT.
64 * pixel_step defines whether the filter is applied
65 * horizontally (pixel_step=1) or vertically (pixel_step=stride ).
66 * It defines the offset required to move from one input
67 * to the next.
68 *
69 ****************************************************************************/
70 static void var_filter_block2d_bil_first_pass(const unsigned char *src_ptr,
71 unsigned short *output_ptr,
72 unsigned int src_pixels_per_line,
73 int pixel_step,
74 unsigned int output_height,
75 unsigned int output_width,
76 const short *vp9_filter) {
77 unsigned int i, j;
78
79 for (i = 0; i < output_height; i++) {
80 for (j = 0; j < output_width; j++) {
81 // Apply bilinear filter
82 output_ptr[j] = (((int)src_ptr[0] * vp9_filter[0]) +
83 ((int)src_ptr[pixel_step] * vp9_filter[1]) +
84 (VP9_FILTER_WEIGHT / 2)) >> VP9_FILTER_SHIFT;
85 src_ptr++;
86 }
87
88 // Next row...
89 src_ptr += src_pixels_per_line - output_width;
90 output_ptr += output_width;
91 }
92 }
93
94 /****************************************************************************
95 *
96 * ROUTINE : filter_block2d_bil_second_pass
97 *
98 * INPUTS : INT32 *src_ptr : Pointer to source block.
99 * UINT32 src_pixels_per_line : Stride of input block.
100 * UINT32 pixel_step : Offset between filter input sampl es (see notes).
101 * UINT32 output_height : Input block height.
102 * UINT32 output_width : Input block width.
103 * INT32 *vp9_filter : Array of 2 bi-linear filter ta ps.
104 *
105 * OUTPUTS : UINT16 *output_ptr : Pointer to filtered block.
106 *
107 * RETURNS : void
108 *
109 * FUNCTION : Applies a 1-D 2-tap bi-linear filter to the source block in
110 * either horizontal or vertical direction to produce the
111 * filtered output block. Used to implement second-pass
112 * of 2-D separable filter.
113 *
114 * SPECIAL NOTES : Requires 32-bit input as produced by filter_block2d_bil_firs t_pass.
115 * Two filter taps should sum to VP9_FILTER_WEIGHT.
116 * pixel_step defines whether the filter is applied
117 * horizontally (pixel_step=1) or vertically (pixel_step=stride ).
118 * It defines the offset required to move from one input
119 * to the next.
120 *
121 ****************************************************************************/
122 static void var_filter_block2d_bil_second_pass(const unsigned short *src_ptr,
123 unsigned char *output_ptr,
124 unsigned int src_pixels_per_line,
125 unsigned int pixel_step,
126 unsigned int output_height,
127 unsigned int output_width,
128 const short *vp9_filter) {
129 unsigned int i, j;
130 int Temp;
131
132 for (i = 0; i < output_height; i++) {
133 for (j = 0; j < output_width; j++) {
134 // Apply filter
135 Temp = ((int)src_ptr[0] * vp9_filter[0]) +
136 ((int)src_ptr[pixel_step] * vp9_filter[1]) +
137 (VP9_FILTER_WEIGHT / 2);
138 output_ptr[j] = (unsigned int)(Temp >> VP9_FILTER_SHIFT);
139 src_ptr++;
140 }
141
142 // Next row...
143 src_ptr += src_pixels_per_line - output_width;
144 output_ptr += output_width;
145 }
146 }
147
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698