summaryrefslogtreecommitdiff
path: root/drivers/amvdec_ports/decoder/aml_mpeg4_parser.h (plain)
blob: 543c63137989fc2fef3310212e7f61954f487c36
1#ifndef AVCODEC_MPEG4VIDEO_H
2#define AVCODEC_MPEG4VIDEO_H
3
4#include "../utils/pixfmt.h"
5#include "../utils/common.h"
6
7//mpeg4 profile
8#define FF_PROFILE_MPEG4_SIMPLE 0
9#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
10#define FF_PROFILE_MPEG4_CORE 2
11#define FF_PROFILE_MPEG4_MAIN 3
12#define FF_PROFILE_MPEG4_N_BIT 4
13#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
14#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
15#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
16#define FF_PROFILE_MPEG4_HYBRID 8
17#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
18#define FF_PROFILE_MPEG4_CORE_SCALABLE 10
19#define FF_PROFILE_MPEG4_ADVANCED_CODING 11
20#define FF_PROFILE_MPEG4_ADVANCED_CORE 12
21#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
22#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
23#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
24
25// shapes
26#define RECT_SHAPE 0
27#define BIN_SHAPE 1
28#define BIN_ONLY_SHAPE 2
29#define GRAY_SHAPE 3
30
31#define SIMPLE_VO_TYPE 1
32#define CORE_VO_TYPE 3
33#define MAIN_VO_TYPE 4
34#define NBIT_VO_TYPE 5
35#define ARTS_VO_TYPE 10
36#define ACE_VO_TYPE 12
37#define SIMPLE_STUDIO_VO_TYPE 14
38#define CORE_STUDIO_VO_TYPE 15
39#define ADV_SIMPLE_VO_TYPE 17
40
41#define VOT_VIDEO_ID 1
42#define VOT_STILL_TEXTURE_ID 2
43
44#define FF_PROFILE_UNKNOWN -99
45#define FF_PROFILE_RESERVED -100
46
47// aspect_ratio_info
48#define EXTENDED_PAR 15
49
50//vol_sprite_usage / sprite_enable
51#define STATIC_SPRITE 1
52#define GMC_SPRITE 2
53
54#define MOTION_MARKER 0x1F001
55#define DC_MARKER 0x6B001
56
57#define VOS_STARTCODE 0x1B0
58#define USER_DATA_STARTCODE 0x1B2
59#define GOP_STARTCODE 0x1B3
60#define VISUAL_OBJ_STARTCODE 0x1B5
61#define VOP_STARTCODE 0x1B6
62#define SLICE_STARTCODE 0x1B7
63#define EXT_STARTCODE 0x1B8
64
65#define QUANT_MATRIX_EXT_ID 0x3
66
67/* smaller packets likely don't contain a real frame */
68#define MAX_NVOP_SIZE 19
69
70#define IS_3IV1 0
71
72#define CHROMA_420 1
73#define CHROMA_422 2
74#define CHROMA_444 3
75
76#define FF_ASPECT_EXTENDED 15
77
78#define AV_NOPTS_VALUE (LONG_MIN)
79
80/**
81 * Return value for header parsers if frame is not coded.
82 * */
83#define FRAME_SKIPPED 100
84
85enum AVPictureType {
86 AV_PICTURE_TYPE_NONE = 0, ///< Undefined
87 AV_PICTURE_TYPE_I, ///< Intra
88 AV_PICTURE_TYPE_P, ///< Predicted
89 AV_PICTURE_TYPE_B, ///< Bi-dir predicted
90 AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG-4
91 AV_PICTURE_TYPE_SI, ///< Switching Intra
92 AV_PICTURE_TYPE_SP, ///< Switching Predicted
93 AV_PICTURE_TYPE_BI, ///< BI type
94};
95
96struct VLC {
97 int bits;
98 short (*table)[2]; ///< code, bits
99 int table_size, table_allocated;
100};
101
102/**
103 * MpegEncContext.
104 */
105struct MpegEncContext {
106 struct mpeg4_dec_param *ctx;
107
108 /* the following parameters must be initialized before encoding */
109 int width, height;///< picture size. must be a multiple of 16
110 int codec_tag; ///< internal codec_tag upper case converted from avctx codec_tag
111 int picture_number; //FIXME remove, unclear definition
112
113 /** matrix transmitted in the bitstream */
114 u16 intra_matrix[64];
115 u16 chroma_intra_matrix[64];
116 u16 inter_matrix[64];
117 u16 chroma_inter_matrix[64];
118
119 /* MPEG-4 specific */
120 int studio_profile;
121 int time_base; ///< time in seconds of last I,P,S Frame
122 int quant_precision;
123 int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
124 int aspect_ratio_info; //FIXME remove
125 int sprite_warping_accuracy;
126 int data_partitioning; ///< data partitioning flag from header
127 int low_delay; ///< no reordering needed / has no B-frames
128 int vo_type;
129 int mpeg_quant;
130
131 /* divx specific, used to workaround (many) bugs in divx5 */
132 int divx_packed;
133
134 /* MPEG-2-specific - I wished not to have to support this mess. */
135 int progressive_sequence;
136
137 int progressive_frame;
138 int interlaced_dct;
139
140 int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replication)
141 const u8 *y_dc_scale_table; ///< qscale -> y_dc_scale table
142 const u8 *c_dc_scale_table; ///< qscale -> c_dc_scale table
143 int qscale; ///< QP
144 int chroma_qscale; ///< chroma QP
145 int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
146 int f_code; ///< forward MV resolution
147 int b_code; ///< backward MV resolution for B-frames (MPEG-4)
148 int no_rounding; /**< apply no rounding to motion compensation (MPEG-4, msmpeg4, ...)
149 for B-frames rounding mode is always 0 */
150 int last_time_base;
151 long time; ///< time of current frame
152 long last_non_b_time;
153 u16 pp_time; ///< time distance between the last 2 p,s,i frames
154 u16 pb_time; ///< time distance between the last b and p,s,i frame
155 u16 pp_field_time;
156 u16 pb_field_time; ///< like above, just for interlaced
157 int real_sprite_warping_points;
158 int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY]
159 int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY]
160 int mcsel;
161 int partitioned_frame; ///< is current frame partitioned
162 int top_field_first;
163 int alternate_scan;
164 int last_dc[3]; ///< last DC values for MPEG-1
165 int dct_precision;
166 int intra_dc_precision;
167 int frame_pred_frame_dct;
168 int q_scale_type;
169 int context_reinit;
170 int chroma_format;
171};
172
173struct mpeg4_dec_param {
174 struct MpegEncContext m;
175
176 /// number of bits to represent the fractional part of time
177 int time_increment_bits;
178 int shape;
179 int vol_sprite_usage;
180 int sprite_brightness_change;
181 int num_sprite_warping_points;
182 /// sprite trajectory points
183 u16 sprite_traj[4][2];
184 /// sprite shift [isChroma]
185 int sprite_shift[2];
186
187 // reversible vlc
188 int rvlc;
189 /// could this stream contain resync markers
190 int resync_marker;
191 /// time distance of first I -> B, used for interlaced B-frames
192 int t_frame;
193
194 int new_pred;
195 int enhancement_type;
196 int scalability;
197 int use_intra_dc_vlc;
198
199 /// QP above which the ac VLC should be used for intra dc
200 int intra_dc_threshold;
201
202 /* bug workarounds */
203 int divx_version;
204 int divx_build;
205 int xvid_build;
206 int lavc_build;
207
208 /// flag for having shown the warning about invalid Divx B-frames
209 int showed_packed_warning;
210 /** does the stream contain the low_delay flag,
211 * used to work around buggy encoders. */
212 int vol_control_parameters;
213 int cplx_estimation_trash_i;
214 int cplx_estimation_trash_p;
215 int cplx_estimation_trash_b;
216
217 struct VLC studio_intra_tab[12];
218 struct VLC studio_luma_dc;
219 struct VLC studio_chroma_dc;
220
221 int rgb;
222
223 struct AVRational time_base;
224 int ticks_per_frame;
225 enum AVPixelFormat pix_fmt;
226 struct AVRational sample_aspect_ratio;
227 enum AVColorPrimaries color_primaries;
228 enum AVColorTransferCharacteristic color_trc;
229 enum AVColorSpace colorspace;
230 enum AVColorRange color_range;
231 enum AVChromaLocation chroma_sample_location;
232 int err_recognition;
233 int idct_algo;
234 int bits_per_raw_sample;
235 int profile;
236 int level;
237 struct AVRational framerate;
238 int flags;
239};
240
241struct mpeg4_param_sets {
242 bool head_parsed;
243 /* currently active parameter sets */
244 struct mpeg4_dec_param dec_ps;
245};
246
247int mpeg4_decode_extradata_ps(u8 *buf, int size, struct mpeg4_param_sets *ps);
248
249#endif
250
251