MediaArea / MediaInfo

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://MediaArea.net/MediaInfo
BSD 2-Clause "Simplified" License
1.31k stars 158 forks source link

HDR AV1 metadata is parsed wrong #600

Open mxsrm opened 2 years ago

mxsrm commented 2 years ago

Hello,

mediainfo is parsing HDR side_data wrong. It seems to have been tested on x265 data mainly, which uses /50000 values:

[SIDE_DATA]
side_data_type=Mastering display metadata
red_x=34000/50000
red_y=16000/50000
green_x=13250/50000
green_y=34500/50000
blue_x=7500/50000
blue_y=3000/50000
white_point_x=15635/50000
white_point_y=16450/50000
min_luminance=1/10000
max_luminance=10000000/10000
[/SIDE_DATA]

However, for example SVT-AV1 uses /65536 (and others), which lead to wrong values. Test file attached.

ffprobe (exact same raw data as the example above):

[SIDE_DATA]
side_data_type=Mastering display metadata
red_x=44564/65536
red_y=20972/65536
green_x=17367/65536
green_y=45220/65536
blue_x=9830/65536
blue_y=3932/65536
white_point_x=20493/65536
white_point_y=21561/65536
min_luminance=2/16384
max_luminance=256000/256
[/SIDE_DATA]

But the info displayed by mediainfo is wrong:

Mastering display color primaries        : R: x=0.891280 y=0.419440, G: x=0.347340 y=0.904400, B: x=0.196600 y=0.078640, White point: x=0.409860 y=0.431220
Mastering display luminance              : min: 0.0002 cd/m2, max: 25.6000 cd/m2

Mastering display luminance should be Mastering display luminance : min: 0.0001 cd/m2, max: 1000 cd/m2 for example

https://user-images.githubusercontent.com/7951225/162791238-a185f277-8415-4f64-8279-796858b4019b.mp4.

JeromeMartinez commented 2 years ago

However, for example SVT-AV1 uses /65536 (and others), which lead to wrong values.

There is a standard about values, with exact numbers, but someone decided to use another denominator... Fun! It leads to non precise values e.g. 20493/65536=0.312698 vs 0.312670 elsewhere, and I hope for the person who chose that the future will not require the value 1.0 (impossible to store in the stream with this denominator).

Thank you for the precise report, we won't o as FFmpeg with the explicit denominator but we'll use the right one for showing the right floating point value.

JeromeMartinez commented 2 years ago

@mxsrm I have that now:

Mastering display color primaries        : Display P3
Mastering display luminance              : min: 0.0001 cd/m2, max: 1000 cd/m2

But still:

Maximum Content Light Level              : 2594 cd/m2
Maximum Frame-Average Light Level        : 1698 cd/m2

Are there the expected values, else what are they?

JeromeMartinez commented 2 years ago

@mxsrm how do you get the mastering metadata with ffprobe?

While checking the only AV1 file I have, and it is 50000 based, I don't remind where I got it and I am curious about what FFmpeg says. I bet it will show 65536 based values but I would like to be sure (in case there is somewhere a check on "bad" behavior in "old" encoders?). This is not for not implementing the 65536 based analysis as the spec is clear about it ("0.16 fixed-point").

mxsrm commented 2 years ago

Have you tried the file I attached above? I think the denominator is dependent on the encoder. Maybe AOM produces 50000-based and only SVT-AV1 does 65536-based, I'm not sure.

ffprobe -i test.mkv -select_streams v:0 -show_frames -read_intervals %+#1

Maximum content light and frame-average light level are correct, because there is no denominator involved:

[SIDE_DATA]
side_data_type=Content light level metadata
max_content=2594
max_average=1698
[/SIDE_DATA]