diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-10-08 10:04:06 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-10-08 10:04:06 +0200 |
| commit | 758b23791b9778e51c42b21f66d7a233a69025ff (patch) | |
| tree | 899f9f22c3a6e1488e0b4bd0e742ee19b4f45c8f /src/lib/cuda_j2k_encoder_thread.cc | |
| parent | 750121997c4359664e7c560809dd71365bfe41be (diff) | |
fixup! wip: CUDA with nvjpeg2knvidia2
Diffstat (limited to 'src/lib/cuda_j2k_encoder_thread.cc')
| -rw-r--r-- | src/lib/cuda_j2k_encoder_thread.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/cuda_j2k_encoder_thread.cc b/src/lib/cuda_j2k_encoder_thread.cc index 466b78fc1..46b34c077 100644 --- a/src/lib/cuda_j2k_encoder_thread.cc +++ b/src/lib/cuda_j2k_encoder_thread.cc @@ -46,9 +46,13 @@ CUDAJ2KEncoderThread::CUDAJ2KEncoderThread(J2KEncoder& encoder) shared_ptr<dcp::ArrayData> CUDAJ2KEncoderThread::encode(DCPVideo const& frame) { + std::cout << "CUDA: encode " << frame.index() << "\n"; + auto xyz = convert_to_xyz(frame.frame()); auto const size = xyz->size(); + std::cout << "freeowwwwm\n"; + /* {x,y,z}lp is 4-byte int representation */ int* xlp = xyz->data(0); int* ylp = xyz->data(1); @@ -69,14 +73,20 @@ CUDAJ2KEncoderThread::encode(DCPVideo const& frame) int16_t* zp = _xyz_z.data(); pixel_data_h[2] = reinterpret_cast<uint8_t*>(zp); + std::cout << "felcher\n"; + for (int j = 0; j < size.width * size.height; ++j) { *xp++ = static_cast<int16_t>(*xlp++); *yp++ = static_cast<int16_t>(*ylp++); *zp++ = static_cast<int16_t>(*zlp++); } + std::cout << "big bag o bollox"; + allocate_pixel_data_d(size); + std::cout << "copying to device.\n"; + /* Copy to device */ size_t pitch_in_bytes_h[3]; for (int i = 0; i < 3; ++i) { @@ -96,6 +106,8 @@ CUDAJ2KEncoderThread::encode(DCPVideo const& frame) } } + std::cout << "copied to device.\n"; + nvjpeg2kImage_t device_image; device_image.num_components = 3; device_image.pixel_data = reinterpret_cast<void**>(_pixel_data_d); @@ -143,6 +155,8 @@ CUDAJ2KEncoderThread::encode(DCPVideo const& frame) throw CUDAError("nvjpeg2kEncodeParamsSetQuality", status); } + std::cout << "calling nvjpeg2kEncode\n"; + status = nvjpeg2kEncode(_encoder_handle, _encode_state, _encode_params, &device_image, _stream); if (status != NVJPEG2K_STATUS_SUCCESS) { throw CUDAError("nvjpeg2kEncode", status); @@ -179,6 +193,7 @@ CUDAJ2KEncoderThread::allocate_pixel_data_d(dcp::Size size) ); if (status != cudaSuccess) { + std::cout << "bad news brown: " << status << "\n"; throw CUDAError("cudaMallocPitch", status); } } |
