From: Steinar H. Gunderson Date: Tue, 4 Dec 2018 22:15:05 +0000 (+0100) Subject: Set a FFmpeg-private JPEG marker to signal some Y'CbCr information. X-Git-Tag: 1.8.0~55 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=012f5333c8958ed3da410ef53493c347028b44c4 Set a FFmpeg-private JPEG marker to signal some Y'CbCr information. --- diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index 8f11714..6fb8c5c 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -107,6 +107,10 @@ vector encode_jpeg(const uint8_t *y_data, const uint8_t *cb_data, const cinfo.CCIR601_sampling = true; // Seems to be mostly ignored by libjpeg, though. jpeg_start_compress(&cinfo, true); + // This comment marker is private to FFmpeg. It signals limited Y'CbCr range + // (and nothing else). + jpeg_write_marker(&cinfo, JPEG_COM, (const JOCTET *)"CS=ITU601", strlen("CS=ITU601")); + JSAMPROW yptr[8], cbptr[8], crptr[8]; JSAMPARRAY data[3] = { yptr, cbptr, crptr }; for (unsigned y = 0; y < height; y += 8) { diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 3587d78..614cb5c 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -389,6 +389,10 @@ void MJPEGEncoder::init_jpeg_422(unsigned width, unsigned height, VectorDestinat cinfo->comp_info[2].v_samp_factor = 1; cinfo->CCIR601_sampling = true; // Seems to be mostly ignored by libjpeg, though. jpeg_start_compress(cinfo, true); + + // This comment marker is private to FFmpeg. It signals limited Y'CbCr range + // (and nothing else). + jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)"CS=ITU601", strlen("CS=ITU601")); } vector MJPEGEncoder::get_jpeg_header(unsigned width, unsigned height, jpeg_compress_struct *cinfo)