blob: de1292ddd68f81e5d5f03e1abe6a16497381579d
1 | #ifndef AML_MPEG12_PARSER_H |
2 | #define AML_MPEG12_PARSER_H |
3 | |
4 | #include "../utils/pixfmt.h" |
5 | #include "../utils/common.h" |
6 | |
7 | /* Start codes. */ |
8 | #define SEQ_END_CODE 0x000001b7 |
9 | #define SEQ_START_CODE 0x000001b3 |
10 | #define GOP_START_CODE 0x000001b8 |
11 | #define PICTURE_START_CODE 0x00000100 |
12 | #define SLICE_MIN_START_CODE 0x00000101 |
13 | #define SLICE_MAX_START_CODE 0x000001af |
14 | #define EXT_START_CODE 0x000001b5 |
15 | #define USER_START_CODE 0x000001b2 |
16 | #define SLICE_START_CODE 0x000001b7 |
17 | |
18 | enum AVFieldOrder { |
19 | AV_FIELD_UNKNOWN, |
20 | AV_FIELD_PROGRESSIVE, |
21 | AV_FIELD_TT, //< Top coded_first, top displayed first |
22 | AV_FIELD_BB, //< Bottom coded first, bottom displayed first |
23 | AV_FIELD_TB, //< Top coded first, bottom displayed first |
24 | AV_FIELD_BT, //< Bottom coded first, top displayed first |
25 | }; |
26 | |
27 | struct MpvParseContext { |
28 | struct AVRational frame_rate; |
29 | int progressive_sequence; |
30 | int width, height; |
31 | |
32 | int repeat_pict; /* XXX: Put it back in AVCodecContext. */ |
33 | int pict_type; /* XXX: Put it back in AVCodecContext. */ |
34 | enum AVFieldOrder field_order; |
35 | int format; |
36 | /** |
37 | * Dimensions of the coded video. |
38 | */ |
39 | int coded_width; |
40 | int coded_height; |
41 | /** |
42 | * For some codecs, the time base is closer to the field rate than the frame rate. |
43 | * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration |
44 | * if no telecine is used ... |
45 | * |
46 | * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. |
47 | */ |
48 | int ticks_per_frame; |
49 | /** |
50 | * Size of the frame reordering buffer in the decoder. |
51 | * For MPEG-2 it is 1 IPB or 0 low delay IP. |
52 | * - encoding: Set by libavcodec. |
53 | * - decoding: Set by libavcodec. |
54 | */ |
55 | int has_b_frames; |
56 | /** |
57 | * - decoding: For codecs that store a framerate value in the compressed |
58 | * bitstream, the decoder may export it here. { 0, 1} when |
59 | * unknown. |
60 | * - encoding: May be used to signal the framerate of CFR content to an |
61 | * encoder. |
62 | */ |
63 | struct AVRational framerate; |
64 | }; |
65 | |
66 | struct mpeg12_param_sets { |
67 | bool head_parsed; |
68 | /* currently active parameter sets */ |
69 | struct MpvParseContext dec_ps; |
70 | }; |
71 | |
72 | int mpeg12_decode_extradata_ps(u8 *buf, int size, struct mpeg12_param_sets *ps); |
73 | |
74 | #endif |
75 |