vtenc: color profile or gamma seems to be wrong sometimes
I have a pipeline converting a stream of jpegs (mjpegs) to an h264 RTP stream which looks something like this:
appsrc ! jpegdec ! vtenc_h264 ! rtph264pay ! appsink
The issue I have is with jpegs from some sources (not all) the colors in the resulting h264 stream are slightly off. eg: some greys appear almost white. When I run the same "pipeline" in ffmpeg on the same machine, using the same videotoolbox h264 encoder the resulting output has the correct colors, eg:
ffmpeg -i <input> -profile:v baseline -c:v h264_videotoolbox -realtime 1 -f rtp rtp://<address>
I'm wondering if this has something to do with the color profile of the jpegs. I noticed in the ffmpeg source these 3 keys can be set which seem to specify the color profile in various ways: https://github.com/FFmpeg/FFmpeg/blob/6c4074e4234edacfb3f37184fd68771df3cb2b7f/libavcodec/videotoolboxenc.c#L847-L867
see also: https://developer.apple.com/documentation/corevideo/cvimagebuffer/image_buffer_transfer_function_constants https://developer.apple.com/documentation/corevideo/cvimagebuffer/image_buffer_color_primaries_constants https://developer.apple.com/documentation/corevideo/cvimagebuffer/image_buffer_ycbcr_matrix_constants
I don't see these keys being set in vtenc.c
I'm not sure if it would make sense to set the manually, or they could be somehow derived from the source buffer.
I'm currently playing around with setting these keys manually in the vtenc.c source to see if it will fix my issue, though I'm not sure what they should be or how to parse the raw h264 stream to see what they are currently set as...
Thanks.