Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 4 | * 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_COMMON_WARPED_MOTION_H_ |
| 13 | #define AOM_AV1_COMMON_WARPED_MOTION_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
| 17 | #include <memory.h> |
| 18 | #include <math.h> |
| 19 | #include <assert.h> |
| 20 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 21 | #include "config/aom_config.h" |
| 22 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | #include "aom_ports/mem.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 24 | #include "aom_dsp/aom_dsp_common.h" |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 25 | #include "av1/common/mv.h" |
Angie Chiang | 81b2e50 | 2017-06-19 15:13:52 -0700 | [diff] [blame] | 26 | #include "av1/common/convolve.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 27 | |
Debargha Mukherjee | 8c41024 | 2017-04-11 15:20:56 -0700 | [diff] [blame] | 28 | #define LEAST_SQUARES_SAMPLES_MAX_BITS 3 |
| 29 | #define LEAST_SQUARES_SAMPLES_MAX (1 << LEAST_SQUARES_SAMPLES_MAX_BITS) |
Yue Chen | d28bdba | 2017-06-16 10:38:03 -0700 | [diff] [blame] | 30 | #define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2) |
Yunqing Wang | d3c13e8 | 2018-01-02 17:52:56 -0800 | [diff] [blame] | 31 | #define WARPED_MOTION_DEBUG 0 |
Debargha Mukherjee | e6eb3b5 | 2017-02-26 08:50:56 -0800 | [diff] [blame] | 32 | #define DEFAULT_WMTYPE AFFINE |
Sarah Parker | 36b997b | 2019-05-09 16:06:53 -0700 | [diff] [blame] | 33 | #define WARP_ERROR_BLOCK_LOG 5 |
| 34 | #define WARP_ERROR_BLOCK (1 << WARP_ERROR_BLOCK_LOG) |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 35 | |
Yaowu Xu | 3a19b8a | 2019-05-01 08:40:42 -0700 | [diff] [blame] | 36 | extern const int16_t av1_warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8]; |
David Barker | d5dfa96 | 2017-01-10 15:06:08 +0000 | [diff] [blame] | 37 | |
Aniket Dhok | a80c64e | 2019-04-25 09:29:28 +0530 | [diff] [blame] | 38 | DECLARE_ALIGNED(8, extern const int8_t, |
Yaowu Xu | 2c61970 | 2019-05-03 08:55:45 -0700 | [diff] [blame] | 39 | av1_filter_8bit[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8]); |
Aniket Dhok | a80c64e | 2019-04-25 09:29:28 +0530 | [diff] [blame] | 40 | |
Ravi Chaudhary | 8ff220c | 2018-05-09 16:42:19 +0530 | [diff] [blame] | 41 | static 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 | |
| 58 | static 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 | |
Remya | 3eb3fe7 | 2019-08-30 11:35:04 +0530 | [diff] [blame] | 75 | void 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 | |
| 81 | void 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 Xu | d3e7c68 | 2017-12-21 14:08:25 -0800 | [diff] [blame] | 86 | void av1_warp_plane(WarpedMotionParams *wm, int use_hbd, int bd, |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 87 | const uint8_t *ref, int width, int height, int stride, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 88 | uint8_t *pred, int p_col, int p_row, int p_width, |
| 89 | int p_height, int p_stride, int subsampling_x, |
Frederic Barbier | c33aec5 | 2017-11-13 10:14:25 +0100 | [diff] [blame] | 90 | int subsampling_y, ConvolveParams *conv_params); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 91 | |
chiyotsai | 74da72b | 2020-04-07 13:45:40 -0700 | [diff] [blame] | 92 | int 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 Mukherjee | 11f0e40 | 2017-03-29 07:42:40 -0700 | [diff] [blame] | 95 | |
Yaowu Xu | 3a19b8a | 2019-05-01 08:40:42 -0700 | [diff] [blame] | 96 | int av1_get_shear_params(WarpedMotionParams *wm); |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 97 | #endif // AOM_AV1_COMMON_WARPED_MOTION_H_ |