1 #ifndef _MPEG2_H 2 #define _MPEG2_H 3 4 /** 5 * mpeg2.h 6 * ------- 7 * This file contains all the necessary enumerations and structures needed from 8 * the MPEG-2 Specification. 9 */ 10 11 /* Max Pan-Scan offsets */ 12 #define MPEG2_MAX_VID_OFFSETS 3 13 14 /* Quantization matrix size */ 15 #define MPEG2_QUANT_MAT_SIZE 64 16 17 /* MPEG2 Start Code Values */ 18 typedef enum { 19 MPEG2_SC_PICTURE = 0x00, 20 MPEG2_SC_SLICE_HDR = 0x01, 21 MPEG2_SC_SLICE_MIN = 0x01, 22 MPEG2_SC_SLICE_MAX = 0xAF, 23 MPEG2_SC_USER_DATA = 0xB2, 24 MPEG2_SC_SEQ_HDR = 0xB3, 25 MPEG2_SC_SEQ_ERR = 0xB4, 26 MPEG2_SC_EXT = 0xB5, 27 MPEG2_SC_SEQ_END = 0xB7, 28 MPEG2_SC_GROUP = 0xB8, 29 MPEG2_SC_SYS_MIN = 0xB9, 30 MPEG2_SC_SYS_MAX = 0xFF, 31 MPEG2_SC_ALL = 0xFF 32 } mpeg2_start_codes; 33 34 /* MPEG2 Extension Start Code ID */ 35 typedef enum { 36 MPEG2_EXT_SEQ = 1, 37 MPEG2_EXT_SEQ_DISP = 2, 38 MPEG2_EXT_QUANT_MAT = 3, 39 MPEG2_EXT_COPYRIGHT = 4, 40 MPEG2_EXT_SEQ_SCAL = 5, 41 MPEG2_EXT_PIC_DISP = 7, 42 MPEG2_EXT_PIC_CODING = 8, 43 MPEG2_EXT_PIC_SPA_SCAL = 9, 44 MPEG2_EXT_PIC_TEMP_SCAL = 10, 45 MPEG2_EXT_ALL = 11 46 } mpeg2_ext_start_codes; 47 48 /* MPEG2 Picture Coding Type Values */ 49 typedef enum { 50 MPEG2_PC_TYPE_FORBIDDEN = 0, 51 MPEG2_PC_TYPE_I = 1, 52 MPEG2_PC_TYPE_P = 2, 53 MPEG2_PC_TYPE_B = 3 54 } mpeg2_picture_type; 55 56 /* MPEG2 Picture Structure Type Values */ 57 typedef enum { 58 MPEG2_PIC_STRUCT_RESERVED = 0, 59 MPEG2_PIC_STRUCT_TOP = 1, 60 MPEG2_PIC_STRUCT_BOTTOM = 2, 61 MPEG2_PIC_STRUCT_FRAME = 3 62 } mpeg2_picture_structure; 63 64 /* MPEG2 Chroma Format Values */ 65 typedef enum { 66 MPEG2_CF_RESERVED = 0, 67 MPEG2_CF_420 = 1, 68 MPEG2_CF_422 = 2, 69 MPEG2_CF_444 = 3 70 } mpeg2_chroma_format; 71 72 /* MPEG2 Parser Structures */ 73 /* Sequence Header Info */ 74 struct mpeg2_sequence_hdr_info 75 { 76 uint32_t horizontal_size_value; 77 uint32_t vertical_size_value; 78 uint32_t aspect_ratio_information; 79 uint32_t frame_rate_code; 80 uint32_t bit_rate_value; 81 uint32_t vbv_buffer_size_value; 82 uint32_t constrained_parameters_flag; 83 }; 84 85 /* Group of Pictures Header Info */ 86 struct mpeg2_gop_hdr_info 87 { 88 uint32_t closed_gop; 89 uint32_t broken_link; 90 }; 91 92 /* Picture Header */ 93 struct mpeg2_picture_hdr_info 94 { 95 uint32_t temporal_reference; 96 uint32_t picture_coding_type; 97 uint32_t full_pel_forward_vect; 98 uint32_t forward_f_code; 99 uint32_t full_pel_backward_vect; 100 uint32_t backward_f_code; 101 }; 102 103 /* Sequence Extension Info */ 104 struct mpeg2_sequence_ext_info 105 { 106 uint32_t profile_and_level_indication; 107 uint32_t progressive_sequence; 108 uint32_t chroma_format; 109 uint32_t horizontal_size_extension; 110 uint32_t vertical_size_extension; 111 uint32_t bit_rate_extension; 112 uint32_t vbv_buffer_size_extension; 113 uint32_t frame_rate_extension_n; 114 uint32_t frame_rate_extension_d; 115 }; 116 117 /* Sequence Display Extension Info */ 118 struct mpeg2_sequence_disp_ext_info 119 { 120 uint32_t video_format; 121 uint32_t colour_description; 122 uint32_t colour_primaries; 123 uint32_t transfer_characteristics; 124 uint32_t display_horizontal_size; 125 uint32_t display_vertical_size; 126 }; 127 128 /* Sequence scalable extension Info */ 129 struct mpeg2_sequence_scal_ext_info 130 { 131 uint32_t scalable_mode; 132 }; 133 134 /* Picture Coding Extension */ 135 struct mpeg2_picture_coding_ext_info 136 { 137 uint32_t fcode00; 138 uint32_t fcode01; 139 uint32_t fcode10; 140 uint32_t fcode11; 141 uint32_t intra_dc_precision; 142 uint32_t picture_structure; 143 uint32_t top_field_first; 144 uint32_t frame_pred_frame_dct; 145 uint32_t concealment_motion_vectors; 146 uint32_t q_scale_type; 147 uint32_t intra_vlc_format; 148 uint32_t alternate_scan; 149 uint32_t repeat_first_field; 150 uint32_t chroma_420_type; 151 uint32_t progressive_frame; 152 uint32_t composite_display_flag; 153 }; 154 155 /* Picture Display Extension */ 156 struct mpeg2_picture_disp_ext_info 157 { 158 uint32_t frame_center_horizontal_offset[MPEG2_MAX_VID_OFFSETS]; 159 uint32_t frame_center_vertical_offset[MPEG2_MAX_VID_OFFSETS]; 160 }; 161 162 /* Quantization Matrix Extension */ 163 struct mpeg2_quant_ext_info 164 { 165 uint32_t load_intra_quantiser_matrix; 166 uint32_t load_non_intra_quantiser_matrix; 167 uint32_t load_chroma_intra_quantiser_matrix; 168 uint32_t load_chroma_non_intra_quantiser_matrix; 169 }; 170 171 /* Quantization Matrices */ 172 struct mpeg2_quant_matrices 173 { 174 uint8_t intra_quantiser_matrix[MPEG2_QUANT_MAT_SIZE]; 175 uint8_t non_intra_quantiser_matrix[MPEG2_QUANT_MAT_SIZE]; 176 uint8_t chroma_intra_quantiser_matrix[MPEG2_QUANT_MAT_SIZE]; 177 uint8_t chroma_non_intra_quantiser_matrix[MPEG2_QUANT_MAT_SIZE]; 178 }; 179 180 /* MPEG2 Info */ 181 struct mpeg2_info 182 { 183 struct mpeg2_sequence_hdr_info seq_hdr; 184 struct mpeg2_gop_hdr_info gop_hdr; 185 struct mpeg2_picture_hdr_info pic_hdr; 186 struct mpeg2_sequence_ext_info seq_ext; 187 struct mpeg2_sequence_disp_ext_info seq_disp_ext; 188 struct mpeg2_sequence_scal_ext_info seq_scal_ext; 189 struct mpeg2_picture_coding_ext_info pic_cod_ext; 190 struct mpeg2_picture_disp_ext_info pic_disp_ext; 191 struct mpeg2_quant_ext_info qnt_ext; 192 struct mpeg2_quant_matrices qnt_mat; 193 }; 194 195 #endif 196