From 68569dee1416593955c1570d638b3d9250b33012 Mon Sep 17 00:00:00 2001 From: trav90 Date: Mon, 15 Oct 2018 21:45:30 -0500 Subject: Import aom library This is the reference implementation for the Alliance for Open Media's av1 video code. The commit used was 4d668d7feb1f8abd809d1bca0418570a7f142a36. --- third_party/aom/av1/common/mv.h | 302 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 third_party/aom/av1/common/mv.h (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h new file mode 100644 index 000000000..d4df3790f --- /dev/null +++ b/third_party/aom/av1/common/mv.h @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2016, Alliance for Open Media. All rights reserved + * + * This source code is subject to the terms of the BSD 2 Clause License and + * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License + * was not distributed with this source code in the LICENSE file, you can + * obtain it at www.aomedia.org/license/software. If the Alliance for Open + * Media Patent License 1.0 was not distributed with this source code in the + * PATENTS file, you can obtain it at www.aomedia.org/license/patent. + */ + +#ifndef AV1_COMMON_MV_H_ +#define AV1_COMMON_MV_H_ + +#include "av1/common/common.h" +#include "av1/common/common_data.h" +#include "aom_dsp/aom_filter.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct mv { + int16_t row; + int16_t col; +} MV; + +typedef union int_mv { + uint32_t as_int; + MV as_mv; +} int_mv; /* facilitates faster equality tests and copies */ + +typedef struct mv32 { + int32_t row; + int32_t col; +} MV32; + +#if (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION +#define SEPARATE_GLOBAL_MOTION 1 +#endif // (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION +#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION +// Bits of precision used for the model +#define WARPEDMODEL_PREC_BITS 16 +#define WARPEDMODEL_ROW3HOMO_PREC_BITS 16 + +#define WARPEDMODEL_TRANS_CLAMP (128 << WARPEDMODEL_PREC_BITS) +#define WARPEDMODEL_DIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS + 1)) +#define WARPEDMODEL_NONDIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1)) +#define WARPEDMODEL_ROW3HOMO_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1)) + +// 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 + +// Precision bits reduction after horizontal shear +#define HORSHEAR_REDUCE_PREC_BITS 5 +#define VERSHEAR_REDUCE_PREC_BITS \ + (2 * WARPEDPIXEL_FILTER_BITS - HORSHEAR_REDUCE_PREC_BITS) + +#define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS) + +/* clang-format off */ +typedef enum { + IDENTITY = 0, // identity transformation, 0-parameter + TRANSLATION = 1, // translational motion 2-parameter + ROTZOOM = 2, // simplified affine with rotation + zoom only, 4-parameter + AFFINE = 3, // affine, 6-parameter + HORTRAPEZOID = 4, // constrained homography, hor trapezoid, 6-parameter + VERTRAPEZOID = 5, // constrained homography, ver trapezoid, 6-parameter + HOMOGRAPHY = 6, // homography, 8-parameter + TRANS_TYPES = 7, +} TransformationType; +/* clang-format on */ + +// Number of types used for global motion (must be >= 3 and <= TRANS_TYPES) +// The following can be useful: +// GLOBAL_TRANS_TYPES 3 - up to rotation-zoom +// GLOBAL_TRANS_TYPES 4 - up to affine +// GLOBAL_TRANS_TYPES 6 - up to hor/ver trapezoids +// GLOBAL_TRANS_TYPES 7 - up to full homography +#define GLOBAL_TRANS_TYPES 4 + +typedef struct { +#if CONFIG_GLOBAL_MOTION + int global_warp_allowed; +#endif // CONFIG_GLOBAL_MOTION +#if CONFIG_WARPED_MOTION + int local_warp_allowed; +#endif // CONFIG_WARPED_MOTION +} WarpTypesAllowed; + +// number of parameters used by each transformation in TransformationTypes +static const int trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6, 6, 6, 8 }; + +// The order of values in the wmmat matrix below is best described +// by the homography: +// [x' (m2 m3 m0 [x +// z . y' = m4 m5 m1 * y +// 1] m6 m7 1) 1] +typedef struct { + TransformationType wmtype; + int32_t wmmat[8]; + int16_t alpha, beta, gamma, delta; +} WarpedMotionParams; + +static INLINE void set_default_warp_params(WarpedMotionParams *wm) { + static const int32_t default_wm_mat[8] = { + 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0 + }; + memset(wm, 0, sizeof(*wm)); + memcpy(wm->wmmat, default_wm_mat, sizeof(wm->wmmat)); + wm->wmtype = IDENTITY; +} +#endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION + +#if CONFIG_GLOBAL_MOTION +// The following constants describe the various precisions +// of different parameters in the global motion experiment. +// +// Given the general homography: +// [x' (a b c [x +// z . y' = d e f * y +// 1] g h i) 1] +// +// Constants using the name ALPHA here are related to parameters +// a, b, d, e. Constants using the name TRANS are related +// to parameters c and f. +// +// Anything ending in PREC_BITS is the number of bits of precision +// to maintain when converting from double to integer. +// +// The ABS parameters are used to create an upper and lower bound +// for each parameter. In other words, after a parameter is integerized +// it is clamped between -(1 << ABS_XXX_BITS) and (1 << ABS_XXX_BITS). +// +// XXX_PREC_DIFF and XXX_DECODE_FACTOR +// are computed once here to prevent repetitive +// computation on the decoder side. These are +// to allow the global motion parameters to be encoded in a lower +// precision than the warped model precision. This means that they +// need to be changed to warped precision when they are decoded. +// +// XX_MIN, XX_MAX are also computed to avoid repeated computation + +#define SUBEXPFIN_K 3 +#define GM_TRANS_PREC_BITS 6 +#define GM_ABS_TRANS_BITS 12 +#define GM_ABS_TRANS_ONLY_BITS (GM_ABS_TRANS_BITS - GM_TRANS_PREC_BITS + 3) +#define GM_TRANS_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_TRANS_PREC_BITS) +#define GM_TRANS_ONLY_PREC_DIFF (WARPEDMODEL_PREC_BITS - 3) +#define GM_TRANS_DECODE_FACTOR (1 << GM_TRANS_PREC_DIFF) +#define GM_TRANS_ONLY_DECODE_FACTOR (1 << GM_TRANS_ONLY_PREC_DIFF) + +#define GM_ALPHA_PREC_BITS 15 +#define GM_ABS_ALPHA_BITS 12 +#define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS) +#define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF) + +#define GM_ROW3HOMO_PREC_BITS 16 +#define GM_ABS_ROW3HOMO_BITS 11 +#define GM_ROW3HOMO_PREC_DIFF \ + (WARPEDMODEL_ROW3HOMO_PREC_BITS - GM_ROW3HOMO_PREC_BITS) +#define GM_ROW3HOMO_DECODE_FACTOR (1 << GM_ROW3HOMO_PREC_DIFF) + +#define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS) +#define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS) +#define GM_ROW3HOMO_MAX (1 << GM_ABS_ROW3HOMO_BITS) + +#define GM_TRANS_MIN -GM_TRANS_MAX +#define GM_ALPHA_MIN -GM_ALPHA_MAX +#define GM_ROW3HOMO_MIN -GM_ROW3HOMO_MAX + +// Use global motion parameters for sub8x8 blocks +#define GLOBAL_SUB8X8_USED 0 + +static INLINE int block_center_x(int mi_col, BLOCK_SIZE bs) { + const int bw = block_size_wide[bs]; + return mi_col * MI_SIZE + bw / 2 - 1; +} + +static INLINE int block_center_y(int mi_row, BLOCK_SIZE bs) { + const int bh = block_size_high[bs]; + return mi_row * MI_SIZE + bh / 2 - 1; +} + +static INLINE int convert_to_trans_prec(int allow_hp, int coor) { + if (allow_hp) + return ROUND_POWER_OF_TWO_SIGNED(coor, WARPEDMODEL_PREC_BITS - 3); + else + return ROUND_POWER_OF_TWO_SIGNED(coor, WARPEDMODEL_PREC_BITS - 2) * 2; +} + +// Convert a global motion translation vector (which may have more bits than a +// regular motion vector) into a motion vector +static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm, + int allow_hp, BLOCK_SIZE bsize, + int mi_col, int mi_row, + int block_idx) { + const int unify_bsize = CONFIG_CB4X4; + int_mv res; + const int32_t *mat = gm->wmmat; + int x, y, tx, ty; + + if (gm->wmtype == TRANSLATION) { + res.as_mv.row = gm->wmmat[0] >> GM_TRANS_ONLY_PREC_DIFF; + res.as_mv.col = gm->wmmat[1] >> GM_TRANS_ONLY_PREC_DIFF; + return res; + } + + if (bsize >= BLOCK_8X8 || unify_bsize) { + x = block_center_x(mi_col, bsize); + y = block_center_y(mi_row, bsize); + } else { + x = block_center_x(mi_col, bsize); + y = block_center_y(mi_row, bsize); + x += (block_idx & 1) * MI_SIZE / 2; + y += (block_idx & 2) * MI_SIZE / 4; + } + + if (gm->wmtype == ROTZOOM) { + assert(gm->wmmat[5] == gm->wmmat[2]); + assert(gm->wmmat[4] == -gm->wmmat[3]); + } + if (gm->wmtype > AFFINE) { + int xc = (int)((int64_t)mat[2] * x + (int64_t)mat[3] * y + mat[0]); + int yc = (int)((int64_t)mat[4] * x + (int64_t)mat[5] * y + mat[1]); + const int Z = (int)((int64_t)mat[6] * x + (int64_t)mat[7] * y + + (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); + xc *= 1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS - WARPEDMODEL_PREC_BITS); + yc *= 1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS - WARPEDMODEL_PREC_BITS); + xc = (int)(xc > 0 ? ((int64_t)xc + Z / 2) / Z : ((int64_t)xc - Z / 2) / Z); + yc = (int)(yc > 0 ? ((int64_t)yc + Z / 2) / Z : ((int64_t)yc - Z / 2) / Z); + tx = convert_to_trans_prec(allow_hp, xc) - (x << 3); + ty = convert_to_trans_prec(allow_hp, yc) - (y << 3); + } else { + const int xc = + (mat[2] - (1 << WARPEDMODEL_PREC_BITS)) * x + mat[3] * y + mat[0]; + const int yc = + mat[4] * x + (mat[5] - (1 << WARPEDMODEL_PREC_BITS)) * y + mat[1]; + tx = convert_to_trans_prec(allow_hp, xc); + ty = convert_to_trans_prec(allow_hp, yc); + } + + res.as_mv.row = ty; + res.as_mv.col = tx; + return res; +} + +static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) { + if (gm->wmmat[6] != 0 || gm->wmmat[7] != 0) { + if (!gm->wmmat[6] && !gm->wmmat[4]) return HORTRAPEZOID; + if (!gm->wmmat[7] && !gm->wmmat[3]) return VERTRAPEZOID; + return HOMOGRAPHY; + } + if (gm->wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[4] && + gm->wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[3]) { + return ((!gm->wmmat[1] && !gm->wmmat[0]) ? IDENTITY : TRANSLATION); + } + if (gm->wmmat[2] == gm->wmmat[5] && gm->wmmat[3] == -gm->wmmat[4]) + return ROTZOOM; + else + return AFFINE; +} +#endif // CONFIG_GLOBAL_MOTION + +#if CONFIG_REF_MV +typedef struct candidate_mv { + int_mv this_mv; + int_mv comp_mv; + uint8_t pred_diff[2]; + int weight; +} CANDIDATE_MV; +#endif + +static INLINE int is_zero_mv(const MV *mv) { + return *((const uint32_t *)mv) == 0; +} + +static INLINE int is_equal_mv(const MV *a, const MV *b) { + return *((const uint32_t *)a) == *((const uint32_t *)b); +} + +static INLINE void clamp_mv(MV *mv, int min_col, int max_col, int min_row, + int max_row) { + mv->col = clamp(mv->col, min_col, max_col); + mv->row = clamp(mv->row, min_row, max_row); +} + +static INLINE int mv_has_subpel(const MV *mv) { + return (mv->row & SUBPEL_MASK) || (mv->col & SUBPEL_MASK); +} +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // AV1_COMMON_MV_H_ -- cgit v1.2.3 From df9477dfa60ebb5d31bc142e58ce46535c17abce Mon Sep 17 00:00:00 2001 From: trav90 Date: Wed, 17 Oct 2018 05:59:08 -0500 Subject: Update aom to slightly newer commit ID --- third_party/aom/av1/common/mv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index d4df3790f..41a46f5e8 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -58,6 +58,8 @@ typedef struct mv32 { // Precision of filter taps #define WARPEDPIXEL_FILTER_BITS 7 +#define WARP_PARAM_REDUCE_BITS 6 + // Precision bits reduction after horizontal shear #define HORSHEAR_REDUCE_PREC_BITS 5 #define VERSHEAR_REDUCE_PREC_BITS \ @@ -269,14 +271,12 @@ static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) { } #endif // CONFIG_GLOBAL_MOTION -#if CONFIG_REF_MV typedef struct candidate_mv { int_mv this_mv; int_mv comp_mv; uint8_t pred_diff[2]; int weight; } CANDIDATE_MV; -#endif static INLINE int is_zero_mv(const MV *mv) { return *((const uint32_t *)mv) == 0; -- cgit v1.2.3 From 7369c7d7a5eed32963d8af37658286617919f91c Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 18 Oct 2018 06:04:57 -0500 Subject: Update aom to commit id f5bdeac22930ff4c6b219be49c843db35970b918 --- third_party/aom/av1/common/mv.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index 41a46f5e8..dabfc0ead 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -35,18 +35,18 @@ typedef struct mv32 { int32_t col; } MV32; -#if (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION -#define SEPARATE_GLOBAL_MOTION 1 -#endif // (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION +#if CONFIG_WARPED_MOTION +#define WARPED_MOTION_SORT_SAMPLES 1 +#endif // CONFIG_WARPED_MOTION + #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION // Bits of precision used for the model #define WARPEDMODEL_PREC_BITS 16 #define WARPEDMODEL_ROW3HOMO_PREC_BITS 16 #define WARPEDMODEL_TRANS_CLAMP (128 << WARPEDMODEL_PREC_BITS) -#define WARPEDMODEL_DIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS + 1)) -#define WARPEDMODEL_NONDIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1)) -#define WARPEDMODEL_ROW3HOMO_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 1)) +#define WARPEDMODEL_NONDIAGAFFINE_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 3)) +#define WARPEDMODEL_ROW3HOMO_CLAMP (1 << (WARPEDMODEL_PREC_BITS - 2)) // Bits of subpel precision for warped interpolation #define WARPEDPIXEL_PREC_BITS 6 @@ -88,6 +88,11 @@ typedef enum { // GLOBAL_TRANS_TYPES 7 - up to full homography #define GLOBAL_TRANS_TYPES 4 +// First bit indicates whether using identity or not +// GLOBAL_TYPE_BITS=ceiling(log2(GLOBAL_TRANS_TYPES-1)) is the +// number of bits needed to cover the remaining possibilities +#define GLOBAL_TYPE_BITS (get_msb(2 * GLOBAL_TRANS_TYPES - 3)) + typedef struct { #if CONFIG_GLOBAL_MOTION int global_warp_allowed; -- cgit v1.2.3 From ec910d81405c736a4490383a250299a7837c2e64 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 18 Oct 2018 21:53:44 -0500 Subject: Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614 --- third_party/aom/av1/common/mv.h | 83 +++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 12 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index dabfc0ead..65f0f7eda 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -20,6 +20,8 @@ extern "C" { #endif +#define INVALID_MV 0x80008000 + typedef struct mv { int16_t row; int16_t col; @@ -88,10 +90,12 @@ typedef enum { // GLOBAL_TRANS_TYPES 7 - up to full homography #define GLOBAL_TRANS_TYPES 4 +#if GLOBAL_TRANS_TYPES > 4 // First bit indicates whether using identity or not // GLOBAL_TYPE_BITS=ceiling(log2(GLOBAL_TRANS_TYPES-1)) is the // number of bits needed to cover the remaining possibilities #define GLOBAL_TYPE_BITS (get_msb(2 * GLOBAL_TRANS_TYPES - 3)) +#endif // GLOBAL_TRANS_TYPES > 4 typedef struct { #if CONFIG_GLOBAL_MOTION @@ -116,14 +120,14 @@ typedef struct { int16_t alpha, beta, gamma, delta; } WarpedMotionParams; -static INLINE void set_default_warp_params(WarpedMotionParams *wm) { - static const int32_t default_wm_mat[8] = { - 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0 - }; - memset(wm, 0, sizeof(*wm)); - memcpy(wm->wmmat, default_wm_mat, sizeof(wm->wmmat)); - wm->wmtype = IDENTITY; -} +/* clang-format off */ +static const WarpedMotionParams default_warp_params = { + IDENTITY, + { 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, + 0 }, + 0, 0, 0, 0 +}; +/* clang-format on */ #endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION #if CONFIG_GLOBAL_MOTION @@ -202,21 +206,70 @@ static INLINE int convert_to_trans_prec(int allow_hp, int coor) { else return ROUND_POWER_OF_TWO_SIGNED(coor, WARPEDMODEL_PREC_BITS - 2) * 2; } +#if CONFIG_AMVR +static INLINE void integer_mv_precision(MV *mv) { + int mod = (mv->row % 8); + if (mod != 0) { + mv->row -= mod; + if (abs(mod) > 4) { + if (mod > 0) { + mv->row += 8; + } else { + mv->row -= 8; + } + } + } -// Convert a global motion translation vector (which may have more bits than a -// regular motion vector) into a motion vector + mod = (mv->col % 8); + if (mod != 0) { + mv->col -= mod; + if (abs(mod) > 4) { + if (mod > 0) { + mv->col += 8; + } else { + mv->col -= 8; + } + } + } +} +#endif +// Convert a global motion vector into a motion vector at the centre of the +// given block. +// +// The resulting motion vector will have three fractional bits of precision. If +// allow_hp is zero, the bottom bit will always be zero. If CONFIG_AMVR and +// is_integer is true, the bottom three bits will be zero (so the motion vector +// represents an integer) static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm, int allow_hp, BLOCK_SIZE bsize, - int mi_col, int mi_row, - int block_idx) { + int mi_col, int mi_row, int block_idx +#if CONFIG_AMVR + , + int is_integer +#endif + ) { const int unify_bsize = CONFIG_CB4X4; int_mv res; const int32_t *mat = gm->wmmat; int x, y, tx, ty; if (gm->wmtype == TRANSLATION) { + // All global motion vectors are stored with WARPEDMODEL_PREC_BITS (16) + // bits of fractional precision. The offset for a translation is stored in + // entries 0 and 1. For translations, all but the top three (two if + // cm->allow_high_precision_mv is false) fractional bits are always zero. + // + // After the right shifts, there are 3 fractional bits of precision. If + // allow_hp is false, the bottom bit is always zero (so we don't need a + // call to convert_to_trans_prec here) res.as_mv.row = gm->wmmat[0] >> GM_TRANS_ONLY_PREC_DIFF; res.as_mv.col = gm->wmmat[1] >> GM_TRANS_ONLY_PREC_DIFF; + assert(IMPLIES(1 & (res.as_mv.row | res.as_mv.col), allow_hp)); +#if CONFIG_AMVR + if (is_integer) { + integer_mv_precision(&res.as_mv); + } +#endif return res; } @@ -256,6 +309,12 @@ static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm, res.as_mv.row = ty; res.as_mv.col = tx; + +#if CONFIG_AMVR + if (is_integer) { + integer_mv_precision(&res.as_mv); + } +#endif return res; } -- cgit v1.2.3 From bbcc64772580c8a979288791afa02d30bc476d2e Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 19 Oct 2018 21:52:15 -0500 Subject: Update aom to v1.0.0 Update aom to commit id d14c5bb4f336ef1842046089849dee4a301fbbf0. --- third_party/aom/av1/common/mv.h | 110 +++++++++------------------------------- 1 file changed, 24 insertions(+), 86 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index 65f0f7eda..a6227f18f 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -27,6 +27,8 @@ typedef struct mv { int16_t col; } MV; +static const MV kZeroMv = { 0, 0 }; + typedef union int_mv { uint32_t as_int; MV as_mv; @@ -37,11 +39,6 @@ typedef struct mv32 { int32_t col; } MV32; -#if CONFIG_WARPED_MOTION -#define WARPED_MOTION_SORT_SAMPLES 1 -#endif // CONFIG_WARPED_MOTION - -#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION // Bits of precision used for the model #define WARPEDMODEL_PREC_BITS 16 #define WARPEDMODEL_ROW3HOMO_PREC_BITS 16 @@ -54,19 +51,8 @@ typedef struct mv32 { #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 WARP_PARAM_REDUCE_BITS 6 -// Precision bits reduction after horizontal shear -#define HORSHEAR_REDUCE_PREC_BITS 5 -#define VERSHEAR_REDUCE_PREC_BITS \ - (2 * WARPEDPIXEL_FILTER_BITS - HORSHEAR_REDUCE_PREC_BITS) - #define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS) /* clang-format off */ @@ -75,10 +61,7 @@ typedef enum { TRANSLATION = 1, // translational motion 2-parameter ROTZOOM = 2, // simplified affine with rotation + zoom only, 4-parameter AFFINE = 3, // affine, 6-parameter - HORTRAPEZOID = 4, // constrained homography, hor trapezoid, 6-parameter - VERTRAPEZOID = 5, // constrained homography, ver trapezoid, 6-parameter - HOMOGRAPHY = 6, // homography, 8-parameter - TRANS_TYPES = 7, + TRANS_TYPES, } TransformationType; /* clang-format on */ @@ -90,24 +73,13 @@ typedef enum { // GLOBAL_TRANS_TYPES 7 - up to full homography #define GLOBAL_TRANS_TYPES 4 -#if GLOBAL_TRANS_TYPES > 4 -// First bit indicates whether using identity or not -// GLOBAL_TYPE_BITS=ceiling(log2(GLOBAL_TRANS_TYPES-1)) is the -// number of bits needed to cover the remaining possibilities -#define GLOBAL_TYPE_BITS (get_msb(2 * GLOBAL_TRANS_TYPES - 3)) -#endif // GLOBAL_TRANS_TYPES > 4 - typedef struct { -#if CONFIG_GLOBAL_MOTION int global_warp_allowed; -#endif // CONFIG_GLOBAL_MOTION -#if CONFIG_WARPED_MOTION int local_warp_allowed; -#endif // CONFIG_WARPED_MOTION } WarpTypesAllowed; // number of parameters used by each transformation in TransformationTypes -static const int trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6, 6, 6, 8 }; +static const int trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6 }; // The order of values in the wmmat matrix below is best described // by the homography: @@ -118,6 +90,7 @@ typedef struct { TransformationType wmtype; int32_t wmmat[8]; int16_t alpha, beta, gamma, delta; + int8_t invalid; } WarpedMotionParams; /* clang-format off */ @@ -125,12 +98,11 @@ static const WarpedMotionParams default_warp_params = { IDENTITY, { 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0 }, - 0, 0, 0, 0 + 0, 0, 0, 0, + 0, }; /* clang-format on */ -#endif // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION -#if CONFIG_GLOBAL_MOTION // The following constants describe the various precisions // of different parameters in the global motion experiment. // @@ -187,9 +159,6 @@ static const WarpedMotionParams default_warp_params = { #define GM_ALPHA_MIN -GM_ALPHA_MAX #define GM_ROW3HOMO_MIN -GM_ROW3HOMO_MAX -// Use global motion parameters for sub8x8 blocks -#define GLOBAL_SUB8X8_USED 0 - static INLINE int block_center_x(int mi_col, BLOCK_SIZE bs) { const int bw = block_size_wide[bs]; return mi_col * MI_SIZE + bw / 2 - 1; @@ -206,7 +175,6 @@ static INLINE int convert_to_trans_prec(int allow_hp, int coor) { else return ROUND_POWER_OF_TWO_SIGNED(coor, WARPEDMODEL_PREC_BITS - 2) * 2; } -#if CONFIG_AMVR static INLINE void integer_mv_precision(MV *mv) { int mod = (mv->row % 8); if (mod != 0) { @@ -232,7 +200,6 @@ static INLINE void integer_mv_precision(MV *mv) { } } } -#endif // Convert a global motion vector into a motion vector at the centre of the // given block. // @@ -242,14 +209,15 @@ static INLINE void integer_mv_precision(MV *mv) { // represents an integer) static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm, int allow_hp, BLOCK_SIZE bsize, - int mi_col, int mi_row, int block_idx -#if CONFIG_AMVR - , - int is_integer -#endif - ) { - const int unify_bsize = CONFIG_CB4X4; + int mi_col, int mi_row, + int is_integer) { int_mv res; + + if (gm->wmtype == IDENTITY) { + res.as_int = 0; + return res; + } + const int32_t *mat = gm->wmmat; int x, y, tx, ty; @@ -265,65 +233,37 @@ static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm, res.as_mv.row = gm->wmmat[0] >> GM_TRANS_ONLY_PREC_DIFF; res.as_mv.col = gm->wmmat[1] >> GM_TRANS_ONLY_PREC_DIFF; assert(IMPLIES(1 & (res.as_mv.row | res.as_mv.col), allow_hp)); -#if CONFIG_AMVR if (is_integer) { integer_mv_precision(&res.as_mv); } -#endif return res; } - if (bsize >= BLOCK_8X8 || unify_bsize) { - x = block_center_x(mi_col, bsize); - y = block_center_y(mi_row, bsize); - } else { - x = block_center_x(mi_col, bsize); - y = block_center_y(mi_row, bsize); - x += (block_idx & 1) * MI_SIZE / 2; - y += (block_idx & 2) * MI_SIZE / 4; - } + x = block_center_x(mi_col, bsize); + y = block_center_y(mi_row, bsize); if (gm->wmtype == ROTZOOM) { assert(gm->wmmat[5] == gm->wmmat[2]); assert(gm->wmmat[4] == -gm->wmmat[3]); } - if (gm->wmtype > AFFINE) { - int xc = (int)((int64_t)mat[2] * x + (int64_t)mat[3] * y + mat[0]); - int yc = (int)((int64_t)mat[4] * x + (int64_t)mat[5] * y + mat[1]); - const int Z = (int)((int64_t)mat[6] * x + (int64_t)mat[7] * y + - (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); - xc *= 1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS - WARPEDMODEL_PREC_BITS); - yc *= 1 << (WARPEDMODEL_ROW3HOMO_PREC_BITS - WARPEDMODEL_PREC_BITS); - xc = (int)(xc > 0 ? ((int64_t)xc + Z / 2) / Z : ((int64_t)xc - Z / 2) / Z); - yc = (int)(yc > 0 ? ((int64_t)yc + Z / 2) / Z : ((int64_t)yc - Z / 2) / Z); - tx = convert_to_trans_prec(allow_hp, xc) - (x << 3); - ty = convert_to_trans_prec(allow_hp, yc) - (y << 3); - } else { - const int xc = - (mat[2] - (1 << WARPEDMODEL_PREC_BITS)) * x + mat[3] * y + mat[0]; - const int yc = - mat[4] * x + (mat[5] - (1 << WARPEDMODEL_PREC_BITS)) * y + mat[1]; - tx = convert_to_trans_prec(allow_hp, xc); - ty = convert_to_trans_prec(allow_hp, yc); - } + + const int xc = + (mat[2] - (1 << WARPEDMODEL_PREC_BITS)) * x + mat[3] * y + mat[0]; + const int yc = + mat[4] * x + (mat[5] - (1 << WARPEDMODEL_PREC_BITS)) * y + mat[1]; + tx = convert_to_trans_prec(allow_hp, xc); + ty = convert_to_trans_prec(allow_hp, yc); res.as_mv.row = ty; res.as_mv.col = tx; -#if CONFIG_AMVR if (is_integer) { integer_mv_precision(&res.as_mv); } -#endif return res; } static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) { - if (gm->wmmat[6] != 0 || gm->wmmat[7] != 0) { - if (!gm->wmmat[6] && !gm->wmmat[4]) return HORTRAPEZOID; - if (!gm->wmmat[7] && !gm->wmmat[3]) return VERTRAPEZOID; - return HOMOGRAPHY; - } if (gm->wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[4] && gm->wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[3]) { return ((!gm->wmmat[1] && !gm->wmmat[0]) ? IDENTITY : TRANSLATION); @@ -333,12 +273,10 @@ static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) { else return AFFINE; } -#endif // CONFIG_GLOBAL_MOTION typedef struct candidate_mv { int_mv this_mv; int_mv comp_mv; - uint8_t pred_diff[2]; int weight; } CANDIDATE_MV; -- cgit v1.2.3 From b8df135c97a854c2ff9b4394b016649c601177fa Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 19 Oct 2018 23:00:02 -0500 Subject: Update libaom to rev b25610052a1398032320008d69b51d2da94f5928 --- third_party/aom/av1/common/mv.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index a6227f18f..c2495640e 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -294,9 +294,6 @@ static INLINE void clamp_mv(MV *mv, int min_col, int max_col, int min_row, mv->row = clamp(mv->row, min_row, max_row); } -static INLINE int mv_has_subpel(const MV *mv) { - return (mv->row & SUBPEL_MASK) || (mv->col & SUBPEL_MASK); -} #ifdef __cplusplus } // extern "C" #endif -- cgit v1.2.3 From d2499ead93dc4298c0882fe98902acb1b5209f99 Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 19 Oct 2018 23:05:00 -0500 Subject: Update libaom to commit ID 1e227d41f0616de9548a673a83a21ef990b62591 --- third_party/aom/av1/common/mv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'third_party/aom/av1/common/mv.h') diff --git a/third_party/aom/av1/common/mv.h b/third_party/aom/av1/common/mv.h index c2495640e..5b0225192 100644 --- a/third_party/aom/av1/common/mv.h +++ b/third_party/aom/av1/common/mv.h @@ -9,8 +9,8 @@ * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ -#ifndef AV1_COMMON_MV_H_ -#define AV1_COMMON_MV_H_ +#ifndef AOM_AV1_COMMON_MV_H_ +#define AOM_AV1_COMMON_MV_H_ #include "av1/common/common.h" #include "av1/common/common_data.h" @@ -56,7 +56,7 @@ typedef struct mv32 { #define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS) /* clang-format off */ -typedef enum { +typedef enum ATTRIBUTE_PACKED { IDENTITY = 0, // identity transformation, 0-parameter TRANSLATION = 1, // translational motion 2-parameter ROTZOOM = 2, // simplified affine with rotation + zoom only, 4-parameter @@ -298,4 +298,4 @@ static INLINE void clamp_mv(MV *mv, int min_col, int max_col, int min_row, } // extern "C" #endif -#endif // AV1_COMMON_MV_H_ +#endif // AOM_AV1_COMMON_MV_H_ -- cgit v1.2.3