xref: /aosp_15_r20/external/libgav1/src/motion_vector.h (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1*09537850SAkhilesh Sanikop /*
2*09537850SAkhilesh Sanikop  * Copyright 2019 The libgav1 Authors
3*09537850SAkhilesh Sanikop  *
4*09537850SAkhilesh Sanikop  * Licensed under the Apache License, Version 2.0 (the "License");
5*09537850SAkhilesh Sanikop  * you may not use this file except in compliance with the License.
6*09537850SAkhilesh Sanikop  * You may obtain a copy of the License at
7*09537850SAkhilesh Sanikop  *
8*09537850SAkhilesh Sanikop  *      http://www.apache.org/licenses/LICENSE-2.0
9*09537850SAkhilesh Sanikop  *
10*09537850SAkhilesh Sanikop  * Unless required by applicable law or agreed to in writing, software
11*09537850SAkhilesh Sanikop  * distributed under the License is distributed on an "AS IS" BASIS,
12*09537850SAkhilesh Sanikop  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*09537850SAkhilesh Sanikop  * See the License for the specific language governing permissions and
14*09537850SAkhilesh Sanikop  * limitations under the License.
15*09537850SAkhilesh Sanikop  */
16*09537850SAkhilesh Sanikop 
17*09537850SAkhilesh Sanikop #ifndef LIBGAV1_SRC_MOTION_VECTOR_H_
18*09537850SAkhilesh Sanikop #define LIBGAV1_SRC_MOTION_VECTOR_H_
19*09537850SAkhilesh Sanikop 
20*09537850SAkhilesh Sanikop #include <algorithm>
21*09537850SAkhilesh Sanikop #include <array>
22*09537850SAkhilesh Sanikop #include <cstdint>
23*09537850SAkhilesh Sanikop 
24*09537850SAkhilesh Sanikop #include "src/buffer_pool.h"
25*09537850SAkhilesh Sanikop #include "src/obu_parser.h"
26*09537850SAkhilesh Sanikop #include "src/tile.h"
27*09537850SAkhilesh Sanikop #include "src/utils/array_2d.h"
28*09537850SAkhilesh Sanikop #include "src/utils/constants.h"
29*09537850SAkhilesh Sanikop #include "src/utils/types.h"
30*09537850SAkhilesh Sanikop 
31*09537850SAkhilesh Sanikop namespace libgav1 {
32*09537850SAkhilesh Sanikop 
IsGlobalMvBlock(const BlockParameters & bp,GlobalMotionTransformationType type)33*09537850SAkhilesh Sanikop constexpr bool IsGlobalMvBlock(const BlockParameters& bp,
34*09537850SAkhilesh Sanikop                                GlobalMotionTransformationType type) {
35*09537850SAkhilesh Sanikop   return (bp.y_mode == kPredictionModeGlobalMv ||
36*09537850SAkhilesh Sanikop           bp.y_mode == kPredictionModeGlobalGlobalMv) &&
37*09537850SAkhilesh Sanikop          !IsBlockDimension4(bp.size) &&
38*09537850SAkhilesh Sanikop          type > kGlobalMotionTransformationTypeTranslation;
39*09537850SAkhilesh Sanikop }
40*09537850SAkhilesh Sanikop 
41*09537850SAkhilesh Sanikop // The |contexts| output parameter may be null. If the caller does not need
42*09537850SAkhilesh Sanikop // the |contexts| output, pass nullptr as the argument.
43*09537850SAkhilesh Sanikop void FindMvStack(const Tile::Block& block, bool is_compound,
44*09537850SAkhilesh Sanikop                  MvContexts* contexts);  // 7.10.2
45*09537850SAkhilesh Sanikop 
46*09537850SAkhilesh Sanikop void FindWarpSamples(const Tile::Block& block, int* num_warp_samples,
47*09537850SAkhilesh Sanikop                      int* num_samples_scanned,
48*09537850SAkhilesh Sanikop                      int candidates[kMaxLeastSquaresSamples][4]);  // 7.10.4.
49*09537850SAkhilesh Sanikop 
50*09537850SAkhilesh Sanikop // Section 7.9.1 in the spec. But this is done per tile instead of for the whole
51*09537850SAkhilesh Sanikop // frame.
52*09537850SAkhilesh Sanikop void SetupMotionField(
53*09537850SAkhilesh Sanikop     const ObuFrameHeader& frame_header, const RefCountedBuffer& current_frame,
54*09537850SAkhilesh Sanikop     const std::array<RefCountedBufferPtr, kNumReferenceFrameTypes>&
55*09537850SAkhilesh Sanikop         reference_frames,
56*09537850SAkhilesh Sanikop     int row4x4_start, int row4x4_end, int column4x4_start, int column4x4_end,
57*09537850SAkhilesh Sanikop     TemporalMotionField* motion_field);
58*09537850SAkhilesh Sanikop 
59*09537850SAkhilesh Sanikop }  // namespace libgav1
60*09537850SAkhilesh Sanikop 
61*09537850SAkhilesh Sanikop #endif  // LIBGAV1_SRC_MOTION_VECTOR_H_
62