1 /* 2 * BSD LICENSE 3 * 4 * mp3 header and prasing 5 * Copyright (c) 2011-2012, Intel Corporation 6 * All rights reserved. 7 * 8 * Author: Vinod Koul <vinod.koul@linux.intel.com> 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are met: 12 * 13 * Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * Neither the name of Intel Corporation nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * LGPL LICENSE 35 * 36 * mp3 header and parsing 37 * Copyright (c) 2011-2012, Intel Corporation. 38 * 39 * 40 * This program is free software; you can redistribute it and/or modify it 41 * under the terms and conditions of the GNU Lesser General Public License, 42 * version 2.1, as published by the Free Software Foundation. 43 * 44 * This program is distributed in the hope it will be useful, but WITHOUT 45 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 47 * License for more details. 48 * 49 * You should have received a copy of the GNU Lesser General Public License 50 * along with this program; if not, write to 51 * the Free Software Foundation, Inc., 52 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 53 */ 54 55 56 #ifndef __TINYMP3_H 57 #define __TINYMP3_H 58 59 #if defined(__cplusplus) 60 extern "C" { 61 #endif 62 63 64 #define MP3_SYNC 0xe0ff 65 66 const int mp3_sample_rates[3][3] = { 67 {44100, 48000, 32000}, /* MPEG-1 */ 68 {22050, 24000, 16000}, /* MPEG-2 */ 69 {11025, 12000, 8000}, /* MPEG-2.5 */ 70 }; 71 72 const int mp3_bit_rates[3][3][15] = { 73 { 74 /* MPEG-1 */ 75 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448}, /* Layer 1 */ 76 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384}, /* Layer 2 */ 77 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}, /* Layer 3 */ 78 }, 79 { 80 /* MPEG-2 */ 81 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256}, /* Layer 1 */ 82 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, /* Layer 2 */ 83 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, /* Layer 3 */ 84 }, 85 { 86 /* MPEG-2.5 */ 87 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256}, /* Layer 1 */ 88 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, /* Layer 2 */ 89 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, /* Layer 3 */ 90 }, 91 }; 92 93 enum mpeg_version { 94 MPEG1 = 0, 95 MPEG2 = 1, 96 MPEG25 = 2 97 }; 98 99 enum mp3_stereo_mode { 100 STEREO = 0x00, 101 JOINT = 0x01, 102 DUAL = 0x02, 103 MONO = 0x03 104 }; 105 106 #endif 107