Changeset 107 for libmpcdec/branches/zorg
- Timestamp:
- 11/09/06 13:44:00 (18 years ago)
- Location:
- libmpcdec/branches/zorg
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpcdec/branches/zorg/include/mpcdec/mpcdec.h
r104 r107 58 58 typedef struct mpc_frame_info_t { 59 59 mpc_uint32_t samples; // number of samples in the frame 60 mpc_uint32_t sample_freq; // frame sample frequency61 mpc_uint8_t channels; // number of channels62 60 MPC_SAMPLE_FORMAT * buffer; // frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT) 63 61 } mpc_frame_info; -
libmpcdec/branches/zorg/src/decoder.h
r104 r107 64 64 /// @name internal state variables 65 65 //@{ 66 mpc_uint32_t SampleRate; // Sample frequency 67 mpc_uint32_t StreamVersion; // version of bitstream 68 mpc_uint32_t Max_Band; 69 mpc_uint32_t MS_used; // MS-coding used ? 70 mpc_uint32_t TrueGaplessPresent;71 mpc_uint32_t OverallFrames; // number of frames in the stream, 0 = unknow72 mpc_uint32_t LastFrameSamples; // number of samples in the last frame66 mpc_uint32_t stream_version; ///< Streamversion of stream 67 mpc_uint32_t max_band; ///< Maximum band-index used in stream (0...31) 68 mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) 69 mpc_uint32_t is_true_gapless; ///< True gapless? (0: no, 1: yes) 70 mpc_uint32_t frames; ///< Number of frames in stream 71 mpc_uint32_t last_frame_samples; ///< Number of valid samples within last frame 72 mpc_uint32_t channels; ///< Number of channels in stream 73 73 74 74 mpc_uint32_t samples_to_skip; 75 mpc_uint32_t DecodedFrames;75 mpc_uint32_t decoded_frames; 76 76 77 77 // randomizer state variables -
libmpcdec/branches/zorg/src/mpc_decoder.c
r104 r107 89 89 void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si) 90 90 { 91 d->StreamVersion = si->stream_version; 92 d->MS_used = si->ms; 93 d->Max_Band = si->max_band; 94 d->OverallFrames = si->frames; 95 d->TrueGaplessPresent = si->is_true_gapless; 96 d->SampleRate = si->sample_freq; 91 d->stream_version = si->stream_version; 92 d->ms = si->ms; 93 d->max_band = si->max_band; 94 d->frames = si->frames; 95 d->is_true_gapless = si->is_true_gapless; 96 d->channels = si->channels; 97 d->last_frame_samples = si->last_frame_samples; 97 98 } 98 99 … … 118 119 mpc_frame_info * i) 119 120 { 120 // FIXME : sauter décodage si d->samples_to_skip > MPC_FRAME_LENGTH pour sv7 121 switch (d->StreamVersion) { 122 case 0x07: 123 case 0x17: 124 case 0x08: 125 i->channels = 2; 126 i->sample_freq = d->SampleRate; 127 i->samples = MPC_FRAME_LENGTH; 128 mpc_decoder_read_bitstream_sv7(d, r); 129 break; 121 d->decoded_frames++; 122 123 if (d->decoded_frames > d->frames && !d->is_true_gapless) { 124 mpc_decoder_reset_y(d); 125 } else { 126 mpc_decoder_read_bitstream_sv7(d, r); 127 mpc_decoder_requantisierung(d); 130 128 } 131 132 // synthesize signal133 mpc_decoder_requantisierung(d);134 129 mpc_decoder_synthese_filter_float(d, i->buffer); 135 130 136 d->DecodedFrames++; 137 138 // // cut off first MPC_DECODER_SYNTH_DELAY zero-samples 139 // if (d->DecodedFrames == d->OverallFrames && d->StreamVersion >= 6) { 140 // // reconstruct exact filelength 141 // mpc_int32_t mod_block = mpc_bits_read(r, 11); 142 // mpc_int32_t FilterDecay; 143 // 144 // if (mod_block == 0) { 145 // // Encoder bugfix 146 // mod_block = 1152; 147 // } 148 // FilterDecay = (mod_block + MPC_DECODER_SYNTH_DELAY) % MPC_FRAME_LENGTH; 149 // 150 // // additional FilterDecay samples are needed for decay of synthesis filter 151 // if (MPC_DECODER_SYNTH_DELAY + mod_block >= MPC_FRAME_LENGTH) { 152 // if (!d->TrueGaplessPresent) { 153 // mpc_decoder_reset_y(d); 154 // } else { 155 // mpc_bits_read(r, 20); 156 // mpc_decoder_read_bitstream_sv7(d, FALSE); 157 // mpc_decoder_requantisierung(d, d->Max_Band); 158 // } 159 // 160 // mpc_decoder_synthese_filter_float(d, buffer + 2304); 161 // 162 // i->samples = MPC_FRAME_LENGTH + FilterDecay; 163 // } 164 // else { // there are only FilterDecay samples needed for this frame 165 // i->samples = FilterDecay; 166 // } 167 // } 131 // cut off first MPC_DECODER_SYNTH_DELAY zero-samples 132 // reconstruct exact filelength 133 if (d->decoded_frames == d->frames && (d->stream_version & 15) == 7) { 134 d->last_frame_samples = mpc_bits_read(r, 11); 135 if (d->last_frame_samples == 0) { 136 // Encoder bugfix 137 d->last_frame_samples = MPC_FRAME_LENGTH; 138 } 139 } 140 141 mpc_int32_t samples_left = d->last_frame_samples + MPC_DECODER_SYNTH_DELAY 142 + (d->frames - d->decoded_frames) * MPC_FRAME_LENGTH; 143 144 i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : samples_left; 168 145 169 146 if (d->samples_to_skip) { … … 173 150 } else { 174 151 i->samples -= d->samples_to_skip; 175 memmove(i->buffer, i->buffer + d->samples_to_skip * i->channels,176 i->samples * i->channels * sizeof (MPC_SAMPLE_FORMAT));152 memmove(i->buffer, i->buffer + d->samples_to_skip * d->channels, 153 i->samples * d->channels * sizeof (MPC_SAMPLE_FORMAT)); 177 154 d->samples_to_skip = 0; 178 155 } … … 193 170 mpc_int32_t* L; 194 171 mpc_int32_t* R; 195 const mpc_int32_t Last_Band = d-> Max_Band;172 const mpc_int32_t Last_Band = d->max_band; 196 173 197 174 #ifdef MPC_FIXED_POINT … … 363 340 *ResL = mpc_bits_read(r, 4); 364 341 *ResR = mpc_bits_read(r, 4); 365 if (d->MS_used&& !(*ResL==0 && *ResR==0)) {342 if (d->ms && !(*ResL==0 && *ResR==0)) { 366 343 d->MS_Flag[0] = mpc_bits_read(r, 1); 367 344 } … … 369 346 // consecutive subbands 370 347 ++ResL; ++ResR; // increase pointers 371 for (n=1; n <= d->Max_Band; ++n, ++ResL, ++ResR)348 for (n=1; n <= d->max_band; ++n, ++ResL, ++ResR) 372 349 { 373 350 idx = mpc_bits_huff_dec(r, mpc_table_HuffHdr); … … 377 354 *ResR = (idx!=4) ? *(ResR-1) + idx : (int) mpc_bits_read(r, 4); 378 355 379 if (d->MS_used&& !(*ResL==0 && *ResR==0)) {356 if (d->ms && !(*ResL==0 && *ResR==0)) { 380 357 d->MS_Flag[n] = mpc_bits_read(r, 1); 381 358 } -
libmpcdec/branches/zorg/src/mpc_demux.c
r104 r107 172 172 void mpc_demux_decode(mpc_demux * d, mpc_frame_info * i) 173 173 { 174 i->samples = 0;175 if (d->d->OverallFrames != 0 && d->d->DecodedFrames == d->d->OverallFrames)176 return;177 174 if (d->si.stream_version == 8) { 178 175 mpc_bits_reader r; 179 if (d->block_bits < 8 ){176 if (d->block_bits < 8 && (d->d->decoded_frames < d->d->frames || d->d->frames == 0)){ 180 177 mpc_block b; 181 178 d->bits_reader.count &= -8; … … 195 192 d->block_bits -= (d->bits_reader.buff - r.buff) * 8 + r.count - d->bits_reader.count; 196 193 } else { 197 int frame_size;198 194 mpc_bits_reader r; 199 195 mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); 200 frame_size =mpc_bits_read(&d->bits_reader, 20); // read frame size196 mpc_bits_read(&d->bits_reader, 20); // read frame size 201 197 r = d->bits_reader; 202 198 mpc_decoder_decode_frame(d->d, &d->bits_reader, i); 203 if ((d->bits_reader.buff - r.buff) * 8 + r.count - d->bits_reader.count != frame_size){204 frame_size--;205 frame_size += 1;206 }207 199 } 208 200 } … … 215 207 // mpc_uint32_t FrameBitCnt = 0; 216 208 // 217 // if (d-> DecodedFrames >= d->OverallFrames) {209 // if (d->decoded_frames >= d->OverallFrames) { 218 210 // return (mpc_uint32_t)(-1); // end of file -> abort decoding 219 211 // } 220 212 // 221 213 // // add seeking info 222 // if (d->seeking_table_frames < d-> DecodedFrames &&223 // (d-> DecodedFrames & ((1 << d->seeking_pwr) - 1)) == 0) {224 // d->seeking_table[d-> DecodedFrames >> d->seeking_pwr] = mpc_decoder_bits_read(d);225 // d->seeking_table_frames = d-> DecodedFrames;214 // if (d->seeking_table_frames < d->decoded_frames && 215 // (d->decoded_frames & ((1 << d->seeking_pwr) - 1)) == 0) { 216 // d->seeking_table[d->decoded_frames >> d->seeking_pwr] = mpc_decoder_bits_read(d); 217 // d->seeking_table_frames = d->decoded_frames; 226 218 // } 227 219 //
Note: See TracChangeset
for help on using the changeset viewer.