Skip to content

aspt/diff_tools

Repository files navigation

diff_tools

Set of tools for media files comparison:

  • WavDiif - Command-line tool for audio files comparison

The WD (WavDiff) is a command-line tool for audio file comparison and statistical analysis

  • wav or raw PCM formats
  • signed integer of IEEE floating-point formats
  • fast automatic alignment
  • files and directories comparison with wildcards support
  • save difference or aligned
  • unicode file names support
  • can compare files with different precision, for example IEEE double with 16-bit PCM

Command-line options

usage: wd file1 [file2 [file_difference]] [options]

Option       Defaults  Note
=============================================================================
file1        mandatory First (reference) file/directory to compare (WAV/PCM)
file2        optional  Second (test) file/directory to compare (WAV/PCM)
file_diff    optional  Produce difference between files := file2 - file1
-r<file>     optional  Copy screen output to &lt;file&gt; (owerwrite mode)
-p<file>     optional  Copy screen output to &lt;file&gt; (append mode)
-bits<int>   16        Bits per sample for raw PCM
-ch<int>     2         Number of channels for raw PCM
-ll          file mode Produce detailed report listing
-ls          dir mode  Produce short one-line report listing
-lx          no        One-line report listing w/o bitexact files
-ob1:<int>   0         Ignore &lt;int&gt; initial data bytes of the first file
-ob2:<int>   0         Ignore &lt;int&gt; initial data bytes of the second file
-os1:<int>   0         Ignore &lt;int&gt; initial samples of the first file
-os2:<int>   0         Ignore &lt;int&gt; initial samples of the second file
-align<int>  No        Use &quot;Best Match&quot; offset sample before comparison.
-saveAligned No        Write aligned second file instead of difference
-wo          No        No warn on file open fail
-h           No        Produce wd.html help file
=============================================================================
Notes:
 * wildcards * and ? in file names accepted
 * -bits and -ch options are used only for raw PCM files
 * Negative -bits values convert PCM samples from Motorola format
 * Fractional -bits values assumes IEEE format: -bits.32 == float
 * "Best Match" alignment applied after -off parameters,
   so it gives you a chance to compare parts after dropouts
 * If only one file name given, file statistics reported
 * -align option can take <int> argument to increase alignement buffer size
 * -short listing difference always shown in 16-bit samples
Examples:
wd -align256k -ls reference.wav totest.wav diff.wav -rTestReport.txt
wd ref/*.wav test/*.raw -align

Sample output: long listing (-ll option)


Comparing  WAV 24 bits 6 ch 44100 Hz 4414-AMODE5+lfe.dts.wav (878592 samples)
With       RAW 24 bits 6 ch 44100 Hz 4414-AMODE5+lfe.dts_.wav (881666 samples)
Compared: 878592 samples ( 99.7%).
3 samples skipped from 2nd file. 3071 samples remains in 2nd file.
                        Total          |Ch 1           Ch 2           Ch 3           Ch 4           Ch 5           Ch 6
PSNR Square(dB):        24.45          |22.98          23.22          21.99          22.66          MATCH          MATCH
PSNR Sine  (dB):        21.44          |19.97          20.21          18.98          19.65          MATCH          MATCH
SNR        (dB):        -0.00          |-0.00          -0.00          -0.00          -0.00          MATCH          MATCH
Quantizer  bits:        3.269          |3.025          3.065          2.860          2.972          MATCH          MATCH
RMSE   (* 2^24):        502537.349     |595092.376     578862.711     667001.893     617376.891     0.000          0.000
|Max|  (* 2^24):        1023366        |844091         1023366        946202         881988         0              0
DC     (* 2^24):        -104.8793      |-7.3486        0.6824         -7.4617        -615.1479      0.0000         0.0000
S/N correlation:        -1.0000000     |-1.00000000    -1.00000000    -1.00000000    -1.00000000    0.00000000     0.00000000
Noise ACF (R01):        0.98522829     |0.98986608     0.99746345     0.95967469     0.99998976     0.00000000     0.00000000
Amplification  :        0.00000000     |0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000

Long listing report statistic for each channel and summary statistic for whole file. See detailed description of statistical below.

Sample output: short listing (-ls option)


PSNR (dB):24.45    Max*2^16:(3297 : 3998 : 3696 : 3445 : 0 : 0)  RAW/24 /44100 [ 878592 smp]  Offsets: 3+[1st]+3071 <-> [2nd]                     4414-AMODE5+lfe.dts.wav
PSNR (dB):141.49   Max*2^16:(0.00)                               WAV/24 /32000 [2087152 smp]  Offsets: 10000+[1st]  <-> [2nd]                     am00_32off.wav         
PSNR (dB):MATCH    Max*2^16:(0.00)                               WAV/dbl/32000 [2077153 smp]  Offsets: 9999+[1st]   <-> [2nd]+13855               off1.wav               
PSNR (dB):MATCH    Max*2^16:(0.00)                               WAV/dbl/32000 [2081009 smp]  Offsets: 9999+[1st]   <-> [2nd]+6143                off10k.wav             
Note that short listing always shows maximum difference with 16-bit precison

Sample output: directory comparison summary


Files compared: 24 from 28
Average PSNR square wave,    dB : 79.82   
Equivalent quantization    bits : 12.466  
Worst-case PSNR square wave, dB : 72.08    noise\i08_48.wav
Worst-case diff,             dB : 42.14    noise\i08_1.wav
Worst-case diff, 16-bit samples : 256.00 
DC offset,       16-bit samples : +0.00443 (137.38  dB)
Amplification                   :  1.00000 (-0.00   dB)
S/N correlation                 : +0.00069

What it does?

The WD tool accept two inputs, 1st input assumed to be the “signal”, while 2nd input assumed to be “signal + noise”. So, for this tool

signal = input1

noise = input2 - input1

If only one input given, then it is taken for “noise”.“

The WD tool estimates following signal statistics

Variance

This is most informative value, directly related to noise power. Note that expected value of the signal assumed to be zero. The calculated variance is not reported by this tool; instead, it is used to calculate several variance-related metrics: SNR, PSNR, RMSE and quantization bits.

Signal-to-Noise Ratio

SNR is dimensionless unit, expressed in decibels. If noise or signal variance is zero, SNR is not defined. The tool displays 'MATCH' if noise is absent. If signal value is zero, but noise variance is not zero, SNR indicated as 'INF'

Peak Signal-to-Noise Ratio

The PSNR metric is similar to SNR, but instead of actual input signal variance, it takes a variance of the hypothetical signal with maximum dynamic range. This metric is more reasonable than SNR for stationary additive nose, since it does not depend on input signal, and estimates only noise power.

For float-point signals it is assumed that signal range is [-1;1]

For audio signals there are two variants of this metric, depending on what is taken for “Maximum variance” signal. Most frequently a constant signal with maximum amplitude, or square wave, is taken. But sometimes, a “Maximum variance” signal assumed to be a sine signal with maximum amplitude. Since sine wave power of is a half of square wave power,

these PSNR metrics are differs by 3 dB

Equivalent quantizer bits

This metric estimates noise power as number of bits, required for uniform quantization process to provide equivalent noise level. The uniform quantizer noise estimated as

Where nbits is a number of quantizer bits, including sign bit. Note: each quantizer bits costs about 6 dB.

The quantizer bits estimated as:

RMS error

RMS is a acronym for “Root Mean Square”. This value expressed in LSB. Also known as L2 metric.

Maximum deviation

Amplitude of maximum noise value, in LSB. Also known as L-inf metric.

Arithmetic mean

For audio engineering, this value called “DC offset”. DC is a acronym for “Direct Current”. Non-zero DC is undesirable effect for audio applications

Signal-noise correlation

Dimensionless value in the range from -1 to 1. Estimate how does the noise correlate with the signal. Correlated noise is harder to handle, and should be avoided. Note that correlated noise may also indicate signal amplitude change (see amplification below).

Noise autocorrelation

Dimensionless value in the range from -1 to 1, representing first coefficient of auto-correlation. Rough estimate of how "white" is the noise. "Colored" noise is harder to handle than "white" noise.

Amplification

Estimates signal level change. Significant multiplicative error makes

Note: RMSE, Max and DC values are reported in LSB's (Leas Significant Bit). The LSB weight reported beside the value, for example “(* 2^16)” for 16-bit signals, etc.

About

Set of tools for media files comparison

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages