Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1374:8db84bd61eaa
Some work to make spectrum layers (and slice layers generally) zoomable in the frequency axis. Also fixes a number of view id mixups in SliceLayer which broke offset calculations for the x axis scale.
author | Chris Cannam |
---|---|
date | Tue, 07 Feb 2017 14:55:19 +0000 |
parents | 7a38b2cbb6c1 |
children | 48e9f538e6e9 |
comparison
equal
deleted
inserted
replaced
1373:7a38b2cbb6c1 | 1374:8db84bd61eaa |
---|---|
137 .arg(m_plugin->getMaxChannelCount()) | 137 .arg(m_plugin->getMaxChannelCount()) |
138 .arg(input->getChannelCount()); | 138 .arg(input->getChannelCount()); |
139 SVCERR << m_message << endl; | 139 SVCERR << m_message << endl; |
140 return false; | 140 return false; |
141 } | 141 } |
142 | |
143 int step = primaryTransform.getStepSize(); | |
144 int block = primaryTransform.getBlockSize(); | |
142 | 145 |
143 SVDEBUG << "Initialising feature extraction plugin with channels = " | 146 SVDEBUG << "Initialising feature extraction plugin with channels = " |
144 << channelCount << ", step = " << primaryTransform.getStepSize() | 147 << channelCount << ", step = " << step |
145 << ", block = " << primaryTransform.getBlockSize() << endl; | 148 << ", block = " << block << endl; |
146 | 149 |
147 if (!m_plugin->initialise(channelCount, | 150 if (!m_plugin->initialise(channelCount, step, block)) { |
148 primaryTransform.getStepSize(), | 151 |
149 primaryTransform.getBlockSize())) { | 152 int preferredStep = int(m_plugin->getPreferredStepSize()); |
153 int preferredBlock = int(m_plugin->getPreferredBlockSize()); | |
150 | 154 |
151 int pstep = primaryTransform.getStepSize(); | 155 if (step != preferredStep || block != preferredBlock) { |
152 int pblock = primaryTransform.getBlockSize(); | 156 |
153 | 157 SVDEBUG << "Initialisation failed, trying again with preferred step = " |
154 ///!!! hang on, this isn't right -- we're modifying a copy | 158 << preferredStep << ", block = " << preferredBlock << endl; |
155 primaryTransform.setStepSize(0); | |
156 primaryTransform.setBlockSize(0); | |
157 TransformFactory::getInstance()->makeContextConsistentWithPlugin | |
158 (primaryTransform, m_plugin); | |
159 | |
160 if (primaryTransform.getStepSize() != pstep || | |
161 primaryTransform.getBlockSize() != pblock) { | |
162 | |
163 SVDEBUG << "Initialisation failed, trying again with default step = " | |
164 << primaryTransform.getStepSize() | |
165 << ", block = " << primaryTransform.getBlockSize() << endl; | |
166 | 159 |
167 if (!m_plugin->initialise(channelCount, | 160 if (!m_plugin->initialise(channelCount, preferredStep, preferredBlock)) { |
168 primaryTransform.getStepSize(), | |
169 primaryTransform.getBlockSize())) { | |
170 | 161 |
171 SVDEBUG << "Initialisation failed again" << endl; | 162 SVDEBUG << "Initialisation failed again" << endl; |
172 | 163 |
173 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | 164 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); |
174 SVCERR << m_message << endl; | 165 SVCERR << m_message << endl; |
175 return false; | 166 return false; |
176 | 167 |
177 } else { | 168 } else { |
178 | 169 |
179 SVDEBUG << "Initialisation succeeded this time" << endl; | 170 SVDEBUG << "Initialisation succeeded this time" << endl; |
171 | |
172 // Set these values into the primary transform in the list | |
173 m_transforms[0].setStepSize(preferredStep); | |
174 m_transforms[0].setBlockSize(preferredBlock); | |
180 | 175 |
181 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead") | 176 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead") |
182 .arg(pluginId) | 177 .arg(pluginId) |
183 .arg(pstep) | 178 .arg(step) |
184 .arg(pblock) | 179 .arg(block) |
185 .arg(primaryTransform.getStepSize()) | 180 .arg(preferredStep) |
186 .arg(primaryTransform.getBlockSize()); | 181 .arg(preferredBlock); |
187 SVCERR << m_message << endl; | 182 SVCERR << m_message << endl; |
188 } | 183 } |
189 | 184 |
190 } else { | 185 } else { |
191 | 186 |
192 SVDEBUG << "Initialisation failed" << endl; | 187 SVDEBUG << "Initialisation failed (with step = " << step |
188 << " and block = " << block | |
189 << ", both matching the plugin's preference)" << endl; | |
193 | 190 |
194 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | 191 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); |
195 SVCERR << m_message << endl; | 192 SVCERR << m_message << endl; |
196 return false; | 193 return false; |
197 } | 194 } |