subpel_variance_media.c 3.37 KB
Newer Older
Johann's avatar
Johann committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Johann's avatar
Johann committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Johann's avatar
Johann committed
10 11
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13 14
#include "./aom_config.h"
#include "./aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
15
#include "aom_ports/mem.h"
Johann's avatar
Johann committed
16 17

#if HAVE_MEDIA
clang-format's avatar
clang-format committed
18 19 20 21
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
22

Yaowu Xu's avatar
Yaowu Xu committed
23
extern void aom_filter_block2d_bil_first_pass_media(
clang-format's avatar
clang-format committed
24 25
    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
26

Yaowu Xu's avatar
Yaowu Xu committed
27
extern void aom_filter_block2d_bil_second_pass_media(
clang-format's avatar
clang-format committed
28 29
    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
30

Yaowu Xu's avatar
Yaowu Xu committed
31
unsigned int aom_sub_pixel_variance8x8_media(
clang-format's avatar
clang-format committed
32 33 34 35
    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
36 37 38 39 40
  const int16_t *HFilter, *VFilter;

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

Yaowu Xu's avatar
Yaowu Xu committed
41
  aom_filter_block2d_bil_first_pass_media(src_ptr, first_pass,
clang-format's avatar
clang-format committed
42
                                          src_pixels_per_line, 9, 8, HFilter);
Yaowu Xu's avatar
Yaowu Xu committed
43
  aom_filter_block2d_bil_second_pass_media(first_pass, second_pass, 8, 8, 8,
clang-format's avatar
clang-format committed
44
                                           VFilter);
Johann's avatar
Johann committed
45

Yaowu Xu's avatar
Yaowu Xu committed
46
  return aom_variance8x8_media(second_pass, 8, dst_ptr, dst_pixels_per_line,
clang-format's avatar
clang-format committed
47
                               sse);
Johann's avatar
Johann committed
48 49
}

Yaowu Xu's avatar
Yaowu Xu committed
50
unsigned int aom_sub_pixel_variance16x16_media(
clang-format's avatar
clang-format committed
51 52 53 54
    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
55 56 57 58
  const int16_t *HFilter, *VFilter;
  unsigned int var;

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

Yaowu Xu's avatar
Yaowu Xu committed
71
    aom_filter_block2d_bil_first_pass_media(
clang-format's avatar
clang-format committed
72
        src_ptr, first_pass, src_pixels_per_line, 17, 16, HFilter);
Yaowu Xu's avatar
Yaowu Xu committed
73
    aom_filter_block2d_bil_second_pass_media(first_pass, second_pass, 16, 16,
clang-format's avatar
clang-format committed
74
                                             16, VFilter);
Johann's avatar
Johann committed
75

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