 |
AOMedia AV1 Codec
|
12 #ifndef AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
13 #define AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
28 #define TF_BLOCK_SIZE BLOCK_32X32
31 #define TF_WINDOW_LENGTH 5
37 #define TF_WEIGHT_SCALE 1000
41 #define TF_WINDOW_BLOCK_BALANCE_WEIGHT 5
47 #define TF_Q_DECAY_THRESHOLD 20
51 #define TF_SEARCH_ERROR_NORM_WEIGHT 20
57 #define TF_STRENGTH_THRESHOLD 4
66 #define TF_SEARCH_DISTANCE_THRESHOLD 0.1
68 #define NOISE_ESTIMATION_EDGE_THRESHOLD 50
95 struct scale_factors sf;
99 double noise_levels[MAX_MB_PLANE];
144 } TemporalFilterData;
148 #if CONFIG_MULTITHREAD
150 pthread_mutex_t *mutex_;
151 #endif // CONFIG_MULTITHREAD
154 } AV1TemporalFilterSync;
171 const int bit_depth);
214 const int filter_frame_lookahead_idx,
215 FRAME_UPDATE_TYPE update_type,
int is_forward_keyframe,
216 int *show_existing_arf);
220 int av1_get_q(
const struct AV1_COMP *cpi);
229 static AOM_INLINE
void tf_alloc_and_reset_data(TemporalFilterData *tf_data,
231 int is_high_bitdepth) {
232 tf_data->tmp_mbmi = (
MB_MODE_INFO *)malloc(
sizeof(*tf_data->tmp_mbmi));
233 memset(tf_data->tmp_mbmi, 0,
sizeof(*tf_data->tmp_mbmi));
235 (uint32_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->accum));
237 (uint16_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->count));
238 memset(&tf_data->diff, 0,
sizeof(tf_data->diff));
239 if (is_high_bitdepth)
240 tf_data->pred = CONVERT_TO_BYTEPTR(
241 aom_memalign(32, num_pels * 2 *
sizeof(*tf_data->pred)));
244 (uint8_t *)aom_memalign(32, num_pels *
sizeof(*tf_data->pred));
254 static AOM_INLINE
void tf_setup_macroblockd(
MACROBLOCKD *mbd,
255 TemporalFilterData *tf_data,
256 const struct scale_factors *scale) {
259 mbd->
mi = &tf_data->tmp_mbmi;
269 static AOM_INLINE
void tf_dealloc_data(TemporalFilterData *tf_data,
270 int is_high_bitdepth) {
271 if (is_high_bitdepth)
272 tf_data->pred = (uint8_t *)CONVERT_TO_SHORTPTR(tf_data->pred);
273 free(tf_data->tmp_mbmi);
274 aom_free(tf_data->accum);
275 aom_free(tf_data->count);
276 aom_free(tf_data->pred);
280 static INLINE
int get_num_blocks(
const int frame_length,
const int mb_length) {
281 return (frame_length + mb_length - 1) / mb_length;
294 uint8_t **input_buffer,
int num_planes) {
295 for (
int i = 0; i < num_planes; i++) {
296 input_buffer[i] = mbd->
plane[i].pre[0].buf;
298 *input_mbmi = mbd->
mi;
310 uint8_t **input_buffer,
int num_planes) {
311 for (
int i = 0; i < num_planes; i++) {
312 mbd->
plane[i].pre[0].buf = input_buffer[i];
314 mbd->
mi = input_mbmi;
322 #endif // AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
int q_factor
Definition: temporal_filter.h:119
Declares top-level encoder structures and functions.
Parameters related to temporal filtering.
Definition: temporal_filter.h:75
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 wh...
Definition: temporal_filter.c:541
int mb_rows
Definition: temporal_filter.h:107
struct macroblock_plane plane[3]
Each of the encoding plane.
Definition: block.h:856
Rate Control parameters and status.
Definition: ratectrl.h:118
Data related to the current GF/ARF group and the individual frames within the group.
Definition: firstpass.h:171
const struct scale_factors * block_ref_scale_factors[2]
Definition: blockd.h:685
#define AOM_PLANE_Y
Definition: aom_image.h:199
Encoder parameters related to multi-threading.
Definition: encoder.h:1375
#define AOM_PLANE_U
Definition: aom_image.h:200
SPEED_FEATURES sf
Definition: encoder.h:2314
ThreadData td
Definition: encoder.h:2110
unsigned char gf_frame_index
Definition: encoder.h:2362
COMPRESSOR_STAGE compressor_stage
Definition: encoder.h:2645
int filter_frame_idx
Definition: temporal_filter.h:87
int arnr_max_frames
Definition: encoder.h:735
bool cur_frame_force_integer_mv
Definition: av1_common_int.h:347
int bd
Definition: blockd.h:806
KeyFrameCfg kf_cfg
Definition: encoder.h:822
int num_workers
Definition: encoder.h:1379
MultiThreadInfo mt_info
Definition: encoder.h:2501
int num_frames
Definition: temporal_filter.h:83
int av1_rc_pick_q_and_bounds(const struct AV1_COMP *cpi, RATE_CONTROL *rc, int width, int height, int gf_index, int *bottom_index, int *top_index)
Picks q and q bounds given the rate control parameters in cpi->rc.
GF_GROUP gf_group
Definition: encoder.h:2357
Top level encoder structure.
Definition: encoder.h:2095
int height
Definition: av1_common_int.h:749
void av1_tf_do_filtering_row(AV1_COMP *cpi, ThreadData *td, int mb_row)
Does temporal filter for a given macroblock row.
Definition: temporal_filter.c:755
int is_highbitdepth
Definition: temporal_filter.h:115
search_site_config search_site_cfg[SS_CFG_TOTAL][NUM_DISTINCT_SEARCH_METHODS]
Definition: encoder.h:1756
int num_pels
Definition: temporal_filter.h:103
struct lookahead_ctx * lookahead
Definition: encoder.h:2071
AV1_COMMON common
Definition: encoder.h:2138
int mb_cols
Definition: temporal_filter.h:111
MotionVectorSearchParams mv_search_params
Definition: encoder.h:2319
int gfu_boost
Definition: ratectrl.h:169
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 ...
Definition: temporal_filter.c:927
aom_variance_fn_ptr_t fn_ptr[BLOCK_SIZES_ALL]
Definition: encoder.h:2347
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....
Definition: temporal_filter.c:84
FullMvLimits mv_limits
Limit for the range of motion vectors.
Definition: block.h:1194
YV12_BUFFER_CONFIG alt_ref_buffer
Definition: encoder.h:2378
MOTION_MODE motion_mode
The motion mode used by the inter prediction.
Definition: blockd.h:244
TemporalFilterCtx tf_ctx
Definition: encoder.h:2207
int base_frame_target
Definition: ratectrl.h:125
HIGH_LEVEL_SPEED_FEATURES hl_sf
Definition: speed_features.h:1124
fractional_mv_step_fp * find_fractional_mv_step
Definition: encoder.h:1749
YV12 frame buffer data structure.
Definition: yv12config.h:38
int check_show_existing
Definition: temporal_filter.h:91
struct buf_2d src
A buffer containing the source frame.
Definition: block.h:117
RATE_CONTROL rc
Definition: encoder.h:2294
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,...
Definition: temporal_filter.c:312
int arnr_strength
Definition: encoder.h:740
AlgoCfg algo_cfg
Definition: encoder.h:817
static void tf_do_filtering(AV1_COMP *cpi)
Does temporal filter for a given frame.
Definition: temporal_filter.c:887
struct lookahead_entry * av1_lookahead_peek(struct lookahead_ctx *ctx, int index, COMPRESSOR_STAGE stage)
Get a future source buffer to encode.
int second_alt_ref_filtering
Definition: speed_features.h:355
AV1_PRIMARY * ppi
Definition: encoder.h:2099
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:216
Variables related to current coding block.
Definition: blockd.h:568
int enable_keyframe_filtering
Definition: encoder.h:391
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:864
unsigned int av1_lookahead_depth(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage)
Get the number of frames currently in the lookahead queue.
double noise_levels[MAX_MB_PLANE]
Definition: temporal_filter.h:99
int width
Definition: av1_common_int.h:748
AV1EncoderConfig oxcf
Definition: encoder.h:2143
SequenceHeader seq_params
Definition: av1_common_int.h:953
struct scale_factors sf
Definition: temporal_filter.h:95
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 r...
struct macroblockd_plane plane[3]
Definition: blockd.h:604
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.
Definition: temporal_filter.c:708
int showable_frame
Definition: av1_common_int.h:870
FeatureFlags features
Definition: av1_common_int.h:882
YV12_BUFFER_CONFIG * frames[MAX_LAG_BUFFERS]
Definition: temporal_filter.h:79
CommonModeInfoParams mi_params
Definition: av1_common_int.h:887
Encoder's parameters related to the current coding block.
Definition: block.h:846
MB_MODE_INFO ** mi
Definition: blockd.h:615
int frames_to_key
Definition: ratectrl.h:223
bool enable_overlay
Definition: encoder.h:759