blob: 1437fcd9c7ee23d608ffc730afe7af32da9cd08d [file] [log] [blame]
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -07001/*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef VP9_COMMON_VP9_SCALE_H_
12#define VP9_COMMON_VP9_SCALE_H_
13
14#include "vp9/common/vp9_mv.h"
15#include "vp9/common/vp9_convolve.h"
16
James Zernc8ba8c52013-08-22 18:40:34 -070017#define REF_SCALE_SHIFT 14
18#define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
19#define REF_INVALID_SCALE -1
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070020
Yunqing Wang175c3132013-10-18 08:56:30 -070021struct scale_factors;
22struct scale_factors_common {
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070023 int x_scale_fp; // horizontal fixed point scale factor
24 int y_scale_fp; // vertical fixed point scale factor
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070025 int x_step_q4;
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070026 int y_step_q4;
27
Yunqing Wang175c3132013-10-18 08:56:30 -070028 int (*scale_value_x)(int val, const struct scale_factors_common *sfc);
29 int (*scale_value_y)(int val, const struct scale_factors_common *sfc);
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070030 void (*set_scaled_offsets)(struct scale_factors *scale, int row, int col);
31 MV32 (*scale_mv)(const MV *mv, const struct scale_factors *scale);
32
33 convolve_fn_t predict[2][2][2]; // horiz, vert, avg
34};
35
Yunqing Wang175c3132013-10-18 08:56:30 -070036struct scale_factors {
37 int x_offset_q4;
38 int y_offset_q4;
39 const struct scale_factors_common *sfc;
40};
41
Dmitry Kovalev3c426572013-08-22 15:19:05 -070042void vp9_setup_scale_factors_for_frame(struct scale_factors *scale,
Yunqing Wang175c3132013-10-18 08:56:30 -070043 struct scale_factors_common *scale_comm,
Dmitry Kovalev8ffe85a2013-08-09 14:07:09 -070044 int other_w, int other_h,
45 int this_w, int this_h);
46
Yunqing Wang175c3132013-10-18 08:56:30 -070047static int vp9_is_valid_scale(const struct scale_factors_common *sfc) {
48 return sfc->x_scale_fp != REF_INVALID_SCALE &&
49 sfc->y_scale_fp != REF_INVALID_SCALE;
Dmitry Kovalev3c426572013-08-22 15:19:05 -070050}
51
Yunqing Wang175c3132013-10-18 08:56:30 -070052static int vp9_is_scaled(const struct scale_factors_common *sfc) {
53 return sfc->x_scale_fp != REF_NO_SCALE ||
54 sfc->y_scale_fp != REF_NO_SCALE;
Dmitry Kovalev640dea42013-08-22 14:04:59 -070055}
56
Jim Bankoski716d37f2013-09-29 18:58:58 -070057#endif // VP9_COMMON_VP9_SCALE_H_