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_BADFRAMELEN = 0x0231,
00048 MAD_ERROR_BADBIGVALUES = 0x0232,
00049 MAD_ERROR_BADBLOCKTYPE = 0x0233,
00050 MAD_ERROR_BADSCFSI = 0x0234,
00051 MAD_ERROR_BADDATAPTR = 0x0235,
00052 MAD_ERROR_BADPART3LEN = 0x0236,
00053 MAD_ERROR_BADHUFFTABLE = 0x0237,
00054 MAD_ERROR_BADHUFFDATA = 0x0238,
00055 MAD_ERROR_BADSTEREO = 0x0239
00056 };
00057
00058 # define MAD_RECOVERABLE(error) ((error) & 0xff00)
00059
00060 struct mad_stream {
00061 unsigned char const *buffer;
00062 unsigned char const *bufend;
00063 unsigned long skiplen;
00064
00065 int sync;
00066 unsigned long freerate;
00067
00068 unsigned char const *this_frame;
00069 unsigned char const *next_frame;
00070 struct mad_bitptr ptr;
00071
00072 struct mad_bitptr anc_ptr;
00073 unsigned int anc_bitlen;
00074
00075 unsigned char (*main_data)[MAD_BUFFER_MDLEN];
00076
00077 unsigned int md_len;
00078
00079 int options;
00080 enum mad_error error;
00081 };
00082
00083 enum {
00084 MAD_OPTION_IGNORECRC = 0x0001,
00085 MAD_OPTION_HALFSAMPLERATE = 0x0002
00086 # if 0
00087 MAD_OPTION_LEFTCHANNEL = 0x0010,
00088 MAD_OPTION_RIGHTCHANNEL = 0x0020,
00089 MAD_OPTION_SINGLECHANNEL = 0x0030
00090 # endif
00091 };
00092
00093 void mad_stream_init(struct mad_stream *);
00094 void mad_stream_finish(struct mad_stream *);
00095
00096 # define mad_stream_options(stream, opts) \
00097 ((void) ((stream)->options = (opts)))
00098
00099 void mad_stream_buffer(struct mad_stream *,
00100 unsigned char const *, unsigned long);
00101 void mad_stream_skip(struct mad_stream *, unsigned long);
00102
00103 int mad_stream_sync(struct mad_stream *);
00104
00105 char const *mad_stream_errorstr(struct mad_stream const *);
00106
00107 # endif