Commit 89fa9cb6 authored by norvell's avatar norvell
Browse files

Move result dict init in audioarray.compare

parent 49984457
Loading
Loading
Loading
Loading
Loading
+23 −21
Original line number Diff line number Diff line
@@ -306,6 +306,29 @@ def compare(

    framesize = fs // 50

    # Init result dict
    result = {
        "bitexact": True,
        "max_abs_diff": 0,
        "max_abs_diff_pos_sample": 0,
        "max_abs_diff_pos_channel": 0,
        "nsamples_diff": 0,
        "nsamples_diff_percentage": 0.0,
        "first_diff_pos_sample": -1,
        "first_diff_pos_channel": -1,
        "first_diff_pos_frame": -1,
    }

    if get_mld:
        result["MLD"] = 0
    if get_ssnr:
        result["SSNR"] = np.asarray([np.inf] * ref.shape[1])

    if per_frame:
        result["max_abs_diff_pos_frame"] = 0
        result["nframes_diff"] = 0
        result["nframes_diff_percentage"] = 0.0

    # MLD (wav-diff) tool is run first, since it uses the input signals without length difference check for JBM test cases.
    if get_mld:

@@ -414,27 +437,6 @@ def compare(
    diff = abs(test - ref)

    max_diff = int(diff.max())
    result = {
        "bitexact": True,
        "max_abs_diff": 0,
        "max_abs_diff_pos_sample": 0,
        "max_abs_diff_pos_channel": 0,
        "nsamples_diff": 0,
        "nsamples_diff_percentage": 0.0,
        "first_diff_pos_sample": -1,
        "first_diff_pos_channel": -1,
        "first_diff_pos_frame": -1,
    }

    if get_mld:
        result["MLD"] = 0
    if get_ssnr:
        result["SSNR"] = np.asarray([np.inf] * ref.shape[1])

    if per_frame:
        result["max_abs_diff_pos_frame"] = 0
        result["nframes_diff"] = 0
        result["nframes_diff_percentage"] = 0.0

    if max_diff != 0:
        if diff.ndim == 1: