X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fvideo_stream.cpp;h=87e843ae1e8d61ea7bdd8ae5e9c6822fe304e22b;hb=5c1bc79d6c26c96cb8d2195ae8ef457c30ed364a;hp=8f11714fb6d50bf863e37b9d5b531bbe0fbebe73;hpb=eeda8995329601f9f4e35047358400833eeae68e;p=nageru diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index 8f11714..87e843a 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) { @@ -234,7 +238,12 @@ VideoStream::~VideoStream() {} void VideoStream::start() { AVFormatContext *avctx = avformat_alloc_context(); - avctx->oformat = av_guess_format("nut", nullptr, nullptr); + + // We use Matroska, because it's pretty much the only mux where FFmpeg + // allows writing chroma location to override JFIF's default center placement. + // (Note that at the time of writing, however, FFmpeg does not correctly + // _read_ this information!) + avctx->oformat = av_guess_format("matroska", nullptr, nullptr); uint8_t *buf = (uint8_t *)av_malloc(MUX_BUFFER_SIZE); avctx->pb = avio_alloc_context(buf, MUX_BUFFER_SIZE, 1, this, nullptr, nullptr, nullptr); @@ -438,7 +447,7 @@ void VideoStream::schedule_interpolated_frame(steady_clock::time_point local_pts shared_ptr frame2 = decode_jpeg_with_cache(secondary_frame, DECODE_IF_NOT_IN_CACHE, &frame_reader, &did_decode); // Then fade against it, putting it into the fade Y' and CbCr textures. - ycbcr_semiplanar_converter->prepare_chain_for_fade_from_texture(qf.output_tex, frame2, fade_alpha)->render_to_fbo(resources->fade_fbo, 1280, 720); + ycbcr_semiplanar_converter->prepare_chain_for_fade_from_texture(qf.output_tex, 1280, 720, frame2, fade_alpha)->render_to_fbo(resources->fade_fbo, 1280, 720); // Subsample and split Cb/Cr. chroma_subsampler->subsample_chroma(resources->fade_cbcr_output_tex, 1280, 720, resources->cb_tex, resources->cr_tex);