summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/libmpeg2/mpeg2.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/libmpeg2/mpeg2.h')
-rw-r--r--apps/plugins/mpegplayer/libmpeg2/mpeg2.h223
1 files changed, 223 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/libmpeg2/mpeg2.h b/apps/plugins/mpegplayer/libmpeg2/mpeg2.h
new file mode 100644
index 0000000000..bd14ead96e
--- /dev/null
+++ b/apps/plugins/mpegplayer/libmpeg2/mpeg2.h
@@ -0,0 +1,223 @@
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 * $Id$
24 * libmpeg2 sync history:
25 * 2008-07-01 - CVS revision 1.67
26 */
27
28#ifndef MPEG2_H
29#define MPEG2_H
30
31#include "mpeg2dec_config.h"
32
33#define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
34#define MPEG2_RELEASE MPEG2_VERSION (0, 5, 0) /* 0.5.0 */
35
36#define SEQ_FLAG_MPEG2 1
37#define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
38#define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4
39#define SEQ_FLAG_LOW_DELAY 8
40#define SEQ_FLAG_COLOUR_DESCRIPTION 16
41
42#define SEQ_MASK_VIDEO_FORMAT 0xe0
43#define SEQ_VIDEO_FORMAT_COMPONENT 0x00
44#define SEQ_VIDEO_FORMAT_PAL 0x20
45#define SEQ_VIDEO_FORMAT_NTSC 0x40
46#define SEQ_VIDEO_FORMAT_SECAM 0x60
47#define SEQ_VIDEO_FORMAT_MAC 0x80
48#define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
49
50typedef struct mpeg2_sequence_s
51{
52 unsigned int width, height;
53 unsigned int chroma_width, chroma_height;
54 unsigned int byte_rate;
55 unsigned int vbv_buffer_size;
56 uint32_t flags;
57
58 unsigned int picture_width, picture_height;
59 unsigned int display_width, display_height;
60 unsigned int pixel_width, pixel_height;
61 unsigned int frame_period;
62
63 uint8_t profile_level_id;
64 uint8_t colour_primaries;
65 uint8_t transfer_characteristics;
66 uint8_t matrix_coefficients;
67} mpeg2_sequence_t;
68
69#define GOP_FLAG_DROP_FRAME 1
70#define GOP_FLAG_BROKEN_LINK 2
71#define GOP_FLAG_CLOSED_GOP 4
72
73typedef struct mpeg2_gop_s
74{
75 uint8_t hours;
76 uint8_t minutes;
77 uint8_t seconds;
78 uint8_t pictures;
79 uint32_t flags;
80} mpeg2_gop_t;
81
82#define PIC_MASK_CODING_TYPE 7
83#define PIC_FLAG_CODING_TYPE_I 1
84#define PIC_FLAG_CODING_TYPE_P 2
85#define PIC_FLAG_CODING_TYPE_B 3
86#define PIC_FLAG_CODING_TYPE_D 4
87
88#define PIC_FLAG_TOP_FIELD_FIRST 8
89#define PIC_FLAG_PROGRESSIVE_FRAME 16
90#define PIC_FLAG_COMPOSITE_DISPLAY 32
91#define PIC_FLAG_SKIP 64
92#define PIC_FLAG_TAGS 128
93#define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
94
95typedef struct mpeg2_picture_s
96{
97 unsigned int temporal_reference;
98 unsigned int nb_fields;
99 uint32_t tag, tag2;
100 uint32_t flags;
101 struct
102 {
103 int x, y;
104 } display_offset[3];
105} mpeg2_picture_t;
106
107typedef struct mpeg2_fbuf_s
108{
109 uint8_t * buf[MPEG2_COMPONENTS];
110 void * id;
111} mpeg2_fbuf_t;
112
113typedef struct mpeg2_info_s
114{
115 const mpeg2_sequence_t * sequence;
116 const mpeg2_gop_t * gop;
117 const mpeg2_picture_t * current_picture;
118 const mpeg2_picture_t * current_picture_2nd;
119 const mpeg2_fbuf_t * current_fbuf;
120 const mpeg2_picture_t * display_picture;
121 const mpeg2_picture_t * display_picture_2nd;
122 const mpeg2_fbuf_t * display_fbuf;
123 const mpeg2_fbuf_t * discard_fbuf;
124 const uint8_t * user_data;
125 unsigned int user_data_len;
126} mpeg2_info_t;
127
128typedef struct mpeg2dec_s mpeg2dec_t;
129typedef struct mpeg2_decoder_s mpeg2_decoder_t;
130
131typedef enum
132{
133 STATE_INTERNAL_NORETURN = -1,
134 STATE_BUFFER = 0,
135 STATE_SEQUENCE = 1,
136 STATE_SEQUENCE_REPEATED = 2,
137 STATE_SEQUENCE_MODIFIED = 3,
138 STATE_GOP = 4,
139 STATE_PICTURE = 5,
140 STATE_SLICE_1ST = 6,
141 STATE_PICTURE_2ND = 7,
142 STATE_SLICE = 8,
143 STATE_END = 9,
144 STATE_INVALID = 10,
145 STATE_INVALID_END = 11,
146} mpeg2_state_t;
147
148typedef struct mpeg2_convert_init_s
149{
150 unsigned int id_size;
151 unsigned int buf_size[MPEG2_COMPONENTS];
152 void (* start)(void * id, const mpeg2_fbuf_t * fbuf,
153 const mpeg2_picture_t * picture, const mpeg2_gop_t * gop);
154 void (* copy)(void * id, uint8_t * const * src, unsigned int v_offset);
155} mpeg2_convert_init_t;
156
157typedef enum
158{
159 MPEG2_CONVERT_SET = 0,
160 MPEG2_CONVERT_STRIDE = 1,
161 MPEG2_CONVERT_START = 2
162} mpeg2_convert_stage_t;
163
164typedef int mpeg2_convert_t (int stage, void * id,
165 const mpeg2_sequence_t * sequence, int stride,
166 void * arg, mpeg2_convert_init_t * result);
167int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
168int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
169void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[MPEG2_COMPONENTS],
170 void * id);
171void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
172
173mpeg2dec_t * mpeg2_init (void);
174const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
175void mpeg2_close (mpeg2dec_t * mpeg2dec);
176
177void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end);
178int mpeg2_getpos (mpeg2dec_t * mpeg2dec);
179mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec);
180
181void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset);
182void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip);
183void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
184
185void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
186
187void mpeg2_init_fbuf (mpeg2_decoder_t * decoder,
188 uint8_t * current_fbuf[MPEG2_COMPONENTS],
189 uint8_t * forward_fbuf[MPEG2_COMPONENTS],
190 uint8_t * backward_fbuf[MPEG2_COMPONENTS]);
191void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer);
192
193int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence,
194 unsigned int * pixel_width,
195 unsigned int * pixel_height);
196
197typedef enum
198{
199 MPEG2_ALLOC_MPEG2DEC = 0,
200 MPEG2_ALLOC_CHUNK = 1,
201 MPEG2_ALLOC_YUV = 2,
202 MPEG2_ALLOC_CONVERT_ID = 3,
203 MPEG2_ALLOC_CONVERTED = 4,
204 MPEG_ALLOC_CODEC_MALLOC,
205 MPEG_ALLOC_CODEC_CALLOC,
206 MPEG_ALLOC_MPEG2_BUFFER,
207 MPEG_ALLOC_AUDIOBUF,
208 MPEG_ALLOC_PCMOUT,
209 MPEG_ALLOC_DISKBUF,
210 __MPEG_ALLOC_FIRST = -256,
211} mpeg2_alloc_t;
212
213void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
214#if 0
215void mpeg2_free (void * buf);
216#endif
217/* allocates a dedicated buffer and locks all previous allocation in place */
218void * mpeg2_bufalloc(unsigned size, mpeg2_alloc_t reason);
219/* clears all non-dedicated buffer space */
220void mpeg2_mem_reset(void);
221void mpeg2_alloc_init(unsigned char* buf, int mallocsize);
222
223#endif /* MPEG2_H */