/* * Copyright (c) 2016, 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.
*/
/*!\brief AV1 intra mode selection for intra frames. * * \ingroup intra_mode_search * \callgraph * Top level function for rd-based intra mode selection during intra frame * encoding. This function will first search for the best luma prediction by * calling av1_rd_pick_intra_sby_mode, then it searches for chroma prediction * with av1_rd_pick_intra_sbuv_mode. If applicable, this function ends the * search with an evaluation for intrabc. * * \param[in] cpi Top-level encoder structure. * \param[in] x Pointer to structure holding all the data for the current macroblock. * \param[in] rd_cost Struct to keep track of the RD information. * \param[in] bsize Current block size. * \param[in] ctx Structure to hold snapshot of coding context during the mode picking process. * \param[in] best_rd Best RD seen for this block so far. * * \remark Nothing is returned. Instead, the MB_MODE_INFO struct inside x * is modified to store information about the best mode computed * in this function. The rd_cost struct is also updated with the RD stats * corresponding to the best mode found.
*/ void av1_rd_pick_intra_mode_sb(conststruct AV1_COMP *cpi, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, int64_t best_rd);
/*!\brief AV1 inter mode selection. * * \ingroup inter_mode_search * \callgraph * Top level function for inter mode selection. This function will loop over * all possible inter modes and select the best one for the current block by * computing the RD cost. The mode search and RD are computed in * handle_inter_mode(), which is called from this function within the main * loop. * * \param[in] cpi Top-level encoder structure * \param[in] tile_data Pointer to struct holding adaptive data/contexts/models for the tile during encoding * \param[in] x Pointer to structure holding all the data for the current macroblock * \param[in] rd_cost Struct to keep track of the RD information * \param[in] bsize Current block size * \param[in] ctx Structure to hold snapshot of coding context during the mode picking process * \param[in] best_rd_so_far Best RD seen for this block so far * * \remark Nothing is returned. Instead, the MB_MODE_INFO struct inside x * is modified to store information about the best mode computed * in this function. The rd_cost struct is also updated with the RD stats * corresponding to the best mode found.
*/ void av1_rd_pick_inter_mode(struct AV1_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, struct RD_STATS *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far);
/*!\brief AV1 intra mode selection based on Non-RD optimized model. * * \ingroup nonrd_mode_search * \callgraph * \callergraph * Top level function for Non-RD optimized intra mode selection. * This finction will loop over subset of intra modes and select the best one * based on calculated modelled RD cost. Only 4 intra modes are checked as * specified in \c intra_mode_list. When calculating RD cost Hadamard transform * of residual is used to calculate rate. Estmation of RD cost is performed * in \c av1_estimate_block_intra which is called from this function * * \param[in] cpi Top-level encoder structure * \param[in] x Pointer to structure holding all the data for the current macroblock * \param[in] rd_cost Struct to keep track of the RD information * \param[in] bsize Current block size * \param[in] ctx Structure to hold snapshot of coding context during the mode picking process * * \remark Nothing is returned. Instead, the MB_MODE_INFO struct inside x * is modified to store information about the best mode computed * in this function. The rd_cost struct is also updated with the RD stats * corresponding to the best mode found.
*/ void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx);
/*!\brief AV1 inter mode selection based on Non-RD optimized model. * * \ingroup nonrd_mode_search * \callgraph * Top level function for Non-RD optimized inter mode selection. * This finction will loop over subset of inter modes and select the best one * based on calculated modelled RD cost. While making decisions which modes to * check, this function applies heuristics based on previously checked modes, * block residual variance, block size, and other factors to prune certain * modes and reference frames. Currently only single reference frame modes * are checked. Additional heuristics are applied to decide if intra modes * need to be checked. * * * \param[in] cpi Top-level encoder structure * \param[in] tile_data Pointer to struct holding adaptive data/contexts/models for the tile during encoding * \param[in] x Pointer to structure holding all the data for the current macroblock * \param[in] rd_cost Struct to keep track of the RD information * \param[in] bsize Current block size * \param[in] ctx Structure to hold snapshot of coding context during the mode picking process * * \remark Nothing is returned. Instead, the MB_MODE_INFO struct inside x * is modified to store information about the best mode computed * in this function. The rd_cost struct is also updated with the RD stats * corresponding to the best mode found.
*/ void av1_nonrd_pick_inter_mode_sb(struct AV1_COMP *cpi, struct TileDataEnc *tile_data, struct macroblock *x, struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx);
staticinlineint av1_encoder_get_relative_dist(int a, int b) {
assert(a >= 0 && b >= 0); return (a - b);
}
// This function will return number of mi's in a superblock. staticinlineint av1_get_sb_mi_size(const AV1_COMMON *const cm) { constint mi_alloc_size_1d = mi_size_wide[cm->mi_params.mi_alloc_bsize]; int sb_mi_rows =
(mi_size_wide[cm->seq_params->sb_size] + mi_alloc_size_1d - 1) /
mi_alloc_size_1d;
assert(mi_size_wide[cm->seq_params->sb_size] ==
mi_size_high[cm->seq_params->sb_size]); int sb_mi_size = sb_mi_rows * sb_mi_rows;
return sb_mi_size;
}
// This function prunes the mode if either of the reference frame falls in the // pruning list staticinlineint prune_ref(const MV_REFERENCE_FRAME *const ref_frame, constunsignedint *const ref_display_order_hint, constunsignedint frame_display_order_hint, constint *ref_frame_list) { for (int i = 0; i < 2; i++) { if (ref_frame_list[i] == NONE_FRAME) continue;
if (sf->inter_sf.selective_ref_frame >= 2 ||
(sf->inter_sf.selective_ref_frame == 1 && comp_pred)) { int ref_frame_list[2] = { LAST3_FRAME, LAST2_FRAME };
if (x != NULL) { // Disable pruning if either tpl suggests that we keep the frame or // the pred_mv gives us the best sad if (x->tpl_keep_ref_frame[LAST3_FRAME] ||
x->pred_mv_sad[LAST3_FRAME] == x->best_pred_mv_sad[0]) {
ref_frame_list[0] = NONE_FRAME;
} if (x->tpl_keep_ref_frame[LAST2_FRAME] ||
x->pred_mv_sad[LAST2_FRAME] == x->best_pred_mv_sad[0]) {
ref_frame_list[1] = NONE_FRAME;
}
}
if (prune_ref(ref_frame, ref_display_order_hint,
ref_display_order_hint[GOLDEN_FRAME - LAST_FRAME],
ref_frame_list)) return 1;
}
if (sf->inter_sf.selective_ref_frame >= 3) { int ref_frame_list[2] = { ALTREF2_FRAME, BWDREF_FRAME };
if (x != NULL) { // Disable pruning if either tpl suggests that we keep the frame or // the pred_mv gives us the best sad if (x->tpl_keep_ref_frame[ALTREF2_FRAME] ||
x->pred_mv_sad[ALTREF2_FRAME] == x->best_pred_mv_sad[0]) {
ref_frame_list[0] = NONE_FRAME;
} if (x->tpl_keep_ref_frame[BWDREF_FRAME] ||
x->pred_mv_sad[BWDREF_FRAME] == x->best_pred_mv_sad[0]) {
ref_frame_list[1] = NONE_FRAME;
}
}
if (prune_ref(ref_frame, ref_display_order_hint,
ref_display_order_hint[LAST_FRAME - LAST_FRAME],
ref_frame_list)) return 1;
}
if (x != NULL && sf->inter_sf.prune_comp_ref_frames && comp_pred) { int closest_ref_frames = has_closest_ref_frames(
ref_frame, cpi->ref_frame_dist_info.nearest_past_ref,
cpi->ref_frame_dist_info.nearest_future_ref); if (closest_ref_frames == 0) { // Prune reference frames which are not the closest to the current frame. if (sf->inter_sf.prune_comp_ref_frames >= 2) { return 1;
} elseif (sf->inter_sf.prune_comp_ref_frames == 1) { // Prune reference frames with non minimum pred_mv_sad. if (has_best_pred_mv_sad(ref_frame, x) == 0) return 1;
}
}
}
return 0;
}
// This function will copy the best reference mode information from // MB_MODE_INFO_EXT to MB_MODE_INFO_EXT_FRAME. staticinlinevoid av1_copy_mbmi_ext_to_mbmi_ext_frame(
MB_MODE_INFO_EXT_FRAME *mbmi_ext_best, const MB_MODE_INFO_EXT *const mbmi_ext, uint8_t ref_frame_type) {
memcpy(mbmi_ext_best->ref_mv_stack, mbmi_ext->ref_mv_stack[ref_frame_type], sizeof(mbmi_ext->ref_mv_stack[USABLE_REF_MV_STACK_SIZE]));
memcpy(mbmi_ext_best->weight, mbmi_ext->weight[ref_frame_type], sizeof(mbmi_ext->weight[USABLE_REF_MV_STACK_SIZE]));
mbmi_ext_best->mode_context = mbmi_ext->mode_context[ref_frame_type];
mbmi_ext_best->ref_mv_count = mbmi_ext->ref_mv_count[ref_frame_type];
memcpy(mbmi_ext_best->global_mvs, mbmi_ext->global_mvs, sizeof(mbmi_ext->global_mvs));
}
#ifdef __cplusplus
} // extern "C" #endif
#endif// AOM_AV1_ENCODER_RDOPT_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet)
¤
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.