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