xref: /aosp_15_r20/external/libaom/av1/encoder/tune_vmaf.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1 /*
2  * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_ENCODER_TUNE_VMAF_H_
13 #define AOM_AV1_ENCODER_TUNE_VMAF_H_
14 
15 #include "aom_dsp/vmaf.h"
16 #include "aom_scale/yv12config.h"
17 #include "av1/common/enums.h"
18 #include "av1/encoder/ratectrl.h"
19 #include "av1/encoder/block.h"
20 
21 typedef struct {
22   // Stores the scaling factors for rdmult when tuning for VMAF.
23   // rdmult_scaling_factors[row * num_cols + col] stores the scaling factors for
24   // 64x64 block at (row, col).
25   double *rdmult_scaling_factors;
26 
27   // Stores the luma sse of the last frame.
28   double last_frame_ysse[MAX_ARF_LAYERS];
29 
30   // Stores the VMAF of the last frame.
31   double last_frame_vmaf[MAX_ARF_LAYERS];
32 
33   // Stores the filter strength of the last frame.
34   double last_frame_unsharp_amount[MAX_ARF_LAYERS];
35 
36   // Stores the origial qindex before scaling.
37   int original_qindex;
38 
39   // VMAF model used in VMAF caculations.
40   VmafModel *vmaf_model;
41 } TuneVMAFInfo;
42 
43 struct AV1_COMP;
44 
45 void av1_vmaf_blk_preprocessing(struct AV1_COMP *cpi,
46                                 const YV12_BUFFER_CONFIG *source);
47 
48 void av1_vmaf_frame_preprocessing(struct AV1_COMP *cpi,
49                                   const YV12_BUFFER_CONFIG *source);
50 
51 void av1_vmaf_neg_preprocessing(struct AV1_COMP *cpi,
52                                 const YV12_BUFFER_CONFIG *source);
53 
54 void av1_set_mb_vmaf_rdmult_scaling(struct AV1_COMP *cpi);
55 
56 void av1_set_vmaf_rdmult(const struct AV1_COMP *cpi, MACROBLOCK *x,
57                          BLOCK_SIZE bsize, int mi_row, int mi_col, int *rdmult);
58 
59 int av1_get_vmaf_base_qindex(const struct AV1_COMP *cpi, int current_qindex);
60 
61 void av1_update_vmaf_curve(struct AV1_COMP *cpi);
62 
63 #endif  // AOM_AV1_ENCODER_TUNE_VMAF_H_
64