Rearrange encoding so that the different methods / backends are not all crammed into...
[dcpomatic.git] / test / fastvideo_test.cc
1 #include "lib/colour_conversion.h"
2 #include "lib/content.h"
3 #include "lib/cross.h"
4 #include "lib/image.h"
5 #include "lib/fastvideo_player_video_preparer.h"
6 #include "lib/j2k_image_proxy.h"
7 #include "lib/player_video.h"
8 #include "lib/types.h"
9 #include "test.h"
10 #include <boost/optional.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <boost/test/unit_test.hpp>
13 #include <vector>
14
15
16 using std::vector;
17 using boost::optional;
18 using boost::shared_ptr;
19 using boost::weak_ptr;
20
21
22 static
23 AVPixelFormat
24 pixel_format (AVPixelFormat)
25 {
26         return AV_PIX_FMT_RGB24;
27 }
28
29
30 BOOST_AUTO_TEST_CASE (fastvideo_preparer_setup_teardown_test)
31 {
32         FastvideoPlayerVideoPreparer preparer (&pixel_format, true, true);
33 }
34
35
36 BOOST_AUTO_TEST_CASE (fastvideo_preparer_simple_decode_test)
37 {
38         FastvideoPlayerVideoPreparer preparer (&pixel_format, true, true);
39
40         shared_ptr<J2KImageProxy> proxy(new J2KImageProxy("test/data/sizing_card_flat.j2k", dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12));
41
42         vector<shared_ptr<PlayerVideo> > videos;
43
44         for (int i = 0; i < 16; ++i) {
45                 shared_ptr<PlayerVideo> pv(
46                         new PlayerVideo(
47                                 proxy, Crop(), optional<double>(), dcp::Size(1998, 1080), dcp::Size(1998, 1080),
48                                 EYES_BOTH, PART_WHOLE, optional<ColourConversion>(), VIDEO_RANGE_FULL, weak_ptr<Content>(), optional<Frame>(), false
49                                 )
50                         );
51
52                 preparer.request (pv);
53                 videos.push_back (pv);
54         }
55
56         dcpomatic_sleep_seconds (5);
57
58         std::cout << "____-> get an image.\n";
59         videos[0]->image_proxy()->image().image->convert_pixel_format(dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGBA, true, true)->as_png().write("/home/carl/foo.png");
60 }
61