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