12 #ifndef AOM_AV1_DECODER_DECODER_H_
13 #define AOM_AV1_DECODER_DECODER_H_
15 #include "config/aom_config.h"
18 #include "aom_dsp/bitreader.h"
19 #include "aom_scale/yv12config.h"
20 #include "aom_util/aom_thread.h"
22 #include "av1/common/av1_common_int.h"
23 #include "av1/common/thread_common.h"
24 #include "av1/decoder/dthread.h"
26 #include "av1/decoder/accounting.h"
29 #include "av1/decoder/inspection.h"
88 typedef void (*decode_block_visitor_fn_t)(
const AV1_COMMON *
const cm,
90 aom_reader *
const r,
const int plane,
91 const int row,
const int col,
92 const TX_SIZE tx_size);
94 typedef void (*predict_inter_block_visitor_fn_t)(
AV1_COMMON *
const cm,
98 typedef void (*cfl_store_inter_block_visitor_fn_t)(
AV1_COMMON *
const cm,
101 typedef struct ThreadData {
108 CB_BUFFER cb_buffer_base;
110 aom_reader *bit_reader;
118 int mc_buf_use_highbd;
121 CONV_BUF_TYPE *tmp_conv_dst;
122 uint8_t *tmp_obmc_bufs[2];
124 decode_block_visitor_fn_t read_coeffs_tx_intra_block_visit;
125 decode_block_visitor_fn_t predict_and_recon_intra_block_visit;
126 decode_block_visitor_fn_t read_coeffs_tx_inter_block_visit;
127 decode_block_visitor_fn_t inverse_tx_inter_block_visit;
128 predict_inter_block_visitor_fn_t predict_inter_block_visit;
129 cfl_store_inter_block_visitor_fn_t cfl_store_inter_block_visit;
132 typedef struct AV1DecRowMTJobInfo {
136 } AV1DecRowMTJobInfo;
138 typedef struct AV1DecRowMTSyncData {
139 #if CONFIG_MULTITHREAD
140 pthread_mutex_t *mutex_;
141 pthread_cond_t *cond_;
143 int allocated_sb_rows;
148 int mi_rows_parse_done;
149 int mi_rows_decode_started;
150 int num_threads_working;
153 typedef struct AV1DecRowMTInfo {
160 int mi_rows_to_decode;
174 int mi_rows_parse_done;
177 int mi_rows_decode_started;
183 typedef struct TileDataDec {
185 aom_reader bit_reader;
186 DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
187 AV1DecRowMTSync dec_row_mt_sync;
190 typedef struct TileBufferDec {
195 typedef struct DataBuffer {
200 typedef struct EXTERNAL_REFERENCES {
203 } EXTERNAL_REFERENCES;
205 typedef struct TileJobsDec {
206 TileBufferDec *tile_buffer;
207 TileDataDec *tile_data;
210 typedef struct AV1DecTileMTData {
211 #if CONFIG_MULTITHREAD
212 pthread_mutex_t *job_mutex;
214 TileJobsDec *job_queue;
221 typedef struct AV1Decoder {
227 AV1LfSync lf_row_sync;
228 AV1LrSync lr_row_sync;
230 AVxWorker *tile_workers;
232 DecWorkerData *thread_data;
234 TileDataDec *tile_data;
237 TileBufferDec tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
238 AV1DecTileMT tile_mt_info;
250 int output_all_layers;
251 RefCntBuffer *output_frames[MAX_NUM_SPATIAL_LAYERS];
252 size_t num_output_frames;
257 int decoding_first_frame;
259 int allow_lowbitdepth;
263 int reset_decoder_state;
266 int tile_col_size_bytes;
267 int dec_tile_row, dec_tile_col;
268 #if CONFIG_ACCOUNTING
272 int sequence_header_ready;
273 int sequence_header_changed;
274 #if CONFIG_INSPECTION
279 int current_operating_point;
280 int seen_frame_header;
286 int camera_frame_header_ready;
287 size_t frame_header_size;
288 DataBuffer obu_size_hdr;
289 int output_frame_width_in_tiles_minus_1;
290 int output_frame_height_in_tiles_minus_1;
291 int tile_count_minus_1;
292 uint32_t coded_tile_data_size;
293 unsigned int ext_tile_debug;
303 EXTERNAL_REFERENCES ext_refs;
309 CB_BUFFER *cb_buffer_base;
312 int cb_buffer_alloc_size;
314 int allocated_row_mt_sync_rows;
316 #if CONFIG_MULTITHREAD
317 pthread_mutex_t *row_mt_mutex_;
318 pthread_cond_t *row_mt_cond_;
321 AV1DecRowMTInfo frame_row_mt_info;
324 int context_update_tile_id;
325 int skip_loop_filter;
328 int valid_for_referencing[REF_FRAMES];
329 int is_fwd_kf_present;
330 int is_arf_frame_present;
337 int av1_receive_compressed_data(
struct AV1Decoder *pbi,
size_t size,
338 const uint8_t **psource);
342 aom_film_grain_t **grain_params);
346 aom_codec_err_t av1_copy_reference_dec(
struct AV1Decoder *pbi,
int idx,
350 int use_external_ref,
356 struct AV1Decoder *av1_decoder_create(BufferPool *
const pool);
358 void av1_decoder_remove(
struct AV1Decoder *pbi);
359 void av1_dealloc_dec_jobs(
struct AV1DecTileMTData *tile_mt_info);
361 void av1_dec_row_mt_dealloc(AV1DecRowMTSync *dec_row_mt_sync);
363 void av1_dec_free_cb_buf(AV1Decoder *pbi);
365 static INLINE
void decrease_ref_count(RefCntBuffer *
const buf,
366 BufferPool *
const pool) {
371 assert(buf->ref_count >= 0);
376 if (buf->ref_count == 0 && buf->raw_frame_buffer.data) {
377 pool->release_fb_cb(pool->cb_priv, &buf->raw_frame_buffer);
378 buf->raw_frame_buffer.data = NULL;
379 buf->raw_frame_buffer.size = 0;
380 buf->raw_frame_buffer.priv = NULL;
385 #define ACCT_STR __func__
386 static INLINE
int av1_read_uniform(aom_reader *r,
int n) {
387 const int l = get_unsigned_bits(n);
388 const int m = (1 << l) - n;
389 const int v = aom_read_literal(r, l - 1, ACCT_STR);
394 return (v << 1) - m + aom_read_literal(r, 1, ACCT_STR);
397 typedef void (*palette_visitor_fn_t)(
MACROBLOCKD *
const xd,
int plane,
400 void av1_visit_palette(AV1Decoder *
const pbi,
MACROBLOCKD *
const xd,
401 aom_reader *r, palette_visitor_fn_t visit);
403 typedef void (*block_visitor_fn_t)(AV1Decoder *
const pbi, ThreadData *
const td,
404 int mi_row,
int mi_col, aom_reader *r,
405 PARTITION_TYPE partition, BLOCK_SIZE bsize);
Describes the codec algorithm interface to applications.
struct aom_metadata_array aom_metadata_array_t
Array of aom_metadata structs for an image.
Definition: aom_image.h:160
void(* aom_inspect_cb)(void *decoder, void *ctx)
Definition: aomdx.h:55
struct Accounting Accounting
Definition: aomdx.h:50
aom_codec_err_t
Algorithm return codes.
Definition: aom_codec.h:155
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:723
Contains coding block data required by the decoder.
Definition: decoder.h:45
eob_info * eob_data[3]
Definition: decoder.h:73
uint8_t * mc_buf[2]
Definition: decoder.h:58
tran_low_t * dqcoeff_block[3]
Definition: decoder.h:63
uint16_t txb_offset[3]
Definition: decoder.h:78
int corrupted
Definition: decoder.h:53
MACROBLOCKD xd
Definition: decoder.h:49
uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]
Definition: decoder.h:83
uint16_t cb_offset[3]
Definition: decoder.h:68
Structure to hold information about S_FRAME.
Definition: aomdx.h:153
Variables related to current coding block.
Definition: blockd.h:577
YV12 frame buffer data structure.
Definition: yv12config.h:38