use j2k::PreparedBatchGroup;
use j2k_cuda::{CudaBatchDecoder, SubmittedCudaExternalBatch};
use j2k_cuda_runtime::{CudaContext, CudaDeviceBuffer, CudaExternalDeviceBufferViewMut};
pub(super) unsafe fn submit_external_for_test(
decoder: &mut CudaBatchDecoder,
group: &PreparedBatchGroup,
context: &CudaContext,
allocation: &mut CudaDeviceBuffer,
) -> SubmittedCudaExternalBatch {
let ptr = allocation.device_ptr();
let len = allocation.byte_len();
let mut destination = unsafe {
CudaExternalDeviceBufferViewMut::from_raw_parts(
context,
ptr,
len,
std::mem::align_of::<u8>(),
allocation,
)
}
.expect("external destination view");
unsafe { decoder.submit_batch_into(group, &mut destination) }
.expect("submit external test batch")
}