Chris@0: /* Chris@0: * libmad - MPEG audio decoder library Chris@0: * Copyright (C) 2000-2004 Underbit Technologies, Inc. Chris@0: * Chris@0: * This program is free software; you can redistribute it and/or modify Chris@0: * it under the terms of the GNU General Public License as published by Chris@0: * the Free Software Foundation; either version 2 of the License, or Chris@0: * (at your option) any later version. Chris@0: * Chris@0: * This program is distributed in the hope that it will be useful, Chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: * GNU General Public License for more details. Chris@0: * Chris@0: * You should have received a copy of the GNU General Public License Chris@0: * along with this program; if not, write to the Free Software Chris@0: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Chris@0: * Chris@0: * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $ Chris@0: */ Chris@0: Chris@0: # ifndef LIBMAD_FRAME_H Chris@0: # define LIBMAD_FRAME_H Chris@0: Chris@0: # include "fixed.h" Chris@0: # include "timer.h" Chris@0: # include "stream.h" Chris@0: Chris@0: enum mad_layer { Chris@0: MAD_LAYER_I = 1, /* Layer I */ Chris@0: MAD_LAYER_II = 2, /* Layer II */ Chris@0: MAD_LAYER_III = 3 /* Layer III */ Chris@0: }; Chris@0: Chris@0: enum mad_mode { Chris@0: MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ Chris@0: MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ Chris@0: MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ Chris@0: MAD_MODE_STEREO = 3 /* normal LR stereo */ Chris@0: }; Chris@0: Chris@0: enum mad_emphasis { Chris@0: MAD_EMPHASIS_NONE = 0, /* no emphasis */ Chris@0: MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ Chris@0: MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ Chris@0: MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ Chris@0: }; Chris@0: Chris@0: struct mad_header { Chris@0: enum mad_layer layer; /* audio layer (1, 2, or 3) */ Chris@0: enum mad_mode mode; /* channel mode (see above) */ Chris@0: int mode_extension; /* additional mode info */ Chris@0: enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ Chris@0: Chris@0: unsigned long bitrate; /* stream bitrate (bps) */ Chris@0: unsigned int samplerate; /* sampling frequency (Hz) */ Chris@0: Chris@0: unsigned short crc_check; /* frame CRC accumulator */ Chris@0: unsigned short crc_target; /* final target CRC checksum */ Chris@0: Chris@0: int flags; /* flags (see below) */ Chris@0: int private_bits; /* private bits (see below) */ Chris@0: Chris@0: mad_timer_t duration; /* audio playing time of frame */ Chris@0: }; Chris@0: Chris@0: struct mad_frame { Chris@0: struct mad_header header; /* MPEG audio header */ Chris@0: Chris@0: int options; /* decoding options (from stream) */ Chris@0: Chris@0: mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ Chris@0: mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */ Chris@0: }; Chris@0: Chris@0: # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) Chris@0: # define MAD_NSBSAMPLES(header) \ Chris@0: ((header)->layer == MAD_LAYER_I ? 12 : \ Chris@0: (((header)->layer == MAD_LAYER_III && \ Chris@0: ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) Chris@0: Chris@0: enum { Chris@0: MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ Chris@0: MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ Chris@0: Chris@0: MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ Chris@0: MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ Chris@0: MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ Chris@0: MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ Chris@0: Chris@0: MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ Chris@0: MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ Chris@0: MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ Chris@0: Chris@0: MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ Chris@0: MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ Chris@0: MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ Chris@0: }; Chris@0: Chris@0: enum { Chris@0: MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ Chris@0: MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ Chris@0: }; Chris@0: Chris@0: void mad_header_init(struct mad_header *); Chris@0: Chris@0: # define mad_header_finish(header) /* nothing */ Chris@0: Chris@0: int mad_header_decode(struct mad_header *, struct mad_stream *); Chris@0: Chris@0: void mad_frame_init(struct mad_frame *); Chris@0: void mad_frame_finish(struct mad_frame *); Chris@0: Chris@0: int mad_frame_decode(struct mad_frame *, struct mad_stream *); Chris@0: Chris@0: void mad_frame_mute(struct mad_frame *); Chris@0: Chris@0: # endif