45 struct en265_encoder_context;
58 #define INTEGRITY_CORRECT 0
59 #define INTEGRITY_UNAVAILABLE_REFERENCE 1
60 #define INTEGRITY_NOT_DECODED 2
61 #define INTEGRITY_DECODING_ERRORS 3
62 #define INTEGRITY_DERIVED_FROM_FAULTY_REFERENCE 4
64 #define SEI_HASH_UNCHECKED 0
65 #define SEI_HASH_CORRECT 1
66 #define SEI_HASH_INCORRECT 2
68 #define TU_FLAG_NONZERO_COEFF (1<<7)
69 #define TU_FLAG_SPLIT_TRANSFORM_MASK 0x1F
71 #define DEBLOCK_FLAG_VERTI (1<<4)
72 #define DEBLOCK_FLAG_HORIZ (1<<5)
73 #define DEBLOCK_PB_EDGE_VERTI (1<<6)
74 #define DEBLOCK_PB_EDGE_HORIZ (1<<7)
75 #define DEBLOCK_BS_MASK 0x03
78 #define CTB_PROGRESS_NONE 0
79 #define CTB_PROGRESS_PREFILTER 1
80 #define CTB_PROGRESS_DEBLK_V 2
81 #define CTB_PROGRESS_DEBLK_H 3
82 #define CTB_PROGRESS_SAO 4
97 data = (DataUnit*)malloc(
size *
sizeof(DataUnit));
117 const DataUnit&
get(
int x,
int y)
const {
127 DataUnit&
get(
int x,
int y) {
137 void set(
int x,
int y,
const DataUnit& d) {
160 #define SET_CB_BLK(x,y,log2BlkWidth, Field,value) \
161 int cbX = x >> cb_info.log2unitSize; \
162 int cbY = y >> cb_info.log2unitSize; \
163 int width = 1 << (log2BlkWidth - cb_info.log2unitSize); \
164 for (int cby=cbY;cby<cbY+width;cby++) \
165 for (int cbx=cbX;cbx<cbX+width;cbx++) \
167 cb_info[ cbx + cby*cb_info.width_in_units ].Field = value; \
170 #define CLEAR_TB_BLK(x,y,log2BlkWidth) \
171 int tuX = x >> tu_info.log2unitSize; \
172 int tuY = y >> tu_info.log2unitSize; \
173 int width = 1 << (log2BlkWidth - tu_info.log2unitSize); \
174 for (int tuy=tuY;tuy<tuY+width;tuy++) \
175 for (int tux=tuX;tux<tuX+width;tux++) \
177 tu_info[ tux + tuy*tu_info.width_in_units ] = 0; \
228 std::shared_ptr<const seq_parameter_set> sps,
233 bool useCustomAllocFunctions);
242 std::shared_ptr<seq_parameter_set> _sps,
243 std::shared_ptr<pic_parameter_set> _pps) {
265 return pixels[cIdx] + xpos + ypos*stride;
270 template <
class pixel_t>
274 return (pixel_t*)(pixels[cIdx] + (xpos + ypos*stride)*
sizeof(pixel_t));
280 return pixels[cIdx] + xpos + ypos*stride;
286 return pixels[cIdx] + ((xpos + ypos*stride) << bpp_shift[cIdx]);
292 return pixels[cIdx] + ((xpos + ypos*stride) << bpp_shift[cIdx]);
299 if (cIdx==0)
return stride;
300 else return chroma_stride;
306 int get_width (
int cIdx=0)
const {
return cIdx==0 ? width : chroma_width; }
307 int get_height(
int cIdx=0)
const {
return cIdx==0 ? height : chroma_height; }
312 if (cIdx==0)
return sps->BitDepth_Y;
313 else return sps->BitDepth_C;
336 int xP,
int yP,
int nPbW,
int nPbH,
int partIdx,
337 int xN,
int yN)
const;
342 void printBlk(
const char* title,
int x0,
int y0,
int blkSize,
int cIdx)
const {
349 static uint32_t s_next_image_ID;
352 uint8_t bpp_shift[3];
358 int chroma_width, chroma_height;
359 int stride, chroma_stride;
364 std::vector<slice_segment_header*>
slices;
408 std::shared_ptr<const video_parameter_set> vps;
409 std::shared_ptr<const seq_parameter_set> sps;
410 std::shared_ptr<const pic_parameter_set> pps;
580 void set_QPY(
int x,
int y,
int log2BlkWidth,
int QP_Y)
587 return cb_info.
get(x0,y0).
QP_Y;
594 tu_info.
get(x0,y0) |= (1<<trafoDepth);
604 return (tu_info.
get(x0,y0) & (1<<trafoDepth));
611 const int width = 1 << (log2TrafoSize - tu_info.
log2unitSize);
613 for (
int tuy=tuY;tuy<tuY+width;tuy++)
614 for (
int tux=tuX;tux<tuX+width;tux++)
640 int pbSize = 1<<(log2blkSize - intraPredMode.
log2unitSize);
642 for (
int y=0;y<pbSize;y++)
643 for (
int x=0;x<pbSize;x++)
650 int pbSize = 1<<(log2blkSize - intraPredMode.
log2unitSize);
651 int PUidx = (x0>>sps->Log2MinPUSize) + (y0>>sps->Log2MinPUSize)*sps->PicWidthInMinPUs;
653 for (
int y=0;y<pbSize;y++)
654 for (
int x=0;x<pbSize;x++) {
655 assert(x < sps->PicWidthInMinPUs);
656 assert(y < sps->PicHeightInMinPUs);
660 intraPredMode[idx] = mode;
672 return intraPredModeC.
get(x,y) & 0x80;
678 uint8_t combinedValue = mode;
679 if (is_mode4) combinedValue |= 0x80;
681 int pbSize = 1<<(log2blkSize - intraPredMode.
log2unitSize);
682 int PUidx = (x0>>sps->Log2MinPUSize) + (y0>>sps->Log2MinPUSize)*sps->PicWidthInMinPUs;
684 for (
int y=0;y<pbSize;y++)
685 for (
int x=0;x<pbSize;x++) {
686 assert(x<sps->PicWidthInMinPUs);
687 assert(y<sps->PicHeightInMinPUs);
691 intraPredModeC[idx] = combinedValue;
716 ctb_info[idx].SliceAddrRS = SliceAddrRS;
726 return ctb_info[ctbRS].SliceAddrRS;
742 return ctb_info[ctbX + ctbY*ctb_info.
width_in_units].SliceHeaderIndex;
747 return ctb_info[ctb].SliceHeaderIndex;
753 return idx >= 0 && idx <
slices.size();
759 if (idx >=
slices.size()) {
return NULL; }
766 if (idx >=
slices.size()) {
return NULL; }
773 if (idx >=
slices.size()) {
return NULL; }
795 ctb_info[idx].deblock = flag;
807 return ctb_info[idx].has_pcm_or_cu_transquant_bypass;
838 uint8_t* data = &deblk_info[x0/4 + y0/4*deblk_info.
width_in_units];
853 return pb_info.
get(x,y);
860 void printBlk(
int x0,
int y0,
int cIdx,
int log2BlkSize);
void set_progress(int progress)
Definition: threads.h:102
int64_t de265_PTS
Definition: de265.h:166
de265_chroma
Definition: de265.h:159
de265_error
Definition: de265.h:82
PictureState
Definition: image.h:47
@ UnusedForReference
Definition: image.h:48
@ UsedForLongTermReference
Definition: image.h:50
@ UsedForShortTermReference
Definition: image.h:49
#define TU_FLAG_NONZERO_COEFF
Definition: image.h:68
#define DEBLOCK_BS_MASK
Definition: image.h:75
#define CLEAR_TB_BLK(x, y, log2BlkWidth)
Definition: image.h:170
#define SET_CB_BLK(x, y, log2BlkWidth, Field, value)
Definition: image.h:160
qulonglong value
Definition: itemviewutilities.cpp:592
PredMode
Definition: slice.h:90
@ MODE_INTRA
Definition: slice.h:91
@ MODE_SKIP
Definition: slice.h:91
PartMode
Definition: slice.h:75
IntraPredMode
Definition: slice.h:95
uint8_t pcm_flag
Definition: image.h:210
uint8_t ctDepth
Definition: image.h:204
uint8_t PredMode
Definition: image.h:208
uint8_t PartMode
Definition: image.h:200
uint8_t log2CbSize
Definition: image.h:195
int8_t QP_Y
Definition: image.h:215
uint8_t cu_transquant_bypass
Definition: image.h:211
uint16_t SliceAddrRS
Definition: image.h:182
uint16_t SliceHeaderIndex
Definition: image.h:183
sao_info saoInfo
Definition: image.h:185
bool deblock
Definition: image.h:186
bool has_pcm_or_cu_transquant_bypass
Definition: image.h:190
enum IntraPredMode get_IntraPredMode_atIndex(int idx) const
Definition: image.h:633
enum PartMode get_PartMode(int x, int y) const
Definition: image.h:565
int get_SliceHeaderIndex(int x, int y) const
Definition: image.h:735
enum PredMode get_pred_mode(int x, int y) const
Definition: image.h:501
int get_cu_transquant_bypass(int x, int y) const
Definition: image.h:532
uint8_t SubWidthC
Definition: image.h:363
const video_parameter_set & get_vps() const
Definition: image.h:386
const seq_parameter_set & get_sps() const
Definition: image.h:387
bool PicOutputFlag
Definition: image.h:382
bool available_zscan(int xCurr, int yCurr, int xN, int yN) const
void set_CtbDeblockFlag(int ctbX, int ctbY, bool flag)
Definition: image.h:792
int get_log2CbSize_cbUnits(int xCb, int yCb) const
Definition: image.h:555
int get_bytes_per_pixel(int cIdx) const
Definition: image.h:316
void set_IntraPredMode(int PUidx, int log2blkSize, enum IntraPredMode mode)
Definition: image.h:638
int height_confwin
Definition: image.h:372
std::vector< slice_segment_header * > slices
Definition: image.h:364
bool get_CtbDeblockFlag(int ctbX, int ctbY) const
Definition: image.h:798
int get_height(int cIdx=0) const
Definition: image.h:307
de265_mutex mutex
Definition: image.h:477
bool available_pred_blk(int xC, int yC, int nCbS, int xP, int yP, int nPbW, int nPbH, int partIdx, int xN, int yN) const
void set_pred_mode(int x, int y, int log2BlkWidth, enum PredMode mode)
Definition: image.h:490
void set_IntraPredModeC(int x0, int y0, int log2blkSize, enum IntraPredMode mode, bool is_mode4)
Definition: image.h:675
nal_header nal_hdr
Definition: image.h:440
int get_SliceHeaderIndexCtb(int ctbX, int ctbY) const
Definition: image.h:740
int PicOrderCntVal
Definition: image.h:380
uint32_t get_ID() const
Definition: image.h:254
void set_pcm_flag(int x, int y, int log2BlkWidth, uint8_t value=1)
Definition: image.h:511
int get_split_transform_flag(int x0, int y0, int trafoDepth) const
Definition: image.h:602
const PBMotion & get_mv_info(int x, int y) const
Definition: image.h:851
void * user_data
Definition: image.h:424
int get_deblk_width() const
Definition: image.h:814
int get_ctDepth(int x, int y) const
Definition: image.h:575
void set_deblk_bS(int x0, int y0, uint8_t bS)
Definition: image.h:836
slice_segment_header * get_SliceHeaderCtb(int ctbX, int ctbY)
Definition: image.h:763
void printBlk(int x0, int y0, int cIdx, int log2BlkSize)
int chroma_height_confwin
Definition: image.h:373
int width_confwin
Definition: image.h:372
void set_mv_info(int x, int y, int nPbW, int nPbH, const PBMotion &mv)
void fill_image(int y, int u, int v)
bool is_IntraPredModeC_Mode4(int x, int y) const
Definition: image.h:670
decoder_context * decctx
Definition: image.h:399
enum de265_chroma get_chroma_format() const
Definition: image.h:309
de265_error alloc_image(int w, int h, enum de265_chroma c, std::shared_ptr< const seq_parameter_set > sps, bool allocMetadata, decoder_context *dctx, de265_PTS pts, void *user_data, bool useCustomAllocFunctions)
int nThreadsQueued
Definition: image.h:470
int nThreadsTotal
Definition: image.h:474
void printBlk(const char *title, int x0, int y0, int blkSize, int cIdx) const
Definition: image.h:342
int get_image_stride(int cIdx) const
Definition: image.h:297
void mark_all_CTB_progress(int progress)
Definition: image.h:446
int get_SliceAddrRS_atCtbRS(int ctbRS) const
Definition: image.h:724
int get_chroma_stride() const
Definition: image.h:304
de265_PTS pts
Definition: image.h:423
bool sei_hash_check_result
Definition: image.h:438
void set_ctDepth(int x, int y, int log2BlkWidth, int depth)
Definition: image.h:570
int get_nonzero_coefficient(int x, int y) const
Definition: image.h:620
enum PictureState PicState
Definition: image.h:381
void set_image_plane(int cIdx, uint8_t *mem, int stride, void *userdata)
de265_progress_lock * ctb_progress
Definition: image.h:444
void wait_for_completion()
const uint8_t * get_image_plane(int cIdx) const
Definition: image.h:258
void thread_finishes(const thread_task *)
void copy_lines_from(const de265_image *src, int first, int end)
void * get_image_plane_at_pos_any_depth(int cIdx, int xpos, int ypos)
Definition: image.h:283
uint8_t get_cu_skip_flag(int x, int y) const
Definition: image.h:506
int get_deblk_height() const
Definition: image.h:815
uint8_t get_deblk_flags(int x0, int y0) const
Definition: image.h:828
int32_t removed_at_picture_id
Definition: image.h:384
void set_SliceAddrRS(int ctbX, int ctbY, int SliceAddrRS)
Definition: image.h:713
int nThreadsBlocked
Definition: image.h:472
const void * get_image_plane_at_pos_any_depth(int cIdx, int xpos, int ypos) const
Definition: image.h:289
int get_SliceHeaderIndex_atIndex(int ctb) const
Definition: image.h:745
void set_cu_transquant_bypass(int x, int y, int log2BlkWidth, uint8_t value=1)
Definition: image.h:524
const uint8_t * get_image_plane_at_pos(int cIdx, int xpos, int ypos) const
Definition: image.h:277
int get_width(int cIdx=0) const
Definition: image.h:306
enum IntraPredMode get_IntraPredModeC(int x, int y) const
Definition: image.h:665
void set_nonzero_coefficient(int x, int y, int log2TrafoSize)
Definition: image.h:607
void thread_run(const thread_task *)
de265_cond finished_cond
Definition: image.h:478
const sao_info * get_sao_info(int ctbX, int ctbY) const
Definition: image.h:786
pixel_t * get_image_plane_at_pos_NEW(int cIdx, int xpos, int ypos)
xpos;ypos in actual plane resolution
Definition: image.h:271
int number_of_ctbs() const
Definition: image.h:402
int get_log2CbSize(int x0, int y0) const
Definition: image.h:549
void thread_start(int nThreads)
bool debug_is_completed() const
bool get_CTB_has_pcm_or_cu_transquant_bypass(int ctbX, int ctbY) const
Definition: image.h:804
int num_threads_active() const
Definition: image.h:467
void set_SliceHeaderIndex(int x, int y, int SliceHeaderIndex)
Definition: image.h:730
int nThreadsRunning
Definition: image.h:471
int get_SliceAddrRS(int ctbX, int ctbY) const
Definition: image.h:719
bool high_bit_depth(int cIdx) const
Definition: image.h:320
const pic_parameter_set & get_pps() const
Definition: image.h:388
void * plane_user_data[3]
Definition: image.h:425
slice_segment_header * get_SliceHeader(int x, int y)
Definition: image.h:756
bool is_allocated() const
Definition: image.h:237
void clear_split_transform_flags(int x0, int y0, int log2CbSize)
Definition: image.h:597
int get_bit_depth(int cIdx) const
Definition: image.h:311
int picture_order_cnt_lsb
Definition: image.h:379
bool has_vps() const
Definition: image.h:390
int chroma_width_confwin
Definition: image.h:373
de265_error copy_image(const de265_image *src)
void set_headers(std::shared_ptr< video_parameter_set > _vps, std::shared_ptr< seq_parameter_set > _sps, std::shared_ptr< pic_parameter_set > _pps)
Definition: image.h:241
int get_QPY(int x0, int y0) const
Definition: image.h:585
uint8_t BitDepth_Y
Definition: image.h:362
const slice_segment_header * get_SliceHeaderCtb(int ctbX, int ctbY) const
Definition: image.h:770
void exchange_pixel_data_with(de265_image &)
void set_split_transform_flag(int x0, int y0, int trafoDepth)
Definition: image.h:592
void set_log2CbSize(int x0, int y0, int log2CbSize, bool fill)
Definition: image.h:537
uint8_t get_deblk_bS(int x0, int y0) const
Definition: image.h:843
int get_pcm_flag(int x, int y) const
Definition: image.h:519
uint8_t SubHeightC
Definition: image.h:363
void set_PartMode(int x, int y, enum PartMode mode)
Definition: image.h:560
de265_image_allocation image_allocation_functions
Definition: image.h:426
bool has_pps() const
Definition: image.h:392
void wait_for_progress(thread_task *task, int ctbAddrRS, int progress)
bool has_sps() const
Definition: image.h:391
uint8_t integrity
Definition: image.h:434
static de265_image_allocation default_image_allocation
Definition: image.h:340
uint8_t * get_image_plane_at_pos(int cIdx, int xpos, int ypos)
Definition: image.h:262
void fill_pred_mode(enum PredMode mode)
Definition: image.h:495
int nThreadsFinished
Definition: image.h:473
void set_QPY(int x, int y, int log2BlkWidth, int QP_Y)
Definition: image.h:580
void set_deblk_flags(int x0, int y0, uint8_t flags)
Definition: image.h:817
uint8_t * get_image_plane(int cIdx)
Definition: image.h:257
uint8_t BitDepth_C
Definition: image.h:362
void wait_for_progress(thread_task *task, int ctbx, int ctby, int progress)
std::shared_ptr< const seq_parameter_set > get_shared_sps()
Definition: image.h:394
bool can_be_released() const
Definition: image.h:324
bool is_SliceHeader_available(int x, int y) const
Definition: image.h:750
int get_luma_stride() const
Definition: image.h:303
uint8_t * pixels_confwin[3]
Definition: image.h:370
void add_slice_segment_header(slice_segment_header *shdr)
Definition: image.h:327
enum IntraPredMode get_IntraPredMode(int x, int y) const
Definition: image.h:628
void set_sao_info(int ctbX, int ctbY, const sao_info *saoinfo)
Definition: image.h:777
pthread_mutex_t de265_mutex
Definition: threads.h:42
pthread_cond_t de265_cond
Definition: threads.h:43
#define LIBDE265_CHECK_RESULT
Definition: util.h:56