2015-08-06 05:00:31 +03:00
|
|
|
/*
|
2016-11-29 02:26:06 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2015-08-06 05:00:31 +03:00
|
|
|
*
|
2016-11-29 02:26:06 +03:00
|
|
|
* 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.
|
2015-08-06 05:00:31 +03:00
|
|
|
*/
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#ifndef AV1_COMMON_SCALE_H_
|
|
|
|
#define AV1_COMMON_SCALE_H_
|
2015-08-06 05:00:31 +03:00
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
#include "av1/common/mv.h"
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "aom_dsp/aom_convolve.h"
|
2015-08-06 05:00:31 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define REF_SCALE_SHIFT 14
|
|
|
|
#define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
|
|
|
|
#define REF_INVALID_SCALE -1
|
|
|
|
|
|
|
|
struct scale_factors {
|
2016-08-12 04:55:00 +03:00
|
|
|
int x_scale_fp; // horizontal fixed point scale factor
|
|
|
|
int y_scale_fp; // vertical fixed point scale factor
|
2015-08-06 05:00:31 +03:00
|
|
|
int x_step_q4;
|
|
|
|
int y_step_q4;
|
|
|
|
|
|
|
|
int (*scale_value_x)(int val, const struct scale_factors *sf);
|
|
|
|
int (*scale_value_y)(int val, const struct scale_factors *sf);
|
|
|
|
|
|
|
|
convolve_fn_t predict[2][2][2]; // horiz, vert, avg
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
2015-08-06 05:00:31 +03:00
|
|
|
highbd_convolve_fn_t highbd_predict[2][2][2]; // horiz, vert, avg
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2015-10-30 19:19:36 +03:00
|
|
|
|
|
|
|
// Functions for non-interpolating filters (those that filter zero offsets)
|
|
|
|
#if CONFIG_EXT_INTERP && SUPPORT_NONINTERPOLATING_FILTERS
|
|
|
|
convolve_fn_t predict_ni[2][2][2]; // horiz, vert, avg
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
2015-10-30 19:19:36 +03:00
|
|
|
highbd_convolve_fn_t highbd_predict_ni[2][2][2]; // horiz, vert, avg
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2015-10-30 19:19:36 +03:00
|
|
|
#endif // CONFIG_EXT_INTERP && SUPPORT_NONINTERPOLATING_FILTERS
|
2015-08-06 05:00:31 +03:00
|
|
|
};
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
MV32 av1_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf);
|
2015-08-06 05:00:31 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
|
|
|
void av1_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
|
|
|
|
int other_h, int this_w, int this_h,
|
|
|
|
int use_high);
|
2015-08-06 05:00:31 +03:00
|
|
|
#else
|
2016-08-31 00:01:10 +03:00
|
|
|
void av1_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
|
|
|
|
int other_h, int this_w, int this_h);
|
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2015-08-06 05:00:31 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
static INLINE int av1_is_valid_scale(const struct scale_factors *sf) {
|
2015-08-06 05:00:31 +03:00
|
|
|
return sf->x_scale_fp != REF_INVALID_SCALE &&
|
|
|
|
sf->y_scale_fp != REF_INVALID_SCALE;
|
|
|
|
}
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
static INLINE int av1_is_scaled(const struct scale_factors *sf) {
|
|
|
|
return av1_is_valid_scale(sf) &&
|
2015-08-06 05:00:31 +03:00
|
|
|
(sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE int valid_ref_frame_size(int ref_width, int ref_height,
|
2016-08-12 04:55:00 +03:00
|
|
|
int this_width, int this_height) {
|
|
|
|
return 2 * this_width >= ref_width && 2 * this_height >= ref_height &&
|
|
|
|
this_width <= 16 * ref_width && this_height <= 16 * ref_height;
|
2015-08-06 05:00:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // AV1_COMMON_SCALE_H_
|