1 //=========================================================================
2 // FILENAME : tagutils-mp3.h
3 // DESCRIPTION : MP3 metadata reader
4 //=========================================================================
5 // Copyright (c) 2008- NETGEAR, Inc. All Rights Reserved.
6 //=========================================================================
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 struct mp3_frameinfo
{
26 int bitrate
; // unit=kbps
27 int samplerate
; // samp/sec
30 int frame_length
; // bytes
31 int crc_protected
; // flag
32 int samples_per_frame
; // calculated
34 int xing_offset
; // for xing hdr
45 static int _get_mp3tags(char *file
, struct song_metadata
*psong
);
46 static int _get_mp3fileinfo(char *file
, struct song_metadata
*psong
);
47 static int _decode_mp3_frame(unsigned char *frame
, struct mp3_frameinfo
*pfi
);
49 // bitrate_tbl[layer_index][bitrate_index]
50 static int bitrate_tbl
[5][16] = {
51 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, /* MPEG1, L1 */
52 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, /* MPEG1, L2 */
53 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 }, /* MPEG1, L3 */
54 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, /* MPEG2/2.5, L1 */
55 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 } /* MPEG2/2.5, L2/L3 */
58 // sample_rate[sample_index][samplerate_index]
59 static int sample_rate_tbl
[3][4] = {
60 { 44100, 48000, 32000, 0 }, /* MPEG 1 */
61 { 22050, 24000, 16000, 0 }, /* MPEG 2 */
62 { 11025, 12000, 8000, 0 } /* MPEG 2.5 */