Mercurial > hg > match-vamp
comparison src/Matcher.cpp @ 207:0159aff8c4c5 memory
Simplify memory reduction
author | Chris Cannam |
---|---|
date | Fri, 27 Feb 2015 12:53:04 +0000 |
parents | fb799a1aabd8 |
children | 9a8fc47d4f93 |
comparison
equal
deleted
inserted
replaced
206:fb799a1aabd8 | 207:0159aff8c4c5 |
---|---|
294 | 294 |
295 if (m_frameCount >= m_distXSize) { | 295 if (m_frameCount >= m_distXSize) { |
296 m_distXSize *= 2; | 296 m_distXSize *= 2; |
297 size(); | 297 size(); |
298 } | 298 } |
299 | 299 |
300 if (m_firstPM && (m_frameCount >= m_blockSize)) { | 300 if (m_firstPM && (m_frameCount >= m_blockSize)) { |
301 | 301 // Memory reduction for old rows |
302 int len = m_last[m_frameCount - m_blockSize] - | 302 int oldidx = m_frameCount - m_blockSize; |
303 m_first[m_frameCount - m_blockSize]; | 303 int len = m_last[oldidx] - m_first[oldidx]; |
304 | 304 m_distance[oldidx].resize(len); |
305 // We need to copy distance[m_frameCount-m_blockSize] to | 305 m_bestPathCost[oldidx].resize(len); |
306 // distance[m_frameCount], and then truncate | 306 m_advance[oldidx].resize(len); |
307 // distance[m_frameCount-m_blockSize] to its first len elements. | |
308 // Same for bestPathCost. | |
309 | |
310 distancevec_t dOld(m_distance[m_frameCount - m_blockSize]); | |
311 distancevec_t dNew(len, InvalidDistance); | |
312 | |
313 pathcostvec_t bpcOld(m_bestPathCost[m_frameCount - m_blockSize]); | |
314 pathcostvec_t bpcNew(len, InvalidPathCost); | |
315 | |
316 advancevec_t adOld(m_advance[m_frameCount - m_blockSize]); | |
317 advancevec_t adNew(len, AdvanceNone); | |
318 | |
319 for (int i = 0; i < len; ++i) { | |
320 dNew[i] = dOld[i]; | |
321 bpcNew[i] = bpcOld[i]; | |
322 adNew[i] = adOld[i]; | |
323 } | |
324 | |
325 m_distance[m_frameCount] = dOld; | |
326 m_distance[m_frameCount - m_blockSize] = dNew; | |
327 | |
328 m_bestPathCost[m_frameCount] = bpcOld; | |
329 m_bestPathCost[m_frameCount - m_blockSize] = bpcNew; | |
330 | |
331 m_advance[m_frameCount] = adOld; | |
332 m_advance[m_frameCount - m_blockSize] = adNew; | |
333 } | 307 } |
334 | 308 |
335 int stop = m_otherMatcher->m_frameCount; | 309 int stop = m_otherMatcher->m_frameCount; |
336 int index = stop - m_blockSize; | 310 int index = stop - m_blockSize; |
337 if (index < 0) index = 0; | 311 if (index < 0) index = 0; |