[FFmpeg-devel] Adding ICC profile support to MOV decode/encode
Hello Vectronic
hello.vectronic at gmail.com
Wed Sep 18 12:30:39 EEST 2019
Hello,
I need to implement support for reading and writing ICC profiles which can be stored in MOV/MP4 sample descriptor colour information.
The relevant extract from the ISO standard is:
class ColourInformationBox extends Box('colr'){
unsigned int(32) colour_type;
if (colour_type == 'nclx') /* on-screen colours */
{
unsigned int(16) colour_primaries;
unsigned int(16) transfer_characteristics;
unsigned int(16) matrix_coefficients;
unsigned int(1) full_range_flag;
unsigned int(7) reserved = 0;
}
else if (colour_type == 'rICC')
{
ICC_profile; // restricted ICC profile
}
else if (colour_type == 'prof')
{
ICC_profile; // unrestricted ICC profile
}
}
At the moment the code only supports nclc/nclx colour type in:
libavformat/mov.c => mov_read_colr()
libavformat/moveenc.c => mov_write_colr_tag()
Support for ICC profile is implemented on a per frame basis in AVFrameSideDataType.AV_FRAME_DATA_ICC_PROFILE. This is used by the PNG, WEBP and MJPEG codec implementations. The ICC profile in this scenario is treated as an opaque octet buffer. I don't believe this is relevant to my use case as the colour information within the MOV/MP4 sample descriptor relates to the entire stream and is not used on a per-frame basis.
My thinking is to implement support for ICC profile in a similar way that color_range, color_primaries etc. are currently handled:
1. Store the ICC profile as an opaque octet buffer stored in an AVCodecParameters struct value:
uint8_t *icc_profile_data;
int icc_profile_size;
2. Add handling of these in libavcodec/utils.c to the following:
codec_parameters_reset()
avcodec_parameters_to_context()
avcodec_parameters_from_context()
2. Add support for reading and writing to the existing MOV/MP4 implementations:
libavformat/mov.c => mov_read_colr()
libavformat/moveenc.c => mov_write_colr_tag()
I'd appreciate any suggestions on better/alternative ways to implement this as I would like to eventually submit as a patch.
Thanks very much,
vectronic
More information about the ffmpeg-devel
mailing list