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 typedef struct AV1_COMP AV1_COMP; 44 45 void av1_vmaf_blk_preprocessing(AV1_COMP *cpi, YV12_BUFFER_CONFIG *source); 46 47 void av1_vmaf_frame_preprocessing(AV1_COMP *cpi, YV12_BUFFER_CONFIG *source); 48 49 void av1_vmaf_neg_preprocessing(AV1_COMP *cpi, YV12_BUFFER_CONFIG *source); 50 51 void av1_set_mb_vmaf_rdmult_scaling(AV1_COMP *cpi); 52 53 void av1_set_vmaf_rdmult(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, 54 int mi_row, int mi_col, int *rdmult); 55 56 int av1_get_vmaf_base_qindex(const AV1_COMP *cpi, int current_qindex); 57 58 void av1_update_vmaf_curve(AV1_COMP *cpi); 59 60 #endif // AOM_AV1_ENCODER_TUNE_VMAF_H_ 61