FFmpeg git repo
Go to file
Chema Gonzalez 7311fcc869 lavfi/vf_psnr: add warning when color ranges differ
The PSNR filter uses the pixel values without considering
the color ranges. This is incorrect. Patch adds a warning
so at least the user knows it.

Let's see an example:

(1) Let's get a simple black pixel/white pixel image.
```
$ echo -n -e "\x00\x00\x00\xff\xff\xff" > /tmp/foo.rgb24
```

(2) From this image, let's distill full and limited range y4m
copies.

```
$ ffmpeg -y -f rawvideo -video_size 2x1 -pix_fmt rgb24 -i /tmp/foo.rgb24 -vf scale="out_range=full" -pix_fmt yuv420p /tmp/foo.full.y4m
$ xxd /tmp/foo.full.y4m
00000000: 5955 5634 4d50 4547 3220 5732 2048 3120  YUV4MPEG2 W2 H1
00000010: 4632 353a 3120 4970 2041 303a 3020 4334  F25:1 Ip A0:0 C4
00000020: 3230 6a70 6567 2058 5953 4353 533d 3432  20jpeg XYSCSS=42
00000030: 304a 5045 4720 5843 4f4c 4f52 5241 4e47  0JPEG XCOLORRANG
00000040: 453d 4655 4c4c 0a46 5241 4d45 0a00 ff80  E=FULL.FRAME....
00000050: 80                                       .
```

and

```
$ ffmpeg -y -f rawvideo -video_size 2x1 -pix_fmt rgb24 -i /tmp/foo.rgb24 -vf scale="out_range=limited" -pix_fmt yuv420p /tmp/foo.limited.y4m
$ xxd /tmp/foo.limited.y4m
00000000: 5955 5634 4d50 4547 3220 5732 2048 3120  YUV4MPEG2 W2 H1
00000010: 4632 353a 3120 4970 2041 303a 3020 4334  F25:1 Ip A0:0 C4
00000020: 3230 6a70 6567 2058 5953 4353 533d 3432  20jpeg XYSCSS=42
00000030: 304a 5045 4720 5843 4f4c 4f52 5241 4e47  0JPEG XCOLORRANG
00000040: 453d 4c49 4d49 5445 440a 4652 414d 450a  E=LIMITED.FRAME.
00000050: 10eb 8080                                ....
```

Note that the 2x images are the same (both have 1x pixel at the
darkest black, and one at the brightest white). Only difference
is the range.

(3) Let's calculate the PSNR score:
```
$ ./ffmpeg -filter_threads 1 -filter_complex_threads 1 -i /tmp/foo.full.y4m -i /tmp/foo.limited.y4m -lavfi "psnr" -f null -
...
[Parsed_psnr_0 @ 0x2f5dac0] PSNR y:22.972065 u:inf v:inf average:25.982365 min:25.982365 max:25.982365
```

As we are comparing an image with itself, we expect "y:inf" as the
luma PSNR. Issue here is that the PSNR filter just uses the pixel
values, ignoring the color ranges.

A possible solution would be to have the filter do the conversion.

Proposed solution is to add a warning.

```
$ ./ffmpeg -filter_threads 1 -filter_complex_threads 1 -i /tmp/foo.full.y4m -i /tmp/foo.limited.y4m -lavfi "psnr" -f null -
...
[Parsed_psnr_0 @ 0x2f5dac0] master and reference frames use different color ranges (pc != tv)
...
[Parsed_psnr_0 @ 0x2f5dac0] PSNR y:22.972065 u:inf v:inf average:25.982365 min:25.982365 max:25.982365
```

Tested:

Ran fate.
```
$ make fate -j
...
TEST    seek-lavf-ppmpipe
TEST    seek-lavf-pgmpipe
TEST    seek-lavf-mxf_opatom
```
2023-09-23 15:55:44 +01:00
compat
doc lavc/vaapi_encode: Add VAAPI AV1 encoder 2023-09-22 13:15:00 +08:00
ffbuild
fftools
libavcodec avcodec/flicvideo: fix decoding with AVFrame's negative linesize 2023-09-23 15:31:44 +02:00
libavdevice avdevice/android_camera: fix missing include for usleep 2023-09-19 00:39:47 +08:00
libavfilter lavfi/vf_psnr: add warning when color ranges differ 2023-09-23 15:55:44 +01:00
libavformat avformat/mov: Avoid cloning encryption info if its unchanged 2023-09-22 23:47:39 +02:00
libavutil avutil/avutil: make AV_TIME_BASE_Q available in C++ 2023-09-19 00:52:21 +08:00
libpostproc
libswresample
libswscale
presets
tests lavc/av1: Add unit test for level handling 2023-09-22 13:15:01 +08:00
tools tools/target_dec_fuzzer: Adjust threshold for rtv1 2023-09-22 23:47:40 +02:00
.gitattributes
.gitignore
.mailmap
.travis.yml
CONTRIBUTING.md
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
Changelog lavc/vaapi_encode: Add VAAPI AV1 encoder 2023-09-22 13:15:00 +08:00
INSTALL.md
LICENSE.md
MAINTAINERS
Makefile
README.md
RELEASE
configure lavc/vaapi_encode: Add VAAPI AV1 encoder 2023-09-22 13:15:00 +08:00

README.md

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides means to alter decoded audio and video through a directed graph of connected filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information.

Contributing

Patches should be submitted to the ffmpeg-devel mailing list using git format-patch or git send-email. Github pull requests should be avoided because they are not part of our review process and will be ignored.