1 /******************************************************************************
2 *
3 * Copyright (C) 2022 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
23 * isvcd_vui.c
24 *
25 * @brief
26 * This file contains routines to parse VUI NAL's
27 *
28 * @author
29 * Kishore
30 *
31 * @remarks
32 * None
33 *
34 *******************************************************************************
35 */
36
37 #include "ih264_typedefs.h"
38 #include "ih264_macros.h"
39 #include "ih264_platform_macros.h"
40 #include "ih264d_vui.h"
41 #include "ih264d_bitstrm.h"
42 #include "ih264d_parse_cavlc.h"
43 #include "isvcd_structs.h"
44 #include "ih264d_error_handler.h"
45
46 /*****************************************************************************/
47 /* */
48 /* Function Name : isvcd_parse_vui_ext_parametres */
49 /* */
50 /* Description : This function parses VUI NALs. */
51 /* Inputs : ps_vu4 pointer to VUI params */
52 /* ps_bitstrm Bitstream */
53 /* Globals : None */
54 /* Processing : Parses VUI NAL's units and stores the info */
55 /* Outputs : None */
56 /* Returns : None */
57 /* */
58 /* Issues : None */
59 /* */
60 /* Revision History: */
61 /* */
62 /* DD MM YYYY Author(s) Changes (Describe the changes made) */
63 /* 06 05 2002 Kishore Draft */
64 /* */
65 /*****************************************************************************/
66
isvcd_parse_vui_ext_parametres(svc_vui_ext_t * ps_svc_vui_ext,dec_bit_stream_t * ps_bitstrm)67 WORD32 isvcd_parse_vui_ext_parametres(svc_vui_ext_t *ps_svc_vui_ext, dec_bit_stream_t *ps_bitstrm)
68 {
69 UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst;
70 UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer;
71 WORD32 ret;
72 UWORD32 u4_i;
73
74 ps_svc_vui_ext->u4_vui_ext_num_entries_minus1 = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf);
75 if(ps_svc_vui_ext->u4_vui_ext_num_entries_minus1 > 1023)
76 {
77 return ERROR_INV_SPS_PPS_T;
78 }
79
80 for(u4_i = 0; u4_i <= ps_svc_vui_ext->u4_vui_ext_num_entries_minus1; u4_i++)
81 {
82 ps_svc_vui_ext->u1_vui_ext_dependency_id[u4_i] = ih264d_get_bits_h264(ps_bitstrm, 3);
83 ps_svc_vui_ext->u1_vui_ext_quality_id[u4_i] = ih264d_get_bits_h264(ps_bitstrm, 4);
84 ps_svc_vui_ext->u1_vui_ext_temporal_id[u4_i] = ih264d_get_bits_h264(ps_bitstrm, 3);
85 ps_svc_vui_ext->u1_vui_ext_timing_info_present_flag[u4_i] = ih264d_get_bit_h264(ps_bitstrm);
86
87 if(1 == ps_svc_vui_ext->u1_vui_ext_timing_info_present_flag[u4_i])
88 {
89 ps_svc_vui_ext->u4_vui_ext_num_units_in_tick[u4_i] =
90 ih264d_get_bits_h264(ps_bitstrm, 32);
91 ps_svc_vui_ext->u4_vui_ext_time_scale[u4_i] = ih264d_get_bits_h264(ps_bitstrm, 32);
92 ps_svc_vui_ext->u1_vui_ext_fixed_frame_rate_flag[u4_i] =
93 ih264d_get_bit_h264(ps_bitstrm);
94 }
95
96 ps_svc_vui_ext->u1_vui_ext_nal_hrd_params_present_flag[u4_i] =
97 ih264d_get_bit_h264(ps_bitstrm);
98 if(ps_svc_vui_ext->u1_vui_ext_nal_hrd_params_present_flag[u4_i])
99 {
100 ret = ih264d_parse_hrd_parametres(&ps_svc_vui_ext->s_nal_hrd[u4_i], ps_bitstrm);
101 if(ret != OK) return ret;
102 }
103 ps_svc_vui_ext->u1_vui_ext_vcl_hrd_params_present_flag[u4_i] =
104 ih264d_get_bit_h264(ps_bitstrm);
105 if(ps_svc_vui_ext->u1_vui_ext_vcl_hrd_params_present_flag[u4_i])
106 {
107 ret = ih264d_parse_hrd_parametres(&ps_svc_vui_ext->s_vcl_hrd[u4_i], ps_bitstrm);
108 if(ret != OK) return ret;
109 }
110 if(ps_svc_vui_ext->u1_vui_ext_nal_hrd_params_present_flag[u4_i] ||
111 ps_svc_vui_ext->u1_vui_ext_vcl_hrd_params_present_flag[u4_i])
112 {
113 ps_svc_vui_ext->u1_vui_ext_low_delay_hrd_flag[u4_i] = ih264d_get_bit_h264(ps_bitstrm);
114 }
115 ps_svc_vui_ext->u1_vui_ext_pic_struct_present_flag[u4_i] = ih264d_get_bit_h264(ps_bitstrm);
116 }
117 return OK;
118 }
119