00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026 # ifndef LIBMAD_STREAM_H
00027 # define LIBMAD_STREAM_H
00028
00029 # include "bit.h"
00030
00031 # define MAD_BUFFER_GUARD 8
00032 # define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
00033
00034 enum mad_error {
00035 MAD_ERROR_NONE = 0x0000,
00037 MAD_ERROR_BUFLEN = 0x0001,
00038 MAD_ERROR_BUFPTR = 0x0002,
00040 MAD_ERROR_NOMEM = 0x0031,
00042 MAD_ERROR_LOSTSYNC = 0x0101,
00043 MAD_ERROR_BADLAYER = 0x0102,
00044 MAD_ERROR_BADBITRATE = 0x0103,
00045 MAD_ERROR_BADSAMPLERATE = 0x0104,
00046 MAD_ERROR_BADEMPHASIS = 0x0105,
00048 MAD_ERROR_BADCRC = 0x0201,
00049 MAD_ERROR_BADBITALLOC = 0x0211,
00050 MAD_ERROR_BADSCALEFACTOR = 0x0221,
00051 MAD_ERROR_BADMODE = 0x0222,
00052 MAD_ERROR_BADFRAMELEN = 0x0231,
00053 MAD_ERROR_BADBIGVALUES = 0x0232,
00054 MAD_ERROR_BADBLOCKTYPE = 0x0233,
00055 MAD_ERROR_BADSCFSI = 0x0234,
00056 MAD_ERROR_BADDATAPTR = 0x0235,
00057 MAD_ERROR_BADPART3LEN = 0x0236,
00058 MAD_ERROR_BADHUFFTABLE = 0x0237,
00059 MAD_ERROR_BADHUFFDATA = 0x0238,
00060 MAD_ERROR_BADSTEREO = 0x0239
00061 };
00062
00063 # define MAD_RECOVERABLE(error) ((error) & 0xff00)
00064
00065 struct mad_stream {
00066 unsigned char const *buffer;
00067 unsigned char const *bufend;
00068 unsigned long skiplen;
00070 int sync;
00071 unsigned long freerate;
00073 unsigned char const *this_frame;
00074 unsigned char const *next_frame;
00075 struct mad_bitptr ptr;
00077 struct mad_bitptr anc_ptr;
00078 unsigned int anc_bitlen;
00080 unsigned char (*main_data)[MAD_BUFFER_MDLEN];
00082 unsigned int md_len;
00084 int options;
00085 enum mad_error error;
00086 };
00087
00088 enum {
00089 MAD_OPTION_IGNORECRC = 0x0001,
00090 MAD_OPTION_HALFSAMPLERATE = 0x0002
00091 # if 0
00092 MAD_OPTION_LEFTCHANNEL = 0x0010,
00093 MAD_OPTION_RIGHTCHANNEL = 0x0020,
00094 MAD_OPTION_SINGLECHANNEL = 0x0030
00095 # endif
00096 };
00097
00098 void mad_stream_init(struct mad_stream *);
00099 void mad_stream_finish(struct mad_stream *);
00100
00101 # define mad_stream_options(stream, opts) \
00102 ((void) ((stream)->options = (opts)))
00103
00104 void mad_stream_buffer(struct mad_stream *,
00105 unsigned char const *, unsigned long);
00106 void mad_stream_skip(struct mad_stream *, unsigned long);
00107
00108 int mad_stream_sync(struct mad_stream *);
00109
00110 char const *mad_stream_errorstr(struct mad_stream const *);
00111
00112 # endif