12#ifndef AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
13#define AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
20struct AV1EncoderConfig;
29#define TF_BLOCK_SIZE BLOCK_32X32
32#define TF_WINDOW_LENGTH 5
38#define TF_WEIGHT_SCALE 1000
42#define TF_WINDOW_BLOCK_BALANCE_WEIGHT 5
48#define TF_Q_DECAY_THRESHOLD 20
52#define TF_SEARCH_ERROR_NORM_WEIGHT 20
58#define TF_STRENGTH_THRESHOLD 4
67#define TF_SEARCH_DISTANCE_THRESHOLD 0.1
75#define TF_QINDEX_CUTOFF 128
77#define NOISE_ESTIMATION_EDGE_THRESHOLD 50
117 struct scale_factors sf;
121 double noise_levels[MAX_MB_PLANE];
149#define TF_INFO_BUF_COUNT 2
197int av1_is_temporal_filter_on(
const struct AV1EncoderConfig *oxcf);
231 FRAME_DIFF *frame_diff);
252#if CONFIG_MULTITHREAD
254 pthread_mutex_t *mutex_;
258} AV1TemporalFilterSync;
276 const int edge_thresh);
318 const int filter_frame_lookahead_idx,
319 int gf_frame_index, FRAME_DIFF *frame_diff,
337 const FRAME_DIFF *frame_diff,
int q_index,
342int av1_get_q(
const struct AV1_COMP *cpi);
351static AOM_INLINE
void tf_alloc_and_reset_data(TemporalFilterData *tf_data,
353 int is_high_bitdepth) {
354 tf_data->tmp_mbmi = (
MB_MODE_INFO *)malloc(
sizeof(*tf_data->tmp_mbmi));
355 memset(tf_data->tmp_mbmi, 0,
sizeof(*tf_data->tmp_mbmi));
357 (uint32_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->accum));
359 (uint16_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->count));
360 memset(&tf_data->diff, 0,
sizeof(tf_data->diff));
361 if (is_high_bitdepth)
362 tf_data->pred = CONVERT_TO_BYTEPTR(
363 aom_memalign(32, num_pels * 2 *
sizeof(*tf_data->pred)));
366 (uint8_t *)aom_memalign(32, num_pels *
sizeof(*tf_data->pred));
376static AOM_INLINE
void tf_setup_macroblockd(
MACROBLOCKD *mbd,
377 TemporalFilterData *tf_data,
378 const struct scale_factors *scale) {
381 mbd->
mi = &tf_data->tmp_mbmi;
391static AOM_INLINE
void tf_dealloc_data(TemporalFilterData *tf_data,
392 int is_high_bitdepth) {
393 if (is_high_bitdepth)
394 tf_data->pred = (uint8_t *)CONVERT_TO_SHORTPTR(tf_data->pred);
395 free(tf_data->tmp_mbmi);
396 aom_free(tf_data->accum);
397 aom_free(tf_data->count);
398 aom_free(tf_data->pred);
411 uint8_t **input_buffer,
int num_planes) {
412 for (
int i = 0; i < num_planes; i++) {
413 input_buffer[i] = mbd->
plane[i].pre[0].buf;
415 *input_mbmi = mbd->
mi;
427 uint8_t **input_buffer,
int num_planes) {
428 for (
int i = 0; i < num_planes; i++) {
429 mbd->
plane[i].pre[0].buf = input_buffer[i];
431 mbd->
mi = input_mbmi;
enum aom_bit_depth aom_bit_depth_t
Bit depth for codecThis enumeration determines the bit depth of the codec.
int av1_check_show_filtered_frame(const YV12_BUFFER_CONFIG *frame, const FRAME_DIFF *frame_diff, int q_index, aom_bit_depth_t bit_depth)
Check whether a filtered frame can be show directly.
void av1_temporal_filter(struct AV1_COMP *cpi, const int filter_frame_lookahead_idx, int gf_frame_index, FRAME_DIFF *frame_diff, YV12_BUFFER_CONFIG *output_frame)
Performs temporal filtering if needed on a source frame. For example to create a filtered alternate r...
void av1_tf_do_filtering_row(struct AV1_COMP *cpi, struct ThreadData *td, int mb_row)
Does temporal filter for a given macroblock row.
Definition: temporal_filter.c:764
Data related to the current GF/ARF group and the individual frames within the group.
Definition: firstpass.h:344
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:222
MOTION_MODE motion_mode
The motion mode used by the inter prediction.
Definition: blockd.h:250
Temporal filter info for a gop.
Definition: temporal_filter.h:154
int tf_buf_display_index_offset[2]
Definition: temporal_filter.h:185
YV12_BUFFER_CONFIG tf_buf[2]
Definition: temporal_filter.h:165
int tf_buf_gf_index[2]
Definition: temporal_filter.h:181
FRAME_DIFF frame_diff[2]
Definition: temporal_filter.h:177
int is_temporal_filter_on
Definition: temporal_filter.h:160
int tf_buf_valid[2]
Definition: temporal_filter.h:189
YV12_BUFFER_CONFIG tf_buf_second_arf
Definition: temporal_filter.h:173
Parameters related to temporal filtering.
Definition: temporal_filter.h:91
YV12_BUFFER_CONFIG * output_frame
Definition: temporal_filter.h:104
int q_factor
Definition: temporal_filter.h:141
int num_pels
Definition: temporal_filter.h:125
int num_frames
Definition: temporal_filter.h:99
int compute_frame_diff
Definition: temporal_filter.h:113
int mb_rows
Definition: temporal_filter.h:129
int mb_cols
Definition: temporal_filter.h:133
int is_highbitdepth
Definition: temporal_filter.h:137
int filter_frame_idx
Definition: temporal_filter.h:109
Variables related to current coding block.
Definition: blockd.h:577
struct macroblockd_plane plane[3]
Definition: blockd.h:613
const struct scale_factors * block_ref_scale_factors[2]
Definition: blockd.h:694
MB_MODE_INFO ** mi
Definition: blockd.h:624
YV12 frame buffer data structure.
Definition: yv12config.h:39