digiKam
algo.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 ALGO_H
24 #define ALGO_H
25 
27 
28 
29 /* When entering the next recursion level, it is assumed that
30  a valid CB structure is passed down. Ownership is transferred to
31  the new algorithm. That algorithm passes back a (possibly different)
32  CB structure that the first algorithm should use. The receiving
33  algorithm will be the owner of the passed back algorithm.
34  The original CB structure might have been deleted in the called algorithm.
35 
36  When using CodingOptions, it is important to set the passed back
37  enc_node in the CodingOption (set_node()), so that the CodingOption
38  can correctly handle ownership and delete nodes as needed.
39 
40  The context_model_table passed down is at the current state.
41  When the algorithm returns, the state should represent the state
42  after running this algorithm.
43  */
44 
45 class Algo
46 {
47  public:
48  virtual ~Algo() { }
49 
50  virtual const char* name() const { return "noname"; }
51 
52 #ifdef DE265_LOG_DEBUG
53  void enter();
54  void descend(const enc_node* node,const char* option_description, ...);
55  void ascend(const enc_node* resultNode=NULL, const char* fmt=NULL, ...);
56  void leaf(const enc_node* node,const char* option_description, ...);
57 #else
58  inline void enter() { }
59  inline void descend(const enc_node*,const char*, ...) { }
60  inline void ascend(const enc_node* resultNode=NULL,const char* fmt=NULL, ...) { }
61  inline void leaf(const enc_node*,const char*, ...) { }
62 #endif
63 };
64 
65 
66 class Algo_CB : public Algo
67 {
68  public:
69  virtual ~Algo_CB() { }
70 
71  /* The context_model_table that is provided can be modified and
72  even released in the function. On exit, it should be filled with
73  a (optionally new) context_model_table that represents the state
74  after encoding the syntax element. However, to speed up computation,
75  it is also allowed to not modify the context_model_table at all.
76  */
79  enc_cb* cb) = 0;
80 };
81 
82 
83 class Algo_PB : public Algo
84 {
85  public:
86  virtual ~Algo_PB() { }
87 
90  enc_cb* cb,
91  int PBidx, int x,int y,int w,int h) = 0;
92 };
93 
94 
95 #endif
Definition: algo.h:67
virtual ~Algo_CB()
Definition: algo.h:69
virtual enc_cb * analyze(encoder_context *, context_model_table &, enc_cb *cb)=0
Definition: algo.h:84
virtual enc_cb * analyze(encoder_context *, context_model_table &, enc_cb *cb, int PBidx, int x, int y, int w, int h)=0
virtual ~Algo_PB()
Definition: algo.h:86
Definition: algo.h:46
void leaf(const enc_node *, const char *,...)
Definition: algo.h:61
void ascend(const enc_node *resultNode=NULL, const char *fmt=NULL,...)
Definition: algo.h:60
virtual const char * name() const
Definition: algo.h:50
void enter()
Definition: algo.h:58
virtual ~Algo()
Definition: algo.h:48
void descend(const enc_node *, const char *,...)
Definition: algo.h:59
Definition: contextmodel.h:100
Definition: encoder-types.h:248
Definition: encoder-types.h:74
Definition: encoder-context.h:39