/*
-Copyright (c) 2005-2006, John Hurst
+Copyright (c) 2005-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
nchannels = ADesc.ChannelCount;
bitspersample = ADesc.QuantizationBits;
samplespersec = (ui32_t)ceil(ADesc.AudioSamplingRate.Quotient());
- avgbps = samplespersec * nchannels * ((bitspersample + 7) / 8);
- blockalign = nchannels * ((bitspersample + 7) / 8);
+ blockalign = nchannels * (bitspersample / 8);
+ avgbps = samplespersec * blockalign;
cbsize = 0;
data_len = ASDCP::PCM::CalcFrameBufferSize(ADesc) * ADesc.ContainerDuration;
}
void
ASDCP::Wav::SimpleWaveHeader::FillADesc(ASDCP::PCM::AudioDescriptor& ADesc, ASDCP::Rational PictureRate) const
{
- ADesc.SampleRate = PictureRate;
+ ADesc.EditRate = PictureRate;
ADesc.LinkedTrackID = 0;
ADesc.Locked = 0;
ADesc.QuantizationBits = bitspersample;
ui32_t FrameBufferSize = ASDCP::PCM::CalcFrameBufferSize(ADesc);
ADesc.ContainerDuration = data_len / FrameBufferSize;
+ ADesc.ChannelFormat = PCM::CF_NONE;
}
fourcc test_RIFF(p); p += 4;
if ( test_RIFF != FCC_RIFF )
{
- DefaultLogSink().Debug("File does not begin with RIFF header\n");
+ // DefaultLogSink().Debug("File does not begin with RIFF header\n");
return RESULT_RAW_FORMAT;
}
{
ui16_t format = KM_i16_LE(*(ui16_t*)p); p += 2;
- if ( format != 1 )
+ if ( format != WAVE_FORMAT_PCM && format != WAVE_FORMAT_EXTENSIBLE )
{
- DefaultLogSink().Error("Expecting uncompressed essence, got format type %hu\n", format);
+ DefaultLogSink().Error("Expecting uncompressed PCM data, got format type %hd\n", format);
return RESULT_RAW_FORMAT;
}
avgbps = KM_i32_LE(*(ui32_t*)p); p += 4;
blockalign = KM_i16_LE(*(ui16_t*)p); p += 2;
bitspersample = KM_i16_LE(*(ui16_t*)p); p += 2;
- p += chunk_size - 16;
+ p += chunk_size - 16; // 16 is the number of bytes read in this block
}
else
{
void
ASDCP::AIFF::SimpleAIFFHeader::FillADesc(ASDCP::PCM::AudioDescriptor& ADesc, ASDCP::Rational PictureRate) const
{
- ADesc.SampleRate = PictureRate;
+ ADesc.EditRate = PictureRate;
ADesc.ChannelCount = numChannels;
ADesc.AudioSamplingRate = extended_to_Rat(sampleRate);
ADesc.QuantizationBits = sampleSize;
ADesc.BlockAlign = sampleSize / 8;
- ADesc.AvgBps = ADesc.BlockAlign * (ui32_t)ceil(ADesc.AudioSamplingRate.Quotient());
+ ADesc.AvgBps = (ui32_t) (ADesc.BlockAlign * ADesc.AudioSamplingRate.Quotient());
ui32_t FrameBufferSize = ASDCP::PCM::CalcFrameBufferSize(ADesc);
ADesc.ContainerDuration = data_len / FrameBufferSize;
+ ADesc.ChannelFormat = PCM::CF_NONE;
}
//
fourcc test_FORM(p); p += 4;
if ( test_FORM != FCC_FORM )
{
- DefaultLogSink().Debug("File does not begin with FORM header\n");
+ // DefaultLogSink().Debug("File does not begin with FORM header\n");
return RESULT_RAW_FORMAT;
}