Changeset 1369
- Timestamp:
- 04/26/08 15:17:30 (7 months ago)
- Location:
- trunk
- Files:
-
- 12 modified
-
Decoders/FLACDecoder.m (modified) (3 diffs)
-
Decoders/LibsndfileDecoder.m (modified) (1 diff)
-
Decoders/MusepackDecoder.m (modified) (1 diff)
-
Decoders/OggFLACDecoder.m (modified) (1 diff)
-
Decoders/WavPackDecoder.m (modified) (1 diff)
-
Encoders/FLACEncoder.m (modified) (1 diff)
-
Encoders/LibsndfileEncoder.m (modified) (1 diff)
-
Encoders/MP3Encoder.m (modified) (1 diff)
-
Encoders/OggFLACEncoder.m (modified) (1 diff)
-
Encoders/OggSpeexEncoder.m (modified) (1 diff)
-
Encoders/OggVorbisEncoder.m (modified) (1 diff)
-
Encoders/WavPackEncoder.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Decoders/FLACDecoder.m
r1366 r1369 35 35 writeCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) 36 36 { 37 FLACDecoder *source = (FLACDecoder *)client_data; 38 39 unsigned spaceRequired = 0; 40 37 FLACDecoder *source = (FLACDecoder *)client_data; 38 41 39 int8_t *alias8 = NULL; 42 40 int16_t *alias16 = NULL; … … 47 45 48 46 // Calculate the number of audio data points contained in the frame (should be one for each channel) 49 spaceRequired = frame->header.blocksize * frame->header.channels * (frame->header.bits_per_sample / 8);47 unsigned spaceRequired = frame->header.blocksize * frame->header.channels * (frame->header.bits_per_sample / 8); 50 48 51 49 // Increase buffer size as required … … 89 87 for(sample = 0; sample < frame->header.blocksize; ++sample) { 90 88 for(channel = 0; channel < frame->header.channels; ++channel) { 91 audioSample = OSSwapHostToBigInt32(buffer[channel][sample]); 92 // Skip the lowest byte 89 audioSample = buffer[channel][sample]; 90 91 // Skip the highest byte 92 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 93 93 *alias8++ = (int8_t)((audioSample & 0x0000ff00) >> 8); 94 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 95 *alias8++ = (int8_t)((audioSample & 0xff000000) >> 24); 94 *alias8++ = (int8_t)((audioSample & 0x000000ff) /*>> 0*/); 96 95 } 97 96 } -
trunk/Decoders/LibsndfileDecoder.m
r1366 r1369 166 166 alias8 = [buffer exposeBufferForWriting]; 167 167 for(sample = 0; sample < frameCount * [self pcmFormat].mChannelsPerFrame; ++sample) { 168 audioSample = OSSwapHostToBigInt32(doubleBuffer[sample] * (1 << 23)); 169 // Skip the lowest byte 168 audioSample = doubleBuffer[sample] * (1 << 23); 169 170 // Skip the highest byte 171 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 170 172 *alias8++ = (int8_t)((audioSample & 0x0000ff00) >> 8); 171 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 172 *alias8++ = (int8_t)((audioSample & 0xff000000) >> 24); 173 *alias8++ = (int8_t)((audioSample & 0x000000ff) /*>> 0*/); 173 174 } 174 175 -
trunk/Decoders/MusepackDecoder.m
r1339 r1369 143 143 audioSample = mpcBuffer[sample] * (1 << 23); 144 144 audioSample = (audioSample < clipMin ? clipMin : (audioSample > clipMax ? clipMax : audioSample)); 145 #if __BIG_ENDIAN__ 146 *alias8++ = (int8_t)(audioSample >> 16); 147 *alias8++ = (int8_t)(audioSample >> 8); 148 *alias8++ = (int8_t)audioSample; 149 #else 150 *alias8++ = (int8_t)audioSample; 151 *alias8++ = (int8_t)(audioSample >> 8); 152 *alias8++ = (int8_t)(audioSample >> 16); 153 #endif 145 146 // Skip the highest byte 147 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 148 *alias8++ = (int8_t)((audioSample & 0x0000ff00) >> 8); 149 *alias8++ = (int8_t)((audioSample & 0x000000ff) /*>> 0*/); 154 150 } 155 151 -
trunk/Decoders/OggFLACDecoder.m
r1366 r1369 89 89 for(sample = 0; sample < frame->header.blocksize; ++sample) { 90 90 for(channel = 0; channel < frame->header.channels; ++channel) { 91 audioSample = OSSwapHostToBigInt32(buffer[channel][sample]); 92 // Skip the lowest byte 91 audioSample = buffer[channel][sample]; 92 93 // Skip the highest byte 94 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 93 95 *alias8++ = (int8_t)((audioSample & 0x0000ff00) >> 8); 94 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 95 *alias8++ = (int8_t)((audioSample & 0xff000000) >> 24); 96 *alias8++ = (int8_t)((audioSample & 0x000000ff) /*>> 0*/); 96 97 } 97 98 } -
trunk/Decoders/WavPackDecoder.m
r1366 r1369 122 122 alias8 = [buffer exposeBufferForWriting]; 123 123 for(sample = 0; sample < samplesRead * [self pcmFormat].mChannelsPerFrame; ++sample) { 124 audioSample = OSSwapHostToBigInt32(inputBuffer[sample]); 125 // Skip the lowest byte 124 audioSample = inputBuffer[sample]; 125 126 // Skip the highest byte 127 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 126 128 *alias8++ = (int8_t)((audioSample & 0x0000ff00) >> 8); 127 *alias8++ = (int8_t)((audioSample & 0x00ff0000) >> 16); 128 *alias8++ = (int8_t)((audioSample & 0xff000000) >> 24); 129 *alias8++ = (int8_t)((audioSample & 0x000000ff) /*>> 0*/); 129 130 } 130 131 -
trunk/Encoders/FLACEncoder.m
r1366 r1369 383 383 buffer8 = chunk->mBuffers[0].mData; 384 384 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 385 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel , ++sample) {386 // Read three bytes and reconstruct them as a 32-bit BE integer387 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);388 constructedSample = OSSwapBigToHostInt32(constructedSample);389 385 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel) { 386 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 387 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 388 constructedSample |= (uint8_t)*buffer8++; 389 390 390 buffer[channel][wideSample] = constructedSample; 391 391 } -
trunk/Encoders/LibsndfileEncoder.m
r1366 r1369 175 175 buffer8 = bufferList.mBuffers[0].mData; 176 176 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 177 for(channel = 0; channel < bufferList.mBuffers[0].mNumberChannels; ++channel , ++sample) {178 // Read three bytes and reconstruct them as a 32-bit BE integer179 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);180 constructedSample = OSSwapBigToHostInt32(constructedSample);177 for(channel = 0; channel < bufferList.mBuffers[0].mNumberChannels; ++channel) { 178 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 179 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 180 constructedSample |= (uint8_t)*buffer8++; 181 181 182 buf[(bufferList.mBuffers[0].mNumberChannels * wideSample) + channel] = ((constructedSample << 8) | constructedSample);182 buf[(bufferList.mBuffers[0].mNumberChannels * wideSample) + channel] = constructedSample << 8; 183 183 } 184 184 } -
trunk/Encoders/MP3Encoder.m
r1366 r1369 418 418 buffer8 = chunk->mBuffers[0].mData; 419 419 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 420 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel , ++sample) {420 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel) { 421 421 // Read three bytes and reconstruct them as a 32-bit BE integer 422 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000); 423 constructedSample = OSSwapBigToHostInt32(constructedSample); 424 422 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 423 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 424 constructedSample |= (uint8_t)*buffer8++; 425 425 426 // Convert to 32-bit sample scaling 426 427 channelBuffers32[channel][wideSample] = (long)((constructedSample << 8) | (constructedSample & 0x000000ff)); -
trunk/Encoders/OggFLACEncoder.m
r1366 r1369 343 343 buffer8 = chunk->mBuffers[0].mData; 344 344 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 345 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel , ++sample) {346 // Read three bytes and reconstruct them as a 32-bit BE integer347 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);348 constructedSample = OSSwapBigToHostInt32(constructedSample);345 for(channel = 0; channel < chunk->mBuffers[0].mNumberChannels; ++channel) { 346 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 347 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 348 constructedSample |= (uint8_t)*buffer8++; 349 349 350 350 buffer[channel][wideSample] = constructedSample; -
trunk/Encoders/OggSpeexEncoder.m
r1366 r1369 423 423 buffer8 = bufferList.mBuffers[0].mData; 424 424 for(wideSample = sample = 0; wideSample < frameCount && sample < bufferList.mBuffers[0].mDataByteSize; ++wideSample, ++sample) { 425 // Read three bytes and reconstruct them as a 32-bit BE integer426 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);427 constructedSample = OSSwapBigToHostInt32(constructedSample);425 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 426 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 427 constructedSample |= (uint8_t)*buffer8++; 428 428 429 429 floatBuffer[wideSample] = (constructedSample / 8388608.); -
trunk/Encoders/OggVorbisEncoder.m
r1366 r1369 233 233 buffer8 = bufferList.mBuffers[0].mData; 234 234 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 235 for(channel = 0; channel < bufferList.mBuffers[0].mNumberChannels; ++channel , ++sample) {236 // Read three bytes and reconstruct them as a 32-bit BE integer237 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);238 constructedSample = OSSwapBigToHostInt32(constructedSample);235 for(channel = 0; channel < bufferList.mBuffers[0].mNumberChannels; ++channel) { 236 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 237 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 238 constructedSample |= (uint8_t)*buffer8++; 239 239 240 240 buffer[channel][wideSample] = (constructedSample / 8388608.); -
trunk/Encoders/WavPackEncoder.m
r1366 r1369 221 221 for(wideSample = sample = 0; wideSample < frameCount; ++wideSample) { 222 222 for(channel = 0; channel < bufferList.mBuffers[0].mNumberChannels; ++channel, ++sample) { 223 // Read three bytes and reconstruct them as a 32-bit BE integer224 constructedSample = (((int32_t)buffer8[sample] << 8) & 0x0000ff00) | (((int32_t)buffer8[++sample] << 16) & 0x00ff0000) | (((int32_t)buffer8[++sample] << 24) & 0xff000000);225 constructedSample = OSSwapBigToHostInt32(constructedSample);223 constructedSample = (int8_t)*buffer8++; constructedSample <<= 8; 224 constructedSample |= (uint8_t)*buffer8++; constructedSample <<= 8; 225 constructedSample |= (uint8_t)*buffer8++; 226 226 227 227 wpBuf[(bufferList.mBuffers[0].mNumberChannels * wideSample) + channel] = constructedSample;
