Mercurial > mplayer.hg
comparison libmpdemux/mp3_hdr.c @ 10370:2cfd7ef9cb75
codmetics (noticed by Alex)
author | arpi |
---|---|
date | Fri, 04 Jul 2003 21:04:14 +0000 |
parents | b9fdaecc672f |
children | c9e2d75a9013 |
comparison
equal
deleted
inserted
replaced
10369:b9fdaecc672f | 10370:2cfd7ef9cb75 |
---|---|
15 {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0} } | 15 {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,0} } |
16 }; | 16 }; |
17 | 17 |
18 static long freqs[9] = { 44100, 48000, 32000, // MPEG 1.0 | 18 static long freqs[9] = { 44100, 48000, 32000, // MPEG 1.0 |
19 22050, 24000, 16000, // MPEG 2.0 | 19 22050, 24000, 16000, // MPEG 2.0 |
20 11025, 12000 , 8000 }; // MPEG 2.5 | 20 11025, 12000, 8000}; // MPEG 2.5 |
21 | 21 |
22 int mp_mp3_get_lsf(unsigned char* hbuf){ | 22 int mp_mp3_get_lsf(unsigned char* hbuf){ |
23 unsigned long newhead = | 23 unsigned long newhead = |
24 hbuf[0] << 24 | | 24 hbuf[0] << 24 | |
25 hbuf[1] << 16 | | 25 hbuf[1] << 16 | |
55 if((4-((newhead>>17)&3))!=3){ | 55 if((4-((newhead>>17)&3))!=3){ |
56 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-3\n"); | 56 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"not layer-3\n"); |
57 return -1; | 57 return -1; |
58 } | 58 } |
59 | 59 |
60 sampling_frequency = ((newhead>>10)&0x3); | 60 sampling_frequency = ((newhead>>10)&0x3); // valid: 0..2 |
61 if(sampling_frequency==3){ | 61 if(sampling_frequency==3){ |
62 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid sampling_frequency\n"); | 62 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid sampling_frequency\n"); |
63 return -1; // valid: 0..8 | 63 return -1; |
64 } | 64 } |
65 | 65 |
66 if( newhead & ((long)1<<20) ) { | 66 if( newhead & ((long)1<<20) ) { |
67 // MPEG 1.0 (lsf==0) or MPEG 2.0 (lsf==1) | 67 // MPEG 1.0 (lsf==0) or MPEG 2.0 (lsf==1) |
68 lsf = (newhead & ((long)1<<19)) ? 0x0 : 0x1; | 68 lsf = (newhead & ((long)1<<19)) ? 0x0 : 0x1; |
72 lsf = 1; | 72 lsf = 1; |
73 sampling_frequency += 6; | 73 sampling_frequency += 6; |
74 } | 74 } |
75 | 75 |
76 // crc = ((newhead>>16)&0x1)^0x1; | 76 // crc = ((newhead>>16)&0x1)^0x1; |
77 bitrate_index = ((newhead>>12)&0xf); | 77 bitrate_index = ((newhead>>12)&0xf); // valid: 1..14 |
78 padding = ((newhead>>9)&0x1); | 78 padding = ((newhead>>9)&0x1); |
79 // fr->extension = ((newhead>>8)&0x1); | 79 // fr->extension = ((newhead>>8)&0x1); |
80 // fr->mode = ((newhead>>6)&0x3); | 80 // fr->mode = ((newhead>>6)&0x3); |
81 // fr->mode_ext = ((newhead>>4)&0x3); | 81 // fr->mode_ext = ((newhead>>4)&0x3); |
82 // fr->copyright = ((newhead>>3)&0x1); | 82 // fr->copyright = ((newhead>>3)&0x1); |
99 | 99 |
100 framesize = tabsel_123[lsf][2][bitrate_index] * 144000; | 100 framesize = tabsel_123[lsf][2][bitrate_index] * 144000; |
101 | 101 |
102 if(!framesize){ | 102 if(!framesize){ |
103 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n"); | 103 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"invalid framesize/bitrate_index\n"); |
104 return -1; // valid: 1..14 | 104 return -1; |
105 } | 105 } |
106 | 106 |
107 framesize /= freqs[sampling_frequency]<<lsf; | 107 framesize /= freqs[sampling_frequency]<<lsf; |
108 framesize += padding; | 108 framesize += padding; |
109 | 109 |