diff plugins/DWT.cpp @ 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 fb4688d2cca5
children c655fa61884f
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;