blob: 4d707cfeff1adc29f6ee6ce9994ddc2d648a887c [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"
Angie Chiang81b2e502017-06-19 15:13:52 -070025#include "av1/common/convolve.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070026
Yue Chen1ab57802016-09-27 17:48:38 -070027#define MAX_PARAMDIM 9
Yue Chen69f18e12016-09-08 14:48:15 -070028#if CONFIG_WARPED_MOTION
Debargha Mukherjee8c410242017-04-11 15:20:56 -070029#define LEAST_SQUARES_SAMPLES_MAX_BITS 3
30#define LEAST_SQUARES_SAMPLES_MAX (1 << LEAST_SQUARES_SAMPLES_MAX_BITS)
Yue Chend28bdba2017-06-16 10:38:03 -070031#define SAMPLES_ARRAY_SIZE (LEAST_SQUARES_SAMPLES_MAX * 2)
Debargha Mukherjee8c410242017-04-11 15:20:56 -070032
Debargha Mukherjeee6eb3b52017-02-26 08:50:56 -080033#define DEFAULT_WMTYPE AFFINE
Yue Chen69f18e12016-09-08 14:48:15 -070034#endif // CONFIG_WARPED_MOTION
Yue Chen1ab57802016-09-27 17:48:38 -070035
James Zerned3a39f2017-05-01 12:09:08 -070036extern const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3 + 1][8];
David Barkerd5dfa962017-01-10 15:06:08 +000037
Yaowu Xucd0f6c42017-05-05 11:18:22 -070038typedef void (*ProjectPointsFunc)(const int32_t *mat, int *points, int *proj,
Sarah Parkere5299862016-08-16 14:57:37 -070039 const int n, const int stride_points,
Yaowu Xuc27fc142016-08-22 16:08:15 -070040 const int stride_proj,
41 const int subsampling_x,
42 const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070043
Yaowu Xucd0f6c42017-05-05 11:18:22 -070044void project_points_translation(const int32_t *mat, int *points, int *proj,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070045 const int n, const int stride_points,
46 const int stride_proj, const int subsampling_x,
47 const int subsampling_y);
Sarah Parkere5299862016-08-16 14:57:37 -070048
Yaowu Xucd0f6c42017-05-05 11:18:22 -070049void 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 Parkere5299862016-08-16 14:57:37 -070053
Yaowu Xucd0f6c42017-05-05 11:18:22 -070054void 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 Parkere5299862016-08-16 14:57:37 -070058
Yaowu Xucd0f6c42017-05-05 11:18:22 -070059void project_points_hortrapezoid(const int32_t *mat, int *points, int *proj,
Debargha Mukherjee5dfa9302017-02-10 05:00:08 -080060 const int n, const int stride_points,
61 const int stride_proj, const int subsampling_x,
62 const int subsampling_y);
Yaowu Xucd0f6c42017-05-05 11:18:22 -070063void project_points_vertrapezoid(const int32_t *mat, int *points, int *proj,
Debargha Mukherjee5dfa9302017-02-10 05:00:08 -080064 const int n, const int stride_points,
65 const int stride_proj, const int subsampling_x,
66 const int subsampling_y);
Yaowu Xucd0f6c42017-05-05 11:18:22 -070067void project_points_homography(const int32_t *mat, int *points, int *proj,
Sarah Parkerf9a961c2016-09-06 11:25:04 -070068 const int n, const int stride_points,
69 const int stride_proj, const int subsampling_x,
70 const int subsampling_y);
Yaowu Xuc27fc142016-08-22 16:08:15 -070071
Yaowu Xucd0f6c42017-05-05 11:18:22 -070072void project_points(const WarpedMotionParams *wm_params, int *points, int *proj,
Yue Chen69f18e12016-09-08 14:48:15 -070073 const int n, const int stride_points, const int stride_proj,
74 const int subsampling_x, const int subsampling_y);
75
emilkeyder@google.com6e3557c2017-03-27 10:52:53 -040076// Returns the error between the result of applying motion 'wm' to the frame
77// described by 'ref' and the frame described by 'dst'.
78int64_t av1_warp_error(WarpedMotionParams *wm,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020079#if CONFIG_HIGHBITDEPTH
emilkeyder@google.com6e3557c2017-03-27 10:52:53 -040080 int use_hbd, int bd,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020081#endif // CONFIG_HIGHBITDEPTH
emilkeyder@google.com6e3557c2017-03-27 10:52:53 -040082 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 Parker81f6ecd2017-05-26 16:10:11 -070085 int subsampling_y, int x_scale, int y_scale,
86 int64_t best_error);
emilkeyder@google.com6e3557c2017-03-27 10:52:53 -040087
88// Returns the error between the frame described by 'ref' and the frame
89// described by 'dst'.
90int64_t av1_frame_error(
91#if CONFIG_HIGHBITDEPTH
92 int use_hbd, int bd,
93#endif // CONFIG_HIGHBITDEPTH
Sarah Parker81f6ecd2017-05-26 16:10:11 -070094 const uint8_t *ref, int stride, uint8_t *dst, int p_width, int p_height,
95 int p_stride);
Yaowu Xuc27fc142016-08-22 16:08:15 -070096
Yaowu Xuf883b422016-08-30 14:01:10 -070097void av1_warp_plane(WarpedMotionParams *wm,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020098#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070099 int use_hbd, int bd,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200100#endif // CONFIG_HIGHBITDEPTH
Yaowu Xucd0f6c42017-05-05 11:18:22 -0700101 const uint8_t *ref, int width, int height, int stride,
Yaowu Xuf883b422016-08-30 14:01:10 -0700102 uint8_t *pred, int p_col, int p_row, int p_width,
103 int p_height, int p_stride, int subsampling_x,
Angie Chiang81b2e502017-06-19 15:13:52 -0700104 int subsampling_y, int x_scale, int y_scale,
105 ConvolveParams *conv_params);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700106
Yaowu Xu4ff59b52017-04-24 12:41:56 -0700107int find_projection(int np, int *pts1, int *pts2, BLOCK_SIZE bsize, int mvy,
108 int mvx, WarpedMotionParams *wm_params, int mi_row,
Debargha Mukherjeee8e6cad2017-03-22 17:38:38 -0700109 int mi_col);
Debargha Mukherjee11f0e402017-03-29 07:42:40 -0700110
Debargha Mukherjee3b6c5442017-03-30 08:22:00 -0700111int get_shear_params(WarpedMotionParams *wm);
Sarah Parkerf9a961c2016-09-06 11:25:04 -0700112#endif // AV1_COMMON_WARPED_MOTION_H_