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" |
Angie Chiang | 81b2e50 | 2017-06-19 15:13:52 -0700 | [diff] [blame^] | 25 | #include "av1/common/convolve.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 26 | |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 27 | #define MAX_PARAMDIM 9 |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 28 | #if CONFIG_WARPED_MOTION |
Debargha Mukherjee | 8c41024 | 2017-04-11 15:20:56 -0700 | [diff] [blame] | 29 | #define LEAST_SQUARES_SAMPLES_MAX_BITS 3 |
| 30 | #define LEAST_SQUARES_SAMPLES_MAX (1 << LEAST_SQUARES_SAMPLES_MAX_BITS) |
Yue Chen | d28bdba | 2017-06-16 10:38:03 -0700 | [diff] [blame] | 31 | #define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2) |
Debargha Mukherjee | 8c41024 | 2017-04-11 15:20:56 -0700 | [diff] [blame] | 32 | |
Debargha Mukherjee | e6eb3b5 | 2017-02-26 08:50:56 -0800 | [diff] [blame] | 33 | #define DEFAULT_WMTYPE AFFINE |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 34 | #endif // CONFIG_WARPED_MOTION |
Yue Chen | 1ab5780 | 2016-09-27 17:48:38 -0700 | [diff] [blame] | 35 | |
James Zern | ed3a39f | 2017-05-01 12:09:08 -0700 | [diff] [blame] | 36 | extern const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8]; |
David Barker | d5dfa96 | 2017-01-10 15:06:08 +0000 | [diff] [blame] | 37 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 38 | typedef void (*ProjectPointsFunc)(const int32_t *mat, int *points, int *proj, |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 39 | const int n, const int stride_points, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 40 | const int stride_proj, |
| 41 | const int subsampling_x, |
| 42 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 43 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 44 | void project_points_translation(const int32_t *mat, int *points, int *proj, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 45 | const int n, const int stride_points, |
| 46 | const int stride_proj, const int subsampling_x, |
| 47 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 48 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 49 | void project_points_rotzoom(const int32_t *mat, int *points, int *proj, |
| 50 | const int n, const int stride_points, |
| 51 | const int stride_proj, const int subsampling_x, |
| 52 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 53 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 54 | void project_points_affine(const int32_t *mat, int *points, int *proj, |
| 55 | const int n, const int stride_points, |
| 56 | const int stride_proj, const int subsampling_x, |
| 57 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame] | 58 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 59 | void project_points_hortrapezoid(const int32_t *mat, int *points, int *proj, |
Debargha Mukherjee | 5dfa930 | 2017-02-10 05:00:08 -0800 | [diff] [blame] | 60 | const int n, const int stride_points, |
| 61 | const int stride_proj, const int subsampling_x, |
| 62 | const int subsampling_y); |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 63 | void project_points_vertrapezoid(const int32_t *mat, int *points, int *proj, |
Debargha Mukherjee | 5dfa930 | 2017-02-10 05:00:08 -0800 | [diff] [blame] | 64 | const int n, const int stride_points, |
| 65 | const int stride_proj, const int subsampling_x, |
| 66 | const int subsampling_y); |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 67 | void project_points_homography(const int32_t *mat, int *points, int *proj, |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 68 | const int n, const int stride_points, |
| 69 | const int stride_proj, const int subsampling_x, |
| 70 | const int subsampling_y); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 71 | |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 72 | void project_points(const WarpedMotionParams *wm_params, int *points, int *proj, |
Yue Chen | 69f18e1 | 2016-09-08 14:48:15 -0700 | [diff] [blame] | 73 | const int n, const int stride_points, const int stride_proj, |
| 74 | const int subsampling_x, const int subsampling_y); |
| 75 | |
emilkeyder@google.com | 6e3557c | 2017-03-27 10:52:53 -0400 | [diff] [blame] | 76 | // Returns the error between the result of applying motion 'wm' to the frame |
| 77 | // described by 'ref' and the frame described by 'dst'. |
| 78 | int64_t av1_warp_error(WarpedMotionParams *wm, |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 79 | #if CONFIG_HIGHBITDEPTH |
emilkeyder@google.com | 6e3557c | 2017-03-27 10:52:53 -0400 | [diff] [blame] | 80 | int use_hbd, int bd, |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 81 | #endif // CONFIG_HIGHBITDEPTH |
emilkeyder@google.com | 6e3557c | 2017-03-27 10:52:53 -0400 | [diff] [blame] | 82 | const uint8_t *ref, int width, int height, int stride, |
| 83 | uint8_t *dst, int p_col, int p_row, int p_width, |
| 84 | int p_height, int p_stride, int subsampling_x, |
Sarah Parker | 81f6ecd | 2017-05-26 16:10:11 -0700 | [diff] [blame] | 85 | int subsampling_y, int x_scale, int y_scale, |
| 86 | int64_t best_error); |
emilkeyder@google.com | 6e3557c | 2017-03-27 10:52:53 -0400 | [diff] [blame] | 87 | |
| 88 | // Returns the error between the frame described by 'ref' and the frame |
| 89 | // described by 'dst'. |
| 90 | int64_t av1_frame_error( |
| 91 | #if CONFIG_HIGHBITDEPTH |
| 92 | int use_hbd, int bd, |
| 93 | #endif // CONFIG_HIGHBITDEPTH |
Sarah Parker | 81f6ecd | 2017-05-26 16:10:11 -0700 | [diff] [blame] | 94 | const uint8_t *ref, int stride, uint8_t *dst, int p_width, int p_height, |
| 95 | int p_stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 96 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 97 | void av1_warp_plane(WarpedMotionParams *wm, |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 98 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 99 | int use_hbd, int bd, |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 100 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | cd0f6c4 | 2017-05-05 11:18:22 -0700 | [diff] [blame] | 101 | const uint8_t *ref, int width, int height, int stride, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 102 | uint8_t *pred, int p_col, int p_row, int p_width, |
| 103 | int p_height, int p_stride, int subsampling_x, |
Angie Chiang | 81b2e50 | 2017-06-19 15:13:52 -0700 | [diff] [blame^] | 104 | int subsampling_y, int x_scale, int y_scale, |
| 105 | ConvolveParams *conv_params); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 106 | |
Yaowu Xu | 4ff59b5 | 2017-04-24 12:41:56 -0700 | [diff] [blame] | 107 | int find_projection(int np, int *pts1, int *pts2, BLOCK_SIZE bsize, int mvy, |
| 108 | int mvx, WarpedMotionParams *wm_params, int mi_row, |
Debargha Mukherjee | e8e6cad | 2017-03-22 17:38:38 -0700 | [diff] [blame] | 109 | int mi_col); |
Debargha Mukherjee | 11f0e40 | 2017-03-29 07:42:40 -0700 | [diff] [blame] | 110 | |
Debargha Mukherjee | 3b6c544 | 2017-03-30 08:22:00 -0700 | [diff] [blame] | 111 | int get_shear_params(WarpedMotionParams *wm); |
Sarah Parker | f9a961c | 2016-09-06 11:25:04 -0700 | [diff] [blame] | 112 | #endif // AV1_COMMON_WARPED_MOTION_H_ |