/src/aom/av1/encoder/encodemv.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved. |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 2 Clause License and |
5 | | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
6 | | * was not distributed with this source code in the LICENSE file, you can |
7 | | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
8 | | * Media Patent License 1.0 was not distributed with this source code in the |
9 | | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
10 | | */ |
11 | | |
12 | | #ifndef AOM_AV1_ENCODER_ENCODEMV_H_ |
13 | | #define AOM_AV1_ENCODER_ENCODEMV_H_ |
14 | | |
15 | | #include "av1/encoder/encoder.h" |
16 | | |
17 | | #ifdef __cplusplus |
18 | | extern "C" { |
19 | | #endif |
20 | | |
21 | | void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, ThreadData *td, const MV *mv, |
22 | | const MV *ref, nmv_context *mvctx, int usehp); |
23 | | |
24 | | void av1_update_mv_stats(const MV *mv, const MV *ref, nmv_context *mvctx, |
25 | | MvSubpelPrecision precision); |
26 | | |
27 | | void av1_build_nmv_cost_table(int *mvjoint, int *mvcost[2], |
28 | | const nmv_context *mvctx, |
29 | | MvSubpelPrecision precision); |
30 | | void av1_build_nmv_component_cost_table(int *mvcost, |
31 | | const nmv_component *const mvcomp, |
32 | | MvSubpelPrecision precision); |
33 | | |
34 | | void av1_update_mv_count(ThreadData *td); |
35 | | |
36 | | void av1_encode_dv(aom_writer *w, const MV *mv, const MV *ref, |
37 | | nmv_context *mvctx); |
38 | | int_mv av1_get_ref_mv(const MACROBLOCK *x, int ref_idx); |
39 | | int_mv av1_get_ref_mv_from_stack(int ref_idx, |
40 | | const MV_REFERENCE_FRAME *ref_frame, |
41 | | int ref_mv_idx, |
42 | | const MB_MODE_INFO_EXT *mbmi_ext); |
43 | | void av1_find_best_ref_mvs_from_stack(int allow_hp, |
44 | | const MB_MODE_INFO_EXT *mbmi_ext, |
45 | | MV_REFERENCE_FRAME ref_frame, |
46 | | int_mv *nearest_mv, int_mv *near_mv, |
47 | | int is_integer); |
48 | | |
49 | 0 | static inline MV_JOINT_TYPE av1_get_mv_joint(const MV *mv) { |
50 | | // row: Z col: Z | MV_JOINT_ZERO (0) |
51 | | // row: Z col: NZ | MV_JOINT_HNZVZ (1) |
52 | | // row: NZ col: Z | MV_JOINT_HZVNZ (2) |
53 | | // row: NZ col: NZ | MV_JOINT_HNZVNZ (3) |
54 | 0 | return (!!mv->col) | ((!!mv->row) << 1); |
55 | 0 | } Unexecuted instantiation: bitstream.c:av1_get_mv_joint Unexecuted instantiation: encodeframe.c:av1_get_mv_joint Unexecuted instantiation: encodemv.c:av1_get_mv_joint Unexecuted instantiation: encoder.c:av1_get_mv_joint Unexecuted instantiation: firstpass.c:av1_get_mv_joint Unexecuted instantiation: mcomp.c:av1_get_mv_joint Unexecuted instantiation: mv_prec.c:av1_get_mv_joint Unexecuted instantiation: partition_search.c:av1_get_mv_joint Unexecuted instantiation: ratectrl.c:av1_get_mv_joint Unexecuted instantiation: rd.c:av1_get_mv_joint Unexecuted instantiation: rdopt.c:av1_get_mv_joint Unexecuted instantiation: nonrd_pickmode.c:av1_get_mv_joint Unexecuted instantiation: nonrd_opt.c:av1_get_mv_joint Unexecuted instantiation: motion_search_facade.c:av1_get_mv_joint |
56 | | |
57 | 0 | static inline int av1_mv_class_base(MV_CLASS_TYPE c) { |
58 | 0 | return c ? CLASS0_SIZE << (c + 2) : 0; |
59 | 0 | } Unexecuted instantiation: bitstream.c:av1_mv_class_base Unexecuted instantiation: encodeframe.c:av1_mv_class_base Unexecuted instantiation: encodemv.c:av1_mv_class_base Unexecuted instantiation: encoder.c:av1_mv_class_base Unexecuted instantiation: firstpass.c:av1_mv_class_base Unexecuted instantiation: mcomp.c:av1_mv_class_base Unexecuted instantiation: mv_prec.c:av1_mv_class_base Unexecuted instantiation: partition_search.c:av1_mv_class_base Unexecuted instantiation: ratectrl.c:av1_mv_class_base Unexecuted instantiation: rd.c:av1_mv_class_base Unexecuted instantiation: rdopt.c:av1_mv_class_base Unexecuted instantiation: nonrd_pickmode.c:av1_mv_class_base Unexecuted instantiation: nonrd_opt.c:av1_mv_class_base Unexecuted instantiation: motion_search_facade.c:av1_mv_class_base |
60 | | |
61 | | // If n != 0, returns the floor of log base 2 of n. If n == 0, returns 0. |
62 | 0 | static inline uint8_t av1_log_in_base_2(unsigned int n) { |
63 | | // get_msb() is only valid when n != 0. |
64 | 0 | return n == 0 ? 0 : get_msb(n); |
65 | 0 | } Unexecuted instantiation: bitstream.c:av1_log_in_base_2 Unexecuted instantiation: encodeframe.c:av1_log_in_base_2 Unexecuted instantiation: encodemv.c:av1_log_in_base_2 Unexecuted instantiation: encoder.c:av1_log_in_base_2 Unexecuted instantiation: firstpass.c:av1_log_in_base_2 Unexecuted instantiation: mcomp.c:av1_log_in_base_2 Unexecuted instantiation: mv_prec.c:av1_log_in_base_2 Unexecuted instantiation: partition_search.c:av1_log_in_base_2 Unexecuted instantiation: ratectrl.c:av1_log_in_base_2 Unexecuted instantiation: rd.c:av1_log_in_base_2 Unexecuted instantiation: rdopt.c:av1_log_in_base_2 Unexecuted instantiation: nonrd_pickmode.c:av1_log_in_base_2 Unexecuted instantiation: nonrd_opt.c:av1_log_in_base_2 Unexecuted instantiation: motion_search_facade.c:av1_log_in_base_2 |
66 | | |
67 | 0 | static inline MV_CLASS_TYPE av1_get_mv_class(int z, int *offset) { |
68 | 0 | assert(z >= 0); |
69 | 0 | const MV_CLASS_TYPE c = (MV_CLASS_TYPE)av1_log_in_base_2(z >> 3); |
70 | 0 | assert(c <= MV_CLASS_10); |
71 | 0 | if (offset) *offset = z - av1_mv_class_base(c); |
72 | 0 | return c; |
73 | 0 | } Unexecuted instantiation: bitstream.c:av1_get_mv_class Unexecuted instantiation: encodeframe.c:av1_get_mv_class Unexecuted instantiation: encodemv.c:av1_get_mv_class Unexecuted instantiation: encoder.c:av1_get_mv_class Unexecuted instantiation: firstpass.c:av1_get_mv_class Unexecuted instantiation: mcomp.c:av1_get_mv_class Unexecuted instantiation: mv_prec.c:av1_get_mv_class Unexecuted instantiation: partition_search.c:av1_get_mv_class Unexecuted instantiation: ratectrl.c:av1_get_mv_class Unexecuted instantiation: rd.c:av1_get_mv_class Unexecuted instantiation: rdopt.c:av1_get_mv_class Unexecuted instantiation: nonrd_pickmode.c:av1_get_mv_class Unexecuted instantiation: nonrd_opt.c:av1_get_mv_class Unexecuted instantiation: motion_search_facade.c:av1_get_mv_class |
74 | | |
75 | | static inline int av1_check_newmv_joint_nonzero(const AV1_COMMON *cm, |
76 | 0 | MACROBLOCK *const x) { |
77 | 0 | (void)cm; |
78 | 0 | MACROBLOCKD *xd = &x->e_mbd; |
79 | 0 | MB_MODE_INFO *mbmi = xd->mi[0]; |
80 | 0 | const PREDICTION_MODE this_mode = mbmi->mode; |
81 | 0 | if (this_mode == NEW_NEWMV) { |
82 | 0 | const int_mv ref_mv_0 = av1_get_ref_mv(x, 0); |
83 | 0 | const int_mv ref_mv_1 = av1_get_ref_mv(x, 1); |
84 | 0 | if (mbmi->mv[0].as_int == ref_mv_0.as_int || |
85 | 0 | mbmi->mv[1].as_int == ref_mv_1.as_int) { |
86 | 0 | return 0; |
87 | 0 | } |
88 | 0 | } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) { |
89 | 0 | const int_mv ref_mv_1 = av1_get_ref_mv(x, 1); |
90 | 0 | if (mbmi->mv[1].as_int == ref_mv_1.as_int) { |
91 | 0 | return 0; |
92 | 0 | } |
93 | 0 | } else if (this_mode == NEW_NEARESTMV || this_mode == NEW_NEARMV) { |
94 | 0 | const int_mv ref_mv_0 = av1_get_ref_mv(x, 0); |
95 | 0 | if (mbmi->mv[0].as_int == ref_mv_0.as_int) { |
96 | 0 | return 0; |
97 | 0 | } |
98 | 0 | } else if (this_mode == NEWMV) { |
99 | 0 | const int_mv ref_mv_0 = av1_get_ref_mv(x, 0); |
100 | 0 | if (mbmi->mv[0].as_int == ref_mv_0.as_int) { |
101 | 0 | return 0; |
102 | 0 | } |
103 | 0 | } |
104 | 0 | return 1; |
105 | 0 | } Unexecuted instantiation: bitstream.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: encodeframe.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: encodemv.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: encoder.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: firstpass.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: mcomp.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: mv_prec.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: partition_search.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: ratectrl.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: rd.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: rdopt.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: nonrd_pickmode.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: nonrd_opt.c:av1_check_newmv_joint_nonzero Unexecuted instantiation: motion_search_facade.c:av1_check_newmv_joint_nonzero |
106 | | #ifdef __cplusplus |
107 | | } // extern "C" |
108 | | #endif |
109 | | |
110 | | #endif // AOM_AV1_ENCODER_ENCODEMV_H_ |