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 | |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 12 | #ifndef AV1_COMMON_WARPED_MOTION_H_ |
| 13 | #define 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 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 21 | #include "./aom_config.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | #include "aom_ports/mem.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 23 | #include "aom_dsp/aom_dsp_common.h" |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 24 | #include "av1/common/mv.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 26 | #define MAX_PARAMDIM 9 |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 27 | #if CONFIG_WARPED_MOTION |
Debargha Mukherjee | 9868c74 | 2017-01-26 15:23:35 -0800 | [diff] [blame^] | 28 | #define SAMPLES_PER_NEIGHBOR 4 |
| 29 | #define SAMPLES_ARRAY_SIZE ((2 * MAX_MIB_SIZE + 2) * SAMPLES_PER_NEIGHBOR * 2) |
Yue Chen | 80a15c9 | 2017-01-12 19:29:14 -0800 | [diff] [blame] | 30 | #define DEFAULT_WMTYPE ROTZOOM |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 31 | #endif // CONFIG_WARPED_MOTION |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 32 | |
David Barker | d5dfa96 | 2017-01-10 15:06:08 +0000 | [diff] [blame] | 33 | const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3][8]; |
| 34 | |
Debargha Mukherjee | 5f30585 | 2016-11-03 15:47:21 -0700 | [diff] [blame] | 35 | typedef void (*ProjectPointsFunc)(int32_t *mat, int *points, int *proj, |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 36 | const int n, const int stride_points, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 37 | const int stride_proj, |
| 38 | const int subsampling_x, |
| 39 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 40 | |
Debargha Mukherjee | 5f30585 | 2016-11-03 15:47:21 -0700 | [diff] [blame] | 41 | void project_points_translation(int32_t *mat, int *points, int *proj, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 42 | const int n, const int stride_points, |
| 43 | const int stride_proj, const int subsampling_x, |
| 44 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 45 | |
Debargha Mukherjee | 5f30585 | 2016-11-03 15:47:21 -0700 | [diff] [blame] | 46 | void project_points_rotzoom(int32_t *mat, int *points, int *proj, const int n, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 47 | const int stride_points, const int stride_proj, |
| 48 | const int subsampling_x, const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 49 | |
Debargha Mukherjee | 5f30585 | 2016-11-03 15:47:21 -0700 | [diff] [blame] | 50 | void project_points_affine(int32_t *mat, int *points, int *proj, const int n, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 51 | const int stride_points, const int stride_proj, |
| 52 | const int subsampling_x, const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 53 | |
Debargha Mukherjee | 5f30585 | 2016-11-03 15:47:21 -0700 | [diff] [blame] | 54 | void project_points_homography(int32_t *mat, int *points, int *proj, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 55 | const int n, const int stride_points, |
| 56 | const int stride_proj, const int subsampling_x, |
| 57 | const int subsampling_y); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 59 | void project_points(WarpedMotionParams *wm_params, int *points, int *proj, |
| 60 | const int n, const int stride_points, const int stride_proj, |
| 61 | const int subsampling_x, const int subsampling_y); |
| 62 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 63 | double av1_warp_erroradv(WarpedMotionParams *wm, |
Sarah Parker | e3b8ff5 | 2016-09-07 12:17:22 -0700 | [diff] [blame] | 64 | #if CONFIG_AOM_HIGHBITDEPTH |
| 65 | int use_hbd, int bd, |
| 66 | #endif // CONFIG_AOM_HIGHBITDEPTH |
| 67 | uint8_t *ref, int width, int height, int stride, |
| 68 | uint8_t *dst, int p_col, int p_row, int p_width, |
| 69 | int p_height, int p_stride, int subsampling_x, |
| 70 | int subsampling_y, int x_scale, int y_scale); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 71 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 72 | void av1_warp_plane(WarpedMotionParams *wm, |
| 73 | #if CONFIG_AOM_HIGHBITDEPTH |
| 74 | int use_hbd, int bd, |
| 75 | #endif // CONFIG_AOM_HIGHBITDEPTH |
| 76 | uint8_t *ref, int width, int height, int stride, |
| 77 | uint8_t *pred, int p_col, int p_row, int p_width, |
| 78 | int p_height, int p_stride, int subsampling_x, |
Sarah Parker | 43d56f3 | 2016-10-21 17:06:37 -0700 | [diff] [blame] | 79 | int subsampling_y, int x_scale, int y_scale, int ref_frm); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 80 | |
| 81 | // Integerize model into the WarpedMotionParams structure |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 82 | void av1_integerize_model(const double *model, TransformationType wmtype, |
| 83 | WarpedMotionParams *wm); |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 84 | |
| 85 | int find_translation(const int np, double *pts1, double *pts2, double *mat); |
| 86 | int find_rotzoom(const int np, double *pts1, double *pts2, double *mat); |
| 87 | int find_affine(const int np, double *pts1, double *pts2, double *mat); |
| 88 | int find_homography(const int np, double *pts1, double *pts2, double *mat); |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 89 | int find_projection(const int np, double *pts1, double *pts2, |
| 90 | WarpedMotionParams *wm_params); |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 91 | #endif // AV1_COMMON_WARPED_MOTION_H_ |