Skip to content

Commit d5f4ea9

Browse files
committed
Fix cuda builds for lower ffmpeg versions
1 parent c6a0a5a commit d5f4ea9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/torchcodec/decoders/_core/CudaDevice.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ AVBufferRef* getFromCache(const torch::Device& device) {
7777
return nullptr;
7878
}
7979

80+
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 26, 100)
81+
8082
AVBufferRef* getFFMPEGContextFromExistingCudaContext(
8183
const torch::Device& device,
8284
torch::DeviceIndex nonNegativeDeviceIndex,
@@ -105,6 +107,8 @@ AVBufferRef* getFFMPEGContextFromExistingCudaContext(
105107
return hw_device_ctx;
106108
}
107109

110+
#else
111+
108112
AVBufferRef* getFFMPEGContextFromNewCudaContext(
109113
const torch::Device& device,
110114
torch::DeviceIndex nonNegativeDeviceIndex,
@@ -122,6 +126,8 @@ AVBufferRef* getFFMPEGContextFromNewCudaContext(
122126
return hw_device_ctx;
123127
}
124128

129+
#endif
130+
125131
AVBufferRef* getCudaContext(const torch::Device& device) {
126132
enum AVHWDeviceType type = av_hwdevice_find_type_by_name("cuda");
127133
TORCH_CHECK(type != AV_HWDEVICE_TYPE_NONE, "Failed to find cuda device");

0 commit comments

Comments
 (0)