1*c83a76b0SSuyog Pawar /****************************************************************************** 2*c83a76b0SSuyog Pawar * 3*c83a76b0SSuyog Pawar * Copyright (C) 2018 The Android Open Source Project 4*c83a76b0SSuyog Pawar * 5*c83a76b0SSuyog Pawar * Licensed under the Apache License, Version 2.0 (the "License"); 6*c83a76b0SSuyog Pawar * you may not use this file except in compliance with the License. 7*c83a76b0SSuyog Pawar * You may obtain a copy of the License at: 8*c83a76b0SSuyog Pawar * 9*c83a76b0SSuyog Pawar * http://www.apache.org/licenses/LICENSE-2.0 10*c83a76b0SSuyog Pawar * 11*c83a76b0SSuyog Pawar * Unless required by applicable law or agreed to in writing, software 12*c83a76b0SSuyog Pawar * distributed under the License is distributed on an "AS IS" BASIS, 13*c83a76b0SSuyog Pawar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*c83a76b0SSuyog Pawar * See the License for the specific language governing permissions and 15*c83a76b0SSuyog Pawar * limitations under the License. 16*c83a76b0SSuyog Pawar * 17*c83a76b0SSuyog Pawar ***************************************************************************** 18*c83a76b0SSuyog Pawar * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19*c83a76b0SSuyog Pawar */ 20*c83a76b0SSuyog Pawar 21*c83a76b0SSuyog Pawar /** 22*c83a76b0SSuyog Pawar ****************************************************************************** 23*c83a76b0SSuyog Pawar * @file ihevce_profile.h 24*c83a76b0SSuyog Pawar * 25*c83a76b0SSuyog Pawar * @brief 26*c83a76b0SSuyog Pawar * This file contains profiling related definitions 27*c83a76b0SSuyog Pawar * 28*c83a76b0SSuyog Pawar * @author 29*c83a76b0SSuyog Pawar * Ittiam 30*c83a76b0SSuyog Pawar ****************************************************************************** 31*c83a76b0SSuyog Pawar */ 32*c83a76b0SSuyog Pawar 33*c83a76b0SSuyog Pawar #ifndef _IHEVCE_PROFILE_H_ 34*c83a76b0SSuyog Pawar #define _IHEVCE_PROFILE_H_ 35*c83a76b0SSuyog Pawar 36*c83a76b0SSuyog Pawar /*****************************************************************************/ 37*c83a76b0SSuyog Pawar /* Constant Macros */ 38*c83a76b0SSuyog Pawar /*****************************************************************************/ 39*c83a76b0SSuyog Pawar #ifndef PROFILE_ENABLE 40*c83a76b0SSuyog Pawar #define PROFILE_ENABLE 0 41*c83a76b0SSuyog Pawar #endif 42*c83a76b0SSuyog Pawar 43*c83a76b0SSuyog Pawar typedef struct 44*c83a76b0SSuyog Pawar { 45*c83a76b0SSuyog Pawar /* Note that time below will be in units of micro seconds */ 46*c83a76b0SSuyog Pawar /* Time before process call */ 47*c83a76b0SSuyog Pawar ULWORD64 u8_time_start; 48*c83a76b0SSuyog Pawar 49*c83a76b0SSuyog Pawar /* Time after process call */ 50*c83a76b0SSuyog Pawar ULWORD64 u8_time_end; 51*c83a76b0SSuyog Pawar 52*c83a76b0SSuyog Pawar /* Time taken by the last process call */ 53*c83a76b0SSuyog Pawar ULWORD64 u8_cur_time; 54*c83a76b0SSuyog Pawar 55*c83a76b0SSuyog Pawar /* Sum total of the time taken by process calls so far */ 56*c83a76b0SSuyog Pawar ULWORD64 u8_total_time; 57*c83a76b0SSuyog Pawar 58*c83a76b0SSuyog Pawar /*Avg time taken by a process so far */ 59*c83a76b0SSuyog Pawar ULWORD64 u8_avg_time; 60*c83a76b0SSuyog Pawar 61*c83a76b0SSuyog Pawar /* Peak time taken by a process so far */ 62*c83a76b0SSuyog Pawar ULWORD64 u8_peak_time; 63*c83a76b0SSuyog Pawar 64*c83a76b0SSuyog Pawar /* Number of process calls so far. 65*c83a76b0SSuyog Pawar * Required for calc of avg time taken per process call */ 66*c83a76b0SSuyog Pawar UWORD32 u4_num_profile_calls; 67*c83a76b0SSuyog Pawar 68*c83a76b0SSuyog Pawar /* This flag is present to check that every 69*c83a76b0SSuyog Pawar * profile_start() will have a corresponding 70*c83a76b0SSuyog Pawar * arm_profile_sample_time_end() */ 71*c83a76b0SSuyog Pawar UWORD8 u1_sample_taken_flag; 72*c83a76b0SSuyog Pawar 73*c83a76b0SSuyog Pawar } profile_database_t; 74*c83a76b0SSuyog Pawar 75*c83a76b0SSuyog Pawar typedef struct 76*c83a76b0SSuyog Pawar { 77*c83a76b0SSuyog Pawar WORD32 tv_sec; /* Time in seconds. */ 78*c83a76b0SSuyog Pawar WORD32 tv_usec; /* Time in micro seconds. */ 79*c83a76b0SSuyog Pawar } timeval_t; 80*c83a76b0SSuyog Pawar 81*c83a76b0SSuyog Pawar /*****************************************************************************/ 82*c83a76b0SSuyog Pawar /* Function Declarations */ 83*c83a76b0SSuyog Pawar /*****************************************************************************/ 84*c83a76b0SSuyog Pawar void profile_sample_time_start(); 85*c83a76b0SSuyog Pawar void profile_sample_time_end(); 86*c83a76b0SSuyog Pawar void profile_print_stats(); 87*c83a76b0SSuyog Pawar int profile_get_avg_time(profile_database_t *ps_profile_data); 88*c83a76b0SSuyog Pawar int profile_get_peak_time(profile_database_t *ps_profile_data); 89*c83a76b0SSuyog Pawar int profile_convert_to_milli_sec(profile_database_t *ps_profile_data); 90*c83a76b0SSuyog Pawar 91*c83a76b0SSuyog Pawar ULWORD64 profile_sample_time(); 92*c83a76b0SSuyog Pawar 93*c83a76b0SSuyog Pawar /* Should be called after each process call */ 94*c83a76b0SSuyog Pawar void profile_stop(profile_database_t *ps_profile_data, char *msg); 95*c83a76b0SSuyog Pawar 96*c83a76b0SSuyog Pawar /* Should be called before every process call */ 97*c83a76b0SSuyog Pawar void profile_start(profile_database_t *ps_profile_data); 98*c83a76b0SSuyog Pawar 99*c83a76b0SSuyog Pawar /* Should be called after codec instance initialization */ 100*c83a76b0SSuyog Pawar void init_profiler(profile_database_t *ps_profile_data); 101*c83a76b0SSuyog Pawar 102*c83a76b0SSuyog Pawar /* Should be called at the end of processing */ 103*c83a76b0SSuyog Pawar void profile_end(profile_database_t *ps_profile_data, char *msg); 104*c83a76b0SSuyog Pawar 105*c83a76b0SSuyog Pawar #if PROFILE_ENABLE 106*c83a76b0SSuyog Pawar 107*c83a76b0SSuyog Pawar #define PROFILE_INIT(x) init_profiler(x) 108*c83a76b0SSuyog Pawar #define PROFILE_START(x) profile_start(x) 109*c83a76b0SSuyog Pawar #define PROFILE_STOP(x, y) profile_stop(x, y) 110*c83a76b0SSuyog Pawar #define PROFILE_END(x, y) profile_end(x, y) 111*c83a76b0SSuyog Pawar 112*c83a76b0SSuyog Pawar #else /* #if PROFILE_ENABLE */ 113*c83a76b0SSuyog Pawar 114*c83a76b0SSuyog Pawar #define PROFILE_INIT(x) 115*c83a76b0SSuyog Pawar #define PROFILE_START(x) 116*c83a76b0SSuyog Pawar #define PROFILE_STOP(x, y) 117*c83a76b0SSuyog Pawar #define PROFILE_END(x, y) 118*c83a76b0SSuyog Pawar 119*c83a76b0SSuyog Pawar #endif /* #if PROFILE_ENABLE */ 120*c83a76b0SSuyog Pawar 121*c83a76b0SSuyog Pawar #endif /* _IHEVCE_PROFILE_H_ */ 122