Coverage Report

Created: 2025-10-10 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/encoder/ih264e_time_stamp.c
Line
Count
Source
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_time_stamp.c
25
*
26
* @brief
27
*  This file contains functions used for source and target time stamp management
28
*
29
* @author
30
*  ittiam
31
*
32
* @par List of Functions:
33
*  - gcd
34
*  - ih264e_get_range
35
*  - ih264e_frame_time_get_init_free_memtab
36
*  - ih264e_init_frame_time
37
*  - ih264e_should_src_be_skipped
38
*  - ih264e_time_stamp_get_init_free_memtab
39
*  - ih264e_init_time_stamp
40
*  - ih264e_update_time_stamp
41
*  - ih264e_frame_time_get_src_frame_rate
42
*  - ih264e_frame_time_get_tgt_frame_rate
43
*  - ih264e_frame_time_get_src_ticks
44
*  - ih264e_frame_time_get_tgt_ticks
45
*  - ih264e_frame_time_get_src_time
46
*  - ih264e_frame_time_get_tgt_time
47
*  - ih264e_frame_time_update_src_frame_rate
48
*  - ih264e_frame_time_update_tgt_frame_rate
49
*  - ih264_time_stamp_update_frame_rate
50
*
51
* @remarks
52
*  none
53
*
54
*******************************************************************************
55
*/
56
57
/*****************************************************************************/
58
/* File Includes                                                             */
59
/*****************************************************************************/
60
61
/* User Include Files */
62
#include "ih264_typedefs.h"
63
#include "iv2.h"
64
#include "ive2.h"
65
66
#include "ih264_defs.h"
67
#include "ih264_mem_fns.h"
68
#include "ih264_padding.h"
69
#include "ih264_structs.h"
70
#include "ih264_trans_quant_itrans_iquant.h"
71
#include "ih264_inter_pred_filters.h"
72
#include "ih264_intra_pred_filters.h"
73
#include "ih264_deblk_edge_filters.h"
74
#include "ih264_cabac_tables.h"
75
76
#include "ime_defs.h"
77
#include "ime_distortion_metrics.h"
78
#include "ime_structs.h"
79
80
#include "irc_mem_req_and_acq.h"
81
#include "irc_cntrl_param.h"
82
#include "irc_frame_info_collector.h"
83
#include "irc_common.h"
84
#include "irc_rate_control_api.h"
85
86
#include "ih264e_error.h"
87
#include "ih264e_defs.h"
88
#include "ih264e_rate_control.h"
89
#include "ih264e_bitstream.h"
90
#include "ih264e_cabac_structs.h"
91
#include "ih264e_structs.h"
92
#include "ih264e_time_stamp.h"
93
94
95
/*****************************************************************************/
96
/* Function Definitions                                                      */
97
/*****************************************************************************/
98
99
/**
100
*******************************************************************************
101
*
102
* @brief Function to compute gcd of two numbers
103
*
104
* @par   Description
105
*  Function to compute gcd of two numbers
106
*
107
* @param[in] i4_x
108
*  value 1
109
*
110
* @param[in] i4_y
111
*  value 2
112
*
113
* @returns
114
*  GCD(value 1, value 2)
115
*
116
* @remarks none
117
*
118
*******************************************************************************
119
*/
120
static WORD32 gcd(WORD32 i4_x, WORD32 i4_y)
121
67.0k
{
122
67.0k
    if (i4_x > i4_y)
123
3.69k
    {
124
3.69k
        i4_x = i4_y + i4_x;
125
3.69k
        i4_y = i4_x - i4_y;
126
3.69k
        i4_x = i4_x - i4_y;
127
3.69k
    }
128
152k
    while (i4_y != 0)
129
85.2k
    {
130
85.2k
        WORD32 temp;
131
85.2k
        i4_x = i4_x % i4_y;
132
85.2k
        temp = i4_x;
133
85.2k
        i4_x = i4_y;
134
85.2k
        i4_y = temp;
135
85.2k
    }
136
67.0k
    return (i4_x);
137
67.0k
}
138
139
/**
140
*******************************************************************************
141
*
142
* @brief Function to determine number of bits required to represent a given
143
*  value
144
*
145
* @par   Description
146
*  This function determines the number of bits required to represent the given
147
*  value. It is used to find out number of bits to read when the data size is
148
*  not fixed (e.g. vop_time_increment_resolution).
149
*
150
* @param[in] u4_value
151
*  Value for which the number of bits required to represent is to be determined
152
*
153
* @param[in] u1_no_of_bits
154
*  Represents the value's word type = 8/16/32
155
*
156
* @returns
157
*  The number of bits required to represent the given number
158
*
159
* @remarks none
160
*
161
*******************************************************************************
162
*/
163
static UWORD8 ih264e_get_range(UWORD32 u4_value, UWORD8 u1_no_of_bits)
164
53.2k
{
165
53.2k
    UWORD8 count;
166
53.2k
    UWORD32 temp;
167
168
53.2k
    if (u4_value > (UWORD32) ((1 << (u1_no_of_bits >> 1)) - 1))
169
0
    {
170
0
        temp = (1 << (u1_no_of_bits - 1));
171
0
        for (count = 0; count < (u1_no_of_bits >> 1); count++)
172
0
        {
173
0
            if ((temp & u4_value) != 0)
174
0
            {
175
0
                return (UWORD8) (u1_no_of_bits - count);
176
0
            }
177
0
            else
178
0
            {
179
0
                temp >>= 1;
180
0
            }
181
0
        }
182
0
        return 0;
183
0
    }
184
53.2k
    else
185
53.2k
    {
186
53.2k
        temp = (1 << ((u1_no_of_bits >> 1) - 1));
187
53.2k
        for (count = 0; count < ((u1_no_of_bits >> 1) - 1); count++)
188
53.2k
        {
189
53.2k
            if ((temp & u4_value) != 0)
190
53.2k
            {
191
53.2k
                return (UWORD8) ((u1_no_of_bits >> 1) - count);
192
53.2k
            }
193
0
            else
194
0
            {
195
0
                temp >>= 1;
196
0
            }
197
53.2k
        }
198
0
        return 1;
199
53.2k
    }
200
53.2k
}
201
202
/**
203
*******************************************************************************
204
*
205
* @brief
206
*  Function to init frame time memtabs
207
*
208
* @par Description
209
*  Function to init frame time memtabs
210
*
211
* @param[in] pps_frame_time
212
*  Pointer to frame time contexts
213
*
214
* @param[in] ps_memtab
215
*  Pointer to memtab
216
*
217
* @param[in] e_func_type
218
*  Function type (get memtabs/init memtabs)
219
*
220
* @returns
221
*  none
222
*
223
* @remarks
224
*
225
*******************************************************************************
226
*/
227
WORD32 ih264e_frame_time_get_init_free_memtab(frame_time_handle *pps_frame_time,
228
                                              itt_memtab_t *ps_memtab,
229
                                              ITT_FUNC_TYPE_E e_func_type)
230
55.5k
{
231
55.5k
    WORD32 i4_mem_tab_idx = 0;
232
55.5k
    frame_time_t s_temp_frame_time_t;
233
234
    /* Hack for al alloc, during which we dont have any state memory.
235
     Dereferencing can cause issues */
236
55.5k
    if (e_func_type == GET_NUM_MEMTAB || e_func_type == FILL_MEMTAB)
237
46.3k
        (*pps_frame_time) = &s_temp_frame_time_t;
238
239
    /* for src rate control state structure */
240
55.5k
    if (e_func_type != GET_NUM_MEMTAB)
241
27.7k
    {
242
27.7k
        fill_memtab(&ps_memtab[i4_mem_tab_idx], sizeof(frame_time_t),
243
27.7k
                    ALIGN_128_BYTE, PERSISTENT, DDR);
244
27.7k
        use_or_fill_base(&ps_memtab[0], (void**) pps_frame_time, e_func_type);
245
27.7k
    }
246
55.5k
    i4_mem_tab_idx++;
247
248
55.5k
    return (i4_mem_tab_idx);
249
55.5k
}
250
251
/**
252
*******************************************************************************
253
*
254
* @brief
255
*  Function to init frame time context
256
*
257
* @par Description
258
*  Frame time structure stores the time of the source and the target frames to
259
*  be encoded. Based on the time we decide whether or not to encode the source
260
*  frame
261
*
262
* @param[in] ps_frame_time
263
*  Pointer Frame time context
264
*
265
* @param[in] u4_src_frm_rate
266
*  Source frame rate
267
*
268
* @param[in] u4_tgt_frm_rate
269
*  Target frame rate
270
*
271
* @returns
272
*  none
273
*
274
* @remarks
275
*
276
*******************************************************************************
277
*/
278
void ih264e_init_frame_time(frame_time_t *ps_frame_time,
279
                            UWORD32 u4_src_frm_rate,
280
                            UWORD32 u4_tgt_frm_rate)
281
67.0k
{
282
    /* Initialise the common time base based on which the source and target
283
     * frame times increase */
284
67.0k
    WORD32 i4_gcd = gcd(u4_src_frm_rate, u4_tgt_frm_rate);
285
286
    /* Avoiding overflow by doing calculations in float */
287
67.0k
    number_t s_src_frm_rate, s_tgt_frm_rate, s_gcd, s_common_time_base, s_numerator;
288
289
67.0k
    SET_VAR_Q(s_src_frm_rate, u4_src_frm_rate, 0);
290
67.0k
    SET_VAR_Q(s_tgt_frm_rate, u4_tgt_frm_rate, 0);
291
67.0k
    SET_VAR_Q(s_gcd, i4_gcd, 0);
292
67.0k
    mult32_var_q(s_src_frm_rate, s_tgt_frm_rate, &s_numerator);
293
67.0k
    div32_var_q(s_numerator, s_gcd, &s_common_time_base);
294
67.0k
    number_t_to_word32(s_common_time_base, &(ps_frame_time->common_time_base));
295
296
    /* The source and target increment per vop is initialized */
297
67.0k
    ps_frame_time->u4_src_frm_time_incr = ps_frame_time->common_time_base
298
67.0k
                    / u4_src_frm_rate;
299
67.0k
    ps_frame_time->u4_tgt_frm_time_incr = ps_frame_time->common_time_base
300
67.0k
                    / u4_tgt_frm_rate;
301
302
    /* Initialise the source and target times to 0 (RESET) */
303
67.0k
    ps_frame_time->u4_src_frm_time = 0;
304
67.0k
    ps_frame_time->u4_tgt_frm_time = 0;
305
306
    /* Initialize the number of frms not to be skipped to 0 */
307
67.0k
    ps_frame_time->u4_num_frms_dont_skip = 0;
308
67.0k
}
309
310
/**
311
*******************************************************************************
312
*
313
* @brief
314
*  Function to check if frame can be skipped
315
*
316
* @par Description
317
*  Based on the source and target frame time and the delta time stamp
318
*  we decide whether to code the source or not.
319
*  This is based on the assumption
320
*  that the source frame rate is greater that target frame rate.
321
*  Updates the time_stamp structure
322
*
323
* @param[in] ps_frame_time
324
*  Handle to frame time context
325
*
326
* @param[in] u4_delta_time_stamp
327
*  Time stamp difference between frames
328
*
329
* @param[out] pu4_frm_not_skipped_for_dts
330
*  Flag to indicate if frame is already skipped by application
331
*
332
* @returns
333
*  Flag to skip frame
334
*
335
* @remarks
336
*
337
*******************************************************************************
338
*/
339
UWORD8 ih264e_should_src_be_skipped(frame_time_t *ps_frame_time,
340
                                    UWORD32 u4_delta_time_stamp,
341
                                    UWORD32 *pu4_frm_not_skipped_for_dts)
342
134k
{
343
134k
    UWORD8 skip_src = 0;
344
345
134k
    if (ps_frame_time->u4_tgt_frm_time > ps_frame_time->u4_src_frm_time &&
346
4.84k
        ps_frame_time->u4_tgt_frm_time >= (ps_frame_time->u4_src_frm_time +
347
4.84k
                        ps_frame_time->u4_src_frm_time_incr))
348
469
    {
349
469
        skip_src = 1;
350
469
    }
351
352
    /* source time gets updated every frame */
353
134k
    ps_frame_time->u4_src_frm_time += ps_frame_time->u4_src_frm_time_incr;
354
355
    /* target time gets updated only when the source is coded */
356
134k
    if (!skip_src)
357
134k
    {
358
134k
        ps_frame_time->u4_tgt_frm_time += ps_frame_time->u4_tgt_frm_time_incr;
359
134k
    }
360
361
    /* If the source and target frame times get incremented properly
362
     both should be equal to the common time base at the same time. If
363
     that happens we reset the time to zero*/
364
134k
    if (( ps_frame_time->common_time_base ==(WORD32)ps_frame_time->u4_src_frm_time)
365
0
         && (ps_frame_time->common_time_base ==(WORD32) ps_frame_time->u4_tgt_frm_time ))
366
0
    {
367
0
        ps_frame_time->u4_src_frm_time = 0;
368
0
        ps_frame_time->u4_tgt_frm_time = 0;
369
0
    }
370
371
    /* This keeps a count of how many frames need not be skipped in order
372
     to take care of the delta time stamp */
373
134k
    ps_frame_time->u4_num_frms_dont_skip += (u4_delta_time_stamp - 1);
374
375
    /** If this frame is to be skipped in order to maintain the tgt_frm_rate
376
     check if already a frame has been skipped by the application.
377
     In that case, do not skip this frame **/
378
134k
    if (ps_frame_time->u4_num_frms_dont_skip && skip_src)
379
0
    {
380
0
        skip_src = 0;
381
0
        *pu4_frm_not_skipped_for_dts = 1;
382
0
        ps_frame_time->u4_num_frms_dont_skip -= 1;
383
0
    }
384
134k
    else
385
134k
    {
386
134k
        pu4_frm_not_skipped_for_dts[0] = 0;
387
134k
    }
388
389
134k
    return (skip_src);
390
134k
}
391
392
/**
393
*******************************************************************************
394
*
395
* @brief
396
*  Function to inititialize time stamp memtabs
397
*
398
* @par Description
399
*  Function to initialize time stamp memtabs
400
*
401
* @param[in] pps_time_stamp
402
*  Pointer to time stamp context
403
*
404
* @param[in] ps_memtab
405
*  Pointer to memtab
406
*
407
* @param[in] e_func_type
408
*  Funcion type (Get memtab/ init memtab)
409
*
410
* @returns
411
*   number of memtabs used
412
*
413
* @remarks
414
*
415
*******************************************************************************
416
*/
417
WORD32 ih264e_time_stamp_get_init_free_memtab(time_stamp_handle *pps_time_stamp,
418
                                              itt_memtab_t *ps_memtab,
419
                                              ITT_FUNC_TYPE_E e_func_type)
420
55.5k
{
421
55.5k
    WORD32 i4_mem_tab_idx = 0;
422
55.5k
    time_stamp_t s_temp_time_stamp_t;
423
424
    /* Hack for al alloc, during which we dont have any state memory.
425
     Dereferencing can cause issues */
426
55.5k
    if (e_func_type == GET_NUM_MEMTAB || e_func_type == FILL_MEMTAB)
427
46.3k
        (*pps_time_stamp) = &s_temp_time_stamp_t;
428
429
    /* for src rate control state structure */
430
55.5k
    if (e_func_type != GET_NUM_MEMTAB)
431
27.7k
    {
432
27.7k
        fill_memtab(&ps_memtab[i4_mem_tab_idx], sizeof(time_stamp_t),
433
27.7k
                    ALIGN_128_BYTE, PERSISTENT, DDR);
434
27.7k
        use_or_fill_base(&ps_memtab[0], (void**) pps_time_stamp, e_func_type);
435
27.7k
    }
436
55.5k
    i4_mem_tab_idx++;
437
438
55.5k
    return (i4_mem_tab_idx);
439
55.5k
}
440
441
/**
442
*******************************************************************************
443
*
444
* @brief
445
*  Function to initialize time stamp context
446
*
447
* @par Description
448
*  Time stamp structure stores the time stamp data that
449
*  needs to be sent in to the header of MPEG4. Based on the
450
*  max target frame rate the vop_time increment resolution is set
451
*  so as to support all the frame rates below max frame rate.
452
*  A support till the third decimal point is assumed.
453
*
454
* @param[in] ps_time_stamp
455
*  Pointer to time stamp structure
456
*
457
* @param[in] u4_max_frm_rate
458
*  Maximum frame rate
459
*
460
* @param[in] u4_src_frm_rate
461
*  Source frame rate
462
*
463
* @returns
464
*  none
465
*
466
* @remarks
467
*
468
*******************************************************************************
469
*/
470
void ih264e_init_time_stamp(time_stamp_t *ps_time_stamp,
471
                            UWORD32 u4_max_frm_rate,
472
                            UWORD32 u4_src_frm_rate)
473
53.2k
{
474
    /* We expect the max frame rate to be less than 60000,
475
     * if not we divide it by zero and work with it */
476
53.2k
    if (u4_max_frm_rate > 60000)
477
53.2k
    {
478
53.2k
        u4_max_frm_rate >>= 1;
479
53.2k
        ps_time_stamp->is_max_frame_rate_scaled = 1;
480
53.2k
    }
481
0
    else
482
0
    {
483
0
        ps_time_stamp->is_max_frame_rate_scaled = 0;
484
0
    }
485
486
53.2k
    ps_time_stamp->u4_vop_time_incr_res = u4_max_frm_rate;
487
53.2k
    ps_time_stamp->u4_vop_time_incr_range = ih264e_get_range(u4_max_frm_rate, 32);
488
53.2k
    ps_time_stamp->u4_vop_time_incr = (ps_time_stamp->u4_vop_time_incr_res * 1000) / u4_src_frm_rate;/* Since frm rate is in millisec */
489
53.2k
    ps_time_stamp->u4_vop_time = 0;
490
53.2k
    ps_time_stamp->u4_cur_tgt_vop_time = 0;
491
53.2k
    ps_time_stamp->u4_prev_tgt_vop_time = 0;
492
53.2k
}
493
494
/**
495
*******************************************************************************
496
*
497
* @brief Function to update time stamp context
498
*
499
* @par Description
500
*  Vop time is incremented by increment value. When vop time goes
501
*  more than the vop time resolution set the modulo time base to
502
*  1 and reduce the vop time by vop time resolution so that the
503
*  excess value is present in vop time and get accumulated over time
504
*  so that the corresponding frame rate is achieved at a average of
505
*  1000 seconds
506
*
507
* @param[in] ps_time_stamp
508
*  Pointer to time stamp structure
509
*
510
* @returns
511
*  none
512
*
513
* @remarks
514
*
515
*******************************************************************************
516
*/
517
void ih264e_update_time_stamp(time_stamp_t *ps_time_stamp)
518
134k
{
519
    /* Since get time stamp is called after the update
520
     A copy of the vop time and the modulo time is stored */
521
134k
    ps_time_stamp->u4_cur_tgt_vop_time = ps_time_stamp->u4_vop_time;
522
523
134k
    ps_time_stamp->u4_vop_time += ps_time_stamp->u4_vop_time_incr;
524
134k
    if (ps_time_stamp->u4_vop_time >= ps_time_stamp->u4_vop_time_incr_res)
525
11.3k
    {
526
11.3k
        ps_time_stamp->u4_vop_time -= ps_time_stamp->u4_vop_time_incr_res;
527
11.3k
    }
528
134k
}
529
530
/****************************************************************************
531
                       Run-Time Modifying functions
532
****************************************************************************/
533
534
/**
535
*******************************************************************************
536
*
537
* @brief Function to get source frame rate
538
*
539
* @par Description
540
*  Function to get source frame rate
541
*
542
* @param[in] ps_frame_time
543
*  Pointer to frame time context
544
*
545
* @returns
546
*  source frame rate
547
*
548
* @remarks
549
*
550
*******************************************************************************
551
*/
552
WORD32 ih264e_frame_time_get_src_frame_rate(frame_time_t *ps_frame_time)
553
134k
{
554
134k
    return (ps_frame_time->common_time_base / ps_frame_time->u4_src_frm_time_incr);
555
134k
}
556
557
/**
558
*******************************************************************************
559
*
560
* @brief Function to get target frame rate
561
*
562
* @par Description
563
*  Function to get target frame rate
564
*
565
* @param[in] ps_frame_time
566
*  Pointer to frame time context
567
*
568
* @returns
569
*   target frame rate
570
*
571
* @remarks
572
*
573
*******************************************************************************
574
*/
575
WORD32 ih264e_frame_time_get_tgt_frame_rate(frame_time_t *ps_frame_time)
576
0
{
577
0
    return (ps_frame_time->common_time_base / ps_frame_time->u4_tgt_frm_time_incr);
578
0
}
579
580
/**
581
*******************************************************************************
582
*
583
* @brief Function to get source time increment
584
*
585
* @par Description
586
*  Function to get source time increment
587
*
588
* @param[in] ps_frame_time
589
*  Pointer to frame time context
590
*
591
* @returns
592
*  source time increment
593
*
594
* @remarks
595
*
596
*******************************************************************************
597
*/
598
WORD32 ih264e_frame_time_get_src_ticks(frame_time_t *ps_frame_time)
599
60.1k
{
600
60.1k
    return (ps_frame_time->u4_src_frm_time_incr);
601
60.1k
}
602
603
/**
604
*******************************************************************************
605
*
606
* @brief Function to get target time increment
607
*
608
* @par Description
609
*  Function to get target time increment
610
*
611
* @param[in] ps_frame_time
612
*  Pointer to frame time context
613
*
614
* @returns
615
*  target time increment
616
*
617
* @remarks
618
*
619
*******************************************************************************
620
*/
621
WORD32 ih264e_frame_time_get_tgt_ticks(frame_time_t *ps_frame_time)
622
60.1k
{
623
60.1k
    return (ps_frame_time->u4_tgt_frm_time_incr);
624
60.1k
}
625
626
/**
627
*******************************************************************************
628
*
629
* @brief Function to get src frame time
630
*
631
* @par Description
632
*  Function to get src frame time
633
*
634
* @param[in] ps_frame_time
635
*  Pointer to frame time context
636
*
637
* @returns
638
*  src frame time
639
*
640
* @remarks
641
*
642
*******************************************************************************
643
*/
644
WORD32 ih264e_frame_time_get_src_time(frame_time_t *frame_time)
645
0
{
646
0
    return (frame_time->u4_src_frm_time);
647
0
}
648
649
/**
650
*******************************************************************************
651
*
652
* @brief Function to get tgt frame time
653
*
654
* @par Description
655
*  Function to get tgt frame time
656
*
657
* @param[in] ps_frame_time
658
*  Pointer to frame time context
659
*
660
* @returns
661
*  tgt frame time
662
*
663
* @remarks
664
*
665
*******************************************************************************
666
*/
667
WORD32 ih264e_frame_time_get_tgt_time(frame_time_t *frame_time)
668
0
{
669
0
    return (frame_time->u4_tgt_frm_time);
670
0
}
671
672
/**
673
*******************************************************************************
674
*
675
* @brief Function to update source frame time with a new source frame rate
676
*
677
* @par Description
678
*  Function to update source frame time with a new source frame rate
679
*
680
* @param[in] ps_frame_time
681
*  Pointer to frame time context
682
*
683
* @param[in] src_frm_rate
684
*  source frame rate
685
*
686
* @returns
687
*  none
688
*
689
* @remarks
690
*
691
*******************************************************************************
692
*/
693
void ih264e_frame_time_update_src_frame_rate(frame_time_t *ps_frame_time,
694
                                             WORD32 src_frm_rate)
695
6.89k
{
696
    /* Since tgt frame rate does not change deriving the tgt_frm rate from
697
     * common_time_base */
698
6.89k
    WORD32 tgt_frm_rate = ps_frame_time->common_time_base / ps_frame_time->u4_tgt_frm_time_incr;
699
700
    /* Re-initialise frame_time based on the new src_frame_rate and
701
     * old tgt_frame_rate */
702
6.89k
    ih264e_init_frame_time(ps_frame_time, src_frm_rate, tgt_frm_rate);
703
6.89k
}
704
705
/**
706
*******************************************************************************
707
*
708
* @brief Function to update target frame time with a new source frame rate
709
*
710
* @par Description
711
*  Function to update target frame time with a new source frame rate
712
*
713
* @param[in] ps_frame_time
714
*  Pointer to frame time context
715
*
716
* @param[in] tgt_frm_rate
717
*  target frame rate
718
*
719
* @returns
720
*  none
721
*
722
* @remarks
723
*
724
*******************************************************************************
725
*/
726
void ih264e_frame_time_update_tgt_frame_rate(frame_time_t *ps_frame_time,
727
                                             WORD32 tgt_frm_rate)
728
6.89k
{
729
    /* Since src frame rate does not change deriving the src_frm rate from
730
     * common_time_base */
731
6.89k
    WORD32 src_frm_rate = ps_frame_time->common_time_base / ps_frame_time->u4_src_frm_time_incr;
732
733
    /* Re-initialise frame_time based on the new tgt_frame_rate and
734
     * old src_frame_rate */
735
6.89k
    ih264e_init_frame_time(ps_frame_time, src_frm_rate, tgt_frm_rate);
736
6.89k
}
737
738
/**
739
*******************************************************************************
740
*
741
* @brief Function to update target frame time with a new source frame rate
742
*
743
* @par Description
744
*  When the frame rate changes the time increment is modified by appropriate ticks
745
*
746
* @param[in] ps_time_stamp
747
*  Pointer to time stamp structure
748
*
749
* @param[in] src_frm_rate
750
*  source frame rate
751
*
752
* @returns
753
*  none
754
*
755
* @remarks
756
*
757
*******************************************************************************
758
*/
759
void ih264_time_stamp_update_frame_rate(time_stamp_t *ps_time_stamp,
760
                                        UWORD32 src_frm_rate)
761
6.89k
{
762
6.89k
    ps_time_stamp->u4_vop_time_incr = (ps_time_stamp->u4_vop_time_incr_res * 1000) / src_frm_rate;/* Since frm rate is in millisec */
763
6.89k
}