12#ifndef AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
13#define AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
31#define TF_BLOCK_SIZE BLOCK_32X32
34#define TF_WINDOW_LENGTH 5
40#define TF_WEIGHT_SCALE 1000
44#define TF_WINDOW_BLOCK_BALANCE_WEIGHT 5
50#define TF_Q_DECAY_THRESHOLD 20
54#define TF_SEARCH_ERROR_NORM_WEIGHT 20
60#define TF_STRENGTH_THRESHOLD 4
69#define TF_SEARCH_DISTANCE_THRESHOLD 0.1
77#define TF_QINDEX_CUTOFF 128
79#define NOISE_ESTIMATION_EDGE_THRESHOLD 50
119 struct scale_factors sf;
123 double noise_levels[MAX_MB_PLANE];
151#define TF_INFO_BUF_COUNT 2
234 FRAME_DIFF *frame_diff);
255#if CONFIG_MULTITHREAD
257 pthread_mutex_t *mutex_;
261} AV1TemporalFilterSync;
279 const int edge_thresh);
321 const int filter_frame_lookahead_idx,
322 int gf_frame_index, FRAME_DIFF *frame_diff,
340 const FRAME_DIFF *frame_diff,
int q_index,
345int av1_get_q(
const struct AV1_COMP *cpi);
354static AOM_INLINE
bool tf_alloc_and_reset_data(TemporalFilterData *tf_data,
356 int is_high_bitdepth) {
357 tf_data->tmp_mbmi = (
MB_MODE_INFO *)malloc(
sizeof(*tf_data->tmp_mbmi));
358 memset(tf_data->tmp_mbmi, 0,
sizeof(*tf_data->tmp_mbmi));
360 (uint32_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->accum));
362 (uint16_t *)aom_memalign(16, num_pels *
sizeof(*tf_data->count));
363 memset(&tf_data->diff, 0,
sizeof(tf_data->diff));
364 if (is_high_bitdepth)
365 tf_data->pred = CONVERT_TO_BYTEPTR(
366 aom_memalign(32, num_pels * 2 *
sizeof(*tf_data->pred)));
369 (uint8_t *)aom_memalign(32, num_pels *
sizeof(*tf_data->pred));
370 if (!(tf_data->accum && tf_data->count && tf_data->pred)) {
371 aom_free(tf_data->accum);
372 aom_free(tf_data->count);
373 aom_free(tf_data->pred);
386static AOM_INLINE
void tf_setup_macroblockd(
MACROBLOCKD *mbd,
387 TemporalFilterData *tf_data,
388 const struct scale_factors *scale) {
391 mbd->
mi = &tf_data->tmp_mbmi;
401static AOM_INLINE
void tf_dealloc_data(TemporalFilterData *tf_data,
402 int is_high_bitdepth) {
403 if (is_high_bitdepth)
404 tf_data->pred = (uint8_t *)CONVERT_TO_SHORTPTR(tf_data->pred);
405 free(tf_data->tmp_mbmi);
406 aom_free(tf_data->accum);
407 aom_free(tf_data->count);
408 aom_free(tf_data->pred);
421 uint8_t **input_buffer,
int num_planes) {
422 for (
int i = 0; i < num_planes; i++) {
423 input_buffer[i] = mbd->
plane[i].pre[0].buf;
425 *input_mbmi = mbd->
mi;
437 uint8_t **input_buffer,
int num_planes) {
438 for (
int i = 0; i < num_planes; i++) {
439 mbd->
plane[i].pre[0].buf = input_buffer[i];
441 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:792
Main encoder configuration data structure.
Definition encoder.h:915
Top level encoder structure.
Definition encoder.h:2759
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:156
int tf_buf_display_index_offset[2]
Definition temporal_filter.h:187
YV12_BUFFER_CONFIG tf_buf[2]
Definition temporal_filter.h:167
int tf_buf_gf_index[2]
Definition temporal_filter.h:183
FRAME_DIFF frame_diff[2]
Definition temporal_filter.h:179
int is_temporal_filter_on
Definition temporal_filter.h:162
int tf_buf_valid[2]
Definition temporal_filter.h:191
YV12_BUFFER_CONFIG tf_buf_second_arf
Definition temporal_filter.h:175
Parameters related to temporal filtering.
Definition temporal_filter.h:93
YV12_BUFFER_CONFIG * output_frame
Definition temporal_filter.h:106
int q_factor
Definition temporal_filter.h:143
int num_pels
Definition temporal_filter.h:127
int num_frames
Definition temporal_filter.h:101
int compute_frame_diff
Definition temporal_filter.h:115
int mb_rows
Definition temporal_filter.h:131
int mb_cols
Definition temporal_filter.h:135
int is_highbitdepth
Definition temporal_filter.h:139
int filter_frame_idx
Definition temporal_filter.h:111
Variables related to current coding block.
Definition blockd.h:574
struct macroblockd_plane plane[3]
Definition blockd.h:610
const struct scale_factors * block_ref_scale_factors[2]
Definition blockd.h:691
MB_MODE_INFO ** mi
Definition blockd.h:621
YV12 frame buffer data structure.
Definition yv12config.h:39