digiKam
tb-intrapredmode.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: Dirk Farin <farin@struktur.de>
6  *
7  * This file is part of libde265.
8  *
9  * libde265 is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation, either version 3 of
12  * the License, or (at your option) any later version.
13  *
14  * libde265 is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef TB_INTRAPREDMODE_H
24 #define TB_INTRAPREDMODE_H
25 
26 #include "libde265/nal-parser.h"
27 #include "libde265/decctx.h"
30 #include "libde265/slice.h"
31 #include "libde265/scan.h"
32 #include "libde265/intrapred.h"
33 #include "libde265/transform.h"
34 #include "libde265/fallback-dct.h"
35 #include "libde265/quality.h"
36 #include "libde265/fallback.h"
37 #include "libde265/configparam.h"
38 
39 
40 // ========== TB intra prediction mode ==========
41 
46 };
47 
48 class option_ALGO_TB_IntraPredMode : public choice_option<enum ALGO_TB_IntraPredMode>
49 {
50  public:
54  add_choice("fast-brute" ,ALGO_TB_IntraPredMode_FastBrute, true);
55  }
56 };
57 
58 
60  //TBBitrateEstim_AccurateBits,
65 };
66 
67 class option_TBBitrateEstimMethod : public choice_option<enum TBBitrateEstimMethod>
68 {
69  public:
75  }
76 };
77 
78 class Algo_TB_Split;
79 
80 
85 {
86  public:
88  virtual ~Algo_TB_IntraPredMode() { }
89 
92  const de265_image* input,
93  enc_tb* tb,
94  int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag) = 0;
95 
96  void setChildAlgo(Algo_TB_Split* algo) { mTBSplitAlgo = algo; }
97 
98  const char* name() const { return "tb-intrapredmode"; }
99 
100  protected:
102 };
103 
104 
110 };
111 
112 class option_ALGO_TB_IntraPredMode_Subset : public choice_option<enum ALGO_TB_IntraPredMode_Subset>
113 {
114  public:
120  }
121 };
122 
123 
127 {
128  public:
131  }
132 
134  for (int i=0;i<35;i++) {
135  mPredMode_enabled[i] = true;
136  mPredMode[i] = (enum IntraPredMode)i;
137  }
138 
139  mNumPredModesEnabled = 35;
140  }
141 
143  for (int i=0;i<35;i++) {
144  mPredMode_enabled[i] = false;
145  }
146 
147  mNumPredModesEnabled = 0;
148  }
149 
151  if (!mPredMode_enabled[mode]) {
152  mPredMode[mNumPredModesEnabled] = mode;
153  mPredMode_enabled[mode] = true;
154  mNumPredModesEnabled++;
155  }
156  }
157 
158  // TODO: method to disable modes
159 
161  switch (subset)
162  {
163  case ALGO_TB_IntraPredMode_Subset_All: // activate all is the default
164  for (int i=0;i<35;i++) { enableIntraPredMode((enum IntraPredMode)i); }
165  break;
169  break;
173  break;
180  break;
181  }
182  }
183 
184 
185  enum IntraPredMode getPredMode(int idx) const {
186  assert(idx<mNumPredModesEnabled);
187  return mPredMode[idx];
188  }
189 
190  int nPredModesEnabled() const {
191  return mNumPredModesEnabled;
192  }
193 
195  return mPredMode_enabled[mode];
196  }
197 
198  private:
199  IntraPredMode mPredMode[35];
200  bool mPredMode_enabled[35];
201  int mNumPredModesEnabled;
202 };
203 
204 
208 {
209  public:
210 
213  const de265_image* input,
214  enc_tb* tb,
215  int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
216 
217 
218  const char* name() const { return "tb-intrapredmode_BruteForce"; }
219 };
220 
221 
225 {
226  public:
227 
228  struct params
229  {
230  params() {
231  keepNBest.set_ID("IntraPredMode-FastBrute-keepNBest");
232  keepNBest.set_range(0,32);
234 
235  bitrateEstimMethod.set_ID("IntraPredMode-FastBrute-estimator");
236  }
237 
240  };
241 
243  config.add_option(&mParams.keepNBest);
244  config.add_option(&mParams.bitrateEstimMethod);
245  }
246 
247  void setParams(const params& p) { mParams=p; }
248 
249 
252  const de265_image* input,
253  enc_tb* tb,
254  int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
255 
256 
257  const char* name() const { return "tb-intrapredmode_FastBrute"; }
258 
259  private:
260  params mParams;
261 };
262 
263 
267 {
268  public:
269 
270  struct params
271  {
272  params() {
273  bitrateEstimMethod.set_ID("IntraPredMode-MinResidual-estimator");
274  }
275 
277  };
278 
279  void setParams(const params& p) { mParams=p; }
280 
282  config.add_option(&mParams.bitrateEstimMethod);
283  }
284 
287  const de265_image* input,
288  enc_tb* tb,
289  int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag);
290 
291  const char* name() const { return "tb-intrapredmode_MinResidual"; }
292 
293  private:
294  params mParams;
295 };
296 
297 #endif
Definition: tb-intrapredmode.h:208
const char * name() const
Definition: tb-intrapredmode.h:218
virtual enc_tb * analyze(encoder_context *, context_model_table &, const de265_image *input, enc_tb *tb, int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag)
Definition: tb-intrapredmode.h:225
void setParams(const params &p)
Definition: tb-intrapredmode.h:247
const char * name() const
Definition: tb-intrapredmode.h:257
void registerParams(config_parameters &config)
Definition: tb-intrapredmode.h:242
virtual enc_tb * analyze(encoder_context *, context_model_table &, const de265_image *input, enc_tb *tb, int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag)
Definition: tb-intrapredmode.h:267
void registerParams(config_parameters &config)
Definition: tb-intrapredmode.h:281
void setParams(const params &p)
Definition: tb-intrapredmode.h:279
const char * name() const
Definition: tb-intrapredmode.h:291
enc_tb * analyze(encoder_context *, context_model_table &, const de265_image *input, enc_tb *tb, int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag)
Definition: tb-intrapredmode.h:127
void disableAllIntraPredModes()
Definition: tb-intrapredmode.h:142
Algo_TB_IntraPredMode_ModeSubset()
Definition: tb-intrapredmode.h:129
void enableIntraPredMode(enum IntraPredMode mode)
Definition: tb-intrapredmode.h:150
bool isPredModeEnabled(enum IntraPredMode mode)
Definition: tb-intrapredmode.h:194
void enableAllIntraPredModes()
Definition: tb-intrapredmode.h:133
void enableIntraPredModeSubset(enum ALGO_TB_IntraPredMode_Subset subset)
Definition: tb-intrapredmode.h:160
enum IntraPredMode getPredMode(int idx) const
Definition: tb-intrapredmode.h:185
int nPredModesEnabled() const
Definition: tb-intrapredmode.h:190
Definition: tb-intrapredmode.h:85
Algo_TB_Split * mTBSplitAlgo
Definition: tb-intrapredmode.h:101
virtual enc_tb * analyze(encoder_context *, context_model_table &, const de265_image *input, enc_tb *tb, int TrafoDepth, int MaxTrafoDepth, int IntraSplitFlag)=0
void setChildAlgo(Algo_TB_Split *algo)
Definition: tb-intrapredmode.h:96
const char * name() const
Definition: tb-intrapredmode.h:98
Algo_TB_IntraPredMode()
Definition: tb-intrapredmode.h:87
virtual ~Algo_TB_IntraPredMode()
Definition: tb-intrapredmode.h:88
Definition: tb-split.h:47
Definition: algo.h:46
Definition: configparam.h:258
void add_choice(const std::string &s, enum ALGO_TB_IntraPredMode id, bool default_value=false)
Definition: configparam.h:264
Definition: configparam.h:366
void LIBDE265_API add_option(option_base *o)
Definition: contextmodel.h:100
Definition: encoder-types.h:135
Definition: encoder-context.h:39
Definition: tb-intrapredmode.h:113
option_ALGO_TB_IntraPredMode_Subset()
Definition: tb-intrapredmode.h:115
Definition: tb-intrapredmode.h:49
option_ALGO_TB_IntraPredMode()
Definition: tb-intrapredmode.h:51
Definition: tb-intrapredmode.h:68
option_TBBitrateEstimMethod()
Definition: tb-intrapredmode.h:70
void set_ID(const char *name)
Definition: configparam.h:56
Definition: configparam.h:182
void set_range(int mini, int maxi)
void set_default(int v)
Definition: configparam.h:203
IntraPredMode
Definition: slice.h:95
@ INTRA_ANGULAR_26
Definition: slice.h:104
@ INTRA_DC
Definition: slice.h:97
@ INTRA_ANGULAR_10
Definition: slice.h:100
@ INTRA_PLANAR
Definition: slice.h:96
Definition: tb-intrapredmode.h:229
option_TBBitrateEstimMethod bitrateEstimMethod
Definition: tb-intrapredmode.h:238
params()
Definition: tb-intrapredmode.h:230
option_int keepNBest
Definition: tb-intrapredmode.h:239
Definition: tb-intrapredmode.h:271
option_TBBitrateEstimMethod bitrateEstimMethod
Definition: tb-intrapredmode.h:276
params()
Definition: tb-intrapredmode.h:272
Definition: image.h:222
TBBitrateEstimMethod
Definition: tb-intrapredmode.h:59
@ TBBitrateEstim_SATD_DCT
Definition: tb-intrapredmode.h:63
@ TBBitrateEstim_SATD_Hadamard
Definition: tb-intrapredmode.h:64
@ TBBitrateEstim_SSD
Definition: tb-intrapredmode.h:61
@ TBBitrateEstim_SAD
Definition: tb-intrapredmode.h:62
ALGO_TB_IntraPredMode
Definition: tb-intrapredmode.h:42
@ ALGO_TB_IntraPredMode_BruteForce
Definition: tb-intrapredmode.h:43
@ ALGO_TB_IntraPredMode_FastBrute
Definition: tb-intrapredmode.h:44
@ ALGO_TB_IntraPredMode_MinResidual
Definition: tb-intrapredmode.h:45
ALGO_TB_IntraPredMode_Subset
Definition: tb-intrapredmode.h:105
@ ALGO_TB_IntraPredMode_Subset_HVPlus
Definition: tb-intrapredmode.h:107
@ ALGO_TB_IntraPredMode_Subset_DC
Definition: tb-intrapredmode.h:108
@ ALGO_TB_IntraPredMode_Subset_Planar
Definition: tb-intrapredmode.h:109
@ ALGO_TB_IntraPredMode_Subset_All
Definition: tb-intrapredmode.h:106