Skip to content

Commit

Permalink
Use CXX_FLAGS; fix Cuda code
Browse files Browse the repository at this point in the history
  • Loading branch information
scotts committed Jan 16, 2025
1 parent 07ef579 commit 0b8e9e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/torchcodec/decoders/_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ cmake_minimum_required(VERSION 3.18)
project(TorchCodec)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra -pedantic -Werror)

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -Wall -Wextra -pedantic -Werror")
find_package(Python3 ${PYTHON_VERSION} EXACT COMPONENTS Development)

function(make_torchcodec_library library_name ffmpeg_target)
Expand Down
13 changes: 6 additions & 7 deletions src/torchcodec/decoders/_core/CudaDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,16 @@ std::optional<AVCodecPtr> findCudaCodec(

void* i = nullptr;

const AVCodecPtr c;
while ((c = av_codec_iterate(&i))) {
const AVCodecHWConfig* config;

if (c->id != codecId || !av_codec_is_decoder(c)) {
while ((const AVCodecPtr codec = av_codec_iterate(&i))) {
if (codec->id != codecId || !av_codec_is_decoder(codec)) {
continue;
}

for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
for (int j = 0;
(const AVCodecHWConfig* config = avcodec_get_hw_config(codec, j));
j++) {
if (config->device_type == AV_HWDEVICE_TYPE_CUDA) {
return c;
return codec;
}
}
}
Expand Down

0 comments on commit 0b8e9e0

Please sign in to comment.