Opened 5 years ago

Last modified 4 months ago

#8529 open defect

the ssim_c1 has bug in vf_ssim.c

Reported by: none Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: ssim
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I'm learning the SSIM, and I find FFMpeg provides this capability in the vf_ssim.c and tiny_ssim.c. I analyzed the code of the tiny_ssim.c and find a bug for the define of the ssim_c1 variable in the
ssim_end1() function.

I recalculate the mathematical formula of SSIM according to the algorithm of tiny_ssim, and get the following formula:

SSIM(x,y)=((2*s1*s2+64*64*C1)(2*(64*s12-s1*s2)+64*63*C2))/((s1*s1+s2*s2+64*64*C1)(64*ss-s1*s1-s2*s2+64*63*C2))

Thus the ssim_c1 shoule be (.01*.01*PIXEL_MAX*PIXEL_MAX*64*64 + .5) instead of ssim_c1 = (int)(.01*.01*PIXEL_MAX*PIXEL_MAX*64 + .5).

How to reproduce:

static const int ssim_c1 = (int)(.01*.01*PIXEL_MAX*PIXEL_MAX*64*64 + .5);

Attachments (2)

tiny_ssim.jpg (49.4 KB ) - added by none 5 years ago.
mathematical formula of the tiny_ssim
ssim_proof.jpg (207.1 KB ) - added by none 5 years ago.
the proof of the ssim

Download all attachments as: .zip

Change History (8)

by none, 5 years ago

Attachment: tiny_ssim.jpg added

mathematical formula of the tiny_ssim

comment:1 by Carl Eugen Hoyos, 5 years ago

Keywords: ssim added; ssim_c1 removed
Priority: importantnormal

comment:2 by Elon Musk, 5 years ago

I nowhere do not see proof of your claim.

by none, 5 years ago

Attachment: ssim_proof.jpg added

the proof of the ssim

in reply to:  2 comment:3 by none, 5 years ago

The proof of the formula is as the following link (ssim_end1() calculate the ssim for 8x8 block sums): https://wangwei1237.github.io/2020/02/18/the-proof-of-the-SSIM-in-FFMpeg/

Replying to richardpl:

I nowhere do not see proof of your claim.

Last edited 5 years ago by none (previous) (diff)

comment:4 by Balling, 5 years ago

So, c1 is defined as (k_1 * L)2, where k_1 is 0.01 and L is PIXEL_MAX (it is a define that is 255 for 8 bit). It means that everything is already squared... so it can be 64 == 8 * 8, dunno or maybe a comfortable shortcat. Anyway, you forgot + 0.5

Last edited 5 years ago by Balling (previous) (diff)

comment:5 by Balling, 5 years ago

Status: newopen
Note: See TracTickets for help on using tickets.