digiKam
contextmodel.h
Go to the documentation of this file.
1 /*
2  * H.265 video codec.
3  * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
4  *
5  * Authors: struktur AG, Dirk Farin <farin@struktur.de>
6  * Min Chen <chenm003@163.com>
7  *
8  * This file is part of libde265.
9  *
10  * libde265 is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as
12  * published by the Free Software Foundation, either version 3 of
13  * the License, or (at your option) any later version.
14  *
15  * libde265 is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef DE265_CONTEXTMODEL_H
25 #define DE265_CONTEXTMODEL_H
26 
27 #include "libde265/cabac.h"
28 #include "libde265/de265.h"
29 
30 #include <string.h>
31 #include <string>
32 
33 
34 struct context_model {
35  uint8_t MPSbit : 1;
36  uint8_t state : 7;
37 
38  bool operator==(context_model b) const { return state==b.state && MPSbit==b.MPSbit; }
39  bool operator!=(context_model b) const { return state!=b.state || MPSbit!=b.MPSbit; }
40 };
41 
42 
44  // SAO
47 
48  // CB-tree
51 
52  // intra-prediction
56 
57  // transform-tree
63 
64  // residual
71 
76 
77  // motion
90 };
91 
92 
93 
95  int initType,
96  int QPY);
97 
98 
100 {
101  public:
105 
106  void init(int initType, int QPY);
107  void release();
108  void decouple();
110  context_model_table copy() const { context_model_table t=*this; t.decouple(); return t; }
111 
112  bool empty() const { return refcnt != NULL; }
113 
114  context_model& operator[](int i) { return model[i]; }
115 
117 
118  bool operator==(const context_model_table&) const;
119 
120  std::string debug_dump() const;
121 
122  private:
123  void decouple_or_alloc_with_empty_data();
124 
125  context_model* model; // [CONTEXT_MODEL_TABLE_LENGTH]
126  int* refcnt;
127 };
128 
129 
130 #endif
Definition: contextmodel.h:100
context_model_table & operator=(const context_model_table &)
std::string debug_dump() const
bool empty() const
Definition: contextmodel.h:112
context_model_table transfer()
context_model & operator[](int i)
Definition: contextmodel.h:114
context_model_table(const context_model_table &)
void init(int initType, int QPY)
bool operator==(const context_model_table &) const
context_model_table copy() const
Definition: contextmodel.h:110
context_model_index
Definition: contextmodel.h:43
@ CONTEXT_MODEL_RES_SCALE_SIGN_FLAG
Definition: contextmodel.h:88
@ CONTEXT_MODEL_CU_QP_DELTA_ABS
Definition: contextmodel.h:72
@ CONTEXT_MODEL_LOG2_RES_SCALE_ABS_PLUS1
Definition: contextmodel.h:87
@ CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER2_FLAG
Definition: contextmodel.h:70
@ CONTEXT_MODEL_SAO_MERGE_FLAG
Definition: contextmodel.h:45
@ CONTEXT_MODEL_CBF_LUMA
Definition: contextmodel.h:58
@ CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_FLAG
Definition: contextmodel.h:61
@ CONTEXT_MODEL_SPLIT_TRANSFORM_FLAG
Definition: contextmodel.h:60
@ CONTEXT_MODEL_RDPCM_FLAG
Definition: contextmodel.h:74
@ CONTEXT_MODEL_PART_MODE
Definition: contextmodel.h:53
@ CONTEXT_MODEL_TABLE_LENGTH
Definition: contextmodel.h:89
@ CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_Y_PREFIX
Definition: contextmodel.h:66
@ CONTEXT_MODEL_PREV_INTRA_LUMA_PRED_FLAG
Definition: contextmodel.h:54
@ CONTEXT_MODEL_CBF_CHROMA
Definition: contextmodel.h:59
@ CONTEXT_MODEL_COEFF_ABS_LEVEL_GREATER1_FLAG
Definition: contextmodel.h:69
@ CONTEXT_MODEL_CODED_SUB_BLOCK_FLAG
Definition: contextmodel.h:67
@ CONTEXT_MODEL_SAO_TYPE_IDX
Definition: contextmodel.h:46
@ CONTEXT_MODEL_TRANSFORM_SKIP_FLAG
Definition: contextmodel.h:73
@ CONTEXT_MODEL_CU_SKIP_FLAG
Definition: contextmodel.h:50
@ CONTEXT_MODEL_INTRA_CHROMA_PRED_MODE
Definition: contextmodel.h:55
@ CONTEXT_MODEL_RQT_ROOT_CBF
Definition: contextmodel.h:83
@ CONTEXT_MODEL_LAST_SIGNIFICANT_COEFFICIENT_X_PREFIX
Definition: contextmodel.h:65
@ CONTEXT_MODEL_MERGE_FLAG
Definition: contextmodel.h:78
@ CONTEXT_MODEL_MVP_LX_FLAG
Definition: contextmodel.h:82
@ CONTEXT_MODEL_SIGNIFICANT_COEFF_FLAG
Definition: contextmodel.h:68
@ CONTEXT_MODEL_CU_TRANSQUANT_BYPASS_FLAG
Definition: contextmodel.h:86
@ CONTEXT_MODEL_MERGE_IDX
Definition: contextmodel.h:79
@ CONTEXT_MODEL_INTER_PRED_IDC
Definition: contextmodel.h:85
@ CONTEXT_MODEL_SPLIT_CU_FLAG
Definition: contextmodel.h:49
@ CONTEXT_MODEL_REF_IDX_LX
Definition: contextmodel.h:84
@ CONTEXT_MODEL_PRED_MODE_FLAG
Definition: contextmodel.h:80
@ CONTEXT_MODEL_RDPCM_DIR
Definition: contextmodel.h:75
@ CONTEXT_MODEL_CU_CHROMA_QP_OFFSET_IDX
Definition: contextmodel.h:62
@ CONTEXT_MODEL_ABS_MVD_GREATER01_FLAG
Definition: contextmodel.h:81
void initialize_CABAC_models(context_model context_model_table[CONTEXT_MODEL_TABLE_LENGTH], int initType, int QPY)
Definition: contextmodel.h:34
uint8_t state
Definition: contextmodel.h:36
bool operator!=(context_model b) const
Definition: contextmodel.h:39
uint8_t MPSbit
Definition: contextmodel.h:35
bool operator==(context_model b) const
Definition: contextmodel.h:38