changeset 129:1a24b134cd79

* give a sensible preferred block size, & fail to initialise if block size is too small
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 03 Jul 2009 13:08:12 +0000
parents 9949881120a4
children c655fa61884f
files plugins/DWT.cpp plugins/DWT.h
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/DWT.cpp	Tue Jun 30 14:50:08 2009 +0000
+++ b/plugins/DWT.cpp	Fri Jul 03 13:08:12 2009 +0000
@@ -70,6 +70,14 @@
 }
 
 size_t 
+DWT::getPreferredBlockSize() const 
+{ 
+    size_t s = (1 << m_scales);
+    while (s < 1024) s *= 2;
+    return s;
+} 
+
+size_t 
 DWT::getPreferredStepSize() const 
 { 
     return 0;  
@@ -81,6 +89,11 @@
     if (channels < getMinChannelCount() ||
         channels > getMaxChannelCount()) return false;
 	
+    if ((1 << m_scales) > blockSize) {
+        std::cerr << "DWT::initialise: ERROR: Block size must be at least 2^scales (specified block size " << blockSize << " < " << (1 << m_scales) << ")" << std::endl;
+        return false;
+    }
+
     m_stepSize = stepSize;
     m_blockSize = blockSize;
 
--- a/plugins/DWT.h	Tue Jun 30 14:50:08 2009 +0000
+++ b/plugins/DWT.h	Fri Jul 03 13:08:12 2009 +0000
@@ -34,6 +34,7 @@
     std::string getMaker() const;
     int getPluginVersion() const;
     std::string getCopyright() const;
+    size_t getPreferredBlockSize() const;
     size_t getPreferredStepSize() const;
 	
     OutputList getOutputDescriptors() const;