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