Skip to content

Compare writes NaN and Infinity metrics when no frame is evaluated #49

Description

@msg7086

Analysis attribution: This issue analysis was created by Codex GPT.
The GitHub user who submits this issue does not claim authorship of the analysis.

Finding

  • Finding ID: B11-compare-zero-frame-log-summary
  • Status: Reproduced defect
  • Severity: Low
  • Affected component: Compare
  • Source location: avs_core/filters/text-overlay.cpp:2510-2521

Summary

The destructor computes summary metrics and logarithms unconditionally when framecount is zero.

Affected Code

Compare::~Compare()
{
  if (log) {
    fprintf(log,"\n\n\nTotal frames processed: %d\n\n", framecount);
    fprintf(log,"                           Minimum   Average   Maximum\n");
    fprintf(log,"Mean Absolute Deviation: %9.4f %9.4f %9.4f\n", MAD_min, MAD_tot/framecount, MAD_max);
    fprintf(log,"         Mean Deviation: %+9.4f %+9.4f %+9.4f\n", MD_min, MD_tot/framecount, MD_max);
    fprintf(log,"                   PSNR: %9.4f %9.4f %9.4f\n", PSNR_min, PSNR_tot/framecount, PSNR_max);
    double factor = (1 << bits_per_pixel) - 1;
    double PSNR_overall = 10.0 * log10(bytecount_overall * factor * factor / SSD_overall);
    fprintf(log,"           Overall PSNR: %9.4f\n", PSNR_overall);
    fclose(log);
  }
}

Correct Behavior

For zero evaluated frames, skip metric division/logarithms and write a defined no-data summary.

Reproduction

Create Compare with a logfile, then destroy it without calling GetFrame.

Observed Result

observed: logfile contains nan and inf
expected: finite, explicit zero-frame summary

Impact

Log consumers receive invalid numeric output for a legitimate no-evaluation lifetime.

Validation Criteria

Zero-frame logs contain no NaN/Infinity; normal evaluated-frame summaries are unchanged.

Version and Environment

  • AviSynthPlus revision: 815780226951f95dfc1fc74f1df90ef98824fcf5
  • Platform and compiler: Linux x86_64 / Clang 22 debug
  • CPU features used: host-default build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NaNNon-finite numeric input handling

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions