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"
88typedef 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);
94typedef void (*predict_inter_block_visitor_fn_t)(
AV1_COMMON *
const cm,
98typedef void (*cfl_store_inter_block_visitor_fn_t)(
AV1_COMMON *
const cm,
101typedef struct ThreadData {
108 CB_BUFFER cb_buffer_base;
110 aom_reader *bit_reader;
120 int mc_buf_use_highbd;
123 CONV_BUF_TYPE *tmp_conv_dst;
124 uint8_t *tmp_obmc_bufs[2];
126 decode_block_visitor_fn_t read_coeffs_tx_intra_block_visit;
127 decode_block_visitor_fn_t predict_and_recon_intra_block_visit;
128 decode_block_visitor_fn_t read_coeffs_tx_inter_block_visit;
129 decode_block_visitor_fn_t inverse_tx_inter_block_visit;
130 predict_inter_block_visitor_fn_t predict_inter_block_visit;
131 cfl_store_inter_block_visitor_fn_t cfl_store_inter_block_visit;
134typedef struct AV1DecRowMTJobInfo {
140typedef struct AV1DecRowMTSyncData {
141#if CONFIG_MULTITHREAD
142 pthread_mutex_t *mutex_;
143 pthread_cond_t *cond_;
145 int allocated_sb_rows;
156 int intrabc_extra_top_right_sb_delay;
159 int mi_rows_parse_done;
160 int mi_rows_decode_started;
161 int num_threads_working;
164typedef struct AV1DecRowMTInfo {
171 int mi_rows_to_decode;
185 int mi_rows_parse_done;
188 int mi_rows_decode_started;
194typedef struct TileDataDec {
196 aom_reader bit_reader;
197 DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
198 AV1DecRowMTSync dec_row_mt_sync;
201typedef struct TileBufferDec {
206typedef struct DataBuffer {
211typedef struct EXTERNAL_REFERENCES {
214} EXTERNAL_REFERENCES;
216typedef struct TileJobsDec {
217 TileBufferDec *tile_buffer;
218 TileDataDec *tile_data;
221typedef struct AV1DecTileMTData {
222#if CONFIG_MULTITHREAD
223 pthread_mutex_t *job_mutex;
225 TileJobsDec *job_queue;
232typedef struct AV1Decoder {
238 AV1LfSync lf_row_sync;
239 AV1LrSync lr_row_sync;
241 AV1CdefSync cdef_sync;
242 AV1CdefWorkerData *cdef_worker;
243 AVxWorker *tile_workers;
245 DecWorkerData *thread_data;
247 TileDataDec *tile_data;
250 TileBufferDec tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
251 AV1DecTileMT tile_mt_info;
263 int output_all_layers;
264 RefCntBuffer *output_frames[MAX_NUM_SPATIAL_LAYERS];
265 size_t num_output_frames;
270 int decoding_first_frame;
272 int allow_lowbitdepth;
276 int reset_decoder_state;
279 int tile_col_size_bytes;
280 int dec_tile_row, dec_tile_col;
285 int sequence_header_ready;
286 int sequence_header_changed;
292 int current_operating_point;
293 int seen_frame_header;
299 int camera_frame_header_ready;
300 size_t frame_header_size;
301 DataBuffer obu_size_hdr;
302 int output_frame_width_in_tiles_minus_1;
303 int output_frame_height_in_tiles_minus_1;
304 int tile_count_minus_1;
305 uint32_t coded_tile_data_size;
306 unsigned int ext_tile_debug;
316 EXTERNAL_REFERENCES ext_refs;
322 CB_BUFFER *cb_buffer_base;
325 int cb_buffer_alloc_size;
327 int allocated_row_mt_sync_rows;
329#if CONFIG_MULTITHREAD
330 pthread_mutex_t *row_mt_mutex_;
331 pthread_cond_t *row_mt_cond_;
334 AV1DecRowMTInfo frame_row_mt_info;
337 int context_update_tile_id;
338 int skip_loop_filter;
341 int valid_for_referencing[REF_FRAMES];
342 int is_fwd_kf_present;
343 int is_arf_frame_present;
351 SequenceHeader seq_params;
356 bool buffer_removal_time_present;
361 struct aom_internal_error_info error;
366 unsigned int number_temporal_layers;
371 unsigned int number_spatial_layers;
376int av1_receive_compressed_data(
struct AV1Decoder *pbi,
size_t size,
377 const uint8_t **psource);
381 aom_film_grain_t **grain_params);
389 int use_external_ref,
395struct AV1Decoder *av1_decoder_create(BufferPool *
const pool);
397void av1_decoder_remove(
struct AV1Decoder *pbi);
398void av1_dealloc_dec_jobs(
struct AV1DecTileMTData *tile_mt_info);
400void av1_dec_row_mt_dealloc(AV1DecRowMTSync *dec_row_mt_sync);
402void av1_dec_free_cb_buf(AV1Decoder *pbi);
404static inline void decrease_ref_count(RefCntBuffer *
const buf,
405 BufferPool *
const pool) {
410 assert(buf->ref_count >= 0);
415 if (buf->ref_count == 0 && buf->raw_frame_buffer.data) {
416 pool->release_fb_cb(pool->cb_priv, &buf->raw_frame_buffer);
417 buf->raw_frame_buffer.data = NULL;
418 buf->raw_frame_buffer.size = 0;
419 buf->raw_frame_buffer.priv = NULL;
424#define ACCT_STR __func__
425static inline int av1_read_uniform(aom_reader *r,
int n) {
426 const int l = get_unsigned_bits(n);
427 const int m = (1 << l) - n;
428 const int v = aom_read_literal(r, l - 1, ACCT_STR);
433 return (v << 1) - m + aom_read_literal(r, 1, ACCT_STR);
436typedef void (*palette_visitor_fn_t)(
MACROBLOCKD *
const xd,
int plane,
439void av1_visit_palette(AV1Decoder *
const pbi,
MACROBLOCKD *
const xd,
440 aom_reader *r, palette_visitor_fn_t visit);
442typedef void (*block_visitor_fn_t)(AV1Decoder *
const pbi, ThreadData *
const td,
443 int mi_row,
int mi_col, aom_reader *r,
444 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:171
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:757
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:570
YV12 frame buffer data structure.
Definition yv12config.h:46