1 /**************************************************************************
2  *
3  * Copyright 2009 Younes Manton.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 #ifndef PIPE_VIDEO_STATE_H
29 #define PIPE_VIDEO_STATE_H
30 
31 #include "pipe/p_defines.h"
32 #include "pipe/p_format.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_screen.h"
35 #include "util/u_hash_table.h"
36 #include "util/u_inlines.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * see table 6-12 in the spec
44  */
45 enum pipe_mpeg12_picture_coding_type
46 {
47    PIPE_MPEG12_PICTURE_CODING_TYPE_I = 0x01,
48    PIPE_MPEG12_PICTURE_CODING_TYPE_P = 0x02,
49    PIPE_MPEG12_PICTURE_CODING_TYPE_B = 0x03,
50    PIPE_MPEG12_PICTURE_CODING_TYPE_D = 0x04
51 };
52 
53 /*
54  * see table 6-14 in the spec
55  */
56 enum pipe_mpeg12_picture_structure
57 {
58    PIPE_MPEG12_PICTURE_STRUCTURE_RESERVED = 0x00,
59    PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_TOP = 0x01,
60    PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_BOTTOM = 0x02,
61    PIPE_MPEG12_PICTURE_STRUCTURE_FRAME = 0x03
62 };
63 
64 /*
65  * flags for macroblock_type, see section 6.3.17.1 in the spec
66  */
67 enum pipe_mpeg12_macroblock_type
68 {
69    PIPE_MPEG12_MB_TYPE_QUANT = 0x01,
70    PIPE_MPEG12_MB_TYPE_MOTION_FORWARD = 0x02,
71    PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD = 0x04,
72    PIPE_MPEG12_MB_TYPE_PATTERN = 0x08,
73    PIPE_MPEG12_MB_TYPE_INTRA = 0x10
74 };
75 
76 /*
77  * flags for motion_type, see table 6-17 and 6-18 in the spec
78  */
79 enum pipe_mpeg12_motion_type
80 {
81    PIPE_MPEG12_MO_TYPE_RESERVED = 0x00,
82    PIPE_MPEG12_MO_TYPE_FIELD = 0x01,
83    PIPE_MPEG12_MO_TYPE_FRAME = 0x02,
84    PIPE_MPEG12_MO_TYPE_16x8 = 0x02,
85    PIPE_MPEG12_MO_TYPE_DUAL_PRIME = 0x03
86 };
87 
88 /*
89  * see section 6.3.17.1 and table 6-19 in the spec
90  */
91 enum pipe_mpeg12_dct_type
92 {
93    PIPE_MPEG12_DCT_TYPE_FRAME = 0,
94    PIPE_MPEG12_DCT_TYPE_FIELD = 1
95 };
96 
97 enum pipe_mpeg12_field_select
98 {
99    PIPE_MPEG12_FS_FIRST_FORWARD = 0x01,
100    PIPE_MPEG12_FS_FIRST_BACKWARD = 0x02,
101    PIPE_MPEG12_FS_SECOND_FORWARD = 0x04,
102    PIPE_MPEG12_FS_SECOND_BACKWARD = 0x08
103 };
104 
105 enum pipe_h264_slice_type
106 {
107    PIPE_H264_SLICE_TYPE_P = 0x0,
108    PIPE_H264_SLICE_TYPE_B = 0x1,
109    PIPE_H264_SLICE_TYPE_I = 0x2,
110    PIPE_H264_SLICE_TYPE_SP = 0x3,
111    PIPE_H264_SLICE_TYPE_SI = 0x4
112 };
113 
114 enum pipe_h264_enc_picture_type
115 {
116    PIPE_H264_ENC_PICTURE_TYPE_P = 0x00,
117    PIPE_H264_ENC_PICTURE_TYPE_B = 0x01,
118    PIPE_H264_ENC_PICTURE_TYPE_I = 0x02,
119    PIPE_H264_ENC_PICTURE_TYPE_IDR = 0x03,
120    PIPE_H264_ENC_PICTURE_TYPE_SKIP = 0x04
121 };
122 
123 enum pipe_h265_enc_picture_type
124 {
125    PIPE_H265_ENC_PICTURE_TYPE_P = 0x00,
126    PIPE_H265_ENC_PICTURE_TYPE_B = 0x01,
127    PIPE_H265_ENC_PICTURE_TYPE_I = 0x02,
128    PIPE_H265_ENC_PICTURE_TYPE_IDR = 0x03,
129    PIPE_H265_ENC_PICTURE_TYPE_SKIP = 0x04
130 };
131 
132 enum pipe_h264_enc_rate_control_method
133 {
134    PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE = 0x00,
135    PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP = 0x01,
136    PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP = 0x02,
137    PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT = 0x03,
138    PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE = 0x04
139 };
140 
141 enum pipe_h265_enc_rate_control_method
142 {
143    PIPE_H265_ENC_RATE_CONTROL_METHOD_DISABLE = 0x00,
144    PIPE_H265_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP = 0x01,
145    PIPE_H265_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP = 0x02,
146    PIPE_H265_ENC_RATE_CONTROL_METHOD_CONSTANT = 0x03,
147    PIPE_H265_ENC_RATE_CONTROL_METHOD_VARIABLE = 0x04
148 };
149 
150 struct pipe_picture_desc
151 {
152    enum pipe_video_profile profile;
153    enum pipe_video_entrypoint entry_point;
154    bool protected_playback;
155    uint8_t *decrypt_key;
156 };
157 
158 struct pipe_quant_matrix
159 {
160    enum pipe_video_format codec;
161 };
162 
163 struct pipe_macroblock
164 {
165    enum pipe_video_format codec;
166 };
167 
168 struct pipe_mpeg12_picture_desc
169 {
170    struct pipe_picture_desc base;
171 
172    unsigned picture_coding_type;
173    unsigned picture_structure;
174    unsigned frame_pred_frame_dct;
175    unsigned q_scale_type;
176    unsigned alternate_scan;
177    unsigned intra_vlc_format;
178    unsigned concealment_motion_vectors;
179    unsigned intra_dc_precision;
180    unsigned f_code[2][2];
181    unsigned top_field_first;
182    unsigned full_pel_forward_vector;
183    unsigned full_pel_backward_vector;
184    unsigned num_slices;
185 
186    const uint8_t *intra_matrix;
187    const uint8_t *non_intra_matrix;
188 
189    struct pipe_video_buffer *ref[2];
190 };
191 
192 struct pipe_mpeg12_macroblock
193 {
194    struct pipe_macroblock base;
195 
196    /* see section 6.3.17 in the spec */
197    unsigned short x, y;
198 
199    /* see section 6.3.17.1 in the spec */
200    unsigned char macroblock_type;
201 
202    union {
203       struct {
204          /* see table 6-17 in the spec */
205          unsigned int frame_motion_type:2;
206 
207          /* see table 6-18 in the spec */
208          unsigned int field_motion_type:2;
209 
210          /* see table 6-19 in the spec */
211          unsigned int dct_type:1;
212       } bits;
213       unsigned int value;
214    } macroblock_modes;
215 
216     /* see section 6.3.17.2 in the spec */
217    unsigned char motion_vertical_field_select;
218 
219    /* see Table 7-7 in the spec */
220    short PMV[2][2][2];
221 
222    /* see figure 6.10-12 in the spec */
223    unsigned short coded_block_pattern;
224 
225    /* see figure 6.10-12 in the spec */
226    short *blocks;
227 
228    /* Number of skipped macroblocks after this macroblock */
229    unsigned short num_skipped_macroblocks;
230 };
231 
232 struct pipe_mpeg4_picture_desc
233 {
234    struct pipe_picture_desc base;
235 
236    int32_t trd[2];
237    int32_t trb[2];
238    uint16_t vop_time_increment_resolution;
239    uint8_t vop_coding_type;
240    uint8_t vop_fcode_forward;
241    uint8_t vop_fcode_backward;
242    uint8_t resync_marker_disable;
243    uint8_t interlaced;
244    uint8_t quant_type;
245    uint8_t quarter_sample;
246    uint8_t short_video_header;
247    uint8_t rounding_control;
248    uint8_t alternate_vertical_scan_flag;
249    uint8_t top_field_first;
250 
251    const uint8_t *intra_matrix;
252    const uint8_t *non_intra_matrix;
253 
254    struct pipe_video_buffer *ref[2];
255 };
256 
257 struct pipe_vc1_picture_desc
258 {
259    struct pipe_picture_desc base;
260 
261    uint32_t slice_count;
262    uint8_t picture_type;
263    uint8_t frame_coding_mode;
264    uint8_t postprocflag;
265    uint8_t pulldown;
266    uint8_t interlace;
267    uint8_t tfcntrflag;
268    uint8_t finterpflag;
269    uint8_t psf;
270    uint8_t dquant;
271    uint8_t panscan_flag;
272    uint8_t refdist_flag;
273    uint8_t quantizer;
274    uint8_t extended_mv;
275    uint8_t extended_dmv;
276    uint8_t overlap;
277    uint8_t vstransform;
278    uint8_t loopfilter;
279    uint8_t fastuvmc;
280    uint8_t range_mapy_flag;
281    uint8_t range_mapy;
282    uint8_t range_mapuv_flag;
283    uint8_t range_mapuv;
284    uint8_t multires;
285    uint8_t syncmarker;
286    uint8_t rangered;
287    uint8_t maxbframes;
288    uint8_t deblockEnable;
289    uint8_t pquant;
290 
291    struct pipe_video_buffer *ref[2];
292 };
293 
294 struct pipe_h264_sps
295 {
296    uint8_t  level_idc;
297    uint8_t  chroma_format_idc;
298    uint8_t  separate_colour_plane_flag;
299    uint8_t  bit_depth_luma_minus8;
300    uint8_t  bit_depth_chroma_minus8;
301    uint8_t  seq_scaling_matrix_present_flag;
302    uint8_t  ScalingList4x4[6][16];
303    uint8_t  ScalingList8x8[6][64];
304    uint8_t  log2_max_frame_num_minus4;
305    uint8_t  pic_order_cnt_type;
306    uint8_t  log2_max_pic_order_cnt_lsb_minus4;
307    uint8_t  delta_pic_order_always_zero_flag;
308    int32_t  offset_for_non_ref_pic;
309    int32_t  offset_for_top_to_bottom_field;
310    uint8_t  num_ref_frames_in_pic_order_cnt_cycle;
311    int32_t  offset_for_ref_frame[256];
312    uint8_t  max_num_ref_frames;
313    uint8_t  frame_mbs_only_flag;
314    uint8_t  mb_adaptive_frame_field_flag;
315    uint8_t  direct_8x8_inference_flag;
316 };
317 
318 struct pipe_h264_pps
319 {
320    struct pipe_h264_sps *sps;
321 
322    uint8_t  entropy_coding_mode_flag;
323    uint8_t  bottom_field_pic_order_in_frame_present_flag;
324    uint8_t  num_slice_groups_minus1;
325    uint8_t  slice_group_map_type;
326    uint8_t  slice_group_change_rate_minus1;
327    uint8_t  num_ref_idx_l0_default_active_minus1;
328    uint8_t  num_ref_idx_l1_default_active_minus1;
329    uint8_t  weighted_pred_flag;
330    uint8_t  weighted_bipred_idc;
331    int8_t   pic_init_qp_minus26;
332    int8_t   chroma_qp_index_offset;
333    uint8_t  deblocking_filter_control_present_flag;
334    uint8_t  constrained_intra_pred_flag;
335    uint8_t  redundant_pic_cnt_present_flag;
336    uint8_t  ScalingList4x4[6][16];
337    uint8_t  ScalingList8x8[6][64];
338    uint8_t  transform_8x8_mode_flag;
339    int8_t   second_chroma_qp_index_offset;
340 };
341 
342 struct pipe_h264_picture_desc
343 {
344    struct pipe_picture_desc base;
345 
346    struct pipe_h264_pps *pps;
347 
348    /* slice header */
349    uint32_t frame_num;
350    uint8_t  field_pic_flag;
351    uint8_t  bottom_field_flag;
352    uint8_t  num_ref_idx_l0_active_minus1;
353    uint8_t  num_ref_idx_l1_active_minus1;
354 
355    uint32_t slice_count;
356    int32_t  field_order_cnt[2];
357    bool     is_reference;
358    uint8_t  num_ref_frames;
359 
360    bool     is_long_term[16];
361    bool     top_is_reference[16];
362    bool     bottom_is_reference[16];
363    uint32_t field_order_cnt_list[16][2];
364    uint32_t frame_num_list[16];
365 
366    struct pipe_video_buffer *ref[16];
367 };
368 
369 struct pipe_h264_enc_rate_control
370 {
371    enum pipe_h264_enc_rate_control_method rate_ctrl_method;
372    unsigned target_bitrate;
373    unsigned peak_bitrate;
374    unsigned frame_rate_num;
375    unsigned frame_rate_den;
376    unsigned vbv_buffer_size;
377    unsigned vbv_buf_lv;
378    unsigned target_bits_picture;
379    unsigned peak_bits_picture_integer;
380    unsigned peak_bits_picture_fraction;
381    unsigned fill_data_enable;
382    unsigned enforce_hrd;
383 };
384 
385 struct pipe_h264_enc_motion_estimation
386 {
387    unsigned motion_est_quarter_pixel;
388    unsigned enc_disable_sub_mode;
389    unsigned lsmvert;
390    unsigned enc_en_ime_overw_dis_subm;
391    unsigned enc_ime_overw_dis_subm_no;
392    unsigned enc_ime2_search_range_x;
393    unsigned enc_ime2_search_range_y;
394 };
395 
396 struct pipe_h264_enc_pic_control
397 {
398    unsigned enc_cabac_enable;
399    unsigned enc_constraint_set_flags;
400    unsigned enc_frame_cropping_flag;
401    unsigned enc_frame_crop_left_offset;
402    unsigned enc_frame_crop_right_offset;
403    unsigned enc_frame_crop_top_offset;
404    unsigned enc_frame_crop_bottom_offset;
405 };
406 
407 struct pipe_h264_enc_picture_desc
408 {
409    struct pipe_picture_desc base;
410 
411    struct pipe_h264_enc_rate_control rate_ctrl;
412 
413    struct pipe_h264_enc_motion_estimation motion_est;
414    struct pipe_h264_enc_pic_control pic_ctrl;
415 
416    unsigned quant_i_frames;
417    unsigned quant_p_frames;
418    unsigned quant_b_frames;
419 
420    enum pipe_h264_enc_picture_type picture_type;
421    unsigned frame_num;
422    unsigned frame_num_cnt;
423    unsigned p_remain;
424    unsigned i_remain;
425    unsigned idr_pic_id;
426    unsigned gop_cnt;
427    unsigned pic_order_cnt;
428    unsigned pic_order_cnt_type;
429    unsigned ref_idx_l0;
430    unsigned ref_idx_l1;
431    unsigned gop_size;
432    unsigned ref_pic_mode;
433 
434    bool not_referenced;
435    bool enable_vui;
436    struct hash_table *frame_idx;
437 
438 };
439 
440 struct pipe_h265_enc_seq_param
441 {
442    uint8_t  general_profile_idc;
443    uint8_t  general_level_idc;
444    uint8_t  general_tier_flag;
445    uint32_t intra_period;
446    uint16_t pic_width_in_luma_samples;
447    uint16_t pic_height_in_luma_samples;
448    uint32_t chroma_format_idc;
449    uint32_t bit_depth_luma_minus8;
450    uint32_t bit_depth_chroma_minus8;
451    bool strong_intra_smoothing_enabled_flag;
452    bool amp_enabled_flag;
453    bool sample_adaptive_offset_enabled_flag;
454    bool pcm_enabled_flag;
455    bool sps_temporal_mvp_enabled_flag;
456    uint8_t  log2_min_luma_coding_block_size_minus3;
457    uint8_t  log2_diff_max_min_luma_coding_block_size;
458    uint8_t  log2_min_transform_block_size_minus2;
459    uint8_t  log2_diff_max_min_transform_block_size;
460    uint8_t  max_transform_hierarchy_depth_inter;
461    uint8_t  max_transform_hierarchy_depth_intra;
462    uint8_t conformance_window_flag;
463    uint16_t conf_win_left_offset;
464    uint16_t conf_win_right_offset;
465    uint16_t conf_win_top_offset;
466    uint16_t conf_win_bottom_offset;
467 };
468 
469 struct pipe_h265_enc_pic_param
470 {
471    uint8_t log2_parallel_merge_level_minus2;
472    uint8_t nal_unit_type;
473    bool constrained_intra_pred_flag;
474 };
475 
476 struct pipe_h265_enc_slice_param
477 {
478    uint8_t max_num_merge_cand;
479    int8_t slice_cb_qp_offset;
480    int8_t slice_cr_qp_offset;
481    int8_t slice_beta_offset_div2;
482    int8_t slice_tc_offset_div2;
483    bool cabac_init_flag;
484    uint32_t slice_deblocking_filter_disabled_flag;
485    bool slice_loop_filter_across_slices_enabled_flag;
486 };
487 
488 struct pipe_h265_enc_rate_control
489 {
490    enum pipe_h265_enc_rate_control_method rate_ctrl_method;
491    unsigned target_bitrate;
492    unsigned peak_bitrate;
493    unsigned frame_rate_num;
494    unsigned frame_rate_den;
495    unsigned quant_i_frames;
496    unsigned vbv_buffer_size;
497    unsigned vbv_buf_lv;
498    unsigned target_bits_picture;
499    unsigned peak_bits_picture_integer;
500    unsigned peak_bits_picture_fraction;
501    unsigned fill_data_enable;
502    unsigned enforce_hrd;
503 };
504 
505 struct pipe_h265_enc_picture_desc
506 {
507    struct pipe_picture_desc base;
508 
509    struct pipe_h265_enc_seq_param seq;
510    struct pipe_h265_enc_pic_param pic;
511    struct pipe_h265_enc_slice_param slice;
512    struct pipe_h265_enc_rate_control rc;
513 
514    enum pipe_h265_enc_picture_type picture_type;
515    unsigned decoded_curr_pic;
516    unsigned reference_frames[16];
517    unsigned frame_num;
518    unsigned pic_order_cnt;
519    unsigned pic_order_cnt_type;
520    unsigned ref_idx_l0;
521    unsigned ref_idx_l1;
522    bool not_referenced;
523    struct hash_table *frame_idx;
524 };
525 
526 struct pipe_h265_sps
527 {
528    uint8_t chroma_format_idc;
529    uint8_t separate_colour_plane_flag;
530    uint32_t pic_width_in_luma_samples;
531    uint32_t pic_height_in_luma_samples;
532    uint8_t bit_depth_luma_minus8;
533    uint8_t bit_depth_chroma_minus8;
534    uint8_t log2_max_pic_order_cnt_lsb_minus4;
535    uint8_t sps_max_dec_pic_buffering_minus1;
536    uint8_t log2_min_luma_coding_block_size_minus3;
537    uint8_t log2_diff_max_min_luma_coding_block_size;
538    uint8_t log2_min_transform_block_size_minus2;
539    uint8_t log2_diff_max_min_transform_block_size;
540    uint8_t max_transform_hierarchy_depth_inter;
541    uint8_t max_transform_hierarchy_depth_intra;
542    uint8_t scaling_list_enabled_flag;
543    uint8_t ScalingList4x4[6][16];
544    uint8_t ScalingList8x8[6][64];
545    uint8_t ScalingList16x16[6][64];
546    uint8_t ScalingList32x32[2][64];
547    uint8_t ScalingListDCCoeff16x16[6];
548    uint8_t ScalingListDCCoeff32x32[2];
549    uint8_t amp_enabled_flag;
550    uint8_t sample_adaptive_offset_enabled_flag;
551    uint8_t pcm_enabled_flag;
552    uint8_t pcm_sample_bit_depth_luma_minus1;
553    uint8_t pcm_sample_bit_depth_chroma_minus1;
554    uint8_t log2_min_pcm_luma_coding_block_size_minus3;
555    uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
556    uint8_t pcm_loop_filter_disabled_flag;
557    uint8_t num_short_term_ref_pic_sets;
558    uint8_t long_term_ref_pics_present_flag;
559    uint8_t num_long_term_ref_pics_sps;
560    uint8_t sps_temporal_mvp_enabled_flag;
561    uint8_t strong_intra_smoothing_enabled_flag;
562 };
563 
564 struct pipe_h265_pps
565 {
566    struct pipe_h265_sps *sps;
567 
568    uint8_t dependent_slice_segments_enabled_flag;
569    uint8_t output_flag_present_flag;
570    uint8_t num_extra_slice_header_bits;
571    uint8_t sign_data_hiding_enabled_flag;
572    uint8_t cabac_init_present_flag;
573    uint8_t num_ref_idx_l0_default_active_minus1;
574    uint8_t num_ref_idx_l1_default_active_minus1;
575    int8_t init_qp_minus26;
576    uint8_t constrained_intra_pred_flag;
577    uint8_t transform_skip_enabled_flag;
578    uint8_t cu_qp_delta_enabled_flag;
579    uint8_t diff_cu_qp_delta_depth;
580    int8_t pps_cb_qp_offset;
581    int8_t pps_cr_qp_offset;
582    uint8_t pps_slice_chroma_qp_offsets_present_flag;
583    uint8_t weighted_pred_flag;
584    uint8_t weighted_bipred_flag;
585    uint8_t transquant_bypass_enabled_flag;
586    uint8_t tiles_enabled_flag;
587    uint8_t entropy_coding_sync_enabled_flag;
588    uint8_t num_tile_columns_minus1;
589    uint8_t num_tile_rows_minus1;
590    uint8_t uniform_spacing_flag;
591    uint16_t column_width_minus1[20];
592    uint16_t row_height_minus1[22];
593    uint8_t loop_filter_across_tiles_enabled_flag;
594    uint8_t pps_loop_filter_across_slices_enabled_flag;
595    uint8_t deblocking_filter_control_present_flag;
596    uint8_t deblocking_filter_override_enabled_flag;
597    uint8_t pps_deblocking_filter_disabled_flag;
598    int8_t pps_beta_offset_div2;
599    int8_t pps_tc_offset_div2;
600    uint8_t lists_modification_present_flag;
601    uint8_t log2_parallel_merge_level_minus2;
602    uint8_t slice_segment_header_extension_present_flag;
603 };
604 
605 struct pipe_h265_picture_desc
606 {
607    struct pipe_picture_desc base;
608 
609    struct pipe_h265_pps *pps;
610 
611    uint8_t IDRPicFlag;
612    uint8_t RAPPicFlag;
613    uint8_t CurrRpsIdx;
614    uint32_t NumPocTotalCurr;
615    uint32_t NumDeltaPocsOfRefRpsIdx;
616    uint32_t NumShortTermPictureSliceHeaderBits;
617    uint32_t NumLongTermPictureSliceHeaderBits;
618 
619    int32_t CurrPicOrderCntVal;
620    struct pipe_video_buffer *ref[16];
621    int32_t PicOrderCntVal[16];
622    uint8_t IsLongTerm[16];
623    uint8_t NumPocStCurrBefore;
624    uint8_t NumPocStCurrAfter;
625    uint8_t NumPocLtCurr;
626    uint8_t RefPicSetStCurrBefore[8];
627    uint8_t RefPicSetStCurrAfter[8];
628    uint8_t RefPicSetLtCurr[8];
629    uint8_t RefPicList[2][15];
630    bool UseRefPicList;
631 };
632 
633 struct pipe_mjpeg_picture_desc
634 {
635    struct pipe_picture_desc base;
636 
637    struct
638    {
639       uint16_t picture_width;
640       uint16_t picture_height;
641 
642       struct {
643          uint8_t component_id;
644          uint8_t h_sampling_factor;
645          uint8_t v_sampling_factor;
646          uint8_t quantiser_table_selector;
647       } components[255];
648 
649       uint8_t num_components;
650    } picture_parameter;
651 
652    struct
653    {
654       uint8_t load_quantiser_table[4];
655       uint8_t quantiser_table[4][64];
656    } quantization_table;
657 
658    struct
659    {
660       uint8_t load_huffman_table[2];
661 
662       struct {
663          uint8_t   num_dc_codes[16];
664          uint8_t   dc_values[12];
665          uint8_t   num_ac_codes[16];
666          uint8_t   ac_values[162];
667          uint8_t   pad[2];
668       } table[2];
669    } huffman_table;
670 
671    struct
672    {
673       unsigned slice_data_size;
674       unsigned slice_data_offset;
675       unsigned slice_data_flag;
676       unsigned slice_horizontal_position;
677       unsigned slice_vertical_position;
678 
679       struct {
680          uint8_t component_selector;
681          uint8_t dc_table_selector;
682          uint8_t ac_table_selector;
683       } components[4];
684 
685       uint8_t num_components;
686 
687       uint16_t restart_interval;
688       unsigned num_mcus;
689    } slice_parameter;
690 };
691 
692 struct vp9_segment_parameter
693 {
694    struct {
695       uint16_t segment_reference_enabled:1;
696       uint16_t segment_reference:2;
697       uint16_t segment_reference_skipped:1;
698    } segment_flags;
699 
700    bool alt_quant_enabled;
701    int16_t alt_quant;
702 
703    bool alt_lf_enabled;
704    int16_t alt_lf;
705 
706    uint8_t filter_level[4][2];
707 
708    int16_t luma_ac_quant_scale;
709    int16_t luma_dc_quant_scale;
710 
711    int16_t chroma_ac_quant_scale;
712    int16_t chroma_dc_quant_scale;
713 };
714 
715 struct pipe_vp9_picture_desc
716 {
717    struct pipe_picture_desc base;
718 
719    struct pipe_video_buffer *ref[16];
720 
721    struct {
722       uint16_t frame_width;
723       uint16_t frame_height;
724 
725       struct {
726          uint32_t  subsampling_x:1;
727          uint32_t  subsampling_y:1;
728          uint32_t  frame_type:1;
729          uint32_t  show_frame:1;
730          uint32_t  error_resilient_mode:1;
731          uint32_t  intra_only:1;
732          uint32_t  allow_high_precision_mv:1;
733          uint32_t  mcomp_filter_type:3;
734          uint32_t  frame_parallel_decoding_mode:1;
735          uint32_t  reset_frame_context:2;
736          uint32_t  refresh_frame_context:1;
737          uint32_t  frame_context_idx:2;
738          uint32_t  segmentation_enabled:1;
739          uint32_t  segmentation_temporal_update:1;
740          uint32_t  segmentation_update_map:1;
741          uint32_t  last_ref_frame:3;
742          uint32_t  last_ref_frame_sign_bias:1;
743          uint32_t  golden_ref_frame:3;
744          uint32_t  golden_ref_frame_sign_bias:1;
745          uint32_t  alt_ref_frame:3;
746          uint32_t  alt_ref_frame_sign_bias:1;
747          uint32_t  lossless_flag:1;
748       } pic_fields;
749 
750       uint8_t filter_level;
751       uint8_t sharpness_level;
752 
753       uint8_t log2_tile_rows;
754       uint8_t log2_tile_columns;
755 
756       uint8_t frame_header_length_in_bytes;
757 
758       uint16_t first_partition_size;
759 
760       uint8_t mb_segment_tree_probs[7];
761       uint8_t segment_pred_probs[3];
762 
763       uint8_t profile;
764 
765       uint8_t bit_depth;
766 
767       bool mode_ref_delta_enabled;
768       bool mode_ref_delta_update;
769 
770       uint8_t base_qindex;
771       int8_t y_dc_delta_q;
772       int8_t uv_ac_delta_q;
773       int8_t uv_dc_delta_q;
774       uint8_t abs_delta;
775    } picture_parameter;
776 
777    struct {
778       uint32_t slice_data_size;
779       uint32_t slice_data_offset;
780 
781       uint32_t slice_data_flag;
782 
783       struct vp9_segment_parameter seg_param[8];
784    } slice_parameter;
785 };
786 
787 #ifdef __cplusplus
788 }
789 #endif
790 
791 #endif /* PIPE_VIDEO_STATE_H */
792