MP3 Player. You can change fwd/rev speed and skip. see: http://mbed.org/users/okini3939/notebook/lpc4088_madplayer/
Dependencies: I2SSlave SDFileSystem TLV320 mbed
madplayer/frame.h@0:8ba6230eefbd, 2014-02-18 (annotated)
- Committer:
- okini3939
- Date:
- Tue Feb 18 00:22:50 2014 +0000
- Revision:
- 0:8ba6230eefbd
1st build
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:8ba6230eefbd | 1 | /* |
okini3939 | 0:8ba6230eefbd | 2 | * libmad - MPEG audio decoder library |
okini3939 | 0:8ba6230eefbd | 3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. |
okini3939 | 0:8ba6230eefbd | 4 | * |
okini3939 | 0:8ba6230eefbd | 5 | * This program is free software; you can redistribute it and/or modify |
okini3939 | 0:8ba6230eefbd | 6 | * it under the terms of the GNU General Public License as published by |
okini3939 | 0:8ba6230eefbd | 7 | * the Free Software Foundation; either version 2 of the License, or |
okini3939 | 0:8ba6230eefbd | 8 | * (at your option) any later version. |
okini3939 | 0:8ba6230eefbd | 9 | * |
okini3939 | 0:8ba6230eefbd | 10 | * This program is distributed in the hope that it will be useful, |
okini3939 | 0:8ba6230eefbd | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
okini3939 | 0:8ba6230eefbd | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
okini3939 | 0:8ba6230eefbd | 13 | * GNU General Public License for more details. |
okini3939 | 0:8ba6230eefbd | 14 | * |
okini3939 | 0:8ba6230eefbd | 15 | * You should have received a copy of the GNU General Public License |
okini3939 | 0:8ba6230eefbd | 16 | * along with this program; if not, write to the Free Software |
okini3939 | 0:8ba6230eefbd | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
okini3939 | 0:8ba6230eefbd | 18 | * |
okini3939 | 0:8ba6230eefbd | 19 | * $Id: frame.h,v 1.1 2010/11/23 20:12:57 andy Exp $ |
okini3939 | 0:8ba6230eefbd | 20 | */ |
okini3939 | 0:8ba6230eefbd | 21 | |
okini3939 | 0:8ba6230eefbd | 22 | # ifndef LIBMAD_FRAME_H |
okini3939 | 0:8ba6230eefbd | 23 | # define LIBMAD_FRAME_H |
okini3939 | 0:8ba6230eefbd | 24 | |
okini3939 | 0:8ba6230eefbd | 25 | # include "fixed.h" |
okini3939 | 0:8ba6230eefbd | 26 | # include "timer.h" |
okini3939 | 0:8ba6230eefbd | 27 | # include "stream.h" |
okini3939 | 0:8ba6230eefbd | 28 | |
okini3939 | 0:8ba6230eefbd | 29 | enum mad_layer { |
okini3939 | 0:8ba6230eefbd | 30 | MAD_LAYER_I = 1, /* Layer I */ |
okini3939 | 0:8ba6230eefbd | 31 | MAD_LAYER_II = 2, /* Layer II */ |
okini3939 | 0:8ba6230eefbd | 32 | MAD_LAYER_III = 3 /* Layer III */ |
okini3939 | 0:8ba6230eefbd | 33 | }; |
okini3939 | 0:8ba6230eefbd | 34 | |
okini3939 | 0:8ba6230eefbd | 35 | enum mad_mode { |
okini3939 | 0:8ba6230eefbd | 36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ |
okini3939 | 0:8ba6230eefbd | 37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ |
okini3939 | 0:8ba6230eefbd | 38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ |
okini3939 | 0:8ba6230eefbd | 39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ |
okini3939 | 0:8ba6230eefbd | 40 | }; |
okini3939 | 0:8ba6230eefbd | 41 | |
okini3939 | 0:8ba6230eefbd | 42 | enum mad_emphasis { |
okini3939 | 0:8ba6230eefbd | 43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ |
okini3939 | 0:8ba6230eefbd | 44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ |
okini3939 | 0:8ba6230eefbd | 45 | MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ |
okini3939 | 0:8ba6230eefbd | 46 | MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ |
okini3939 | 0:8ba6230eefbd | 47 | }; |
okini3939 | 0:8ba6230eefbd | 48 | |
okini3939 | 0:8ba6230eefbd | 49 | struct mad_header { |
okini3939 | 0:8ba6230eefbd | 50 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ |
okini3939 | 0:8ba6230eefbd | 51 | enum mad_mode mode; /* channel mode (see above) */ |
okini3939 | 0:8ba6230eefbd | 52 | int mode_extension; /* additional mode info */ |
okini3939 | 0:8ba6230eefbd | 53 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ |
okini3939 | 0:8ba6230eefbd | 54 | |
okini3939 | 0:8ba6230eefbd | 55 | unsigned long bitrate; /* stream bitrate (bps) */ |
okini3939 | 0:8ba6230eefbd | 56 | unsigned int samplerate; /* sampling frequency (Hz) */ |
okini3939 | 0:8ba6230eefbd | 57 | |
okini3939 | 0:8ba6230eefbd | 58 | unsigned short crc_check; /* frame CRC accumulator */ |
okini3939 | 0:8ba6230eefbd | 59 | unsigned short crc_target; /* final target CRC checksum */ |
okini3939 | 0:8ba6230eefbd | 60 | |
okini3939 | 0:8ba6230eefbd | 61 | int flags; /* flags (see below) */ |
okini3939 | 0:8ba6230eefbd | 62 | int private_bits; /* private bits (see below) */ |
okini3939 | 0:8ba6230eefbd | 63 | |
okini3939 | 0:8ba6230eefbd | 64 | mad_timer_t duration; /* audio playing time of frame */ |
okini3939 | 0:8ba6230eefbd | 65 | }; |
okini3939 | 0:8ba6230eefbd | 66 | |
okini3939 | 0:8ba6230eefbd | 67 | struct mad_frame { |
okini3939 | 0:8ba6230eefbd | 68 | struct mad_header header; /* MPEG audio header */ |
okini3939 | 0:8ba6230eefbd | 69 | |
okini3939 | 0:8ba6230eefbd | 70 | int options; /* decoding options (from stream) */ |
okini3939 | 0:8ba6230eefbd | 71 | |
okini3939 | 0:8ba6230eefbd | 72 | mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */ |
okini3939 | 0:8ba6230eefbd | 73 | mad_fixed_t overlap[2][32][18]; /* Layer III block overlap data */ |
okini3939 | 0:8ba6230eefbd | 74 | }; |
okini3939 | 0:8ba6230eefbd | 75 | |
okini3939 | 0:8ba6230eefbd | 76 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) |
okini3939 | 0:8ba6230eefbd | 77 | # define MAD_NSBSAMPLES(header) \ |
okini3939 | 0:8ba6230eefbd | 78 | ((header)->layer == MAD_LAYER_I ? 12 : \ |
okini3939 | 0:8ba6230eefbd | 79 | (((header)->layer == MAD_LAYER_III && \ |
okini3939 | 0:8ba6230eefbd | 80 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) |
okini3939 | 0:8ba6230eefbd | 81 | |
okini3939 | 0:8ba6230eefbd | 82 | enum { |
okini3939 | 0:8ba6230eefbd | 83 | MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ |
okini3939 | 0:8ba6230eefbd | 84 | MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ |
okini3939 | 0:8ba6230eefbd | 85 | |
okini3939 | 0:8ba6230eefbd | 86 | MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ |
okini3939 | 0:8ba6230eefbd | 87 | MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ |
okini3939 | 0:8ba6230eefbd | 88 | MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ |
okini3939 | 0:8ba6230eefbd | 89 | MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ |
okini3939 | 0:8ba6230eefbd | 90 | |
okini3939 | 0:8ba6230eefbd | 91 | MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ |
okini3939 | 0:8ba6230eefbd | 92 | MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ |
okini3939 | 0:8ba6230eefbd | 93 | MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ |
okini3939 | 0:8ba6230eefbd | 94 | |
okini3939 | 0:8ba6230eefbd | 95 | MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ |
okini3939 | 0:8ba6230eefbd | 96 | MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ |
okini3939 | 0:8ba6230eefbd | 97 | MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ |
okini3939 | 0:8ba6230eefbd | 98 | }; |
okini3939 | 0:8ba6230eefbd | 99 | |
okini3939 | 0:8ba6230eefbd | 100 | enum { |
okini3939 | 0:8ba6230eefbd | 101 | MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ |
okini3939 | 0:8ba6230eefbd | 102 | MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ |
okini3939 | 0:8ba6230eefbd | 103 | }; |
okini3939 | 0:8ba6230eefbd | 104 | |
okini3939 | 0:8ba6230eefbd | 105 | void mad_header_init(struct mad_header *); |
okini3939 | 0:8ba6230eefbd | 106 | |
okini3939 | 0:8ba6230eefbd | 107 | # define mad_header_finish(header) /* nothing */ |
okini3939 | 0:8ba6230eefbd | 108 | |
okini3939 | 0:8ba6230eefbd | 109 | int mad_header_decode(struct mad_header *, struct mad_stream *); |
okini3939 | 0:8ba6230eefbd | 110 | |
okini3939 | 0:8ba6230eefbd | 111 | void mad_frame_init(struct mad_frame *); |
okini3939 | 0:8ba6230eefbd | 112 | void mad_frame_finish(struct mad_frame *); |
okini3939 | 0:8ba6230eefbd | 113 | |
okini3939 | 0:8ba6230eefbd | 114 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); |
okini3939 | 0:8ba6230eefbd | 115 | |
okini3939 | 0:8ba6230eefbd | 116 | void mad_frame_mute(struct mad_frame *); |
okini3939 | 0:8ba6230eefbd | 117 | |
okini3939 | 0:8ba6230eefbd | 118 | # endif |