mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-09 00:37:32 +09:00
Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614
This commit is contained in:
parent
debbee1e2a
commit
992c6637e3
429 changed files with 76047 additions and 40937 deletions
2277
third_party/aom/av1/decoder/decodeframe.c
vendored
2277
third_party/aom/av1/decoder/decodeframe.c
vendored
File diff suppressed because it is too large
Load diff
21
third_party/aom/av1/decoder/decodeframe.h
vendored
21
third_party/aom/av1/decoder/decodeframe.h
vendored
|
|
@ -21,16 +21,33 @@ struct aom_read_bit_buffer;
|
|||
|
||||
#if CONFIG_REFERENCE_BUFFER
|
||||
/* Placeholder for now */
|
||||
void read_sequence_header(SequenceHeader *seq_params);
|
||||
void read_sequence_header(SequenceHeader *seq_params,
|
||||
struct aom_read_bit_buffer *rb);
|
||||
#endif
|
||||
|
||||
int av1_read_sync_code(struct aom_read_bit_buffer *const rb);
|
||||
void av1_read_frame_size(struct aom_read_bit_buffer *rb, int *width,
|
||||
int *height);
|
||||
BITSTREAM_PROFILE av1_read_profile(struct aom_read_bit_buffer *rb);
|
||||
|
||||
// This function is now obsolete
|
||||
void av1_decode_frame(struct AV1Decoder *pbi, const uint8_t *data,
|
||||
const uint8_t *data_end, const uint8_t **p_data_end);
|
||||
size_t av1_decode_frame_headers_and_setup(struct AV1Decoder *pbi,
|
||||
const uint8_t *data,
|
||||
const uint8_t *data_end,
|
||||
const uint8_t **p_data_end);
|
||||
|
||||
void av1_decode_tg_tiles_and_wrapup(struct AV1Decoder *pbi, const uint8_t *data,
|
||||
const uint8_t *data_end,
|
||||
const uint8_t **p_data_end, int startTile,
|
||||
int endTile, int initialize_flag);
|
||||
|
||||
#if CONFIG_OBU
|
||||
// replaces av1_decode_frame
|
||||
void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
|
||||
const uint8_t *data_end,
|
||||
const uint8_t **p_data_end);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
1041
third_party/aom/av1/decoder/decodemv.c
vendored
1041
third_party/aom/av1/decoder/decodemv.c
vendored
File diff suppressed because it is too large
Load diff
141
third_party/aom/av1/decoder/decoder.c
vendored
141
third_party/aom/av1/decoder/decoder.c
vendored
|
|
@ -33,7 +33,9 @@
|
|||
|
||||
#include "av1/decoder/decodeframe.h"
|
||||
#include "av1/decoder/decoder.h"
|
||||
|
||||
#if CONFIG_NCOBMC_ADAPT_WEIGHT
|
||||
#include "av1/common/ncobmc_kernels.h"
|
||||
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
|
||||
#if !CONFIG_PVQ
|
||||
#include "av1/decoder/detokenize.h"
|
||||
#endif
|
||||
|
|
@ -46,23 +48,8 @@ static void initialize_dec(void) {
|
|||
aom_dsp_rtcd();
|
||||
aom_scale_rtcd();
|
||||
av1_init_intra_predictors();
|
||||
#if CONFIG_EXT_INTER
|
||||
av1_init_wedge_masks();
|
||||
#endif // CONFIG_EXT_INTER
|
||||
init_done = 1;
|
||||
av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
|
||||
av1_switchable_interp_tree);
|
||||
#if CONFIG_EXT_TX
|
||||
int s;
|
||||
for (s = 1; s < EXT_TX_SETS_INTRA; ++s)
|
||||
av1_indices_from_tree(av1_ext_tx_intra_ind[s], av1_ext_tx_intra_inv[s],
|
||||
av1_ext_tx_intra_tree[s]);
|
||||
for (s = 1; s < EXT_TX_SETS_INTER; ++s)
|
||||
av1_indices_from_tree(av1_ext_tx_inter_ind[s], av1_ext_tx_inter_inv[s],
|
||||
av1_ext_tx_inter_tree[s]);
|
||||
#else
|
||||
av1_indices_from_tree(av1_ext_tx_ind, av1_ext_tx_inv, av1_ext_tx_tree);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +120,10 @@ AV1Decoder *av1_decoder_create(BufferPool *const pool) {
|
|||
|
||||
av1_loop_filter_init(cm);
|
||||
|
||||
#if CONFIG_NCOBMC_ADAPT_WEIGHT
|
||||
get_default_ncobmc_kernels(cm);
|
||||
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
|
||||
|
||||
#if CONFIG_AOM_QM
|
||||
aom_qm_init(cm);
|
||||
#endif
|
||||
|
|
@ -184,106 +175,35 @@ static int equal_dimensions(const YV12_BUFFER_CONFIG *a,
|
|||
a->uv_height == b->uv_height && a->uv_width == b->uv_width;
|
||||
}
|
||||
|
||||
aom_codec_err_t av1_copy_reference_dec(AV1Decoder *pbi,
|
||||
AOM_REFFRAME ref_frame_flag,
|
||||
aom_codec_err_t av1_copy_reference_dec(AV1Decoder *pbi, int idx,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
AV1_COMMON *cm = &pbi->common;
|
||||
|
||||
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
|
||||
* encoder is using the frame buffers for. This is just a stub to keep the
|
||||
* aomenc --test-decode functionality working, and will be replaced in a
|
||||
* later commit that adds AV1-specific controls for this functionality.
|
||||
*/
|
||||
if (ref_frame_flag == AOM_LAST_FLAG) {
|
||||
const YV12_BUFFER_CONFIG *const cfg = get_ref_frame(cm, 0);
|
||||
if (cfg == NULL) {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"No 'last' reference frame");
|
||||
return AOM_CODEC_ERROR;
|
||||
}
|
||||
if (!equal_dimensions(cfg, sd))
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"Incorrect buffer dimensions");
|
||||
else
|
||||
aom_yv12_copy_frame(cfg, sd);
|
||||
} else {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR, "Invalid reference frame");
|
||||
const YV12_BUFFER_CONFIG *const cfg = get_ref_frame(cm, idx);
|
||||
if (cfg == NULL) {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR, "No reference frame");
|
||||
return AOM_CODEC_ERROR;
|
||||
}
|
||||
if (!equal_dimensions(cfg, sd))
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"Incorrect buffer dimensions");
|
||||
else
|
||||
aom_yv12_copy_frame(cfg, sd);
|
||||
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
|
||||
AOM_REFFRAME ref_frame_flag,
|
||||
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, int idx,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
int idx;
|
||||
YV12_BUFFER_CONFIG *ref_buf = NULL;
|
||||
|
||||
// TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
|
||||
// encoder is using the frame buffers for. This is just a stub to keep the
|
||||
// aomenc --test-decode functionality working, and will be replaced in a
|
||||
// later commit that adds AV1-specific controls for this functionality.
|
||||
|
||||
// (Yunqing) The set_reference control depends on the following setting in
|
||||
// encoder.
|
||||
// cpi->lst_fb_idx = 0;
|
||||
// #if CONFIG_EXT_REFS
|
||||
// cpi->lst2_fb_idx = 1;
|
||||
// cpi->lst3_fb_idx = 2;
|
||||
// cpi->gld_fb_idx = 3;
|
||||
// cpi->bwd_fb_idx = 4;
|
||||
// #if CONFIG_ALTREF2
|
||||
// cpi->alt2_fb_idx = 5;
|
||||
// cpi->alt_fb_idx = 6;
|
||||
// #else // !CONFIG_ALTREF2
|
||||
// cpi->alt_fb_idx = 5;
|
||||
// #endif // CONFIG_ALTREF2
|
||||
// #else // CONFIG_EXT_REFS
|
||||
// cpi->gld_fb_idx = 1;
|
||||
// cpi->alt_fb_idx = 2;
|
||||
// #endif // CONFIG_EXT_REFS
|
||||
|
||||
// TODO(zoeliu): To revisit following code and reconsider what assumption we
|
||||
// may take on the reference frame buffer virtual indexes
|
||||
if (ref_frame_flag == AOM_LAST_FLAG) {
|
||||
idx = cm->ref_frame_map[0];
|
||||
#if CONFIG_EXT_REFS
|
||||
} else if (ref_frame_flag == AOM_LAST2_FLAG) {
|
||||
idx = cm->ref_frame_map[1];
|
||||
} else if (ref_frame_flag == AOM_LAST3_FLAG) {
|
||||
idx = cm->ref_frame_map[2];
|
||||
} else if (ref_frame_flag == AOM_GOLD_FLAG) {
|
||||
idx = cm->ref_frame_map[3];
|
||||
} else if (ref_frame_flag == AOM_BWD_FLAG) {
|
||||
idx = cm->ref_frame_map[4];
|
||||
#if CONFIG_ALTREF2
|
||||
} else if (ref_frame_flag == AOM_ALT2_FLAG) {
|
||||
idx = cm->ref_frame_map[5];
|
||||
} else if (ref_frame_flag == AOM_ALT_FLAG) {
|
||||
idx = cm->ref_frame_map[6];
|
||||
#else // !CONFIG_ALTREF2
|
||||
} else if (ref_frame_flag == AOM_ALT_FLAG) {
|
||||
idx = cm->ref_frame_map[5];
|
||||
#endif // CONFIG_ALTREF2
|
||||
#else // !CONFIG_EXT_REFS
|
||||
} else if (ref_frame_flag == AOM_GOLD_FLAG) {
|
||||
idx = cm->ref_frame_map[1];
|
||||
} else if (ref_frame_flag == AOM_ALT_FLAG) {
|
||||
idx = cm->ref_frame_map[2];
|
||||
#endif // CONFIG_EXT_REFS
|
||||
} else {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR, "Invalid reference frame");
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
if (idx < 0 || idx >= FRAME_BUFFERS) {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"Invalid reference frame map");
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
// Get the destination reference buffer.
|
||||
ref_buf = &cm->buffer_pool->frame_bufs[idx].buf;
|
||||
ref_buf = get_ref_frame(cm, idx);
|
||||
|
||||
if (ref_buf == NULL) {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR, "No reference frame");
|
||||
return AOM_CODEC_ERROR;
|
||||
}
|
||||
|
||||
if (!equal_dimensions(ref_buf, sd)) {
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
|
|
@ -444,7 +364,16 @@ int av1_receive_compressed_data(AV1Decoder *pbi, size_t size,
|
|||
}
|
||||
|
||||
cm->error.setjmp = 1;
|
||||
av1_decode_frame(pbi, source, source + size, psource);
|
||||
|
||||
#if !CONFIG_OBU
|
||||
av1_decode_frame_headers_and_setup(pbi, source, source + size, psource);
|
||||
if (!cm->show_existing_frame) {
|
||||
av1_decode_tg_tiles_and_wrapup(pbi, source, source + size, psource, 0,
|
||||
cm->tile_rows * cm->tile_cols - 1, 1);
|
||||
}
|
||||
#else
|
||||
av1_decode_frame_from_obus(pbi, source, source + size, psource);
|
||||
#endif
|
||||
|
||||
swap_frame_buffers(pbi);
|
||||
|
||||
|
|
@ -492,6 +421,8 @@ int av1_receive_compressed_data(AV1Decoder *pbi, size_t size,
|
|||
} else {
|
||||
cm->last_width = cm->width;
|
||||
cm->last_height = cm->height;
|
||||
cm->last_tile_cols = cm->tile_cols;
|
||||
cm->last_tile_rows = cm->tile_rows;
|
||||
if (cm->show_frame) {
|
||||
cm->current_video_frame++;
|
||||
}
|
||||
|
|
|
|||
21
third_party/aom/av1/decoder/decoder.h
vendored
21
third_party/aom/av1/decoder/decoder.h
vendored
|
|
@ -54,9 +54,10 @@ typedef struct TileData {
|
|||
CFL_CTX cfl;
|
||||
#endif
|
||||
DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
|
||||
#if CONFIG_PALETTE
|
||||
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
|
||||
#endif // CONFIG_PALETTE
|
||||
#if CONFIG_MRC_TX
|
||||
DECLARE_ALIGNED(16, uint8_t, mrc_mask[MAX_SB_SQUARE]);
|
||||
#endif // CONFIG_MRC_TX
|
||||
} TileData;
|
||||
|
||||
typedef struct TileWorkerData {
|
||||
|
|
@ -74,9 +75,10 @@ typedef struct TileWorkerData {
|
|||
CFL_CTX cfl;
|
||||
#endif
|
||||
FRAME_CONTEXT tctx;
|
||||
#if CONFIG_PALETTE
|
||||
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
|
||||
#endif // CONFIG_PALETTE
|
||||
#if CONFIG_MRC_TX
|
||||
DECLARE_ALIGNED(16, uint8_t, mrc_mask[MAX_SB_SQUARE]);
|
||||
#endif // CONFIG_MRC_TX
|
||||
struct aom_internal_error_info error_info;
|
||||
} TileWorkerData;
|
||||
|
||||
|
|
@ -138,9 +140,6 @@ typedef struct AV1Decoder {
|
|||
int tg_size; // Number of tiles in the current tilegroup
|
||||
int tg_start; // First tile in the current tilegroup
|
||||
int tg_size_bit_offset;
|
||||
#if CONFIG_REFERENCE_BUFFER
|
||||
SequenceHeader seq_params;
|
||||
#endif
|
||||
#if CONFIG_INSPECTION
|
||||
aom_inspect_cb inspect_cb;
|
||||
void *inspect_ctx;
|
||||
|
|
@ -154,12 +153,10 @@ int av1_get_raw_frame(struct AV1Decoder *pbi, YV12_BUFFER_CONFIG *sd);
|
|||
|
||||
int av1_get_frame_to_show(struct AV1Decoder *pbi, YV12_BUFFER_CONFIG *frame);
|
||||
|
||||
aom_codec_err_t av1_copy_reference_dec(struct AV1Decoder *pbi,
|
||||
AOM_REFFRAME ref_frame_flag,
|
||||
aom_codec_err_t av1_copy_reference_dec(struct AV1Decoder *pbi, int idx,
|
||||
YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
|
||||
AOM_REFFRAME ref_frame_flag,
|
||||
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, int idx,
|
||||
YV12_BUFFER_CONFIG *sd);
|
||||
|
||||
static INLINE uint8_t read_marker(aom_decrypt_cb decrypt_cb,
|
||||
|
|
@ -213,7 +210,6 @@ static INLINE int dec_is_ref_frame_buf(AV1Decoder *const pbi,
|
|||
}
|
||||
#endif // CONFIG_EXT_REFS
|
||||
|
||||
#if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
|
||||
#define ACCT_STR __func__
|
||||
static INLINE int av1_read_uniform(aom_reader *r, int n) {
|
||||
const int l = get_unsigned_bits(n);
|
||||
|
|
@ -225,7 +221,6 @@ static INLINE int av1_read_uniform(aom_reader *r, int n) {
|
|||
else
|
||||
return (v << 1) - m + aom_read_literal(r, 1, ACCT_STR);
|
||||
}
|
||||
#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
418
third_party/aom/av1/decoder/decodetxb.c
vendored
418
third_party/aom/av1/decoder/decodetxb.c
vendored
|
|
@ -15,16 +15,20 @@
|
|||
#include "av1/decoder/decodemv.h"
|
||||
#include "av1/decoder/decodetxb.h"
|
||||
#include "av1/decoder/dsubexp.h"
|
||||
#include "av1/decoder/symbolrate.h"
|
||||
|
||||
#define ACCT_STR __func__
|
||||
|
||||
static int read_golomb(MACROBLOCKD *xd, aom_reader *r) {
|
||||
static int read_golomb(MACROBLOCKD *xd, aom_reader *r, FRAME_COUNTS *counts) {
|
||||
#if !CONFIG_SYMBOLRATE
|
||||
(void)counts;
|
||||
#endif
|
||||
int x = 1;
|
||||
int length = 0;
|
||||
int i = 0;
|
||||
|
||||
while (!i) {
|
||||
i = aom_read_bit(r, ACCT_STR);
|
||||
i = av1_read_record_bit(counts, r, ACCT_STR);
|
||||
++length;
|
||||
if (length >= 32) {
|
||||
aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME,
|
||||
|
|
@ -35,21 +39,247 @@ static int read_golomb(MACROBLOCKD *xd, aom_reader *r) {
|
|||
|
||||
for (i = 0; i < length - 1; ++i) {
|
||||
x <<= 1;
|
||||
x += aom_read_bit(r, ACCT_STR);
|
||||
x += av1_read_record_bit(counts, r, ACCT_STR);
|
||||
}
|
||||
|
||||
return x - 1;
|
||||
}
|
||||
|
||||
static INLINE int read_nz_map(aom_reader *r, tran_low_t *tcoeffs, int plane,
|
||||
const int16_t *scan, TX_SIZE tx_size,
|
||||
TX_TYPE tx_type, FRAME_CONTEXT *fc,
|
||||
FRAME_COUNTS *counts) {
|
||||
TX_SIZE txs_ctx = get_txsize_context(tx_size);
|
||||
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
|
||||
const int height = tx_size_high[tx_size];
|
||||
#if CONFIG_CTX1D
|
||||
const int width = tx_size_wide[tx_size];
|
||||
const int eob_offset = width + height;
|
||||
const TX_CLASS tx_class = get_tx_class(tx_type);
|
||||
const int seg_eob =
|
||||
(tx_class == TX_CLASS_2D) ? tx_size_2d[tx_size] : eob_offset;
|
||||
#else
|
||||
const int seg_eob = tx_size_2d[tx_size];
|
||||
#endif
|
||||
const PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] =
|
||||
(counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL;
|
||||
#if !LV_MAP_PROB
|
||||
aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type];
|
||||
aom_prob *eob_flag = fc->eob_flag[txs_ctx][plane_type];
|
||||
#endif
|
||||
int c;
|
||||
for (c = 0; c < seg_eob; ++c) {
|
||||
int is_nz;
|
||||
int coeff_ctx = get_nz_map_ctx(tcoeffs, c, scan, bwl, height, tx_type);
|
||||
int eob_ctx = get_eob_ctx(tcoeffs, scan[c], txs_ctx, tx_type);
|
||||
|
||||
if (c < seg_eob - 1) {
|
||||
#if LV_MAP_PROB
|
||||
is_nz = av1_read_record_bin(
|
||||
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
|
||||
#endif
|
||||
} else {
|
||||
is_nz = 1;
|
||||
}
|
||||
|
||||
// set non-zero coefficient map.
|
||||
tcoeffs[scan[c]] = is_nz;
|
||||
|
||||
if (c == seg_eob - 1) {
|
||||
++c;
|
||||
break;
|
||||
}
|
||||
|
||||
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
|
||||
|
||||
if (is_nz) {
|
||||
#if LV_MAP_PROB
|
||||
int is_eob = av1_read_record_bin(
|
||||
counts, r, fc->eob_flag_cdf[txs_ctx][plane_type][eob_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int is_eob = aom_read(r, eob_flag[eob_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob];
|
||||
if (is_eob) break;
|
||||
}
|
||||
}
|
||||
return AOMMIN(seg_eob, c + 1);
|
||||
}
|
||||
|
||||
#if CONFIG_CTX1D
|
||||
static INLINE int read_nz_map_vert(aom_reader *r, tran_low_t *tcoeffs,
|
||||
int plane, const int16_t *scan,
|
||||
const int16_t *iscan, TX_SIZE tx_size,
|
||||
TX_TYPE tx_type, FRAME_CONTEXT *fc,
|
||||
FRAME_COUNTS *counts) {
|
||||
const TX_SIZE txs_ctx = get_txsize_context(tx_size);
|
||||
const PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
const TX_CLASS tx_class = get_tx_class(tx_type);
|
||||
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
|
||||
const int width = tx_size_wide[tx_size];
|
||||
const int height = tx_size_high[tx_size];
|
||||
int16_t eob_ls[MAX_HVTX_SIZE];
|
||||
int eob = 0;
|
||||
#if !LV_MAP_PROB
|
||||
aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type];
|
||||
#endif
|
||||
for (int col = 0; col < width; ++col) {
|
||||
int el_ctx = get_empty_line_ctx(col, eob_ls);
|
||||
#if LV_MAP_PROB
|
||||
int empty_line = av1_read_record_bin(
|
||||
counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int empty_line = aom_read(
|
||||
r, fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts)
|
||||
++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][empty_line];
|
||||
if (!empty_line) {
|
||||
int row;
|
||||
for (row = 0; row < height; ++row) {
|
||||
if (row + 1 != height) {
|
||||
int coeff_idx = row * width + col;
|
||||
int scan_idx = iscan[coeff_idx];
|
||||
int coeff_ctx =
|
||||
get_nz_map_ctx(tcoeffs, scan_idx, scan, bwl, height, tx_type);
|
||||
#if LV_MAP_PROB
|
||||
int is_nz = av1_read_record_bin(
|
||||
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->nz_map[txs_ctx][plane_type][coeff_ctx][is_nz];
|
||||
tcoeffs[coeff_idx] = is_nz;
|
||||
if (is_nz) {
|
||||
eob = AOMMAX(eob, iscan[coeff_idx] + 1);
|
||||
if (row + 1 != height) {
|
||||
int eob_ctx = get_hv_eob_ctx(col, row, eob_ls);
|
||||
#if LV_MAP_PROB
|
||||
int is_eob = av1_read_record_bin(
|
||||
counts, r,
|
||||
fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int is_eob = aom_read(
|
||||
r, fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx],
|
||||
ACCT_STR);
|
||||
#endif
|
||||
if (counts)
|
||||
++counts
|
||||
->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx][is_eob];
|
||||
if (is_eob) break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int coeff_idx = row * width + col;
|
||||
tcoeffs[coeff_idx] = 1;
|
||||
eob = AOMMAX(eob, iscan[coeff_idx] + 1);
|
||||
}
|
||||
}
|
||||
eob_ls[col] = AOMMIN(height, row + 1);
|
||||
} else {
|
||||
eob_ls[col] = 0;
|
||||
}
|
||||
}
|
||||
return eob;
|
||||
}
|
||||
|
||||
static INLINE int read_nz_map_horiz(aom_reader *r, tran_low_t *tcoeffs,
|
||||
int plane, const int16_t *scan,
|
||||
const int16_t *iscan, TX_SIZE tx_size,
|
||||
TX_TYPE tx_type, FRAME_CONTEXT *fc,
|
||||
FRAME_COUNTS *counts) {
|
||||
const TX_SIZE txs_ctx = get_txsize_context(tx_size);
|
||||
const PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
const TX_CLASS tx_class = get_tx_class(tx_type);
|
||||
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
|
||||
const int width = tx_size_wide[tx_size];
|
||||
const int height = tx_size_high[tx_size];
|
||||
int16_t eob_ls[MAX_HVTX_SIZE];
|
||||
int eob = 0;
|
||||
#if !LV_MAP_PROB
|
||||
aom_prob *nz_map = fc->nz_map[txs_ctx][plane_type];
|
||||
#endif
|
||||
for (int row = 0; row < height; ++row) {
|
||||
int el_ctx = get_empty_line_ctx(row, eob_ls);
|
||||
#if LV_MAP_PROB
|
||||
int empty_line = av1_read_record_bin(
|
||||
counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int empty_line = aom_read(
|
||||
r, fc->empty_line[txs_ctx][plane_type][tx_class][el_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts)
|
||||
++counts->empty_line[txs_ctx][plane_type][tx_class][el_ctx][empty_line];
|
||||
if (!empty_line) {
|
||||
int col;
|
||||
for (col = 0; col < width; ++col) {
|
||||
if (col + 1 != width) {
|
||||
int coeff_idx = row * width + col;
|
||||
int scan_idx = iscan[coeff_idx];
|
||||
int coeff_ctx =
|
||||
get_nz_map_ctx(tcoeffs, scan_idx, scan, bwl, height, tx_type);
|
||||
#if LV_MAP_PROB
|
||||
int is_nz = av1_read_record_bin(
|
||||
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->nz_map[txs_ctx][plane_type][coeff_ctx][is_nz];
|
||||
tcoeffs[coeff_idx] = is_nz;
|
||||
if (is_nz) {
|
||||
eob = AOMMAX(eob, iscan[coeff_idx] + 1);
|
||||
int eob_ctx = get_hv_eob_ctx(row, col, eob_ls);
|
||||
#if LV_MAP_PROB
|
||||
int is_eob = av1_read_record_bin(
|
||||
counts, r,
|
||||
fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int is_eob =
|
||||
aom_read(r, fc->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx],
|
||||
ACCT_STR);
|
||||
#endif
|
||||
if (counts)
|
||||
++counts->hv_eob[txs_ctx][plane_type][tx_class][eob_ctx][is_eob];
|
||||
if (is_eob) break;
|
||||
}
|
||||
} else {
|
||||
int coeff_idx = row * width + col;
|
||||
tcoeffs[coeff_idx] = 1;
|
||||
eob = AOMMAX(eob, iscan[coeff_idx] + 1);
|
||||
}
|
||||
}
|
||||
eob_ls[row] = AOMMIN(width, col + 1);
|
||||
} else {
|
||||
eob_ls[row] = 0;
|
||||
}
|
||||
}
|
||||
return eob;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
||||
aom_reader *r, int blk_row, int blk_col, int block,
|
||||
int plane, tran_low_t *tcoeffs, TXB_CTX *txb_ctx,
|
||||
TX_SIZE tx_size, int16_t *max_scan_line, int *eob) {
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
FRAME_COUNTS *counts = xd->counts;
|
||||
TX_SIZE txs_ctx = get_txsize_context(tx_size);
|
||||
PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
aom_prob *nz_map = cm->fc->nz_map[txs_ctx][plane_type];
|
||||
aom_prob *eob_flag = cm->fc->eob_flag[txs_ctx][plane_type];
|
||||
#if !LV_MAP_PROB
|
||||
aom_prob *nz_map = ec_ctx->nz_map[txs_ctx][plane_type];
|
||||
aom_prob *eob_flag = ec_ctx->eob_flag[txs_ctx][plane_type];
|
||||
#endif
|
||||
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
|
||||
const int seg_eob = tx_size_2d[tx_size];
|
||||
int c = 0;
|
||||
|
|
@ -59,14 +289,16 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
|
||||
const int height = tx_size_high[tx_size];
|
||||
int cul_level = 0;
|
||||
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2];
|
||||
|
||||
nz_map_count = (counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL;
|
||||
|
||||
memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob);
|
||||
|
||||
#if LV_MAP_PROB
|
||||
int all_zero = av1_read_record_bin(
|
||||
counts, r, ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
int all_zero =
|
||||
aom_read(r, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx], ACCT_STR);
|
||||
aom_read(r, ec_ctx->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (xd->counts)
|
||||
++xd->counts->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx][all_zero];
|
||||
|
||||
|
|
@ -89,42 +321,46 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
|
||||
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
|
||||
const int16_t *scan = scan_order->scan;
|
||||
|
||||
#if CONFIG_CTX1D
|
||||
const int16_t *iscan = scan_order->iscan;
|
||||
|
||||
for (c = 0; c < seg_eob; ++c) {
|
||||
int is_nz;
|
||||
int coeff_ctx = get_nz_map_ctx(tcoeffs, scan[c], bwl, height, iscan);
|
||||
int eob_ctx = get_eob_ctx(tcoeffs, scan[c], txs_ctx);
|
||||
|
||||
if (c < seg_eob - 1)
|
||||
is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
|
||||
else
|
||||
is_nz = 1;
|
||||
|
||||
// set non-zero coefficient map.
|
||||
tcoeffs[scan[c]] = is_nz;
|
||||
|
||||
if (c == seg_eob - 1) {
|
||||
++c;
|
||||
break;
|
||||
}
|
||||
|
||||
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
|
||||
|
||||
if (is_nz) {
|
||||
int is_eob = aom_read(r, eob_flag[eob_ctx], ACCT_STR);
|
||||
if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob];
|
||||
if (is_eob) break;
|
||||
TX_CLASS tx_class = get_tx_class(tx_type);
|
||||
if (tx_class == TX_CLASS_2D) {
|
||||
*eob =
|
||||
read_nz_map(r, tcoeffs, plane, scan, tx_size, tx_type, ec_ctx, counts);
|
||||
} else {
|
||||
#if LV_MAP_PROB
|
||||
const int eob_mode = av1_read_record_bin(
|
||||
counts, r, ec_ctx->eob_mode_cdf[txs_ctx][plane_type][tx_class], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
const int eob_mode =
|
||||
aom_read(r, ec_ctx->eob_mode[txs_ctx][plane_type][tx_class], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->eob_mode[txs_ctx][plane_type][tx_class][eob_mode];
|
||||
if (eob_mode == 0) {
|
||||
*eob = read_nz_map(r, tcoeffs, plane, scan, tx_size, tx_type, ec_ctx,
|
||||
counts);
|
||||
} else {
|
||||
assert(tx_class == TX_CLASS_VERT || tx_class == TX_CLASS_HORIZ);
|
||||
if (tx_class == TX_CLASS_VERT)
|
||||
*eob = read_nz_map_vert(r, tcoeffs, plane, scan, iscan, tx_size,
|
||||
tx_type, ec_ctx, counts);
|
||||
else
|
||||
*eob = read_nz_map_horiz(r, tcoeffs, plane, scan, iscan, tx_size,
|
||||
tx_type, ec_ctx, counts);
|
||||
}
|
||||
}
|
||||
|
||||
*eob = AOMMIN(seg_eob, c + 1);
|
||||
#else
|
||||
*eob = read_nz_map(r, tcoeffs, plane, scan, tx_size, tx_type, ec_ctx, counts);
|
||||
#endif
|
||||
*max_scan_line = *eob;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < NUM_BASE_LEVELS; ++i) {
|
||||
aom_prob *coeff_base = cm->fc->coeff_base[txs_ctx][plane_type][i];
|
||||
|
||||
#if !LV_MAP_PROB
|
||||
aom_prob *coeff_base = ec_ctx->coeff_base[txs_ctx][plane_type][i];
|
||||
#endif
|
||||
update_eob = 0;
|
||||
for (c = *eob - 1; c >= 0; --c) {
|
||||
tran_low_t *v = &tcoeffs[scan[c]];
|
||||
|
|
@ -135,7 +371,14 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
|
||||
ctx = get_base_ctx(tcoeffs, scan[c], bwl, height, i + 1);
|
||||
|
||||
if (aom_read(r, coeff_base[ctx], ACCT_STR)) {
|
||||
#if LV_MAP_PROB
|
||||
if (av1_read_record_bin(
|
||||
counts, r, ec_ctx->coeff_base_cdf[txs_ctx][plane_type][i][ctx], 2,
|
||||
ACCT_STR))
|
||||
#else
|
||||
if (aom_read(r, coeff_base[ctx], ACCT_STR))
|
||||
#endif
|
||||
{
|
||||
*v = i + 1;
|
||||
cul_level += i + 1;
|
||||
|
||||
|
|
@ -143,11 +386,17 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
|
||||
if (c == 0) {
|
||||
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
|
||||
#if LV_MAP_PROB
|
||||
sign = av1_read_record_bin(
|
||||
counts, r, ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], 2,
|
||||
ACCT_STR);
|
||||
#else
|
||||
sign =
|
||||
aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
|
||||
aom_read(r, ec_ctx->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
|
||||
} else {
|
||||
sign = aom_read_bit(r, ACCT_STR);
|
||||
sign = av1_read_record_bit(counts, r, ACCT_STR);
|
||||
}
|
||||
if (sign) *v = -(*v);
|
||||
continue;
|
||||
|
|
@ -170,18 +419,74 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
|
||||
if (c == 0) {
|
||||
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
|
||||
sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
|
||||
#if LV_MAP_PROB
|
||||
sign = av1_read_record_bin(
|
||||
counts, r, ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], 2, ACCT_STR);
|
||||
#else
|
||||
sign = aom_read(r, ec_ctx->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
|
||||
#endif
|
||||
if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
|
||||
} else {
|
||||
sign = aom_read_bit(r, ACCT_STR);
|
||||
sign = av1_read_record_bit(counts, r, ACCT_STR);
|
||||
}
|
||||
|
||||
ctx = get_br_ctx(tcoeffs, scan[c], bwl, height);
|
||||
|
||||
if (cm->fc->coeff_lps[txs_ctx][plane_type][ctx] == 0) exit(0);
|
||||
#if BR_NODE
|
||||
for (idx = 0; idx < BASE_RANGE_SETS; ++idx) {
|
||||
#if LV_MAP_PROB
|
||||
if (av1_read_record_bin(
|
||||
counts, r, ec_ctx->coeff_br_cdf[txs_ctx][plane_type][idx][ctx], 2,
|
||||
ACCT_STR))
|
||||
#else // LV_MAP_PROB
|
||||
if (aom_read(r, ec_ctx->coeff_br[txs_ctx][plane_type][idx][ctx],
|
||||
ACCT_STR))
|
||||
#endif // LV_MAP_PROB
|
||||
{
|
||||
int extra_bits = (1 << br_extra_bits[idx]) - 1;
|
||||
// int br_offset = aom_read_literal(r, extra_bits, ACCT_STR);
|
||||
int br_offset = 0;
|
||||
int tok;
|
||||
if (counts) ++counts->coeff_br[txs_ctx][plane_type][idx][ctx][1];
|
||||
for (tok = 0; tok < extra_bits; ++tok) {
|
||||
#if LV_MAP_PROB
|
||||
if (av1_read_record_bin(
|
||||
counts, r, ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2,
|
||||
ACCT_STR))
|
||||
#else
|
||||
if (aom_read(r, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx],
|
||||
ACCT_STR))
|
||||
#endif
|
||||
{
|
||||
br_offset = tok;
|
||||
if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][1];
|
||||
break;
|
||||
}
|
||||
if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][0];
|
||||
}
|
||||
if (tok == extra_bits) br_offset = extra_bits;
|
||||
|
||||
int br_base = br_index_to_coeff[idx];
|
||||
|
||||
*v = NUM_BASE_LEVELS + 1 + br_base + br_offset;
|
||||
cul_level += *v;
|
||||
if (sign) *v = -(*v);
|
||||
break;
|
||||
}
|
||||
if (counts) ++counts->coeff_br[txs_ctx][plane_type][idx][ctx][0];
|
||||
}
|
||||
|
||||
if (idx < BASE_RANGE_SETS) continue;
|
||||
#else
|
||||
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
|
||||
if (aom_read(r, cm->fc->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR)) {
|
||||
#if LV_MAP_PROB
|
||||
if (av1_read_record_bin(counts, r,
|
||||
ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx],
|
||||
2, ACCT_STR))
|
||||
#else
|
||||
if (aom_read(r, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR))
|
||||
#endif
|
||||
{
|
||||
*v = (idx + 1 + NUM_BASE_LEVELS);
|
||||
if (sign) *v = -(*v);
|
||||
cul_level += abs(*v);
|
||||
|
|
@ -192,9 +497,10 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][0];
|
||||
}
|
||||
if (idx < COEFF_BASE_RANGE) continue;
|
||||
#endif
|
||||
|
||||
// decode 0-th order Golomb code
|
||||
*v = read_golomb(xd, r) + COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS;
|
||||
*v = read_golomb(xd, r, counts) + COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS;
|
||||
if (sign) *v = -(*v);
|
||||
cul_level += abs(*v);
|
||||
}
|
||||
|
|
@ -202,6 +508,9 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
for (c = 0; c < *eob; ++c) {
|
||||
int16_t dqv = (c == 0) ? dequant[0] : dequant[1];
|
||||
tran_low_t *v = &tcoeffs[scan[c]];
|
||||
#if CONFIG_SYMBOLRATE
|
||||
av1_record_coeff(counts, abs(*v));
|
||||
#endif
|
||||
int sign = (*v) < 0;
|
||||
*v = (abs(*v) * dqv) >> shift;
|
||||
if (sign) *v = -(*v);
|
||||
|
|
@ -251,11 +560,15 @@ uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||
return cul_level;
|
||||
}
|
||||
|
||||
#if !LV_MAP_PROB
|
||||
static void read_txb_probs(FRAME_CONTEXT *fc, const TX_SIZE tx_size,
|
||||
aom_reader *r) {
|
||||
aom_reader *r, FRAME_COUNTS *counts) {
|
||||
#if !CONFIG_SYMBOLRATE
|
||||
(void)counts;
|
||||
#endif
|
||||
int plane, ctx, level;
|
||||
|
||||
if (aom_read_bit(r, ACCT_STR) == 0) return;
|
||||
if (av1_read_record_bit(counts, r, ACCT_STR) == 0) return;
|
||||
|
||||
for (ctx = 0; ctx < TXB_SKIP_CONTEXTS; ++ctx)
|
||||
av1_diff_update_prob(r, &fc->txb_skip[tx_size][ctx], ACCT_STR);
|
||||
|
|
@ -279,14 +592,17 @@ static void read_txb_probs(FRAME_CONTEXT *fc, const TX_SIZE tx_size,
|
|||
av1_diff_update_prob(r, &fc->coeff_lps[tx_size][plane][ctx], ACCT_STR);
|
||||
}
|
||||
|
||||
void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r) {
|
||||
void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r,
|
||||
FRAME_COUNTS *counts) {
|
||||
const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
|
||||
TX_SIZE tx_size;
|
||||
int ctx, plane;
|
||||
|
||||
for (plane = 0; plane < PLANE_TYPES; ++plane)
|
||||
for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
|
||||
av1_diff_update_prob(r, &fc->dc_sign[plane][ctx], ACCT_STR);
|
||||
|
||||
for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
|
||||
read_txb_probs(fc, tx_size, r);
|
||||
read_txb_probs(fc, tx_size, r, counts);
|
||||
}
|
||||
#endif // !LV_MAP_PROB
|
||||
|
|
|
|||
5
third_party/aom/av1/decoder/decodetxb.h
vendored
5
third_party/aom/av1/decoder/decodetxb.h
vendored
|
|
@ -28,5 +28,8 @@ uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||
int plane, tran_low_t *tcoeffs,
|
||||
TX_SIZE tx_size, int16_t *max_scan_line,
|
||||
int *eob);
|
||||
void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r);
|
||||
#if !LV_MAP_PROB
|
||||
void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r,
|
||||
FRAME_COUNTS *counts);
|
||||
#endif // !LV_MAP_PROB
|
||||
#endif // DECODETXB_H_
|
||||
|
|
|
|||
190
third_party/aom/av1/decoder/detokenize.c
vendored
190
third_party/aom/av1/decoder/detokenize.c
vendored
|
|
@ -24,7 +24,11 @@
|
|||
#include "av1/common/common.h"
|
||||
#include "av1/common/entropy.h"
|
||||
#include "av1/common/idct.h"
|
||||
#endif
|
||||
|
||||
#include "av1/decoder/symbolrate.h"
|
||||
|
||||
#if !CONFIG_PVQ || CONFIG_VAR_TX
|
||||
#define EOB_CONTEXT_NODE 0
|
||||
#define ZERO_CONTEXT_NODE 1
|
||||
#define ONE_CONTEXT_NODE 2
|
||||
|
|
@ -43,31 +47,43 @@
|
|||
} while (0)
|
||||
|
||||
#if CONFIG_NEW_MULTISYMBOL
|
||||
#define READ_COEFF(prob_name, cdf_name, num, r) read_coeff(cdf_name, num, r);
|
||||
static INLINE int read_coeff(const aom_cdf_prob *const *cdf, int n,
|
||||
#define READ_COEFF(counts, prob_name, cdf_name, num, r) \
|
||||
read_coeff(counts, cdf_name, num, r);
|
||||
static INLINE int read_coeff(FRAME_COUNTS *counts,
|
||||
const aom_cdf_prob *const *cdf, int n,
|
||||
aom_reader *r) {
|
||||
#if !CONFIG_SYMBOLRATE
|
||||
(void)counts;
|
||||
#endif
|
||||
int val = 0;
|
||||
int i = 0;
|
||||
int count = 0;
|
||||
while (count < n) {
|
||||
const int size = AOMMIN(n - count, 4);
|
||||
val |= aom_read_cdf(r, cdf[i++], 1 << size, ACCT_STR) << count;
|
||||
val |= av1_read_record_cdf(counts, r, cdf[i++], 1 << size, ACCT_STR)
|
||||
<< count;
|
||||
count += size;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
#else
|
||||
#define READ_COEFF(prob_name, cdf_name, num, r) read_coeff(prob_name, num, r);
|
||||
static INLINE int read_coeff(const aom_prob *probs, int n, aom_reader *r) {
|
||||
#define READ_COEFF(counts, prob_name, cdf_name, num, r) \
|
||||
read_coeff(counts, prob_name, num, r);
|
||||
static INLINE int read_coeff(FRAME_COUNTS *counts, const aom_prob *probs, int n,
|
||||
aom_reader *r) {
|
||||
#if !CONFIG_SYMBOLRATE
|
||||
(void)counts;
|
||||
#endif
|
||||
int i, val = 0;
|
||||
for (i = 0; i < n; ++i) val = (val << 1) | aom_read(r, probs[i], ACCT_STR);
|
||||
for (i = 0; i < n; ++i)
|
||||
val = (val << 1) | av1_read_record(counts, r, probs[i], ACCT_STR);
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int token_to_value(aom_reader *const r, int token, TX_SIZE tx_size,
|
||||
int bit_depth) {
|
||||
static int token_to_value(FRAME_COUNTS *counts, aom_reader *const r, int token,
|
||||
TX_SIZE tx_size, int bit_depth) {
|
||||
#if !CONFIG_HIGHBITDEPTH
|
||||
assert(bit_depth == 8);
|
||||
#endif // !CONFIG_HIGHBITDEPTH
|
||||
|
|
@ -79,20 +95,25 @@ static int token_to_value(aom_reader *const r, int token, TX_SIZE tx_size,
|
|||
case THREE_TOKEN:
|
||||
case FOUR_TOKEN: return token;
|
||||
case CATEGORY1_TOKEN:
|
||||
return CAT1_MIN_VAL + READ_COEFF(av1_cat1_prob, av1_cat1_cdf, 1, r);
|
||||
return CAT1_MIN_VAL +
|
||||
READ_COEFF(counts, av1_cat1_prob, av1_cat1_cdf, 1, r);
|
||||
case CATEGORY2_TOKEN:
|
||||
return CAT2_MIN_VAL + READ_COEFF(av1_cat2_prob, av1_cat2_cdf, 2, r);
|
||||
return CAT2_MIN_VAL +
|
||||
READ_COEFF(counts, av1_cat2_prob, av1_cat2_cdf, 2, r);
|
||||
case CATEGORY3_TOKEN:
|
||||
return CAT3_MIN_VAL + READ_COEFF(av1_cat3_prob, av1_cat3_cdf, 3, r);
|
||||
return CAT3_MIN_VAL +
|
||||
READ_COEFF(counts, av1_cat3_prob, av1_cat3_cdf, 3, r);
|
||||
case CATEGORY4_TOKEN:
|
||||
return CAT4_MIN_VAL + READ_COEFF(av1_cat4_prob, av1_cat4_cdf, 4, r);
|
||||
return CAT4_MIN_VAL +
|
||||
READ_COEFF(counts, av1_cat4_prob, av1_cat4_cdf, 4, r);
|
||||
case CATEGORY5_TOKEN:
|
||||
return CAT5_MIN_VAL + READ_COEFF(av1_cat5_prob, av1_cat5_cdf, 5, r);
|
||||
return CAT5_MIN_VAL +
|
||||
READ_COEFF(counts, av1_cat5_prob, av1_cat5_cdf, 5, r);
|
||||
case CATEGORY6_TOKEN: {
|
||||
const int skip_bits = (int)sizeof(av1_cat6_prob) -
|
||||
av1_get_cat6_extrabits_size(tx_size, bit_depth);
|
||||
return CAT6_MIN_VAL + READ_COEFF(av1_cat6_prob + skip_bits, av1_cat6_cdf,
|
||||
18 - skip_bits, r);
|
||||
return CAT6_MIN_VAL + READ_COEFF(counts, av1_cat6_prob + skip_bits,
|
||||
av1_cat6_cdf, 18 - skip_bits, r);
|
||||
}
|
||||
default:
|
||||
assert(0); // Invalid token.
|
||||
|
|
@ -104,22 +125,22 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
TX_SIZE tx_size, TX_TYPE tx_type, const int16_t *dq,
|
||||
#if CONFIG_NEW_QUANT
|
||||
dequant_val_type_nuq *dq_val,
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
#else
|
||||
#if CONFIG_AOM_QM
|
||||
const qm_val_t *iqm[2][TX_SIZES_ALL],
|
||||
qm_val_t *iqm[2][TX_SIZES_ALL],
|
||||
#endif // CONFIG_AOM_QM
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
int ctx, const int16_t *scan, const int16_t *nb,
|
||||
int16_t *max_scan_line, aom_reader *r) {
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
const int max_eob = tx_size_2d[tx_size];
|
||||
const int ref = is_inter_block(&xd->mi[0]->mbmi);
|
||||
#if CONFIG_AOM_QM
|
||||
#if CONFIG_AOM_QM && !CONFIG_NEW_QUANT
|
||||
const qm_val_t *iqmatrix = iqm[!ref][tx_size];
|
||||
#else
|
||||
(void)tx_type;
|
||||
#endif // CONFIG_AOM_QM
|
||||
(void)tx_type;
|
||||
int band, c = 0;
|
||||
const int tx_size_ctx = txsize_sqr_map[tx_size];
|
||||
const TX_SIZE tx_size_ctx = txsize_sqr_map[tx_size];
|
||||
aom_cdf_prob(*coef_head_cdfs)[COEFF_CONTEXTS][CDF_SIZE(ENTROPY_TOKENS)] =
|
||||
ec_ctx->coef_head_cdfs[tx_size_ctx][type][ref];
|
||||
aom_cdf_prob(*coef_tail_cdfs)[COEFF_CONTEXTS][CDF_SIZE(ENTROPY_TOKENS)] =
|
||||
|
|
@ -130,7 +151,7 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
const uint8_t *band_translate = get_band_translate(tx_size);
|
||||
int dq_shift;
|
||||
int v, token;
|
||||
int16_t dqv = dq[0];
|
||||
int32_t dqv = dq[0];
|
||||
#if CONFIG_NEW_QUANT
|
||||
const tran_low_t *dqv_val = &dq_val[0][0];
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
|
@ -149,9 +170,10 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
dqv_val = &dq_val[band][0];
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
||||
comb_token = last_pos ? 2 * aom_read_bit(r, ACCT_STR) + 2
|
||||
: aom_read_symbol(r, coef_head_cdfs[band][ctx],
|
||||
HEAD_TOKENS + first_pos, ACCT_STR) +
|
||||
comb_token = last_pos ? 2 * av1_read_record_bit(xd->counts, r, ACCT_STR) + 2
|
||||
: av1_read_record_symbol(
|
||||
xd->counts, r, coef_head_cdfs[band][ctx],
|
||||
HEAD_TOKENS + first_pos, ACCT_STR) +
|
||||
!first_pos;
|
||||
if (first_pos) {
|
||||
if (comb_token == 0) return 0;
|
||||
|
|
@ -161,6 +183,9 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
while (!token) {
|
||||
*max_scan_line = AOMMAX(*max_scan_line, scan[c]);
|
||||
token_cache[scan[c]] = 0;
|
||||
#if CONFIG_SYMBOLRATE
|
||||
av1_record_coeff(xd->counts, 0);
|
||||
#endif
|
||||
++c;
|
||||
dqv = dq[1];
|
||||
ctx = get_coef_context(nb, token_cache, c);
|
||||
|
|
@ -168,18 +193,20 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
|
||||
last_pos = (c + 1 == max_eob);
|
||||
|
||||
comb_token = last_pos ? 2 * aom_read_bit(r, ACCT_STR) + 2
|
||||
: aom_read_symbol(r, coef_head_cdfs[band][ctx],
|
||||
HEAD_TOKENS, ACCT_STR) +
|
||||
1;
|
||||
comb_token =
|
||||
last_pos
|
||||
? 2 * av1_read_record_bit(xd->counts, r, ACCT_STR) + 2
|
||||
: av1_read_record_symbol(xd->counts, r, coef_head_cdfs[band][ctx],
|
||||
HEAD_TOKENS, ACCT_STR) +
|
||||
1;
|
||||
token = comb_token >> 1;
|
||||
}
|
||||
|
||||
more_data = comb_token & 1;
|
||||
|
||||
if (token > ONE_TOKEN)
|
||||
token +=
|
||||
aom_read_symbol(r, coef_tail_cdfs[band][ctx], TAIL_TOKENS, ACCT_STR);
|
||||
token += av1_read_record_symbol(xd->counts, r, coef_tail_cdfs[band][ctx],
|
||||
TAIL_TOKENS, ACCT_STR);
|
||||
#if CONFIG_NEW_QUANT
|
||||
dqv_val = &dq_val[band][0];
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
|
@ -187,7 +214,10 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
*max_scan_line = AOMMAX(*max_scan_line, scan[c]);
|
||||
token_cache[scan[c]] = av1_pt_energy_class[token];
|
||||
|
||||
val = token_to_value(r, token, tx_size, xd->bd);
|
||||
val = token_to_value(xd->counts, r, token, tx_size, xd->bd);
|
||||
#if CONFIG_SYMBOLRATE
|
||||
av1_record_coeff(xd->counts, val);
|
||||
#endif
|
||||
|
||||
#if CONFIG_NEW_QUANT
|
||||
v = av1_dequant_abscoeff_nuq(val, dqv, dqv_val);
|
||||
|
|
@ -195,14 +225,15 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
#else
|
||||
#if CONFIG_AOM_QM
|
||||
// Apply quant matrix only for 2D transforms
|
||||
if (IS_2D_TRANSFORM(tx_type))
|
||||
if (IS_2D_TRANSFORM(tx_type) && iqmatrix != NULL)
|
||||
dqv = ((iqmatrix[scan[c]] * (int)dqv) + (1 << (AOM_QM_BITS - 1))) >>
|
||||
AOM_QM_BITS;
|
||||
#endif
|
||||
v = (val * dqv) >> dq_shift;
|
||||
#endif
|
||||
|
||||
v = (int)check_range(aom_read_bit(r, ACCT_STR) ? -v : v, xd->bd);
|
||||
v = (int)check_range(av1_read_record_bit(xd->counts, r, ACCT_STR) ? -v : v,
|
||||
xd->bd);
|
||||
|
||||
dqcoeff[scan[c]] = v;
|
||||
|
||||
|
|
@ -218,22 +249,15 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
|
|||
}
|
||||
#endif // !CONFIG_PVQ
|
||||
|
||||
#if CONFIG_PALETTE
|
||||
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
||||
aom_reader *r) {
|
||||
const MODE_INFO *const mi = xd->mi[0];
|
||||
const MB_MODE_INFO *const mbmi = &mi->mbmi;
|
||||
static void decode_color_map_tokens(Av1ColorMapParam *param, aom_reader *r) {
|
||||
uint8_t color_order[PALETTE_MAX_SIZE];
|
||||
const int n = mbmi->palette_mode_info.palette_size[plane];
|
||||
uint8_t *const color_map = xd->plane[plane].color_index_map;
|
||||
aom_cdf_prob(
|
||||
*palette_cdf)[PALETTE_COLOR_INDEX_CONTEXTS][CDF_SIZE(PALETTE_COLORS)] =
|
||||
plane ? xd->tile_ctx->palette_uv_color_index_cdf
|
||||
: xd->tile_ctx->palette_y_color_index_cdf;
|
||||
int plane_block_width, plane_block_height, rows, cols;
|
||||
av1_get_block_dimensions(mbmi->sb_type, plane, xd, &plane_block_width,
|
||||
&plane_block_height, &rows, &cols);
|
||||
assert(plane == 0 || plane == 1);
|
||||
const int n = param->n_colors;
|
||||
uint8_t *const color_map = param->color_map;
|
||||
MapCdf color_map_cdf = param->map_cdf;
|
||||
int plane_block_width = param->plane_width;
|
||||
int plane_block_height = param->plane_height;
|
||||
int rows = param->rows;
|
||||
int cols = param->cols;
|
||||
|
||||
// The first color index.
|
||||
color_map[0] = av1_read_uniform(r, n);
|
||||
|
|
@ -246,14 +270,14 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
|||
const int color_ctx = av1_get_palette_color_index_context(
|
||||
color_map, plane_block_width, (i - j), j, n, color_order, NULL);
|
||||
const int color_idx = aom_read_symbol(
|
||||
r, palette_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
|
||||
r, color_map_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
|
||||
assert(color_idx >= 0 && color_idx < n);
|
||||
color_map[(i - j) * plane_block_width + j] = color_order[color_idx];
|
||||
}
|
||||
}
|
||||
// Copy last column to extra columns.
|
||||
if (cols < plane_block_width) {
|
||||
for (int i = 0; i < plane_block_height; ++i) {
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
memset(color_map + i * plane_block_width + cols,
|
||||
color_map[i * plane_block_width + cols - 1],
|
||||
(plane_block_width - cols));
|
||||
|
|
@ -265,7 +289,7 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
|||
const int color_ctx = av1_get_palette_color_index_context(
|
||||
color_map, plane_block_width, i, j, n, color_order, NULL);
|
||||
const int color_idx = aom_read_symbol(
|
||||
r, palette_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
|
||||
r, color_map_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
|
||||
assert(color_idx >= 0 && color_idx < n);
|
||||
color_map[i * plane_block_width + j] = color_order[color_idx];
|
||||
}
|
||||
|
|
@ -280,7 +304,60 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
|||
color_map + (rows - 1) * plane_block_width, plane_block_width);
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_PALETTE
|
||||
|
||||
static void get_palette_params(const MACROBLOCKD *const xd, int plane,
|
||||
BLOCK_SIZE bsize, Av1ColorMapParam *params) {
|
||||
assert(plane == 0 || plane == 1);
|
||||
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
||||
const PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
|
||||
params->color_map = xd->plane[plane].color_index_map;
|
||||
params->map_cdf = plane ? xd->tile_ctx->palette_uv_color_index_cdf
|
||||
: xd->tile_ctx->palette_y_color_index_cdf;
|
||||
params->n_colors = pmi->palette_size[plane];
|
||||
av1_get_block_dimensions(bsize, plane, xd, ¶ms->plane_width,
|
||||
¶ms->plane_height, ¶ms->rows, ¶ms->cols);
|
||||
}
|
||||
|
||||
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
static void get_mrc_params(const MACROBLOCKD *const xd, TX_SIZE tx_size,
|
||||
Av1ColorMapParam *params) {
|
||||
memset(params, 0, sizeof(*params));
|
||||
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
||||
const int is_inter = is_inter_block(mbmi);
|
||||
params->color_map = xd->mrc_mask;
|
||||
params->map_cdf = is_inter ? xd->tile_ctx->mrc_mask_inter_cdf
|
||||
: xd->tile_ctx->mrc_mask_intra_cdf;
|
||||
params->n_colors = 2;
|
||||
params->plane_width = tx_size_wide[tx_size];
|
||||
params->rows = tx_size_high[tx_size];
|
||||
params->cols = tx_size_wide[tx_size];
|
||||
}
|
||||
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
|
||||
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
|
||||
aom_reader *r) {
|
||||
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
||||
assert(plane == 0 || plane == 1);
|
||||
assert(mbmi->sb_type >= BLOCK_8X8);
|
||||
Av1ColorMapParam color_map_params;
|
||||
memset(&color_map_params, 0, sizeof(color_map_params));
|
||||
get_palette_params(xd, plane, mbmi->sb_type, &color_map_params);
|
||||
decode_color_map_tokens(&color_map_params, r);
|
||||
}
|
||||
|
||||
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
static void decode_mrc_tokens(MACROBLOCKD *const xd, TX_TYPE tx_size,
|
||||
aom_reader *r) {
|
||||
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
||||
const int is_inter = is_inter_block(mbmi);
|
||||
if ((is_inter && !SIGNAL_MRC_MASK_INTER) ||
|
||||
(!is_inter && !SIGNAL_MRC_MASK_INTRA))
|
||||
return;
|
||||
Av1ColorMapParam color_map_params;
|
||||
get_mrc_params(xd, tx_size, &color_map_params);
|
||||
decode_color_map_tokens(&color_map_params, r);
|
||||
}
|
||||
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
|
||||
#if !CONFIG_PVQ || CONFIG_VAR_TX
|
||||
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
|
||||
|
|
@ -297,14 +374,19 @@ int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
|
|||
get_dq_profile_from_ctx(xd->qindex[seg_id], ctx, ref, pd->plane_type);
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
|
||||
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
if (tx_type == MRC_DCT) decode_mrc_tokens(xd, tx_size, r);
|
||||
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
|
||||
|
||||
const int eob =
|
||||
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
|
||||
#if CONFIG_NEW_QUANT
|
||||
pd->seg_dequant_nuq[seg_id][dq],
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
#else
|
||||
#if CONFIG_AOM_QM
|
||||
pd->seg_iqmatrix[seg_id],
|
||||
#endif // CONFIG_AOM_QM
|
||||
#endif // CONFIG_NEW_QUANT
|
||||
ctx, sc->scan, sc->neighbors, max_scan_line, r);
|
||||
av1_set_contexts(xd, pd, plane, tx_size, eob > 0, x, y);
|
||||
#if CONFIG_ADAPT_SCAN
|
||||
|
|
|
|||
2
third_party/aom/av1/decoder/detokenize.h
vendored
2
third_party/aom/av1/decoder/detokenize.h
vendored
|
|
@ -22,9 +22,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_PALETTE
|
||||
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
|
||||
#endif // CONFIG_PALETTE
|
||||
|
||||
#if !CONFIG_PVQ || CONFIG_VAR_TX
|
||||
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
|
||||
|
|
|
|||
5
third_party/aom/av1/decoder/dthread.c
vendored
5
third_party/aom/av1/decoder/dthread.c
vendored
|
|
@ -181,7 +181,12 @@ void av1_frameworker_copy_context(AVxWorker *const dst_worker,
|
|||
memcpy(dst_cm->lf_info.lfthr, src_cm->lf_info.lfthr,
|
||||
(MAX_LOOP_FILTER + 1) * sizeof(loop_filter_thresh));
|
||||
dst_cm->lf.last_sharpness_level = src_cm->lf.sharpness_level;
|
||||
#if CONFIG_LOOPFILTER_LEVEL
|
||||
dst_cm->lf.filter_level[0] = src_cm->lf.filter_level[0];
|
||||
dst_cm->lf.filter_level[1] = src_cm->lf.filter_level[1];
|
||||
#else
|
||||
dst_cm->lf.filter_level = src_cm->lf.filter_level;
|
||||
#endif
|
||||
memcpy(dst_cm->lf.ref_deltas, src_cm->lf.ref_deltas, TOTAL_REFS_PER_FRAME);
|
||||
memcpy(dst_cm->lf.mode_deltas, src_cm->lf.mode_deltas, MAX_MODE_LF_DELTAS);
|
||||
dst_cm->seg = src_cm->seg;
|
||||
|
|
|
|||
32
third_party/aom/av1/decoder/inspection.c
vendored
32
third_party/aom/av1/decoder/inspection.c
vendored
|
|
@ -18,13 +18,19 @@
|
|||
#include "av1/common/cfl.h"
|
||||
#endif
|
||||
|
||||
void ifd_init(insp_frame_data *fd, int frame_width, int frame_height) {
|
||||
fd->mi_cols = ALIGN_POWER_OF_TWO(frame_width, 3) >> MI_SIZE_LOG2;
|
||||
fd->mi_rows = ALIGN_POWER_OF_TWO(frame_height, 3) >> MI_SIZE_LOG2;
|
||||
static void ifd_init_mi_rc(insp_frame_data *fd, int mi_cols, int mi_rows) {
|
||||
fd->mi_cols = mi_cols;
|
||||
fd->mi_rows = mi_rows;
|
||||
fd->mi_grid = (insp_mi_data *)aom_malloc(sizeof(insp_mi_data) * fd->mi_rows *
|
||||
fd->mi_cols);
|
||||
}
|
||||
|
||||
void ifd_init(insp_frame_data *fd, int frame_width, int frame_height) {
|
||||
int mi_cols = ALIGN_POWER_OF_TWO(frame_width, 3) >> MI_SIZE_LOG2;
|
||||
int mi_rows = ALIGN_POWER_OF_TWO(frame_height, 3) >> MI_SIZE_LOG2;
|
||||
ifd_init_mi_rc(fd, mi_cols, mi_rows);
|
||||
}
|
||||
|
||||
void ifd_clear(insp_frame_data *fd) {
|
||||
aom_free(fd->mi_grid);
|
||||
fd->mi_grid = NULL;
|
||||
|
|
@ -35,9 +41,9 @@ void ifd_clear(insp_frame_data *fd) {
|
|||
int ifd_inspect(insp_frame_data *fd, void *decoder) {
|
||||
struct AV1Decoder *pbi = (struct AV1Decoder *)decoder;
|
||||
AV1_COMMON *const cm = &pbi->common;
|
||||
// TODO(negge): Should this function just call ifd_clear() and ifd_init()?
|
||||
if (fd->mi_rows != cm->mi_rows || fd->mi_cols != cm->mi_cols) {
|
||||
return 0;
|
||||
ifd_clear(fd);
|
||||
ifd_init_mi_rc(fd, cm->mi_rows, cm->mi_cols);
|
||||
}
|
||||
fd->show_frame = cm->show_frame;
|
||||
fd->frame_type = cm->frame_type;
|
||||
|
|
@ -85,26 +91,26 @@ int ifd_inspect(insp_frame_data *fd, void *decoder) {
|
|||
// Skip Flag
|
||||
mi->skip = mbmi->skip;
|
||||
#if CONFIG_DUAL_FILTER
|
||||
mi->filter[0] = mbmi->interp_filter[0];
|
||||
mi->filter[1] = mbmi->interp_filter[1];
|
||||
mi->filter[0] = av1_extract_interp_filter(mbmi->interp_filters, 0);
|
||||
mi->filter[1] = av1_extract_interp_filter(mbmi->interp_filters, 1);
|
||||
#else
|
||||
mi->filter = mbmi->interp_filter;
|
||||
mi->filter = av1_extract_interp_filter(mbmi->interp_filters, 0);
|
||||
#endif
|
||||
// Transform
|
||||
mi->tx_type = mbmi->tx_type;
|
||||
mi->tx_size = mbmi->tx_size;
|
||||
|
||||
#if CONFIG_CDEF
|
||||
mi->cdef_level = cm->cdef_strengths[mbmi->cdef_strength] / CLPF_STRENGTHS;
|
||||
mi->cdef_level =
|
||||
cm->cdef_strengths[mbmi->cdef_strength] / CDEF_SEC_STRENGTHS;
|
||||
mi->cdef_strength =
|
||||
cm->cdef_strengths[mbmi->cdef_strength] % CLPF_STRENGTHS;
|
||||
cm->cdef_strengths[mbmi->cdef_strength] % CDEF_SEC_STRENGTHS;
|
||||
mi->cdef_strength += mi->cdef_strength == 3;
|
||||
#endif
|
||||
#if CONFIG_CFL
|
||||
if (mbmi->uv_mode == UV_DC_PRED) {
|
||||
if (mbmi->uv_mode == UV_CFL_PRED) {
|
||||
mi->cfl_alpha_idx = mbmi->cfl_alpha_idx;
|
||||
mi->cfl_alpha_sign = (mbmi->cfl_alpha_signs[CFL_PRED_V] << CFL_PRED_V) +
|
||||
mbmi->cfl_alpha_signs[CFL_PRED_U];
|
||||
mi->cfl_alpha_sign = mbmi->cfl_alpha_signs;
|
||||
} else {
|
||||
mi->cfl_alpha_idx = 0;
|
||||
mi->cfl_alpha_sign = 0;
|
||||
|
|
|
|||
88
third_party/aom/av1/decoder/symbolrate.h
vendored
Normal file
88
third_party/aom/av1/decoder/symbolrate.h
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include "aom_dsp/bitreader.h"
|
||||
|
||||
#ifndef AV1_DECODER_SYMBOLRATE_H_
|
||||
#define AV1_DECODER_SYMBOLRATE_H_
|
||||
|
||||
#if CONFIG_SYMBOLRATE
|
||||
static INLINE void av1_dump_symbol_rate(struct AV1Common *cm) {
|
||||
const FRAME_COUNTS *counts = &cm->counts;
|
||||
printf("%d %d %d %d\n", counts->coeff_num[0], counts->coeff_num[1],
|
||||
counts->symbol_num[0], counts->symbol_num[1]);
|
||||
}
|
||||
static INLINE int av1_read_record_symbol(FRAME_COUNTS *counts, aom_reader *r,
|
||||
aom_cdf_prob *cdf, int nsymbs,
|
||||
const char *str) {
|
||||
(void)str;
|
||||
if (counts) ++counts->symbol_num[0];
|
||||
return aom_read_symbol(r, cdf, nsymbs, str);
|
||||
}
|
||||
|
||||
#if CONFIG_LV_MAP
|
||||
static INLINE int av1_read_record_bin(FRAME_COUNTS *counts, aom_reader *r,
|
||||
aom_cdf_prob *cdf, int nsymbs,
|
||||
const char *str) {
|
||||
(void)str;
|
||||
if (counts) ++counts->symbol_num[0];
|
||||
return aom_read_bin(r, cdf, nsymbs, str);
|
||||
}
|
||||
#endif
|
||||
|
||||
static INLINE int av1_read_record(FRAME_COUNTS *counts, aom_reader *r, int prob,
|
||||
const char *str) {
|
||||
(void)str;
|
||||
if (counts) ++counts->symbol_num[0];
|
||||
return aom_read(r, prob, str);
|
||||
}
|
||||
|
||||
static INLINE int av1_read_record_cdf(FRAME_COUNTS *counts, aom_reader *r,
|
||||
const aom_cdf_prob *cdf, int nsymbs,
|
||||
const char *str) {
|
||||
(void)str;
|
||||
if (counts) ++counts->symbol_num[0];
|
||||
return aom_read_cdf(r, cdf, nsymbs, str);
|
||||
}
|
||||
|
||||
static INLINE int av1_read_record_bit(FRAME_COUNTS *counts, aom_reader *r,
|
||||
const char *str) {
|
||||
(void)str;
|
||||
if (counts) ++counts->symbol_num[1];
|
||||
return aom_read_bit(r, str);
|
||||
}
|
||||
|
||||
static INLINE void av1_record_coeff(FRAME_COUNTS *counts, tran_low_t qcoeff) {
|
||||
assert(qcoeff >= 0);
|
||||
if (counts) ++counts->coeff_num[qcoeff != 0];
|
||||
}
|
||||
#else // CONFIG_SYMBOLRATE
|
||||
|
||||
#define av1_read_record_symbol(counts, r, cdf, nsymbs, ACCT_STR_NAME) \
|
||||
aom_read_symbol(r, cdf, nsymbs, ACCT_STR_NAME)
|
||||
|
||||
#if CONFIG_LV_MAP
|
||||
#define av1_read_record_bin(counts, r, cdf, nsymbs, ACCT_STR_NAME) \
|
||||
aom_read_bin(r, cdf, nsymbs, ACCT_STR_NAME)
|
||||
#endif
|
||||
|
||||
#define av1_read_record(counts, r, prob, ACCT_STR_NAME) \
|
||||
aom_read(r, prob, ACCT_STR_NAME)
|
||||
|
||||
#define av1_read_record_cdf(counts, r, cdf, nsymbs, ACCT_STR_NAME) \
|
||||
aom_read_cdf(r, cdf, nsymbs, ACCT_STR_NAME)
|
||||
|
||||
#define av1_read_record_bit(counts, r, ACCT_STR_NAME) \
|
||||
aom_read_bit(r, ACCT_STR_NAME)
|
||||
|
||||
#endif // CONFIG_SYMBOLRATE
|
||||
|
||||
#endif // AV1_DECODER_SYMBOLRATE_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue