vp9_scale.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  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. #ifndef VP9_COMMON_VP9_SCALE_H_
  11. #define VP9_COMMON_VP9_SCALE_H_
  12. #include "vp9/common/vp9_mv.h"
  13. #include "vpx_dsp/vpx_convolve.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #define REF_SCALE_SHIFT 14
  18. #define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
  19. #define REF_INVALID_SCALE -1
  20. struct scale_factors {
  21. int x_scale_fp; // horizontal fixed point scale factor
  22. int y_scale_fp; // vertical fixed point scale factor
  23. int x_step_q4;
  24. int y_step_q4;
  25. int (*scale_value_x)(int val, const struct scale_factors *sf);
  26. int (*scale_value_y)(int val, const struct scale_factors *sf);
  27. convolve_fn_t predict[2][2][2]; // horiz, vert, avg
  28. #if CONFIG_VP9_HIGHBITDEPTH
  29. highbd_convolve_fn_t highbd_predict[2][2][2]; // horiz, vert, avg
  30. #endif
  31. };
  32. MV32 vp9_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf);
  33. #if CONFIG_VP9_HIGHBITDEPTH
  34. void vp9_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
  35. int other_h, int this_w, int this_h,
  36. int use_high);
  37. #else
  38. void vp9_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
  39. int other_h, int this_w, int this_h);
  40. #endif
  41. static INLINE int vp9_is_valid_scale(const struct scale_factors *sf) {
  42. return sf->x_scale_fp != REF_INVALID_SCALE &&
  43. sf->y_scale_fp != REF_INVALID_SCALE;
  44. }
  45. static INLINE int vp9_is_scaled(const struct scale_factors *sf) {
  46. return vp9_is_valid_scale(sf) &&
  47. (sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE);
  48. }
  49. static INLINE int valid_ref_frame_size(int ref_width, int ref_height,
  50. int this_width, int this_height) {
  51. return 2 * this_width >= ref_width && 2 * this_height >= ref_height &&
  52. this_width <= 16 * ref_width && this_height <= 16 * ref_height;
  53. }
  54. #ifdef __cplusplus
  55. } // extern "C"
  56. #endif
  57. #endif // VP9_COMMON_VP9_SCALE_H_