Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebM project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be |
| 7 | * found in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 11 | #ifndef AV1_COMMON_WARPED_MOTION_H |
| 12 | #define AV1_COMMON_WARPED_MOTION_H |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 13 | |
| 14 | #include <stdio.h> |
| 15 | #include <stdlib.h> |
| 16 | #include <memory.h> |
| 17 | #include <math.h> |
| 18 | #include <assert.h> |
| 19 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 20 | #include "./aom_config.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 21 | #include "aom_ports/mem.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 22 | #include "aom_dsp/aom_dsp_common.h" |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 23 | #include "av1/common/mv.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 24 | |
| 25 | // Bits of precision used for the model |
| 26 | #define WARPEDMODEL_PREC_BITS 8 |
| 27 | #define WARPEDMODEL_ROW3HOMO_PREC_BITS 12 |
| 28 | |
| 29 | // Bits of subpel precision for warped interpolation |
| 30 | #define WARPEDPIXEL_PREC_BITS 6 |
| 31 | #define WARPEDPIXEL_PREC_SHIFTS (1 << WARPEDPIXEL_PREC_BITS) |
| 32 | |
| 33 | // Taps for ntap filter |
| 34 | #define WARPEDPIXEL_FILTER_TAPS 6 |
| 35 | |
| 36 | // Precision of filter taps |
| 37 | #define WARPEDPIXEL_FILTER_BITS 7 |
| 38 | |
| 39 | #define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS) |
| 40 | |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 41 | typedef void (*ProjectPointsType)(int16_t *mat, int *points, int *proj, |
| 42 | const int n, const int stride_points, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 43 | const int stride_proj, |
| 44 | const int subsampling_x, |
| 45 | const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 46 | |
| 47 | void projectPointsHomography(int16_t *mat, int *points, int *proj, const int n, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 48 | const int stride_points, const int stride_proj, |
| 49 | const int subsampling_x, const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 50 | |
| 51 | void projectPointsAffine(int16_t *mat, int *points, int *proj, const int n, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 52 | const int stride_points, const int stride_proj, |
| 53 | const int subsampling_x, const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 54 | |
| 55 | void projectPointsRotZoom(int16_t *mat, int *points, int *proj, const int n, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 56 | const int stride_points, const int stride_proj, |
| 57 | const int subsampling_x, const int subsampling_y); |
Sarah Parker | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 58 | |
| 59 | void projectPointsTranslation(int16_t *mat, int *points, int *proj, const int n, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 60 | 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 | e529986 | 2016-08-16 14:57:37 -0700 | [diff] [blame^] | 64 | #if CONFIG_VP9_HIGHBITDEPTH |
| 65 | int use_hbd, int bd, |
| 66 | #endif // CONFIG_VP9_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, |
| 79 | int subsampling_y, int x_scale, int y_scale); |
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); |
| 84 | #endif // AV1_COMMON_WARPED_MOTION_H |