Opened 3 months ago
Last modified 4 weeks ago
#11267 open defect
mxf_parse_jpeg2000_frame() checks for the incorrect number of components
Reported by: | Pierre-Anthony Lemieux | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avcodec |
Version: | git-master | Keywords: | j2k |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
mxf_parse_jpeg2000_frame() uses av_pix_fmt_count_planes() to determine the number of components expects from the JPEG 2000 codestreams. This fails for RGB, where the number of planes is 1 but the number of components is 3.
ffmpeg -i last.j2c -vcodec copy build/out.mxf
mxf_parse_jpeg2000_frame() should use av_pix_fmt_desc_get(st->codecpar->format)->nb_components.
Change History (4)
comment:1 by , 3 months ago
comment:2 by , 3 months ago
Status: | new → open |
---|
Eurica! this a duplicate of #5919 where file that is rgb48 is recognized as xyz12le.
The opposite happens with your sample:
ffmpeg.exe -i mer_shrt_23976_vdm_sdr_rec709_g24_3840x2160_20170913_12bit_DCDM.4bpp.mxf -vframes 1 -c copy wafa.j2c
ffplay -pixel_format xyz12le wafa.j2c
shows better colors. So there it is recognized as rgb48 but in reality it is xyz12le
comment:3 by , 3 months ago
T-REC-T.814-201906-I!!PDF-E.pdf talks about how to see it is XYZ and what profile in RSIZ. The spec is too hard for me to parse, so... RSIZ looks zeroed out anyway, as it is just 14 bit set for HT and all others are not set. So no profile like Cinema.
Mediainfo recognized the file as XYZ just fine and clearly has support for HT JPEG2000.
Okay, I think I got it. So, H.273 says that Identity matrix can be XYZ or it can mean RGB. Now, if it is XYZ then primaries are XYZ.
I also see it does not understand what transfer it is, it says it is some 0x0401010101130000
0000E4A Code (6): 19 (0x13)
<Entry> <Register>Labels</Register> <NamespaceName>http://www.smpte-ra.org/reg/400/2012</NamespaceName> <Symbol>TransferCharacteristic_CinemaMezzanineDCDM</Symbol> <UL>urn:smpte:ul:060e2b34.0401010d.04010101.01130000</UL> <Kind>LEAF</Kind> <Name>Cinema Mezzanine DCDM Transfer Characteristic</Name> <Definition> Identifies the COLOR.APP4.2 transfer characteristic specified in SMPTE ST 2067-40 </Definition> <DefiningDocument>SMPTE ST 2067-40</DefiningDocument> <IsDeprecated>false</IsDeprecated> </Entry>
And then in some other place
000020C Code (5): 1 (0x01) - Transfer Characteristics
000020D Code (6): 1 (0x01) - Capture Gamma Equation
000020E Code (7): 2 (0x02) - UL
Then we can see it actually sees XYZ primaries like this: https://github.com/MediaArea/MediaInfoLib/blob/451e82bcc73375a8f44eb1ef624e05900dfd1a66/Source/MediaInfo/Multiple/File_Mxf.cpp#L1551
( case 0x08 : return "XYZ"; SMPTE ST 2067-40 / ISO 11664-3, this is Cinema Mezannine)
I also see that this byte should mean something:
https://github.com/MediaArea/MediaInfoLib/blob/451e82bcc73375a8f44eb1ef624e05900dfd1a66/Source/MediaInfo/Multiple/File_Mxf.cpp#L16784C13-L16785C75 as it says 0x08. And indeed this says:
https://registry.smpte-ra.org/view/published/Labels.xml
<Register>Labels</Register> <NamespaceName>http://www.smpte-ra.org/reg/400/2012</NamespaceName> <Symbol>HTJ2KPictureCodingScheme</Symbol> <UL>urn:smpte:ul:060e2b34.0401010d.04010202.03010800</UL> <Kind>NODE</Kind> <Name>High-Throughput JPEG 2000 Picture Coding Scheme</Name> <Definition> Identifies High-Throughput JPEG 2000 (HTJ2K) codestreams </Definition>
comment:4 by , 4 weeks ago
Just check how much better it decodes with af6d52eec66961f6a502b0f2f390c12226d087cd!!
Wow! ffmpeg -flags +bitexact -pixel_format xyz12le -i wafa.j2k fcasfca1.png
Also please apply this patch: https://trac.ffmpeg.org/ticket/9468