1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 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 #ifndef _FRAME_INFO_COLLECTOR_H_ 22 #define _FRAME_INFO_COLLECTOR_H_ 23 24 typedef struct 25 { 26 /* Number of MBs in each type */ 27 WORD32 num_mbs[MAX_MB_TYPE]; 28 29 /* Sum of all MB SADs of each MB type */ 30 WORD32 tot_mb_sad[MAX_MB_TYPE]; 31 32 /* Sum of QPs for each mb type */ 33 WORD32 qp_sum[MAX_MB_TYPE]; 34 35 /* Header bits consumed other than MB headers */ 36 WORD32 other_header_bits; 37 38 /* Header bits consumed for each type of MBs */ 39 WORD32 mb_header_bits[MAX_MB_TYPE]; 40 41 /* Texture bits consumed for each type of MBs */ 42 WORD32 mb_texture_bits[MAX_MB_TYPE]; 43 44 /* Sum of all MB activity */ 45 WORD32 activity_sum; 46 47 /* Sum of all the Intra MB cost values for the entire frame */ 48 WORD32 intra_mb_cost_sum; 49 50 } frame_info_t; 51 52 void irc_init_frame_info(frame_info_t *frame_info); 53 54 /* 55 * Update functions: Collecting information from encoder 56 */ 57 #define FI_UPDATE_OTHER_HEADER_BITS(frame_info,header_bits)\ 58 {(frame_info)->other_header_bits += (header_bits);} 59 60 #define FI_UPDATE_MB_HEADER(frame_info,header_bits,mb_type)\ 61 {(frame_info)->mb_header_bits[(mb_type)] += (header_bits);} 62 63 #define FI_UPDATE_MB_TEXTURE(frame_info,texture_bits,mb_type)\ 64 {(frame_info)->mb_texture_bits[(mb_type)] += (texture_bits);} 65 66 #define FI_UPDATE_MB_SAD(frame_info,mb_sad,mb_type)\ 67 {(frame_info)->tot_mb_sad[(mb_type)] += (mb_sad);} 68 69 #define FI_UPDATE_MB_QP(frame_info,qp,mb_type)\ 70 {(frame_info)->qp_sum[(mb_type)] += (qp);(frame_info)->num_mbs[(mb_type)]++;} 71 72 #define FI_UPDATE_ACTIVITY(frame_info,mb_activity)\ 73 {(frame_info)->activity_sum += (mb_activity);} 74 75 #define FI_UPDATE_INTRA_MB_COST(frame_info,intra_mb_cost)\ 76 {(frame_info)->intra_mb_cost_sum += (intra_mb_cost);} 77 78 /* 79 * GET Functions: Sending back collected information to the rate control module 80 */ 81 82 /* Frame Level Model Information */ 83 WORD32 irc_fi_get_total_header_bits(frame_info_t *frame_info); 84 85 WORD32 irc_fi_get_total_texture_bits(frame_info_t *frame_info); 86 87 WORD32 irc_fi_get_average_qp(frame_info_t *frame_info); 88 89 WORD32 irc_fi_get_total_frame_sad(frame_info_t *frame_info); 90 91 WORD32 irc_fi_get_avg_activity(frame_info_t *frame_info); 92 93 /* Number of Intra MBs for Scene Change Detection */ 94 WORD32 irc_fi_get_num_intra_mb(frame_info_t *frame_info); 95 96 /* MB Level Model Information */ 97 WORD32 irc_fi_get_avg_mb_header(frame_info_t *frame_info, UWORD8 mb_type); 98 99 WORD32 irc_fi_get_total_mb_texture_bits(frame_info_t *frame_info, 100 UWORD8 mb_type); 101 102 WORD32 irc_fi_get_total_mb_sad(frame_info_t *frame_info, UWORD8 mb_type); 103 104 WORD32 irc_fi_get_total_mb_qp(frame_info_t *frame_info, UWORD8 mb_type); 105 106 WORD32 irc_fi_get_total_mb(frame_info_t *frame_info, UWORD8 mb_type); 107 108 WORD32 irc_fi_get_total_intra_mb_cost(frame_info_t *frame_info); 109 #endif 110