mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
compare: special case empty regions with 1 SSIM to avoid dividing by 0
Coverity 1139689, 1139688
This commit is contained in:
parent
93b1504945
commit
75c09f8d03
1 changed files with 8 additions and 0 deletions
|
@ -363,6 +363,10 @@ gst_compare_ssim_window (GstCompare * comp, guint8 * data1, guint8 * data2,
|
|||
const gdouble c1 = (k1 * L) * (k1 * L);
|
||||
const gdouble c2 = (k2 * L) * (k2 * L);
|
||||
|
||||
/* For empty images, return maximum similarity */
|
||||
if (height <= 0 || width <= 0)
|
||||
return 1.0;
|
||||
|
||||
/* plain and simple; no fancy optimizations */
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
|
@ -414,6 +418,10 @@ gst_compare_ssim_component (GstCompare * comp, guint8 * data1, guint8 * data2,
|
|||
}
|
||||
}
|
||||
|
||||
/* For empty images, return maximum similarity */
|
||||
if (count == 0)
|
||||
return 1.0;
|
||||
|
||||
return (ssim_sum / count);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue