Switch PlayerVideo::always_rgb to a new ::force and use it in FFmpegFileEncoder.
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Nov 2018 22:43:52 +0000 (22:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 6 Nov 2018 22:43:52 +0000 (22:43 +0000)
src/lib/ffmpeg_file_encoder.cc
src/lib/player_video.cc
src/lib/player_video.h
src/wx/film_viewer.cc
test/dcp_playback_test.cc
test/player_test.cc

index 52977ad5bb6b12fd02cdc27eabd8c745d41267ab..7cc4d26a47031f3ee1160eda413968c365dc20ee 100644 (file)
@@ -43,12 +43,6 @@ using boost::weak_ptr;
 int FFmpegFileEncoder::_video_stream_index = 0;
 int FFmpegFileEncoder::_audio_stream_index = 1;
 
-static AVPixelFormat
-force_pixel_format (AVPixelFormat, AVPixelFormat out)
-{
-       return out;
-}
-
 FFmpegFileEncoder::FFmpegFileEncoder (
        dcp::Size video_frame_size,
        int video_frame_rate,
@@ -230,7 +224,7 @@ void
 FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
 {
        shared_ptr<Image> image = video->image (
-               bind (&force_pixel_format, _1, _pixel_format),
+               bind (&PlayerVideo::force, _1, _pixel_format),
                true,
                false
                );
index 376ace12818b971a1260262ee9c58243e3fc07ca..c9ed6a6e4ffa6ded15d243efa693fe1b751b8341 100644 (file)
@@ -105,7 +105,7 @@ PlayerVideo::set_text (PositionImage image)
 /** Create an image for this frame.
  *  @param pixel_format Function which is called to decide what pixel format the output image should be;
  *  it is passed the pixel format of the input image from the ImageProxy, and should return the desired
- *  output pixel format.  Two functions always_rgb and keep_xyz_or_rgb are provided for use here.
+ *  output pixel format.  Two functions force and keep_xyz_or_rgb are provided for use here.
  *  @param aligned true if the output image should be aligned to 32-byte boundaries.
  *  @param fast true to be fast at the expense of quality.
  */
@@ -254,9 +254,9 @@ PlayerVideo::same (shared_ptr<const PlayerVideo> other) const
 }
 
 AVPixelFormat
-PlayerVideo::always_rgb (AVPixelFormat)
+PlayerVideo::force (AVPixelFormat, AVPixelFormat force_to)
 {
-       return AV_PIX_FMT_RGB24;
+       return force_to;
 }
 
 AVPixelFormat
index 6599eeaa0b4489e110562337934de8ebc8180355..8e41e8f2371dc5dff5d504aabf65fad32acca172 100644 (file)
@@ -65,7 +65,7 @@ public:
        void prepare ();
        boost::shared_ptr<Image> image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const;
 
-       static AVPixelFormat always_rgb (AVPixelFormat);
+       static AVPixelFormat force (AVPixelFormat, AVPixelFormat);
        static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat);
 
        void add_metadata (xmlpp::Node* node) const;
index 0a72b5a1da568d43a06c0a27dc25d2d92e8d60d4..01963372061d8ddef25851b78a375c036b8e2cb3 100644 (file)
@@ -267,12 +267,12 @@ FilmViewer::display_player_video ()
         * The content's specified colour conversion indicates the colourspace
         * which the content is in (according to the user).
         *
-        * PlayerVideo::image (bound to PlayerVideo::always_rgb) will take the source
+        * PlayerVideo::image (bound to PlayerVideo::force) will take the source
         * image and convert it (from whatever the user has said it is) to RGB.
         */
 
        _frame = _player_video.first->image (
-               bind (&PlayerVideo::always_rgb, _1),
+               bind (&PlayerVideo::force, _1, AV_PIX_FMT_RGB24),
                false, true
                );
 
index 609971657844261b57831b68fec036257039f520..17318e0ff8328f178db64806d850e24407092ead 100644 (file)
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE (dcp_playback_test)
                }
                /* assuming DCP is 24fps/48kHz */
                butler->get_audio (audio_buffer, 2000);
-               p.first->image(bind(&PlayerVideo::always_rgb, _1), false, true);
+               p.first->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true);
        }
        delete[] audio_buffer;
 }
index 9351d3dd3684b29194cea3dcef0812bdc61a564e..0c9b6f21f0a8c81f55b0e13e383ccc5802b3148b 100644 (file)
@@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
                butler->seek (t, true);
                pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
                BOOST_CHECK_EQUAL(video.second.get(), t.get());
-               write_image(video.first->image(PlayerVideo::always_rgb, false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB");
+               write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB");
                /* This 0.011 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
                   (17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing
                   text altogether.
@@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test2)
                butler->seek (t, true);
                pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
                BOOST_CHECK_EQUAL(video.second.get(), t.get());
-               write_image(video.first->image(PlayerVideo::always_rgb, false, true), String::compose("build/test/player_seek_test2_%1.png", i), "RGB");
+               write_image(video.first->image(bind(PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true), String::compose("build/test/player_seek_test2_%1.png", i), "RGB");
                check_image(String::compose("test/data/player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 0.011);
        }
 }