Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stream.h
00001 /* 00002 * libmad - MPEG audio decoder library 00003 * Copyright (C) 2000-2004 Underbit Technologies, Inc. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * $Id: stream.h,v 1.1 2010/11/23 20:12:57 andy Exp $ 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, /* no error */ 00032 00033 MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ 00034 MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ 00035 00036 MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ 00037 00038 MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ 00039 MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ 00040 MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ 00041 MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ 00042 MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ 00043 00044 MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ 00045 MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ 00046 MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ 00047 MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ 00048 MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ 00049 MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ 00050 MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ 00051 MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ 00052 MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ 00053 MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ 00054 MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ 00055 MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ 00056 MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ 00057 }; 00058 00059 # define MAD_RECOVERABLE(error) ((error) & 0xff00) 00060 00061 struct mad_stream { 00062 unsigned char const *buffer; /* input bitstream buffer */ 00063 unsigned char const *bufend; /* end of buffer */ 00064 unsigned long skiplen; /* bytes to skip before next frame */ 00065 00066 int sync; /* stream sync found */ 00067 unsigned long freerate; /* free bitrate (fixed) */ 00068 00069 unsigned char const *this_frame; /* start of current frame */ 00070 unsigned char const *next_frame; /* start of next frame */ 00071 struct mad_bitptr ptr; /* current processing bit pointer */ 00072 00073 struct mad_bitptr anc_ptr; /* ancillary bits pointer */ 00074 unsigned int anc_bitlen; /* number of ancillary bits */ 00075 00076 unsigned char (*main_data)[MAD_BUFFER_MDLEN]; 00077 /* Layer III main_data() */ 00078 unsigned int md_len; /* bytes in main_data */ 00079 00080 int options; /* decoding options (see below) */ 00081 enum mad_error error; /* error code (see above) */ 00082 }; 00083 00084 enum { 00085 MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ 00086 MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ 00087 # if 0 /* not yet implemented */ 00088 MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ 00089 MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ 00090 MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ 00091 # endif 00092 }; 00093 00094 void mad_stream_init(struct mad_stream *); 00095 void mad_stream_finish(struct mad_stream *); 00096 00097 # define mad_stream_options(stream, opts) \ 00098 ((void) ((stream)->options = (opts))) 00099 00100 void mad_stream_buffer(struct mad_stream *, 00101 unsigned char const *, unsigned long); 00102 void mad_stream_skip(struct mad_stream *, unsigned long); 00103 00104 int mad_stream_sync(struct mad_stream *); 00105 00106 char const *mad_stream_errorstr(struct mad_stream const *); 00107 00108 # endif
Generated on Tue Jul 12 2022 23:11:09 by
1.7.2