DrKLO/Telegram · error

Test vector FAILS\n

Error message

Test vector FAILS\n

What it means

After computing a psychoacoustic error metric across all analysis frames, the tool derives a quality score Q = 100*(1 - 0.5*log(1+err)/log(1.13)). The error `err` is the 16th-root of the accumulated per-frame weighted noise-to-mask ratio across 21 Bark bands. If Q < 0, the degraded signal is so different from the reference that it fails the quality threshold, and the tool returns EXIT_FAILURE. A passing test requires Q >= 0, which corresponds to an internal weighted error below ~0.13.

Source

Thrown at TMessagesProj/jni/opus/src/opus_compare.c:372

          Eb+=im;
        }
      }
      Eb /= (BANDS[bi+1]-BANDS[bi])*nchannels;
      Ef += Eb*Eb;
    }
    /*Using a fixed normalization value means we're willing to accept slightly
       lower quality for lower sampling rates.*/
    Ef/=NBANDS;
    Ef*=Ef;
    err+=Ef*Ef;
  }
  free(xb);
  free(X);
  free(Y);
  err=pow(err/nframes,1.0/16);
  Q=100*(1-0.5*log(1+err)/log(1.13));
  if(Q<0){
    fprintf(stderr,"Test vector FAILS\n");
    fprintf(stderr,"Internal weighted error is %f\n",err);
    return EXIT_FAILURE;
  }
  else{
    fprintf(stderr,"Test vector PASSES\n");
    fprintf(stderr,
     "Opus quality metric: %.1f %% (internal weighted error is %f)\n",Q,err);
    return EXIT_SUCCESS;
  }
}

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Check the internal weighted error printed on the next line — if it is only slightly above threshold, investigate minor regressions; if very high, suspect a fundamental mismatch.
  2. Verify both files use the same channel configuration (use -s for stereo comparisons).
  3. Verify the sample rate matches the actual encode rate via -r; a missing -r causes the sample-count check at line 238 to silently pass when rate=48000 default is correct, but frequency alignment will be wrong for non-48kHz files.
  4. Re-encode the degraded file with the same opus_demo parameters used for passing baselines and compare.
  5. If the quality drop is expected (e.g., lower bitrate), adjust the test expectation rather than treating it as a bug.
Defensive patterns

Strategy: validation

Validate before calling

// In a test harness, capture opus_compare stderr and parse the Q score
// to decide pass/fail with a configurable threshold rather than relying
// solely on exit code (which fails at Q<0).
int run_quality_check(const char *ref, const char *deg, int rate) {
    char cmd[1024];
    snprintf(cmd, sizeof(cmd), "opus_compare %s %s %s 2>&1",
             rate > 0 ? "-r" : "", rate > 0 ? "%d" : "", ref, deg);
    // ... run and parse 'Opus quality metric: NN.N %' from output
    // treat Q below your threshold (e.g., 50%%) as failure
    return 0;
}

Prevention

When it happens

Trigger: The spectral error ratio Y/X (degraded energy divided by reference energy) is consistently large across frames and bands, driving `err` above the threshold. This occurs with severe encoding artifacts, wrong decoder output, comparing files at mismatched sample rates without the -r flag, or a genuine Opus codec regression. The cross-over damping at bins 79-81 (line 352-353) shows the metric is tuned for the SILK/CELT boundary.

Common situations: Opus CI regression where a code change degrades quality; testing at extremely low bitrates where artifacts are expected; comparing a stereo reference against a mono degraded file without the -s flag; decoder bug producing silence or noise; encoding with wrong application mode (VOIP vs audio) causing different band allocation.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/82a02a5118e1c9d8. Report an issue: GitHub.