Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / vp9 / common / vp9_convolve.c
1 /*
2  *  Copyright (c) 2013 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 <assert.h>
12
13 #include "./vpx_config.h"
14 #include "./vp9_rtcd.h"
15 #include "vp9/common/vp9_common.h"
16 #include "vp9/common/vp9_convolve.h"
17 #include "vp9/common/vp9_filter.h"
18 #include "vpx/vpx_integer.h"
19 #include "vpx_ports/mem.h"
20
21 static void convolve_horiz(const uint8_t *src, ptrdiff_t src_stride,
22                            uint8_t *dst, ptrdiff_t dst_stride,
23                            const InterpKernel *x_filters,
24                            int x0_q4, int x_step_q4, int w, int h) {
25   int x, y;
26   src -= SUBPEL_TAPS / 2 - 1;
27   for (y = 0; y < h; ++y) {
28     int x_q4 = x0_q4;
29     for (x = 0; x < w; ++x) {
30       const uint8_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
31       const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
32       int k, sum = 0;
33       for (k = 0; k < SUBPEL_TAPS; ++k)
34         sum += src_x[k] * x_filter[k];
35       dst[x] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
36       x_q4 += x_step_q4;
37     }
38     src += src_stride;
39     dst += dst_stride;
40   }
41 }
42
43 static void convolve_avg_horiz(const uint8_t *src, ptrdiff_t src_stride,
44                                uint8_t *dst, ptrdiff_t dst_stride,
45                                const InterpKernel *x_filters,
46                                int x0_q4, int x_step_q4, int w, int h) {
47   int x, y;
48   src -= SUBPEL_TAPS / 2 - 1;
49   for (y = 0; y < h; ++y) {
50     int x_q4 = x0_q4;
51     for (x = 0; x < w; ++x) {
52       const uint8_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
53       const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
54       int k, sum = 0;
55       for (k = 0; k < SUBPEL_TAPS; ++k)
56         sum += src_x[k] * x_filter[k];
57       dst[x] = ROUND_POWER_OF_TWO(dst[x] +
58           clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)), 1);
59       x_q4 += x_step_q4;
60     }
61     src += src_stride;
62     dst += dst_stride;
63   }
64 }
65
66 static void convolve_vert(const uint8_t *src, ptrdiff_t src_stride,
67                           uint8_t *dst, ptrdiff_t dst_stride,
68                           const InterpKernel *y_filters,
69                           int y0_q4, int y_step_q4, int w, int h) {
70   int x, y;
71   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
72
73   for (x = 0; x < w; ++x) {
74     int y_q4 = y0_q4;
75     for (y = 0; y < h; ++y) {
76       const unsigned char *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
77       const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
78       int k, sum = 0;
79       for (k = 0; k < SUBPEL_TAPS; ++k)
80         sum += src_y[k * src_stride] * y_filter[k];
81       dst[y * dst_stride] = clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS));
82       y_q4 += y_step_q4;
83     }
84     ++src;
85     ++dst;
86   }
87 }
88
89 static void convolve_avg_vert(const uint8_t *src, ptrdiff_t src_stride,
90                               uint8_t *dst, ptrdiff_t dst_stride,
91                               const InterpKernel *y_filters,
92                               int y0_q4, int y_step_q4, int w, int h) {
93   int x, y;
94   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
95
96   for (x = 0; x < w; ++x) {
97     int y_q4 = y0_q4;
98     for (y = 0; y < h; ++y) {
99       const unsigned char *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
100       const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
101       int k, sum = 0;
102       for (k = 0; k < SUBPEL_TAPS; ++k)
103         sum += src_y[k * src_stride] * y_filter[k];
104       dst[y * dst_stride] = ROUND_POWER_OF_TWO(dst[y * dst_stride] +
105           clip_pixel(ROUND_POWER_OF_TWO(sum, FILTER_BITS)), 1);
106       y_q4 += y_step_q4;
107     }
108     ++src;
109     ++dst;
110   }
111 }
112
113 static void convolve(const uint8_t *src, ptrdiff_t src_stride,
114                      uint8_t *dst, ptrdiff_t dst_stride,
115                      const InterpKernel *const x_filters,
116                      int x0_q4, int x_step_q4,
117                      const InterpKernel *const y_filters,
118                      int y0_q4, int y_step_q4,
119                      int w, int h) {
120   // Note: Fixed size intermediate buffer, temp, places limits on parameters.
121   // 2d filtering proceeds in 2 steps:
122   //   (1) Interpolate horizontally into an intermediate buffer, temp.
123   //   (2) Interpolate temp vertically to derive the sub-pixel result.
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];
133   int intermediate_height =
134           (((h - 1) * y_step_q4 + y0_q4) >> SUBPEL_BITS) + SUBPEL_TAPS;
135
136   assert(w <= 64);
137   assert(h <= 64);
138   assert(y_step_q4 <= 32);
139   assert(x_step_q4 <= 32);
140
141   convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1), src_stride, temp, 64,
142                  x_filters, x0_q4, x_step_q4, w, intermediate_height);
143   convolve_vert(temp + 64 * (SUBPEL_TAPS / 2 - 1), 64, dst, dst_stride,
144                 y_filters, y0_q4, y_step_q4, w, h);
145 }
146
147 static const InterpKernel *get_filter_base(const int16_t *filter) {
148   // NOTE: This assumes that the filter table is 256-byte aligned.
149   // TODO(agrange) Modify to make independent of table alignment.
150   return (const InterpKernel *)(((intptr_t)filter) & ~((intptr_t)0xFF));
151 }
152
153 static int get_filter_offset(const int16_t *f, const InterpKernel *base) {
154   return (int)((const InterpKernel *)(intptr_t)f - base);
155 }
156
157 void vp9_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
158                            uint8_t *dst, ptrdiff_t dst_stride,
159                            const int16_t *filter_x, int x_step_q4,
160                            const int16_t *filter_y, int y_step_q4,
161                            int w, int h) {
162   const InterpKernel *const filters_x = get_filter_base(filter_x);
163   const int x0_q4 = get_filter_offset(filter_x, filters_x);
164
165   (void)filter_y;
166   (void)y_step_q4;
167
168   convolve_horiz(src, src_stride, dst, dst_stride, filters_x,
169                  x0_q4, x_step_q4, w, h);
170 }
171
172 void vp9_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
173                                uint8_t *dst, ptrdiff_t dst_stride,
174                                const int16_t *filter_x, int x_step_q4,
175                                const int16_t *filter_y, int y_step_q4,
176                                int w, int h) {
177   const InterpKernel *const filters_x = get_filter_base(filter_x);
178   const int x0_q4 = get_filter_offset(filter_x, filters_x);
179
180   (void)filter_y;
181   (void)y_step_q4;
182
183   convolve_avg_horiz(src, src_stride, dst, dst_stride, filters_x,
184                      x0_q4, x_step_q4, w, h);
185 }
186
187 void vp9_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride,
188                           uint8_t *dst, ptrdiff_t dst_stride,
189                           const int16_t *filter_x, int x_step_q4,
190                           const int16_t *filter_y, int y_step_q4,
191                           int w, int h) {
192   const InterpKernel *const filters_y = get_filter_base(filter_y);
193   const int y0_q4 = get_filter_offset(filter_y, filters_y);
194
195   (void)filter_x;
196   (void)x_step_q4;
197
198   convolve_vert(src, src_stride, dst, dst_stride, filters_y,
199                 y0_q4, y_step_q4, w, h);
200 }
201
202 void vp9_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride,
203                               uint8_t *dst, ptrdiff_t dst_stride,
204                               const int16_t *filter_x, int x_step_q4,
205                               const int16_t *filter_y, int y_step_q4,
206                               int w, int h) {
207   const InterpKernel *const filters_y = get_filter_base(filter_y);
208   const int y0_q4 = get_filter_offset(filter_y, filters_y);
209
210   (void)filter_x;
211   (void)x_step_q4;
212
213   convolve_avg_vert(src, src_stride, dst, dst_stride, filters_y,
214                     y0_q4, y_step_q4, w, h);
215 }
216
217 void vp9_convolve8_c(const uint8_t *src, ptrdiff_t src_stride,
218                      uint8_t *dst, ptrdiff_t dst_stride,
219                      const int16_t *filter_x, int x_step_q4,
220                      const int16_t *filter_y, int y_step_q4,
221                      int w, int h) {
222   const InterpKernel *const filters_x = get_filter_base(filter_x);
223   const int x0_q4 = get_filter_offset(filter_x, filters_x);
224
225   const InterpKernel *const filters_y = get_filter_base(filter_y);
226   const int y0_q4 = get_filter_offset(filter_y, filters_y);
227
228   convolve(src, src_stride, dst, dst_stride,
229            filters_x, x0_q4, x_step_q4,
230            filters_y, y0_q4, y_step_q4, w, h);
231 }
232
233 void vp9_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride,
234                          uint8_t *dst, ptrdiff_t dst_stride,
235                          const int16_t *filter_x, int x_step_q4,
236                          const int16_t *filter_y, int y_step_q4,
237                          int w, int h) {
238   /* Fixed size intermediate buffer places limits on parameters. */
239   DECLARE_ALIGNED_ARRAY(16, uint8_t, temp, 64 * 64);
240   assert(w <= 64);
241   assert(h <= 64);
242
243   vp9_convolve8_c(src, src_stride, temp, 64,
244                   filter_x, x_step_q4, filter_y, y_step_q4, w, h);
245   vp9_convolve_avg_c(temp, 64, dst, dst_stride, NULL, 0, NULL, 0, w, h);
246 }
247
248 void vp9_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride,
249                          uint8_t *dst, ptrdiff_t dst_stride,
250                          const int16_t *filter_x, int filter_x_stride,
251                          const int16_t *filter_y, int filter_y_stride,
252                          int w, int h) {
253   int r;
254
255   (void)filter_x;  (void)filter_x_stride;
256   (void)filter_y;  (void)filter_y_stride;
257
258   for (r = h; r > 0; --r) {
259     vpx_memcpy(dst, src, w);
260     src += src_stride;
261     dst += dst_stride;
262   }
263 }
264
265 void vp9_convolve_avg_c(const uint8_t *src, ptrdiff_t src_stride,
266                         uint8_t *dst, ptrdiff_t dst_stride,
267                         const int16_t *filter_x, int filter_x_stride,
268                         const int16_t *filter_y, int filter_y_stride,
269                         int w, int h) {
270   int x, y;
271
272   (void)filter_x;  (void)filter_x_stride;
273   (void)filter_y;  (void)filter_y_stride;
274
275   for (y = 0; y < h; ++y) {
276     for (x = 0; x < w; ++x)
277       dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1);
278
279     src += src_stride;
280     dst += dst_stride;
281   }
282 }
283
284 #if CONFIG_VP9_HIGHBITDEPTH
285 static void highbd_convolve_horiz(const uint8_t *src8, ptrdiff_t src_stride,
286                                   uint8_t *dst8, ptrdiff_t dst_stride,
287                                   const InterpKernel *x_filters,
288                                   int x0_q4, int x_step_q4,
289                                   int w, int h, int bd) {
290   int x, y;
291   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
292   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
293   src -= SUBPEL_TAPS / 2 - 1;
294   for (y = 0; y < h; ++y) {
295     int x_q4 = x0_q4;
296     for (x = 0; x < w; ++x) {
297       const uint16_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
298       const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
299       int k, sum = 0;
300       for (k = 0; k < SUBPEL_TAPS; ++k)
301         sum += src_x[k] * x_filter[k];
302       dst[x] = clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
303       x_q4 += x_step_q4;
304     }
305     src += src_stride;
306     dst += dst_stride;
307   }
308 }
309
310 static void highbd_convolve_avg_horiz(const uint8_t *src8, ptrdiff_t src_stride,
311                                       uint8_t *dst8, ptrdiff_t dst_stride,
312                                       const InterpKernel *x_filters,
313                                       int x0_q4, int x_step_q4,
314                                       int w, int h, int bd) {
315   int x, y;
316   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
317   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
318   src -= SUBPEL_TAPS / 2 - 1;
319   for (y = 0; y < h; ++y) {
320     int x_q4 = x0_q4;
321     for (x = 0; x < w; ++x) {
322       const uint16_t *const src_x = &src[x_q4 >> SUBPEL_BITS];
323       const int16_t *const x_filter = x_filters[x_q4 & SUBPEL_MASK];
324       int k, sum = 0;
325       for (k = 0; k < SUBPEL_TAPS; ++k)
326         sum += src_x[k] * x_filter[k];
327       dst[x] = ROUND_POWER_OF_TWO(dst[x] +
328           clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd), 1);
329       x_q4 += x_step_q4;
330     }
331     src += src_stride;
332     dst += dst_stride;
333   }
334 }
335
336 static void highbd_convolve_vert(const uint8_t *src8, ptrdiff_t src_stride,
337                                  uint8_t *dst8, ptrdiff_t dst_stride,
338                                  const InterpKernel *y_filters,
339                                  int y0_q4, int y_step_q4, int w, int h,
340                                  int bd) {
341   int x, y;
342   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
343   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
344   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
345   for (x = 0; x < w; ++x) {
346     int y_q4 = y0_q4;
347     for (y = 0; y < h; ++y) {
348       const uint16_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
349       const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
350       int k, sum = 0;
351       for (k = 0; k < SUBPEL_TAPS; ++k)
352         sum += src_y[k * src_stride] * y_filter[k];
353       dst[y * dst_stride] = clip_pixel_highbd(
354           ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd);
355       y_q4 += y_step_q4;
356     }
357     ++src;
358     ++dst;
359   }
360 }
361
362 static void highbd_convolve_avg_vert(const uint8_t *src8, ptrdiff_t src_stride,
363                                      uint8_t *dst8, ptrdiff_t dst_stride,
364                                      const InterpKernel *y_filters,
365                                      int y0_q4, int y_step_q4, int w, int h,
366                                      int bd) {
367   int x, y;
368   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
369   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
370   src -= src_stride * (SUBPEL_TAPS / 2 - 1);
371   for (x = 0; x < w; ++x) {
372     int y_q4 = y0_q4;
373     for (y = 0; y < h; ++y) {
374       const uint16_t *src_y = &src[(y_q4 >> SUBPEL_BITS) * src_stride];
375       const int16_t *const y_filter = y_filters[y_q4 & SUBPEL_MASK];
376       int k, sum = 0;
377       for (k = 0; k < SUBPEL_TAPS; ++k)
378         sum += src_y[k * src_stride] * y_filter[k];
379       dst[y * dst_stride] = ROUND_POWER_OF_TWO(dst[y * dst_stride] +
380           clip_pixel_highbd(ROUND_POWER_OF_TWO(sum, FILTER_BITS), bd), 1);
381       y_q4 += y_step_q4;
382     }
383     ++src;
384     ++dst;
385   }
386 }
387
388 static void highbd_convolve(const uint8_t *src, ptrdiff_t src_stride,
389                             uint8_t *dst, ptrdiff_t dst_stride,
390                             const InterpKernel *const x_filters,
391                             int x0_q4, int x_step_q4,
392                             const InterpKernel *const y_filters,
393                             int y0_q4, int y_step_q4,
394                             int w, int h, int bd) {
395   // Note: Fixed size intermediate buffer, temp, places limits on parameters.
396   // 2d filtering proceeds in 2 steps:
397   //   (1) Interpolate horizontally into an intermediate buffer, temp.
398   //   (2) Interpolate temp vertically to derive the sub-pixel result.
399   // Deriving the maximum number of rows in the temp buffer (135):
400   // --Smallest scaling factor is x1/2 ==> y_step_q4 = 32 (Normative).
401   // --Largest block size is 64x64 pixels.
402   // --64 rows in the downscaled frame span a distance of (64 - 1) * 32 in the
403   //   original frame (in 1/16th pixel units).
404   // --Must round-up because block may be located at sub-pixel position.
405   // --Require an additional SUBPEL_TAPS rows for the 8-tap filter tails.
406   // --((64 - 1) * 32 + 15) >> 4 + 8 = 135.
407   uint16_t temp[64 * 135];
408   int intermediate_height =
409           (((h - 1) * y_step_q4 + y0_q4) >> SUBPEL_BITS) + SUBPEL_TAPS;
410
411   assert(w <= 64);
412   assert(h <= 64);
413   assert(y_step_q4 <= 32);
414   assert(x_step_q4 <= 32);
415
416   highbd_convolve_horiz(src - src_stride * (SUBPEL_TAPS / 2 - 1),
417                         src_stride, CONVERT_TO_BYTEPTR(temp), 64,
418                         x_filters, x0_q4, x_step_q4, w,
419                         intermediate_height, bd);
420   highbd_convolve_vert(CONVERT_TO_BYTEPTR(temp) + 64 * (SUBPEL_TAPS / 2 - 1),
421                        64, dst, dst_stride, y_filters, y0_q4, y_step_q4,
422                        w, h, bd);
423 }
424
425
426 void vp9_highbd_convolve8_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
427                                   uint8_t *dst, ptrdiff_t dst_stride,
428                                   const int16_t *filter_x, int x_step_q4,
429                                   const int16_t *filter_y, int y_step_q4,
430                                   int w, int h, int bd) {
431   const InterpKernel *const filters_x = get_filter_base(filter_x);
432   const int x0_q4 = get_filter_offset(filter_x, filters_x);
433   (void)filter_y;
434   (void)y_step_q4;
435
436   highbd_convolve_horiz(src, src_stride, dst, dst_stride, filters_x,
437                         x0_q4, x_step_q4, w, h, bd);
438 }
439
440 void vp9_highbd_convolve8_avg_horiz_c(const uint8_t *src, ptrdiff_t src_stride,
441                                       uint8_t *dst, ptrdiff_t dst_stride,
442                                       const int16_t *filter_x, int x_step_q4,
443                                       const int16_t *filter_y, int y_step_q4,
444                                       int w, int h, int bd) {
445   const InterpKernel *const filters_x = get_filter_base(filter_x);
446   const int x0_q4 = get_filter_offset(filter_x, filters_x);
447   (void)filter_y;
448   (void)y_step_q4;
449
450   highbd_convolve_avg_horiz(src, src_stride, dst, dst_stride, filters_x,
451                             x0_q4, x_step_q4, w, h, bd);
452 }
453
454 void vp9_highbd_convolve8_vert_c(const uint8_t *src, ptrdiff_t src_stride,
455                                  uint8_t *dst, ptrdiff_t dst_stride,
456                                  const int16_t *filter_x, int x_step_q4,
457                                  const int16_t *filter_y, int y_step_q4,
458                                  int w, int h, int bd) {
459   const InterpKernel *const filters_y = get_filter_base(filter_y);
460   const int y0_q4 = get_filter_offset(filter_y, filters_y);
461   (void)filter_x;
462   (void)x_step_q4;
463
464   highbd_convolve_vert(src, src_stride, dst, dst_stride, filters_y,
465                        y0_q4, y_step_q4, w, h, bd);
466 }
467
468 void vp9_highbd_convolve8_avg_vert_c(const uint8_t *src, ptrdiff_t src_stride,
469                                      uint8_t *dst, ptrdiff_t dst_stride,
470                                      const int16_t *filter_x, int x_step_q4,
471                                      const int16_t *filter_y, int y_step_q4,
472                                      int w, int h, int bd) {
473   const InterpKernel *const filters_y = get_filter_base(filter_y);
474   const int y0_q4 = get_filter_offset(filter_y, filters_y);
475   (void)filter_x;
476   (void)x_step_q4;
477
478   highbd_convolve_avg_vert(src, src_stride, dst, dst_stride, filters_y,
479                            y0_q4, y_step_q4, w, h, bd);
480 }
481
482 void vp9_highbd_convolve8_c(const uint8_t *src, ptrdiff_t src_stride,
483                             uint8_t *dst, ptrdiff_t dst_stride,
484                             const int16_t *filter_x, int x_step_q4,
485                             const int16_t *filter_y, int y_step_q4,
486                             int w, int h, int bd) {
487   const InterpKernel *const filters_x = get_filter_base(filter_x);
488   const int x0_q4 = get_filter_offset(filter_x, filters_x);
489
490   const InterpKernel *const filters_y = get_filter_base(filter_y);
491   const int y0_q4 = get_filter_offset(filter_y, filters_y);
492
493   highbd_convolve(src, src_stride, dst, dst_stride,
494                   filters_x, x0_q4, x_step_q4,
495                   filters_y, y0_q4, y_step_q4, w, h, bd);
496 }
497
498 void vp9_highbd_convolve8_avg_c(const uint8_t *src, ptrdiff_t src_stride,
499                                 uint8_t *dst, ptrdiff_t dst_stride,
500                                 const int16_t *filter_x, int x_step_q4,
501                                 const int16_t *filter_y, int y_step_q4,
502                                 int w, int h, int bd) {
503   // Fixed size intermediate buffer places limits on parameters.
504   DECLARE_ALIGNED_ARRAY(16, uint16_t, temp, 64 * 64);
505   assert(w <= 64);
506   assert(h <= 64);
507
508   vp9_highbd_convolve8_c(src, src_stride, CONVERT_TO_BYTEPTR(temp), 64,
509                          filter_x, x_step_q4, filter_y, y_step_q4, w, h, bd);
510   vp9_highbd_convolve_avg_c(CONVERT_TO_BYTEPTR(temp), 64, dst, dst_stride,
511                             NULL, 0, NULL, 0, w, h, bd);
512 }
513
514 void vp9_highbd_convolve_copy_c(const uint8_t *src8, ptrdiff_t src_stride,
515                                 uint8_t *dst8, ptrdiff_t dst_stride,
516                                 const int16_t *filter_x, int filter_x_stride,
517                                 const int16_t *filter_y, int filter_y_stride,
518                                 int w, int h, int bd) {
519   int r;
520   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
521   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
522   (void)filter_x;
523   (void)filter_y;
524   (void)filter_x_stride;
525   (void)filter_y_stride;
526   (void)bd;
527
528   for (r = h; r > 0; --r) {
529     vpx_memcpy(dst, src, w * sizeof(uint16_t));
530     src += src_stride;
531     dst += dst_stride;
532   }
533 }
534
535 void vp9_highbd_convolve_avg_c(const uint8_t *src8, ptrdiff_t src_stride,
536                                uint8_t *dst8, ptrdiff_t dst_stride,
537                                const int16_t *filter_x, int filter_x_stride,
538                                const int16_t *filter_y, int filter_y_stride,
539                                int w, int h, int bd) {
540   int x, y;
541   uint16_t *src = CONVERT_TO_SHORTPTR(src8);
542   uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
543   (void)filter_x;
544   (void)filter_y;
545   (void)filter_x_stride;
546   (void)filter_y_stride;
547   (void)bd;
548
549   for (y = 0; y < h; ++y) {
550     for (x = 0; x < w; ++x) {
551       dst[x] = ROUND_POWER_OF_TWO(dst[x] + src[x], 1);
552     }
553     src += src_stride;
554     dst += dst_stride;
555   }
556 }
557 #endif