HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / wsutil / mpeg-audio.c
blobe848ce673e5a4d635cf47fb6c1b18c01deec3ba9
1 /* mpeg-audio.c
3 * MPEG Audio header dissection
4 * Written by Shaun Jackman <sjackman@gmail.com>
5 * Copyright 2007 Shaun Jackman
7 * $Id$
9 * Wiretap Library
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "mpeg-audio.h"
27 static const int mpa_versions[4] = { 2, -1, 1, 0 };
28 static const int mpa_layers[4] = { -1, 2, 1, 0 };
30 static const unsigned int mpa_samples_data[3][3] = {
31 { 384, 1152, 1152 },
32 { 384, 1152, 576 },
33 { 384, 1152, 576 },
36 static const unsigned int mpa_bitrates[3][3][16] = { /* kb/s */
38 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
39 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
40 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 },
43 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
44 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
45 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
48 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
49 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
50 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
54 static const unsigned int mpa_frequencies[3][4] = {
55 { 44100, 48000, 32000 },
56 { 22050, 24000, 16000 },
57 { 11025, 12000, 8000 },
60 static const unsigned int mpa_padding_data[3] = { 4, 1, 1 };
62 int
63 mpa_version(const struct mpa *mpa)
65 return mpa_versions[mpa->version];
68 int
69 mpa_layer(const struct mpa *mpa)
71 return mpa_layers[mpa->layer];
74 unsigned
75 mpa_samples(const struct mpa *mpa)
77 return mpa_samples_data[mpa_versions[mpa->version]][mpa_layer(mpa)];
80 unsigned
81 mpa_bitrate(const struct mpa *mpa)
83 return (1000 * (mpa_bitrates[mpa_versions[mpa->version]][mpa_layers[mpa->layer]][mpa->bitrate]));
86 unsigned
87 mpa_frequency(const struct mpa *mpa)
89 return(mpa_frequencies[mpa_versions[mpa->version]][mpa->frequency]);
92 unsigned
93 mpa_padding(const struct mpa *mpa)
95 return(mpa->padding ? mpa_padding_data[mpa_layers[mpa->layer]] : 0);