/* For keyframes, intra block modes are predicted by the (already decoded) modesfortheYblockstotheleftandaboveus;forinterframes,there
is a single probability table. */
typedefstruct { // Value of base colors for Y, U, and V
uint16_t palette_colors[3 * PALETTE_MAX_SIZE]; // Number of base colors for Y (0) and UV (1)
uint8_t palette_size[2];
} PALETTE_MODE_INFO;
typedefstruct RD_STATS { int rate; int zero_rate;
int64_t dist; // Please be careful of using rdcost, it's not guaranteed to be set all the // time. // TODO(angiebird): Create a set of functions to manipulate the RD_STATS. In // these functions, make sure rdcost is always up-to-date according to // rate/dist.
int64_t rdcost;
int64_t sse;
uint8_t skip_txfm; // sse should equal to dist when skip_txfm == 1 #if CONFIG_RD_DEBUG int txb_coeff_cost[MAX_MB_PLANE]; #endif// CONFIG_RD_DEBUG
} RD_STATS;
// This struct is used to group function args that are commonly // sent together in functions related to interinter compound modes typedefstruct {
uint8_t *seg_mask;
int8_t wedge_index;
int8_t wedge_sign;
DIFFWTD_MASK_TYPE mask_type;
COMPOUND_TYPE type;
} INTERINTER_COMPOUND_DATA;
/*! \brief Stores the prediction/txfm mode of the current coding block
*/ typedefstruct MB_MODE_INFO { /***************************************************************************** *\nameGeneralInfooftheCodingBlock
****************************************************************************/ /**@{*/ /*! \brief The block size of the current coding block */
BLOCK_SIZE bsize; /*! \brief The partition type of the current coding block. */
PARTITION_TYPE partition; /*! \brief The prediction mode used */
PREDICTION_MODE mode; /*! \brief The UV mode when intra is used */
UV_PREDICTION_MODE uv_mode; /*! \brief The q index for the current coding block. */ int current_qindex; /**@}*/
/***************************************************************************** *\nameInterModeInfo
****************************************************************************/ /**@{*/ /*! \brief The motion vectors used by the current inter mode */
int_mv mv[2]; /*! \brief The reference frames for the MV */
MV_REFERENCE_FRAME ref_frame[2]; /*! \brief Filter used in subpel interpolation. */
int_interpfilters interp_filters; /*! \brief The motion mode used by the inter prediction. */
MOTION_MODE motion_mode; /*! \brief Number of samples used by warp causal */
uint8_t num_proj_ref; /*! \brief The number of overlapped neighbors above/left for obmc/warp motion
* mode. */
uint8_t overlappable_neighbors; /*! \brief The parameters used in warp motion mode. */
WarpedMotionParams wm_params; /*! \brief The type of intra mode used by inter-intra */
INTERINTRA_MODE interintra_mode; /*! \brief The type of wedge used in interintra mode. */
int8_t interintra_wedge_index; /*! \brief Struct that stores the data used in interinter compound mode. */
INTERINTER_COMPOUND_DATA interinter_comp; /**@}*/
/***************************************************************************** *\nameIntraModeInfo
****************************************************************************/ /**@{*/ /*! \brief Directional mode delta: the angle is base angle + (angle_delta *
* step). */
int8_t angle_delta[PLANE_TYPES]; /*! \brief The type of filter intra mode used (if applicable). */
FILTER_INTRA_MODE_INFO filter_intra_mode_info; /*! \brief Chroma from Luma: Joint sign of alpha Cb and alpha Cr */
int8_t cfl_alpha_signs; /*! \brief Chroma from Luma: Index of the alpha Cb and alpha Cr combination */
uint8_t cfl_alpha_idx; /*! \brief Stores the size and colors of palette mode */
PALETTE_MODE_INFO palette_mode_info; /**@}*/
/***************************************************************************** *\nameTransformInfo
****************************************************************************/ /**@{*/ /*! \brief Whether to skip transforming and sending. */
uint8_t skip_txfm; /*! \brief Transform size when fixed size txfm is used (e.g. intra modes). */
TX_SIZE tx_size; /*! \brief Transform size when recursive txfm tree is on. */
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]; /**@}*/
/***************************************************************************** *\nameBitfieldforMemoryReduction
****************************************************************************/ /**@{*/ /*! \brief The segment id */
uint8_t segment_id : 3; /*! \brief Only valid when temporal update if off. */
uint8_t seg_id_predicted : 1; /*! \brief Which ref_mv to use */
uint8_t ref_mv_idx : 2; /*! \brief Inter skip mode */
uint8_t skip_mode : 1; /*! \brief Whether intrabc is used. */
uint8_t use_intrabc : 1; /*! \brief Indicates if masked compound is used(1) or not (0). */
uint8_t comp_group_idx : 1; /*! \brief Indicates whether dist_wtd_comp(0) is used or not (0). */
uint8_t compound_idx : 1; /*! \brief Whether to use interintra wedge */
uint8_t use_wedge_interintra : 1; /*! \brief CDEF strength per BLOCK_64X64 */
int8_t cdef_strength : 4; /**@}*/
#if CONFIG_RD_DEBUG /*! \brief RD info used for debugging */
RD_STATS rd_stats; /*! \brief The current row in unit of 4x4 blocks for debugging */ int mi_row; /*! \brief The current col in unit of 4x4 blocks for debugging */ int mi_col; #endif #if CONFIG_INSPECTION /*! \brief Whether we are skipping the current rows or columns. */
int16_t tx_skip[TXK_TYPE_BUF_LEN]; #endif
} MB_MODE_INFO;
typedefstruct macroblockd_plane {
PLANE_TYPE plane_type; int subsampling_x; int subsampling_y; struct buf_2d dst; struct buf_2d pre[2];
ENTROPY_CONTEXT *above_entropy_context;
ENTROPY_CONTEXT *left_entropy_context;
// The dequantizers below are true dequantizers used only in the // dequantization process. They have the same coefficient // shift/scale as TX.
int16_t seg_dequant_QTX[MAX_SEGMENTS][2]; // Pointer to color index map of: // - Current coding block, on encoder side. // - Current superblock, on decoder side.
uint8_t *color_index_map;
/*!\brief Parameters related to Sgrproj Filter */ typedefstruct { /*! *Parameterindex.
*/ int ep;
/*! *Weightsforlinearcombinationoffilteredversions
*/ int xqd[2];
} SgrprojInfo;
/*!\cond */
#define CFL_MAX_BLOCK_SIZE (BLOCK_32X32) #define CFL_BUF_LINE (32) #define CFL_BUF_LINE_I128 (CFL_BUF_LINE >> 3) #define CFL_BUF_LINE_I256 (CFL_BUF_LINE >> 4) #define CFL_BUF_SQUARE (CFL_BUF_LINE * CFL_BUF_LINE) typedefstruct cfl_ctx { // Q3 reconstructed luma pixels (only Q2 is required, but Q3 is used to avoid // shifts)
uint16_t recon_buf_q3[CFL_BUF_SQUARE]; // Q3 AC contributions (reconstructed luma pixels - tx block avg)
int16_t ac_buf_q3[CFL_BUF_SQUARE];
// Cache the DC_PRED when performing RDO, so it does not have to be recomputed // for every scaling parameter bool dc_pred_is_cached[CFL_PRED_PLANES]; // Whether the DC_PRED cache is enabled. The DC_PRED cache is disabled when // decoding. bool use_dc_pred_cache; // Only cache the first row of the DC_PRED
int16_t dc_pred_cache[CFL_PRED_PLANES][CFL_BUF_LINE];
// Height and width currently used in the CfL prediction buffer. int buf_height, buf_width;
int are_parameters_computed;
// Chroma subsampling int subsampling_x, subsampling_y;
// Whether the reconstructed luma pixels need to be stored int store_y;
} CFL_CTX;
typedefstruct dist_wtd_comp_params { int use_dist_wtd_comp_avg; int fwd_offset; int bck_offset;
} DIST_WTD_COMP_PARAMS;
struct scale_factors;
/*!\endcond */
/*! \brief Variables related to current coding block. * *Thisisacommonsetofvariablesusedbybothencoderanddecoder. *Most/allofthepointersaremerepointerstoactualarraysareallocated *elsewhere.Thisismostlyforcodingconvenience.
*/ typedefstruct macroblockd { /** *\namePositionofcurrentmacroblockinmiunits
*/ /**@{*/ int mi_row; /*!< Row position in mi units. */ int mi_col; /*!< Column position in mi units. */ /**@}*/
/*! *Sameascm->mi_params.mi_stride,copiedhereforconvenience.
*/ int mi_stride;
/** *\nameDistanceofthismacroblockfromframeedgesin1/8thpixelunits.
*/ /**@{*/ int mb_to_left_edge; /*!< Distance from left edge */ int mb_to_right_edge; /*!< Distance from right edge */ int mb_to_top_edge; /*!< Distance from top edge */ int mb_to_bottom_edge; /*!< Distance from bottom edge */ /**@}*/
typedefstruct BitDepthInfo { int bit_depth; /*! Is the image buffer high bit depth? *Lowbitdepthbufferusesuint8_t. *Highbitdepthbufferusesuint16_t. *Equivalenttocm->seq_params->use_highbitdepth
*/ int use_highbitdepth_buf;
} BitDepthInfo;
staticinlineint get_sqr_bsize_idx(BLOCK_SIZE bsize) { switch (bsize) { case BLOCK_4X4: return0; case BLOCK_8X8: return1; case BLOCK_16X16: return2; case BLOCK_32X32: return3; case BLOCK_64X64: return4; case BLOCK_128X128: return5; default: return SQR_BLOCK_SIZES;
}
}
// For a square block size 'bsize', returns the size of the sub-blocks used by // the given partition type. If the partition produces sub-blocks of different // sizes, then the function returns the largest sub-block size. // Implements the Partition_Subsize lookup table in the spec (Section 9.3. // Conversion tables). // Note: the input block size should be square. // Otherwise it's considered invalid. staticinline BLOCK_SIZE get_partition_subsize(BLOCK_SIZE bsize,
PARTITION_TYPE partition) { if (partition == PARTITION_INVALID) { return BLOCK_INVALID;
} else { constint sqr_bsize_idx = get_sqr_bsize_idx(bsize); return sqr_bsize_idx >= SQR_BLOCK_SIZES
? BLOCK_INVALID
: subsize_lookup[partition][sqr_bsize_idx];
}
}
// Converts block_index for given transform size to index of the block in raster // order. staticinlineint av1_block_index_to_raster_order(TX_SIZE tx_size, int block_idx) { // For transform size 4x8, the possible block_idx values are 0 & 2, because // block_idx values are incremented in steps of size 'tx_width_unit x // tx_height_unit'. But, for this transform size, block_idx = 2 corresponds to // block number 1 in raster order, inside an 8x8 MI block. // For any other transform size, the two indices are equivalent. return (tx_size == TX_4X8 && block_idx == 2) ? 1 : block_idx;
}
// Inverse of above function. // Note: only implemented for transform sizes 4x4, 4x8 and 8x4 right now. staticinlineint av1_raster_order_to_block_index(TX_SIZE tx_size, int raster_order) {
assert(tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4); // We ensure that block indices are 0 & 2 if tx size is 4x8 or 8x4. return (tx_size == TX_4X4) ? raster_order : (raster_order > 0) ? 2 : 0;
}
constint txw = tx_size_wide_unit[tx_size]; constint txh = tx_size_high_unit[tx_size]; // The 16x16 unit is due to the constraint from tx_64x64 which sets the // maximum tx size for chroma as 32x32. Coupled with 4x1 transform block // size, the constraint takes effect in 32x16 / 16x32 size too. To solve // the intricacy, cover all the 16x16 units inside a 64 level transform. if (txw == tx_size_wide_unit[TX_64X64] ||
txh == tx_size_high_unit[TX_64X64]) { constint tx_unit = tx_size_wide_unit[TX_16X16]; for (int idy = 0; idy < txh; idy += tx_unit) { for (int idx = 0; idx < txw; idx += tx_unit) {
xd->tx_type_map[(blk_row + idy) * stride + blk_col + idx] = tx_type;
}
}
}
}
staticinline TX_TYPE av1_get_tx_type(const MACROBLOCKD *xd,
PLANE_TYPE plane_type, int blk_row, int blk_col, TX_SIZE tx_size, int reduced_tx_set) { const MB_MODE_INFO *const mbmi = xd->mi[0]; if (xd->lossless[mbmi->segment_id] || txsize_sqr_up_map[tx_size] > TX_32X32) { return DCT_DCT;
}
TX_TYPE tx_type; if (plane_type == PLANE_TYPE_Y) {
tx_type = xd->tx_type_map[blk_row * xd->tx_type_map_stride + blk_col];
} else { if (is_inter_block(mbmi)) { // scale back to y plane's coordinate conststruct macroblockd_plane *const pd = &xd->plane[plane_type];
blk_row <<= pd->subsampling_y;
blk_col <<= pd->subsampling_x;
tx_type = xd->tx_type_map[blk_row * xd->tx_type_map_stride + blk_col];
} else { // In intra mode, uv planes don't share the same prediction mode as y // plane, so the tx_type should not be shared
tx_type = intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV);
} const TxSetType tx_set_type =
av1_get_ext_tx_set_type(tx_size, is_inter_block(mbmi), reduced_tx_set); if (!av1_ext_tx_used[tx_set_type][tx_type]) tx_type = DCT_DCT;
}
assert(tx_type < TX_TYPES);
assert(av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, is_inter_block(mbmi),
reduced_tx_set)][tx_type]); return tx_type;
}
void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y, constint num_planes);
typedefvoid (*foreach_transformed_block_visitor)(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg);
void av1_set_entropy_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, int plane,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob, int aoff, int loff);
staticinlineint is_interintra_allowed_bsize_group(int group) { int i; for (i = 0; i < BLOCK_SIZES_ALL; i++) { if (size_group_lookup[i] == group &&
is_interintra_allowed_bsize((BLOCK_SIZE)i)) { return1;
}
} return0;
}
// Returns sub-sampled dimensions of the given block. // The output values for 'rows_within_bounds' and 'cols_within_bounds' will // differ from 'height' and 'width' when part of the block is outside the // right // and/or bottom image boundary. staticinlinevoid av1_get_block_dimensions(BLOCK_SIZE bsize, int plane, const MACROBLOCKD *xd, int *width, int *height, int *rows_within_bounds, int *cols_within_bounds) { constint block_height = block_size_high[bsize]; constint block_width = block_size_wide[bsize]; constint block_rows = (xd->mb_to_bottom_edge >= 0)
? block_height
: (xd->mb_to_bottom_edge >> 3) + block_height; constint block_cols = (xd->mb_to_right_edge >= 0)
? block_width
: (xd->mb_to_right_edge >> 3) + block_width; conststruct macroblockd_plane *const pd = &xd->plane[plane];
assert(IMPLIES(plane == PLANE_TYPE_Y, pd->subsampling_x == 0));
assert(IMPLIES(plane == PLANE_TYPE_Y, pd->subsampling_y == 0));
assert(block_width >= block_cols);
assert(block_height >= block_rows); constint plane_block_width = block_width >> pd->subsampling_x; constint plane_block_height = block_height >> pd->subsampling_y; // Special handling for chroma sub8x8. constint is_chroma_sub8_x = plane > 0 && plane_block_width < 4; constint is_chroma_sub8_y = plane > 0 && plane_block_height < 4; if (width) {
*width = plane_block_width + 2 * is_chroma_sub8_x;
assert(*width >= 0);
} if (height) {
*height = plane_block_height + 2 * is_chroma_sub8_y;
assert(*height >= 0);
} if (rows_within_bounds) {
*rows_within_bounds =
(block_rows >> pd->subsampling_y) + 2 * is_chroma_sub8_y;
assert(*rows_within_bounds >= 0);
} if (cols_within_bounds) {
*cols_within_bounds =
(block_cols >> pd->subsampling_x) + 2 * is_chroma_sub8_x;
assert(*cols_within_bounds >= 0);
}
}
/* clang-format off */ // Pointer to a three-dimensional array whose first dimension is PALETTE_SIZES. typedef aom_cdf_prob (*MapCdf)[PALETTE_COLOR_INDEX_CONTEXTS]
[CDF_SIZE(PALETTE_COLORS)]; // Pointer to a const three-dimensional array whose first dimension is // PALETTE_SIZES. typedefconstint (*ColorCost)[PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS]; /* clang-format on */
typedefstruct { int rows; int cols; int n_colors; int plane_width; int plane_height;
uint8_t *color_map;
MapCdf map_cdf;
ColorCost color_cost;
} Av1ColorMapParam;
staticinlineint is_nontrans_global_motion(const MACROBLOCKD *xd, const MB_MODE_INFO *mbmi) { int ref;
// First check if all modes are GLOBALMV if (mbmi->mode != GLOBALMV && mbmi->mode != GLOBAL_GLOBALMV) return0;
if (AOMMIN(mi_size_wide[mbmi->bsize], mi_size_high[mbmi->bsize]) < 2) return0;
// Now check if all global motion is non translational for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) { if (xd->global_motion[mbmi->ref_frame[ref]].wmtype == TRANSLATION) return0;
} return1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.