@@ -192,6 +192,7 @@ void CudaDeviceInterface::initialize(
192
192
const AVRational& timeBase,
193
193
const FrameDims& outputDims) {
194
194
TORCH_CHECK (!ctx_, " FFmpeg HW device context already initialized" );
195
+ TORCH_CHECK (codecContext != nullptr , " codecContext is null" );
195
196
196
197
timeBase_ = timeBase;
197
198
outputDims_ = outputDims;
@@ -222,8 +223,7 @@ void CudaDeviceInterface::convertAVFrameToFrameOutput(
222
223
// first, and do the color conversion there.
223
224
//
224
225
// TODO: If we're going to keep this around, we should probably cache it?
225
- auto cpuDevice = torch::Device (torch::kCPU );
226
- auto cpuInterface = createDeviceInterface (cpuDevice);
226
+ auto cpuInterface = createDeviceInterface (torch::Device (torch::kCPU ));
227
227
TORCH_CHECK (
228
228
cpuInterface != nullptr , " Failed to create CPU device interface" );
229
229
cpuInterface->initialize (
@@ -294,6 +294,8 @@ void CudaDeviceInterface::convertAVFrameToFrameOutput(
294
294
" The AVFrame's hw_frames_ctx does not have a device_ctx. " );
295
295
auto cudaDeviceCtx =
296
296
static_cast <AVCUDADeviceContext*>(hwFramesCtx->device_ctx ->hwctx );
297
+ TORCH_CHECK (cudaDeviceCtx != nullptr , " The hardware context is null" );
298
+
297
299
at::cuda::CUDAEvent nvdecDoneEvent;
298
300
at::cuda::CUDAStream nvdecStream = // That's always the default stream. Sad.
299
301
c10::cuda::getStreamFromExternal (cudaDeviceCtx->stream , deviceIndex);
0 commit comments