subpel_variance_media.c 3.26 KB
Newer Older
Johann's avatar
Johann committed
1 2 3 4 5 6 7 8 9 10 11 12
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
13 14
#include "aom/vpx_integer.h"
#include "aom_ports/mem.h"
Johann's avatar
Johann committed
15 16

#if HAVE_MEDIA
clang-format's avatar
clang-format committed
17 18 19 20
static const int16_t bilinear_filters_media[8][2] = { { 128, 0 }, { 112, 16 },
                                                      { 96, 32 }, { 80, 48 },
                                                      { 64, 64 }, { 48, 80 },
                                                      { 32, 96 }, { 16, 112 } };
Johann's avatar
Johann committed
21

clang-format's avatar
clang-format committed
22 23 24
extern void vpx_filter_block2d_bil_first_pass_media(
    const uint8_t *src_ptr, uint16_t *dst_ptr, uint32_t src_pitch,
    uint32_t height, uint32_t width, const int16_t *filter);
Johann's avatar
Johann committed
25

clang-format's avatar
clang-format committed
26 27 28
extern void vpx_filter_block2d_bil_second_pass_media(
    const uint16_t *src_ptr, uint8_t *dst_ptr, int32_t src_pitch,
    uint32_t height, uint32_t width, const int16_t *filter);
Johann's avatar
Johann committed
29

clang-format's avatar
clang-format committed
30 31 32 33 34
unsigned int 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) {
  uint16_t first_pass[10 * 8];
  uint8_t second_pass[8 * 8];
Johann's avatar
Johann committed
35 36 37 38 39 40
  const int16_t *HFilter, *VFilter;

  HFilter = bilinear_filters_media[xoffset];
  VFilter = bilinear_filters_media[yoffset];

  vpx_filter_block2d_bil_first_pass_media(src_ptr, first_pass,
clang-format's avatar
clang-format committed
41 42 43
                                          src_pixels_per_line, 9, 8, HFilter);
  vpx_filter_block2d_bil_second_pass_media(first_pass, second_pass, 8, 8, 8,
                                           VFilter);
Johann's avatar
Johann committed
44

clang-format's avatar
clang-format committed
45 46
  return vpx_variance8x8_media(second_pass, 8, dst_ptr, dst_pixels_per_line,
                               sse);
Johann's avatar
Johann committed
47 48
}

clang-format's avatar
clang-format committed
49 50 51 52 53
unsigned int 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) {
  uint16_t first_pass[36 * 16];
  uint8_t second_pass[20 * 16];
Johann's avatar
Johann committed
54 55 56 57
  const int16_t *HFilter, *VFilter;
  unsigned int var;

  if (xoffset == 4 && yoffset == 0) {
clang-format's avatar
clang-format committed
58 59
    var = vpx_variance_halfpixvar16x16_h_media(
        src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
Johann's avatar
Johann committed
60
  } else if (xoffset == 0 && yoffset == 4) {
clang-format's avatar
clang-format committed
61 62
    var = vpx_variance_halfpixvar16x16_v_media(
        src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
Johann's avatar
Johann committed
63
  } else if (xoffset == 4 && yoffset == 4) {
clang-format's avatar
clang-format committed
64 65
    var = vpx_variance_halfpixvar16x16_hv_media(
        src_ptr, src_pixels_per_line, dst_ptr, dst_pixels_per_line, sse);
Johann's avatar
Johann committed
66 67 68 69
  } else {
    HFilter = bilinear_filters_media[xoffset];
    VFilter = bilinear_filters_media[yoffset];

clang-format's avatar
clang-format committed
70 71 72 73
    vpx_filter_block2d_bil_first_pass_media(
        src_ptr, first_pass, src_pixels_per_line, 17, 16, HFilter);
    vpx_filter_block2d_bil_second_pass_media(first_pass, second_pass, 16, 16,
                                             16, VFilter);
Johann's avatar
Johann committed
74

clang-format's avatar
clang-format committed
75 76
    var = vpx_variance16x16_media(second_pass, 16, dst_ptr, dst_pixels_per_line,
                                  sse);
Johann's avatar
Johann committed
77 78 79 80
  }
  return var;
}
#endif  // HAVE_MEDIA