Use a colorspace filter when previewing Rec.2020 content with the simple viewer.
authorCarl Hetherington <cth@carlh.net>
Sat, 8 Oct 2022 19:32:05 +0000 (21:32 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Oct 2022 18:25:57 +0000 (20:25 +0200)
src/wx/simple_video_view.cc
src/wx/simple_video_view.h

index 00d81ab47a4d89f89e552b55ab017348e7220363..09c17217194bbe0f0423e755bbec2e7070f0a92c 100644 (file)
@@ -26,6 +26,8 @@
 #include "lib/butler.h"
 #include "lib/dcpomatic_log.h"
 #include "lib/image.h"
+#include "lib/video_filter_graph.h"
+#include "lib/video_filter_graph_set.h"
 #include <dcp/util.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -46,6 +48,8 @@ using namespace dcpomatic;
 
 SimpleVideoView::SimpleVideoView (FilmViewer* viewer, wxWindow* parent)
        : VideoView (viewer)
+       , _rec2020_filter("convert", "convert", "", "colorspace=all=bt709:iall=bt2020")
+       , _rec2020_filter_graph({ &_rec2020_filter }, dcp::Fraction(24, 1))
 {
        _panel = new wxPanel (parent);
 
@@ -241,7 +245,11 @@ SimpleVideoView::update ()
 
        _state_timer.set ("get image");
 
-       _image = player_video().first->image(boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+       auto const pv = player_video();
+       _image = pv.first->image(boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+       if (pv.first->colour_conversion() && pv.first->colour_conversion()->about_equal(dcp::ColourConversion::rec2020_to_xyz(), 1e-6)) {
+               _image = Image::ensure_alignment(_rec2020_filter_graph.get(_image->size(), _image->pixel_format())->process(_image).front(), Image::Alignment::COMPACT);
+       }
 
        _state_timer.set ("ImageChanged");
        _viewer->image_changed (player_video().first);
index 7a48f8ef839344c452bfae50f77785a08d737e0f..e19068979b5ef2c4724f6aa2ddec848cf1393a0f 100644 (file)
 
 
 #include "video_view.h"
+#include "lib/filter.h"
 #include "lib/position.h"
+#include "lib/video_filter_graph_set.h"
 #include <dcp/types.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
 LIBDCP_ENABLE_WARNINGS
 
+
 class FilmViewer;
+class Filter;
 
 
 class SimpleVideoView : public VideoView
@@ -53,4 +57,7 @@ private:
        wxTimer _timer;
        Position<int> _inter_position;
        dcp::Size _inter_size;
+
+       Filter _rec2020_filter;
+       VideoFilterGraphSet _rec2020_filter_graph;
 };