1 2 #ifndef __DIRAC_PARSE_H__ 3 #define __DIRAC_PARSE_H__ 4 5 #include <glib.h> 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 #ifndef TRUE 12 #define TRUE 1 13 #endif 14 #ifndef FALSE 15 #define FALSE 0 16 #endif 17 18 typedef enum _SchroParseCode { 19 SCHRO_PARSE_CODE_SEQUENCE_HEADER = 0x00, 20 SCHRO_PARSE_CODE_END_OF_SEQUENCE = 0x10, 21 SCHRO_PARSE_CODE_AUXILIARY_DATA = 0x20, 22 SCHRO_PARSE_CODE_PADDING = 0x30, 23 24 SCHRO_PARSE_CODE_INTRA_REF = 0x0c, 25 SCHRO_PARSE_CODE_INTRA_NON_REF = 0x08, 26 SCHRO_PARSE_CODE_INTRA_REF_NOARITH = 0x4c, 27 SCHRO_PARSE_CODE_INTRA_NON_REF_NOARITH = 0x48, 28 29 SCHRO_PARSE_CODE_INTER_REF_1 = 0x0d, 30 SCHRO_PARSE_CODE_INTER_REF_1_NOARITH = 0x4d, 31 SCHRO_PARSE_CODE_INTER_REF_2 = 0x0e, 32 SCHRO_PARSE_CODE_INTER_REF_2_NOARITH = 0x4e, 33 34 SCHRO_PARSE_CODE_INTER_NON_REF_1 = 0x09, 35 SCHRO_PARSE_CODE_INTER_NON_REF_1_NOARITH = 0x49, 36 SCHRO_PARSE_CODE_INTER_NON_REF_2 = 0x0a, 37 SCHRO_PARSE_CODE_INTER_NON_REF_2_NOARITH = 0x4a, 38 39 SCHRO_PARSE_CODE_LD_INTRA_REF = 0xcc, 40 SCHRO_PARSE_CODE_LD_INTRA_NON_REF = 0xc8 41 } SchroParseCode; 42 43 #define SCHRO_PARSE_CODE_PICTURE(is_ref,n_refs,is_lowdelay,is_noarith) \ 44 (8 | ((is_ref)<<2) | (n_refs) | ((is_lowdelay)<<7) | ((is_noarith)<<6)) 45 46 #define SCHRO_PARSE_CODE_IS_SEQ_HEADER(x) ((x) == SCHRO_PARSE_CODE_SEQUENCE_HEADER) 47 #define SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(x) ((x) == SCHRO_PARSE_CODE_END_OF_SEQUENCE) 48 #define SCHRO_PARSE_CODE_IS_AUXILIARY_DATA(x) ((x) == SCHRO_PARSE_CODE_AUXILIARY_DATA) 49 #define SCHRO_PARSE_CODE_IS_PADDING(x) ((x) == SCHRO_PARSE_CODE_PADDING) 50 #define SCHRO_PARSE_CODE_IS_PICTURE(x) ((x) & 0x8) 51 #define SCHRO_PARSE_CODE_IS_LOW_DELAY(x) (((x) & 0x88) == 0x88) 52 #define SCHRO_PARSE_CODE_IS_CORE_SYNTAX(x) (((x) & 0x88) == 0x08) 53 #define SCHRO_PARSE_CODE_USING_AC(x) (((x) & 0x48) == 0x08) 54 #define SCHRO_PARSE_CODE_IS_REFERENCE(x) (((x) & 0xc) == 0x0c) 55 #define SCHRO_PARSE_CODE_IS_NON_REFERENCE(x) (((x) & 0xc) == 0x08) 56 #define SCHRO_PARSE_CODE_NUM_REFS(x) ((x) & 0x3) 57 #define SCHRO_PARSE_CODE_IS_INTRA(x) (SCHRO_PARSE_CODE_IS_PICTURE(x) && SCHRO_PARSE_CODE_NUM_REFS(x) == 0) 58 #define SCHRO_PARSE_CODE_IS_INTER(x) (SCHRO_PARSE_CODE_IS_PICTURE(x) && SCHRO_PARSE_CODE_NUM_REFS(x) > 0) 59 60 #define SCHRO_PARSE_HEADER_SIZE (4+1+4+4) 61 62 typedef enum _SchroVideoFormatEnum { 63 SCHRO_VIDEO_FORMAT_CUSTOM = 0, 64 SCHRO_VIDEO_FORMAT_QSIF, 65 SCHRO_VIDEO_FORMAT_QCIF, 66 SCHRO_VIDEO_FORMAT_SIF, 67 SCHRO_VIDEO_FORMAT_CIF, 68 SCHRO_VIDEO_FORMAT_4SIF, 69 SCHRO_VIDEO_FORMAT_4CIF, 70 SCHRO_VIDEO_FORMAT_SD480I_60, 71 SCHRO_VIDEO_FORMAT_SD576I_50, 72 SCHRO_VIDEO_FORMAT_HD720P_60, 73 SCHRO_VIDEO_FORMAT_HD720P_50, 74 SCHRO_VIDEO_FORMAT_HD1080I_60, 75 SCHRO_VIDEO_FORMAT_HD1080I_50, 76 SCHRO_VIDEO_FORMAT_HD1080P_60, 77 SCHRO_VIDEO_FORMAT_HD1080P_50, 78 SCHRO_VIDEO_FORMAT_DC2K_24, 79 SCHRO_VIDEO_FORMAT_DC4K_24 80 } SchroVideoFormatEnum; 81 82 typedef enum _SchroChromaFormat { 83 SCHRO_CHROMA_444 = 0, 84 SCHRO_CHROMA_422, 85 SCHRO_CHROMA_420 86 } SchroChromaFormat; 87 88 #define SCHRO_CHROMA_FORMAT_H_SHIFT(format) (((format) == SCHRO_CHROMA_444)?0:1) 89 #define SCHRO_CHROMA_FORMAT_V_SHIFT(format) (((format) == SCHRO_CHROMA_420)?1:0) 90 91 typedef enum _SchroSignalRange { 92 SCHRO_SIGNAL_RANGE_CUSTOM = 0, 93 SCHRO_SIGNAL_RANGE_8BIT_FULL = 1, 94 SCHRO_SIGNAL_RANGE_8BIT_VIDEO = 2, 95 SCHRO_SIGNAL_RANGE_10BIT_VIDEO = 3, 96 SCHRO_SIGNAL_RANGE_12BIT_VIDEO = 4 97 } SchroSignalRange; 98 99 typedef enum _SchroColourSpec { 100 SCHRO_COLOUR_SPEC_CUSTOM = 0, 101 SCHRO_COLOUR_SPEC_SDTV_525 = 1, 102 SCHRO_COLOUR_SPEC_SDTV_625 = 2, 103 SCHRO_COLOUR_SPEC_HDTV = 3, 104 SCHRO_COLOUR_SPEC_CINEMA = 4 105 } SchroColourSpec; 106 107 typedef enum _SchroColourPrimaries { 108 SCHRO_COLOUR_PRIMARY_HDTV = 0, 109 SCHRO_COLOUR_PRIMARY_SDTV_525 = 1, 110 SCHRO_COLOUR_PRIMARY_SDTV_625 = 2, 111 SCHRO_COLOUR_PRIMARY_CINEMA = 3 112 } SchroColourPrimaries; 113 114 typedef enum _SchroColourMatrix { 115 SCHRO_COLOUR_MATRIX_HDTV = 0, 116 SCHRO_COLOUR_MATRIX_SDTV = 1, 117 SCHRO_COLOUR_MATRIX_REVERSIBLE = 2 118 }SchroColourMatrix; 119 120 typedef enum _SchroTransferFunction { 121 SCHRO_TRANSFER_CHAR_TV_GAMMA = 0, 122 SCHRO_TRANSFER_CHAR_EXTENDED_GAMUT = 1, 123 SCHRO_TRANSFER_CHAR_LINEAR = 2, 124 SCHRO_TRANSFER_CHAR_DCI_GAMMA = 3 125 } SchroTransferFunction; 126 127 128 129 typedef struct _DiracSequenceHeader DiracSequenceHeader; 130 131 struct _DiracSequenceHeader { 132 int major_version; 133 int minor_version; 134 int profile; 135 int level; 136 137 int index; 138 int width; 139 int height; 140 int chroma_format; 141 142 int interlaced; 143 int top_field_first; 144 145 int frame_rate_numerator; 146 int frame_rate_denominator; 147 int aspect_ratio_numerator; 148 int aspect_ratio_denominator; 149 150 int clean_width; 151 int clean_height; 152 int left_offset; 153 int top_offset; 154 155 int luma_offset; 156 int luma_excursion; 157 int chroma_offset; 158 int chroma_excursion; 159 160 int colour_primaries; 161 int colour_matrix; 162 int transfer_function; 163 164 int interlaced_coding; 165 166 int unused0; 167 int unused1; 168 int unused2; 169 }; 170 171 G_GNUC_INTERNAL 172 int gst_dirac_sequence_header_parse (DiracSequenceHeader *header, 173 unsigned char *data, int length); 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 #endif 180 181