Changeset 126 for libmpcdec/branches/zorg/src/streaminfo.c
- Timestamp:
- 11/13/06 20:13:18 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpcdec/branches/zorg/src/streaminfo.c
r117 r126 99 99 { 100 100 mpc_uint16_t Estimatedpeak_title = 0; 101 mpc_uint32_t frames, last_frame_samples; 101 102 102 103 si->bitrate = 0; 103 si->frames= mpc_bits_read(r, 32);104 frames = mpc_bits_read(r, 32); 104 105 mpc_bits_read(r, 1); // intensity stereo : should be 0 105 106 si->ms = mpc_bits_read(r, 1); … … 115 116 si->peak_album = (mpc_uint16_t) mpc_bits_read(r, 16); 116 117 si->is_true_gapless = mpc_bits_read(r, 1); // true gapless: used? 117 si->last_frame_samples= mpc_bits_read(r, 11); // true gapless: valid samples for last frame118 last_frame_samples = mpc_bits_read(r, 11); // true gapless: valid samples for last frame 118 119 si->fast_seek = mpc_bits_read(r, 1); // fast seeking 119 120 mpc_bits_read(r, 19); // unused … … 123 124 mpc_get_encoder_string(si); 124 125 125 // estimation, exact value needs too much time 126 si->pcm_samples = 1152 * si->frames - 576; 127 si->average_bitrate = 0; 128 if (si->pcm_samples > 0) 129 si->average_bitrate = (si->tag_offset - si->header_position) * 8.0 130 * si->sample_freq / si->pcm_samples; 126 if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH; 127 si->samples = (mpc_int64_t) frames * MPC_FRAME_LENGTH; 128 if (si->is_true_gapless) 129 si->samples -= (MPC_FRAME_LENGTH - last_frame_samples); 130 else 131 si->samples -= MPC_DECODER_SYNTH_DELAY; 132 133 si->average_bitrate = (si->tag_offset - si->header_position) * 8.0 134 * si->sample_freq / si->samples; 131 135 132 136 return MPC_STATUS_OK; … … 138 142 { 139 143 mpc_uint32_t CRC; 140 mpc_uint64_t sampleCount = 0;141 144 mpc_bits_reader r = *r_in; 142 145 … … 144 147 CRC = mpc_bits_read(&r, 32); 145 148 si->stream_version = mpc_bits_read(&r, 8); 146 mpc_bits_get_size(&r, &sampleCount); 147 si->frames = (sampleCount + MPC_FRAME_LENGTH - 1) / MPC_FRAME_LENGTH; 149 mpc_bits_get_size(&r, &si->samples); 148 150 si->is_true_gapless = 1; 149 si->last_frame_samples = sampleCount - (si->frames - 1) * MPC_FRAME_LENGTH;150 151 si->sample_freq = samplefreqs[mpc_bits_read(&r, 4)]; 151 152 si->channels = mpc_bits_read(&r, 4) + 1; … … 156 157 si->bitrate = 0; 157 158 158 si->pcm_samples = sampleCount; 159 si->average_bitrate = 0; 160 if (si->pcm_samples > 0) 161 si->average_bitrate = (si->tag_offset - si->header_position) * 8.0 162 * si->sample_freq / si->pcm_samples; 159 si->average_bitrate = (si->tag_offset - si->header_position) * 8.0 160 * si->sample_freq / si->samples; 163 161 164 162 return MPC_STATUS_OK; … … 198 196 mpc_streaminfo_get_length(mpc_streaminfo * si) 199 197 { 200 return (double) mpc_streaminfo_get_length_samples(si) / si->sample_freq; 201 } 202 203 mpc_int64_t 204 mpc_streaminfo_get_length_samples(mpc_streaminfo * si) 205 { 206 mpc_int64_t samples = (mpc_int64_t) si->frames * MPC_FRAME_LENGTH; 207 if (si->is_true_gapless) 208 samples -= (MPC_FRAME_LENGTH - si->last_frame_samples); 209 else 210 samples -= MPC_DECODER_SYNTH_DELAY; 211 return samples; 212 } 198 return (double) si->samples / si->sample_freq; 199 } 200 201 mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si) 202 { 203 return si->samples; 204 }
Note: See TracChangeset
for help on using the changeset viewer.