Changeset 150
- Timestamp:
- 11/24/06 19:18:18 (18 years ago)
- Location:
- libmpc/branches/r2d
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpc.kdevelop
r138 r150 3 3 <general> 4 4 <author>Nicolas Botti</author> 5 <email ></email>5 <email/> 6 6 <version>0.1</version> 7 7 <projectmanagement>KDevAutoProject</projectmanagement> … … 14 14 <projectdirectory>.</projectdirectory> 15 15 <absoluteprojectpath>false</absoluteprojectpath> 16 <description ></description>16 <description/> 17 17 </general> 18 18 <kdevautoproject> … … 26 26 <directoryradio>custom</directoryradio> 27 27 <runarguments> 28 <mppenc ></mppenc>28 <mppenc/> 29 29 </runarguments> 30 30 <customdirectory>/</customdirectory> 31 <programargs ></programargs>31 <programargs/> 32 32 <autocompile>true</autocompile> 33 33 <envvars/> … … 184 184 </codecompletion> 185 185 <creategettersetter> 186 <prefixGet ></prefixGet>186 <prefixGet/> 187 187 <prefixSet>set</prefixSet> 188 188 <prefixVariable>m_,_</prefixVariable> … … 200 200 <kdevdebugger> 201 201 <general> 202 <programargs>~/ mdv-startup.mpc</programargs>203 <gdbpath ></gdbpath>202 <programargs>~/08\ -\ Jimmy\ Jimmy.mpc</programargs> 203 <gdbpath/> 204 204 <dbgshell>libtool</dbgshell> 205 <configGdbScript ></configGdbScript>206 <runShellScript ></runShellScript>207 <runGdbScript ></runGdbScript>205 <configGdbScript/> 206 <runShellScript/> 207 <runGdbScript/> 208 208 <breakonloadinglibs>true</breakonloadinglibs> 209 209 <separatetty>false</separatetty> -
libmpc/branches/r2d/libmpcdec/mpc_bits_reader.c
r104 r150 68 68 } 69 69 70 mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k) 71 { 72 unsigned int l = 0; 73 unsigned int code = r->buff[0] & ((1 << r->count) - 1); 74 75 while( code == 0 ) { 76 l += r->count; 77 r->buff++; 78 code = r->buff[0]; 79 r->count = 8; 80 } 81 82 while( ((1 << (r->count - 1)) & code) == 0 ) { 83 l++; 84 r->count--; 85 } 86 r->count--; 87 88 while( r->count < k ) { 89 r->buff++; 90 r->count += 8; 91 code = (code << 8) | r->buff[0]; 92 } 93 94 r->count -= k; 95 96 return (l << k) | ((code >> r->count) & ((1 << k) - 1)); 97 } 98 70 99 unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size) 71 100 { -
libmpc/branches/r2d/libmpcdec/mpc_demux.c
r149 r150 41 41 mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits); 42 42 int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block); 43 mpc_int32_t mpc_bits_golomb_dec(mpc_bits_reader * r, const mpc_uint_t k); 44 unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size); 43 45 44 46 // streaminfo.c … … 143 145 { 144 146 return ((d->r->tell(d->r) - d->bytes_total + d->bits_reader.buff - d->buffer) << 3) + 8 - d->bits_reader.count; 147 } 148 149 mpc_status mpc_demux_seek_init(mpc_demux * d) 150 { 151 if (d->seek_table != 0) 152 return MPC_STATUS_OK; 153 154 d->seek_pwr = 6; 155 if (d->si.block_pwr > d->seek_pwr) 156 d->seek_pwr = d->si.block_pwr; 157 d->seek_table = malloc((1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t)); 158 if (d->seek_table == 0) 159 return MPC_STATUS_FILE; 160 d->seek_table[0] = mpc_demux_pos(d); 161 d->seek_table_size = 1; 162 163 return MPC_STATUS_OK; 164 } 165 166 static void mpc_demux_ST(mpc_demux * d) 167 { 168 mpc_uint64_t tmp; 169 mpc_uint32_t * table; 170 mpc_bits_reader r = d->bits_reader; 171 mpc_uint_t i; 172 173 if (d->seek_table != 0) 174 return; 175 176 mpc_bits_get_size(&r, &tmp); 177 d->seek_table_size = tmp; 178 d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4); 179 d->seek_table = malloc((1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t)); 180 181 table = d->seek_table; 182 mpc_bits_get_size(&r, &tmp); 183 table[0] = (tmp + d->si.header_position) * 8; 184 185 if (d->seek_table_size == 1) 186 return; 187 188 mpc_bits_get_size(&r, &tmp); 189 table[1] = (tmp + d->si.header_position) * 8; 190 191 for (i = 2; i < d->seek_table_size; i++) { 192 int code = mpc_bits_golomb_dec(&r, 12); 193 if (code & 1) 194 code = -(code & (-1u << 1)); 195 code <<= 2; 196 table[i] = code + 2 * table[i-1] - table[i-2]; 197 } 198 } 199 200 static void mpc_demux_SP(mpc_demux * d, int size, int block_size) 201 { 202 mpc_size_t cur; 203 mpc_uint64_t ptr; 204 mpc_block b; 205 206 cur = mpc_demux_pos(d); 207 mpc_bits_get_size(&d->bits_reader, &ptr); 208 mpc_demux_seek(d, (ptr - size) * 8 + cur, 11); 209 mpc_bits_get_block(&d->bits_reader, &b); 210 if (memcmp(b.key, "ST", 2) == 0) { 211 mpc_demux_fill(d, b.size, 0); 212 mpc_demux_ST(d); 213 } 214 mpc_demux_seek(d, cur, 11 + block_size); 145 215 } 146 216 … … 189 259 } else if (memcmp(b.key, "EI", 2) == 0) 190 260 streaminfo_encoder_info(&d->si, &d->bits_reader); 261 else if (memcmp(b.key, "SP", 2) == 0) 262 mpc_demux_SP(d, size, b.size); 263 else if (memcmp(b.key, "ST", 2) == 0) 264 mpc_demux_ST(d); 191 265 d->bits_reader.buff += b.size; 192 266 size = mpc_bits_get_block(&d->bits_reader, &b); … … 206 280 p_tmp->r = p_reader; 207 281 mpc_demux_clear_buff(p_tmp); 282 p_tmp->seek_table = 0; 208 283 if (mpc_demux_header(p_tmp) == MPC_STATUS_OK) { 209 p_tmp->seek_pwr = 6; 210 if (p_tmp->si.block_pwr > p_tmp->seek_pwr) 211 p_tmp->seek_pwr = p_tmp->si.block_pwr; 212 p_tmp->seek_table = malloc((1 + p_tmp->si.samples / (MPC_FRAME_LENGTH << p_tmp->seek_pwr)) * sizeof(mpc_uint32_t)); 213 p_tmp->seek_table[0] = mpc_demux_pos(p_tmp); 214 p_tmp->seek_table_size = 1; 284 mpc_demux_seek_init(p_tmp); 215 285 p_tmp->d = mpc_decoder_init(&p_tmp->si); 216 286 } else { -
libmpc/branches/r2d/libmpcdec/streaminfo.c
r149 r150 173 173 mpc_bits_get_size(&r, &si->samples); 174 174 si->is_true_gapless = 1; 175 si->sample_freq = samplefreqs[mpc_bits_read(&r, 4)];175 si->sample_freq = samplefreqs[mpc_bits_read(&r, 3)]; 176 176 si->channels = mpc_bits_read(&r, 4) + 1; 177 177 si->max_band = mpc_bits_read(&r, 5) + 1; 178 178 si->ms = mpc_bits_read(&r, 1); 179 si->block_pwr = mpc_bits_read(&r, 4);179 si->block_pwr = mpc_bits_read(&r, 3) * 2; 180 180 181 181 si->bitrate = 0; -
libmpc/branches/r2d/libmpcenc/encode_sv7.c
r149 r150 105 105 writeBits ( e, tmp[0] , 8 ); 106 106 107 writeBits ( e, 0x08, 8 ); // StreamVersion107 writeBits ( e, 8, 8 ); // StreamVersion 108 108 109 109 len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE); … … 112 112 113 113 switch ( SampleFreq ) { 114 case 44100: writeBits ( e, 0, 4); break;115 case 48000: writeBits ( e, 1, 4); break;116 case 37800: writeBits ( e, 2, 4); break;117 case 32000: writeBits ( e, 3, 4); break;114 case 44100: writeBits ( e, 0, 3 ); break; 115 case 48000: writeBits ( e, 1, 3 ); break; 116 case 37800: writeBits ( e, 2, 3 ); break; 117 case 32000: writeBits ( e, 3, 3 ); break; 118 118 default : fprintf(stderr, "Internal error\n");// FIXME : stderr_printf ( "Internal error\n"); 119 119 exit (1); … … 123 123 writeBits ( e, MaxBand - 1 , 5 ); // Bandwidth 124 124 writeBits ( e, MS_on , 1 ); // MS-Coding Flag 125 writeBits ( e, FRAMES_PER_BLOCK_PWR, 4 ); // frames per block (log2 unit) 126 writeBits ( e, 0, 6 ); // unused 125 writeBits ( e, FRAMES_PER_BLOCK_PWR >> 1, 3 ); // frames per block (log4 unit) 127 126 128 127 writeGainInfo(e); -
libmpc/branches/r2d/libmpcenc/libmpcenc.h
r149 r150 28 28 29 29 // bitstream.c 30 #define FRAMES_PER_BLOCK_PWR 6 30 #define FRAMES_PER_BLOCK_PWR 6 // MUST be even 31 31 #define FRAMES_PER_BLOCK (1 << FRAMES_PER_BLOCK_PWR) 32 32 #define BUFFER_FULL (4352 * FRAMES_PER_BLOCK) // 34490 bit/frame 1320.3 kbps
Note: See TracChangeset
for help on using the changeset viewer.