xine-lib: xine-lib-1.2.13/src/video_dec/libmpeg2new/include/mpeg2.h Source File

xine-lib 1.2.13-20230125hg15249

mpeg2.h
Go to the documentation of this file.
1/*
2 * mpeg2.h
3 * Copyright (C) 2000-2004 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5 *
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7 * See http://libmpeg2.sourceforge.net/ for updates.
8 *
9 * mpeg2dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * mpeg2dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#ifndef MPEG2_H
25#define MPEG2_H
26
27#define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
28#define MPEG2_RELEASE MPEG2_VERSION (0, 4, 1) /* 0.4.1 */
29
30#define SEQ_FLAG_MPEG2 1
31#define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
32#define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4
33#define SEQ_FLAG_LOW_DELAY 8
34#define SEQ_FLAG_COLOUR_DESCRIPTION 16
35
36#define SEQ_MASK_VIDEO_FORMAT 0xe0
37#define SEQ_VIDEO_FORMAT_COMPONENT 0
38#define SEQ_VIDEO_FORMAT_PAL 0x20
39#define SEQ_VIDEO_FORMAT_NTSC 0x40
40#define SEQ_VIDEO_FORMAT_SECAM 0x60
41#define SEQ_VIDEO_FORMAT_MAC 0x80
42#define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
43
44 typedef struct mpeg2_sequence_s {
45 unsigned int width, height;
46 unsigned int chroma_width, chroma_height;
47 unsigned int byte_rate;
48 unsigned int vbv_buffer_size;
49 uint32_t flags;
50
51 unsigned int picture_width, picture_height;
52 unsigned int display_width, display_height;
53 unsigned int pixel_width, pixel_height;
54 unsigned int frame_period;
55
56 uint8_t profile_level_id;
57 uint8_t colour_primaries;
58 uint8_t transfer_characteristics;
59 uint8_t matrix_coefficients;
60} mpeg2_sequence_t;
61
62#define GOP_FLAG_DROP_FRAME 1
63#define GOP_FLAG_BROKEN_LINK 2
64#define GOP_FLAG_CLOSED_GOP 4
65
66 typedef struct mpeg2_gop_s {
67 uint8_t hours;
68 uint8_t minutes;
69 uint8_t seconds;
70 uint8_t pictures;
71 uint32_t flags;
72} mpeg2_gop_t;
73
74#define PIC_MASK_CODING_TYPE 7
75#define PIC_FLAG_CODING_TYPE_I 1
76#define PIC_FLAG_CODING_TYPE_P 2
77#define PIC_FLAG_CODING_TYPE_B 3
78#define PIC_FLAG_CODING_TYPE_D 4
79
80#define PIC_FLAG_TOP_FIELD_FIRST 8
81#define PIC_FLAG_PROGRESSIVE_FRAME 16
82#define PIC_FLAG_COMPOSITE_DISPLAY 32
83#define PIC_FLAG_SKIP 64
84#define PIC_FLAG_TAGS 128
85#define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
86
87 typedef struct mpeg2_picture_s {
88 unsigned int temporal_reference;
89 unsigned int nb_fields;
90 uint32_t tag, tag2;
91 uint32_t flags;
92 struct {
93 int x, y;
94 } display_offset[3];
95} mpeg2_picture_t;
96
97 typedef struct mpeg2_fbuf_s {
98 uint8_t * buf[3];
99 void * id;
100} mpeg2_fbuf_t;
101
102 typedef struct mpeg2_info_s {
103 const mpeg2_sequence_t * sequence;
104 const mpeg2_gop_t * gop;
105 const mpeg2_picture_t * current_picture;
106 const mpeg2_picture_t * current_picture_2nd;
107 const mpeg2_fbuf_t * current_fbuf;
108 const mpeg2_picture_t * display_picture;
109 const mpeg2_picture_t * display_picture_2nd;
110 const mpeg2_fbuf_t * display_fbuf;
111 const mpeg2_fbuf_t * discard_fbuf;
112 const uint8_t * user_data;
113 unsigned int user_data_len;
114} mpeg2_info_t;
115
116 typedef struct mpeg2dec_s mpeg2dec_t;
117 typedef struct mpeg2_decoder_s mpeg2_decoder_t;
118
119 typedef enum {
120 STATE_BUFFER = 0,
121 STATE_SEQUENCE = 1,
122 STATE_SEQUENCE_REPEATED = 2,
123 STATE_SEQUENCE_MODIFIED = 3,
124 STATE_GOP = 4,
125 STATE_PICTURE = 5,
126 STATE_SLICE_1ST = 6,
127 STATE_PICTURE_2ND = 7,
128 STATE_SLICE = 8,
129 STATE_END = 9,
130 STATE_INVALID = 10,
131 STATE_INVALID_END = 11
132} mpeg2_state_t;
133
134 typedef struct mpeg2_convert_init_s {
135 unsigned int id_size;
136 unsigned int buf_size[3];
137 void (* start) (void * id, const mpeg2_fbuf_t * fbuf,
138 const mpeg2_picture_t * picture, const mpeg2_gop_t * gop);
139 void (* copy) (void * id, uint8_t * const * src, unsigned int v_offset);
140} mpeg2_convert_init_t;
141 typedef enum {
142 MPEG2_CONVERT_SET = 0,
143 MPEG2_CONVERT_STRIDE = 1,
144 MPEG2_CONVERT_START = 2
145} mpeg2_convert_stage_t;
146 typedef int mpeg2_convert_t (int stage, void * id,
147 const mpeg2_sequence_t * sequence, int stride,
148 uint32_t accel, void * arg,
149 mpeg2_convert_init_t * result);
150int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
151int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
152void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
153void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
154
155#define MPEG2_ACCEL_X86_MMX 1
156#define MPEG2_ACCEL_X86_3DNOW 2
157#define MPEG2_ACCEL_X86_MMXEXT 4
158#define MPEG2_ACCEL_X86_SSE2 8
159#define MPEG2_ACCEL_X86_SSE3 16
160#define MPEG2_ACCEL_PPC_ALTIVEC 1
161#define MPEG2_ACCEL_ALPHA 1
162#define MPEG2_ACCEL_ALPHA_MVI 2
163#define MPEG2_ACCEL_SPARC_VIS 1
164#define MPEG2_ACCEL_SPARC_VIS2 2
165#define MPEG2_ACCEL_DETECT 0x80000000
166
167uint32_t mpeg2_accel (uint32_t accel);
168 mpeg2dec_t * mpeg2_init (void);
169const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
170void mpeg2_close (mpeg2dec_t * mpeg2dec);
171
172void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end);
173int mpeg2_getpos (mpeg2dec_t * mpeg2dec);
174 mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec);
175
176void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset);
177void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip);
178void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
179
180void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
181
182void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
183 uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]);
184void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer);
185int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
186 unsigned int * pixel_width,
187 unsigned int * pixel_height);
188
189 typedef enum {
190 MPEG2_ALLOC_MPEG2DEC = 0,
191 MPEG2_ALLOC_CHUNK = 1,
192 MPEG2_ALLOC_YUV = 2,
193 MPEG2_ALLOC_CONVERT_ID = 3,
194 MPEG2_ALLOC_CONVERTED = 4
195} mpeg2_alloc_t;
196
197void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
198void mpeg2_free (void * buf);
199void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t),
200 int free (void *));
201
202#endif /* MPEG2_H */
mpeg2_reset
void mpeg2_reset(mpeg2dec_t *mpeg2dec)
Definition decode.c:741
mpeg2_close
void mpeg2_close(mpeg2dec_t *mpeg2dec)
Definition decode.c:811
mpeg2_malloc
void * mpeg2_malloc(unsigned size, mpeg2_alloc_t reason)
Definition alloc.c:32
mpeg2_fbuf_t
struct mpeg2_fbuf_s mpeg2_fbuf_t
mpeg2_parse
mpeg2_state_t mpeg2_parse(mpeg2dec_t *mpeg2dec)
Definition decode.c:152
mpeg2_guess_aspect
int mpeg2_guess_aspect(const mpeg2_sequence_t *sequence, unsigned int *pixel_width, unsigned int *pixel_height)
Definition header.c:336
mpeg2_getpos
int mpeg2_getpos(mpeg2dec_t *mpeg2dec)
Definition decode.c:117
mpeg2_accel
uint32_t mpeg2_accel(uint32_t accel)
Definition decode.c:379
mpeg2_malloc_hooks
void mpeg2_malloc_hooks(void *malloc(unsigned, mpeg2_alloc_t), int free(void *))
Definition alloc.c:65
mpeg2_set_buf
void mpeg2_set_buf(mpeg2dec_t *mpeg2dec, uint8_t *buf[3], void *id)
Definition decode.c:328
mpeg2_sequence_t
struct mpeg2_sequence_s mpeg2_sequence_t
mpeg2_info_t
struct mpeg2_info_s mpeg2_info_t
mpeg2_skip
void mpeg2_skip(mpeg2dec_t *mpeg2dec, int skip)
Definition decode.c:355
mpeg2_info
const mpeg2_info_t * mpeg2_info(mpeg2dec_t *mpeg2dec)
Definition decode.c:38
mpeg2_picture_t
struct mpeg2_picture_s mpeg2_picture_t
mpeg2_buffer
void mpeg2_buffer(mpeg2dec_t *mpeg2dec, uint8_t *start, uint8_t *end)
Definition decode.c:111
mpeg2_gop_t
struct mpeg2_gop_s mpeg2_gop_t
mpeg2_convert_stage_t
mpeg2_convert_stage_t
Definition mpeg2.h:141
MPEG2_CONVERT_SET
@ MPEG2_CONVERT_SET
Definition mpeg2.h:142
MPEG2_CONVERT_STRIDE
@ MPEG2_CONVERT_STRIDE
Definition mpeg2.h:143
MPEG2_CONVERT_START
@ MPEG2_CONVERT_START
Definition mpeg2.h:144
mpeg2_slice_region
void mpeg2_slice_region(mpeg2dec_t *mpeg2dec, int start, int end)
Definition decode.c:361
mpeg2_init
mpeg2dec_t * mpeg2_init(void)
Definition decode.c:411
mpeg2_slice
void mpeg2_slice(mpeg2_decoder_t *decoder, int code, const uint8_t *buffer)
Definition slice.c:1775
mpeg2_convert_init_t
struct mpeg2_convert_init_s mpeg2_convert_init_t
mpeg2_alloc_t
mpeg2_alloc_t
Definition mpeg2.h:189
MPEG2_ALLOC_CONVERT_ID
@ MPEG2_ALLOC_CONVERT_ID
Definition mpeg2.h:193
MPEG2_ALLOC_YUV
@ MPEG2_ALLOC_YUV
Definition mpeg2.h:192
MPEG2_ALLOC_MPEG2DEC
@ MPEG2_ALLOC_MPEG2DEC
Definition mpeg2.h:190
MPEG2_ALLOC_CHUNK
@ MPEG2_ALLOC_CHUNK
Definition mpeg2.h:191
MPEG2_ALLOC_CONVERTED
@ MPEG2_ALLOC_CONVERTED
Definition mpeg2.h:194
mpeg2_custom_fbuf
void mpeg2_custom_fbuf(mpeg2dec_t *mpeg2dec, int custom_fbuf)
Definition decode.c:350
mpeg2_tag_picture
void mpeg2_tag_picture(mpeg2dec_t *mpeg2dec, uint32_t tag, uint32_t tag2)
Definition decode.c:369
mpeg2_init_fbuf
void mpeg2_init_fbuf(mpeg2_decoder_t *decoder, uint8_t *current_fbuf[3], uint8_t *forward_fbuf[3], uint8_t *backward_fbuf[3])
Definition slice.c:1590
mpeg2_convert_t
int mpeg2_convert_t(int stage, void *id, const mpeg2_sequence_t *sequence, int stride, uint32_t accel, void *arg, mpeg2_convert_init_t *result)
Definition mpeg2.h:146
mpeg2_state_t
mpeg2_state_t
Definition mpeg2.h:119
STATE_SLICE_1ST
@ STATE_SLICE_1ST
Definition mpeg2.h:126
STATE_PICTURE
@ STATE_PICTURE
Definition mpeg2.h:125
STATE_PICTURE_2ND
@ STATE_PICTURE_2ND
Definition mpeg2.h:127
STATE_INVALID
@ STATE_INVALID
Definition mpeg2.h:130
STATE_SEQUENCE_MODIFIED
@ STATE_SEQUENCE_MODIFIED
Definition mpeg2.h:123
STATE_SLICE
@ STATE_SLICE
Definition mpeg2.h:128
STATE_INVALID_END
@ STATE_INVALID_END
Definition mpeg2.h:131
STATE_SEQUENCE_REPEATED
@ STATE_SEQUENCE_REPEATED
Definition mpeg2.h:122
STATE_BUFFER
@ STATE_BUFFER
Definition mpeg2.h:120
STATE_GOP
@ STATE_GOP
Definition mpeg2.h:124
STATE_SEQUENCE
@ STATE_SEQUENCE
Definition mpeg2.h:121
STATE_END
@ STATE_END
Definition mpeg2.h:129
mpeg2_convert
int mpeg2_convert(mpeg2dec_t *mpeg2dec, mpeg2_convert_t convert, void *arg)
Definition decode.c:293
mpeg2_free
void mpeg2_free(void *buf)
Definition alloc.c:56
mpeg2_stride
int mpeg2_stride(mpeg2dec_t *mpeg2dec, int stride)
Definition decode.c:309
mpeg2_convert_init_s
Definition mpeg2.h:134
mpeg2_convert_init_s::buf_size
unsigned int buf_size[3]
Definition mpeg2.h:136
mpeg2_convert_init_s::copy
void(* copy)(void *id, uint8_t *const *src, unsigned int v_offset)
Definition mpeg2.h:139
mpeg2_convert_init_s::start
void(* start)(void *id, const mpeg2_fbuf_t *fbuf, const mpeg2_picture_t *picture, const mpeg2_gop_t *gop)
Definition mpeg2.h:137
mpeg2_convert_init_s::id_size
unsigned int id_size
Definition mpeg2.h:135
mpeg2_decoder_s
Definition mpeg2_internal.h:64
mpeg2_fbuf_s
Definition mpeg2.h:97
mpeg2_fbuf_s::buf
uint8_t * buf[3]
Definition mpeg2.h:98
mpeg2_fbuf_s::id
void * id
Definition mpeg2.h:99
mpeg2_gop_s
Definition mpeg2.h:66
mpeg2_gop_s::flags
uint32_t flags
Definition mpeg2.h:71
mpeg2_gop_s::hours
uint8_t hours
Definition mpeg2.h:67
mpeg2_gop_s::minutes
uint8_t minutes
Definition mpeg2.h:68
mpeg2_gop_s::pictures
uint8_t pictures
Definition mpeg2.h:70
mpeg2_gop_s::seconds
uint8_t seconds
Definition mpeg2.h:69
mpeg2_info_s
Definition mpeg2.h:102
mpeg2_info_s::current_picture
const mpeg2_picture_t * current_picture
Definition mpeg2.h:105
mpeg2_info_s::display_picture_2nd
const mpeg2_picture_t * display_picture_2nd
Definition mpeg2.h:109
mpeg2_info_s::current_fbuf
const mpeg2_fbuf_t * current_fbuf
Definition mpeg2.h:107
mpeg2_info_s::user_data_len
unsigned int user_data_len
Definition mpeg2.h:113
mpeg2_info_s::display_picture
const mpeg2_picture_t * display_picture
Definition mpeg2.h:108
mpeg2_info_s::gop
const mpeg2_gop_t * gop
Definition mpeg2.h:104
mpeg2_info_s::user_data
const uint8_t * user_data
Definition mpeg2.h:112
mpeg2_info_s::display_fbuf
const mpeg2_fbuf_t * display_fbuf
Definition mpeg2.h:110
mpeg2_info_s::discard_fbuf
const mpeg2_fbuf_t * discard_fbuf
Definition mpeg2.h:111
mpeg2_info_s::current_picture_2nd
const mpeg2_picture_t * current_picture_2nd
Definition mpeg2.h:106
mpeg2_info_s::sequence
const mpeg2_sequence_t * sequence
Definition mpeg2.h:103
mpeg2_picture_s
Definition mpeg2.h:87
mpeg2_picture_s::y
int y
Definition mpeg2.h:93
mpeg2_picture_s::display_offset
struct mpeg2_picture_s::@61 display_offset[3]
mpeg2_picture_s::x
int x
Definition mpeg2.h:93
mpeg2_picture_s::flags
uint32_t flags
Definition mpeg2.h:91
mpeg2_picture_s::tag2
uint32_t tag2
Definition mpeg2.h:90
mpeg2_picture_s::tag
uint32_t tag
Definition mpeg2.h:90
mpeg2_picture_s::nb_fields
unsigned int nb_fields
Definition mpeg2.h:89
mpeg2_picture_s::temporal_reference
unsigned int temporal_reference
Definition mpeg2.h:88
mpeg2_sequence_s
Definition mpeg2.h:44
mpeg2_sequence_s::display_width
unsigned int display_width
Definition mpeg2.h:52
mpeg2_sequence_s::picture_width
unsigned int picture_width
Definition mpeg2.h:51
mpeg2_sequence_s::byte_rate
unsigned int byte_rate
Definition mpeg2.h:47
mpeg2_sequence_s::pixel_height
unsigned int pixel_height
Definition mpeg2.h:53
mpeg2_sequence_s::width
unsigned int width
Definition mpeg2.h:45
mpeg2_sequence_s::flags
uint32_t flags
Definition mpeg2.h:49
mpeg2_sequence_s::chroma_height
unsigned int chroma_height
Definition mpeg2.h:46
mpeg2_sequence_s::pixel_width
unsigned int pixel_width
Definition mpeg2.h:53
mpeg2_sequence_s::vbv_buffer_size
unsigned int vbv_buffer_size
Definition mpeg2.h:48
mpeg2_sequence_s::display_height
unsigned int display_height
Definition mpeg2.h:52
mpeg2_sequence_s::matrix_coefficients
uint8_t matrix_coefficients
Definition mpeg2.h:59
mpeg2_sequence_s::chroma_width
unsigned int chroma_width
Definition mpeg2.h:46
mpeg2_sequence_s::picture_height
unsigned int picture_height
Definition mpeg2.h:51
mpeg2_sequence_s::frame_period
unsigned int frame_period
Definition mpeg2.h:54
mpeg2_sequence_s::profile_level_id
uint8_t profile_level_id
Definition mpeg2.h:56
mpeg2_sequence_s::height
unsigned int height
Definition mpeg2.h:45
mpeg2_sequence_s::transfer_characteristics
uint8_t transfer_characteristics
Definition mpeg2.h:58
mpeg2_sequence_s::colour_primaries
uint8_t colour_primaries
Definition mpeg2.h:57
mpeg2dec_s
Definition mpeg2.h:29
code
char code
Definition xmllexer.c:612