comparison data/fileio/DecodingWavFileReader.cpp @ 1069:32ab6c48efaa

Merge from branch tonioni
author Chris Cannam
date Mon, 20 Apr 2015 09:11:34 +0100
parents 843f67be0ed9
children 4d9816ba0ebe
comparison
equal deleted inserted replaced
1036:682d64f05e72 1069:32ab6c48efaa
22 #include <QFileInfo> 22 #include <QFileInfo>
23 23
24 DecodingWavFileReader::DecodingWavFileReader(FileSource source, 24 DecodingWavFileReader::DecodingWavFileReader(FileSource source,
25 ResampleMode resampleMode, 25 ResampleMode resampleMode,
26 CacheMode mode, 26 CacheMode mode,
27 int targetRate, 27 sv_samplerate_t targetRate,
28 bool normalised, 28 bool normalised,
29 ProgressReporter *reporter) : 29 ProgressReporter *reporter) :
30 CodedAudioFileReader(mode, targetRate, normalised), 30 CodedAudioFileReader(mode, targetRate, normalised),
31 m_source(source), 31 m_source(source),
32 m_path(source.getLocalFilename()), 32 m_path(source.getLocalFilename()),
62 connect(m_reporter, SIGNAL(cancelled()), this, SLOT(cancelled())); 62 connect(m_reporter, SIGNAL(cancelled()), this, SLOT(cancelled()));
63 m_reporter->setMessage 63 m_reporter->setMessage
64 (tr("Decoding %1...").arg(QFileInfo(m_path).fileName())); 64 (tr("Decoding %1...").arg(QFileInfo(m_path).fileName()));
65 } 65 }
66 66
67 int blockSize = 16384; 67 sv_frame_t blockSize = 16384;
68 int total = m_original->getFrameCount(); 68 sv_frame_t total = m_original->getFrameCount();
69 69
70 SampleBlock block; 70 SampleBlock block;
71 71
72 for (int i = 0; i < total; i += blockSize) { 72 for (sv_frame_t i = 0; i < total; i += blockSize) {
73 73
74 int count = blockSize; 74 sv_frame_t count = blockSize;
75 if (i + count > total) count = total - i; 75 if (i + count > total) count = total - i;
76 76
77 m_original->getInterleavedFrames(i, count, block); 77 block = m_original->getInterleavedFrames(i, count);
78 addBlock(block); 78 addBlock(block);
79 79
80 if (m_cancelled) break; 80 if (m_cancelled) break;
81 } 81 }
82 82
119 { 119 {
120 if (m_reader->m_cacheMode == CacheInTemporaryFile) { 120 if (m_reader->m_cacheMode == CacheInTemporaryFile) {
121 m_reader->startSerialised("DecodingWavFileReader::Decode"); 121 m_reader->startSerialised("DecodingWavFileReader::Decode");
122 } 122 }
123 123
124 int blockSize = 16384; 124 sv_frame_t blockSize = 16384;
125 int total = m_reader->m_original->getFrameCount(); 125 sv_frame_t total = m_reader->m_original->getFrameCount();
126 126
127 SampleBlock block; 127 SampleBlock block;
128 128
129 for (int i = 0; i < total; i += blockSize) { 129 for (sv_frame_t i = 0; i < total; i += blockSize) {
130 130
131 int count = blockSize; 131 sv_frame_t count = blockSize;
132 if (i + count > total) count = total - i; 132 if (i + count > total) count = total - i;
133 133
134 m_reader->m_original->getInterleavedFrames(i, count, block); 134 block = m_reader->m_original->getInterleavedFrames(i, count);
135 m_reader->addBlock(block); 135 m_reader->addBlock(block);
136 136
137 if (m_reader->m_cancelled) break; 137 if (m_reader->m_cancelled) break;
138 } 138 }
139 139
151 { 151 {
152 addSamplesToDecodeCache(frames); 152 addSamplesToDecodeCache(frames);
153 153
154 m_processed += frames.size(); 154 m_processed += frames.size();
155 155
156 float ratio = float(m_sampleRate) / float(m_fileRate); 156 double ratio = double(m_sampleRate) / double(m_fileRate);
157 157
158 int progress = lrint((float(m_processed) * ratio * 100) / 158 int progress = int(lrint((double(m_processed) * ratio * 100) /
159 float(m_original->getFrameCount())); 159 double(m_original->getFrameCount())));
160 160
161 if (progress > 99) progress = 99; 161 if (progress > 99) progress = 99;
162 m_completion = progress; 162 m_completion = progress;
163 163
164 if (m_reporter) { 164 if (m_reporter) {