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