1/******************************************************************************
2*
3* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
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
19/**
20 *******************************************************************************
21 * @file
22 *  ihevc_structs.h
23 *
24 * @brief
25 *  Structure definitions used in the code
26 *
27 * @author
28 *  Ittiam
29 *
30 * @par List of Functions:
31 *
32 * @remarks
33 *  None
34 *
35 *******************************************************************************
36 */
37
38#ifndef _IHEVC_STRUCTS_H_
39#define _IHEVC_STRUCTS_H_
40
41
42/**
43 * Buffering Period SEI parameters Info
44 */
45typedef struct
46{
47    /**
48     * specifies SPS Id active for the coded picture assosiated
49     * with the bp message.
50     */
51    UWORD8  u1_bp_seq_parameter_set_id;
52
53    /**
54     * Derived from Hrd parameters
55     */
56    UWORD8  u1_sub_pic_cpb_params_present_flag;
57
58    /**
59     * specifies the presence of the initial_alt_cpb_removal_delay[ i ]
60     * and initial_alt_cpb_removal_offset[ i ] syntax elements
61     */
62    UWORD8  u1_rap_cpb_params_present_flag;
63
64    /**
65     * cbp removal delay used in buffering period SEI
66     */
67    UWORD32 u4_cpb_delay_offset;
68
69    /**
70     * dbp removal delay used in buffering period SEI
71     */
72    UWORD32 u4_dpb_delay_offset;
73
74    /**
75     * concatanation flag
76     */
77    UWORD8 u1_concatenation_flag;
78
79    /**
80     * delata cbp removal delay
81     */
82    UWORD32 u4_au_cpb_removal_delay_delta_minus1;
83
84    /**
85     * specify the default initial CPB removal delays, respectively,
86     * for the CPB when the NAL HRD parameters are in use
87     */
88    UWORD32 au4_nal_initial_cpb_removal_delay[MAX_CPB_CNT];
89
90    /**
91     * specify the alternate initial CPB removal delays, respectively,
92     * for the CPB when the NAL HRD parameters are in use
93     */
94    UWORD32 au4_nal_initial_alt_cpb_removal_delay[MAX_CPB_CNT];
95
96    /**
97     * specify the initial CPB removal delay offset, respectively,
98     * for the CPB when the NAL HRD parameters are in use
99     */
100    UWORD32 au4_nal_initial_cpb_removal_delay_offset[MAX_CPB_CNT];
101
102    /**
103     * specify the alternate initial CPB removal delays offsets, respectively,
104     * for the CPB when the NAL HRD parameters are in use
105     */
106    UWORD32 au4_nal_initial_alt_cpb_removal_delay_offset[MAX_CPB_CNT];
107
108    /**
109     * specify the default initial CPB removal delays, respectively,
110     * for the CPB when the VCL HRD parameters are in use
111     */
112    UWORD32 au4_vcl_initial_cpb_removal_delay[MAX_CPB_CNT];
113
114    /**
115     * specify the initial alt CPB removal delays , respectively,
116     * for the CPB when the VCL HRD parameters are in use
117     */
118    UWORD32 au4_vcl_initial_alt_cpb_removal_delay[MAX_CPB_CNT];
119
120    /**
121     * specify the initial CPB removal delay offset, respectively,
122     * for the CPB when the VCL HRD parameters are in use
123     */
124    UWORD32 au4_vcl_initial_cpb_removal_delay_offset[MAX_CPB_CNT];
125
126    /**
127     * specify the alternate initial CPB removal delays offsets, respectively,
128     * for the CPB when the VCL HRD parameters are in use
129     */
130    UWORD32 au4_vcl_initial_alt_cpb_removal_delay_offset[MAX_CPB_CNT];
131
132    /**
133     * Inital CPB removal delay
134     */
135    UWORD32 u4_initial_cpb_removal_delay_length;
136
137    /**
138     * CPB cnt for corr. sublayer
139     */
140    UWORD32 u4_cpb_cnt;
141
142
143    /**
144     * VBV buffer size used in buffering period SEI
145     */
146    UWORD32 u4_buffer_size_sei;
147
148    /**
149     * Encoder buffer fullness  used in buffering period SEI
150     */
151    UWORD32 u4_dbf_sei;
152
153    /**
154     * target bitrate used in buffering period SEI
155     */
156    UWORD32 u4_target_bit_rate_sei;
157
158}buf_period_sei_params_t;
159
160
161/**
162 * Picture Timing SEI parameters Info
163 */
164typedef struct
165{
166    /**
167     * derived from vui parameters
168     */
169    UWORD8 u1_frame_field_info_present_flag;
170
171    /**
172     * indicates whether a picture should be displayed as a
173     * frame or as one or more fields
174     */
175    UWORD32 u4_pic_struct;
176
177    UWORD32 u4_source_scan_type;
178
179    /**
180     * if 1, indicates if the current pic is a duplicte pic in output order
181     */
182    UWORD8 u1_duplicate_flag;
183
184    /**
185     * specifies the number clock ticks between the nominal CPB removal time
186     * au associated with the pt SEI message and
187     * the preceding au in decoding order that contained a bp SEI message
188     */
189    UWORD32 u4_au_cpb_removal_delay_minus1;
190
191    /**
192     * compute the DPB output time of the picture
193     */
194    UWORD32 u4_pic_dpb_output_delay;
195
196    UWORD32 u4_pic_dpb_output_du_delay;
197
198    /**
199     * specifies the number of decoding units in the access unit
200     * the picture timing SEI message is associated with
201     */
202    UWORD32 u4_num_decoding_units_minus1;
203
204    /**
205     * if 1 specifies that the du_common_cpb_removal_delay_increment_minus1 is present
206     */
207    UWORD8 u1_du_common_cpb_removal_delay_flag;
208
209    /**
210     * specifies the duration, in units of clock sub-ticks,
211     * between the nominal CPB removal times of any two consecutive decoding units
212     * in decoding order in the access unit associated with the pt_SEI message
213     */
214    UWORD32 u4_du_common_cpb_removal_delay_increment_minus1; //same as u4_du_cpb_removal_delay_increment_minus1
215
216    /**
217     * specifies the number of NAL units in the decoding unit of the access unit
218     * the picture timing SEI message is associated with.
219     * range from 0 to (pic size in ctby - 1)
220     */
221    UWORD32 au4_num_nalus_in_du_minus1[4320 / MIN_CTB_SIZE];
222
223    /**
224     * specifies the duration, in units of clock sub-ticks,
225     * between the nominal CPB removal times of the ( i + 1 )-th decoding unit and the i-th decoding unit,
226     * in decoding order, in the access unit associated with the pt_SEI message
227     */
228    UWORD32 au4_du_cpb_removal_delay_increment_minus1[4320 / MIN_CTB_SIZE];
229
230}pic_timing_sei_params_t;
231
232/**
233 * Structure to hold Recovery point SEI parameters Info
234 */
235typedef struct
236{
237    /**
238     * specifies the recovery point of output pictures in output order
239     */
240    WORD32 i4_recovery_poc_cnt;
241
242    UWORD8 u1_exact_match_flag;
243
244    /**
245     * indicates the presence or absence of a broken link in the NAL unit
246     * stream at the location of the recovery point SEI message
247     */
248
249    UWORD8 u1_broken_link_flag;
250
251}recovery_point_sei_params_t;
252
253/**
254 * Structure to hold Mastering Display Colour Volume SEI
255 */
256typedef struct
257{
258    /**
259     * Array to store the display_primaries_x values
260     */
261    UWORD16 au2_display_primaries_x[3];
262
263    /**
264     * Array to store the display_primaries_y values
265     */
266    UWORD16 au2_display_primaries_y[3];
267
268    /**
269     * Variable to store the white point x value
270     */
271    UWORD16 u2_white_point_x;
272
273    /**
274     * Variable to store the white point y value
275     */
276    UWORD16 u2_white_point_y;
277
278    /**
279     * Variable to store the max display mastering luminance value
280     */
281    UWORD32 u4_max_display_mastering_luminance;
282
283    /**
284     * Variable to store the min display mastering luminance value
285     */
286    UWORD32 u4_min_display_mastering_luminance;
287
288}mastering_dis_col_vol_sei_params_t;
289
290/**
291 * Structure to hold active parameter parameter set SEI parameters Info
292 */
293typedef struct
294{
295    /*
296    * active vps id
297    */
298
299    UWORD8 u1_active_video_parameter_set_id;
300
301    /*
302     * default set to zero.
303     */
304    UWORD8 u1_self_contained_cvs_flag;
305
306    UWORD8 u1_no_parameter_set_update_flag;
307
308    UWORD8 u1_num_sps_ids_minus1;
309
310    /*
311     * active sps id
312     */
313    UWORD8 au1_active_seq_parameter_set_id[15];
314
315    UWORD32 au4_layer_sps_idx[64];
316
317}active_parameter_set_sei_param_t;
318
319/**
320 * Structure to hold SEI Hash values
321 */
322typedef struct
323{
324    /*
325     * SEI Hash values for each color component
326     */
327    UWORD8 au1_sei_hash[3][16];
328
329}hash_sei_param_t;
330
331/**
332 * Structure to hold user data registered SEI param Info
333 */
334typedef struct
335{
336    /**
337     * Contains country code by Annex A of Recommendation ITU-T T.35
338     */
339    UWORD8 u1_itu_t_t35_country_code;
340
341    /**
342     * Contains country code by Annex B of Recommendation ITU-T T.35
343     */
344    UWORD8 u1_itu_t_t35_country_code_extension_byte;
345
346    /**
347     * Contains data registered as specified in Recommendation ITU-T T.35
348     */
349    UWORD8 u1_itu_t_t35_payload_byte[MAX_USERDATA_PAYLOAD];
350
351    /**
352     * Valid payload size present in this buffer
353     */
354    WORD32 i4_valid_payload_size;
355
356    /**
357     * Total payload size incase payloadSize > IHEVCD_MAX_USERDATA_PAYLOAD
358     */
359    WORD32 i4_payload_size;
360}user_data_registered_itu_t_t35_t;
361
362/**
363 * Structure to hold time code SEI param info
364 */
365typedef struct
366{
367    /**
368     * Number of sets of clock timestamp syntax elements present for the current picture
369     */
370    UWORD8 u1_num_clock_ts;
371
372    /**
373     * Indicates presenc of associated set of clock timestamps
374     */
375    UWORD8 au1_clock_timestamp_flag[MAX_NUM_CLOCK_TS];
376
377    /**
378     * Used in calculating clockTimestamp[i]
379     */
380    UWORD8 au1_units_field_based_flag[MAX_NUM_CLOCK_TS];
381
382    /**
383     * Specifies the method of dropping values of the n_frames[i] syntax element
384     */
385    UWORD8 au1_counting_type[MAX_NUM_CLOCK_TS];
386
387    /**
388     * Specifies that the n_frames[i] syntax element is followed by seconds_value[i],
389     * minutes_value[i] and hours_value[i]
390     */
391    UWORD8 au1_full_timestamp_flag[MAX_NUM_CLOCK_TS];
392
393    /**
394     * Indicates the discontinuity in clockTimestamp
395     */
396    UWORD8 au1_discontinuity_flag[MAX_NUM_CLOCK_TS];
397
398    /**
399     * Specifies the skipping of one or more values of n_frames[i]
400     */
401    UWORD8 au1_cnt_dropped_flag[MAX_NUM_CLOCK_TS];
402
403    /**
404     * Specifies the value of nFrames used to compute clockTimestamp[i]
405     */
406    UWORD16 au2_n_frames[MAX_NUM_CLOCK_TS];
407
408    /**
409     * Specifies the presence of seconds_value[i] and minutes_flag[i]
410     */
411    UWORD8 au1_seconds_flag[MAX_NUM_CLOCK_TS];
412
413    /**
414     * Specifies the presence of minutes_value[i] and hours_flag[i]
415     */
416    UWORD8 au1_minutes_flag[MAX_NUM_CLOCK_TS];
417
418    /**
419     * Specifies the presence of hours_value[i]
420     */
421    UWORD8 au1_hours_flag[MAX_NUM_CLOCK_TS];
422
423    /**
424     * Specifies the value of sS used to compute clockTimestamp[i]
425     */
426    UWORD8 au1_seconds_value[MAX_NUM_CLOCK_TS];
427
428    /**
429     * Specifies the value of mM used to compute clockTimestamp[i]
430     */
431    UWORD8 au1_minutes_value[MAX_NUM_CLOCK_TS];
432
433    /**
434     * Specifies the value of hH used to compute clockTimestamp[i]
435     */
436    UWORD8 au1_hours_value[MAX_NUM_CLOCK_TS];
437
438    /**
439     * Specifies the length in bits of the time_offset_value[i]
440     */
441    UWORD8 au1_time_offset_length[MAX_NUM_CLOCK_TS];
442
443    /**
444     * pecifies the value of tOffset used to compute clockTimestamp[i]
445     */
446    UWORD8 au1_time_offset_value[MAX_NUM_CLOCK_TS];
447
448}time_code_t;
449
450
451/**
452 * Structure to hold SEI parameters Info
453 */
454typedef struct
455{
456
457    WORD8 i1_sei_parameters_present_flag;
458
459    WORD8 i1_aud_present_flag;
460
461    WORD8 i1_buf_period_params_present_flag;
462
463    WORD8 i1_pic_timing_params_present_flag;
464
465    WORD8 i1_recovery_point_params_present_flag;
466
467    WORD8 i1_active_parameter_set;
468
469    WORD8 i4_sei_mastering_disp_colour_vol_params_present_flags;
470
471    /* Enable/Disable SEI Hash on the Decoded picture & Hash type */
472    /* < 3 : Checksum, 2 : CRC, 1 : MD5, 0 : disable >            */
473    /* Other values are not supported                             */
474    WORD8 i1_decoded_pic_hash_sei_flag;
475
476    /* number of user data e.g. CC data, BAR data, AFD data etc */
477    WORD32 i4_sei_user_data_cnt;
478
479    WORD8 i1_user_data_registered_present_flag;
480
481    WORD8 i1_time_code_present_flag;
482
483    buf_period_sei_params_t  s_buf_period_sei_params;
484
485    pic_timing_sei_params_t  s_pic_timing_sei_params;
486
487    recovery_point_sei_params_t s_recovery_point_params;
488
489    active_parameter_set_sei_param_t s_active_parameter_set_sei_params;
490
491    hash_sei_param_t    s_hash_sei_params;
492
493    mastering_dis_col_vol_sei_params_t s_mastering_dis_col_vol_sei_params;
494
495    user_data_registered_itu_t_t35_t as_user_data_registered_itu_t_t35[USER_DATA_MAX];
496
497    time_code_t s_time_code;
498} sei_params_t;
499
500
501/**
502 * Sub-layer HRD parameters Info
503 */
504typedef struct
505{
506    /**
507     * (together with bit_rate_scale) specifies the
508     * maximum input bit rate for the i-th CPB
509     */
510    UWORD32 au4_bit_rate_value_minus1[MAX_CPB_CNT];
511    /**
512     * together with cpb_size_scale to specify the
513     * CPB size when the CPB operates at the access unit level.
514     */
515    UWORD32 au4_cpb_size_value_minus1[MAX_CPB_CNT];
516
517    /**
518     * together with cpb_size_du_scale to specify the CPB size
519     * when the CPB operates at sub-picture level
520     */
521    UWORD32 au4_cpb_size_du_value_minus1[MAX_CPB_CNT];
522
523    /**
524     * specifies the maximum input bit rate for the i-th CPB when the CPB
525     * operates at the sub-picture level. bit_rate_du_value_minus1[ i ]
526     * shall be in the range of 0 to 2^32 - 2
527     */
528    UWORD32 au4_bit_rate_du_value_minus1[MAX_CPB_CNT];
529
530    /**
531     * if 1, specifies that the HSS operates in a constant bit rate (CBR) mode
532     * if 0, specifies that the HSS operates in a intermittent bit rate (CBR) mode
533     */
534    UWORD8  au1_cbr_flag[32];
535
536}sub_lyr_hrd_params_t;
537
538/**
539 * HRD parameters Info
540 */
541typedef struct
542{
543    /**
544     * Indicates the presence of the
545     * num_units_in_ticks, time_scale flag
546     */
547    UWORD8 u1_timing_info_present_flag;
548
549    /**
550     * Number of units that
551     * correspond to one increment of the
552     * clock. Indicates the  resolution
553     */
554    UWORD32 u4_num_units_in_tick;
555
556    /**
557     * The number of time units that pass in one second
558     */
559    UWORD32 u4_time_scale;
560
561    /**
562     * Nal- hrd parameters flag
563     */
564    UWORD8 u1_nal_hrd_parameters_present_flag;
565
566    /**
567     * VCL- hrd parameters flag
568     */
569    UWORD8 u1_vcl_hrd_parameters_present_flag;
570
571    /**
572     * Indicates the presence of NAL-HRD params or VCL_HRD params
573     * in the bitstream
574     */
575    UWORD8 u1_cpbdpb_delays_present_flag;
576
577    /**
578     * specifies that sub-picture level CPB removal delay parameters are
579     * present in picture timing SEI messages
580     */
581    UWORD8 u1_sub_pic_cpb_params_present_flag;
582
583    /**
584     * specify the clock sub-tick
585     * (the minimum interval of time that can be represented in the coded data when sub_pic_cpb_params_present_flag is equal to 1)
586     */
587    UWORD8 u1_tick_divisor_minus2;
588
589    /**
590     * specifies the length, in bits for the du cpb delay syntax in pt_sei
591     */
592    UWORD8 u1_du_cpb_removal_delay_increment_length_minus1;
593
594    /**
595     * Indicates presence of sub_pic_cpb_params in pic timing sei
596     */
597    UWORD8 u1_sub_pic_cpb_params_in_pic_timing_sei_flag;
598
599    /**
600     * specifies the length, in bits, of the pic_dpb_output_du_delay syntax
601     * element in the picture timing SEI message and the
602     * pic_spt_dpb_output_du_delay syntax element in the decoding unit
603     * information SEI message
604     */
605    UWORD8 u1_dpb_output_delay_du_length_minus1;
606
607    /**
608     * (together with bit_rate_value_minus1) specifies the
609     * maximum input bit rate of the i-th CPB
610     */
611    UWORD32 u4_bit_rate_scale;
612
613    /**
614     * (together with cpb_size_du_value_minus1) specfies
615     * CPB size of the i-th CPB when the CPB operates
616     * at the access unit level
617     */
618    UWORD32 u4_cpb_size_scale;
619
620    /**
621     * (together with cpb_size_du_value_minus1) specfies
622     * CPB size of the i-th CPB when the CPB operates
623     * at the sub-picture level
624     */
625    UWORD32 u4_cpb_size_du_scale;
626
627
628    /**
629     * specifies the length, in bits for initial cpb delay (nal/vcl)sysntax in bp sei
630     */
631    UWORD8  u1_initial_cpb_removal_delay_length_minus1;
632
633    /**
634     * specifies the length, in bits for the au cpb delay syntax in pt_sei
635     */
636    UWORD8  u1_au_cpb_removal_delay_length_minus1;
637
638    /**
639     * specifies the length, in bits, of the pic_dpb_output_delay syntax element in the pt SEI message
640     */
641    UWORD8  u1_dpb_output_delay_length_minus1;
642
643    /**
644     * if 1, , for the highest temporal sub-layers, the temporal distance between the HRD output times
645     * of consecutive pictures in output order is constrained refer to Table E-6
646     */
647    UWORD8 au1_fixed_pic_rate_general_flag[6];
648
649    UWORD8 au1_fixed_pic_rate_within_cvs_flag[6];
650
651    /**
652     * if 1, , for the highest temporal sub-layers, the temporal distance (in clock ticks) between the
653     * element units that specify HRD output times of consecutive pictures in output order is constrained
654     * refer to Table E-6
655     */
656    UWORD8 au1_elemental_duration_in_tc_minus1[6];
657
658    /**
659     * specifies the HRD operational mode
660     */
661    UWORD8 au1_low_delay_hrd_flag[6];
662
663    /**
664     * 1 specifies the number of alternative CPB specifications in the
665     * bitstream of the cvs when HighestTid is equal to i
666     */
667    UWORD8 au1_cpb_cnt_minus1[6];
668
669
670    /**
671     * VUI level Sub-layer HRD parameters
672     */
673    sub_lyr_hrd_params_t as_sub_layer_hrd_params[6];
674
675}hrd_params_t;
676
677/**
678 * Structure to hold VUI parameters Info
679 */
680typedef struct
681{
682    /**
683     * indicates the presence of aspect_ratio
684     */
685    UWORD8 u1_aspect_ratio_info_present_flag;
686
687    /**
688     * specifies the aspect ratio of the luma samples
689     */
690    UWORD8 u1_aspect_ratio_idc;
691
692    /**
693     *  width of the luma samples. user dependent
694     */
695    UWORD16 u2_sar_width;
696
697    /**
698     *  hieght of the luma samples. user dependent
699     */
700    UWORD16 u2_sar_height;
701
702    /**
703     * if 1, specifies that the overscan_appropriate_flag is present
704     * if 0, the preferred display method for the video signal is unspecified
705     */
706    UWORD8 u1_overscan_info_present_flag;
707
708    /**
709     * if 1,indicates that the cropped decoded pictures output
710     * are suitable for display using overscan
711     */
712    UWORD8 u1_overscan_appropriate_flag;
713
714    /**
715     * if 1 specifies that video_format, video_full_range_flag and
716     * colour_description_present_flag are present
717     */
718    UWORD8 u1_video_signal_type_present_flag;
719
720    /**
721     *
722     */
723    UWORD8 u1_video_format;
724
725    /**
726     * indicates the black level and range of the luma and chroma signals
727     */
728    UWORD8 u1_video_full_range_flag;
729
730    /**
731     * if 1,to 1 specifies that colour_primaries, transfer_characteristics
732     * and matrix_coefficients are present
733     */
734    UWORD8 u1_colour_description_present_flag;
735
736    /**
737     * indicates the chromaticity coordinates of the source primaries
738     */
739    UWORD8 u1_colour_primaries;
740
741    /**
742     * indicates the opto-electronic transfer characteristic of the source picture
743     */
744    UWORD8 u1_transfer_characteristics;
745
746    /**
747     * the matrix coefficients used in deriving luma and chroma signals
748     * from the green, blue, and red primaries
749     */
750    UWORD8 u1_matrix_coefficients;
751
752    /**
753     * if 1, specifies that chroma_sample_loc_type_top_field and
754     * chroma_sample_loc_type_bottom_field are present
755     */
756    UWORD8 u1_chroma_loc_info_present_flag;
757
758    /**
759     * location of chroma samples
760     */
761    UWORD8 u1_chroma_sample_loc_type_top_field;
762
763    UWORD8 u1_chroma_sample_loc_type_bottom_field;
764
765    /**
766     * if 1, indicates that the value of all decoded chroma samples is
767     * equal to 1 << ( BitDepthC - 1 )
768     */
769    UWORD8 u1_neutral_chroma_indication_flag;
770
771    /**
772     * 1 indicates that the coded video sequence conveys pictures that represent fields
773     * 0 indicates the pictures that represents field
774     */
775    UWORD8 u1_field_seq_flag;
776
777    /**
778     * specifies that picture timing SEI messages are present for every picture
779     */
780    UWORD8 u1_frame_field_info_present_flag;
781
782    /**
783     * 1 indicates that the default display window parameters follow next in the VUI
784     */
785    UWORD8 u1_default_display_window_flag;
786
787    /**
788     * specify the samples of the pictures in the coded video sequence
789     * that are within the default display window,
790     * in terms of a rectangular region specified in picture coordinates for display
791     */
792    UWORD32 u4_def_disp_win_left_offset;
793
794    UWORD32 u4_def_disp_win_right_offset;
795
796    UWORD32 u4_def_disp_win_top_offset;
797
798    UWORD32 u4_def_disp_win_bottom_offset;
799
800    /**
801     * to 1 specifies that the syntax structure hrd_parameters is present in the vui_parameters syntax structue
802     */
803    UWORD8 u1_vui_hrd_parameters_present_flag;
804
805    /**
806     * VUI level HRD parameters
807     */
808    hrd_params_t s_vui_hrd_parameters;
809
810    /**
811     * Indicates the presence of the
812     * num_units_in_ticks, time_scale flag
813     */
814    UWORD8 u1_vui_timing_info_present_flag;
815
816    /**
817     * Number of units that
818     * correspond to one increment of the
819     * clock. Indicates the  resolution
820     */
821    UWORD32 u4_vui_num_units_in_tick;
822
823    /**
824     * The number of time units that pass in one second
825     */
826    UWORD32 u4_vui_time_scale;
827    /**
828     * if 1, indicates that the POC for each picture in the coded video sequence (cvs) (not the first picture), in decoding order,
829     * is proportional to the output time of the picture relative to that of the first picture in the cvs
830     */
831    UWORD8 u1_poc_proportional_to_timing_flag;
832
833    /**
834     * num_ticks_poc_diff_one_minus1 plus 1 specifies the number of clock ticks
835     * corresponding to a difference of poc values equal to 1
836     */
837    UWORD8 u1_num_ticks_poc_diff_one_minus1;
838
839    /**
840     * 1, specifies that the following cvs bitstream restriction parameters are present
841     */
842    UWORD8 u1_bitstream_restriction_flag;
843
844    /**
845     *  if 1, indicates that each pps that is active in the cvs has
846     *  the same value of the tile syntax elements
847     */
848    UWORD8 u1_tiles_fixed_structure_flag;
849
850    /**
851     * if 0, indicates that no pel outside the pic boundaries and
852     * no sub-pels derived using pels outside the pic boundaries is used for inter prediction
853     */
854    UWORD8 u1_motion_vectors_over_pic_boundaries_flag;
855
856    /**
857     * if 1, indicates
858     * all P/B slices belonging to the same pic have an identical refpic list0,
859     * all B slices that belong to the same picture have an identical refpic list1.
860     */
861    UWORD8 u1_restricted_ref_pic_lists_flag;
862
863    /**
864     * min_spatial_segmentation_idc, when not equal to 0, establishes a bound on the maximum possible size of distinct
865     * coded spatial segmentation regions in the pictures of the CVS. When min_spatial_segmentation_idc is not present, it is
866     * inferred to be equal to 0. The value of min_spatial_segmentation_idc shall be in the range of 0 to 4095, inclusive.
867     *
868     * can be used by a decoder to calculate the maximum number of luma samples to be processed by one processing thread
869     *
870     * If tiles=0 and entropy_sync=0 then
871     *     no slice shall exceed ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4 luma samples
872     *
873     * If tiles=1 and entropy_sync=0 then
874     *     no tile shall exceed ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4 luma samples
875     *
876     * If tiles=0 and entropy_sync=1 then
877     *     ( 2 * pic_height_in_luma_samples + pic_width_in_luma_samples ) * CtbSizeY
878     *             <= ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4
879     */
880    UWORD32 u4_min_spatial_segmentation_idc;
881    /**
882     * Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units
883     * associated with any coded picture
884     */
885    UWORD8 u1_max_bytes_per_pic_denom;
886
887    /**
888     * Indicates an upper bound for the number of bits of coding_unit() data
889     */
890    UWORD8 u1_max_bits_per_mincu_denom;
891
892    /**
893     * Indicate the maximum absolute value of a decoded horizontal MV component
894     * in quarter-pel luma units
895     */
896    UWORD8 u1_log2_max_mv_length_horizontal;
897
898    /**
899     * Indicate the maximum absolute value of a decoded vertical MV component
900     * in quarter-pel luma units
901     */
902    UWORD8 u1_log2_max_mv_length_vertical;
903}vui_t;
904
905/**
906 * Picture buffer
907 */
908typedef struct
909{
910    UWORD8 *pu1_luma;
911    UWORD8 *pu1_chroma;
912
913    WORD32 i4_abs_poc;
914    WORD32 i4_poc_lsb;
915    /** Used to store display Timestamp for current buffer */
916    WORD32 u4_ts;
917    UWORD8 u1_used_as_ref;
918
919    UWORD8 u1_free_delay_cnt;
920
921    /**
922     * buffer ID from buffer manager
923     */
924    UWORD8 u1_buf_id;
925
926
927    // See IV_FLD_TYPE_T for all field types
928    UWORD32 e4_fld_type;
929
930    sei_params_t s_sei_params;
931
932    WORD32 i4_vui_present;
933
934    vui_t s_vui;
935
936}pic_buf_t;
937
938
939/**
940 * Reference List
941 */
942typedef struct
943{
944    void *pv_pic_buf;
945
946    void *pv_mv_buf;
947
948    UWORD8 u1_used_as_ref;
949
950}ref_list_t;
951
952
953/**
954 * SAO
955 */
956typedef struct
957{
958    /**
959     * sao_type_idx_luma
960     */
961    UWORD32      b3_y_type_idx   : 3;
962
963    /**
964     * luma SaoOffsetVal[1]
965     */
966    WORD32      b4_y_offset_1   : 4;
967
968    /**
969     * luma SaoOffsetVal[2]
970     */
971    WORD32      b4_y_offset_2   : 4;
972
973    /**
974     * luma SaoOffsetVal[3]
975     */
976    WORD32      b4_y_offset_3   : 4;
977
978    /**
979     * luma SaoOffsetVal[4]
980     */
981    WORD32      b4_y_offset_4   : 4;
982
983    /**
984     * luma sao_band_position
985     */
986    UWORD32      b5_y_band_pos   : 5;
987
988    WORD32                      : 0;
989
990    /**
991     * sao_type_idx_chroma
992     */
993    UWORD32      b3_cb_type_idx  : 3;
994
995    /**
996     * chroma SaoOffsetVal[1]
997     */
998    WORD32      b4_cb_offset_1  : 4;
999
1000    /**
1001     * chroma SaoOffsetVal[2]
1002     */
1003    WORD32      b4_cb_offset_2  : 4;
1004
1005    /**
1006     * chroma SaoOffsetVal[3]
1007     */
1008    WORD32      b4_cb_offset_3  : 4;
1009
1010    /**
1011     * chroma SaoOffsetVal[4]
1012     */
1013    WORD32      b4_cb_offset_4  : 4;
1014
1015    /**
1016     * cb sao_band_position
1017     */
1018    UWORD32      b5_cb_band_pos  : 5;
1019
1020    WORD32                      : 0;
1021
1022    /**
1023     * sao_type_idx_chroma
1024     */
1025    UWORD32      b3_cr_type_idx  : 3;
1026
1027    /**
1028     * chroma SaoOffsetVal[1]
1029     */
1030    WORD32      b4_cr_offset_1  : 4;
1031
1032    /**
1033     * chroma SaoOffsetVal[2]
1034     */
1035    WORD32      b4_cr_offset_2  : 4;
1036
1037    /**
1038     * chroma SaoOffsetVal[3]
1039     */
1040    WORD32      b4_cr_offset_3  : 4;
1041
1042    /**
1043     * chroma SaoOffsetVal[4]
1044     */
1045    WORD32      b4_cr_offset_4  : 4;
1046
1047    /**
1048     * cr sao_band_position
1049     */
1050    UWORD32      b5_cr_band_pos  : 5;
1051
1052    WORD32                      : 0;
1053
1054}sao_t;
1055
1056/**
1057 * SAO
1058 */
1059typedef struct
1060{
1061    /**
1062     * sao_type_idx_luma
1063     */
1064    UWORD32      b3_y_type_idx   : 3;
1065
1066    /**
1067     * luma SaoOffsetVal[1]
1068     */
1069    WORD32      b8_y_offset_1   : 8;
1070
1071    /**
1072     * luma SaoOffsetVal[2]
1073     */
1074    WORD32      b8_y_offset_2   : 8;
1075
1076    /**
1077     * luma SaoOffsetVal[3]
1078     */
1079    WORD32      b8_y_offset_3   : 8;
1080
1081    /**
1082     * luma SaoOffsetVal[4]
1083     */
1084    WORD32      b8_y_offset_4   : 8;
1085
1086    /**
1087     * luma sao_band_position
1088     */
1089    UWORD32      b5_y_band_pos   : 5;
1090
1091    WORD32                      : 0;
1092
1093    /**
1094     * sao_type_idx_chroma
1095     */
1096    UWORD32      b3_cb_type_idx  : 3;
1097
1098    /**
1099     * chroma SaoOffsetVal[1]
1100     */
1101    WORD32      b8_cb_offset_1  : 8;
1102
1103    /**
1104     * chroma SaoOffsetVal[2]
1105     */
1106    WORD32      b8_cb_offset_2  : 8;
1107
1108    /**
1109     * chroma SaoOffsetVal[3]
1110     */
1111    WORD32      b8_cb_offset_3  : 8;
1112
1113    /**
1114     * chroma SaoOffsetVal[4]
1115     */
1116    WORD32      b8_cb_offset_4  : 8;
1117
1118    /**
1119     * cb sao_band_position
1120     */
1121    UWORD32      b5_cb_band_pos  : 5;
1122
1123    WORD32                      : 0;
1124
1125    /**
1126     * sao_type_idx_chroma
1127     */
1128    UWORD32      b3_cr_type_idx  : 3;
1129
1130    /**
1131     * chroma SaoOffsetVal[1]
1132     */
1133    WORD32      b8_cr_offset_1  : 8;
1134
1135    /**
1136     * chroma SaoOffsetVal[2]
1137     */
1138    WORD32      b8_cr_offset_2  : 8;
1139
1140    /**
1141     * chroma SaoOffsetVal[3]
1142     */
1143    WORD32      b8_cr_offset_3  : 8;
1144
1145    /**
1146     * chroma SaoOffsetVal[4]
1147     */
1148    WORD32      b8_cr_offset_4  : 8;
1149
1150    /**
1151     * cr sao_band_position
1152     */
1153    UWORD32      b5_cr_band_pos  : 5;
1154
1155    WORD32                      : 0;
1156
1157}sao_10bd_t;
1158
1159/**
1160 * Motion vector
1161 */
1162typedef struct
1163{
1164    /**
1165     * Horizontal Motion Vector
1166     */
1167    WORD16 i2_mvx;
1168
1169    /**
1170     * Vertical Motion Vector
1171     */
1172    WORD16 i2_mvy;
1173}mv_t;
1174
1175/*****************************************************************************/
1176/* Following results in packed 48 bit structure. If mv_t included            */
1177/*  ref_pic_buf_id, then 8 bits will be wasted for each mv for aligning.     */
1178/*  Also using mv_t as elements directly instead of a pointer to l0 and l1   */
1179/*  mvs. Since pointer takes 4 bytes and MV itself is 4 bytes. It does not   */
1180/*  really help using pointers.                                              */
1181/*****************************************************************************/
1182
1183/**
1184 * PU Motion Vector info
1185 */
1186typedef struct
1187{
1188    /**
1189     *  L0 Motion Vector
1190     */
1191    mv_t s_l0_mv;
1192
1193    /**
1194     *  L1 Motion Vector
1195     */
1196    mv_t s_l1_mv;
1197
1198    /**
1199     *  L0 Ref index
1200     */
1201    WORD8   i1_l0_ref_idx;
1202
1203    /**
1204     *  L1 Ref index
1205     */
1206    WORD8   i1_l1_ref_idx;
1207
1208    /**
1209     *  L0 Ref Pic Buf ID
1210     */
1211    WORD8 i1_l0_ref_pic_buf_id;
1212
1213    /**
1214     *  L1 Ref Pic Buf ID
1215     */
1216    WORD8 i1_l1_ref_pic_buf_id;
1217
1218}pu_mv_t;
1219
1220/**
1221 * PU information
1222 */
1223typedef struct
1224{
1225
1226    /**
1227     *  PU motion vectors
1228     */
1229    pu_mv_t     mv;
1230
1231    /**
1232     *  PU X position in terms of min PU (4x4) units
1233     */
1234    UWORD32     b4_pos_x        : 4;
1235
1236    /**
1237     *  PU Y position in terms of min PU (4x4) units
1238     */
1239    UWORD32     b4_pos_y        : 4;
1240
1241    /**
1242     *  PU width in pixels = (b4_wd + 1) << 2
1243     */
1244    UWORD32     b4_wd           : 4;
1245
1246    /**
1247     *  PU height in pixels = (b4_ht + 1) << 2
1248     */
1249    UWORD32     b4_ht           : 4;
1250
1251    /**
1252     *  Intra or Inter flag for each partition - 0 or 1
1253     */
1254    UWORD32     b1_intra_flag   : 1;
1255
1256
1257    /**
1258     *  PRED_L0, PRED_L1, PRED_BI - Initialized in parsing only for MVP case
1259     */
1260    UWORD32     b2_pred_mode    : 2;
1261
1262
1263    /**
1264     *  Merge flag for each partition - 0 or 1
1265     */
1266    UWORD32     b1_merge_flag   : 1;
1267
1268    /**
1269     *  Merge index for each partition - 0 to 4
1270     */
1271    UWORD32     b3_merge_idx    : 3;
1272
1273    /*************************************************************************/
1274    /* Following two flags can be overloaded with b3_merge_idx if there      */
1275    /* is need for additional bits                                           */
1276    /*************************************************************************/
1277
1278    /**
1279     *  If merge is zero, following gives presence of mvd for L0 MV
1280     */
1281    UWORD32     b1_l0_mvp_idx   : 1;
1282
1283    /**
1284     *  If merge is zero, following gives presence of mvd for L1 MV
1285     */
1286    UWORD32     b1_l1_mvp_idx   : 1;
1287
1288    /**
1289     * Partition mode - Needed during MV merge stage
1290     * Note: Part mode can be derived using pu_wd, pu_ht and minCB size
1291     * If there is a need for bits, the following can be removed at the cost
1292     * of more control code in MV Merge
1293     */
1294    UWORD32      b3_part_mode    : 3;
1295
1296    /**
1297     * Partition index - Needed during MV merge stage
1298     */
1299    UWORD32      b2_part_idx     : 2;
1300
1301}pu_t;
1302
1303/**
1304 * TU information
1305 */
1306typedef struct
1307{
1308    /**
1309     *  TU X position in terms of min TU (4x4) units
1310     */
1311    UWORD32      b4_pos_x            : 4;
1312
1313    /**
1314     *  TU Y position in terms of min TU (4x4) units
1315     */
1316    UWORD32     b4_pos_y            : 4;
1317
1318    /*************************************************************************/
1319    /* Luma TU size (width or height) = 1 << (b3_size + 2)                   */
1320    /*   i.e. 0 : 4, 1 : 8, 2: 16, 3: 32, 4: 64                              */
1321    /* Note: Though 64 x 64 TU is not possible, this size is supported to    */
1322    /* signal SKIP CUs or PCM CUs etc where transform is not called          */
1323    /* Chroma width will be half of luma except for 4x4 luma                 */
1324    /*************************************************************************/
1325    /**
1326     * Luma TU size (width or height)
1327     */
1328    UWORD32     b3_size             : 3; //To be changed.
1329
1330    /*************************************************************************/
1331    /* Chroma present : For 4x4 Luma TUs only the fourth one contains Cb     */
1332    /* Cr info. For the first three TUs in 8x8 (for 4x4 luma) this will      */
1333    /* be zero. For all the other cases this will be 1                       */
1334    /*************************************************************************/
1335    /**
1336     * 4x4 Luma TUs only the fourth one contains cb,cr
1337     * TODO: Check if this is really needed, cb_cbf and cr_cbf should be enough
1338     */
1339
1340    /**
1341     *  Y CBF
1342     */
1343    UWORD32      b1_y_cbf            : 1;
1344
1345    /**
1346     *  Cb CBF
1347     */
1348    UWORD32      b1_cb_cbf           : 1;
1349
1350
1351    /**
1352     *  Cr CBF
1353     */
1354    UWORD32     b1_cr_cbf           : 1;
1355
1356
1357    /**
1358     *  Flag to indicate if it is the first TU in a CU
1359     */
1360    UWORD32     b1_first_tu_in_cu       : 1;
1361
1362    /**
1363     *  Transform quant bypass flag
1364     */
1365    UWORD32     b1_transquant_bypass  : 1;
1366
1367    /**
1368     *  Y Qp
1369     */
1370    //UWORD32     b6_qp               : 6; // BUG_FIX related to nighbour QP's in case of negative QP for HBD.
1371    WORD32     b7_qp               : 7;
1372
1373
1374    /**
1375     *  Luma Intra Mode 0 - 34
1376     */
1377    UWORD32    b6_luma_intra_mode      : 6;
1378
1379    /*************************************************************************/
1380    /* Chroma Intra Mode Index 0 - 4: Actual mode (0, 1, 10, 26, 34, X) to be*/
1381    /* derived using luma_intra_mode and the following                       */
1382    /*************************************************************************/
1383    /**
1384     * Chroma Intra Mode Index 0 - 4
1385     */
1386    UWORD32    b3_chroma_intra_mode_idx    : 3;
1387
1388}tu_t;
1389
1390/**
1391 * CU information
1392 */
1393typedef struct
1394{
1395
1396    /**
1397     *  CU X position in terms of min CU (8x8) units
1398     */
1399    UWORD32 b3_cu_pos_x :3;
1400
1401    /**
1402     *  CU Y position in terms of min CU (8x8) units
1403     */
1404    UWORD32 b3_cu_pos_y :3;
1405
1406    /**
1407     *  CU size in terms of min CU (8x8) units
1408     */
1409    UWORD32 b4_cu_size :4;
1410
1411    /**
1412     *  transquant bypass flag ; 0 for this encoder
1413     */
1414    UWORD32 b1_tq_bypass_flag :1;
1415
1416    /**
1417     *  CU skip flag
1418     */
1419    UWORD32 b1_skip_flag :1;
1420
1421    /**
1422     *  intra / inter CU flag
1423     */
1424    UWORD32 b1_pred_mode_flag :1;
1425
1426    /**
1427     *  indicates partition information for CU
1428     *  For intra 0 : for 2Nx2N / 1 for NxN iff CU=minCBsize
1429     *  For inter 0 : @sa PART_SIZE_E
1430     */
1431    UWORD32 b3_part_mode :3;
1432
1433    /**
1434     *  0 for this encoder
1435     */
1436    UWORD32 b1_pcm_flag :1;
1437
1438    /**
1439     *  only applicable for intra cu
1440     */
1441    UWORD32 b3_chroma_intra_pred_mode :3;
1442
1443    /**
1444     * only applicable for intra cu
1445     */
1446    UWORD32 b1_prev_intra_luma_pred_flag0 :1;
1447
1448    /**
1449     * only applicable for intra cu and pred_mode=NxN
1450     */
1451    UWORD32 b1_prev_intra_luma_pred_flag1 :1;
1452
1453    /**
1454     * only applicable for intra cu and pred_mode=NxN
1455     */
1456    UWORD32 b1_prev_intra_luma_pred_flag2 :1;
1457
1458    /**
1459     * only applicable for intra cu and pred_mode=NxN
1460     */
1461    UWORD32 b1_prev_intra_luma_pred_flag3 :1;
1462
1463    /**
1464     *  only applicable for luma intra cu
1465     */
1466    UWORD32 b2_mpm_idx0 :2;
1467
1468    /**
1469     *  only applicable for intra cu and pred_mode=NxN
1470     */
1471    UWORD32 b2_mpm_idx1 :2;
1472
1473    /**
1474     *  only applicable for intra cu and pred_mode=NxN
1475     */
1476    UWORD32 b2_mpm_idx2 :2;
1477
1478    /**
1479     *  only applicable for intra cu and pred_mode=NxN
1480     */
1481    UWORD32 b2_mpm_idx3 :2;
1482
1483    /**
1484     *  only applicable for intra cu
1485     */
1486    UWORD32 b5_rem_intra_pred_mode0 :5;
1487
1488    /**
1489     *  only applicable for intra cu and pred_mode=NxN
1490     */
1491    UWORD32 b5_rem_intra_pred_mode1 :5;
1492
1493    /**
1494     *  only applicable for intra cu and pred_mode=NxN
1495     */
1496    UWORD32 b5_rem_intra_pred_mode2 :5;
1497
1498    /**
1499     *  only applicable for intra cu and pred_mode=NxN
1500     */
1501    UWORD32 b5_rem_intra_pred_mode3 :5;
1502
1503    /**
1504     *  no residue flag for cu
1505     */
1506    UWORD32 b1_no_residual_syntax_flag :1;
1507
1508}cu_t;
1509
1510/*****************************************************************************/
1511/* Since the following data will be accessed linearly (no random access      */
1512/*  is needed for this) there is no need to store a frame level offset for   */
1513/*  each CTB's TU data. Only a pointer to this is stored in CTB's structure  */
1514/*****************************************************************************/
1515
1516typedef struct
1517{
1518    /*************************************************************************/
1519    /* Number of TUs filled in as_tu                                         */
1520    /* Having the first entry as 32 bit data, helps in keeping each of       */
1521    /* the structures aligned to 32 bits at CTB level                        */
1522    /*************************************************************************/
1523    /**
1524     * Number of TUs filled in as_tu
1525     */
1526    WORD32 i4_tu_cnt;
1527
1528    /**
1529     *  Array to map each min TU unit to a corresponding entry in as_tu
1530     */
1531    UWORD8 au1_tu_map[MAX_TU_IN_CTB];
1532
1533    /*************************************************************************/
1534    /* TU level information                                                  */
1535    /* Though the allocation for as_pu as done to handle worst case data,    */
1536    /* only valid number of TUs will be filled in the following array.       */
1537    /* Next CTB starts after the valid as_tu entries                         */
1538    /*************************************************************************/
1539    /**
1540     *  TU level information
1541     */
1542    tu_t as_tu[MAX_TU_IN_CTB];
1543
1544}ctb_tu_list_t;
1545
1546/*****************************************************************************/
1547/* Info from last TU row of CTB is stored in a row level neighbour buffer    */
1548/* , which will be used for Boundary Strength computation                    */
1549/*****************************************************************************/
1550/**
1551 *  CTB neighbor info
1552 */
1553typedef struct
1554{
1555    /**
1556     *  Slice index of the ctb
1557     */
1558    UWORD16 u2_slice_idx;
1559
1560    /*************************************************************************/
1561    /* CBF of bottom TU row (replicated in 4 pixel boundary)                 */
1562    /* MSB contains CBF of first TU in the last row and LSB contains CBF     */
1563    /* of last TU in the last row                                            */
1564    /*************************************************************************/
1565    /**
1566     * CBF of bottom TU row
1567     */
1568    UWORD16 u2_packed_cbf;
1569
1570    /*************************************************************************/
1571    /* QP of bottom TU row (replicated at 8 pixel boundary (Since QP can     */
1572    /* not change at less than min CU granularity)                           */
1573    /*************************************************************************/
1574    /**
1575     * QP of bottom TU row
1576     */
1577    UWORD8 au1_qp[MAX_CU_IN_CTB_ROW];
1578
1579}ctb_top_ny_info_t;
1580
1581/**
1582 *  CTB level info
1583 */
1584typedef struct _ctb_t
1585{
1586    /*************************************************************************/
1587    /* Tile boundary can be detected by looking at tile start x and tile     */
1588    /* start y.  And based on the tile, slice and frame boundary the         */
1589    /* following will be initialized.                                        */
1590    /*************************************************************************/
1591    /**
1592     *  Pointer to left CTB
1593     */
1594    /*  If not available, this will be set to NULL   */
1595    struct _ctb_t *ps_ctb_left;
1596
1597    /**
1598     *  Pointer to top-left CTB
1599     */
1600    /* If not available, this will be set to NULL   */
1601    ctb_top_ny_info_t *ps_ctb_ny_topleft;
1602
1603    /**
1604     *  Pointer to top CTB
1605     */
1606    /* If not available, this will be set to NULL  */
1607    ctb_top_ny_info_t *ps_ctb_ny_top;
1608
1609    /**
1610     *  Pointer to top-right CTB
1611     */
1612    /* If not available, this will be set to NULL */
1613    ctb_top_ny_info_t *ps_ctb_ny_topright;
1614
1615    /*************************************************************************/
1616    /* Pointer to PU data.                                                   */
1617    /* This points to a MV Bank stored at frame level. Though this           */
1618    /* pointer can be derived by reading offset at frame level, it is        */
1619    /* stored here for faster access. Can be removed if storage of CTB       */
1620    /* structure is critical                                                 */
1621    /*************************************************************************/
1622    /**
1623     * Pointer to PU data
1624     */
1625    pu_t *ps_pu;
1626
1627    /*************************************************************************/
1628    /* Pointer to a PU map stored at frame level,                            */
1629    /* Though this pointer can be derived by multiplying CTB adress with     */
1630    /* number of minTUs in a CTB, it is stored here for faster access.       */
1631    /* Can be removed if storage of CTB structure is critical                */
1632    /*************************************************************************/
1633    /**
1634     * Pointer to a PU map stored at frame level
1635     */
1636    UWORD8 *pu1_pu_map;
1637
1638    /**
1639     *  Number of TUs filled in as_tu
1640     */
1641    /*************************************************************************/
1642    /* Having the first entry as 32 bit data, helps in keeping each of       */
1643    /* the structures aligned to 32 bits at CTB level                        */
1644    /*************************************************************************/
1645    WORD32 i4_tu_cnt;
1646
1647    /**
1648     *  Array to map each min TU unit to a corresponding entry in as_tu
1649     */
1650    UWORD8 *pu1_tu_map;
1651
1652    /**
1653     *  TU level information
1654     */
1655    /*************************************************************************/
1656    /* Though the allocation for as_pu as done to handle worst case data,    */
1657    /* only valid number of TUs will be filled in the following array.       */
1658    /* Next CTB starts after the valid as_tu entries                         */
1659    /*************************************************************************/
1660    tu_t *ps_tu;
1661
1662    /**
1663     *  Pointer to transform coeff data
1664     */
1665    /*************************************************************************/
1666    /* Following format is repeated for every coded TU                       */
1667    /* Luma Block                                                            */
1668    /* num_coeffs      : 16 bits                                             */
1669    /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
1670    /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
1671    /* coeff_data      : Non zero coefficients                               */
1672    /* Cb Block (only for last TU in 4x4 case else for every luma TU)        */
1673    /* num_coeffs      : 16 bits                                             */
1674    /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
1675    /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
1676    /* coeff_data      : Non zero coefficients                               */
1677    /* Cr Block (only for last TU in 4x4 case else for every luma TU)        */
1678    /* num_coeffs      : 16 bits                                             */
1679    /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
1680    /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
1681    /* coeff_data      : Non zero coefficients                               */
1682    /*************************************************************************/
1683    void            *pv_coeff_data;
1684
1685    /**
1686     *  Slice to which the CTB belongs to
1687     */
1688    WORD32 i4_slice_idx;
1689
1690    /**
1691     *  CTB column position
1692     */
1693    WORD32 i4_pos_x;
1694
1695    /**
1696     *  CTB row position
1697     */
1698    WORD32 i4_pos_y;
1699
1700    /**
1701     *  Number of PUs filled in ps_pu
1702     */
1703    WORD32 i4_pu_cnt;
1704
1705    /**
1706     *  Index of current PU being processed in ps_pu
1707     */
1708    /*  Scratch variable set to 0 at the start of any PU processing function */
1709    WORD32 i4_pu_idx;
1710
1711    /**
1712     * Vertical Boundary strength
1713     */
1714    /* Two bits per edge.
1715    Stored in format. BS[15] | BS[14] | .. |BS[0]*/
1716    UWORD32 *pu4_vert_bs;
1717
1718    /**
1719     * Horizontal Boundary strength
1720     */
1721
1722    /* Two bits per edge.
1723    Stored in format. BS[15] | BS[14] | .. |BS[0]*/
1724    UWORD32 *pu4_horz_bs;
1725
1726    /**
1727     *  Qp array stored for each 8x8 pixels
1728     */
1729    UWORD8 *pu1_qp;
1730
1731    /**
1732     *  Pointer to current frame's pu_t array
1733     */
1734    pu_t *ps_frm_pu;
1735
1736    /**
1737     * Pointer to current frame's pu_t index array, which stores starting index
1738     * of pu_t for every CTB
1739     */
1740    UWORD32 *pu4_frm_pu_idx;
1741
1742    /**
1743     *  Pointer to current frame's pu map array
1744     */
1745    UWORD8 *pu1_frm_pu_map;
1746
1747    /*************************************************************************/
1748    /* Need to add encoder specific elements for identifying the order of    */
1749    /* coding for CU, TU and PU if any                                       */
1750    /*************************************************************************/
1751}ctb_t;
1752
1753/*****************************************************************************/
1754/* The following can be used to typecast coefficient data that is stored     */
1755/*  per subblock. Note that though i2_level is shown as an array that        */
1756/*  holds 16 coefficients, only the first few entries will be valid. Next    */
1757/*  subblocks data starts after the valid number of coefficients. Number     */
1758/*  of non-zero coefficients will be derived using number of non-zero bits   */
1759/*  in sig coeff map                                                         */
1760/*****************************************************************************/
1761/**
1762 * Structure to hold coefficient info for a 4x4 subblock
1763 */
1764typedef struct
1765{
1766    /**
1767     * sub block position
1768     */
1769    UWORD16 u2_subblk_pos;
1770
1771    /**
1772     * significant coefficient map
1773     */
1774    UWORD16 u2_sig_coeff_map;
1775
1776    /**
1777     * holds 16 coefficients
1778     */
1779    WORD16  ai2_level[SUBBLK_COEFF_CNT];
1780}tu_sblk_coeff_data_t;
1781
1782
1783/*************************************************************************/
1784/* The following describes how each of the CU cases are handled          */
1785/*************************************************************************/
1786
1787/*************************************************************************/
1788/* For SKIP CU                                                           */
1789/* One Inter PU with appropriate MV                                      */
1790/* One TU which says Y, Cb and Cr CBF is zero with size equal to CB size */
1791/*************************************************************************/
1792
1793/*************************************************************************/
1794/* For Inter CU                                                          */
1795/* M Inter PU with appropriate MVs (M between 1 to 4)                    */
1796/* N TU (N is number of TU in CU)                                        */
1797/*************************************************************************/
1798
1799/*************************************************************************/
1800/* For Intra CU                                                          */
1801/* N TU (N is number of TU in CU)                                        */
1802/* N Intra PU with appropriate pred modes for luma and chroma            */
1803/*************************************************************************/
1804
1805/*************************************************************************/
1806/* For Intra PCM CU                                                      */
1807/* One TU which says transquant bypass is 1  with size equal to CB size  */
1808/* 1 Intra PU with pcm flag set to 1(which ensures no intra pred is done)*/
1809/*************************************************************************/
1810
1811/*************************************************************************/
1812/* For a CU where cu_transquant_bypass_flag is 1                         */
1813/* One TU which says transquant bypass is 1  with size equal to CB size  */
1814/* N Intra/Inter PUs                                                     */
1815/*************************************************************************/
1816
1817/*************************************************************************/
1818/* For a CU where no_residual_syntax_flag is 1                           */
1819/* One TU which says Y, Cb, Cr CBF is 0  with size equal to CB size      */
1820/* N Inter PUs                                                           */
1821/*************************************************************************/
1822
1823
1824/**
1825 * Structure giving information about the tile
1826 */
1827typedef struct
1828{
1829    /* X position of the tile in the current frame in CTB units */
1830    UWORD8 u1_pos_x;
1831
1832    /* Y position of the tile in the current frame in CTB units */
1833    UWORD8 u1_pos_y;
1834
1835    /* Tile width in CTB units */
1836    UWORD16 u2_wd;
1837
1838    /* Tile height in CTB units */
1839    UWORD16 u2_ht;
1840
1841}tile_t;
1842
1843/**
1844 * Structure to hold Profile tier level info for a given layer
1845 */
1846
1847typedef struct
1848{
1849    /**
1850     *  NAL unit type
1851     */
1852    WORD8 i1_nal_unit_type;
1853
1854    /**
1855     *  NAL temporal id
1856     */
1857    WORD8 i1_nuh_temporal_id;
1858}nal_header_t;
1859
1860/**
1861 * Structure to hold Profile tier level info for a given layer
1862 */
1863
1864typedef struct
1865{
1866    /**
1867     *  profile_space
1868     */
1869    WORD8 i1_profile_space;
1870
1871    /**
1872     *  tier_flag
1873     */
1874    WORD8 i1_tier_flag;
1875
1876    /**
1877     *  profile_idc
1878     */
1879    WORD8 i1_profile_idc;
1880
1881    /**
1882     *  profile_compatibility_flag[]
1883     */
1884    WORD8 ai1_profile_compatibility_flag[MAX_PROFILE_COMPATBLTY];
1885
1886    /**
1887     * progressive_source_flag
1888     */
1889    WORD8 i1_general_progressive_source_flag;
1890
1891    /**
1892     * interlaced_source_flag
1893     */
1894    WORD8 i1_general_interlaced_source_flag;
1895
1896    /**
1897     * non_packed_constraint_flag
1898     */
1899    WORD8 i1_general_non_packed_constraint_flag;
1900
1901    /**
1902     * frame_only_constraint_flag
1903     */
1904    WORD8 i1_frame_only_constraint_flag;
1905
1906    /**
1907     * general_max_12bit_constraint_flag
1908     */
1909    WORD8 i1_general_max_12bit_constraint_flag;
1910
1911    /**
1912     * general_max_10bit_constraint_flag
1913     */
1914    WORD8 i1_general_max_10bit_constraint_flag;
1915
1916    /**
1917     * general_max_8bit_constraint_flag
1918     */
1919    WORD8 i1_general_max_8bit_constraint_flag;
1920
1921    /**
1922     * general_max_422chroma_constraint_flag
1923     */
1924    WORD8 i1_general_max_422chroma_constraint_flag;
1925
1926    /**
1927     * general_max_420chroma_constraint_flag
1928     */
1929    WORD8 i1_general_max_420chroma_constraint_flag;
1930
1931    /**
1932     * general_max_monochrome_constraint_flag
1933     */
1934    WORD8 i1_general_max_monochrome_constraint_flag;
1935
1936    /**
1937     * general_intra_constraint_flag
1938     */
1939    WORD8 i1_general_intra_constraint_flag;
1940
1941    /**
1942     * general_one_picture_only_constraint_flag
1943     */
1944    WORD8 i1_general_one_picture_only_constraint_flag;
1945
1946    /**
1947     * general_lower_bit_rate_constraint_flag
1948     */
1949    WORD8 i1_general_lower_bit_rate_constraint_flag;
1950
1951    /**
1952     *  level_idc
1953     */
1954    UWORD8 u1_level_idc;
1955}profile_tier_lvl_t;
1956
1957/**
1958 * Structure to hold Profile tier level info for all layers
1959 */
1960typedef struct
1961{
1962    /**
1963     *  Profile and tier information for general
1964     */
1965    profile_tier_lvl_t s_ptl_gen;
1966
1967    /**
1968     *  sub_layer_profile_present_flag[]
1969     */
1970    WORD8 ai1_sub_layer_profile_present_flag[VPS_MAX_SUB_LAYERS - 1];
1971
1972    /**
1973     *  sub_layer_level_present_flag[]
1974     */
1975    WORD8 ai1_sub_layer_level_present_flag[VPS_MAX_SUB_LAYERS - 1];
1976
1977    /**
1978     *  Profile and tier information for sub layers
1979     */
1980    profile_tier_lvl_t as_ptl_sub[VPS_MAX_SUB_LAYERS - 1];
1981
1982}profile_tier_lvl_info_t;
1983
1984/**
1985 * Structure to hold short term reference picture set info
1986 */
1987typedef struct
1988{
1989    /**
1990     *  delta_poc_s0_minus1[ i ] and delta_poc_s1_minus1[ i ]
1991     */
1992    WORD16 ai2_delta_poc[MAX_DPB_SIZE];
1993
1994    /**
1995     *  inter_ref_pic_set_prediction_flag
1996     */
1997    WORD8 i1_inter_ref_pic_set_prediction_flag;
1998
1999    /**
2000     *  num_negative_pics
2001     */
2002    WORD8 i1_num_neg_pics;
2003
2004    /**
2005     *  num_positive_pics
2006     */
2007    WORD8 i1_num_pos_pics;
2008
2009    /**
2010     *  used_by_curr_pic_s0_flag[ i ] and used_by_curr_pic_s1_flag[i]
2011     */
2012    WORD8 ai1_used[MAX_DPB_SIZE];
2013
2014    /**
2015     *  Ref Idc
2016     */
2017    WORD8 ai1_ref_idc[MAX_DPB_SIZE];
2018
2019    /**
2020     *  Sum of positive and negative pics for each refence
2021     */
2022    WORD8 i1_num_delta_pocs;
2023
2024    /**
2025     *  Number of ref_idc
2026     */
2027    WORD8 i1_num_ref_idc;
2028}stref_picset_t;
2029
2030/**
2031 * Structure to hold weighted prediction info such as weights and offsets
2032 */
2033typedef struct
2034{
2035    /** luma_log2_weight_denom */
2036    WORD8 i1_luma_log2_weight_denom;
2037
2038    /** delta_chroma_log2_weight_denom */
2039    WORD8 i1_chroma_log2_weight_denom;
2040
2041
2042    /** luma_weight_l0_flag[ i ] */
2043    WORD8 i1_luma_weight_l0_flag[MAX_DPB_SIZE];
2044
2045    /** chroma_weight_l0_flag[ i ] */
2046    WORD8 i1_chroma_weight_l0_flag[MAX_DPB_SIZE];
2047
2048    /** delta_luma_weight_l0[ i ] */
2049    WORD16 i2_luma_weight_l0[MAX_DPB_SIZE];
2050
2051    /** luma_offset_l0[ i ] */
2052    WORD16 i2_luma_offset_l0[MAX_DPB_SIZE];
2053
2054    /** delta_chroma_weight_l0[ i ][ j ] */
2055    WORD16 i2_chroma_weight_l0_cb[MAX_DPB_SIZE];
2056
2057    /** delta_chroma_offset_l0[ i ][ j ] */
2058    WORD16 i2_chroma_offset_l0_cb[MAX_DPB_SIZE];
2059
2060    /** delta_chroma_weight_l0[ i ][ j ] */
2061    WORD16 i2_chroma_weight_l0_cr[MAX_DPB_SIZE];
2062
2063    /** delta_chroma_offset_l0[ i ][ j ] */
2064    WORD16 i2_chroma_offset_l0_cr[MAX_DPB_SIZE];
2065
2066    /** luma_weight_l1_flag[ i ] */
2067    WORD8 i1_luma_weight_l1_flag[MAX_DPB_SIZE];
2068
2069    /** chroma_weight_l1_flag[ i ] */
2070    WORD8 i1_chroma_weight_l1_flag[MAX_DPB_SIZE];
2071
2072    /** delta_luma_weight_l1[ i ] */
2073    WORD16 i2_luma_weight_l1[MAX_DPB_SIZE];
2074
2075    /** luma_offset_l1[ i ] */
2076    WORD16 i2_luma_offset_l1[MAX_DPB_SIZE];
2077
2078    /** delta_chroma_weight_l1[ i ][ j ] */
2079    WORD16 i2_chroma_weight_l1_cb[MAX_DPB_SIZE];
2080
2081    /** delta_chroma_offset_l1[ i ][ j ] */
2082    WORD16 i2_chroma_offset_l1_cb[MAX_DPB_SIZE];
2083
2084    /** delta_chroma_weight_l1[ i ][ j ] */
2085    WORD16 i2_chroma_weight_l1_cr[MAX_DPB_SIZE];
2086
2087    /** delta_chroma_offset_l1[ i ][ j ] */
2088    WORD16 i2_chroma_offset_l1_cr[MAX_DPB_SIZE];
2089
2090}pred_wt_ofst_t;
2091
2092
2093/**
2094 * Structure to hold Reference picture list modification info
2095 */
2096typedef struct
2097{
2098    /* ref_pic_list_modification_flag_l0 */
2099    WORD8 i1_ref_pic_list_modification_flag_l0;
2100
2101    /* list_entry_l0[ i ] */
2102    WORD8 i1_list_entry_l0[16];
2103
2104    /* ref_pic_list_modification_flag_l1 */
2105    WORD8 i1_ref_pic_list_modification_flag_l1;
2106
2107    /* list_entry_l1[ i ] */
2108    WORD8 i1_list_entry_l1[16];
2109
2110    /* Reference POC values for L0,L1 */
2111    WORD32 i4_ref_poc_l0[16];
2112    WORD32 i4_ref_poc_l1[16];
2113}rplm_t;
2114
2115
2116/**
2117 * Structure to hold VPS info
2118 */
2119typedef struct
2120{
2121    /**
2122     *  video_parameter_set_id
2123     */
2124    WORD8 i1_vps_id;
2125
2126    /**
2127     *  vps_temporal_id_nesting_flag
2128     */
2129    WORD8 i1_vps_temporal_id_nesting_flag;
2130    /**
2131     * sub_layer_ordering_info_present_flag
2132     */
2133    WORD8 i1_sub_layer_ordering_info_present_flag;
2134    /**
2135     *  vps_max_sub_layers_minus1
2136     */
2137    WORD8 i1_vps_max_sub_layers;
2138
2139    /**
2140     *  vps_max_dec_pic_buffering
2141     */
2142    WORD8 ai1_vps_max_dec_pic_buffering[VPS_MAX_SUB_LAYERS];
2143
2144    /**
2145     *  vps_max_num_reorder_pics
2146     */
2147    WORD8 ai1_vps_max_num_reorder_pics[VPS_MAX_SUB_LAYERS];
2148
2149    /**
2150     *  vps_max_latency_increase
2151     */
2152    WORD8 ai1_vps_max_latency_increase[VPS_MAX_SUB_LAYERS];
2153
2154    /**
2155     *  vps_num_hrd_parameters
2156     */
2157    WORD8 i1_vps_num_hrd_parameters;
2158
2159    /**
2160     * vps_max_nuh_reserved_zero_layer_id
2161     */
2162    WORD8 i1_vps_max_nuh_reserved_zero_layer_id;
2163
2164    /**
2165     * vps_num_op_sets
2166     */
2167    WORD8 i1_vps_num_op_sets;
2168
2169    /**
2170     * layer_id_included_flag
2171     */
2172    //WORD8 ai1_layer_id_included_flag[2][MAX_NUH_LAYERS];
2173    /**
2174     *  Profile, Tier and Level info
2175     */
2176    profile_tier_lvl_info_t s_ptl;
2177
2178    /**
2179     * bit_rate_info_present_flag[i]
2180     */
2181    WORD8 ai1_bit_rate_info_present_flag[VPS_MAX_SUB_LAYERS];
2182
2183    /**
2184     * pic_rate_info_present_flag[i]
2185     */
2186    WORD8 ai1_pic_rate_info_present_flag[VPS_MAX_SUB_LAYERS];
2187
2188    /**
2189     * avg_bit_rate[i]
2190     */
2191    UWORD16 au2_avg_bit_rate[VPS_MAX_SUB_LAYERS];
2192
2193    /**
2194     * max_bit_rate[i]
2195     */
2196    UWORD16 au2_max_bit_rate[VPS_MAX_SUB_LAYERS];
2197
2198    /**
2199     * constant_pic_rate_idc[i]
2200     */
2201    WORD8 ai1_constant_pic_rate_idc[VPS_MAX_SUB_LAYERS];
2202
2203    /**
2204     * avg_pic_rate[i]
2205     */
2206    UWORD16 au2_avg_pic_rate[VPS_MAX_SUB_LAYERS];
2207}vps_t;
2208
2209
2210/**
2211 * Structure to hold SPS info
2212 */
2213typedef struct
2214{
2215    /**
2216     * pic_width_in_luma_samples
2217     */
2218    WORD16 i2_pic_width_in_luma_samples;
2219
2220    /**
2221     *  pic_height_in_luma_samples
2222     */
2223    WORD16 i2_pic_height_in_luma_samples;
2224
2225    /**
2226     *  pic_crop_left_offset
2227     */
2228    WORD16 i2_pic_crop_left_offset;
2229
2230    /**
2231     *  pic_crop_right_offset
2232     */
2233    WORD16 i2_pic_crop_right_offset;
2234
2235    /**
2236     *  pic_crop_top_offset
2237     */
2238    WORD16 i2_pic_crop_top_offset;
2239
2240    /**
2241     *  pic_crop_bottom_offset
2242     */
2243    WORD16 i2_pic_crop_bottom_offset;
2244
2245    /**
2246     *  seq_parameter_set_id
2247     */
2248    WORD8 i1_sps_id;
2249
2250    /**
2251     *  video_parameter_set_id
2252     */
2253    WORD8 i1_vps_id;
2254
2255    /**
2256     *  sps_max_sub_layers_minus1
2257     */
2258    WORD8 i1_sps_max_sub_layers;
2259
2260    /**
2261     *  chroma_format_idc
2262     */
2263    WORD8 i1_chroma_format_idc;
2264
2265    /**
2266     * Bit depth of luma samples
2267     */
2268    WORD8 i1_bit_depth_luma_minus8;
2269
2270    /**
2271     * Bit depth of chrma samples
2272     */
2273    WORD8 i1_bit_depth_chroma_minus8;
2274
2275    /* separate_colour_plane_flag */
2276    WORD8 i1_separate_colour_plane_flag;
2277
2278    /**
2279     *  pic_cropping_flag
2280     */
2281    WORD8 i1_pic_cropping_flag;
2282
2283    /**
2284     *  pcm_enabled_flag
2285     */
2286    WORD8 i1_pcm_enabled_flag;
2287
2288    /**
2289     *  pcm_sample_bit_depth_luma
2290     */
2291    WORD8 i1_pcm_sample_bit_depth_luma;
2292
2293    /**
2294     *  pcm_sample_bit_depth_chroma
2295     */
2296    WORD8 i1_pcm_sample_bit_depth_chroma;
2297
2298    /**
2299     *  log2_max_pic_order_cnt_lsb_minus4
2300     */
2301    WORD8 i1_log2_max_pic_order_cnt_lsb;
2302    /**
2303     * sps_sub_layer_ordering_info_present_flag
2304     */
2305    WORD8 i1_sps_sub_layer_ordering_info_present_flag;
2306    /**
2307     *  sps_max_dec_pic_buffering
2308     */
2309    WORD8 ai1_sps_max_dec_pic_buffering[SPS_MAX_SUB_LAYERS];
2310
2311    /**
2312     *  sps_max_num_reorder_pics
2313     */
2314    WORD8 ai1_sps_max_num_reorder_pics[SPS_MAX_SUB_LAYERS];
2315
2316    /**
2317     *  sps_max_latency_increase
2318     */
2319    WORD8 ai1_sps_max_latency_increase[SPS_MAX_SUB_LAYERS];
2320
2321    /**
2322     *  log2_min_coding_block_size_minus3
2323     */
2324    WORD8 i1_log2_min_coding_block_size;
2325
2326    /**
2327     *  log2_diff_max_min_coding_block_size
2328     */
2329    WORD8 i1_log2_diff_max_min_coding_block_size;
2330
2331    /**
2332     *  log2_min_transform_block_size_minus2
2333     */
2334    WORD8 i1_log2_min_transform_block_size;
2335
2336    /**
2337     *  log2_diff_max_min_transform_block_size
2338     */
2339    WORD8 i1_log2_diff_max_min_transform_block_size;
2340
2341    /**
2342     *  log2_min_pcm_coding_block_size_minus3
2343     */
2344    WORD8 i1_log2_min_pcm_coding_block_size;
2345
2346    /**
2347     *  log2_diff_max_min_pcm_coding_block_size
2348     */
2349    WORD8 i1_log2_diff_max_min_pcm_coding_block_size;
2350
2351    /**
2352     *  max_transform_hierarchy_depth_inter
2353     */
2354    WORD8 i1_max_transform_hierarchy_depth_inter;
2355
2356    /**
2357     *  max_transform_hierarchy_depth_intra
2358     */
2359    WORD8 i1_max_transform_hierarchy_depth_intra;
2360
2361    /**
2362     *  scaling_list_enable_flag
2363     */
2364    WORD8 i1_scaling_list_enable_flag;
2365
2366    /**
2367     *  sps_scaling_list_data_present_flag
2368     */
2369    WORD8 i1_sps_scaling_list_data_present_flag;
2370
2371    /**
2372     *  amp_enabled_flag
2373     */
2374    WORD8 i1_amp_enabled_flag;
2375
2376    /**
2377     *  sample_adaptive_offset_enabled_flag
2378     */
2379    WORD8 i1_sample_adaptive_offset_enabled_flag;
2380
2381    /**
2382     *  pcm_loop_filter_disable_flag
2383     */
2384    WORD8 i1_pcm_loop_filter_disable_flag;
2385
2386    /**
2387     *  sps_temporal_id_nesting_flag
2388     */
2389    WORD8 i1_sps_temporal_id_nesting_flag;
2390
2391    /**
2392     *  num_short_term_ref_pic_sets
2393     */
2394    WORD8 i1_num_short_term_ref_pic_sets;
2395
2396    /**
2397     *  long_term_ref_pics_present_flag
2398     */
2399    WORD8 i1_long_term_ref_pics_present_flag;
2400
2401    /**
2402     *  num_long_term_ref_pics_sps
2403     */
2404    WORD8 i1_num_long_term_ref_pics_sps;
2405
2406    /**
2407     *  lt_ref_pic_poc_lsb_sps[]
2408     */
2409    UWORD16 au2_lt_ref_pic_poc_lsb_sps[MAX_LTREF_PICS_SPS];
2410
2411    /**
2412     *  used_by_curr_pic_lt_sps_flag[]
2413     */
2414    WORD8 ai1_used_by_curr_pic_lt_sps_flag[MAX_LTREF_PICS_SPS];
2415
2416    /**
2417     *  sps_temporal_mvp_enable_flag
2418     */
2419    WORD8 i1_sps_temporal_mvp_enable_flag;
2420
2421    /**
2422     * strong_intra_smoothing_enable_flag
2423     */
2424    WORD8 i1_strong_intra_smoothing_enable_flag;
2425
2426    /**
2427     *  vui_parameters_present_flag
2428     */
2429    WORD8 i1_vui_parameters_present_flag;
2430
2431    /**
2432     * vui parameters Structure info
2433     */
2434    vui_t s_vui_parameters;
2435
2436    /**
2437     *  Log2(CTB Size) in luma units
2438     */
2439
2440    WORD8 i1_log2_ctb_size;
2441
2442    /**
2443     * Maximum transform block size
2444     */
2445    WORD8 i1_log2_max_transform_block_size;
2446
2447    /**
2448     *  Picture width in CTB units
2449     */
2450
2451    WORD16 i2_pic_wd_in_ctb;
2452
2453    /**
2454     *  Picture height in CTB units
2455     */
2456
2457    WORD16 i2_pic_ht_in_ctb;
2458
2459    /**
2460     * Picture width in min CB units
2461     */
2462
2463    WORD16 i2_pic_wd_in_min_cb;
2464
2465    /**
2466     *  Picture height in min CB units
2467     */
2468
2469    WORD16 i2_pic_ht_in_min_cb;
2470
2471    /**
2472     *  Picture size in CTB units
2473     */
2474    WORD32 i4_pic_size_in_ctb;
2475
2476    /**
2477     *  Profile, Tier and Level info
2478     */
2479
2480    profile_tier_lvl_info_t s_ptl;
2481
2482    /**
2483     *  Short term reference pic set
2484     */
2485    stref_picset_t as_stref_picset[MAX_STREF_PICS_SPS];
2486
2487    /**
2488     *  Pointer to scaling matrix
2489     */
2490    /*************************************************************************/
2491    /* Contanis the matrice in the following order in a 1D buffer            */
2492    /* Intra 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
2493    /* Inter 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
2494    /* Intra 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
2495    /* Inter 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
2496    /* Intra 16x16 Y, 16x16 U, 16x16 V                                       */
2497    /* Inter 16x16 Y, 16x16 U, 16x16 V                                       */
2498    /* Intra 32x32 Y                                                         */
2499    /* Inter 32x32 Y                                                         */
2500    /*************************************************************************/
2501    WORD16 *pi2_scaling_mat;
2502
2503
2504    /*
2505     * Flag indicating if the SPS is parsed
2506     */
2507    WORD8 i1_sps_valid;
2508
2509}sps_t;
2510
2511/**
2512 * Structure to hold PPS info
2513 */
2514typedef struct
2515{
2516    /**
2517     *  Pointer to scaling matrix
2518     */
2519    /*************************************************************************/
2520    /* Contanis the matrice in the following order in a 1D buffer            */
2521    /* Intra 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
2522    /* Inter 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
2523    /* Intra 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
2524    /* Inter 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
2525    /* Intra 16x16 Y, 16x16 U, 16x16 V                                       */
2526    /* Inter 16x16 Y, 16x16 U, 16x16 V                                       */
2527    /* Intra 32x32 Y                                                         */
2528    /* Inter 32x32 Y                                                         */
2529    /*************************************************************************/
2530    WORD16 *pi2_scaling_mat;
2531
2532    /**
2533     *  Pointer to an array containing tile info such as position, width, height
2534     *  of each tile
2535     */
2536
2537    /* column_width_minus1[ i ] and row_height_minus1[ i ] */
2538    tile_t *ps_tile;
2539
2540    /**
2541     *  pic_parameter_set_id
2542     */
2543    WORD8 i1_pps_id;
2544
2545    /**
2546     *  seq_parameter_set_id
2547     */
2548    WORD8 i1_sps_id;
2549
2550    /**
2551     *  sign_data_hiding_flag
2552     */
2553    WORD8 i1_sign_data_hiding_flag;
2554
2555    /**
2556     *  cabac_init_present_flag
2557     */
2558    WORD8 i1_cabac_init_present_flag;
2559
2560    /**
2561     *  num_ref_idx_l0_default_active_minus1
2562     */
2563    WORD8 i1_num_ref_idx_l0_default_active;
2564
2565    /**
2566     * num_ref_idx_l1_default_active_minus1
2567     */
2568    WORD8 i1_num_ref_idx_l1_default_active;
2569
2570    /**
2571     *  pic_init_qp_minus26
2572     */
2573    WORD8 i1_pic_init_qp;
2574
2575    /**
2576     *  constrained_intra_pred_flag
2577     */
2578    WORD8 i1_constrained_intra_pred_flag;
2579
2580    /**
2581     *  transform_skip_enabled_flag
2582     */
2583    WORD8 i1_transform_skip_enabled_flag;
2584
2585    /**
2586     *  cu_qp_delta_enabled_flag
2587     */
2588    WORD8 i1_cu_qp_delta_enabled_flag;
2589
2590    /**
2591     * diff_cu_qp_delta_depth
2592     */
2593    WORD8 i1_diff_cu_qp_delta_depth;
2594
2595    /**
2596     *  pic_cb_qp_offset
2597     */
2598    WORD8 i1_pic_cb_qp_offset;
2599
2600    /**
2601     *  pic_cr_qp_offset
2602     */
2603    WORD8 i1_pic_cr_qp_offset;
2604
2605    /**
2606     *  pic_slice_level_chroma_qp_offsets_present_flag
2607     */
2608    WORD8 i1_pic_slice_level_chroma_qp_offsets_present_flag;
2609
2610    /**
2611     *  weighted_pred_flag
2612     */
2613    WORD8 i1_weighted_pred_flag;
2614
2615    /**
2616     *  weighted_bipred_flag
2617     */
2618    WORD8 i1_weighted_bipred_flag;
2619
2620    /**
2621     *  output_flag_present_flag
2622     */
2623    WORD8 i1_output_flag_present_flag;
2624
2625    /**
2626     *  transquant_bypass_enable_flag
2627     */
2628    WORD8 i1_transquant_bypass_enable_flag;
2629
2630    /**
2631     *  dependent_slice_enabled_flag
2632     */
2633    WORD8 i1_dependent_slice_enabled_flag;
2634
2635    /**
2636     *  tiles_enabled_flag
2637     */
2638    WORD8 i1_tiles_enabled_flag;
2639
2640    /**
2641     *  entropy_coding_sync_enabled_flag
2642     */
2643    WORD8 i1_entropy_coding_sync_enabled_flag;
2644
2645    /**
2646     * entropy_slice_enabled_flag
2647     */
2648    WORD8 i1_entropy_slice_enabled_flag;
2649
2650    /**
2651     *  num_tile_columns_minus1
2652     */
2653    WORD8 i1_num_tile_columns;
2654
2655    /**
2656     *  num_tile_rows_minus1
2657     */
2658    WORD8 i1_num_tile_rows;
2659
2660    /**
2661     *  uniform_spacing_flag
2662     */
2663    WORD8 i1_uniform_spacing_flag;
2664
2665    /**
2666     *  loop_filter_across_tiles_enabled_flag
2667     */
2668    WORD8 i1_loop_filter_across_tiles_enabled_flag;
2669
2670    /**
2671     *  loop_filter_across_slices_enabled_flag
2672     */
2673    WORD8 i1_loop_filter_across_slices_enabled_flag;
2674
2675    /**
2676     *  deblocking_filter_control_present_flag
2677     */
2678    WORD8 i1_deblocking_filter_control_present_flag;
2679
2680    /**
2681     *  deblocking_filter_override_enabled_flag
2682     */
2683    WORD8 i1_deblocking_filter_override_enabled_flag;
2684
2685    /**
2686     *  pic_disable_deblocking_filter_flag
2687     */
2688    WORD8 i1_pic_disable_deblocking_filter_flag;
2689
2690    /**
2691     *  beta_offset_div2
2692     */
2693    WORD8 i1_beta_offset_div2;
2694
2695    /**
2696     *  tc_offset_div2
2697     */
2698    WORD8 i1_tc_offset_div2;
2699
2700    /**
2701     *  pps_scaling_list_data_present_flag
2702     */
2703    WORD8 i1_pps_scaling_list_data_present_flag;
2704
2705    /**
2706     * lists_modification_present_flag
2707     */
2708    WORD8 i1_lists_modification_present_flag;
2709
2710    /**
2711     * num_extra_slice_header_bits
2712     */
2713    WORD8 i1_num_extra_slice_header_bits;
2714
2715    /**
2716     *  log2_parallel_merge_level_minus2
2717     */
2718    WORD8 i1_log2_parallel_merge_level;
2719
2720    /**
2721     *  slice_header_extension_present_flag
2722     */
2723    WORD8 i1_slice_header_extension_present_flag;
2724
2725    /**
2726     *  slice_extension_present_flag
2727     */
2728    WORD8 i1_slice_extension_present_flag;
2729
2730    /**
2731     *  scaling_list_dc_coef_minus8
2732     */
2733    /*************************************************************************/
2734    /* DC value of the scaling list                                          */
2735    /* Only 16 x 16 and 32 x 32 scaling lists have valid entries.            */
2736    /* Entries stored for all sizes for uniformity.                          */
2737    /* Remaining will be initialized to default values if used               */
2738    /*************************************************************************/
2739    UWORD8 au1_scaling_list_dc_coef[TOTAL_SCALE_MAT_COUNT];
2740
2741    /**
2742     * Log2MinCuQpDeltaSize
2743     */
2744    WORD8 i1_log2_min_cu_qp_delta_size;
2745
2746
2747    /*
2748     * Flag indicating if the PPS is parsed
2749     */
2750    WORD8 i1_pps_valid;
2751
2752}pps_t;
2753
2754
2755/**
2756 * Structure to hold slice header info
2757 */
2758typedef struct
2759{
2760    /**
2761     *  entry_point_offset[ i ]
2762     */
2763    WORD32 *pi4_entry_point_offset;
2764
2765    /**
2766     *  poc_lsb_lt[ i ]
2767     */
2768    WORD32 ai4_poc_lsb_lt[MAX_DPB_SIZE];
2769
2770    /**
2771     *  slice_header_extension_length
2772     */
2773    WORD16 i2_slice_header_extension_length;
2774
2775    /**
2776     *  slice_address
2777     */
2778    WORD16 i2_slice_address;
2779
2780    /**
2781     *  first_slice_in_pic_flag
2782     */
2783    WORD8 i1_first_slice_in_pic_flag;
2784
2785    /* PPS id */
2786    WORD8 i1_pps_id;
2787    /**
2788     *  no_output_of_prior_pics_flag
2789     */
2790    WORD8 i1_no_output_of_prior_pics_flag;
2791
2792    /**
2793     *  dependent_slice_flag
2794     */
2795    WORD8 i1_dependent_slice_flag;
2796
2797    /**
2798     *  slice_type
2799     */
2800    WORD8 i1_slice_type;
2801
2802    /**
2803     *  pic_output_flag
2804     */
2805    WORD8 i1_pic_output_flag;
2806
2807    /**
2808     *  colour_plane_id
2809     */
2810    WORD8 i1_colour_plane_id;
2811
2812    /**
2813     *  pic_order_cnt_lsb
2814     */
2815    WORD32 i4_pic_order_cnt_lsb;
2816
2817    /**
2818     *  absolute pic_order_cnt
2819     */
2820    WORD32 i4_abs_pic_order_cnt;
2821
2822    /**
2823     *  short_term_ref_pic_set_sps_flag
2824     */
2825    WORD8 i1_short_term_ref_pic_set_sps_flag;
2826
2827    /**
2828     *  short_term_ref_pic_set_idx
2829     */
2830    WORD8 i1_short_term_ref_pic_set_idx;
2831
2832    /**
2833     *  num_long_term_sps
2834     */
2835    WORD8 i1_num_long_term_sps;
2836
2837    /**
2838     *  num_long_term_pics
2839     */
2840    WORD8 i1_num_long_term_pics;
2841
2842    /**
2843     *  lt_idx_sps[ i ]
2844     */
2845    WORD8 ai1_lt_idx_sps[MAX_DPB_SIZE];
2846
2847    /**
2848     *  used_by_curr_pic_lt_flag[ i ]
2849     */
2850    WORD8 ai1_used_by_curr_pic_lt_flag[MAX_DPB_SIZE];
2851
2852    /**
2853     *  delta_poc_msb_present_flag[ i ]
2854     */
2855    WORD8 ai1_delta_poc_msb_present_flag[MAX_DPB_SIZE];
2856
2857    /**
2858     *  delta_poc_msb_cycle_lt[ i ]
2859     */
2860    WORD8 ai1_delta_poc_msb_cycle_lt[MAX_DPB_SIZE];
2861
2862    /**
2863     *  slice_sao_luma_flag
2864     */
2865    WORD8 i1_slice_sao_luma_flag;
2866
2867    /**
2868     *  slice_sao_chroma_flag
2869     */
2870    WORD8 i1_slice_sao_chroma_flag;
2871
2872    /**
2873     *  slice_temporal_mvp_enable_flag
2874     */
2875    WORD8 i1_slice_temporal_mvp_enable_flag;
2876
2877    /**
2878     *  num_ref_idx_active_override_flag
2879     */
2880    WORD8 i1_num_ref_idx_active_override_flag;
2881
2882    /**
2883     *  num_ref_idx_l0_active_minus1
2884     */
2885    WORD8 i1_num_ref_idx_l0_active;
2886
2887    /**
2888     *  num_ref_idx_l1_active_minus1
2889     */
2890    WORD8 i1_num_ref_idx_l1_active;
2891
2892    /**
2893     *  mvd_l1_zero_flag
2894     */
2895    WORD8 i1_mvd_l1_zero_flag;
2896
2897    /**
2898     *  cabac_init_flag
2899     */
2900    WORD8 i1_cabac_init_flag;
2901
2902    /**
2903     *  collocated_from_l0_flag
2904     */
2905    WORD8 i1_collocated_from_l0_flag;
2906
2907    /**
2908     *  collocated_ref_idx
2909     */
2910    WORD8 i1_collocated_ref_idx;
2911
2912    /**
2913     * five_minus_max_num_merge_cand
2914     */
2915    WORD8 i1_max_num_merge_cand;
2916
2917    /**
2918     *  slice_qp_delta
2919     */
2920    WORD8 i1_slice_qp_delta;
2921
2922    /**
2923     *  slice_cb_qp_offset
2924     */
2925    WORD8 i1_slice_cb_qp_offset;
2926
2927    /**
2928     *  slice_cr_qp_offset
2929     */
2930    WORD8 i1_slice_cr_qp_offset;
2931
2932    /**
2933     *  deblocking_filter_override_flag
2934     */
2935    WORD8 i1_deblocking_filter_override_flag;
2936
2937    /**
2938     *  slice_disable_deblocking_filter_flag
2939     */
2940    WORD8 i1_slice_disable_deblocking_filter_flag;
2941
2942    /**
2943     *  beta_offset_div2
2944     */
2945    WORD8 i1_beta_offset_div2;
2946
2947    /**
2948     *  tc_offset_div2
2949     */
2950    WORD8 i1_tc_offset_div2;
2951
2952    /**
2953     *  slice_loop_filter_across_slices_enabled_flag
2954     */
2955    WORD8 i1_slice_loop_filter_across_slices_enabled_flag;
2956
2957    /**
2958     *  NUmber of entry point offsets
2959     */
2960    WORD32 i4_num_entry_point_offsets;
2961
2962    /**
2963     *  offset_len_minus1
2964     */
2965    WORD8 i1_offset_len;
2966
2967    /**
2968     *  Entry point offsets
2969     */
2970    WORD32 *pu4_entry_point_offset;
2971
2972    /**
2973     * Short term reference picture set
2974     */
2975    stref_picset_t s_stref_picset;
2976
2977    /**
2978     *  Weight and offset info for Weighted prediction
2979     */
2980    pred_wt_ofst_t s_wt_ofst;
2981
2982    /**
2983     *  Reference prediction list modification
2984     */
2985    rplm_t s_rplm;
2986
2987    /**
2988     *  First CTB' X pos : slice_address % i2_pic_wd_in_ctb
2989     */
2990    WORD16 i2_ctb_x;
2991
2992    /**
2993     *  First CTB' Y pos : slice_address / i2_pic_wd_in_ctb
2994     */
2995    WORD16 i2_ctb_y;
2996
2997    /**
2998     * L0 Reference pic lists
2999     */
3000    ref_list_t as_ref_pic_list0[MAX_DPB_SIZE];
3001
3002    /**
3003     * L1 Reference pic lists
3004     */
3005    ref_list_t as_ref_pic_list1[MAX_DPB_SIZE];
3006
3007    /**
3008     * NAL unit type of the slice
3009     */
3010    WORD8 i1_nal_unit_type;
3011
3012    /**
3013     * Low delay check flag
3014     */
3015    WORD8 i1_low_delay_flag;
3016
3017    /**
3018     * The last independent slice's start ctb_x
3019     * If the current slice is independent, it is the same as the current CTBs ctb_x
3020     */
3021    WORD16 i2_independent_ctb_x;
3022
3023    /**
3024     * The last independent slice's start ctb_y
3025     * If the current slice is independent, it is the same as the current CTBs ctb_y
3026     */
3027    WORD16 i2_independent_ctb_y;
3028
3029
3030    UWORD8 u1_parse_data_init_done;
3031
3032    /**
3033     * Temporal ID in NAL header
3034     */
3035    WORD32 u4_nuh_temporal_id;
3036}slice_header_t;
3037
3038
3039
3040
3041
3042
3043
3044
3045#endif /* _IHEVC_STRUCTS_H_ */
3046