digiKam
sop.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  * This file is part of libde265.
6  *
7  * libde265 is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * libde265 is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with libde265. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DE265_SOP_H
22 #define DE265_SOP_H
23 
24 #include "libde265/image.h"
25 #include "libde265/sps.h"
26 #include "libde265/configparam.h"
27 //#include "libde265/encoder/encoder-context.h"
29 
30 #include <deque>
31 #include <vector>
32 
33 /*
34 struct refpic_set
35 {
36  std::vector<int> l0;
37  std::vector<int> l1;
38 };
39 */
40 
41 class encoder_context;
42 
43 
45 {
46  public:
47  pic_order_counter() { mFrameNumber=0; mPOC=0; mNumLsbBits=6; }
48 
49  void reset_poc() { mPOC=0; }
50 
51  int get_frame_number() const { return mFrameNumber; }
52 
53  int get_pic_order_count() const { return mPOC; }
55  return mPOC & ((1<<mNumLsbBits)-1);
56  }
57 
58  void advance_frame(int n=1) { mFrameNumber+=n; mPOC+=n; }
59 
60  void set_num_poc_lsb_bits(int n) { mNumLsbBits=n; }
61  int get_num_poc_lsb_bits() const { return mNumLsbBits; }
62 
63  private:
64  int mFrameNumber;
65  int mPOC;
66  int mNumLsbBits;
67 };
68 
69 
71 {
72  public:
73  sop_creator() { mEncCtx=NULL; mEncPicBuf=NULL; }
74  virtual ~sop_creator() { }
75 
76  void set_encoder_context(encoder_context* encctx) { mEncCtx=encctx; }
78 
79  /* Fills in the following fields:
80  - SPS.ref_pic_sets
81  - SPS.log2_max_pic_order_cnt_lsb
82  */
83  virtual void set_SPS_header_values() = 0;
84 
85  /* Fills in the following fields:
86  - NAL.nal_type
87  - SHDR.slice_type
88  - SHDR.slice_pic_order_cnt_lsb
89  - IMGDATA.references
90  */
91  virtual void insert_new_input_image(de265_image*) = 0;
93 
94  virtual int get_number_of_temporal_layers() const { return 1; }
95 
96  //virtual std::vector<refpic_set> get_sps_refpic_sets() const = 0;
97 
98  protected:
101 };
102 
103 
104 
106 {
107  public:
109 
110  virtual void set_SPS_header_values();
112 };
113 
114 
115 
117 {
118  public:
119  struct params {
120  params() {
121  intraPeriod.set_ID("sop-lowDelay-intraPeriod");
124  }
125 
127  config.add_option(&intraPeriod);
128  }
129 
131  };
132 
134 
135  void setParams(const params& p) { mParams=p; }
136 
137  virtual void set_SPS_header_values();
139 
140  private:
141  params mParams;
142 
143  bool isIntra(int frame) const { return (frame % mParams.intraPeriod)==0; }
144 };
145 
146 
147 #endif
Definition: configparam.h:366
void LIBDE265_API add_option(option_base *o)
Definition: encoder-context.h:39
Definition: encpicbuf.h:92
void set_ID(const char *name)
Definition: configparam.h:56
Definition: configparam.h:182
void set_minimum(int mini)
Definition: configparam.h:187
void set_default(int v)
Definition: configparam.h:203
Definition: sop.h:45
void reset_poc()
Definition: sop.h:49
void advance_frame(int n=1)
Definition: sop.h:58
int get_pic_order_count() const
Definition: sop.h:53
void set_num_poc_lsb_bits(int n)
Definition: sop.h:60
int get_pic_order_count_lsb() const
Definition: sop.h:54
int get_frame_number() const
Definition: sop.h:51
int get_num_poc_lsb_bits() const
Definition: sop.h:61
pic_order_counter()
Definition: sop.h:47
Definition: sop.h:106
virtual void insert_new_input_image(de265_image *img)
virtual void set_SPS_header_values()
Definition: sop.h:117
void setParams(const params &p)
Definition: sop.h:135
virtual void insert_new_input_image(de265_image *img)
virtual void set_SPS_header_values()
Definition: sop.h:71
virtual int get_number_of_temporal_layers() const
Definition: sop.h:94
void set_encoder_picture_buffer(encoder_picture_buffer *encbuf)
Definition: sop.h:77
virtual void insert_end_of_stream()
Definition: sop.h:92
virtual ~sop_creator()
Definition: sop.h:74
encoder_picture_buffer * mEncPicBuf
Definition: sop.h:100
sop_creator()
Definition: sop.h:73
virtual void insert_new_input_image(de265_image *)=0
void set_encoder_context(encoder_context *encctx)
Definition: sop.h:76
virtual void set_SPS_header_values()=0
encoder_context * mEncCtx
Definition: sop.h:99
Definition: image.h:222
void registerParams(config_parameters &config)
Definition: sop.h:126
option_int intraPeriod
Definition: sop.h:130