#10495 closed defect (fixed)

Optimized (x86 assembly) version of vf_ssim works incorrectly for some video inputs

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

Description

Summary of the bug:

Optimized assembly implementation of vf_sim is expected to behave identically to unoptimized (C-code) implementation, i.e. same metrics should be reported for the same input videos. However, due to bug in the assembly code, it’s not always the case, and the reported metrics can be different between the two. Optimized x86 assembly code works fine for 1920x1080 input, but failed for 852x480 input.

How to reproduce:

1. Build unoptimized ffmpeg binary by fully disable assembly optimization for entire ffmpeg 
% ./configure with --disable-asm
2. Download test 1080p (8-bit) input video (e.g. https://media.xiph.org/video/derf/y4m/crowd_run_1080p50.y4m)
3. Rescale 1080p video to 852x480p (8-bit): 
% ffmpeg -y -i crowd_run_1080p50.y4m -s 852x480 ref_852x480p50.y4m
4. Generate degrade (8-bit) video using x264, e.g.: 
% ffmpeg -y -i ref_852x480p50.y4m -c:v libx264 -qp 40 x264_852x480p50.264
5. Compare (8-bit) SSIM Y/U/V generated with unoptimized ffmpeg binary against SSIM generated using optimized ffmpeg binary:
Sample command line: 
% ffmpeg -vsync 0 -i ref_852x480p50.y4m -i x264_852x480p50.264 -lavfi "ssim" -f null –
Here is a difference between outputs for x86 assembly and C implementations:
Optimized SSIM output: SSIM Y:0.770184 (6.386200) U:0.830635 (7.711759) V:0.845416 (8.108361) All:0.792798 (6.836059) 
Reference(Unoptimized) : SSIM Y:0.770184 (6.386200) U:0.829381 (7.679738) V:0.844320 (8.077677) All:0.792406 (6.827860) 
Some very tiny fractional difference could be observed due to compiler uses different floating point instructions. However, the difference is expected to be very small (e.g. < 1e-5). 

Change History (4)

comment:1 by Elon Musk, 16 months ago

Are you sure this is not h264 related?

You just use -cpuflags 0, no need to recompile new binary.

in reply to:  1 comment:2 by Evgeny, 16 months ago

Replying to Elon Musk:

Are you sure this is not h264 related?

You just use -cpuflags 0, no need to recompile new binary.

Tested with hevc video and got differences in SSIM too.

Submitted a fix to patchwork
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230731112703.13730-2-lucenticus@gmail.com/

comment:4 by Elon Musk, 15 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.