From 0b6ca28db00833714e3909d1931eace5500b6422 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:17:58 -0400 Subject: [PATCH] Do not compile CUDA helper for CPU build (#3657) --- src/libtorio/ffmpeg/stream_reader/stream_processor.cpp | 2 ++ src/libtorio/ffmpeg/stream_writer/encode_process.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/libtorio/ffmpeg/stream_reader/stream_processor.cpp b/src/libtorio/ffmpeg/stream_reader/stream_processor.cpp index 5d5f3c2c06..0636147b5d 100644 --- a/src/libtorio/ffmpeg/stream_reader/stream_processor.cpp +++ b/src/libtorio/ffmpeg/stream_reader/stream_processor.cpp @@ -27,6 +27,7 @@ AVCodecContextPtr alloc_codec_context( return AVCodecContextPtr(codec_ctx); } +#ifdef USE_CUDA const AVCodecHWConfig* get_cuda_config(const AVCodec* codec) { for (int i = 0;; ++i) { const AVCodecHWConfig* config = avcodec_get_hw_config(codec, i); @@ -80,6 +81,7 @@ enum AVPixelFormat get_hw_format( TORCH_WARN("Failed to get HW surface format."); return AV_PIX_FMT_NONE; } +#endif // USE_CUDA AVBufferRef* get_hw_frames_ctx(AVCodecContext* codec_ctx) { AVBufferRef* p = av_hwframe_ctx_alloc(codec_ctx->hw_device_ctx); diff --git a/src/libtorio/ffmpeg/stream_writer/encode_process.cpp b/src/libtorio/ffmpeg/stream_writer/encode_process.cpp index 4e361f503f..474d66731b 100644 --- a/src/libtorio/ffmpeg/stream_writer/encode_process.cpp +++ b/src/libtorio/ffmpeg/stream_writer/encode_process.cpp @@ -527,6 +527,7 @@ void configure_video_codec_ctx( } } +#ifdef USE_CUDA void configure_hw_accel(AVCodecContext* ctx, const std::string& hw_accel) { torch::Device device{hw_accel}; TORCH_CHECK( @@ -570,6 +571,7 @@ void configure_hw_accel(AVCodecContext* ctx, const std::string& hw_accel) { "Failed to initialize CUDA frame context: ", av_err2string(ret)); } +#endif // USE_CUDA //////////////////////////////////////////////////////////////////////////////// // AVStream