diff vamp-sdk/PluginAdapter.h @ 12:a3d35e11c3fe

* Avoid repeated malloc/free for returned feature lists -- reuse static feature lists where possible. Need to document the host behaviour that permits this (i.e. a returned feature list is only valid until the next call to process, getRemainingFeatures or releaseFeatureSet)
author cannam
date Thu, 06 Apr 2006 15:12:25 +0000
parents 83d3eb580731
children 85801331454c
line wrap: on
line diff
--- a/vamp-sdk/PluginAdapter.h	Thu Apr 06 12:26:44 2006 +0000
+++ b/vamp-sdk/PluginAdapter.h	Thu Apr 06 15:12:25 2006 +0000
@@ -84,25 +84,26 @@
 
     static void vampReleaseOutputDescriptor(VampOutputDescriptor *desc);
 
-    static VampFeatureList **vampProcess(VampPluginHandle handle,
-                                       float **inputBuffers,
-                                       int sec,
-                                       int nsec);
+    static VampFeatureList *vampProcess(VampPluginHandle handle,
+                                        float **inputBuffers,
+                                        int sec,
+                                        int nsec);
 
-    static VampFeatureList **vampGetRemainingFeatures(VampPluginHandle handle);
+    static VampFeatureList *vampGetRemainingFeatures(VampPluginHandle handle);
 
-    static void vampReleaseFeatureSet(VampFeatureList **fs);
+    static void vampReleaseFeatureSet(VampFeatureList *fs);
 
     void cleanup(Plugin *plugin);
     void checkOutputMap(Plugin *plugin);
     unsigned int getOutputCount(Plugin *plugin);
     VampOutputDescriptor *getOutputDescriptor(Plugin *plugin,
                                              unsigned int i);
-    VampFeatureList **process(Plugin *plugin,
+    VampFeatureList *process(Plugin *plugin,
                               float **inputBuffers,
                               int sec, int nsec);
-    VampFeatureList **getRemainingFeatures(Plugin *plugin);
-    VampFeatureList **convertFeatures(const Plugin::FeatureSet &features);
+    VampFeatureList *getRemainingFeatures(Plugin *plugin);
+    VampFeatureList *convertFeatures(Plugin *plugin,
+                                     const Plugin::FeatureSet &features);
     
     typedef std::map<const void *, PluginAdapterBase *> AdapterMap;
     static AdapterMap m_adapterMap;
@@ -116,8 +117,12 @@
     typedef std::map<Plugin *, Plugin::OutputList *> OutputMap;
     OutputMap m_pluginOutputs;
 
-    typedef std::map<Plugin *, VampFeature ***> FeatureBufferMap;
-    FeatureBufferMap m_pluginFeatures;
+    std::map<Plugin *, VampFeatureList *> m_fs;
+    std::map<Plugin *, std::vector<size_t> > m_fsizes;
+    std::map<Plugin *, std::vector<std::vector<size_t> > > m_fvsizes;
+    void resizeFS(Plugin *plugin, int n);
+    void resizeFL(Plugin *plugin, int n, size_t sz);
+    void resizeFV(Plugin *plugin, int n, int j, size_t sz);
 };
 
 template <typename P>