digiKam
dpb.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_DPB_H
22 #define DE265_DPB_H
23 
24 #include "libde265/image.h"
25 #include "libde265/sps.h"
26 
27 #include <deque>
28 #include <vector>
29 
30 class decoder_context;
31 
33 public:
36 
37  void set_max_size_of_DPB(int n) { max_images_in_DPB=n; }
38  void set_norm_size_of_DPB(int n) { norm_images_in_DPB=n; }
39 
40  /* Alloc a new image in the DPB and return its index.
41  If there is no space for a new image, return -1. */
42  int new_image(std::shared_ptr<const seq_parameter_set> sps, decoder_context* decctx,
43  de265_PTS pts, void* user_data, bool isOutputImage);
44 
45  /* Check for a free slot in the DPB. There are some slots reserved for
46  unavailable reference frames. If high_priority==true, these reserved slots
47  are included in the check. */
48  bool has_free_dpb_picture(bool high_priority) const;
49 
50  /* Remove all pictures from DPB and queues. Decoding should be stopped while calling this. */
51  void clear();
52 
53  int size() const { return dpb.size(); }
54 
55  /* Raw access to the images. */
56 
57  /* */ de265_image* get_image(int index) {
58  if (index>=dpb.size()) return NULL;
59  return dpb[index];
60  }
61 
62  const de265_image* get_image(int index) const {
63  if (index>=dpb.size()) return NULL;
64  return dpb[index];
65  }
66 
67  /* Search DPB for the slot index of a specific picture. */
68  int DPB_index_of_picture_with_POC(int poc, int currentID, bool preferLongTerm=false) const;
69  int DPB_index_of_picture_with_LSB(int lsb, int currentID, bool preferLongTerm=false) const;
70  int DPB_index_of_picture_with_ID (int id) const;
71 
72 
73  // --- reorder buffer ---
74 
76  reorder_output_queue.push_back(img);
77  }
78 
79  int num_pictures_in_reorder_buffer() const { return reorder_output_queue.size(); }
80 
81  // move next picture in reorder buffer to output queue
83 
84  // Move all pictures in reorder buffer to output buffer. Return true if there were any pictures.
86 
87 
88  // --- output buffer ---
89 
90  int num_pictures_in_output_queue() const { return image_output_queue.size(); }
91 
92  /* Get the next picture in the output queue, but do not remove it from the queue. */
93  struct de265_image* get_next_picture_in_output_queue() const { return image_output_queue.front(); }
94 
95  /* Remove the next picture in the output queue. */
97 
98 
99  // --- debug ---
100 
101  void log_dpb_content() const;
102  void log_dpb_queues() const;
103 
104 private:
105  int max_images_in_DPB;
106  int norm_images_in_DPB;
107 
108  std::vector<struct de265_image*> dpb; // decoded picture buffer
109 
110  std::vector<struct de265_image*> reorder_output_queue;
111  std::deque<struct de265_image*> image_output_queue;
112 
113 private:
115  decoded_picture_buffer& operator=(const decoded_picture_buffer&); // no copy
116 };
117 
118 #endif
Definition: dpb.h:32
void log_dpb_content() const
void insert_image_into_reorder_buffer(struct de265_image *img)
Definition: dpb.h:75
struct de265_image * get_next_picture_in_output_queue() const
Definition: dpb.h:93
int num_pictures_in_reorder_buffer() const
Definition: dpb.h:79
void set_max_size_of_DPB(int n)
Definition: dpb.h:37
void log_dpb_queues() const
void set_norm_size_of_DPB(int n)
Definition: dpb.h:38
int num_pictures_in_output_queue() const
Definition: dpb.h:90
void pop_next_picture_in_output_queue()
int DPB_index_of_picture_with_POC(int poc, int currentID, bool preferLongTerm=false) const
bool has_free_dpb_picture(bool high_priority) const
int size() const
Definition: dpb.h:53
int new_image(std::shared_ptr< const seq_parameter_set > sps, decoder_context *decctx, de265_PTS pts, void *user_data, bool isOutputImage)
int DPB_index_of_picture_with_ID(int id) const
int DPB_index_of_picture_with_LSB(int lsb, int currentID, bool preferLongTerm=false) const
void output_next_picture_in_reorder_buffer()
const de265_image * get_image(int index) const
Definition: dpb.h:62
de265_image * get_image(int index)
Definition: dpb.h:57
Definition: decctx.h:291
int64_t de265_PTS
Definition: de265.h:166
Definition: image.h:222