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 vbr_str_prms.c
23 *
24 * \brief
25 * This file contain
26 *
27 * \date
28 *
29 * \author
30 * ittiam
31 *
32 ******************************************************************************
33 */
34 /*****************************************************************************/
35 /* File Includes */
36 /*****************************************************************************/
37 /* System include files */
38 #include <stdio.h>
39
40 /* User include files */
41 #include "ittiam_datatypes.h"
42 #include "rc_cntrl_param.h"
43 #include "var_q_operator.h"
44 #include "rc_common.h"
45 #include "vbr_str_prms.h"
46
47 /******************************************************************************
48 Function Name : init_vbv_str_prms
49 Description : Initializes and calcuates the number of I frame and P frames
50 in the delay period
51 Arguments :
52 Return Values : void
53 Revision History:
54 Creation
55 *****************************************************************************/
56 #if NON_STEADSTATE_CODE
init_vbv_str_prms(vbr_str_prms_t * p_vbr_str_prms,UWORD32 u4_intra_frm_interval,UWORD32 u4_src_ticks,UWORD32 u4_tgt_ticks,UWORD32 u4_frms_in_delay_period)57 void init_vbv_str_prms(
58 vbr_str_prms_t *p_vbr_str_prms,
59 UWORD32 u4_intra_frm_interval,
60 UWORD32 u4_src_ticks,
61 UWORD32 u4_tgt_ticks,
62 UWORD32 u4_frms_in_delay_period)
63 {
64 p_vbr_str_prms->u4_frms_in_delay_prd = u4_frms_in_delay_period;
65 p_vbr_str_prms->u4_src_ticks = u4_src_ticks;
66 p_vbr_str_prms->u4_tgt_ticks = u4_tgt_ticks;
67 p_vbr_str_prms->u4_intra_frame_int = u4_intra_frm_interval;
68 }
69 #endif /* #if NON_STEADSTATE_CODE */
70
71 /*********************************************************************************
72 Function Name : change_vbr_str_prms
73 Description : Takes in changes of Intra frame interval, source and target ticks
74 and recalculates the position of the next I frame
75 Arguments :
76 Return Values : void
77 Revision History:
78 Creation
79 ***********************************************************************************/
80 #if NON_STEADSTATE_CODE
change_vsp_ifi(vbr_str_prms_t * p_vbr_str_prms,UWORD32 u4_intra_frame_int)81 void change_vsp_ifi(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_intra_frame_int)
82 {
83 init_vbv_str_prms(
84 p_vbr_str_prms,
85 u4_intra_frame_int,
86 p_vbr_str_prms->u4_src_ticks,
87 p_vbr_str_prms->u4_tgt_ticks,
88 p_vbr_str_prms->u4_frms_in_delay_prd);
89 }
90 /******************************************************************************
91 Function Name : change_vsp_tgt_ticks
92 Description :
93 Arguments : p_vbr_str_prms
94 Return Values : void
95 Revision History:
96 Creation
97 *****************************************************************************/
change_vsp_tgt_ticks(vbr_str_prms_t * p_vbr_str_prms,UWORD32 u4_tgt_ticks)98 void change_vsp_tgt_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_tgt_ticks)
99 {
100 UWORD32 u4_rem_intra_per_scaled;
101 UWORD32 u4_prev_tgt_ticks = p_vbr_str_prms->u4_tgt_ticks;
102
103 /*
104 If the target frame rate is changed, recalculate the position of the next I frame based
105 on the new target frame rate
106
107 LIMITATIONS :
108 Currently no support is available for dynamic change in source frame rate
109 */
110
111 u4_rem_intra_per_scaled =
112 ((p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks - p_vbr_str_prms->u4_cur_pos_in_src_ticks) /
113 u4_prev_tgt_ticks) *
114 u4_tgt_ticks;
115
116 p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks =
117 u4_rem_intra_per_scaled + p_vbr_str_prms->u4_cur_pos_in_src_ticks;
118 }
119 /******************************************************************************
120 Function Name : change_vsp_src_ticks
121 Description :
122 Arguments : p_vbr_str_prms
123 Return Values : void
124 Revision History:
125 Creation
126 *****************************************************************************/
change_vsp_src_ticks(vbr_str_prms_t * p_vbr_str_prms,UWORD32 u4_src_ticks)127 void change_vsp_src_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_src_ticks)
128 {
129 init_vbv_str_prms(
130 p_vbr_str_prms,
131 p_vbr_str_prms->u4_intra_frame_int,
132 u4_src_ticks,
133 p_vbr_str_prms->u4_tgt_ticks,
134 p_vbr_str_prms->u4_frms_in_delay_prd);
135 }
136 /******************************************************************************
137 Function Name : change_vsp_fidp
138 Description :
139 Arguments : p_vbr_str_prms
140 Return Values : void
141 Revision History:
142 Creation
143 *****************************************************************************/
change_vsp_fidp(vbr_str_prms_t * p_vbr_str_prms,UWORD32 u4_frms_in_delay_period)144 void change_vsp_fidp(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_frms_in_delay_period)
145 {
146 init_vbv_str_prms(
147 p_vbr_str_prms,
148 p_vbr_str_prms->u4_intra_frame_int,
149 p_vbr_str_prms->u4_src_ticks,
150 p_vbr_str_prms->u4_tgt_ticks,
151 u4_frms_in_delay_period);
152 }
153 #endif /* #if NON_STEADSTATE_CODE */
154