Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

frame.h

Go to the documentation of this file.
00001 /*
00002  * libmad - MPEG audio decoder library
00003  * Copyright (C) 2000-2001 Robert Leslie
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: frame.h,v 1.2 2002/04/19 16:08:55 harlekin Exp $
00020  */
00021 
00022 # ifndef LIBMAD_FRAME_H
00023 # define LIBMAD_FRAME_H
00024 
00025 # include "fixed.h"
00026 # include "timer.h"
00027 # include "stream.h"
00028 
00029 enum mad_layer {
00030   MAD_LAYER_I   = 1,                    /* Layer I */
00031   MAD_LAYER_II  = 2,                    /* Layer II */
00032   MAD_LAYER_III = 3                     /* Layer III */
00033 };
00034 
00035 enum mad_mode {
00036   MAD_MODE_SINGLE_CHANNEL = 0,          /* single channel */
00037   MAD_MODE_DUAL_CHANNEL   = 1,          /* dual channel */
00038   MAD_MODE_JOINT_STEREO   = 2,          /* joint (MS/intensity) stereo */
00039   MAD_MODE_STEREO         = 3           /* normal LR stereo */
00040 };
00041 
00042 enum mad_emphasis {
00043   MAD_EMPHASIS_NONE       = 0,          /* no emphasis */
00044   MAD_EMPHASIS_50_15_US   = 1,          /* 50/15 microseconds emphasis */
00045   MAD_EMPHASIS_CCITT_J_17 = 3           /* CCITT J.17 emphasis */
00046 };
00047 
00048 struct mad_header {
00049   enum mad_layer layer;                 /* audio layer (1, 2, or 3) */
00050   enum mad_mode mode;                   /* channel mode (see above) */
00051   int mode_extension;                   /* additional mode info */
00052   enum mad_emphasis emphasis;           /* de-emphasis to use (see above) */
00053 
00054   unsigned long bitrate;                /* stream bitrate (bps) */
00055   unsigned int samplerate;              /* sampling frequency (Hz) */
00056 
00057   unsigned short crc_check;             /* frame CRC accumulator */
00058   unsigned short crc_target;            /* final target CRC checksum */
00059 
00060   int flags;                            /* flags (see below) */
00061   int private_bits;                     /* private bits (see below) */
00062 
00063   mad_timer_t duration;                 /* audio playing time of frame */
00064 };
00065 
00066 struct mad_frame {
00067   struct mad_header header;             /* MPEG audio header */
00068 
00069   int options;                          /* decoding options (from stream) */
00070 
00071   mad_fixed_t sbsample[2][36][32];      /* synthesis subband filter samples */
00072   mad_fixed_t (*overlap)[2][32][18];    /* Layer III block overlap data */
00073 };
00074 
00075 # define MAD_NCHANNELS(header)          ((header)->mode ? 2 : 1)
00076 # define MAD_NSBSAMPLES(header)  \
00077   ((header)->layer == MAD_LAYER_I ? 12 :  \
00078    (((header)->layer == MAD_LAYER_III &&  \
00079      ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
00080 
00081 enum {
00082   MAD_FLAG_NPRIVATE_III = 0x0007,       /* number of Layer III private bits */
00083   MAD_FLAG_INCOMPLETE   = 0x0008,       /* header but not data is decoded */
00084 
00085   MAD_FLAG_PROTECTION   = 0x0010,       /* frame has CRC protection */
00086   MAD_FLAG_COPYRIGHT    = 0x0020,       /* frame is copyright */
00087   MAD_FLAG_ORIGINAL     = 0x0040,       /* frame is original (else copy) */
00088   MAD_FLAG_PADDING      = 0x0080,       /* frame has additional slot */
00089 
00090   MAD_FLAG_I_STEREO     = 0x0100,       /* uses intensity joint stereo */
00091   MAD_FLAG_MS_STEREO    = 0x0200,       /* uses middle/side joint stereo */
00092   MAD_FLAG_FREEFORMAT   = 0x0400,       /* uses free format bitrate */
00093 
00094   MAD_FLAG_LSF_EXT      = 0x1000,       /* lower sampling freq. extension */
00095   MAD_FLAG_MC_EXT       = 0x2000,       /* multichannel audio extension */
00096   MAD_FLAG_MPEG_2_5_EXT = 0x4000        /* MPEG 2.5 (unofficial) extension */
00097 };
00098 
00099 enum {
00100   MAD_PRIVATE_HEADER    = 0x0100,       /* header private bit */
00101   MAD_PRIVATE_III       = 0x001f        /* Layer III private bits (up to 5) */
00102 };
00103 
00104 void mad_header_init(struct mad_header *);
00105 
00106 # define mad_header_finish(header)  /* nothing */
00107 
00108 int mad_header_decode(struct mad_header *, struct mad_stream *);
00109 
00110 void mad_frame_init(struct mad_frame *);
00111 void mad_frame_finish(struct mad_frame *);
00112 
00113 int mad_frame_decode(struct mad_frame *, struct mad_stream *);
00114 
00115 void mad_frame_mute(struct mad_frame *);
00116 
00117 # endif

Generated on Sat Nov 5 16:15:36 2005 for OPIE by  doxygen 1.4.2