diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-20 16:55:09 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-23 16:55:28 +0200 |
| commit | e7503b1a3c93121c27cec2804376f8621d793f6a (patch) | |
| tree | c0f73c0fde00863d1f749c78ff3c776a109a8b8d /src/lib/cuda_j2k_frame_encoder.h | |
| parent | 9bf074b427b2f6a2ac40e420c595a8d01577ff6d (diff) | |
wip: Add CUDA J2K frame encoder using libjpeg2k.
Diffstat (limited to 'src/lib/cuda_j2k_frame_encoder.h')
| -rw-r--r-- | src/lib/cuda_j2k_frame_encoder.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/lib/cuda_j2k_frame_encoder.h b/src/lib/cuda_j2k_frame_encoder.h new file mode 100644 index 000000000..46ac64607 --- /dev/null +++ b/src/lib/cuda_j2k_frame_encoder.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2022 Carl Hetherington <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + + +#ifndef DCPOMATIC_CUDA_J2K_FRAME_ENCODER +#define DCPOMATIC_CUDA_J2K_FRAME_ENCODER + + +#include "j2k_frame_encoder.h" +#include <dcp/types.h> +#include <nvjpeg2k.h> +#include <vector> + + +class CUDAJ2KFrameEncoder : public J2KFrameEncoder +{ +public: + CUDAJ2KFrameEncoder(); + ~CUDAJ2KFrameEncoder(); + + boost::optional<dcp::ArrayData> encode(DCPVideo const &) override; + void log_thread_start() override; + +private: + void allocate(dcp::Size size); + void free(); + + nvjpeg2kEncoder_t _encoder_handle; + nvjpeg2kEncodeState_t _encoder_state; + nvjpeg2kEncodeParams_t _encoder_params; + uint8_t* _pixel_data_h[3]; + uint8_t* _pixel_data_d[3]; + size_t _pitch_in_bytes[3]; + nvjpeg2kImageComponentInfo_t _image_component_info[3]; + + dcp::Size _allocated_size; +}; + + +#endif |
