• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* Same enum for h264/h265 */
115 enum pipe_h2645_enc_picture_type
116 {
117    PIPE_H2645_ENC_PICTURE_TYPE_P = 0x00,
118    PIPE_H2645_ENC_PICTURE_TYPE_B = 0x01,
119    PIPE_H2645_ENC_PICTURE_TYPE_I = 0x02,
120    PIPE_H2645_ENC_PICTURE_TYPE_IDR = 0x03,
121    PIPE_H2645_ENC_PICTURE_TYPE_SKIP = 0x04
122 };
123 
124 enum pipe_h2645_enc_rate_control_method
125 {
126    PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE = 0x00,
127    PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP = 0x01,
128    PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP = 0x02,
129    PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT = 0x03,
130    PIPE_H2645_ENC_RATE_CONTROL_METHOD_VARIABLE = 0x04
131 };
132 
133 struct pipe_picture_desc
134 {
135    enum pipe_video_profile profile;
136    enum pipe_video_entrypoint entry_point;
137    bool protected_playback;
138    uint8_t *decrypt_key;
139 };
140 
141 struct pipe_quant_matrix
142 {
143    enum pipe_video_format codec;
144 };
145 
146 struct pipe_macroblock
147 {
148    enum pipe_video_format codec;
149 };
150 
151 struct pipe_mpeg12_picture_desc
152 {
153    struct pipe_picture_desc base;
154 
155    unsigned picture_coding_type;
156    unsigned picture_structure;
157    unsigned frame_pred_frame_dct;
158    unsigned q_scale_type;
159    unsigned alternate_scan;
160    unsigned intra_vlc_format;
161    unsigned concealment_motion_vectors;
162    unsigned intra_dc_precision;
163    unsigned f_code[2][2];
164    unsigned top_field_first;
165    unsigned full_pel_forward_vector;
166    unsigned full_pel_backward_vector;
167    unsigned num_slices;
168 
169    const uint8_t *intra_matrix;
170    const uint8_t *non_intra_matrix;
171 
172    struct pipe_video_buffer *ref[2];
173 };
174 
175 struct pipe_mpeg12_macroblock
176 {
177    struct pipe_macroblock base;
178 
179    /* see section 6.3.17 in the spec */
180    unsigned short x, y;
181 
182    /* see section 6.3.17.1 in the spec */
183    unsigned char macroblock_type;
184 
185    union {
186       struct {
187          /* see table 6-17 in the spec */
188          unsigned int frame_motion_type:2;
189 
190          /* see table 6-18 in the spec */
191          unsigned int field_motion_type:2;
192 
193          /* see table 6-19 in the spec */
194          unsigned int dct_type:1;
195       } bits;
196       unsigned int value;
197    } macroblock_modes;
198 
199     /* see section 6.3.17.2 in the spec */
200    unsigned char motion_vertical_field_select;
201 
202    /* see Table 7-7 in the spec */
203    short PMV[2][2][2];
204 
205    /* see figure 6.10-12 in the spec */
206    unsigned short coded_block_pattern;
207 
208    /* see figure 6.10-12 in the spec */
209    short *blocks;
210 
211    /* Number of skipped macroblocks after this macroblock */
212    unsigned short num_skipped_macroblocks;
213 };
214 
215 struct pipe_mpeg4_picture_desc
216 {
217    struct pipe_picture_desc base;
218 
219    int32_t trd[2];
220    int32_t trb[2];
221    uint16_t vop_time_increment_resolution;
222    uint8_t vop_coding_type;
223    uint8_t vop_fcode_forward;
224    uint8_t vop_fcode_backward;
225    uint8_t resync_marker_disable;
226    uint8_t interlaced;
227    uint8_t quant_type;
228    uint8_t quarter_sample;
229    uint8_t short_video_header;
230    uint8_t rounding_control;
231    uint8_t alternate_vertical_scan_flag;
232    uint8_t top_field_first;
233 
234    const uint8_t *intra_matrix;
235    const uint8_t *non_intra_matrix;
236 
237    struct pipe_video_buffer *ref[2];
238 };
239 
240 struct pipe_vc1_picture_desc
241 {
242    struct pipe_picture_desc base;
243 
244    uint32_t slice_count;
245    uint8_t picture_type;
246    uint8_t frame_coding_mode;
247    uint8_t postprocflag;
248    uint8_t pulldown;
249    uint8_t interlace;
250    uint8_t tfcntrflag;
251    uint8_t finterpflag;
252    uint8_t psf;
253    uint8_t dquant;
254    uint8_t panscan_flag;
255    uint8_t refdist_flag;
256    uint8_t quantizer;
257    uint8_t extended_mv;
258    uint8_t extended_dmv;
259    uint8_t overlap;
260    uint8_t vstransform;
261    uint8_t loopfilter;
262    uint8_t fastuvmc;
263    uint8_t range_mapy_flag;
264    uint8_t range_mapy;
265    uint8_t range_mapuv_flag;
266    uint8_t range_mapuv;
267    uint8_t multires;
268    uint8_t syncmarker;
269    uint8_t rangered;
270    uint8_t maxbframes;
271    uint8_t deblockEnable;
272    uint8_t pquant;
273 
274    struct pipe_video_buffer *ref[2];
275 };
276 
277 struct pipe_h264_sps
278 {
279    uint8_t  level_idc;
280    uint8_t  chroma_format_idc;
281    uint8_t  separate_colour_plane_flag;
282    uint8_t  bit_depth_luma_minus8;
283    uint8_t  bit_depth_chroma_minus8;
284    uint8_t  seq_scaling_matrix_present_flag;
285    uint8_t  ScalingList4x4[6][16];
286    uint8_t  ScalingList8x8[6][64];
287    uint8_t  log2_max_frame_num_minus4;
288    uint8_t  pic_order_cnt_type;
289    uint8_t  log2_max_pic_order_cnt_lsb_minus4;
290    uint8_t  delta_pic_order_always_zero_flag;
291    int32_t  offset_for_non_ref_pic;
292    int32_t  offset_for_top_to_bottom_field;
293    uint8_t  num_ref_frames_in_pic_order_cnt_cycle;
294    int32_t  offset_for_ref_frame[256];
295    uint8_t  max_num_ref_frames;
296    uint8_t  frame_mbs_only_flag;
297    uint8_t  mb_adaptive_frame_field_flag;
298    uint8_t  direct_8x8_inference_flag;
299 };
300 
301 struct pipe_h264_pps
302 {
303    struct pipe_h264_sps *sps;
304 
305    uint8_t  entropy_coding_mode_flag;
306    uint8_t  bottom_field_pic_order_in_frame_present_flag;
307    uint8_t  num_slice_groups_minus1;
308    uint8_t  slice_group_map_type;
309    uint8_t  slice_group_change_rate_minus1;
310    uint8_t  num_ref_idx_l0_default_active_minus1;
311    uint8_t  num_ref_idx_l1_default_active_minus1;
312    uint8_t  weighted_pred_flag;
313    uint8_t  weighted_bipred_idc;
314    int8_t   pic_init_qp_minus26;
315    int8_t   chroma_qp_index_offset;
316    uint8_t  deblocking_filter_control_present_flag;
317    uint8_t  constrained_intra_pred_flag;
318    uint8_t  redundant_pic_cnt_present_flag;
319    uint8_t  ScalingList4x4[6][16];
320    uint8_t  ScalingList8x8[6][64];
321    uint8_t  transform_8x8_mode_flag;
322    int8_t   second_chroma_qp_index_offset;
323 };
324 
325 struct pipe_h264_picture_desc
326 {
327    struct pipe_picture_desc base;
328 
329    struct pipe_h264_pps *pps;
330 
331    /* slice header */
332    uint32_t frame_num;
333    uint8_t  field_pic_flag;
334    uint8_t  bottom_field_flag;
335    uint8_t  num_ref_idx_l0_active_minus1;
336    uint8_t  num_ref_idx_l1_active_minus1;
337 
338    uint32_t slice_count;
339    int32_t  field_order_cnt[2];
340    bool     is_reference;
341    uint8_t  num_ref_frames;
342 
343    bool     is_long_term[16];
344    bool     top_is_reference[16];
345    bool     bottom_is_reference[16];
346    uint32_t field_order_cnt_list[16][2];
347    uint32_t frame_num_list[16];
348 
349    struct pipe_video_buffer *ref[16];
350 };
351 
352 struct pipe_h264_enc_rate_control
353 {
354    enum pipe_h2645_enc_rate_control_method rate_ctrl_method;
355    unsigned target_bitrate;
356    unsigned peak_bitrate;
357    unsigned frame_rate_num;
358    unsigned frame_rate_den;
359    unsigned vbv_buffer_size;
360    unsigned vbv_buf_lv;
361    unsigned target_bits_picture;
362    unsigned peak_bits_picture_integer;
363    unsigned peak_bits_picture_fraction;
364    unsigned fill_data_enable;
365    unsigned enforce_hrd;
366 };
367 
368 struct pipe_h264_enc_motion_estimation
369 {
370    unsigned motion_est_quarter_pixel;
371    unsigned enc_disable_sub_mode;
372    unsigned lsmvert;
373    unsigned enc_en_ime_overw_dis_subm;
374    unsigned enc_ime_overw_dis_subm_no;
375    unsigned enc_ime2_search_range_x;
376    unsigned enc_ime2_search_range_y;
377 };
378 
379 struct pipe_h264_enc_pic_control
380 {
381    unsigned enc_cabac_enable;
382    unsigned enc_constraint_set_flags;
383    unsigned enc_frame_cropping_flag;
384    unsigned enc_frame_crop_left_offset;
385    unsigned enc_frame_crop_right_offset;
386    unsigned enc_frame_crop_top_offset;
387    unsigned enc_frame_crop_bottom_offset;
388 };
389 
390 struct pipe_h264_enc_picture_desc
391 {
392    struct pipe_picture_desc base;
393 
394    struct pipe_h264_enc_rate_control rate_ctrl[4];
395 
396    struct pipe_h264_enc_motion_estimation motion_est;
397    struct pipe_h264_enc_pic_control pic_ctrl;
398 
399    unsigned quant_i_frames;
400    unsigned quant_p_frames;
401    unsigned quant_b_frames;
402 
403    enum pipe_h2645_enc_picture_type picture_type;
404    unsigned frame_num;
405    unsigned frame_num_cnt;
406    unsigned p_remain;
407    unsigned i_remain;
408    unsigned idr_pic_id;
409    unsigned gop_cnt;
410    unsigned pic_order_cnt;
411    unsigned pic_order_cnt_type;
412    unsigned ref_idx_l0;
413    unsigned ref_idx_l1;
414    unsigned gop_size;
415    unsigned ref_pic_mode;
416    unsigned num_temporal_layers;
417 
418    bool not_referenced;
419    bool enable_vui;
420    struct hash_table *frame_idx;
421 
422 };
423 
424 struct pipe_h265_enc_seq_param
425 {
426    uint8_t  general_profile_idc;
427    uint8_t  general_level_idc;
428    uint8_t  general_tier_flag;
429    uint32_t intra_period;
430    uint16_t pic_width_in_luma_samples;
431    uint16_t pic_height_in_luma_samples;
432    uint32_t chroma_format_idc;
433    uint32_t bit_depth_luma_minus8;
434    uint32_t bit_depth_chroma_minus8;
435    bool strong_intra_smoothing_enabled_flag;
436    bool amp_enabled_flag;
437    bool sample_adaptive_offset_enabled_flag;
438    bool pcm_enabled_flag;
439    bool sps_temporal_mvp_enabled_flag;
440    uint8_t  log2_min_luma_coding_block_size_minus3;
441    uint8_t  log2_diff_max_min_luma_coding_block_size;
442    uint8_t  log2_min_transform_block_size_minus2;
443    uint8_t  log2_diff_max_min_transform_block_size;
444    uint8_t  max_transform_hierarchy_depth_inter;
445    uint8_t  max_transform_hierarchy_depth_intra;
446    uint8_t conformance_window_flag;
447    uint16_t conf_win_left_offset;
448    uint16_t conf_win_right_offset;
449    uint16_t conf_win_top_offset;
450    uint16_t conf_win_bottom_offset;
451 };
452 
453 struct pipe_h265_enc_pic_param
454 {
455    uint8_t log2_parallel_merge_level_minus2;
456    uint8_t nal_unit_type;
457    bool constrained_intra_pred_flag;
458 };
459 
460 struct pipe_h265_enc_slice_param
461 {
462    uint8_t max_num_merge_cand;
463    int8_t slice_cb_qp_offset;
464    int8_t slice_cr_qp_offset;
465    int8_t slice_beta_offset_div2;
466    int8_t slice_tc_offset_div2;
467    bool cabac_init_flag;
468    uint32_t slice_deblocking_filter_disabled_flag;
469    bool slice_loop_filter_across_slices_enabled_flag;
470 };
471 
472 struct pipe_h265_enc_rate_control
473 {
474    enum pipe_h2645_enc_rate_control_method rate_ctrl_method;
475    unsigned target_bitrate;
476    unsigned peak_bitrate;
477    unsigned frame_rate_num;
478    unsigned frame_rate_den;
479    unsigned quant_i_frames;
480    unsigned vbv_buffer_size;
481    unsigned vbv_buf_lv;
482    unsigned target_bits_picture;
483    unsigned peak_bits_picture_integer;
484    unsigned peak_bits_picture_fraction;
485    unsigned fill_data_enable;
486    unsigned enforce_hrd;
487 };
488 
489 struct pipe_h265_enc_picture_desc
490 {
491    struct pipe_picture_desc base;
492 
493    struct pipe_h265_enc_seq_param seq;
494    struct pipe_h265_enc_pic_param pic;
495    struct pipe_h265_enc_slice_param slice;
496    struct pipe_h265_enc_rate_control rc;
497 
498    enum pipe_h2645_enc_picture_type picture_type;
499    unsigned decoded_curr_pic;
500    unsigned reference_frames[16];
501    unsigned frame_num;
502    unsigned pic_order_cnt;
503    unsigned pic_order_cnt_type;
504    unsigned ref_idx_l0;
505    unsigned ref_idx_l1;
506    bool not_referenced;
507    struct hash_table *frame_idx;
508 };
509 
510 struct pipe_h265_sps
511 {
512    uint8_t chroma_format_idc;
513    uint8_t separate_colour_plane_flag;
514    uint32_t pic_width_in_luma_samples;
515    uint32_t pic_height_in_luma_samples;
516    uint8_t bit_depth_luma_minus8;
517    uint8_t bit_depth_chroma_minus8;
518    uint8_t log2_max_pic_order_cnt_lsb_minus4;
519    uint8_t sps_max_dec_pic_buffering_minus1;
520    uint8_t log2_min_luma_coding_block_size_minus3;
521    uint8_t log2_diff_max_min_luma_coding_block_size;
522    uint8_t log2_min_transform_block_size_minus2;
523    uint8_t log2_diff_max_min_transform_block_size;
524    uint8_t max_transform_hierarchy_depth_inter;
525    uint8_t max_transform_hierarchy_depth_intra;
526    uint8_t scaling_list_enabled_flag;
527    uint8_t ScalingList4x4[6][16];
528    uint8_t ScalingList8x8[6][64];
529    uint8_t ScalingList16x16[6][64];
530    uint8_t ScalingList32x32[2][64];
531    uint8_t ScalingListDCCoeff16x16[6];
532    uint8_t ScalingListDCCoeff32x32[2];
533    uint8_t amp_enabled_flag;
534    uint8_t sample_adaptive_offset_enabled_flag;
535    uint8_t pcm_enabled_flag;
536    uint8_t pcm_sample_bit_depth_luma_minus1;
537    uint8_t pcm_sample_bit_depth_chroma_minus1;
538    uint8_t log2_min_pcm_luma_coding_block_size_minus3;
539    uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
540    uint8_t pcm_loop_filter_disabled_flag;
541    uint8_t num_short_term_ref_pic_sets;
542    uint8_t long_term_ref_pics_present_flag;
543    uint8_t num_long_term_ref_pics_sps;
544    uint8_t sps_temporal_mvp_enabled_flag;
545    uint8_t strong_intra_smoothing_enabled_flag;
546 };
547 
548 struct pipe_h265_pps
549 {
550    struct pipe_h265_sps *sps;
551 
552    uint8_t dependent_slice_segments_enabled_flag;
553    uint8_t output_flag_present_flag;
554    uint8_t num_extra_slice_header_bits;
555    uint8_t sign_data_hiding_enabled_flag;
556    uint8_t cabac_init_present_flag;
557    uint8_t num_ref_idx_l0_default_active_minus1;
558    uint8_t num_ref_idx_l1_default_active_minus1;
559    int8_t init_qp_minus26;
560    uint8_t constrained_intra_pred_flag;
561    uint8_t transform_skip_enabled_flag;
562    uint8_t cu_qp_delta_enabled_flag;
563    uint8_t diff_cu_qp_delta_depth;
564    int8_t pps_cb_qp_offset;
565    int8_t pps_cr_qp_offset;
566    uint8_t pps_slice_chroma_qp_offsets_present_flag;
567    uint8_t weighted_pred_flag;
568    uint8_t weighted_bipred_flag;
569    uint8_t transquant_bypass_enabled_flag;
570    uint8_t tiles_enabled_flag;
571    uint8_t entropy_coding_sync_enabled_flag;
572    uint8_t num_tile_columns_minus1;
573    uint8_t num_tile_rows_minus1;
574    uint8_t uniform_spacing_flag;
575    uint16_t column_width_minus1[20];
576    uint16_t row_height_minus1[22];
577    uint8_t loop_filter_across_tiles_enabled_flag;
578    uint8_t pps_loop_filter_across_slices_enabled_flag;
579    uint8_t deblocking_filter_control_present_flag;
580    uint8_t deblocking_filter_override_enabled_flag;
581    uint8_t pps_deblocking_filter_disabled_flag;
582    int8_t pps_beta_offset_div2;
583    int8_t pps_tc_offset_div2;
584    uint8_t lists_modification_present_flag;
585    uint8_t log2_parallel_merge_level_minus2;
586    uint8_t slice_segment_header_extension_present_flag;
587    uint16_t st_rps_bits;
588 };
589 
590 struct pipe_h265_picture_desc
591 {
592    struct pipe_picture_desc base;
593 
594    struct pipe_h265_pps *pps;
595 
596    uint8_t IDRPicFlag;
597    uint8_t RAPPicFlag;
598    uint8_t CurrRpsIdx;
599    uint32_t NumPocTotalCurr;
600    uint32_t NumDeltaPocsOfRefRpsIdx;
601    uint32_t NumShortTermPictureSliceHeaderBits;
602    uint32_t NumLongTermPictureSliceHeaderBits;
603 
604    int32_t CurrPicOrderCntVal;
605    struct pipe_video_buffer *ref[16];
606    int32_t PicOrderCntVal[16];
607    uint8_t IsLongTerm[16];
608    uint8_t NumPocStCurrBefore;
609    uint8_t NumPocStCurrAfter;
610    uint8_t NumPocLtCurr;
611    uint8_t RefPicSetStCurrBefore[8];
612    uint8_t RefPicSetStCurrAfter[8];
613    uint8_t RefPicSetLtCurr[8];
614    uint8_t RefPicList[2][15];
615    bool UseRefPicList;
616    bool UseStRpsBits;
617 };
618 
619 struct pipe_mjpeg_picture_desc
620 {
621    struct pipe_picture_desc base;
622 
623    struct
624    {
625       uint16_t picture_width;
626       uint16_t picture_height;
627 
628       struct {
629          uint8_t component_id;
630          uint8_t h_sampling_factor;
631          uint8_t v_sampling_factor;
632          uint8_t quantiser_table_selector;
633       } components[255];
634 
635       uint8_t num_components;
636    } picture_parameter;
637 
638    struct
639    {
640       uint8_t load_quantiser_table[4];
641       uint8_t quantiser_table[4][64];
642    } quantization_table;
643 
644    struct
645    {
646       uint8_t load_huffman_table[2];
647 
648       struct {
649          uint8_t   num_dc_codes[16];
650          uint8_t   dc_values[12];
651          uint8_t   num_ac_codes[16];
652          uint8_t   ac_values[162];
653          uint8_t   pad[2];
654       } table[2];
655    } huffman_table;
656 
657    struct
658    {
659       unsigned slice_data_size;
660       unsigned slice_data_offset;
661       unsigned slice_data_flag;
662       unsigned slice_horizontal_position;
663       unsigned slice_vertical_position;
664 
665       struct {
666          uint8_t component_selector;
667          uint8_t dc_table_selector;
668          uint8_t ac_table_selector;
669       } components[4];
670 
671       uint8_t num_components;
672 
673       uint16_t restart_interval;
674       unsigned num_mcus;
675    } slice_parameter;
676 };
677 
678 struct vp9_segment_parameter
679 {
680    struct {
681       uint16_t segment_reference_enabled:1;
682       uint16_t segment_reference:2;
683       uint16_t segment_reference_skipped:1;
684    } segment_flags;
685 
686    bool alt_quant_enabled;
687    int16_t alt_quant;
688 
689    bool alt_lf_enabled;
690    int16_t alt_lf;
691 
692    uint8_t filter_level[4][2];
693 
694    int16_t luma_ac_quant_scale;
695    int16_t luma_dc_quant_scale;
696 
697    int16_t chroma_ac_quant_scale;
698    int16_t chroma_dc_quant_scale;
699 };
700 
701 struct pipe_vp9_picture_desc
702 {
703    struct pipe_picture_desc base;
704 
705    struct pipe_video_buffer *ref[16];
706 
707    struct {
708       uint16_t frame_width;
709       uint16_t frame_height;
710 
711       struct {
712          uint32_t  subsampling_x:1;
713          uint32_t  subsampling_y:1;
714          uint32_t  frame_type:1;
715          uint32_t  show_frame:1;
716          uint32_t  error_resilient_mode:1;
717          uint32_t  intra_only:1;
718          uint32_t  allow_high_precision_mv:1;
719          uint32_t  mcomp_filter_type:3;
720          uint32_t  frame_parallel_decoding_mode:1;
721          uint32_t  reset_frame_context:2;
722          uint32_t  refresh_frame_context:1;
723          uint32_t  frame_context_idx:2;
724          uint32_t  segmentation_enabled:1;
725          uint32_t  segmentation_temporal_update:1;
726          uint32_t  segmentation_update_map:1;
727          uint32_t  last_ref_frame:3;
728          uint32_t  last_ref_frame_sign_bias:1;
729          uint32_t  golden_ref_frame:3;
730          uint32_t  golden_ref_frame_sign_bias:1;
731          uint32_t  alt_ref_frame:3;
732          uint32_t  alt_ref_frame_sign_bias:1;
733          uint32_t  lossless_flag:1;
734       } pic_fields;
735 
736       uint8_t filter_level;
737       uint8_t sharpness_level;
738 
739       uint8_t log2_tile_rows;
740       uint8_t log2_tile_columns;
741 
742       uint8_t frame_header_length_in_bytes;
743 
744       uint16_t first_partition_size;
745 
746       uint8_t mb_segment_tree_probs[7];
747       uint8_t segment_pred_probs[3];
748 
749       uint8_t profile;
750 
751       uint8_t bit_depth;
752 
753       bool mode_ref_delta_enabled;
754       bool mode_ref_delta_update;
755 
756       uint8_t base_qindex;
757       int8_t y_dc_delta_q;
758       int8_t uv_ac_delta_q;
759       int8_t uv_dc_delta_q;
760       uint8_t abs_delta;
761    } picture_parameter;
762 
763    struct {
764       uint32_t slice_data_size;
765       uint32_t slice_data_offset;
766 
767       uint32_t slice_data_flag;
768 
769       struct vp9_segment_parameter seg_param[8];
770    } slice_parameter;
771 };
772 
773 struct pipe_av1_picture_desc
774 {
775    struct pipe_picture_desc base;
776 
777    struct pipe_video_buffer *ref[16];
778 
779    struct {
780       uint8_t profile;
781       uint8_t order_hint_bits_minus_1;
782       uint8_t bit_depth_idx;
783 
784       struct {
785          uint32_t use_128x128_superblock:1;
786          uint32_t enable_filter_intra:1;
787          uint32_t enable_intra_edge_filter:1;
788          uint32_t enable_interintra_compound:1;
789          uint32_t enable_masked_compound:1;
790          uint32_t enable_dual_filter:1;
791          uint32_t enable_order_hint:1;
792          uint32_t enable_jnt_comp:1;
793          uint32_t mono_chrome:1;
794          uint32_t ref_frame_mvs:1;
795       } seq_info_fields;
796 
797       uint32_t current_frame_id;
798 
799       uint16_t frame_width;
800       uint16_t frame_height;
801       uint16_t max_width;
802       uint16_t max_height;
803 
804       uint8_t ref_frame_idx[7];
805       uint8_t primary_ref_frame;
806       uint8_t order_hint;
807 
808       struct {
809          struct {
810             uint32_t enabled:1;
811             uint32_t update_map:1;
812             uint32_t temporal_update:1;
813          } segment_info_fields;
814 
815          int16_t feature_data[8][8];
816          uint8_t feature_mask[8];
817       } seg_info;
818 
819       struct {
820          struct {
821             uint32_t apply_grain:1;
822             uint32_t chroma_scaling_from_luma:1;
823             uint32_t grain_scaling_minus_8:2;
824             uint32_t ar_coeff_lag:2;
825             uint32_t ar_coeff_shift_minus_6:2;
826             uint32_t grain_scale_shift:2;
827             uint32_t overlap_flag:1;
828             uint32_t clip_to_restricted_range:1;
829          } film_grain_info_fields;
830 
831          uint16_t grain_seed;
832          uint8_t num_y_points;
833          uint8_t point_y_value[14];
834          uint8_t point_y_scaling[14];
835          uint8_t num_cb_points;
836          uint8_t point_cb_value[10];
837          uint8_t point_cb_scaling[10];
838          uint8_t num_cr_points;
839          uint8_t point_cr_value[10];
840          uint8_t point_cr_scaling[10];
841          int8_t ar_coeffs_y[24];
842          int8_t ar_coeffs_cb[25];
843          int8_t ar_coeffs_cr[25];
844          uint8_t cb_mult;
845          uint8_t cb_luma_mult;
846          uint16_t cb_offset;
847          uint8_t cr_mult;
848          uint8_t cr_luma_mult;
849          uint16_t cr_offset;
850       } film_grain_info;
851 
852       uint8_t tile_cols;
853       uint8_t tile_rows;
854       uint32_t tile_col_start_sb[65];
855       uint32_t tile_row_start_sb[65];
856       uint16_t context_update_tile_id;
857 
858       struct {
859          uint32_t frame_type:2;
860          uint32_t show_frame:1;
861          uint32_t error_resilient_mode:1;
862          uint32_t disable_cdf_update:1;
863          uint32_t allow_screen_content_tools:1;
864          uint32_t force_integer_mv:1;
865          uint32_t allow_intrabc:1;
866          uint32_t use_superres:1;
867          uint32_t allow_high_precision_mv:1;
868          uint32_t is_motion_mode_switchable:1;
869          uint32_t use_ref_frame_mvs:1;
870          uint32_t disable_frame_end_update_cdf:1;
871          uint32_t allow_warped_motion:1;
872       } pic_info_fields;
873 
874       uint8_t superres_scale_denominator;
875 
876       uint8_t interp_filter;
877       uint8_t filter_level[2];
878       uint8_t filter_level_u;
879       uint8_t filter_level_v;
880       struct {
881          uint8_t sharpness_level:3;
882          uint8_t mode_ref_delta_enabled:1;
883          uint8_t mode_ref_delta_update:1;
884       } loop_filter_info_fields;
885 
886       int8_t ref_deltas[8];
887       int8_t mode_deltas[2];
888 
889       uint8_t base_qindex;
890       int8_t y_dc_delta_q;
891       int8_t u_dc_delta_q;
892       int8_t u_ac_delta_q;
893       int8_t v_dc_delta_q;
894       int8_t v_ac_delta_q;
895 
896       struct {
897          uint16_t qm_y:4;
898          uint16_t qm_u:4;
899          uint16_t qm_v:4;
900       } qmatrix_fields;
901 
902       struct {
903          uint32_t delta_q_present_flag:1;
904          uint32_t log2_delta_q_res:2;
905          uint32_t delta_lf_present_flag:1;
906          uint32_t log2_delta_lf_res:2;
907          uint32_t delta_lf_multi:1;
908          uint32_t tx_mode:2;
909          uint32_t reference_select:1;
910          uint32_t reduced_tx_set_used:1;
911          uint32_t skip_mode_present:1;
912       } mode_control_fields;
913 
914       uint8_t cdef_damping_minus_3;
915       uint8_t cdef_bits;
916       uint8_t cdef_y_strengths[8];
917       uint8_t cdef_uv_strengths[8];
918 
919       struct {
920          uint16_t yframe_restoration_type:2;
921          uint16_t cbframe_restoration_type:2;
922          uint16_t crframe_restoration_type:2;
923       } loop_restoration_fields;
924 
925       uint16_t lr_unit_size[3];
926 
927       struct {
928          uint32_t wmtype;
929          int32_t wmmat[8];
930       } wm[7];
931 
932       uint32_t refresh_frame_flags;
933    } picture_parameter;
934 
935    struct {
936       uint32_t slice_data_size[256];
937       uint32_t slice_data_offset[256];
938    } slice_parameter;
939 };
940 
941 #ifdef __cplusplus
942 }
943 #endif
944 
945 #endif /* PIPE_VIDEO_STATE_H */
946