warped_motion.h 2.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 *  Copyright (c) 2016 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be
 *  found  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef VP10_COMMON_WARPED_MOTION_H
#define VP10_COMMON_WARPED_MOTION_H

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <assert.h>

#include "./vpx_config.h"
#include "vpx_ports/mem.h"
#include "vpx_dsp/vpx_dsp_common.h"

// Bits of precision used for the model
#define WARPEDMODEL_PREC_BITS    8
26
#define WARPEDMODEL_ROW3HOMO_PREC_BITS    12
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

// Bits of subpel precision for warped interpolation
#define WARPEDPIXEL_PREC_BITS    6
#define WARPEDPIXEL_PREC_SHIFTS  (1 << WARPEDPIXEL_PREC_BITS)

// Taps for ntap filter
#define WARPEDPIXEL_FILTER_TAPS  6

// Precision of filter taps
#define WARPEDPIXEL_FILTER_BITS  7

#define WARPEDDIFF_PREC_BITS  (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS)

typedef enum {
  UNKNOWN_TRANSFORM = -1,
  HOMOGRAPHY,      // homography, 8-parameter
  AFFINE,          // affine, 6-parameter
  ROTZOOM,         // simplified affine with rotation and zoom only, 4-parameter
45
46
  TRANSLATION,     // translational motion 2-parameter
  TRANS_TYPES
47
48
} TransformationType;

49
50
51
// number of parameters used by each transformation in TransformationTypes
static const int n_trans_model_params[TRANS_TYPES] = {9, 6, 4, 2};

52
53
typedef struct {
  TransformationType wmtype;
54
  int wmmat[8];  // For homography wmmat[9] is assumed to be 1
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
} WarpedMotionParams;

void vp10_warp_plane(WarpedMotionParams *wm,
                     uint8_t *ref,
                     int width, int height, int stride,
                     uint8_t *pred,
                     int p_col, int p_row,
                     int p_width, int p_height, int p_stride,
                     int subsampling_col, int subsampling_row,
                     int x_scale, int y_scale);
#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_warp_plane(WarpedMotionParams *wm,
                            uint8_t *ref,
                            int width, int height, int stride,
                            uint8_t *pred,
                            int p_col, int p_row,
                            int p_width, int p_height, int p_stride,
                            int subsampling_col, int subsampling_row,
                            int x_scale, int y_scale,
                            int bd);
#endif  // CONFIG_VP9_HIGHBITDEPTH
#endif  // VP10_COMMON_WARPED_MOTION_H