• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CONTEXT_TREE_H_
13 #define AOM_AV1_ENCODER_CONTEXT_TREE_H_
14 
15 #include "config/aom_config.h"
16 
17 #include "av1/common/blockd.h"
18 #include "av1/encoder/block.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 struct AV1_COMP;
25 struct AV1Common;
26 struct ThreadData;
27 
28 // Structure to hold snapshot of coding context during the mode picking process
29 typedef struct {
30   MB_MODE_INFO mic;
31   MB_MODE_INFO_EXT_FRAME mbmi_ext_best;
32   uint8_t *color_index_map[2];
33   uint8_t *blk_skip;
34 
35   tran_low_t *coeff[MAX_MB_PLANE];
36   tran_low_t *qcoeff[MAX_MB_PLANE];
37   tran_low_t *dqcoeff[MAX_MB_PLANE];
38   uint16_t *eobs[MAX_MB_PLANE];
39   uint8_t *txb_entropy_ctx[MAX_MB_PLANE];
40   uint8_t *tx_type_map;
41 
42   int num_4x4_blk;
43   // For current partition, only if all Y, U, and V transform blocks'
44   // coefficients are quantized to 0, skippable is set to 1.
45   int skippable;
46 #if CONFIG_INTERNAL_STATS
47   THR_MODES best_mode_index;
48 #endif  // CONFIG_INTERNAL_STATS
49   int hybrid_pred_diff;
50   int comp_pred_diff;
51   int single_pred_diff;
52 
53   RD_STATS rd_stats;
54 
55   int rd_mode_is_ready;  // Flag to indicate whether rd pick mode decision has
56                          // been made.
57 
58   // motion vector cache for adaptive motion search control in partition
59   // search loop
60   MV pred_mv[REF_FRAMES];
61   PARTITION_TYPE partition;
62 } PICK_MODE_CONTEXT;
63 
64 typedef struct PC_TREE {
65   PARTITION_TYPE partitioning;
66   BLOCK_SIZE block_size;
67   PICK_MODE_CONTEXT none;
68   PICK_MODE_CONTEXT horizontal[2];
69   PICK_MODE_CONTEXT vertical[2];
70   PICK_MODE_CONTEXT horizontala[3];
71   PICK_MODE_CONTEXT horizontalb[3];
72   PICK_MODE_CONTEXT verticala[3];
73   PICK_MODE_CONTEXT verticalb[3];
74   PICK_MODE_CONTEXT horizontal4[4];
75   PICK_MODE_CONTEXT vertical4[4];
76   struct PC_TREE *split[4];
77   int index;
78 
79   // Simple motion search_features
80   FULLPEL_MV start_mvs[REF_FRAMES];
81   unsigned int sms_none_feat[2];
82   unsigned int sms_rect_feat[8];
83   int sms_none_valid;
84   int sms_rect_valid;
85 } PC_TREE;
86 
87 void av1_setup_pc_tree(struct AV1_COMP *const cpi, struct ThreadData *td);
88 void av1_free_pc_tree(const struct AV1_COMP *const cpi, struct ThreadData *td,
89                       const int num_planes, BLOCK_SIZE sb_size);
90 void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
91                            PICK_MODE_CONTEXT *src_ctx);
92 
93 #ifdef __cplusplus
94 }  // extern "C"
95 #endif
96 
97 #endif  // AOM_AV1_ENCODER_CONTEXT_TREE_H_
98