diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-11-21 14:51:09 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-11-22 23:59:43 +0100 |
| commit | 0a49cc2ebbfc3809313f252208a0050a3fce1e97 (patch) | |
| tree | eabde99894ed4caa25970a8b967eb69ebac4a08a /test/client_server_test.cc | |
| parent | 0254f2d12acb2ff8d770b4e47dc15599d145fe17 (diff) | |
Separate out local/remote encode code from DCPVideo.
Now we have a J2KEncoderCPUBackend and a J2KEncoderRemoteBackend.
Diffstat (limited to 'test/client_server_test.cc')
| -rw-r--r-- | test/client_server_test.cc | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/test/client_server_test.cc b/test/client_server_test.cc index d6fe4b948..2355c08c0 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -36,6 +36,8 @@ #include "lib/encode_server_description.h" #include "lib/file_log.h" #include "lib/image.h" +#include "lib/j2k_encoder_cpu_backend.h" +#include "lib/j2k_encoder_remote_backend.h" #include "lib/j2k_image_proxy.h" #include "lib/player_video.h" #include "lib/raw_image_proxy.h" @@ -55,13 +57,15 @@ using namespace dcpomatic; void -do_remote_encode (shared_ptr<DCPVideo> frame, EncodeServerDescription description, ArrayData locally_encoded) +do_remote_encode (DCPVideo frame, EncodeServerDescription description, ArrayData locally_encoded) { - ArrayData remotely_encoded; - BOOST_REQUIRE_NO_THROW (remotely_encoded = frame->encode_remotely (description, 1200)); + optional<ArrayData> remotely_encoded; + J2KEncoderRemoteBackend backend (description, 1200); + BOOST_REQUIRE_NO_THROW (remotely_encoded = backend.encode(frame)); + BOOST_REQUIRE (static_cast<bool>(remotely_encoded)); - BOOST_REQUIRE_EQUAL (locally_encoded.size(), remotely_encoded.size()); - BOOST_CHECK_EQUAL (memcmp (locally_encoded.data(), remotely_encoded.data(), locally_encoded.size()), 0); + BOOST_REQUIRE_EQUAL (locally_encoded.size(), remotely_encoded->size()); + BOOST_CHECK_EQUAL (memcmp (locally_encoded.data(), remotely_encoded->data(), locally_encoded.size()), 0); } @@ -112,7 +116,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb) pvf->set_text (PositionImage(sub_image, Position<int>(50, 60))); - auto frame = make_shared<DCPVideo> ( + DCPVideo frame( pvf, 0, 24, @@ -120,7 +124,9 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb) Resolution::TWO_K ); - auto locally_encoded = frame->encode_locally (); + J2KEncoderCPUBackend cpu; + auto locally_encoded = cpu.encode (frame); + BOOST_REQUIRE (static_cast<bool>(locally_encoded)); auto server = new EncodeServer (true, 2); @@ -134,7 +140,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb) list<thread*> threads; for (int i = 0; i < 8; ++i) { - threads.push_back (new thread (boost::bind (do_remote_encode, frame, description, locally_encoded))); + threads.push_back (new thread(boost::bind(do_remote_encode, frame, description, *locally_encoded))); } for (auto i: threads) { @@ -195,7 +201,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv) pvf->set_text (PositionImage(sub_image, Position<int>(50, 60))); - auto frame = make_shared<DCPVideo>( + DCPVideo frame( pvf, 0, 24, @@ -203,7 +209,9 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv) Resolution::TWO_K ); - auto locally_encoded = frame->encode_locally (); + J2KEncoderCPUBackend cpu; + auto locally_encoded = cpu.encode (frame); + BOOST_REQUIRE (static_cast<bool>(locally_encoded)); auto server = new EncodeServer (true, 2); @@ -217,7 +225,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv) list<thread*> threads; for (int i = 0; i < 8; ++i) { - threads.push_back (new thread(boost::bind(do_remote_encode, frame, description, locally_encoded))); + threads.push_back (new thread(boost::bind(do_remote_encode, frame, description, *locally_encoded))); } for (auto i: threads) { @@ -263,7 +271,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) false ); - auto raw_frame = make_shared<DCPVideo> ( + DCPVideo raw_frame( raw_pvf, 0, 24, @@ -271,10 +279,12 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) Resolution::TWO_K ); - auto raw_locally_encoded = raw_frame->encode_locally (); + J2KEncoderCPUBackend cpu; + auto raw_locally_encoded = cpu.encode (raw_frame); + BOOST_REQUIRE (static_cast<bool>(raw_locally_encoded)); auto j2k_pvf = std::make_shared<PlayerVideo> ( - std::make_shared<J2KImageProxy>(raw_locally_encoded, dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE), + std::make_shared<J2KImageProxy>(*raw_locally_encoded, dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE), Crop(), optional<double>(), dcp::Size(1998, 1080), @@ -288,7 +298,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) false ); - auto j2k_frame = make_shared<DCPVideo> ( + DCPVideo j2k_frame( j2k_pvf, 0, 24, @@ -296,7 +306,8 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) Resolution::TWO_K ); - auto j2k_locally_encoded = j2k_frame->encode_locally (); + auto j2k_locally_encoded = cpu.encode(j2k_frame); + BOOST_REQUIRE (static_cast<bool>(j2k_locally_encoded)); auto server = new EncodeServer (true, 2); @@ -310,7 +321,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k) list<thread*> threads; for (int i = 0; i < 8; ++i) { - threads.push_back (new thread(boost::bind(do_remote_encode, j2k_frame, description, j2k_locally_encoded))); + threads.push_back (new thread(boost::bind(do_remote_encode, j2k_frame, description, *j2k_locally_encoded))); } for (auto i: threads) { |
