/* Copyright (C) 2022 Carl Hetherington This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DCP-o-matic. If not, see . */ #ifndef DCPOMATIC_CUDA_J2K_FRAME_ENCODER #define DCPOMATIC_CUDA_J2K_FRAME_ENCODER #include "j2k_frame_encoder.h" #include "types.h" #include #include #include #include #include #include #include #include #include class CUDAJ2KFrameEncoder : public J2KFrameEncoder { public: CUDAJ2KFrameEncoder(); boost::optional encode(DCPVideo const &) override; void flush() override; void log_thread_start() override; private: void encode_queue(); class Input { public: Input(DCPVideo const& vf); Input(Input const& other) = delete; Input(Input&& other); ~Input(); Input& operator=(Input const& other) = delete; nvjpeg2kImage_t const* const device_image() const { return &_device_image; } int index() const { return _index; } Eyes eyes() const { return _eyes; } dcp::Size size() const { return _size; } Resolution resolution() const { return _resolution; } private: std::vector xyz_x; std::vector xyz_y; std::vector xyz_z; uint8_t* _pixel_data_h[3]; uint8_t* _pixel_data_d[3]; size_t _pitch_in_bytes_h[3]; size_t _pitch_in_bytes_d[3]; nvjpeg2kImage_t _device_image; int _index; Eyes _eyes; dcp::Size _size; Resolution _resolution; }; boost::optional _size; boost::optional _resolution; static void cuda_thread(); static std::vector _cuda_threads; static std::queue _input; static boost::condition _input_condition; static boost::mutex _input_mutex; static std::map, dcp::ArrayData> _output; static boost::condition _output_condition; static boost::mutex _output_mutex; }; #endif