MotionVector.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
  3. * Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Types.h>
  9. namespace Video::VP9 {
  10. struct MotionVector {
  11. public:
  12. constexpr MotionVector() = default;
  13. constexpr MotionVector(MotionVector const& other) = default;
  14. constexpr MotionVector(i32 row, i32 col)
  15. : m_row(row)
  16. , m_column(col)
  17. {
  18. }
  19. constexpr MotionVector& operator=(MotionVector const& other) = default;
  20. constexpr MotionVector& operator=(MotionVector&& other) = default;
  21. constexpr i32 row() const { return m_row; }
  22. constexpr void set_row(i32 row) { m_row = row; }
  23. constexpr i32 column() const { return m_column; }
  24. constexpr void set_column(i32 col) { m_column = col; }
  25. constexpr MotionVector operator+(MotionVector const& other) const
  26. {
  27. return MotionVector(this->row() + other.row(), this->column() + other.column());
  28. }
  29. constexpr MotionVector& operator+=(MotionVector const& other)
  30. {
  31. *this = *this + other;
  32. return *this;
  33. }
  34. constexpr MotionVector operator*(i32 scalar) const
  35. {
  36. return MotionVector(this->row() * scalar, this->column() * scalar);
  37. }
  38. constexpr MotionVector& operator*=(i32 scalar)
  39. {
  40. *this = *this * scalar;
  41. return *this;
  42. }
  43. constexpr bool operator==(MotionVector const& other) const
  44. {
  45. return this->row() == other.row() && this->column() == other.column();
  46. }
  47. private:
  48. i32 m_row { 0 };
  49. i32 m_column { 0 };
  50. };
  51. }