1 /*------------------------------------------------------------------------------
5 Author : Stéphane TAVENARD
7 $VER: MPEGA.h 2.0 (21/06/1998)
9 (C) Copyright 1997-1998 Stéphane TAVENARD
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 */
29 #include <exec/types.h>
32 #ifndef UTILITY_HOOKS_H
33 #include <utility/hooks.h>
36 /* Controls for decoding */
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
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
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.
73 #define MPEGA_BSFUNC_OPEN 0
74 #define MPEGA_BSFUNC_CLOSE 1
75 #define MPEGA_BSFUNC_READ 2
76 #define MPEGA_BSFUNC_SEEK 3
80 LONG func
; /* MPEGA_BSFUNC_xxx */
83 char *stream_name
; /* in */
84 LONG buffer_size
; /* in */
85 LONG stream_size
; /* out */
88 void *buffer
; /* in/out */
89 LONG num_bytes
; /* in */
92 LONG abs_byte_seek_pos
; /* out */
98 /* Decoding output settings */
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) */
106 /* Decoding layer settings */
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 */
113 /* Full control structure of MPEG Audio decoding */
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 */
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
131 /* Public data (read only) */
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 */
152 #define MPEGA_MAX_CHANNELS 2 // Max channels
153 #define MPEGA_PCM_SIZE 1152 // Max samples per frame
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 */