From 62f9b78a2eb5f0fc6b9028264bac6ad501d83309 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 25 May 2021 00:57:16 +0200 Subject: Move video level conversion for RGB from FFmpegImageProxy to Image. Since FFmpeg does not do video level conversion for RGB sources when we (sort of) ask it to in Image::crop_scale_window() it seems to make more sense to compensate for that by calling full_to_video_range() in the same place (rather than in FFmpegImageProxy). --- src/lib/image.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lib/image.cc') diff --git a/src/lib/image.cc b/src/lib/image.cc index 5b926d77c..8e6c5717b 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -297,6 +297,15 @@ Image::crop_scale_window ( out->make_part_black (corner.x + cropped_size.width, out_size.width - cropped_size.width); } + if ( + video_range == VideoRange::VIDEO && + out_video_range == VideoRange::FULL && + av_pix_fmt_desc_get(_pixel_format)->flags & AV_PIX_FMT_FLAG_RGB + ) { + /* libswscale will not convert video range for RGB sources, so we have to do it ourselves */ + out->video_range_to_full_range (); + } + return out; } -- cgit v1.2.3