comparison transform/FeatureExtractionModelTransformer.cpp @ 1582:70e172e6cc59 fix-static-analysis

Use nullptr throughout
author Chris Cannam
date Mon, 26 Nov 2018 14:33:41 +0000
parents 73b3dd65e0b3
children 7a23dfe65d66
comparison
equal deleted inserted replaced
1581:ad5f892c0c4d 1582:70e172e6cc59
43 //#define DEBUG_FEATURE_EXTRACTION_TRANSFORMER_RUN 1 43 //#define DEBUG_FEATURE_EXTRACTION_TRANSFORMER_RUN 1
44 44
45 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, 45 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in,
46 const Transform &transform) : 46 const Transform &transform) :
47 ModelTransformer(in, transform), 47 ModelTransformer(in, transform),
48 m_plugin(0), 48 m_plugin(nullptr),
49 m_haveOutputs(false) 49 m_haveOutputs(false)
50 { 50 {
51 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << m_transforms.begin()->getPluginIdentifier() << ", outputName " << m_transforms.begin()->getOutput() << endl; 51 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << m_transforms.begin()->getPluginIdentifier() << ", outputName " << m_transforms.begin()->getOutput() << endl;
52 } 52 }
53 53
54 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, 54 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in,
55 const Transforms &transforms) : 55 const Transforms &transforms) :
56 ModelTransformer(in, transforms), 56 ModelTransformer(in, transforms),
57 m_plugin(0), 57 m_plugin(nullptr),
58 m_haveOutputs(false) 58 m_haveOutputs(false)
59 { 59 {
60 if (m_transforms.empty()) { 60 if (m_transforms.empty()) {
61 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: " << transforms.size() << " transform(s)" << endl; 61 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: " << transforms.size() << " transform(s)" << endl;
62 } else { 62 } else {
269 // (now fixed) our plugin stub destructor could have 269 // (now fixed) our plugin stub destructor could have
270 // accidentally done so, so just in case: 270 // accidentally done so, so just in case:
271 SVCERR << "FeatureExtractionModelTransformer: caught exception while deleting plugin: " << e.what() << endl; 271 SVCERR << "FeatureExtractionModelTransformer: caught exception while deleting plugin: " << e.what() << endl;
272 m_message = e.what(); 272 m_message = e.what();
273 } 273 }
274 m_plugin = 0; 274 m_plugin = nullptr;
275 275
276 for (int j = 0; j < (int)m_descriptors.size(); ++j) { 276 for (int j = 0; j < (int)m_descriptors.size(); ++j) {
277 delete m_descriptors[j]; 277 delete m_descriptors[j];
278 } 278 }
279 } 279 }
352 break; 352 break;
353 } 353 }
354 354
355 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); 355 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2);
356 356
357 Model *out = 0; 357 Model *out = nullptr;
358 358
359 if (binCount == 0 && 359 if (binCount == 0 &&
360 (preDurationPlugin || !m_descriptors[n]->hasDuration)) { 360 (preDurationPlugin || !m_descriptors[n]->hasDuration)) {
361 361
362 // Anything with no value and no duration is an instant 362 // Anything with no value and no duration is an instant
587 { 587 {
588 // std::cerr << "getAdditionalModel(" << n << ", " << binNo << ")" << std::endl; 588 // std::cerr << "getAdditionalModel(" << n << ", " << binNo << ")" << std::endl;
589 589
590 if (binNo == 0) { 590 if (binNo == 0) {
591 std::cerr << "Internal error: binNo == 0 in getAdditionalModel (should be using primary model)" << std::endl; 591 std::cerr << "Internal error: binNo == 0 in getAdditionalModel (should be using primary model)" << std::endl;
592 return 0; 592 return nullptr;
593 } 593 }
594 594
595 if (!m_needAdditionalModels[n]) return 0; 595 if (!m_needAdditionalModels[n]) return nullptr;
596 if (!isOutput<SparseTimeValueModel>(n)) return 0; 596 if (!isOutput<SparseTimeValueModel>(n)) return nullptr;
597 if (m_additionalModels[n][binNo]) return m_additionalModels[n][binNo]; 597 if (m_additionalModels[n][binNo]) return m_additionalModels[n][binNo];
598 598
599 std::cerr << "getAdditionalModel(" << n << ", " << binNo << "): creating" << std::endl; 599 std::cerr << "getAdditionalModel(" << n << ", " << binNo << "): creating" << std::endl;
600 600
601 SparseTimeValueModel *baseModel = getConformingOutput<SparseTimeValueModel>(n); 601 SparseTimeValueModel *baseModel = getConformingOutput<SparseTimeValueModel>(n);
602 if (!baseModel) return 0; 602 if (!baseModel) return nullptr;
603 603
604 std::cerr << "getAdditionalModel(" << n << ", " << binNo << "): (from " << baseModel << ")" << std::endl; 604 std::cerr << "getAdditionalModel(" << n << ", " << binNo << "): (from " << baseModel << ")" << std::endl;
605 605
606 SparseTimeValueModel *additional = 606 SparseTimeValueModel *additional =
607 new SparseTimeValueModel(baseModel->getSampleRate(), 607 new SparseTimeValueModel(baseModel->getSampleRate(),
737 737
738 for (int j = 0; j < (int)m_outputNos.size(); ++j) { 738 for (int j = 0; j < (int)m_outputNos.size(); ++j) {
739 setCompletion(j, 0); 739 setCompletion(j, 0);
740 } 740 }
741 741
742 float *reals = 0; 742 float *reals = nullptr;
743 float *imaginaries = 0; 743 float *imaginaries = nullptr;
744 if (frequencyDomain) { 744 if (frequencyDomain) {
745 reals = new float[blockSize/2 + 1]; 745 reals = new float[blockSize/2 + 1];
746 imaginaries = new float[blockSize/2 + 1]; 746 imaginaries = new float[blockSize/2 + 1];
747 } 747 }
748 748