Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / include / libraries / mpega.h
blob5b99c84a507716e2c2179f285c1b17f8b38a0829
1 /*------------------------------------------------------------------------------
3 File : MPEGA.h
5 Author : Stéphane TAVENARD
7 $VER: MPEGA.h 2.0 (21/06/1998)
9 (C) Copyright 1997-1998 Stéphane TAVENARD
10 All Rights Reserved
12 #Rev| Date | Comment
13 ----|----------|--------------------------------------------------------
14 0 |25/10/1997| Initial revision ST
15 1 |21/06/1998| Added MPEGA_scale ST
17 ------------------------------------------------------------------------
19 MPEGA decoder library definitions
21 ------------------------------------------------------------------------------*/
23 #ifndef LIBRARIES_MPEGA_H
24 #define LIBRARIES_MPEGA_H
26 #define MPEGA_VERSION 2 /* #1 */
28 #ifndef EXEC_TYPES_H
29 #include <exec/types.h>
30 #endif
32 #ifndef UTILITY_HOOKS_H
33 #include <utility/hooks.h>
34 #endif
36 /* Controls for decoding */
38 /* Qualities */
39 #define MPEGA_QUALITY_LOW 0
40 #define MPEGA_QUALITY_MEDIUM 1
41 #define MPEGA_QUALITY_HIGH 2
44 Bitstream Hook function is called like (SAS/C syntax):
47 ULONG __saveds __asm HookFunc( register __a0 struct Hook *hook,
48 register __a2 APTR handle,
49 register __a1 MPEGA_ACCESS *access );
51 MPEGA_ACCESS struct specify bitstream access function & parameters
53 access->func == MPEGA_BSFUNC_OPEN
54 open the bitstream
55 access->data.open.buffer_size is the i/o block size your read function can use
56 access->data.open.stream_size is the total size of the current stream
57 (in bytes, set it to 0 if unknown)
58 return your file handle (or NULL if failed)
59 access->func == MPEGA_BSFUNC_CLOSE
60 close the bitstream
61 return 0 if ok
62 access->func == MPEGA_BSFUNC_READ
63 read bytes from bitstream.
64 access->data.read.buffer is the destination buffer.
65 access->data.read.num_bytes is the number of bytes requested for read.
66 return # of bytes read or 0 if EOF.
67 access->func == MPEGA_BSFUNC_SEEK
68 seek into the bitstream
69 access->data.seek.abs_byte_seek_pos is the absolute byte position to reach.
70 return 0 if ok
73 #define MPEGA_BSFUNC_OPEN 0
74 #define MPEGA_BSFUNC_CLOSE 1
75 #define MPEGA_BSFUNC_READ 2
76 #define MPEGA_BSFUNC_SEEK 3
78 typedef struct {
80 LONG func; /* MPEGA_BSFUNC_xxx */
81 union {
82 struct {
83 char *stream_name; /* in */
84 LONG buffer_size; /* in */
85 LONG stream_size; /* out */
86 } open;
87 struct {
88 void *buffer; /* in/out */
89 LONG num_bytes; /* in */
90 } read;
91 struct {
92 LONG abs_byte_seek_pos; /* out */
93 } seek;
94 } data;
96 } MPEGA_ACCESS;
98 /* Decoding output settings */
100 typedef struct {
101 WORD freq_div; /* 1, 2 or 4 */
102 WORD quality; /* 0 (low) .. 2 (high) */
103 LONG freq_max; /* for automatic freq_div (if mono_freq_div == 0) */
104 } MPEGA_OUTPUT;
106 /* Decoding layer settings */
107 typedef struct {
108 WORD force_mono; /* 1 to decode stereo stream in mono, 0 otherwise */
109 MPEGA_OUTPUT mono; /* mono settings */
110 MPEGA_OUTPUT stereo; /* stereo settings */
111 } MPEGA_LAYER;
113 /* Full control structure of MPEG Audio decoding */
114 typedef struct {
115 struct Hook *bs_access; /* NULL for default access (file I/O) or give your own bitstream access */
116 MPEGA_LAYER layer_1_2; /* Layer I & II settings */
117 MPEGA_LAYER layer_3; /* Layer III settings */
118 WORD check_mpeg; /* 1 to check for mpeg audio validity at start of stream, 0 otherwise */
119 LONG stream_buffer_size; /* size of bitstream buffer in bytes (0 -> default size) */
120 /* NOTE: stream_buffer_size must be multiple of 4 bytes */
121 } MPEGA_CTRL;
123 /* MPEG Audio modes */
125 #define MPEGA_MODE_STEREO 0
126 #define MPEGA_MODE_J_STEREO 1
127 #define MPEGA_MODE_DUAL 2
128 #define MPEGA_MODE_MONO 3
130 typedef struct {
131 /* Public data (read only) */
132 /* Stream info */
133 WORD norm; /* 1 or 2 */
134 WORD layer; /* 1..3 */
135 WORD mode; /* 0..3 (MPEGA_MODE_xxx) */
136 WORD bitrate; /* in kbps */
137 LONG frequency; /* in Hz */
138 WORD channels; /* 1 or 2 */
139 ULONG ms_duration; /* stream duration in ms */
140 WORD private_bit; /* 0 or 1 */
141 WORD copyright; /* 0 or 1 */
142 WORD original; /* 0 or 1 */
143 /* Decoding info according to MPEG control */
144 WORD dec_channels; /* decoded channels 1 or 2 */
145 WORD dec_quality; /* decoding quality 0..2 */
146 LONG dec_frequency; /* decoding frequency in Hz */
148 /* Private data */
149 void *handle;
150 } MPEGA_STREAM;
152 #define MPEGA_MAX_CHANNELS 2 // Max channels
153 #define MPEGA_PCM_SIZE 1152 // Max samples per frame
155 /* Error codes */
157 #define MPEGA_ERR_NONE 0
158 #define MPEGA_ERR_BASE 0
159 #define MPEGA_ERR_EOF (MPEGA_ERR_BASE-1)
160 #define MPEGA_ERR_BADFRAME (MPEGA_ERR_BASE-2)
161 #define MPEGA_ERR_MEM (MPEGA_ERR_BASE-3)
162 #define MPEGA_ERR_NO_SYNC (MPEGA_ERR_BASE-4)
163 #define MPEGA_ERR_BADVALUE (MPEGA_ERR_BASE-5) /* #1 */
165 #endif /* LIBRARIES_MPEGA_H */