annotate Matcher.cpp @ 21:b15106b0abcd

Separate out feature extraction from distance calculations
author Chris Cannam
date Fri, 10 Oct 2014 15:58:19 +0100
parents 47f98349aa17
children 64c4c0cf80c9
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 Vamp feature extraction plugin using the MATCH audio alignment
cannam@0 5 algorithm.
cannam@0 6
cannam@0 7 Centre for Digital Music, Queen Mary, University of London.
cannam@0 8 This file copyright 2007 Simon Dixon, Chris Cannam and QMUL.
cannam@0 9
cannam@0 10 This program is free software; you can redistribute it and/or
cannam@0 11 modify it under the terms of the GNU General Public License as
cannam@0 12 published by the Free Software Foundation; either version 2 of the
cannam@0 13 License, or (at your option) any later version. See the file
cannam@0 14 COPYING included with this distribution for more information.
cannam@0 15 */
cannam@0 16
cannam@0 17 #include "Matcher.h"
cannam@0 18
cannam@0 19 #include <iostream>
cannam@0 20
cannam@4 21 #include <cstdlib>
Chris@16 22 #include <cassert>
cannam@4 23
cannam@0 24 bool Matcher::silent = true;
cannam@0 25
Chris@10 26 //#define DEBUG_MATCHER 1
Chris@10 27
Chris@15 28 Matcher::Matcher(Parameters parameters, Matcher *p) :
Chris@15 29 params(parameters)
cannam@0 30 {
Chris@10 31 #ifdef DEBUG_MATCHER
Chris@15 32 cerr << "Matcher::Matcher(" << params.sampleRate << ", " << p << ")" << endl;
Chris@10 33 #endif
cannam@0 34
cannam@0 35 otherMatcher = p; // the first matcher will need this to be set later
cannam@0 36 firstPM = (!p);
cannam@0 37 ltAverage = 0;
cannam@0 38 frameCount = 0;
cannam@0 39 runCount = 0;
cannam@0 40 blockSize = 0;
cannam@0 41 scale = 90;
cannam@0 42
Chris@15 43 blockSize = lrint(params.blockTime / params.hopTime);
Chris@15 44 #ifdef DEBUG_MATCHER
Chris@15 45 cerr << "Matcher: blockSize = " << blockSize << endl;
Chris@15 46 #endif
cannam@0 47
cannam@0 48 distance = 0;
cannam@0 49 bestPathCost = 0;
cannam@0 50 distYSizes = 0;
cannam@0 51 distXSize = 0;
cannam@0 52
cannam@0 53 initialised = false;
cannam@0 54
cannam@0 55 } // default constructor
cannam@0 56
cannam@0 57 Matcher::~Matcher()
cannam@0 58 {
Chris@10 59 #ifdef DEBUG_MATCHER
Chris@15 60 cerr << "Matcher(" << this << ")::~Matcher()" << endl;
Chris@10 61 #endif
cannam@0 62
cannam@0 63 if (initialised) {
cannam@0 64
cannam@0 65 for (int i = 0; i < distXSize; ++i) {
cannam@0 66 if (distance[i]) {
cannam@0 67 free(distance[i]);
cannam@0 68 free(bestPathCost[i]);
cannam@0 69 }
cannam@0 70 }
cannam@0 71 free(distance);
cannam@0 72 free(bestPathCost);
cannam@0 73
cannam@0 74 free(first);
cannam@0 75 free(last);
cannam@0 76
cannam@0 77 free(distYSizes);
cannam@0 78 }
cannam@0 79 }
cannam@0 80
cannam@0 81 void
cannam@0 82 Matcher::init()
cannam@0 83 {
cannam@0 84 if (initialised) return;
cannam@0 85
cannam@0 86 initialised = true;
cannam@0 87
Chris@16 88 freqMapSize = getFeatureSize(params);
Chris@16 89
Chris@15 90 makeFreqMap();
cannam@0 91
cannam@0 92 initVector<double>(prevFrame, freqMapSize);
cannam@0 93 initVector<double>(newFrame, freqMapSize);
Chris@13 94 initMatrix<double>(frames, blockSize, freqMapSize);
Chris@13 95 initVector<double>(totalEnergies, blockSize);
cannam@0 96
Chris@15 97 int distSize = (params.maxRunCount + 1) * blockSize;
cannam@0 98
cannam@0 99 distXSize = blockSize * 2;
cannam@0 100
cannam@0 101 distance = (unsigned char **)malloc(distXSize * sizeof(unsigned char *));
cannam@0 102 bestPathCost = (int **)malloc(distXSize * sizeof(int *));
cannam@0 103 distYSizes = (int *)malloc(distXSize * sizeof(int));
cannam@0 104
cannam@0 105 for (int i = 0; i < blockSize; ++i) {
cannam@0 106 distance[i] = (unsigned char *)malloc(distSize * sizeof(unsigned char));
cannam@0 107 bestPathCost[i] = (int *)malloc(distSize * sizeof(int));
cannam@0 108 distYSizes[i] = distSize;
cannam@0 109 }
cannam@0 110 for (int i = blockSize; i < distXSize; ++i) {
cannam@0 111 distance[i] = 0;
cannam@0 112 }
cannam@0 113
cannam@0 114 first = (int *)malloc(distXSize * sizeof(int));
cannam@0 115 last = (int *)malloc(distXSize * sizeof(int));
cannam@0 116
cannam@0 117 frameCount = 0;
cannam@0 118 runCount = 0;
cannam@0 119 ltAverage = 0;
cannam@0 120
cannam@0 121 } // init
cannam@0 122
cannam@0 123 void
Chris@15 124 Matcher::makeFreqMap()
cannam@0 125 {
Chris@15 126 initVector<int>(freqMap, params.fftSize/2 + 1);
Chris@15 127 if (params.useChromaFrequencyMap) {
Chris@15 128 #ifdef DEBUG_MATCHER
Chris@15 129 cerr << "makeFreqMap: calling makeChromaFrequencyMap" << endl;
Chris@15 130 #endif
Chris@15 131 makeChromaFrequencyMap();
Chris@15 132 } else {
Chris@15 133 #ifdef DEBUG_MATCHER
Chris@15 134 cerr << "makeFreqMap: calling makeStandardFrequencyMap" << endl;
Chris@15 135 #endif
Chris@15 136 makeStandardFrequencyMap();
Chris@15 137 }
cannam@0 138 } // makeFreqMap()
cannam@0 139
Chris@16 140 int
Chris@16 141 Matcher::getFeatureSize(Parameters params)
Chris@16 142 {
Chris@16 143 if (params.useChromaFrequencyMap) {
Chris@16 144 return 13;
Chris@16 145 } else {
Chris@16 146 return 84;
Chris@16 147 }
Chris@16 148 }
Chris@16 149
cannam@0 150 void
Chris@15 151 Matcher::makeStandardFrequencyMap()
cannam@0 152 {
Chris@15 153 double binWidth = params.sampleRate / params.fftSize;
cannam@0 154 int crossoverBin = (int)(2 / (pow(2, 1/12.0) - 1));
cannam@7 155 int crossoverMidi = lrint(log(crossoverBin*binWidth/440.0)/
cannam@7 156 log(2.0) * 12 + 69);
cannam@0 157 // freq = 440 * Math.pow(2, (midi-69)/12.0) / binWidth;
cannam@0 158 int i = 0;
cannam@0 159 while (i <= crossoverBin) {
cannam@0 160 freqMap[i] = i;
cannam@0 161 ++i;
cannam@0 162 }
Chris@15 163 while (i <= params.fftSize/2) {
cannam@7 164 double midi = log(i*binWidth/440.0) / log(2.0) * 12 + 69;
Chris@16 165 if (midi > 127) midi = 127;
cannam@0 166 freqMap[i++] = crossoverBin + lrint(midi) - crossoverMidi;
cannam@0 167 }
Chris@16 168 assert(freqMapSize == freqMap[i-1] + 1);
cannam@0 169 if (!silent) {
cannam@0 170 cerr << "Standard map size: " << freqMapSize
cannam@0 171 << "; Crossover at: " << crossoverBin << endl;
Chris@15 172 for (i = 0; i < params.fftSize / 2; i++)
Chris@15 173 cerr << "freqMap[" << i << "] = " << freqMap[i] << endl;
cannam@0 174 }
cannam@0 175 } // makeStandardFrequencyMap()
cannam@0 176
cannam@0 177 void
Chris@15 178 Matcher::makeChromaFrequencyMap()
cannam@0 179 {
Chris@15 180 double binWidth = params.sampleRate / params.fftSize;
cannam@0 181 int crossoverBin = (int)(1 / (pow(2, 1/12.0) - 1));
cannam@0 182 // freq = 440 * Math.pow(2, (midi-69)/12.0) / binWidth;
cannam@0 183 int i = 0;
cannam@0 184 while (i <= crossoverBin)
cannam@0 185 freqMap[i++] = 0;
Chris@15 186 while (i <= params.fftSize/2) {
cannam@7 187 double midi = log(i*binWidth/440.0) / log(2.0) * 12 + 69;
cannam@0 188 freqMap[i++] = (lrint(midi)) % 12 + 1;
cannam@0 189 }
cannam@0 190 if (!silent) {
cannam@0 191 cerr << "Chroma map size: " << freqMapSize
cannam@0 192 << "; Crossover at: " << crossoverBin << endl;
Chris@15 193 for (i = 0; i < params.fftSize / 2; i++)
cannam@0 194 cerr << "freqMap[" << i << "] = " << freqMap[i] << endl;
cannam@0 195 }
cannam@0 196 } // makeChromaFrequencyMap()
cannam@0 197
Chris@14 198 vector<double>
Chris@21 199 Matcher::consumeFrame(double *reBuffer, double *imBuffer)
cannam@0 200 {
cannam@0 201 if (!initialised) init();
cannam@0 202
Chris@21 203 vector<double> processedFrame =
Chris@21 204 processFrameFromFreqData(reBuffer, imBuffer);
Chris@21 205
Chris@21 206 calcAdvance();
Chris@21 207
Chris@21 208 if ((frameCount % 100) == 0) {
Chris@21 209 if (!silent) {
Chris@21 210 cerr << "Progress:" << frameCount << " " << ltAverage << endl;
Chris@21 211 }
Chris@21 212 }
Chris@21 213
Chris@21 214 return processedFrame;
Chris@21 215 }
Chris@21 216
Chris@21 217 vector<double>
Chris@21 218 Matcher::processFrameFromFreqData(double *reBuffer, double *imBuffer)
Chris@21 219 {
cannam@0 220 for (int i = 0; i < (int)newFrame.size(); ++i) {
cannam@0 221 newFrame[i] = 0;
cannam@0 222 }
cannam@0 223 double rms = 0;
Chris@15 224 for (int i = 0; i <= params.fftSize/2; i++) {
cannam@0 225 double mag = reBuffer[i] * reBuffer[i] +
cannam@0 226 imBuffer[i] * imBuffer[i];
cannam@0 227 rms += mag;
cannam@0 228 newFrame[freqMap[i]] += mag;
cannam@0 229 }
Chris@15 230 rms = sqrt(rms / (params.fftSize/2));
cannam@0 231
cannam@0 232 int frameIndex = frameCount % blockSize;
cannam@0 233
Chris@21 234 vector<double> processedFrame(freqMapSize, 0.0);
Chris@21 235
Chris@21 236 double totalEnergy = 0;
Chris@21 237 if (params.useSpectralDifference) {
Chris@21 238 for (int i = 0; i < freqMapSize; i++) {
Chris@21 239 totalEnergy += newFrame[i];
Chris@21 240 if (newFrame[i] > prevFrame[i]) {
Chris@21 241 processedFrame[i] = newFrame[i] - prevFrame[i];
Chris@21 242 } else {
Chris@21 243 processedFrame[i] = 0;
Chris@21 244 }
Chris@21 245 }
Chris@21 246 } else {
Chris@21 247 for (int i = 0; i < freqMapSize; i++) {
Chris@21 248 processedFrame[i] = newFrame[i];
Chris@21 249 totalEnergy += processedFrame[i];
Chris@21 250 }
Chris@21 251 }
Chris@21 252 totalEnergies[frameIndex] = totalEnergy;
Chris@21 253
Chris@21 254 double decay = frameCount >= 200 ? 0.99:
Chris@21 255 (frameCount < 100? 0: (frameCount - 100) / 100.0);
Chris@21 256
Chris@21 257 if (ltAverage == 0)
Chris@21 258 ltAverage = totalEnergy;
Chris@21 259 else
Chris@21 260 ltAverage = ltAverage * decay + totalEnergy * (1.0 - decay);
Chris@21 261
Chris@21 262 if (rms <= params.silenceThreshold)
Chris@21 263 for (int i = 0; i < freqMapSize; i++)
Chris@21 264 processedFrame[i] = 0;
Chris@21 265 else if (params.frameNorm == NormaliseFrameToSum1)
Chris@21 266 for (int i = 0; i < freqMapSize; i++)
Chris@21 267 processedFrame[i] /= totalEnergy;
Chris@21 268 else if (params.frameNorm == NormaliseFrameToLTAverage)
Chris@21 269 for (int i = 0; i < freqMapSize; i++)
Chris@21 270 processedFrame[i] /= ltAverage;
Chris@21 271
Chris@21 272 vector<double> tmp = prevFrame;
Chris@21 273 prevFrame = newFrame;
Chris@21 274 newFrame = tmp;
Chris@21 275
Chris@21 276 frames[frameIndex] = processedFrame;
Chris@21 277
Chris@21 278 return processedFrame;
Chris@21 279 }
Chris@21 280
Chris@21 281 void
Chris@21 282 Matcher::calcAdvance()
Chris@21 283 {
Chris@21 284 int frameIndex = frameCount % blockSize;
Chris@21 285
cannam@0 286 if (frameCount >= distXSize) {
cannam@0 287 // std::cerr << "Resizing " << distXSize << " -> " << distXSize * 2 << std::endl;
cannam@0 288 distXSize *= 2;
cannam@0 289 distance = (unsigned char **)realloc(distance, distXSize * sizeof(unsigned char *));
cannam@0 290 bestPathCost = (int **)realloc(bestPathCost, distXSize * sizeof(int *));
cannam@0 291 distYSizes = (int *)realloc(distYSizes, distXSize * sizeof(int));
cannam@0 292 first = (int *)realloc(first, distXSize * sizeof(int));
cannam@0 293 last = (int *)realloc(last, distXSize * sizeof(int));
cannam@0 294
cannam@0 295 for (int i = distXSize/2; i < distXSize; ++i) {
cannam@0 296 distance[i] = 0;
cannam@0 297 }
cannam@0 298 }
cannam@0 299
cannam@0 300 if (firstPM && (frameCount >= blockSize)) {
cannam@0 301
cannam@0 302 int len = last[frameCount - blockSize] -
cannam@0 303 first[frameCount - blockSize];
cannam@0 304
cannam@0 305 // We need to copy distance[frameCount-blockSize] to
cannam@0 306 // distance[frameCount], and then truncate
cannam@0 307 // distance[frameCount-blockSize] to its first len elements.
cannam@0 308 // Same for bestPathCost.
cannam@0 309 /*
cannam@4 310 std::cerr << "Matcher(" << this << "): moving " << distYSizes[frameCount - blockSize] << " from " << frameCount - blockSize << " to "
cannam@0 311 << frameCount << ", allocating " << len << " for "
cannam@0 312 << frameCount - blockSize << std::endl;
cannam@0 313 */
cannam@0 314 distance[frameCount] = distance[frameCount - blockSize];
cannam@0 315
cannam@0 316 distance[frameCount - blockSize] = (unsigned char *)
cannam@0 317 malloc(len * sizeof(unsigned char));
cannam@0 318 for (int i = 0; i < len; ++i) {
cannam@0 319 distance[frameCount - blockSize][i] =
cannam@0 320 distance[frameCount][i];
cannam@0 321 }
cannam@0 322
cannam@0 323 bestPathCost[frameCount] = bestPathCost[frameCount - blockSize];
cannam@0 324
cannam@0 325 bestPathCost[frameCount - blockSize] = (int *)
cannam@0 326 malloc(len * sizeof(int));
cannam@0 327 for (int i = 0; i < len; ++i) {
cannam@0 328 bestPathCost[frameCount - blockSize][i] =
cannam@0 329 bestPathCost[frameCount][i];
cannam@0 330 }
cannam@0 331
cannam@0 332 distYSizes[frameCount] = distYSizes[frameCount - blockSize];
cannam@0 333 distYSizes[frameCount - blockSize] = len;
cannam@0 334 }
cannam@0 335
cannam@0 336 int stop = otherMatcher->frameCount;
cannam@0 337 int index = stop - blockSize;
cannam@0 338 if (index < 0)
cannam@0 339 index = 0;
cannam@0 340 first[frameCount] = index;
cannam@0 341 last[frameCount] = stop;
cannam@0 342
cannam@0 343 bool overflow = false;
cannam@0 344 int mn= -1;
cannam@0 345 int mx= -1;
cannam@0 346 for ( ; index < stop; index++) {
cannam@0 347 int dMN = calcDistance(frames[frameIndex],
cannam@0 348 otherMatcher->frames[index % blockSize]);
cannam@0 349 if (mx<0)
cannam@0 350 mx = mn = dMN;
cannam@0 351 else if (dMN > mx)
cannam@0 352 mx = dMN;
cannam@0 353 else if (dMN < mn)
cannam@0 354 mn = dMN;
cannam@0 355 if (dMN >= 255) {
cannam@0 356 overflow = true;
cannam@0 357 dMN = 255;
cannam@0 358 }
cannam@0 359 if ((frameCount == 0) && (index == 0)) // first element
cannam@0 360 setValue(0, 0, 0, 0, dMN);
cannam@0 361 else if (frameCount == 0) // first row
cannam@0 362 setValue(0, index, ADVANCE_OTHER,
cannam@0 363 getValue(0, index-1, true), dMN);
cannam@0 364 else if (index == 0) // first column
cannam@0 365 setValue(frameCount, index, ADVANCE_THIS,
cannam@0 366 getValue(frameCount - 1, 0, true), dMN);
cannam@0 367 else if (index == otherMatcher->frameCount - blockSize) {
cannam@0 368 // missing value(s) due to cutoff
cannam@0 369 // - no previous value in current row (resp. column)
cannam@0 370 // - no diagonal value if prev. dir. == curr. dirn
cannam@0 371 int min2 = getValue(frameCount - 1, index, true);
cannam@0 372 // if ((firstPM && (first[frameCount - 1] == index)) ||
cannam@0 373 // (!firstPM && (last[index-1] < frameCount)))
cannam@0 374 if (first[frameCount - 1] == index)
cannam@0 375 setValue(frameCount, index, ADVANCE_THIS, min2, dMN);
cannam@0 376 else {
cannam@0 377 int min1 = getValue(frameCount - 1, index - 1, true);
cannam@0 378 if (min1 + dMN <= min2)
cannam@0 379 setValue(frameCount, index, ADVANCE_BOTH, min1,dMN);
cannam@0 380 else
cannam@0 381 setValue(frameCount, index, ADVANCE_THIS, min2,dMN);
cannam@0 382 }
cannam@0 383 } else {
cannam@0 384 int min1 = getValue(frameCount, index-1, true);
cannam@0 385 int min2 = getValue(frameCount - 1, index, true);
cannam@0 386 int min3 = getValue(frameCount - 1, index-1, true);
cannam@0 387 if (min1 <= min2) {
cannam@0 388 if (min3 + dMN <= min1)
cannam@0 389 setValue(frameCount, index, ADVANCE_BOTH, min3,dMN);
cannam@0 390 else
cannam@0 391 setValue(frameCount, index, ADVANCE_OTHER,min1,dMN);
cannam@0 392 } else {
cannam@0 393 if (min3 + dMN <= min2)
cannam@0 394 setValue(frameCount, index, ADVANCE_BOTH, min3,dMN);
cannam@0 395 else
cannam@0 396 setValue(frameCount, index, ADVANCE_THIS, min2,dMN);
cannam@0 397 }
cannam@0 398 }
cannam@0 399 otherMatcher->last[index]++;
cannam@0 400 } // loop for row (resp. column)
cannam@0 401
cannam@0 402 frameCount++;
cannam@0 403 runCount++;
cannam@0 404
cannam@0 405 otherMatcher->runCount = 0;
cannam@0 406
cannam@0 407 if (overflow && !silent)
cannam@0 408 cerr << "WARNING: overflow in distance metric: "
cannam@0 409 << "frame " << frameCount << ", val = " << mx << endl;
Chris@21 410
cannam@0 411 if (!silent)
cannam@0 412 std::cerr << "Frame " << frameCount << ", d = " << (mx-mn) << std::endl;
Chris@21 413 }
cannam@0 414
cannam@0 415 int
cannam@0 416 Matcher::calcDistance(const vector<double> &f1, const vector<double> &f2)
cannam@0 417 {
cannam@0 418 double d = 0;
cannam@0 419 double sum = 0;
cannam@0 420 for (int i = 0; i < freqMapSize; i++) {
cannam@0 421 d += fabs(f1[i] - f2[i]);
cannam@0 422 sum += f1[i] + f2[i];
cannam@0 423 }
cannam@0 424 // System.err.print(" " + Format.d(d,3));
cannam@0 425 if (sum == 0)
cannam@0 426 return 0;
Chris@15 427 if (params.distanceNorm == NormaliseDistanceToSum)
cannam@0 428 return (int)(scale * d / sum); // 0 <= d/sum <= 2
Chris@15 429 if (params.distanceNorm != NormaliseDistanceToLogSum)
cannam@0 430 return (int)(scale * d);
Chris@13 431
Chris@13 432 // note if this were to be restored, it would have to use
Chris@13 433 // totalEnergies vector instead of f1[freqMapSize] which used to
Chris@13 434 // store the total energy:
cannam@0 435 // double weight = (5 + Math.log(f1[freqMapSize] + f2[freqMapSize]))/10.0;
Chris@13 436
cannam@0 437 double weight = (8 + log(sum)) / 10.0;
cannam@0 438 // if (weight < mins) {
cannam@0 439 // mins = weight;
cannam@0 440 // System.err.println(Format.d(mins,3) + " " + Format.d(maxs));
cannam@0 441 // }
cannam@0 442 // if (weight > maxs) {
cannam@0 443 // maxs = weight;
cannam@0 444 // System.err.println(Format.d(mins,3) + " " + Format.d(maxs));
cannam@0 445 // }
cannam@0 446 if (weight < 0)
cannam@0 447 weight = 0;
cannam@0 448 else if (weight > 1)
cannam@0 449 weight = 1;
cannam@0 450 return (int)(scale * d / sum * weight);
cannam@0 451 } // calcDistance()
cannam@0 452
cannam@0 453 int
cannam@0 454 Matcher::getValue(int i, int j, bool firstAttempt)
cannam@0 455 {
cannam@0 456 if (firstPM)
cannam@0 457 return bestPathCost[i][j - first[i]];
cannam@0 458 else
cannam@0 459 return otherMatcher->bestPathCost[j][i - otherMatcher->first[j]];
cannam@0 460 } // getValue()
cannam@0 461
cannam@0 462 void
cannam@0 463 Matcher::setValue(int i, int j, int dir, int value, int dMN)
cannam@0 464 {
cannam@0 465 if (firstPM) {
cannam@0 466 distance[i][j - first[i]] = (unsigned char)((dMN & MASK) | dir);
cannam@0 467 bestPathCost[i][j - first[i]] =
cannam@0 468 (value + (dir==ADVANCE_BOTH? dMN*2: dMN));
cannam@0 469 } else {
cannam@0 470 if (dir == ADVANCE_THIS)
cannam@0 471 dir = ADVANCE_OTHER;
cannam@0 472 else if (dir == ADVANCE_OTHER)
cannam@0 473 dir = ADVANCE_THIS;
cannam@0 474 int idx = i - otherMatcher->first[j];
cannam@0 475 if (idx == (int)otherMatcher->distYSizes[j]) {
cannam@0 476 // This should never happen, but if we allow arbitrary
cannam@0 477 // pauses in either direction, and arbitrary lengths at
cannam@0 478 // end, it is better than a segmentation fault.
cannam@0 479 std::cerr << "Emergency resize: " << idx << " -> " << idx * 2 << std::endl;
cannam@0 480 otherMatcher->distYSizes[j] = idx * 2;
cannam@0 481 otherMatcher->bestPathCost[j] =
cannam@0 482 (int *)realloc(otherMatcher->bestPathCost[j],
cannam@0 483 idx * 2 * sizeof(int));
cannam@0 484 otherMatcher->distance[j] =
cannam@0 485 (unsigned char *)realloc(otherMatcher->distance[j],
cannam@0 486 idx * 2 * sizeof(unsigned char));
cannam@0 487 }
cannam@0 488 otherMatcher->distance[j][idx] = (unsigned char)((dMN & MASK) | dir);
cannam@0 489 otherMatcher->bestPathCost[j][idx] =
cannam@0 490 (value + (dir==ADVANCE_BOTH? dMN*2: dMN));
cannam@0 491 }
cannam@0 492 } // setValue()
cannam@0 493