summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg2.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg2.h')
-rw-r--r--apps/plugins/mpegplayer/mpeg2.h195
1 files changed, 195 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/mpeg2.h b/apps/plugins/mpegplayer/mpeg2.h
new file mode 100644
index 0000000000..6062f93010
--- /dev/null
+++ b/apps/plugins/mpegplayer/mpeg2.h
@@ -0,0 +1,195 @@
1/*
2 * mpeg2.h
3 * Copyright (C) 2000-2003 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, 0) /* 0.4.0 */
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
44typedef 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
66typedef 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
87typedef 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
97typedef struct mpeg2_fbuf_s {
98 uint8_t * buf[3];
99 void * id;
100} mpeg2_fbuf_t;
101
102typedef 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
116typedef struct mpeg2dec_s mpeg2dec_t;
117typedef struct mpeg2_decoder_s mpeg2_decoder_t;
118
119typedef enum {
120 STATE_BUFFER = 0,
121 STATE_SEQUENCE = 1,
122 STATE_SEQUENCE_REPEATED = 2,
123 STATE_GOP = 3,
124 STATE_PICTURE = 4,
125 STATE_SLICE_1ST = 5,
126 STATE_PICTURE_2ND = 6,
127 STATE_SLICE = 7,
128 STATE_END = 8,
129 STATE_INVALID = 9,
130 STATE_INVALID_END = 10
131} mpeg2_state_t;
132
133typedef struct mpeg2_convert_init_s {
134 unsigned int id_size;
135 unsigned int buf_size[3];
136 void (* start) (void * id, const mpeg2_fbuf_t * fbuf,
137 const mpeg2_picture_t * picture, const mpeg2_gop_t * gop);
138 void (* copy) (void * id, uint8_t * const * src, unsigned int v_offset);
139} mpeg2_convert_init_t;
140typedef enum {
141 MPEG2_CONVERT_SET = 0,
142 MPEG2_CONVERT_STRIDE = 1,
143 MPEG2_CONVERT_START = 2
144} mpeg2_convert_stage_t;
145typedef int mpeg2_convert_t (int stage, void * id,
146 const mpeg2_sequence_t * sequence, int stride,
147 uint32_t accel, void * arg,
148 mpeg2_convert_init_t * result);
149int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
150int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
151void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
152void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
153
154#define MPEG2_ACCEL_X86_MMX 1
155#define MPEG2_ACCEL_X86_3DNOW 2
156#define MPEG2_ACCEL_X86_MMXEXT 4
157#define MPEG2_ACCEL_PPC_ALTIVEC 1
158#define MPEG2_ACCEL_ALPHA 1
159#define MPEG2_ACCEL_ALPHA_MVI 2
160#define MPEG2_ACCEL_SPARC_VIS 1
161#define MPEG2_ACCEL_SPARC_VIS2 2
162#define MPEG2_ACCEL_DETECT 0x80000000
163
164uint32_t mpeg2_accel (uint32_t accel);
165mpeg2dec_t * mpeg2_init (void);
166const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
167void mpeg2_close (mpeg2dec_t * mpeg2dec);
168
169void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end);
170int mpeg2_getpos (mpeg2dec_t * mpeg2dec);
171mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec);
172
173void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset);
174void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip);
175void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end);
176
177void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2);
178
179void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
180 uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]);
181void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer);
182
183typedef enum {
184 MPEG2_ALLOC_MPEG2DEC = 0,
185 MPEG2_ALLOC_CHUNK = 1,
186 MPEG2_ALLOC_YUV = 2,
187 MPEG2_ALLOC_CONVERT_ID = 3,
188 MPEG2_ALLOC_CONVERTED = 4
189} mpeg2_alloc_t;
190
191void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason);
192void mpeg2_free (void * buf);
193void mpeg2_alloc_init(unsigned char* buf, int mallocsize);
194
195#endif /* MPEG2_H */