/src/libhevc/encoder/vbr_str_prms.c
Line | Count | Source (jump to first uncovered line) |
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 |
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 | 2.78k | { |
64 | 2.78k | p_vbr_str_prms->u4_frms_in_delay_prd = u4_frms_in_delay_period; |
65 | 2.78k | p_vbr_str_prms->u4_src_ticks = u4_src_ticks; |
66 | 2.78k | p_vbr_str_prms->u4_tgt_ticks = u4_tgt_ticks; |
67 | 2.78k | p_vbr_str_prms->u4_intra_frame_int = u4_intra_frm_interval; |
68 | 2.78k | } |
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 |
81 | | void change_vsp_ifi(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_intra_frame_int) |
82 | 0 | { |
83 | 0 | init_vbv_str_prms( |
84 | 0 | p_vbr_str_prms, |
85 | 0 | u4_intra_frame_int, |
86 | 0 | p_vbr_str_prms->u4_src_ticks, |
87 | 0 | p_vbr_str_prms->u4_tgt_ticks, |
88 | 0 | p_vbr_str_prms->u4_frms_in_delay_prd); |
89 | 0 | } |
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 | | *****************************************************************************/ |
98 | | void change_vsp_tgt_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_tgt_ticks) |
99 | 0 | { |
100 | 0 | UWORD32 u4_rem_intra_per_scaled; |
101 | 0 | 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 | 0 | u4_rem_intra_per_scaled = |
112 | 0 | ((p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks - p_vbr_str_prms->u4_cur_pos_in_src_ticks) / |
113 | 0 | u4_prev_tgt_ticks) * |
114 | 0 | u4_tgt_ticks; |
115 | |
|
116 | 0 | p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks = |
117 | 0 | u4_rem_intra_per_scaled + p_vbr_str_prms->u4_cur_pos_in_src_ticks; |
118 | 0 | } |
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 | | *****************************************************************************/ |
127 | | void change_vsp_src_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_src_ticks) |
128 | 0 | { |
129 | 0 | init_vbv_str_prms( |
130 | 0 | p_vbr_str_prms, |
131 | 0 | p_vbr_str_prms->u4_intra_frame_int, |
132 | 0 | u4_src_ticks, |
133 | 0 | p_vbr_str_prms->u4_tgt_ticks, |
134 | 0 | p_vbr_str_prms->u4_frms_in_delay_prd); |
135 | 0 | } |
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 | | *****************************************************************************/ |
144 | | void change_vsp_fidp(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_frms_in_delay_period) |
145 | 0 | { |
146 | 0 | init_vbv_str_prms( |
147 | 0 | p_vbr_str_prms, |
148 | 0 | p_vbr_str_prms->u4_intra_frame_int, |
149 | 0 | p_vbr_str_prms->u4_src_ticks, |
150 | 0 | p_vbr_str_prms->u4_tgt_ticks, |
151 | 0 | u4_frms_in_delay_period); |
152 | 0 | } |
153 | | #endif /* #if NON_STEADSTATE_CODE */ |