blob: c1d81773459a741b696660b02ebb8d7748f23423 [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
Sarah Parkerf9a961c2016-09-06 11:25:04 -070012#ifndef AV1_COMMON_WARPED_MOTION_H_
13#define 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
Yaowu Xuf883b422016-08-30 14:01:10 -070021#include "./aom_config.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070022#include "aom_ports/mem.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070023#include "aom_dsp/aom_dsp_common.h"
Sarah Parkere5299862016-08-16 14:57:37 -070024#include "av1/common/mv.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025
Yue Chen1ab57802016-09-27 17:48:38 -070026#define MAX_PARAMDIM 9
Yue Chen69f18e12016-09-08 14:48:15 -070027#if CONFIG_WARPED_MOTION
Debargha Mukherjee9868c742017-01-26 15:23:35 -080028#define SAMPLES_PER_NEIGHBOR 4
29#define SAMPLES_ARRAY_SIZE ((2 * MAX_MIB_SIZE + 2) * SAMPLES_PER_NEIGHBOR * 2)
Yue Chen80a15c92017-01-12 19:29:14 -080030#define DEFAULT_WMTYPE ROTZOOM
Yue Chen69f18e12016-09-08 14:48:15 -070031#endif // CONFIG_WARPED_MOTION
Yue Chen1ab57802016-09-27 17:48:38 -070032
David Barkerd5dfa962017-01-10 15:06:08 +000033const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3][8];
34
Debargha Mukherjee5f305852016-11-03 15:47:21 -070035typedef void (*ProjectPointsFunc)(int32_t *mat, int *points, int *proj,
Sarah Parkere5299862016-08-16 14:57:37 -070036 const int n, const int stride_points,
Yaowu Xuc27fc142016-08-22 16:08:15 -070037 const int stride_proj,
38 const int subsampling_x,
39 const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070040
Debargha Mukherjee5f305852016-11-03 15:47:21 -070041void project_points_translation(int32_t *mat, int *points, int *proj,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070042 const int n, const int stride_points,
43 const int stride_proj, const int subsampling_x,
44 const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070045
Debargha Mukherjee5f305852016-11-03 15:47:21 -070046void project_points_rotzoom(int32_t *mat, int *points, int *proj, const int n,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070047 const int stride_points, const int stride_proj,
48 const int subsampling_x, const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070049
Debargha Mukherjee5f305852016-11-03 15:47:21 -070050void project_points_affine(int32_t *mat, int *points, int *proj, const int n,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070051 const int stride_points, const int stride_proj,
52 const int subsampling_x, const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070053
Debargha Mukherjee5f305852016-11-03 15:47:21 -070054void project_points_homography(int32_t *mat, int *points, int *proj,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070055 const int n, const int stride_points,
56 const int stride_proj, const int subsampling_x,
57 const int subsampling_y);
Yaowu Xuc27fc142016-08-22 16:08:15 -070058
Yue Chen69f18e12016-09-08 14:48:15 -070059void 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 Xuf883b422016-08-30 14:01:10 -070063double av1_warp_erroradv(WarpedMotionParams *wm,
Sarah Parkere3b8ff52016-09-07 12:17:22 -070064#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 Xuc27fc142016-08-22 16:08:15 -070071
Yaowu Xuf883b422016-08-30 14:01:10 -070072void 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 Parker43d56f32016-10-21 17:06:37 -070079 int subsampling_y, int x_scale, int y_scale, int ref_frm);
Yaowu Xuc27fc142016-08-22 16:08:15 -070080
81// Integerize model into the WarpedMotionParams structure
Yaowu Xuf883b422016-08-30 14:01:10 -070082void av1_integerize_model(const double *model, TransformationType wmtype,
83 WarpedMotionParams *wm);
Yue Chen1ab57802016-09-27 17:48:38 -070084
85int find_translation(const int np, double *pts1, double *pts2, double *mat);
86int find_rotzoom(const int np, double *pts1, double *pts2, double *mat);
87int find_affine(const int np, double *pts1, double *pts2, double *mat);
88int find_homography(const int np, double *pts1, double *pts2, double *mat);
Yue Chen69f18e12016-09-08 14:48:15 -070089int find_projection(const int np, double *pts1, double *pts2,
90 WarpedMotionParams *wm_params);
Sarah Parkerf9a961c2016-09-06 11:25:04 -070091#endif // AV1_COMMON_WARPED_MOTION_H_