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 /**
22 *******************************************************************************
23 * @file
24 *  ih264e_modify_frm_rate.h
25 *
26 * @brief
27 *  Functions declarations used to modify frame rate
28 *
29 * @author
30 *  ittiam
31 *
32 * @remarks
33 *  None
34 *
35 *******************************************************************************
36 */
37 
38 #ifndef IH264E_MODIFY_FRM_RATE_H_
39 #define IH264E_MODIFY_FRM_RATE_H_
40 
41 /*****************************************************************************/
42 /* Constant Definitions                                                      */
43 /*****************************************************************************/
44 
45 #define MAX_NUM_FRAME   120
46 
47 
48 /*****************************************************************************/
49 /* Structures                                                                */
50 /*****************************************************************************/
51 typedef struct pd_frm_rate_t
52 {
53     /*
54      * The input frame rate set in the encoder (per 1000 sec)
55      */
56     UWORD32 u4_input_frm_rate;
57 
58     /*
59      * Frame rate of current frame due to pull down
60      */
61     UWORD32 u4_cur_frm_rate[MAX_NUM_FRAME];
62 
63     /*
64      * current frame num in the above buffer
65      */
66     UWORD32 u4_frm_num;
67 
68     /*
69      * Total number of frames encoded.
70      * if greater than input frame rate stays at input frame rate
71      */
72     UWORD32 u4_tot_frm_encoded;
73 
74 }pd_frm_rate_t;
75 
76 typedef struct pd_frm_rate_t *pd_frm_rate_handle;
77 
78 
79 /*****************************************************************************/
80 /* Function Declarations                                                     */
81 /*****************************************************************************/
82 
83 /**
84 *******************************************************************************
85 *
86 * @brief Function to init pd frame rate memtab
87 *
88 * @par Description
89 *  Function to init pull down frame rate memtab
90 *
91 * @param[in] pps_pd_frm_rate
92 *  pull down frame rate context
93 *
94 * @param[in] ps_memtab
95 *  Handle to memtab
96 *
97 * @param[in] e_func_type
98 *  Function type (get memtab/ update memtab)
99 *
100 * @returns  Number of memtabs used
101 *
102 * @remarks  None
103 *
104 *******************************************************************************
105 */
106 WORD32 ih264e_pd_frm_rate_get_init_free_memtab(pd_frm_rate_handle *pps_pd_frm_rate,
107                                                itt_memtab_t *ps_memtab,
108                                                ITT_FUNC_TYPE_E e_func_type);
109 /**
110 *******************************************************************************
111 *
112 * @brief Initializes the pull down frame rate state structure based on input
113 *  frame rate
114 *
115 * @par Description
116 *  Initializes the pull down frame rate state structure based on input frame rate
117 *
118 * @param[in] ps_pd_frm_rate
119 *  Pull down frame rate context
120 *
121 * @param[in] u4_input_frm_rate
122 *  Input frame rate in frame per 1000sec
123 *
124 * @returns none
125 *
126 * @remarks
127 *
128 *******************************************************************************
129 */
130 void ih264e_init_pd_frm_rate(pd_frm_rate_handle ps_pd_frm_rate,
131                              UWORD32 u4_input_frm_rate);
132 
133 /**
134 *******************************************************************************
135 *
136 * @brief Function to update pull down frame rate
137 *
138 * @par   Description
139 *  For each frame a run time frame rate value is sent based on whether a frame
140 *  is skipped or not. If it is skipped for pull down then the current frame
141 *  rate for the pull down period is signaled as 4/5th of the original frame
142 *  rate. Thus when this is averaged the frame rate gradually switches from the
143 *  input frame rate to 4/5th of input frame rate as and when more 3:2 pull
144 *  down patterns are detected
145 *
146 * @param[in] ps_pd_frm_rate
147 *  Pull down frame rate context
148 *
149 * @param[in] u4_input_frm_rate
150 *  Input frame rate in frame per 1000sec
151 *
152 * @returns none
153 *
154 * @remarks
155 *
156 *******************************************************************************
157 */
158 void ih264e_update_pd_frm_rate(pd_frm_rate_handle ps_pd_frm_rate,
159                                UWORD32 u4_cur_frm_rate);
160 
161 /**
162 *******************************************************************************
163 *
164 * @brief returns average frame rate in 1 sec duration
165 *
166 * @par Description
167 *  Averages the last N frame in period(1 sec) and then gives that
168 *  as the current frames frame rate. Thus this averages out the sudden
169 *  variation in frame rate
170 *
171 * @param[in] ps_pd_frm_rate
172 *  Handle to pull down frame rate context
173 *
174 * @returns average frame rate
175 *
176 * @remarks
177 *
178 *******************************************************************************
179 */
180 UWORD32 ih264e_get_pd_avg_frm_rate(pd_frm_rate_handle ps_pd_frm_rate);
181 
182 #endif /* IH264E_MODIFY_FRM_RATE_H_ */
183