blob: d772df8873b8101656b338c128035b086ed5a062 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AV1_COMMON_WARPED_MOTION_H_
13#define AOM_AV1_COMMON_WARPED_MOTION_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <stdio.h>
16#include <stdlib.h>
17#include <memory.h>
18#include <math.h>
19#include <assert.h>
20
Tom Finegan60e653d2018-05-22 11:34:58 -070021#include "config/aom_config.h"
22
Yaowu Xuc27fc142016-08-22 16:08:15 -070023#include "aom_ports/mem.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070024#include "aom_dsp/aom_dsp_common.h"
Sarah Parkere5299862016-08-16 14:57:37 -070025#include "av1/common/mv.h"
Angie Chiang81b2e502017-06-19 15:13:52 -070026#include "av1/common/convolve.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070027
Debargha Mukherjee8c410242017-04-11 15:20:56 -070028#define LEAST_SQUARES_SAMPLES_MAX_BITS 3
29#define LEAST_SQUARES_SAMPLES_MAX (1 << LEAST_SQUARES_SAMPLES_MAX_BITS)
Yue Chend28bdba2017-06-16 10:38:03 -070030#define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2)
Yunqing Wangd3c13e82018-01-02 17:52:56 -080031#define WARPED_MOTION_DEBUG 0
Debargha Mukherjeee6eb3b52017-02-26 08:50:56 -080032#define DEFAULT_WMTYPE AFFINE
Sarah Parker36b997b2019-05-09 16:06:53 -070033#define WARP_ERROR_BLOCK_LOG 5
34#define WARP_ERROR_BLOCK (1 << WARP_ERROR_BLOCK_LOG)
Yue Chen1ab57802016-09-27 17:48:38 -070035
Yaowu Xu3a19b8a2019-05-01 08:40:42 -070036extern const int16_t av1_warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8];
David Barkerd5dfa962017-01-10 15:06:08 +000037
Aniket Dhoka80c64e2019-04-25 09:29:28 +053038DECLARE_ALIGNED(8, extern const int8_t,
Yaowu Xu2c619702019-05-03 08:55:45 -070039 av1_filter_8bit[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8]);
Aniket Dhoka80c64e2019-04-25 09:29:28 +053040
Ravi Chaudhary8ff220c2018-05-09 16:42:19 +053041static const uint8_t warp_pad_left[14][16] = {
42 { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
43 { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
44 { 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
45 { 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
46 { 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
47 { 6, 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
48 { 7, 7, 7, 7, 7, 7, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
49 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 15 },
50 { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 11, 12, 13, 14, 15 },
51 { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14, 15 },
52 { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 13, 14, 15 },
53 { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 14, 15 },
54 { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 15 },
55 { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15 },
56};
57
58static const uint8_t warp_pad_right[14][16] = {
59 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14 },
60 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13 },
61 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 12, 12 },
62 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11, 11 },
63 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10 },
64 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9 },
65 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8 },
66 { 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7 },
67 { 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
68 { 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
69 { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
70 { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
71 { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
72 { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
73};
74
Remya3eb3fe72019-08-30 11:35:04 +053075void highbd_warp_plane(WarpedMotionParams *wm, const uint16_t *const ref,
76 int width, int height, int stride, uint16_t *const pred,
77 int p_col, int p_row, int p_width, int p_height,
78 int p_stride, int subsampling_x, int subsampling_y,
79 int bd, ConvolveParams *conv_params);
80
81void warp_plane(WarpedMotionParams *wm, const uint8_t *const ref, int width,
82 int height, int stride, uint8_t *pred, int p_col, int p_row,
83 int p_width, int p_height, int p_stride, int subsampling_x,
84 int subsampling_y, ConvolveParams *conv_params);
85
Yaowu Xud3e7c682017-12-21 14:08:25 -080086void av1_warp_plane(WarpedMotionParams *wm, int use_hbd, int bd,
Yaowu Xucd0f6c42017-05-05 11:18:22 -070087 const uint8_t *ref, int width, int height, int stride,
Yaowu Xuf883b422016-08-30 14:01:10 -070088 uint8_t *pred, int p_col, int p_row, int p_width,
89 int p_height, int p_stride, int subsampling_x,
Frederic Barbierc33aec52017-11-13 10:14:25 +010090 int subsampling_y, ConvolveParams *conv_params);
Yaowu Xuc27fc142016-08-22 16:08:15 -070091
chiyotsai74da72b2020-04-07 13:45:40 -070092int av1_find_projection(int np, const int *pts1, const int *pts2,
93 BLOCK_SIZE bsize, int mvy, int mvx,
94 WarpedMotionParams *wm_params, int mi_row, int mi_col);
Debargha Mukherjee11f0e402017-03-29 07:42:40 -070095
Yaowu Xu3a19b8a2019-05-01 08:40:42 -070096int av1_get_shear_params(WarpedMotionParams *wm);
James Zerne1cbb132018-08-22 14:10:36 -070097#endif // AOM_AV1_COMMON_WARPED_MOTION_H_