• 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_inlines.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * see table 6-12 in the spec
43  */
44 enum pipe_mpeg12_picture_coding_type
45 {
46    PIPE_MPEG12_PICTURE_CODING_TYPE_I = 0x01,
47    PIPE_MPEG12_PICTURE_CODING_TYPE_P = 0x02,
48    PIPE_MPEG12_PICTURE_CODING_TYPE_B = 0x03,
49    PIPE_MPEG12_PICTURE_CODING_TYPE_D = 0x04
50 };
51 
52 /*
53  * see table 6-14 in the spec
54  */
55 enum pipe_mpeg12_picture_structure
56 {
57    PIPE_MPEG12_PICTURE_STRUCTURE_RESERVED = 0x00,
58    PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_TOP = 0x01,
59    PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_BOTTOM = 0x02,
60    PIPE_MPEG12_PICTURE_STRUCTURE_FRAME = 0x03
61 };
62 
63 /*
64  * flags for macroblock_type, see section 6.3.17.1 in the spec
65  */
66 enum pipe_mpeg12_macroblock_type
67 {
68    PIPE_MPEG12_MB_TYPE_QUANT = 0x01,
69    PIPE_MPEG12_MB_TYPE_MOTION_FORWARD = 0x02,
70    PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD = 0x04,
71    PIPE_MPEG12_MB_TYPE_PATTERN = 0x08,
72    PIPE_MPEG12_MB_TYPE_INTRA = 0x10
73 };
74 
75 /*
76  * flags for motion_type, see table 6-17 and 6-18 in the spec
77  */
78 enum pipe_mpeg12_motion_type
79 {
80    PIPE_MPEG12_MO_TYPE_RESERVED = 0x00,
81    PIPE_MPEG12_MO_TYPE_FIELD = 0x01,
82    PIPE_MPEG12_MO_TYPE_FRAME = 0x02,
83    PIPE_MPEG12_MO_TYPE_16x8 = 0x02,
84    PIPE_MPEG12_MO_TYPE_DUAL_PRIME = 0x03
85 };
86 
87 /*
88  * see section 6.3.17.1 and table 6-19 in the spec
89  */
90 enum pipe_mpeg12_dct_type
91 {
92    PIPE_MPEG12_DCT_TYPE_FRAME = 0,
93    PIPE_MPEG12_DCT_TYPE_FIELD = 1
94 };
95 
96 enum pipe_mpeg12_field_select
97 {
98    PIPE_MPEG12_FS_FIRST_FORWARD = 0x01,
99    PIPE_MPEG12_FS_FIRST_BACKWARD = 0x02,
100    PIPE_MPEG12_FS_SECOND_FORWARD = 0x04,
101    PIPE_MPEG12_FS_SECOND_BACKWARD = 0x08
102 };
103 
104 enum pipe_h264_slice_type
105 {
106    PIPE_H264_SLICE_TYPE_P = 0x0,
107    PIPE_H264_SLICE_TYPE_B = 0x1,
108    PIPE_H264_SLICE_TYPE_I = 0x2,
109    PIPE_H264_SLICE_TYPE_SP = 0x3,
110    PIPE_H264_SLICE_TYPE_SI = 0x4
111 };
112 
113 enum pipe_h264_enc_picture_type
114 {
115    PIPE_H264_ENC_PICTURE_TYPE_P = 0x00,
116    PIPE_H264_ENC_PICTURE_TYPE_B = 0x01,
117    PIPE_H264_ENC_PICTURE_TYPE_I = 0x02,
118    PIPE_H264_ENC_PICTURE_TYPE_IDR = 0x03,
119    PIPE_H264_ENC_PICTURE_TYPE_SKIP = 0x04
120 };
121 
122 enum pipe_h264_enc_rate_control_method
123 {
124    PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE = 0x00,
125    PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT_SKIP = 0x01,
126    PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE_SKIP = 0x02,
127    PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT = 0x03,
128    PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE = 0x04
129 };
130 
131 struct pipe_picture_desc
132 {
133    enum pipe_video_profile profile;
134    enum pipe_video_entrypoint entry_point;
135 };
136 
137 struct pipe_quant_matrix
138 {
139    enum pipe_video_format codec;
140 };
141 
142 struct pipe_macroblock
143 {
144    enum pipe_video_format codec;
145 };
146 
147 struct pipe_mpeg12_picture_desc
148 {
149    struct pipe_picture_desc base;
150 
151    unsigned picture_coding_type;
152    unsigned picture_structure;
153    unsigned frame_pred_frame_dct;
154    unsigned q_scale_type;
155    unsigned alternate_scan;
156    unsigned intra_vlc_format;
157    unsigned concealment_motion_vectors;
158    unsigned intra_dc_precision;
159    unsigned f_code[2][2];
160    unsigned top_field_first;
161    unsigned full_pel_forward_vector;
162    unsigned full_pel_backward_vector;
163    unsigned num_slices;
164 
165    const uint8_t *intra_matrix;
166    const uint8_t *non_intra_matrix;
167 
168    struct pipe_video_buffer *ref[2];
169 };
170 
171 struct pipe_mpeg12_macroblock
172 {
173    struct pipe_macroblock base;
174 
175    /* see section 6.3.17 in the spec */
176    unsigned short x, y;
177 
178    /* see section 6.3.17.1 in the spec */
179    unsigned char macroblock_type;
180 
181    union {
182       struct {
183          /* see table 6-17 in the spec */
184          unsigned int frame_motion_type:2;
185 
186          /* see table 6-18 in the spec */
187          unsigned int field_motion_type:2;
188 
189          /* see table 6-19 in the spec */
190          unsigned int dct_type:1;
191       } bits;
192       unsigned int value;
193    } macroblock_modes;
194 
195     /* see section 6.3.17.2 in the spec */
196    unsigned char motion_vertical_field_select;
197 
198    /* see Table 7-7 in the spec */
199    short PMV[2][2][2];
200 
201    /* see figure 6.10-12 in the spec */
202    unsigned short coded_block_pattern;
203 
204    /* see figure 6.10-12 in the spec */
205    short *blocks;
206 
207    /* Number of skipped macroblocks after this macroblock */
208    unsigned short num_skipped_macroblocks;
209 };
210 
211 struct pipe_mpeg4_picture_desc
212 {
213    struct pipe_picture_desc base;
214 
215    int32_t trd[2];
216    int32_t trb[2];
217    uint16_t vop_time_increment_resolution;
218    uint8_t vop_coding_type;
219    uint8_t vop_fcode_forward;
220    uint8_t vop_fcode_backward;
221    uint8_t resync_marker_disable;
222    uint8_t interlaced;
223    uint8_t quant_type;
224    uint8_t quarter_sample;
225    uint8_t short_video_header;
226    uint8_t rounding_control;
227    uint8_t alternate_vertical_scan_flag;
228    uint8_t top_field_first;
229 
230    const uint8_t *intra_matrix;
231    const uint8_t *non_intra_matrix;
232 
233    struct pipe_video_buffer *ref[2];
234 };
235 
236 struct pipe_vc1_picture_desc
237 {
238    struct pipe_picture_desc base;
239 
240    uint32_t slice_count;
241    uint8_t picture_type;
242    uint8_t frame_coding_mode;
243    uint8_t postprocflag;
244    uint8_t pulldown;
245    uint8_t interlace;
246    uint8_t tfcntrflag;
247    uint8_t finterpflag;
248    uint8_t psf;
249    uint8_t dquant;
250    uint8_t panscan_flag;
251    uint8_t refdist_flag;
252    uint8_t quantizer;
253    uint8_t extended_mv;
254    uint8_t extended_dmv;
255    uint8_t overlap;
256    uint8_t vstransform;
257    uint8_t loopfilter;
258    uint8_t fastuvmc;
259    uint8_t range_mapy_flag;
260    uint8_t range_mapy;
261    uint8_t range_mapuv_flag;
262    uint8_t range_mapuv;
263    uint8_t multires;
264    uint8_t syncmarker;
265    uint8_t rangered;
266    uint8_t maxbframes;
267    uint8_t deblockEnable;
268    uint8_t pquant;
269 
270    struct pipe_video_buffer *ref[2];
271 };
272 
273 struct pipe_h264_sps
274 {
275    uint8_t  level_idc;
276    uint8_t  chroma_format_idc;
277    uint8_t  separate_colour_plane_flag;
278    uint8_t  bit_depth_luma_minus8;
279    uint8_t  bit_depth_chroma_minus8;
280    uint8_t  seq_scaling_matrix_present_flag;
281    uint8_t  ScalingList4x4[6][16];
282    uint8_t  ScalingList8x8[6][64];
283    uint8_t  log2_max_frame_num_minus4;
284    uint8_t  pic_order_cnt_type;
285    uint8_t  log2_max_pic_order_cnt_lsb_minus4;
286    uint8_t  delta_pic_order_always_zero_flag;
287    int32_t  offset_for_non_ref_pic;
288    int32_t  offset_for_top_to_bottom_field;
289    uint8_t  num_ref_frames_in_pic_order_cnt_cycle;
290    int32_t  offset_for_ref_frame[256];
291    uint8_t  max_num_ref_frames;
292    uint8_t  frame_mbs_only_flag;
293    uint8_t  mb_adaptive_frame_field_flag;
294    uint8_t  direct_8x8_inference_flag;
295 };
296 
297 struct pipe_h264_pps
298 {
299    struct pipe_h264_sps *sps;
300 
301    uint8_t  entropy_coding_mode_flag;
302    uint8_t  bottom_field_pic_order_in_frame_present_flag;
303    uint8_t  num_slice_groups_minus1;
304    uint8_t  slice_group_map_type;
305    uint8_t  slice_group_change_rate_minus1;
306    uint8_t  num_ref_idx_l0_default_active_minus1;
307    uint8_t  num_ref_idx_l1_default_active_minus1;
308    uint8_t  weighted_pred_flag;
309    uint8_t  weighted_bipred_idc;
310    int8_t   pic_init_qp_minus26;
311    int8_t   chroma_qp_index_offset;
312    uint8_t  deblocking_filter_control_present_flag;
313    uint8_t  constrained_intra_pred_flag;
314    uint8_t  redundant_pic_cnt_present_flag;
315    uint8_t  ScalingList4x4[6][16];
316    uint8_t  ScalingList8x8[6][64];
317    uint8_t  transform_8x8_mode_flag;
318    int8_t   second_chroma_qp_index_offset;
319 };
320 
321 struct pipe_h264_picture_desc
322 {
323    struct pipe_picture_desc base;
324 
325    struct pipe_h264_pps *pps;
326 
327    /* slice header */
328    uint32_t frame_num;
329    uint8_t  field_pic_flag;
330    uint8_t  bottom_field_flag;
331    uint8_t  num_ref_idx_l0_active_minus1;
332    uint8_t  num_ref_idx_l1_active_minus1;
333 
334    uint32_t slice_count;
335    int32_t  field_order_cnt[2];
336    bool     is_reference;
337    uint8_t  num_ref_frames;
338 
339    bool     is_long_term[16];
340    bool     top_is_reference[16];
341    bool     bottom_is_reference[16];
342    uint32_t field_order_cnt_list[16][2];
343    uint32_t frame_num_list[16];
344 
345    struct pipe_video_buffer *ref[16];
346 };
347 
348 struct pipe_h264_enc_rate_control
349 {
350    enum pipe_h264_enc_rate_control_method rate_ctrl_method;
351    unsigned target_bitrate;
352    unsigned peak_bitrate;
353    unsigned frame_rate_num;
354    unsigned frame_rate_den;
355    unsigned vbv_buffer_size;
356    unsigned vbv_buf_lv;
357    unsigned target_bits_picture;
358    unsigned peak_bits_picture_integer;
359    unsigned peak_bits_picture_fraction;
360    unsigned fill_data_enable;
361    unsigned enforce_hrd;
362 };
363 
364 struct pipe_h264_enc_motion_estimation
365 {
366    unsigned motion_est_quarter_pixel;
367    unsigned enc_disable_sub_mode;
368    unsigned lsmvert;
369    unsigned enc_en_ime_overw_dis_subm;
370    unsigned enc_ime_overw_dis_subm_no;
371    unsigned enc_ime2_search_range_x;
372    unsigned enc_ime2_search_range_y;
373 };
374 
375 struct pipe_h264_enc_pic_control
376 {
377    unsigned enc_cabac_enable;
378    unsigned enc_constraint_set_flags;
379 };
380 
381 struct pipe_h264_enc_picture_desc
382 {
383    struct pipe_picture_desc base;
384 
385    struct pipe_h264_enc_rate_control rate_ctrl;
386 
387    struct pipe_h264_enc_motion_estimation motion_est;
388    struct pipe_h264_enc_pic_control pic_ctrl;
389 
390    unsigned quant_i_frames;
391    unsigned quant_p_frames;
392    unsigned quant_b_frames;
393 
394    enum pipe_h264_enc_picture_type picture_type;
395    unsigned frame_num;
396    unsigned frame_num_cnt;
397    unsigned p_remain;
398    unsigned i_remain;
399    unsigned idr_pic_id;
400    unsigned gop_cnt;
401    unsigned pic_order_cnt;
402    unsigned ref_idx_l0;
403    unsigned ref_idx_l1;
404    unsigned gop_size;
405    unsigned ref_pic_mode;
406 
407    bool not_referenced;
408    bool is_idr;
409    bool enable_vui;
410    unsigned int frame_idx[32];
411 };
412 
413 struct pipe_h265_sps
414 {
415    uint8_t chroma_format_idc;
416    uint8_t separate_colour_plane_flag;
417    uint32_t pic_width_in_luma_samples;
418    uint32_t pic_height_in_luma_samples;
419    uint8_t bit_depth_luma_minus8;
420    uint8_t bit_depth_chroma_minus8;
421    uint8_t log2_max_pic_order_cnt_lsb_minus4;
422    uint8_t sps_max_dec_pic_buffering_minus1;
423    uint8_t log2_min_luma_coding_block_size_minus3;
424    uint8_t log2_diff_max_min_luma_coding_block_size;
425    uint8_t log2_min_transform_block_size_minus2;
426    uint8_t log2_diff_max_min_transform_block_size;
427    uint8_t max_transform_hierarchy_depth_inter;
428    uint8_t max_transform_hierarchy_depth_intra;
429    uint8_t scaling_list_enabled_flag;
430    uint8_t ScalingList4x4[6][16];
431    uint8_t ScalingList8x8[6][64];
432    uint8_t ScalingList16x16[6][64];
433    uint8_t ScalingList32x32[2][64];
434    uint8_t ScalingListDCCoeff16x16[6];
435    uint8_t ScalingListDCCoeff32x32[2];
436    uint8_t amp_enabled_flag;
437    uint8_t sample_adaptive_offset_enabled_flag;
438    uint8_t pcm_enabled_flag;
439    uint8_t pcm_sample_bit_depth_luma_minus1;
440    uint8_t pcm_sample_bit_depth_chroma_minus1;
441    uint8_t log2_min_pcm_luma_coding_block_size_minus3;
442    uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
443    uint8_t pcm_loop_filter_disabled_flag;
444    uint8_t num_short_term_ref_pic_sets;
445    uint8_t long_term_ref_pics_present_flag;
446    uint8_t num_long_term_ref_pics_sps;
447    uint8_t sps_temporal_mvp_enabled_flag;
448    uint8_t strong_intra_smoothing_enabled_flag;
449 };
450 
451 struct pipe_h265_pps
452 {
453    struct pipe_h265_sps *sps;
454 
455    uint8_t dependent_slice_segments_enabled_flag;
456    uint8_t output_flag_present_flag;
457    uint8_t num_extra_slice_header_bits;
458    uint8_t sign_data_hiding_enabled_flag;
459    uint8_t cabac_init_present_flag;
460    uint8_t num_ref_idx_l0_default_active_minus1;
461    uint8_t num_ref_idx_l1_default_active_minus1;
462    int8_t init_qp_minus26;
463    uint8_t constrained_intra_pred_flag;
464    uint8_t transform_skip_enabled_flag;
465    uint8_t cu_qp_delta_enabled_flag;
466    uint8_t diff_cu_qp_delta_depth;
467    int8_t pps_cb_qp_offset;
468    int8_t pps_cr_qp_offset;
469    uint8_t pps_slice_chroma_qp_offsets_present_flag;
470    uint8_t weighted_pred_flag;
471    uint8_t weighted_bipred_flag;
472    uint8_t transquant_bypass_enabled_flag;
473    uint8_t tiles_enabled_flag;
474    uint8_t entropy_coding_sync_enabled_flag;
475    uint8_t num_tile_columns_minus1;
476    uint8_t num_tile_rows_minus1;
477    uint8_t uniform_spacing_flag;
478    uint16_t column_width_minus1[20];
479    uint16_t row_height_minus1[22];
480    uint8_t loop_filter_across_tiles_enabled_flag;
481    uint8_t pps_loop_filter_across_slices_enabled_flag;
482    uint8_t deblocking_filter_control_present_flag;
483    uint8_t deblocking_filter_override_enabled_flag;
484    uint8_t pps_deblocking_filter_disabled_flag;
485    int8_t pps_beta_offset_div2;
486    int8_t pps_tc_offset_div2;
487    uint8_t lists_modification_present_flag;
488    uint8_t log2_parallel_merge_level_minus2;
489    uint8_t slice_segment_header_extension_present_flag;
490 };
491 
492 struct pipe_h265_picture_desc
493 {
494    struct pipe_picture_desc base;
495 
496    struct pipe_h265_pps *pps;
497 
498    uint8_t IDRPicFlag;
499    uint8_t RAPPicFlag;
500    uint8_t CurrRpsIdx;
501    uint32_t NumPocTotalCurr;
502    uint32_t NumDeltaPocsOfRefRpsIdx;
503    uint32_t NumShortTermPictureSliceHeaderBits;
504    uint32_t NumLongTermPictureSliceHeaderBits;
505 
506    int32_t CurrPicOrderCntVal;
507    struct pipe_video_buffer *ref[16];
508    int32_t PicOrderCntVal[16];
509    uint8_t IsLongTerm[16];
510    uint8_t NumPocStCurrBefore;
511    uint8_t NumPocStCurrAfter;
512    uint8_t NumPocLtCurr;
513    uint8_t RefPicSetStCurrBefore[8];
514    uint8_t RefPicSetStCurrAfter[8];
515    uint8_t RefPicSetLtCurr[8];
516    uint8_t RefPicList[2][15];
517    bool UseRefPicList;
518 };
519 
520 #ifdef __cplusplus
521 }
522 #endif
523 
524 #endif /* PIPE_VIDEO_STATE_H */
525