#ifndef DE265_ENCPICBUF_H
#define DE265_ENCPICBUF_H
#include "libde265/image.h"
#include "libde265/sps.h"
#include <deque>
#include <vector>
struct image_data
{
image_data();
~image_data();
int frame_number;
const de265_image* input;
de265_image* prediction;
de265_image* reconstruction;
nal_header nal;
slice_segment_header shdr;
std::vector<int> ref0;
std::vector<int> ref1;
std::vector<int> longterm;
std::vector<int> keep;
int sps_index;
int skip_priority;
bool is_intra;
enum state {
state_unprocessed,
state_sop_metadata_available,
state_encoding,
state_keep_for_reference,
state_skipped
} state;
bool is_in_output_queue;
bool mark_used;
void set_intra();
void set_NAL_type(uint8_t nalType);
void set_NAL_temporal_id(int temporal_id);
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);
void set_skip_priority(int skip_priority);
};
class encoder_picture_buffer
{
public:
encoder_picture_buffer();
~encoder_picture_buffer();
void reset();
image_data* insert_next_image_in_encoding_order(const de265_image*, int frame_number);
void insert_end_of_stream();
void sop_metadata_commit(int frame_number);
void mark_encoding_started(int frame_number);
void set_prediction_image(int frame_number, de265_image*);
void set_reconstruction_image(int frame_number, de265_image*);
void mark_encoding_finished(int frame_number);
bool have_more_frames_to_encode() const;
image_data* get_next_picture_to_encode();
const image_data* get_picture(int frame_number) const;
bool has_picture(int frame_number) const;
const image_data* peek_next_picture_to_encode() const {
assert(!mImages.empty());
return mImages.front();
}
void mark_image_is_outputted(int frame_number);
void release_input_image(int frame_number);
private:
bool mEndOfStream;
std::deque<image_data*> mImages;
void flush_images();
image_data* get_picture(int frame_number);
};
#endif