aboutsummaryrefslogtreecommitdiff
path: root/Src/libvp6/include/Mp3Header.hpp
blob: bfc720358b6b941e7e96451ab70461c44a8ce079 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#if !defined(MP3HEADER_HPP)
#define MP3HEADER_HPP

#include <iosfwd>

class Mp3Header
{
public:
    Mp3Header(unsigned long);
    unsigned long  id;
    unsigned long  layer;
    unsigned long  protectionBit;
    unsigned long  bitRateIndex;
    unsigned long  samplingFrequency;
    unsigned long  paddingBit;
    unsigned long  privateBit;
    unsigned long  mode;
    unsigned long  modeExtension;
    unsigned long  copyright;
    unsigned long  originalOrCopy;
    unsigned long  emphasis;
    unsigned long  nch;
    unsigned long  sampleRate;
    unsigned long  bitRate;
    unsigned long  frameSize;
    unsigned short outFrameSize;

    enum { BITRATE_FREE = 0 };
    enum { MPEG_FORBIDDEN = -1};
    enum { SAMPLING_FREQUENCY_RESERVED = -1};

    enum IdTypes
    {
        MPEG1 = 1,
        MPEG2 = 2
    };

    enum AudioMode
    {
        STEREO_MODE = 0,
        JOINT_STEREO_MODE = 1,
        DUAL_CHANNEL_MODE = 2,
        SINGLE_CHANNEL_MODE = 3
    };

    /* layer code, very bad design */
    enum AudioLayer
    {
        AUDIO_LAYER_1 = 3,
        AUDIO_LAYER_2 = 2,
        AUDIO_LAYER_3 = 1,
        AUDIO_LAYER_RESERVED = 0
    };
    friend std::ostream& operator<<(std::ostream& os, const Mp3Header& mp3);

private:
    static const unsigned short samplingFrequencyTable[2][4];
    static const short m1BitRateTable[3][16];
    static const short m2BitRateTable[3][16];
    static const unsigned short outFrameSizes[2][4];

};
#endif