OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 static void convolve(const uint8_t *src, ptrdiff_t src_stride, | 113 static void convolve(const uint8_t *src, ptrdiff_t src_stride, |
114 uint8_t *dst, ptrdiff_t dst_stride, | 114 uint8_t *dst, ptrdiff_t dst_stride, |
115 const InterpKernel *const x_filters, | 115 const InterpKernel *const x_filters, |
116 int x0_q4, int x_step_q4, | 116 int x0_q4, int x_step_q4, |
117 const InterpKernel *const y_filters, | 117 const InterpKernel *const y_filters, |
118 int y0_q4, int y_step_q4, | 118 int y0_q4, int y_step_q4, |
119 int w, int h) { | 119 int w, int h) { |
120 // Fixed size intermediate buffer places limits on parameters. | 120 // Note: Fixed size intermediate buffer, temp, places limits on parameters. |
121 // Maximum intermediate_height is 324, for y_step_q4 == 80, | 121 // 2d filtering proceeds in 2 steps: |
122 // h == 64, taps == 8. | 122 // (1) Interpolate horizontally into an intermediate buffer, temp. |
123 // y_step_q4 of 80 allows for 1/10 scale for 5 layer svc | 123 // (2) Interpolate temp vertically to derive the sub-pixel result. |
124 uint8_t temp[64 * 324]; | 124 // Deriving the maximum number of rows in the temp buffer (135): |
| 125 // --Smallest scaling factor is x1/2 ==> y_step_q4 = 32 (Normative). |
| 126 // --Largest block size is 64x64 pixels. |
| 127 // --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the |
| 128 // original frame (in 1/16th pixel units). |
| 129 // --Must round-up because block may be located at sub-pixel position. |
| 130 // --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails. |
| 131 // --((64 - 1) * 32 + 15) >> 4 + 8 = 135. |
| 132 uint8_t temp[135 * 64]; |
125 int intermediate_height = (((h - 1) * y_step_q4 + 15) >> 4) + SUBPEL_TAPS; | 133 int intermediate_height = (((h - 1) * y_step_q4 + 15) >> 4) + SUBPEL_TAPS; |
126 | 134 |
127 assert(w <= 64); | 135 assert(w <= 64); |
128 assert(h <= 64); | 136 assert(h <= 64); |
129 assert(y_step_q4 <= 80); | 137 assert(y_step_q4 <= 32); |
130 assert(x_step_q4 <= 80); | 138 assert(x_step_q4 <= 32); |
131 | 139 |
132 if (intermediate_height < h) | 140 if (intermediate_height < h) |
133 intermediate_height = h; | 141 intermediate_height = h; |
134 | 142 |
135 convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride, temp, 64, | 143 convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride, temp, 64, |
136 x_filters, x0_q4, x_step_q4, w, intermediate_height); | 144 x_filters, x0_q4, x_step_q4, w, intermediate_height); |
137 convolve_vert(temp + 64 * (SUBPEL_TAPS / 2 - 1), 64, dst, dst_stride, | 145 convolve_vert(temp + 64 * (SUBPEL_TAPS / 2 - 1), 64, dst, dst_stride, |
138 y_filters, y0_q4, y_step_q4, w, h); | 146 y_filters, y0_q4, y_step_q4, w, h); |
139 } | 147 } |
140 | 148 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 (void)filter_y; (void)filter_y_stride; | 275 (void)filter_y; (void)filter_y_stride; |
268 | 276 |
269 for (y = 0; y < h; ++y) { | 277 for (y = 0; y < h; ++y) { |
270 for (x = 0; x < w; ++x) | 278 for (x = 0; x < w; ++x) |
271 dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1); | 279 dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1); |
272 | 280 |
273 src += src_stride; | 281 src += src_stride; |
274 dst += dst_stride; | 282 dst += dst_stride; |
275 } | 283 } |
276 } | 284 } |
OLD | NEW |