![]() |
AOMedia AV1 Codec
|
![]() |
Functions | |
void | av1_tf_do_filtering_row (struct AV1_COMP *cpi, struct ThreadData *td, int mb_row) |
Does temporal filter for a given macroblock row. More... | |
int | av1_temporal_filter (struct AV1_COMP *cpi, const int filter_frame_lookahead_idx, FRAME_UPDATE_TYPE update_type, int is_forward_keyframe, int *show_existing_arf) |
Performs temporal filtering if needed on a source frame. For example to create a filtered alternate reference frame (ARF) More... | |
static void | tf_motion_search (AV1_COMP *cpi, MACROBLOCK *mb, const YV12_BUFFER_CONFIG *frame_to_filter, const YV12_BUFFER_CONFIG *ref_frame, const BLOCK_SIZE block_size, const int mb_row, const int mb_col, MV *ref_mv, MV *subblock_mvs, int *subblock_mses) |
Does motion search for blocks in temporal filtering. This is the first step for temporal filtering. More specifically, given a frame to be filtered and another frame as reference, this function searches the reference frame to find out the most similar block as that from the frame to be filtered. This found block will be further used for weighted averaging. More... | |
static void | tf_build_predictor (const YV12_BUFFER_CONFIG *ref_frame, const MACROBLOCKD *mbd, const BLOCK_SIZE block_size, const int mb_row, const int mb_col, const int num_planes, const struct scale_factors *scale, const MV *subblock_mvs, uint8_t *pred) |
Builds predictor for blocks in temporal filtering. This is the second step for temporal filtering, which is to construct predictions from all reference frames INCLUDING the frame to be filtered itself. These predictors are built based on the motion search results (motion vector is set as 0 for the frame to be filtered), and will be futher used for weighted averaging. More... | |
void | av1_apply_temporal_filter_c (const YV12_BUFFER_CONFIG *frame_to_filter, const MACROBLOCKD *mbd, const BLOCK_SIZE block_size, const int mb_row, const int mb_col, const int num_planes, const double *noise_levels, const MV *subblock_mvs, const int *subblock_mses, const int q_factor, const int filter_strength, const uint8_t *pred, uint32_t *accum, uint16_t *count) |
Applies temporal filtering. NOTE that there are various optimised versions of this function called where the appropriate instruction set is supported. More... | |
static void | tf_normalize_filtered_frame (const MACROBLOCKD *mbd, const BLOCK_SIZE block_size, const int mb_row, const int mb_col, const int num_planes, const uint32_t *accum, const uint16_t *count, YV12_BUFFER_CONFIG *result_buffer) |
Normalizes the accumulated filtering result to produce the filtered frame. More... | |
static void | tf_do_filtering (AV1_COMP *cpi) |
Does temporal filter for a given frame. More... | |
static void | tf_setup_filtering_buffer (AV1_COMP *cpi, const int filter_frame_lookahead_idx, const int is_second_arf, FRAME_UPDATE_TYPE update_type, int is_forward_keyframe) |
Setups the frame buffer for temporal filtering. This fuction determines how many frames will be used for temporal filtering and then groups them into a buffer. This function will also estimate the noise level of the to-filter frame. More... | |
This module describes algorithms in AV1 assosciated with the pre-processing of source frames. See also Source Frame Processing
void av1_tf_do_filtering_row | ( | struct AV1_COMP * | cpi, |
struct ThreadData * | td, | ||
int | mb_row | ||
) |
Does temporal filter for a given macroblock row.
[in] | cpi | Top level encoder instance structure |
[in] | td | Pointer to thread data |
[in] | mb_row | Macroblock row to be filtered filtering |
References AV1EncoderConfig::algo_cfg, AV1_COMP::alt_ref_buffer, AlgoCfg::arnr_strength, av1_apply_temporal_filter_c(), TemporalFilterCtx::check_show_existing, AV1_COMP::common, macroblock::e_mbd, TemporalFilterCtx::filter_frame_idx, AV1_COMP::fn_ptr, TemporalFilterCtx::frames, TemporalFilterCtx::mb_cols, AV1Common::mi_params, macroblock::mv_limits, TemporalFilterCtx::noise_levels, TemporalFilterCtx::num_frames, TemporalFilterCtx::num_pels, AV1_COMP::oxcf, macroblockd::plane, TemporalFilterCtx::q_factor, TemporalFilterCtx::sf, tf_build_predictor(), AV1_COMP::tf_ctx, tf_motion_search(), and tf_normalize_filtered_frame().
Referenced by tf_do_filtering().
int av1_temporal_filter | ( | struct AV1_COMP * | cpi, |
const int | filter_frame_lookahead_idx, | ||
FRAME_UPDATE_TYPE | update_type, | ||
int | is_forward_keyframe, | ||
int * | show_existing_arf | ||
) |
Performs temporal filtering if needed on a source frame. For example to create a filtered alternate reference frame (ARF)
In this function, the lookahead index is different from the 0-based real index. For example, if we want to filter the first frame in the pre-fetched buffer cpi->lookahead
, the lookahead index will be -1 instead of 0. More concretely, 0 indicates the first LOOKAHEAD frame, which is the second frame in the pre-fetched buffer. Another example: if we want to filter the 17-th frame, which is an ARF, the lookahead index is 15 instead of 16. Futhermore, negative number is used for key frame in one-pass mode, where key frame is filtered with the frames before it instead of after it. For example, -15 means to filter the 17-th frame, which is a key frame in one-pass mode.
[in] | cpi | Top level encoder instance structure |
[in] | filter_frame_lookahead_idx | The index of the to-filter frame in the lookahead buffer cpi->lookahead. |
[in] | update_type | This frame's update type. |
[in] | is_forward_keyframe | Indicate whether this is a forward keyframe. |
[in,out] | show_existing_arf | Whether to show existing ARF. This field is updated in this function. |
Referenced by av1_get_second_pass_params().
|
static |
Does motion search for blocks in temporal filtering. This is the first step for temporal filtering. More specifically, given a frame to be filtered and another frame as reference, this function searches the reference frame to find out the most similar block as that from the frame to be filtered. This found block will be further used for weighted averaging.
NOTE: Besides doing motion search for the entire block, this function will also do motion search for each 1/4 sub-block to get more precise predictions. Then, this function will determines whether to use 4 sub-blocks to replace the entire block. If we do need to split the entire block, 4 elements in subblock_mvs
and subblock_mses
refer to the searched motion vector and search error (MSE) w.r.t. each sub-block respectively. Otherwise, the 4 elements will be the same, all of which are assigned as the searched motion vector and search error (MSE) for the entire block.
[in] | cpi | Top level encoder instance structure |
[in] | mb | Pointer to macroblock |
[in] | frame_to_filter | Pointer to the frame to be filtered |
[in] | ref_frame | Pointer to the reference frame |
[in] | block_size | Block size used for motion search |
[in] | mb_row | Row index of the block in the frame |
[in] | mb_col | Column index of the block in the frame |
[in] | ref_mv | Reference motion vector, which is commonly inherited from the motion search result of previous frame. |
[out] | subblock_mvs | Pointer to the motion vectors for 4 sub-blocks |
[out] | subblock_mses | Pointer to the search errors (MSE) for 4 sub-blocks |
References macroblockd::bd, AV1_COMP::common, FeatureFlags::cur_frame_force_integer_mv, macroblock::e_mbd, AV1Common::features, MotionVectorSearchParams::find_fractional_mv_step, AV1_COMP::fn_ptr, AV1Common::height, AV1_COMP::mv_search_params, macroblockd::plane, macroblock::plane, MotionVectorSearchParams::search_site_cfg, macroblock_plane::src, and AV1Common::width.
Referenced by av1_tf_do_filtering_row().
|
static |
Builds predictor for blocks in temporal filtering. This is the second step for temporal filtering, which is to construct predictions from all reference frames INCLUDING the frame to be filtered itself. These predictors are built based on the motion search results (motion vector is set as 0 for the frame to be filtered), and will be futher used for weighted averaging.
[in] | ref_frame | Pointer to the reference frame (or the frame to be filtered) |
[in] | mbd | Pointer to the block for filtering. Besides containing the subsampling information of all planes, this field also gives the searched motion vector for the entire block, i.e., mbd->mi[0]->mv[0] . This vector should be 0 if the ref_frame itself is the frame to be filtered. |
[in] | block_size | Size of the block |
[in] | mb_row | Row index of the block in the frame |
[in] | mb_col | Column index of the block in the frame |
[in] | num_planes | Number of planes in the frame |
[in] | scale | Scaling factor |
[in] | subblock_mvs | The motion vectors for each sub-block (row-major order) |
[out] | pred | Pointer to the predictor to be built |
pred
will be modified References macroblockd::bd, and macroblockd::plane.
Referenced by av1_tf_do_filtering_row().
void av1_apply_temporal_filter_c | ( | const YV12_BUFFER_CONFIG * | frame_to_filter, |
const MACROBLOCKD * | mbd, | ||
const BLOCK_SIZE | block_size, | ||
const int | mb_row, | ||
const int | mb_col, | ||
const int | num_planes, | ||
const double * | noise_levels, | ||
const MV * | subblock_mvs, | ||
const int * | subblock_mses, | ||
const int | q_factor, | ||
const int | filter_strength, | ||
const uint8_t * | pred, | ||
uint32_t * | accum, | ||
uint16_t * | count | ||
) |
Applies temporal filtering. NOTE that there are various optimised versions of this function called where the appropriate instruction set is supported.
[in] | frame_to_filter | Pointer to the frame to be filtered, which is used as reference to compute squared difference from the predictor. |
[in] | mbd | Pointer to the block for filtering, ONLY used to get subsampling information for the planes |
[in] | block_size | Size of the block |
[in] | mb_row | Row index of the block in the frame |
[in] | mb_col | Column index of the block in the frame |
[in] | num_planes | Number of planes in the frame |
[in] | noise_levels | Estimated noise levels for each plane in the frame (Y,U,V) |
[in] | subblock_mvs | Pointer to the motion vectors for 4 sub-blocks |
[in] | subblock_mses | Pointer to the search errors (MSE) for 4 sub-blocks |
[in] | q_factor | Quantization factor. This is actually the q defined in libaom, converted from qindex |
[in] | filter_strength | Filtering strength. This value lies in range [0, 6] where 6 is the maximum strength. |
[out] | pred | Pointer to the well-built predictors |
[out] | accum | Pointer to the pixel-wise accumulator for filtering |
[out] | count | Pointer to the pixel-wise counter for filtering |
accum
, pred
and 'count' will be modified < Y (Luminance) plane
< Y (Luminance) plane
< Y (Luminance) plane
< U (Chroma) plane
References AOM_PLANE_U, AOM_PLANE_Y, macroblockd::bd, and macroblockd::plane.
Referenced by av1_tf_do_filtering_row().
|
static |
Normalizes the accumulated filtering result to produce the filtered frame.
[in] | mbd | Pointer to the block for filtering, which is ONLY used to get subsampling information for all the planes |
[in] | block_size | Size of the block |
[in] | mb_row | Row index of the block in the frame |
[in] | mb_col | Column index of the block in the frame |
[in] | num_planes | Number of planes in the frame |
[in] | accum | Pointer to the pre-computed accumulator |
[in] | count | Pointer to the pre-computed count |
[out] | result_buffer | Pointer to result buffer |
result_buffer
pointer will be modified References macroblockd::plane.
Referenced by av1_tf_do_filtering_row().
|
static |
Does temporal filter for a given frame.
[in] | cpi | Top level encoder instance structure |
References av1_tf_do_filtering_row(), AV1_COMP::common, TemporalFilterCtx::mb_rows, TemporalFilterCtx::sf, AV1_COMP::td, and AV1_COMP::tf_ctx.
|
static |
Setups the frame buffer for temporal filtering. This fuction determines how many frames will be used for temporal filtering and then groups them into a buffer. This function will also estimate the noise level of the to-filter frame.
[in] | cpi | Top level encoder instance structure |
[in] | filter_frame_lookahead_idx | The index of the to-filter frame in the lookahead buffer cpi->lookahead |
[in] | is_second_arf | Whether the to-filter frame is the second ARF. This field will affect the number of frames used for filtering. |
[in] | update_type | This frame's update type. |
[in] | is_forward_keyframe | Indicate whether this is a forward keyframe. |
frames
, num_frames
, filter_frame_idx
and noise_levels
will be updated in cpi->tf_ctx. References AV1EncoderConfig::algo_cfg, AlgoCfg::arnr_max_frames, av1_lookahead_depth(), av1_lookahead_peek(), AV1_COMP::common, AV1_COMP::compressor_stage, TemporalFilterCtx::filter_frame_idx, TemporalFilterCtx::frames, RATE_CONTROL::frames_to_key, AV1_COMP::gf_frame_index, AV1_COMP::gf_group, RATE_CONTROL::gfu_boost, AV1_PRIMARY::lookahead, TemporalFilterCtx::noise_levels, TemporalFilterCtx::num_frames, AV1_COMP::oxcf, AV1_COMP::ppi, AV1_COMP::rc, AV1Common::seq_params, AV1_COMP::td, and AV1_COMP::tf_ctx.