ronnie
2022-10-23 68f5ca84d926736535296469a2d3fcbea06ca8a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/******************************************************************************
 *
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/*!
******************************************************************************
* \file vbr_str_prms.c
*
* \brief
*    This file contain
*
* \date
*
* \author
*    ittiam
*
******************************************************************************
*/
/*****************************************************************************/
/* File Includes                                                             */
/*****************************************************************************/
/* System include files */
#include <stdio.h>
 
/* User include files */
#include "ittiam_datatypes.h"
#include "rc_cntrl_param.h"
#include "var_q_operator.h"
#include "rc_common.h"
#include "vbr_str_prms.h"
 
/******************************************************************************
  Function Name   : init_vbv_str_prms
  Description     : Initializes and calcuates the number of I frame and P frames
                    in the delay period
  Arguments       :
  Return Values   : void
  Revision History:
                    Creation
*****************************************************************************/
#if NON_STEADSTATE_CODE
void 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)
{
    p_vbr_str_prms->u4_frms_in_delay_prd = u4_frms_in_delay_period;
    p_vbr_str_prms->u4_src_ticks = u4_src_ticks;
    p_vbr_str_prms->u4_tgt_ticks = u4_tgt_ticks;
    p_vbr_str_prms->u4_intra_frame_int = u4_intra_frm_interval;
}
#endif /* #if NON_STEADSTATE_CODE */
 
/*********************************************************************************
  Function Name   : change_vbr_str_prms
  Description     : Takes in changes of Intra frame interval, source and target ticks
                    and recalculates the position of the  next I frame
  Arguments       :
  Return Values   : void
  Revision History:
                    Creation
***********************************************************************************/
#if NON_STEADSTATE_CODE
void change_vsp_ifi(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_intra_frame_int)
{
    init_vbv_str_prms(
        p_vbr_str_prms,
        u4_intra_frame_int,
        p_vbr_str_prms->u4_src_ticks,
        p_vbr_str_prms->u4_tgt_ticks,
        p_vbr_str_prms->u4_frms_in_delay_prd);
}
/******************************************************************************
  Function Name   : change_vsp_tgt_ticks
  Description     :
  Arguments       : p_vbr_str_prms
  Return Values   : void
  Revision History:
                    Creation
*****************************************************************************/
void change_vsp_tgt_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_tgt_ticks)
{
    UWORD32 u4_rem_intra_per_scaled;
    UWORD32 u4_prev_tgt_ticks = p_vbr_str_prms->u4_tgt_ticks;
 
    /*
        If the target frame rate is changed, recalculate the position of the next I frame based
        on the new target frame rate
 
        LIMITATIONS :
        Currently no support is available for dynamic change in source frame rate
    */
 
    u4_rem_intra_per_scaled =
        ((p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks - p_vbr_str_prms->u4_cur_pos_in_src_ticks) /
         u4_prev_tgt_ticks) *
        u4_tgt_ticks;
 
    p_vbr_str_prms->u4_intra_prd_pos_in_tgt_ticks =
        u4_rem_intra_per_scaled + p_vbr_str_prms->u4_cur_pos_in_src_ticks;
}
/******************************************************************************
  Function Name   : change_vsp_src_ticks
  Description     :
  Arguments       : p_vbr_str_prms
  Return Values   : void
  Revision History:
                    Creation
*****************************************************************************/
void change_vsp_src_ticks(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_src_ticks)
{
    init_vbv_str_prms(
        p_vbr_str_prms,
        p_vbr_str_prms->u4_intra_frame_int,
        u4_src_ticks,
        p_vbr_str_prms->u4_tgt_ticks,
        p_vbr_str_prms->u4_frms_in_delay_prd);
}
/******************************************************************************
  Function Name   : change_vsp_fidp
  Description     :
  Arguments       : p_vbr_str_prms
  Return Values   : void
  Revision History:
                    Creation
*****************************************************************************/
void change_vsp_fidp(vbr_str_prms_t *p_vbr_str_prms, UWORD32 u4_frms_in_delay_period)
{
    init_vbv_str_prms(
        p_vbr_str_prms,
        p_vbr_str_prms->u4_intra_frame_int,
        p_vbr_str_prms->u4_src_ticks,
        p_vbr_str_prms->u4_tgt_ticks,
        u4_frms_in_delay_period);
}
#endif /* #if NON_STEADSTATE_CODE */