1 /****************************************************************************** 2 * 3 * Copyright (C) 2018 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 /*! 21 ****************************************************************************** 22 * \file rc_rd_model.h 23 * 24 * \brief 25 * This file contains all the necessary declarations for 26 * Rate Distortion related functions 27 * 28 * \date 29 * 30 * \author 31 * ittiam 32 * 33 ****************************************************************************** 34 */ 35 #ifndef RC_RD_MODEL 36 #define RC_RD_MODEL 37 38 /*****************************************************************************/ 39 /* Constant Macros */ 40 /*****************************************************************************/ 41 #define RC_FIXED_POINT 1 42 #define MAX_FRAMES_MODELLED 16 43 44 #if !RC_FIXED_POINT 45 typedef float model_coeff; 46 #else 47 typedef number_t model_coeff; 48 #endif 49 typedef struct rc_rd_model_t *rc_rd_model_handle; 50 51 /*****************************************************************************/ 52 /* Function Declarations */ 53 /*****************************************************************************/ 54 WORD32 rc_rd_model_num_fill_use_free_memtab( 55 rc_rd_model_handle *pps_rc_rd_model, itt_memtab_t *ps_memtab, ITT_FUNC_TYPE_E e_func_type); 56 /* Interface Functions */ 57 /* Initialise the rate distortion model */ 58 void init_frm_rc_rd_model(rc_rd_model_handle ps_rd_model, UWORD8 u1_max_frames_modelled); 59 60 /* Reset the rate distortion model */ 61 void reset_frm_rc_rd_model(rc_rd_model_handle ps_rd_model); 62 63 /* Returns the Qp to be used for the given bits and SAD */ 64 WORD32 find_qp_for_target_bits( 65 rc_rd_model_handle ps_rd_model, 66 UWORD32 u4_target_res_bits, 67 UWORD32 u4_estimated_sad, 68 WORD32 i4_max_qp_q6, 69 WORD32 i4_min_qp_q6); 70 /* Updates the frame level statistics after encoding a frame */ 71 void add_frame_to_rd_model( 72 rc_rd_model_handle ps_rd_model, 73 UWORD32 i4_res_bits, 74 WORD32 i4_avg_mp2qp_q6, 75 LWORD64 i8_sad_h264, 76 UWORD8 u1_num_skips); 77 78 UWORD32 estimate_bits_for_qp( 79 rc_rd_model_handle ps_rd_model, UWORD32 u4_estimated_sad, WORD32 i4_avg_qp_q6); 80 /* Get the Linear model coefficient */ 81 model_coeff get_linear_coefficient(rc_rd_model_handle ps_rd_model); 82 83 void set_linear_coefficient(rc_rd_model_handle ps_rd_model, number_t model_coeff_a_lin_wo_int); 84 85 WORD32 is_model_valid(rc_rd_model_handle ps_rd_model); 86 87 #endif 88