digiKam
encpicbuf.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_ENCPICBUF_H
22 #define DE265_ENCPICBUF_H
23 
24 #include "libde265/image.h"
25 #include "libde265/sps.h"
26 
27 #include <deque>
28 #include <vector>
29 
30 
31 /* TODO: we need a way to quickly access pictures with a stable ID, like in the DPB.
32  */
33 
34 struct image_data
35 {
38 
40 
41  const de265_image* input; // owner
44 
45  // SOP metadata
46 
47  nal_header nal; // TODO: image split into several NALs (always same NAL header?)
48 
49  slice_segment_header shdr; // TODO: multi-slice pictures
50 
51  std::vector<int> ref0;
52  std::vector<int> ref1;
53  std::vector<int> longterm;
54  std::vector<int> keep;
55  int sps_index;
57  bool is_intra; // TODO: remove, use shdr.slice_type instead
58 
59  /* unprocessed only input image has been inserted, no metadata
60  sop_metadata_available sop-creator has filled in references and skipping metadata
61  a) encoding encoding started for this frame, reconstruction image was created
62  . keep_for_reference encoding finished, picture is kept in the buffer for reference
63  b) skipped image was skipped, no encoding was done, no reconstruction image
64  */
65  enum state {
71  } state;
72 
74 
75  bool mark_used;
76 
77 
78  // --- SOP structure ---
79 
80  void set_intra();
81  void set_NAL_type(uint8_t nalType);
82  void set_NAL_temporal_id(int temporal_id);
83  void set_references(int sps_index, // -1 -> custom
84  const std::vector<int>& l0, const std::vector<int>& l1,
85  const std::vector<int>& lt,
86  const std::vector<int>& keepMoreReferences);
88 };
89 
90 
92 {
93  public:
96 
97 
98  // --- input pushed by the input process ---
99 
100  void reset();
101 
104 
105 
106  // --- SOP structure ---
107 
108  void sop_metadata_commit(int frame_number); // note: frame_number is only for consistency checking
109 
110 
111  // --- infos pushed by encoder ---
112 
113  void mark_encoding_started(int frame_number);
114  void set_prediction_image(int frame_number, de265_image*); // store it just for debugging fun
115  void set_reconstruction_image(int frame_number, de265_image*);
116  void mark_encoding_finished(int frame_number);
117 
118 
119 
120  // --- data access ---
121 
123  image_data* get_next_picture_to_encode(); // or return NULL if no picture is available
124  const image_data* get_picture(int frame_number) const;
125  bool has_picture(int frame_number) const;
126 
128  assert(!mImages.empty());
129  return mImages.front();
130  }
131 
132  void mark_image_is_outputted(int frame_number);
133  void release_input_image(int frame_number);
134 
135  private:
136  bool mEndOfStream;
137  std::deque<image_data*> mImages;
138 
139  void flush_images();
140  image_data* get_picture(int frame_number);
141 };
142 
143 
144 #endif
Definition: encpicbuf.h:92
image_data * get_next_picture_to_encode()
void set_reconstruction_image(int frame_number, de265_image *)
const image_data * get_picture(int frame_number) const
void release_input_image(int frame_number)
void mark_encoding_started(int frame_number)
const image_data * peek_next_picture_to_encode() const
Definition: encpicbuf.h:127
void mark_encoding_finished(int frame_number)
bool has_picture(int frame_number) const
bool have_more_frames_to_encode() const
image_data * insert_next_image_in_encoding_order(const de265_image *, int frame_number)
void mark_image_is_outputted(int frame_number)
void sop_metadata_commit(int frame_number)
void set_prediction_image(int frame_number, de265_image *)
Definition: slice.h:130
Definition: image.h:222
Definition: encpicbuf.h:35
std::vector< int > ref0
Definition: encpicbuf.h:51
state
Definition: encpicbuf.h:65
@ state_skipped
Definition: encpicbuf.h:70
@ state_unprocessed
Definition: encpicbuf.h:66
@ state_encoding
Definition: encpicbuf.h:68
@ state_keep_for_reference
Definition: encpicbuf.h:69
@ state_sop_metadata_available
Definition: encpicbuf.h:67
void set_skip_priority(int skip_priority)
nal_header nal
Definition: encpicbuf.h:47
bool mark_used
Definition: encpicbuf.h:75
bool is_in_output_queue
Definition: encpicbuf.h:73
void set_NAL_temporal_id(int temporal_id)
bool is_intra
Definition: encpicbuf.h:57
de265_image * reconstruction
Definition: encpicbuf.h:43
slice_segment_header shdr
Definition: encpicbuf.h:49
const de265_image * input
Definition: encpicbuf.h:41
de265_image * prediction
Definition: encpicbuf.h:42
void set_references(int sps_index, const std::vector< int > &l0, const std::vector< int > &l1, const std::vector< int > &lt, const std::vector< int > &keepMoreReferences)
std::vector< int > longterm
Definition: encpicbuf.h:53
void set_NAL_type(uint8_t nalType)
int frame_number
Definition: encpicbuf.h:39
int skip_priority
Definition: encpicbuf.h:56
std::vector< int > ref1
Definition: encpicbuf.h:52
std::vector< int > keep
Definition: encpicbuf.h:54
void set_intra()
int sps_index
Definition: encpicbuf.h:55
Definition: nal.h:36