]> git.sesse.net Git - nageru/commitdiff
Set a FFmpeg-private JPEG marker to signal some Y'CbCr information.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Dec 2018 22:15:05 +0000 (23:15 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Dec 2018 22:22:42 +0000 (23:22 +0100)
futatabi/video_stream.cpp
nageru/mjpeg_encoder.cpp

index 8f11714fb6d50bf863e37b9d5b531bbe0fbebe73..6fb8c5c400589a93fc811823421b499c12a8b7cf 100644 (file)
@@ -107,6 +107,10 @@ vector<uint8_t> 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) {
index 3587d78dcf3fa51a61a92af89ec362b3297b2d3e..614cb5cc8836a80b3eb4831d91a1465c8cd4a73e 100644 (file)
@@ -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<uint8_t> MJPEGEncoder::get_jpeg_header(unsigned width, unsigned height, jpeg_compress_struct *cinfo)