aboutsummaryrefslogtreecommitdiff
path: root/decoder/svc/isvcd_structs.h
blob: 85f1295490ad59e67a0818573e10498e27ac3060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/******************************************************************************
 *
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
 */
/**
 *******************************************************************************
 * @file
 *  isvcd_structs.h
 *
 * @brief
 *  Contains structures required for decoder
 *
 * @author
 *  Kishore
 *
 * @remarks
 *  None
 *
 *******************************************************************************
 */

#ifndef _ISVCD_STRUCTS_H_
#define _ISVCD_STRUCTS_H_

#include "isvcd_defs.h"
#include "isvcd_cabac.h"
#include "ih264d_structs.h"
#include "isvcd_iquant_itrans_residual_recon.h"
#include "isvcd_iquant_itrans_residual.h"
#include "isvcd_iquant_itrans.h"
#include "isvcd_pred_residual_recon.h"

#include "isvcd_nal.h"
#include "isvcd_nal_structs.h"
#include "isvcd_nal_parse.h"
#include "isvcd_nal_parse_structs.h"

#include "isvcd_intra_resamp.h"
#include "isvcd_ii_pred.h"
#include "isvcd_residual_resamp.h"

#include "isvcd_vui.h"

#define NUM_MB_PARTS 4
#define NUM_SUB_MB_PARTS 4
#define NUM_INTRA_SUB_BLOCKS 16
#define MAX_NUM_MB_PART NUM_MB_PARTS *NUM_SUB_MB_PARTS

#define ANNEX_B 0     /*!< Annex B stream*/
#define NON_ANNEX_B 1 /*!< Non Annex B RFC stream */

#define BUFFER_ALIGN_4 4

#define MAX_VCL_NAL_BUFF_SIZE (1024 * 1024 * 2)
#define MAX_NON_VCL_NAL_BUFF_SIZE (1024 * 1024)
#define MAX_SCLD_REF_LAYER_OFFSET 32768
#define MIN_SCLD_REF_LAYER_OFFSET -32768
#define MAX_SVC_NAL_UNIT_TYPE 31
/*! Nal unit svc extennsion parameters */

struct _SvcDecLyrStruct;

typedef struct
{
    UWORD8 u1_nal_ref_idc;              /** NAL ref idc of the Slice NAL unit */
    UWORD8 u1_svc_ext_flag;             /** svc nal extension */
    UWORD8 u1_idr_flag;                 /** IDR picture when dependency_id = maximum value of
                                           dependency_id */
    UWORD8 u1_priority_id;              /** priority identifier for the NAL unit */
    UWORD8 u1_no_inter_layer_pred_flag; /** Usage of the inter-layer prediction */
    UWORD8 u1_dependency_id;            /** dependency identifier for the NAL unit */
    UWORD8 u1_quality_id;               /** quality identifier for the NAL unit */
    UWORD8 u1_temporal_id;              /** temporal identifier for the NAL unit */
    UWORD8 u1_use_ref_base_pic_flag;    /** specifies reference pictures for inter
                                           prediction */
    UWORD8 u1_discardable_flag;         /** current NAL unit is not used in dependant
                                           decoding */
    UWORD8 u1_output_flag;              /** decoded picture output and removal process */

} dec_nal_unit_svc_ext_params_t;

/* Structure to contain information about reference base pic marking */
typedef struct
{
    UWORD8 u1_adaptive_ref_base_pic_marking_mode_flag;
    UWORD32 u4_memory_management_base_control_operation;
    UWORD32 u4_difference_of_base_pic_nums_minus1;
    UWORD32 u4_long_term_base_pic_num;

} dec_ref_base_pic_marking_params_t;

/*! Sequence level parameters svc extension */

typedef struct
{
    /** Presence of deblocking filter for inter-layer prediction in the slice
     * header */
    UWORD8 u1_inter_layer_deblocking_filter_control_present_flag;
    UWORD8 u1_extended_spatial_scalability_idc; /** Geometrical parameters for the
                                                   resampling processes */
    /** horizontal phase shift of the chroma components in units of half luma
     * samples*/
    UWORD8 u1_chroma_phase_x_plus1_flag;
    /** vertical phase shift of the chroma components in units of half luma
     * samples */
    UWORD8 u1_chroma_phase_y_plus1;
    /* horizontal phase shift of chroma in units of half luma samples used for
     * inter-layer prediction */
    UWORD8 u1_seq_ref_layer_chroma_phase_x_plus1_flag;
    /* vertical phase shift of chroma in units of half luma samples used for
     * inter-layer prediction */
    UWORD8 u1_seq_ref_layer_chroma_phase_y_plus1;
    WORD32 i4_seq_scaled_ref_layer_left_offset;      /** horizontal left offset */
    WORD32 i4_seq_scaled_ref_layer_top_offset;       /** vertical top offset */
    WORD32 i4_seq_scaled_ref_layer_right_offset;     /**horizontal right offset */
    WORD32 i4_seq_scaled_ref_layer_bottom_offset;    /** vertical bottom offset */
    UWORD8 u1_seq_tcoeff_level_prediction_flag;      /** presence of the syntax element
                                                        adaptive_tcoeff_level_prediction_flag
                                                      */
    UWORD8 u1_adaptive_tcoeff_level_prediction_flag; /** presence of
                                                        tcoeff_level_prediction_flag
                                                      */
    /**  specifies presence of syntax elements in slice headers that refer to the
     * subset sequence parameter set */
    UWORD8 u1_slice_header_restriction_flag;
    UWORD8 u1_svc_vui_parameters_present_flag;
    svc_vui_ext_t *ps_svc_vui_ext;
} dec_subset_seq_params_t;

typedef struct
{
    WORD32 i4_left_offset; /*!< Scaled horizontal offset of the top left
                           corner luma sample of reference layer from
                           the top left corner luma sample of the current
                           layer. (In the units of num MBs) */
    WORD32 i4_rt_offset;   /*!< Scaled horizontal offset of the bottom right
                           corner luma sample of reference layer from
                           the top left corner luma sample of the
                           current layer. (In the units of num MBs) */
    WORD32 i4_top_offset;  /*!< Scaled vertical offset of the top left
                           corner luma sample of reference layer from
                           the top left corner luma sample of the current
                           layer. (In the units of num MBs) */
    WORD32 i4_bot_offset;  /*!< Scaled vertical offset of the bottom right
                           corner luma sample of reference layer from
                           the top left corner luma sample of the current
                           layer. (In the units of num MBs) */
} dec_svc_crop_wnd_offset_t;

typedef struct
{
    UWORD32 u4_ref_layer_dq_id;
    UWORD32 u4_disable_inter_layer_deblk_filter_idc;
    WORD32 i4_inter_layer_slice_alpha_c0_offset_div2;
    WORD32 i4_inter_layer_slice_beta_offset_div2;
    UWORD8 u1_constrained_intra_resampling_flag;
    UWORD8 u1_ref_layer_chroma_phase_x_plus1_flag;
    UWORD8 u1_ref_layer_chroma_phase_y_plus1;

    WORD32 i4_scaled_ref_layer_left_offset;
    WORD32 i4_scaled_ref_layer_right_offset;
    WORD32 i4_scaled_ref_layer_top_offset;
    WORD32 i4_scaled_ref_layer_bottom_offset;
    UWORD8 u1_slice_skip_flag;
    UWORD32 u4_num_mbs_in_slice_minus1;
    UWORD8 u1_adaptive_base_mode_flag;
    UWORD8 u1_default_base_mode_flag;
    UWORD8 u1_adaptive_motion_prediction_flag;
    UWORD8 u1_default_motion_prediction_flag;
    UWORD8 u1_adaptive_residual_prediction_flag;
    UWORD8 u1_default_residual_prediction_flag;
    UWORD8 u1_tcoeff_level_prediction_flag;
    UWORD8 u1_scan_idx_start;
    UWORD8 u1_scan_idx_end;
    UWORD8 u1_base_pred_weight_table_flag;
    dec_ref_base_pic_marking_params_t s_ref_base_pic_marking_svc_ext;
    UWORD8 u1_store_ref_base_pic_flag; /* specifies when dependency_id is equal to
                                          the max value of the VCL NAL units of
                                          the coded picture */

} dec_slice_svc_ext_params_t;

/* Prefix NAL unit svc extension parameters*/

typedef struct
{
    dec_nal_unit_svc_ext_params_t s_nal_svc_ext;
    dec_ref_base_pic_marking_params_t s_ref_base_pic_marking_svc_ext;
    UWORD8 u1_store_ref_base_pic_flag;                  /* specifies when dependency_id is equal to
                                                           the max value of the VCL NAL units of
                                                           the coded picture */
    UWORD8 u1_additional_prefix_nal_unit_ext_flag;      /* To indicate whether additional nal unit
                                                           extension data flag syntax elements */
    UWORD8 u1_additional_prefix_nal_unit_ext_data_flag; /*Used for FUTURE USE */

} dec_prefix_nal_unit_svc_ext_params_t;

typedef enum
{
    LIST_0 = 0,
    LIST_1 = 1,
    NUM_REF_LISTS
} REF_LIST_T;

typedef enum
{
    INTRA_16x16 = 0,
    INTRA_NXN
} INTRA_MB_PRED_MODE_T;

/* Transform type */
typedef enum
{
    T_4X4 = 0,
    T_8X8,
    T_PCM
} TRANSFORM_TYPE_T;

typedef struct
{
    vcl_node_t *ps_top_node; /*!< VCL node corresponding to top most
                             layer in the access unit.
                             */
    vcl_node_t *ps_bot_node; /*!< VCL node corresponding to
                             bottom most layer to be decoded in the
                             access unit. This parameter keeps updated
                             during course of decoding from base layer
                             till top most layer.
                             */

    WORD32 i4_num_res_lyrs;  /*!< Number of layers with
                             different resolutions. Layers with spatial
                             resoluton change flag equal to 0 are
                             considered to be of same resolution as
                             reference layer's resolution.
                             */
    /* following 2 parameter will be updated only if      */
    /* the picture boundary is detected due to difference */
    /* in slice header syntax                             */

    UWORD16 u2_frm_num_next;  /*!< frame number of the next
                              slice after picture boundary detection
                              */
    WORD8 i1_nal_ref_id_next; /*!< nal ref id of the next slice after picture boundary detection
                              range [-1,3];  -1 says the picture boundary is detected
                              by DQID of the layers
                              */
} vcl_nal_t;

typedef struct
{
    WORD32 i4_num_non_vcl_nals;              /*!< Total number of non vcl nals that are
                                             extracted from the bitstream.
                                             */

    non_vcl_buf_hdr_t *ps_first_non_vcl_nal; /*!< This shall point to first NON VCL NAL
                                             that is extracted from the input bitstream. This
                                             shall be set to NULL if there are no VCL NALs
                                             present in the bitstream in a access unit */

} non_vcl_nal_t;

typedef struct
{
    WORD16 i2_mv_x; /*!< motion vectors in horizontal direction
                    QPEL units
                    */
    WORD16 i2_mv_y; /*!< motion vectors in vertical direction QPEL
                    units
                    */
} mot_vec_t;

typedef struct
{
    mot_vec_t as_mv[NUM_SUB_MB_PARTS];
    WORD32 i4_ref_idx;
} mb_part_mv_t;

typedef struct
{
    /*
    PRED_16X16,
    PRED_16X8,
    PRED_8X16,
    PRED_8X8,
    */
    UWORD8 u1_part_type;

    UWORD8 u1_mv_cnt;
    /*
    0-1 bits   : 1st partition
    2-3 bits   : 2nd partition
    4-5 bits   : 3rd partition
    6-7 bits   : 4th partition

    Value
    00     : B_DIRECT
    01     : L0
    10     : L1
    11     : BiPred
    */
    UWORD8 u1_pred_mode; /* Pred mode shall have valid value till
                         mode motion prediction only. Hence this value shall
                         not be used for the motion compensation
                         */
    UWORD8 au1_mot_pred_flags[2];
    UWORD8 au1_sub_mb_part_ht_wd[NUM_MB_PARTS * NUM_SUB_MB_PARTS];
    UWORD8 au1_sub_mb_num[NUM_MB_PARTS * NUM_SUB_MB_PARTS >> 1];
    WORD8 ai1_sub_mb_part_type[NUM_MB_PARTS];
    mb_part_mv_t as_mb_part_dmv[2][NUM_MB_PARTS];
} inter_mb_prms_t; /* We need to improve on commenting */

typedef struct
{
    /*
    0   : I_16x16
    1   : I_NXN
    */
    WORD32 i4_pred_mode;
    WORD32 i4_chroma_intra_pred_mode;
    WORD8 ai1_rem_intra_pred_mode[NUM_INTRA_SUB_BLOCKS];
} intra_mb_prms_t; /* We need to improve on commenting */

typedef union
{
    inter_mb_prms_t s_inter;
    intra_mb_prms_t s_intra;
} mb_prms_ext_t;

typedef struct
{
    UWORD8 u1_chroma_nnz; /*! NNZs of Chroma. Here each bit corresonds
                          to a NNZs of 4x4 sub block. Lower 4 bits are
                          used for Cb and upper are used for Cr */
    UWORD16 u2_luma_nnz;  /*! NNZs of Luma. Here each bit corresonds
                          to a NNZs of 4x4 sub block in raster scan
                          order. */
    WORD8 i1_mb_mode;     /*! MB mode of an MB */

    WORD8 i1_tx_size;     /*! transform size of an MB */

    WORD8 i1_slice_id;
} inter_lyr_mb_prms_t;

/* the following 2 structures are used store certain parameters  */
/* across units for each layer or each dependency layer          */
typedef struct
{
    WORD32 i4_updated_sts; /*!< flag to indicate whether the
                           params have been updated
                           */
    WORD32 i4_ref_dq_id;   /*!< place to hold the ref_dqid of previous
                           access unit
                           */
    WORD32 i4_nal_ref_id;  /*!< place to hold the nal_ref_id of previous
                           access unit
                           */
    UWORD16 u2_frm_num;    /*!< place to hold the frame number of
                           previous access unit  will be used to
                           handle Errors in "frame_num"
                           syntax elements
                           */
} prev_au_prms_t;

typedef struct
{
    WORD32 i4_updated_sts; /*!< flag to indicate whether the
                           params have been updated
                           */

    UWORD8 u1_pps_id;      /*!< PPS ID of an access unit for a particular
                           layer. will be used in concealment of
                           Errors in next access unit
                           */

    UWORD8 u1_sps_id;      /*!< SPS ID of an access unit for a particular
                           layer. will be used in concealment of
                           Errors in next access unit
                           */

} prev_au_sps_pps_t;

typedef enum
{
    /*CABAC SVC related flags*/
    CABAC_BASE_MODE_FLAG = 460,
    CABAC_MOT_PRED_FLAG0 = 463,
    CABAC_MOT_PRED_FLAG1 = 464,
    CABAC_RES_PRED_FLAG = 465

} svc_cabac_table_num_t;

typedef struct
{
    dec_seq_params_t *ps_seq;
    dec_subset_seq_params_t s_sps_svc_ext;

    /* sequence associated frame paramateres*/
    WORD32 i4_reorder_depth;
    UWORD16 u2_disp_height;
    UWORD16 u2_disp_width;
    UWORD16 u2_pic_wd;
    UWORD16 u2_pic_ht;
    UWORD16 u2_frm_wd_y;
    UWORD16 u2_frm_ht_y;
    UWORD16 u2_frm_wd_uv;
    UWORD16 u2_frm_ht_uv;
    UWORD8 u1_pad_len_y_v;
    UWORD8 u1_pad_len_cr_v;
    UWORD16 u2_crop_offset_y;
    UWORD16 u2_crop_offset_uv;
} dec_svc_seq_params_t;

typedef struct
{
    /*svc related flags*/
    UWORD8 u1_base_mode_flag;
    UWORD8 u1_residual_prediction_flag;
    UWORD8 u1_crop_window_flag;
    UWORD8 au1_motion_pred_flag[2];
} dec_svc_mb_info_t;

typedef struct _SvcDecLyrStruct
{
    dec_struct_t s_dec;

    /*Pred + Res = Target when csbp is zero*/
    ih264_pred_residual_recon_ft *pf_pred_residual_recon_luma_4x4;

    ih264_pred_residual_recon_ft *pf_pred_residual_recon_luma_8x8;

    ih264_pred_residual_recon_ft *pf_pred_residual_recon_luma_16x16;

    ih264_pred_residual_recon_chroma_ft *pf_pred_residual_recon_chroma_4x4;

    ih264_pred_residual_recon_chroma_ft *pf_pred_residual_recon_chroma_8x8;

    /* IT + Res + Recon*/
    ih264_iquant_itrans_residual_recon_ft *pf_iquant_itrans_residual_recon_luma_4x4;

    ih264_iquant_itrans_residual_recon_ft *pf_iquant_itrans_residual_recon_luma_4x4_dc;

    ih264_iquant_itrans_residual_recon_ft *pf_iquant_itrans_residual_recon_luma_8x8;

    ih264_iquant_itrans_residual_recon_ft *pf_iquant_itrans_residual_recon_luma_8x8_dc;

    ih264_iquant_itrans_residual_recon_chroma_ft *pf_iquant_itrans_residual_recon_chroma_4x4;

    ih264_iquant_itrans_residual_recon_chroma_ft *pf_iquant_itrans_residual_recon_chroma_4x4_dc;

    /* Res nnz*/
    ih264_residual_ft *pf_residual_luma_4x4;
    ih264_residual_ft *pf_residual_luma_8x8;
    ih264_residual_ft *pf_residual_luma_16x16;

    ih264_residual_chroma_ft *pf_residual_chroma_cb_cr_8x8;

    /*IT + residual */
    ih264_iquant_itrans_residual_ft *pf_iquant_itrans_residual_luma_4x4;

    ih264_iquant_itrans_residual_ft *pf_iquant_itrans_residual_luma_4x4_dc;

    ih264_iquant_itrans_residual_ft *pf_iquant_itrans_residual_luma_8x8;

    ih264_iquant_itrans_residual_ft *pf_iquant_itrans_residual_luma_8x8_dc;

    ih264_iquant_itrans_residual_chroma_ft *pf_iquant_itrans_residual_chroma_4x4;

    ih264_iquant_itrans_residual_chroma_ft *pf_iquant_itrans_residual_chroma_4x4_dc;

    /* IT */
    ih264_iquant_itrans_ft *pf_iquant_itrans_luma_4x4;

    ih264_iquant_itrans_ft *pf_iquant_itrans_luma_4x4_dc;

    ih264_iquant_itrans_ft *pf_iquant_itrans_luma_8x8;

    ih264_iquant_itrans_ft *pf_iquant_itrans_luma_8x8_dc;

    ih264_iquant_itrans_chroma_ft *pf_iquant_itrans_chroma_4x4;

    ih264_iquant_itrans_chroma_ft *pf_iquant_itrans_chroma_4x4_dc;

    /**
     *SVC extension parsing strcture place holders
     */
    dec_nal_unit_svc_ext_params_t *ps_nal_svc_ext;
    dec_prefix_nal_unit_svc_ext_params_t s_pre_nal_unit_svc_ext;
    dec_svc_crop_wnd_offset_t *ps_crop_wnd_offset;
    UWORD8 *apu1_crop_wnd_flag[MAX_DEP_LYRS_IN_RES];

    /**
     *contexts for the CABAC related parsing
     */
    bin_ctxt_model_t *ps_base_mode_flag;
    bin_ctxt_model_t *ps_motion_prediction_flag_l0;
    bin_ctxt_model_t *ps_motion_prediction_flag_l1;
    bin_ctxt_model_t *ps_residual_prediction_flag;

    /**
     * Function pointers to read Params common to CAVLC and CABAC
     */
    WORD32(*pf_parse_inter_mb_svc_ext)
    (struct _SvcDecLyrStruct *ps_dec, dec_mb_info_t *ps_cur_mb_info,
     dec_svc_mb_info_t *ps_svc_cur_mb_info, UWORD8 u1_mb_num, UWORD8 u1_num_mbsNby2);

    WORD32(*pf_parse_inter_slice_svc_ext)
    (struct _SvcDecLyrStruct *ps_dec, dec_slice_params_t *ps_slice, UWORD16 u2_first_mb_in_slice);

    /**
     * Function pointers to parse inter slice data
     */

    WORD32(*pf_parse_svc_inter_slice)
    (struct _SvcDecLyrStruct *ps_dec, dec_slice_params_t *ps_slice, UWORD16 u2_first_mb_in_slice);

    /* inter layer precition buffers */

    /* 4x4 level */
    mv_pred_t *ps_il_pred_mv_bank_buf_base;

    /* 16x16 level */
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms_base;
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms_frm_start;
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms_cur_mb;
    UWORD16 u2_inter_lyr_mb_prms_stride;
    UWORD32 u4_inter_lyr_mb_prms_size; /* in Bytes */

    /* full frame size : -255 -255 */
    WORD16 *pi2_il_residual_resample_luma_base;
    WORD16 *pi2_il_residual_resample_chroma_base;
    WORD16 *pi2_il_residual_resample_mb_luma_frm_start;
    WORD16 *pi2_il_residual_resample_mb_chroma_frm_start;

    UWORD16 u2_residual_resample_luma_stride;
    UWORD16 u2_residual_resample_chroma_stride;
    UWORD32 u4_residual_resample_luma_size;   /* in Bytes */
    UWORD32 u4_residual_resample_chroma_size; /* in Bytes */

    mv_pred_t *ps_il_pred_mv_bank_buf_cur_mb;

    UWORD8 *pu1_crop_wnd_flag;
    /*
     * Layer info flag - Base layer; Intermediate Enhancement Layers; Target
     * Enhacement Layer.
     */
    UWORD8 u1_layer_identifier;
    /* layer id of the current layer */
    UWORD8 u1_layer_id;
    /* flag to indicate if spatial layers are dyadic */
    UWORD8 u1_dyadic_flag;
    /* flag to indicate if current layer is base layer */
    UWORD8 u1_base_res_flag;
    /* reference layer for inter layer prediction, no quality layers */
    UWORD8 u1_ref_layer_id;

    UWORD8 u1_restricted_res_change_flag;

    res_prms_t s_res_prms;

    void *pv_ref_lyr_offset;
    void *pv_mode_mv_sample_ctxt;
    void *pv_ii_pred_ctxt;
    void *pv_residual_sample_ctxt;

    void *pv_intra_sample_ctxt;
    /*!< projected locations buffer pointer exported by Intra Upsampling module
    for luma this buffer contains the projected offsets and window width in
    reference layer for each MB (in horizontal direction) of current resolution
    layer.*/
    ref_mb_map_t *ps_intsam_luma_map_horz;

    /*!< projected locations buffer pointer exported by Intra Upsampling module
      for chroma this buffer contains the projected offsets and window width in
      reference layer
      for each MB (in horizontal direction) of current resolution layer.*/
    ref_mb_map_t *ps_intsam_chroma_map_horz;

    /*!< projected locations  buffer pointer exported by Intra Upsampling module
       for luma this buffer contains the projected offsets and window width in
       reference layer for each MB (in vertical direction) of current resolution
       layer. */
    ref_mb_map_t *ps_intsam_luma_map_vert;

    /*!<  projected locations buffer pointer exported by Intra Upsampling module
       for chroma this buffer contains the projected offsets and window width in
       reference layer for each MB (in vertical direction) of current resolution
       layer.  */
    ref_mb_map_t *ps_intsam_chroma_map_vert;

    /*!< projected locations buffer pointer exported by Residual Upsampling module
    for luma. this buffer contains the projected offsets and window width in
    reference layer for each MB (in horizontal direction) of current resolution
    layer. */
    ref_mb_map_t *ps_ressam_luma_map_horz;

    /*!< projected locations buffer pointer exported by Residual Upsampling module
        for chroma. this buffer contains the projected offsets and window width in
       reference layer
        for each MB (in horizontal direction) of current resolution layer. */
    ref_mb_map_t *ps_ressam_chroma_map_horz;

    /*!< projected locationscbuffer pointercexported by Residual Upsampling
    modulec for chroma. this buffer contains the projected offsets and window
    width in reference layer for each MB (in vertical direction) ofv    current
    resolution layer. */
    ref_mb_map_t *ps_ressam_luma_map_vert;

    /*!< projected locationscbuffer pointerccexported by Residual Upsampling
    module for chroma.cthis buffer contains the projected offsets and window width
    in reference layer for each MB (in vertical direction) of current resolution
    layer.*/
    ref_mb_map_t *ps_ressam_chroma_map_vert;

    /* pointer to decoder layer referered by current layer */
    void *ps_dec_svc_ref_layer;
    /* pointer to master context */
    void *ps_svcd_ctxt;

    UWORD8 u1_inter_lyr_disable_dblk_filter_idc;
    WORD8 i1_inter_lyr_slice_alpha_c0_offset;
    WORD8 i1_inter_lyr_slice_beta_offset;

    UWORD8 *pu1_ii_resamp_buffer_luma;
    UWORD8 *pu1_ii_resamp_buffer_chroma;

    dec_slice_svc_ext_params_t s_svc_slice_params;
    dec_svc_seq_params_t *ps_subset_sps;
    dec_svc_seq_params_t *ps_cur_subset_sps;
    void *pv_scratch_subset_sps;

    /* Variables Required for N MB design */
    dec_svc_mb_info_t *ps_svc_nmb_info;

    dec_svc_mb_info_t *ps_svc_frm_mb_info;

    void (*pf_svc_compute_bs)(struct _SvcDecLyrStruct *ps_svc_lyr_dec,
                              struct _DecMbInfo *ps_cur_mb_info, const UWORD16 u2_mbxn_mb);

    UWORD16 *pu2_frm_res_luma_csbp;
    WORD32 i4_frm_res_luma_csbp_stride;

    UWORD8 *pu1_svc_base_mode_flag;
    WORD32 i4_frm_svc_base_mode_cabac_stride;
    WORD32 i4_frm_svc_base_mode_cabac_size;
    UWORD32 u4_pps_id_for_layer;
    UWORD8 u1_error_in_cur_frame;
    UWORD8 u1_res_init_done;
    WORD32 pic_width;
    WORD32 pic_height;
} svc_dec_lyr_struct_t;

typedef struct
{
    /* common parameters for all layers in SVC */
    UWORD32 u4_num_cores;
    IVD_ARCH_T e_processor_arch;
    IVD_SOC_T e_processor_soc;
    UWORD8 u1_target_layer_id;
    UWORD8 u1_cur_layer_id;

    /* dcode context for all layers in SVC */
    svc_dec_lyr_struct_t *ps_svc_dec_lyr;

    dec_pic_params_t *ps_pps;
    dec_seq_params_t *ps_sps;
    dec_svc_seq_params_t *ps_subset_sps;
    struct _sei *ps_sei;
    struct _sei *ps_sei_parse;

    /* attributes related to set tgt layer api func */
    WORD32 u1_tgt_dep_id;
    WORD32 u1_tgt_quality_id;
    WORD32 u1_tgt_temp_id;
    WORD32 u1_tgt_priority_id;

    ref_lyr_scaled_offset_t as_ref_lyr_offsets[MAX_NUM_RES_LYRS];

    void *pv_ref_lyr_offset;
    void *pv_mode_mv_sample_ctxt;
    void *pv_ii_pred_ctxt;
    void *pv_residual_sample_ctxt;
    void *pv_intra_sample_ctxt;

    void *pv_nal_parse_ctxt;
    non_vcl_nal_t s_non_vcl_nal; /*!< NON VCL nal structure */
    vcl_nal_t s_vcl_nal;         /*!< VCL nal structure */

    /*!< array to store the Did of bottom most layer in each resolution */
    WORD32 ai4_dq_id_map[MAX_NUM_RES_LYRS];
    WORD32 i4_error_code;
    void *pv_vcl_nal_buff;
    void *pv_non_vcl_nal_buff;

    /*!< array of structure to store the reference layer DQID,
    poc syntax and frame num, for each depedency id
    present in an access unit this will be used as reference
    for the next access unit */
    prev_au_prms_t as_au_prms_dep[MAX_DEPENDENCY_LYRS];
    /*!< array to store the pps id for each layer in a resolution */
    prev_au_sps_pps_t as_pps_sps_prev_au[MAX_TOTAL_LYRS];

    WORD32 i4_eos_flag;
    UWORD8 u1_prev_num_res_layers;
    UWORD32 u4_num_sps_ctr;
    UWORD32 u4_num_pps_ctr;
    UWORD8 u1_parse_nal_unit_error;
    UWORD8 u1_exit_till_next_IDR;
    UWORD8 u1_pre_parse_in_flush;
    WORD32 pic_width;
    WORD32 pic_height;
} svc_dec_ctxt_t;

#endif /*_ISVCD_STRUCTS_H_*/