Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginAdapter.cpp @ 168:006a775133b1
* Re-do the way the v2 structure (with durations) is returned.
I bungled backward compatibility -- I failed to spot the contiguous
array returned from process()... duh. Also bump library versions.
author | cannam |
---|---|
date | Thu, 24 Jul 2008 16:50:11 +0000 |
parents | 31eda4b11f2b |
children | 5ce2c3f79a45 |
comparison
equal
deleted
inserted
replaced
167:31eda4b11f2b | 168:006a775133b1 |
---|---|
582 outputCount = m_pluginOutputs[plugin]->size(); | 582 outputCount = m_pluginOutputs[plugin]->size(); |
583 } | 583 } |
584 VampFeatureList *list = m_fs[plugin]; | 584 VampFeatureList *list = m_fs[plugin]; |
585 for (unsigned int i = 0; i < outputCount; ++i) { | 585 for (unsigned int i = 0; i < outputCount; ++i) { |
586 for (unsigned int j = 0; j < m_fsizes[plugin][i]; ++j) { | 586 for (unsigned int j = 0; j < m_fsizes[plugin][i]; ++j) { |
587 if (list[i].features[j].label) { | 587 if (list[i].features[j].v1.label) { |
588 free(list[i].features[j].label); | 588 free(list[i].features[j].v1.label); |
589 } | 589 } |
590 if (list[i].features[j].values) { | 590 if (list[i].features[j].v1.values) { |
591 free(list[i].features[j].values); | 591 free(list[i].features[j].v1.values); |
592 } | 592 } |
593 } | 593 } |
594 if (list[i].features) free(list[i].features); | 594 if (list[i].features) free(list[i].features); |
595 if (list[i].featuresV2) free(list[i].featuresV2); | |
596 } | 595 } |
597 m_fs.erase(plugin); | 596 m_fs.erase(plugin); |
598 m_fsizes.erase(plugin); | 597 m_fsizes.erase(plugin); |
599 m_fvsizes.erase(plugin); | 598 m_fvsizes.erase(plugin); |
600 } | 599 } |
716 if (m_pluginOutputs[plugin]) outputCount = m_pluginOutputs[plugin]->size(); | 715 if (m_pluginOutputs[plugin]) outputCount = m_pluginOutputs[plugin]->size(); |
717 | 716 |
718 resizeFS(plugin, outputCount); | 717 resizeFS(plugin, outputCount); |
719 VampFeatureList *fs = m_fs[plugin]; | 718 VampFeatureList *fs = m_fs[plugin]; |
720 | 719 |
720 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: sizeof(Feature) == " << sizeof(Plugin::Feature) << ", sizeof(VampFeature) == " << sizeof(VampFeature) << ", sizeof(VampFeatureList) == " << sizeof(VampFeatureList) << std::endl; | |
721 | |
721 for (Plugin::FeatureSet::const_iterator fi = features.begin(); | 722 for (Plugin::FeatureSet::const_iterator fi = features.begin(); |
722 fi != features.end(); ++fi) { | 723 fi != features.end(); ++fi) { |
723 | 724 |
724 int n = fi->first; | 725 int n = fi->first; |
725 | 726 |
744 | 745 |
745 for (size_t j = 0; j < sz; ++j) { | 746 for (size_t j = 0; j < sz; ++j) { |
746 | 747 |
747 // std::cerr << "PluginAdapterBase::Impl::convertFeatures: j = " << j << std::endl; | 748 // std::cerr << "PluginAdapterBase::Impl::convertFeatures: j = " << j << std::endl; |
748 | 749 |
749 VampFeature *feature = &fs[n].features[j]; | 750 VampFeature *feature = &fs[n].features[j].v1; |
750 | 751 |
751 feature->hasTimestamp = fl[j].hasTimestamp; | 752 feature->hasTimestamp = fl[j].hasTimestamp; |
752 feature->sec = fl[j].timestamp.sec; | 753 feature->sec = fl[j].timestamp.sec; |
753 feature->nsec = fl[j].timestamp.nsec; | 754 feature->nsec = fl[j].timestamp.nsec; |
754 feature->valueCount = fl[j].values.size(); | 755 feature->valueCount = fl[j].values.size(); |
755 | 756 |
756 VampFeatureV2 *v2 = &fs[n].featuresV2[j]; | 757 VampFeatureV2 *v2 = &fs[n].features[j + sz].v2; |
757 | 758 |
758 v2->hasDuration = fl[j].hasDuration; | 759 v2->hasDuration = fl[j].hasDuration; |
759 v2->durationSec = fl[j].duration.sec; | 760 v2->durationSec = fl[j].duration.sec; |
760 v2->durationNsec = fl[j].duration.nsec; | 761 v2->durationNsec = fl[j].duration.nsec; |
761 | 762 |
786 for (int i = lastN + 1; i < int(outputCount); ++i) { | 787 for (int i = lastN + 1; i < int(outputCount); ++i) { |
787 fs[i].featureCount = 0; | 788 fs[i].featureCount = 0; |
788 } | 789 } |
789 } | 790 } |
790 | 791 |
792 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: have " << outputCount << " outputs" << std::endl; | |
793 // for (int i = 0; i < outputCount; ++i) { | |
794 // std::cerr << "PluginAdapter(v2)::convertFeatures: NOTE: output " << i << " has " << fs[i].featureCount << " features" << std::endl; | |
795 // } | |
796 | |
797 | |
791 return fs; | 798 return fs; |
792 } | 799 } |
793 | 800 |
794 void | 801 void |
795 PluginAdapterBase::Impl::resizeFS(Plugin *plugin, int n) | 802 PluginAdapterBase::Impl::resizeFS(Plugin *plugin, int n) |
805 (m_fs[plugin], n * sizeof(VampFeatureList)); | 812 (m_fs[plugin], n * sizeof(VampFeatureList)); |
806 | 813 |
807 while (i < n) { | 814 while (i < n) { |
808 m_fs[plugin][i].featureCount = 0; | 815 m_fs[plugin][i].featureCount = 0; |
809 m_fs[plugin][i].features = 0; | 816 m_fs[plugin][i].features = 0; |
810 m_fs[plugin][i].featuresV2 = 0; | |
811 m_fsizes[plugin].push_back(0); | 817 m_fsizes[plugin].push_back(0); |
812 m_fvsizes[plugin].push_back(std::vector<size_t>()); | 818 m_fvsizes[plugin].push_back(std::vector<size_t>()); |
813 i++; | 819 i++; |
814 } | 820 } |
815 } | 821 } |
823 size_t i = m_fsizes[plugin][n]; | 829 size_t i = m_fsizes[plugin][n]; |
824 if (i >= sz) return; | 830 if (i >= sz) return; |
825 | 831 |
826 // std::cerr << "resizing from " << i << std::endl; | 832 // std::cerr << "resizing from " << i << std::endl; |
827 | 833 |
828 m_fs[plugin][n].features = (VampFeature *)realloc | 834 m_fs[plugin][n].features = (VampFeatureUnion *)realloc |
829 (m_fs[plugin][n].features, sz * sizeof(VampFeature)); | 835 (m_fs[plugin][n].features, 2 * sz * sizeof(VampFeatureUnion)); |
830 | |
831 m_fs[plugin][n].featuresV2 = (VampFeatureV2 *)realloc | |
832 (m_fs[plugin][n].featuresV2, sz * sizeof(VampFeatureV2)); | |
833 | 836 |
834 while (m_fsizes[plugin][n] < sz) { | 837 while (m_fsizes[plugin][n] < sz) { |
835 m_fs[plugin][n].features[m_fsizes[plugin][n]].hasTimestamp = 0; | 838 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.hasTimestamp = 0; |
836 m_fs[plugin][n].features[m_fsizes[plugin][n]].valueCount = 0; | 839 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.valueCount = 0; |
837 m_fs[plugin][n].features[m_fsizes[plugin][n]].values = 0; | 840 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.values = 0; |
838 m_fs[plugin][n].features[m_fsizes[plugin][n]].label = 0; | 841 m_fs[plugin][n].features[m_fsizes[plugin][n]].v1.label = 0; |
839 m_fs[plugin][n].featuresV2[m_fsizes[plugin][n]].hasDuration = 0; | 842 m_fs[plugin][n].features[m_fsizes[plugin][n + sz]].v2.hasDuration = 0; |
840 m_fvsizes[plugin][n].push_back(0); | 843 m_fvsizes[plugin][n].push_back(0); |
841 m_fsizes[plugin][n]++; | 844 m_fsizes[plugin][n]++; |
842 } | 845 } |
843 } | 846 } |
844 | 847 |
851 size_t i = m_fvsizes[plugin][n][j]; | 854 size_t i = m_fvsizes[plugin][n][j]; |
852 if (i >= sz) return; | 855 if (i >= sz) return; |
853 | 856 |
854 // std::cerr << "resizing from " << i << std::endl; | 857 // std::cerr << "resizing from " << i << std::endl; |
855 | 858 |
856 m_fs[plugin][n].features[j].values = (float *)realloc | 859 m_fs[plugin][n].features[j].v1.values = (float *)realloc |
857 (m_fs[plugin][n].features[j].values, sz * sizeof(float)); | 860 (m_fs[plugin][n].features[j].v1.values, sz * sizeof(float)); |
858 | 861 |
859 m_fvsizes[plugin][n][j] = sz; | 862 m_fvsizes[plugin][n][j] = sz; |
860 } | 863 } |
861 | 864 |
862 PluginAdapterBase::Impl::AdapterMap * | 865 PluginAdapterBase::Impl::AdapterMap * |