[FFmpeg-devel] libopenjpeg decoder not correctly setting the pixel format for cinema JP2K wrapped MXF
Tomas Härdin
tjoppen at acc.umu.se
Mon Aug 31 17:26:18 EEST 2020
sön 2020-08-30 klockan 18:22 +0100 skrev Rémi Achard:
> Hi,
>
> As you are probably aware, the libopenjpeg decoder is not able to interpret
> cinema jp2k mxf correctly, the pixel format being assigned as rgb48 instead
> of xyz12 as it should. Note that ffmpeg native jp2k decoder parse the RSIZ
> descriptor from the jp2k bitstream and is able to correctly assign the
> pixel format, but libopenjpeg currently don't read the RSIZ marker so that
> ffmpeg wrapper has no simple mean of doing this at the moment (a pull
> request on libopenjpeg is still in progress to try to fix that).
>
> Someone recently pointed me to this commit from 2015
> https://github.com/FFmpeg/FFmpeg/commit/2af260e3a85ef2a9fadcac4f4fa652cee53e591e
> .
> According to my tests, it doesn't work because of a wrong RSIZ key and
> missing JP2KEssenceSubDescriptor lookup group. I made a patch I made to fix
> that, mxfdec is now able to correctly assign the descriptor->pix_fmt field.
> Note that these keys can be found in SMPTE ST 429-4 or discovered through
> asdcplib with asdcp-info command line tool parsing a cinema mxf video track.
>
> Then, even with that patch, the pixel format detected by the demuxer is not
> communicated to the decoder, as far as I'm aware. Which makes me wonder,
> what was the original goal of that commit and what I'm missing to
> communicate this information to libopenjpeg decoder ?
>
Can't say much about the J2K part of this, so I'll comment on the MXF
side of things.
> -static const uint8_t mxf_jp2k_rsiz[] = {
> 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00
> };
> +static const uint8_t mxf_jp2k_rsiz[] = {
> 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00
> };
If you want the IS_KLV_KEY() check to be more lenient then you should
make mxf_jp2k_rsiz[] shorter, not replace the end of it with NULs
> + { {
> 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00
> }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /*
> JPEG2000PictureSubDescriptor */
Matches S422M, so should be OK.
We need a sample here, as Carl says.
/Tomas
More information about the ffmpeg-devel
mailing list