Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/torchcodec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import os.path as _osp

# Note: usort wants to put Frame and FrameBatch after decoders and samplers,
# but that results in circular import.
from ._core import core_library_path, variant
from ._frame import AudioSamples, Frame, FrameBatch # usort:skip # noqa
from . import decoders, samplers # noqa

Expand All @@ -14,3 +17,5 @@
from .version import __version__ # noqa: F401
except Exception:
pass

cmake_prefix_path = _osp.join(_osp.dirname(__file__), "share", "cmake")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment to explain what this is used for, and also let's use the more modern pathlib tools instead of os.path.

2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOContextHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/AVIOContextHolder.h"
#include "AVIOContextHolder.h"
#include <torch/types.h>

namespace facebook::torchcodec {
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOContextHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "FFMPEGCommon.h"

namespace facebook::torchcodec {

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOFileLikeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/AVIOFileLikeContext.h"
#include "AVIOFileLikeContext.h"
#include <torch/types.h>

namespace facebook::torchcodec {
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOFileLikeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include "src/torchcodec/_core/AVIOContextHolder.h"
#include "AVIOContextHolder.h"

namespace py = pybind11;

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOTensorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/AVIOTensorContext.h"
#include "AVIOTensorContext.h"
#include <torch/types.h>

namespace facebook::torchcodec {
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOTensorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once

#include <torch/types.h>
#include "src/torchcodec/_core/AVIOContextHolder.h"
#include "AVIOContextHolder.h"

namespace facebook::torchcodec {

Expand Down
12 changes: 6 additions & 6 deletions src/torchcodec/_core/BetaCudaDeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include <mutex>
#include <vector>

#include "src/torchcodec/_core/BetaCudaDeviceInterface.h"
#include "BetaCudaDeviceInterface.h"

#include "src/torchcodec/_core/DeviceInterface.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/NVDECCache.h"
#include "DeviceInterface.h"
#include "FFMPEGCommon.h"
#include "NVDECCache.h"

// #include <cuda_runtime.h> // For cudaStreamSynchronize
#include "src/torchcodec/_core/nvcuvid_include/cuviddec.h"
#include "src/torchcodec/_core/nvcuvid_include/nvcuvid.h"
#include "nvcuvid_include/cuviddec.h"
#include "nvcuvid_include/nvcuvid.h"

extern "C" {
#include <libavutil/hwcontext_cuda.h>
Expand Down
14 changes: 7 additions & 7 deletions src/torchcodec/_core/BetaCudaDeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

#pragma once

#include "src/torchcodec/_core/CUDACommon.h"
#include "src/torchcodec/_core/Cache.h"
#include "src/torchcodec/_core/DeviceInterface.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/NVDECCache.h"
#include "CUDACommon.h"
#include "Cache.h"
#include "DeviceInterface.h"
#include "FFMPEGCommon.h"
#include "NVDECCache.h"

#include <map>
#include <memory>
Expand All @@ -28,8 +28,8 @@
#include <unordered_map>
#include <vector>

#include "src/torchcodec/_core/nvcuvid_include/cuviddec.h"
#include "src/torchcodec/_core/nvcuvid_include/nvcuvid.h"
#include "nvcuvid_include/cuviddec.h"
#include "nvcuvid_include/nvcuvid.h"

namespace facebook::torchcodec {

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/CUDACommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/CUDACommon.h"
#include "src/torchcodec/_core/Cache.h" // for PerGpuCache
#include "CUDACommon.h"
#include "Cache.h" // for PerGpuCache

namespace facebook::torchcodec {

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/CUDACommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <npp.h>
#include <torch/types.h>

#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/Frame.h"
#include "FFMPEGCommon.h"
#include "Frame.h"

extern "C" {
#include <libavutil/hwcontext_cuda.h>
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/CpuDeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/CpuDeviceInterface.h"
#include "CpuDeviceInterface.h"

namespace facebook::torchcodec {
namespace {
Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/CpuDeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#pragma once

#include "src/torchcodec/_core/DeviceInterface.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/FilterGraph.h"
#include "DeviceInterface.h"
#include "FFMPEGCommon.h"
#include "FilterGraph.h"

namespace facebook::torchcodec {

Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/CudaDeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <torch/types.h>
#include <mutex>

#include "src/torchcodec/_core/Cache.h"
#include "src/torchcodec/_core/CudaDeviceInterface.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "Cache.h"
#include "CudaDeviceInterface.h"
#include "FFMPEGCommon.h"

extern "C" {
#include <libavutil/hwcontext_cuda.h>
Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/CudaDeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#pragma once

#include "src/torchcodec/_core/CUDACommon.h"
#include "src/torchcodec/_core/DeviceInterface.h"
#include "src/torchcodec/_core/FilterGraph.h"
#include "CUDACommon.h"
#include "DeviceInterface.h"
#include "FilterGraph.h"

namespace facebook::torchcodec {

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/DeviceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/DeviceInterface.h"
#include "DeviceInterface.h"
#include <map>
#include <mutex>

Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/DeviceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <stdexcept>
#include <string>
#include "FFMPEGCommon.h"
#include "src/torchcodec/_core/Frame.h"
#include "src/torchcodec/_core/StreamOptions.h"
#include "src/torchcodec/_core/Transform.h"
#include "Frame.h"
#include "StreamOptions.h"
#include "Transform.h"

namespace facebook::torchcodec {

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/Encoder.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <sstream>

#include "src/torchcodec/_core/AVIOTensorContext.h"
#include "src/torchcodec/_core/Encoder.h"
#include "AVIOTensorContext.h"
#include "Encoder.h"
#include "torch/types.h"

namespace facebook::torchcodec {
Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/Encoder.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <torch/types.h>
#include "src/torchcodec/_core/AVIOContextHolder.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/StreamOptions.h"
#include "AVIOContextHolder.h"
#include "FFMPEGCommon.h"
#include "StreamOptions.h"

namespace facebook::torchcodec {
class AudioEncoder {
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/FFMPEGCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "FFMPEGCommon.h"

#include <c10/util/Exception.h>

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/FilterGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/FilterGraph.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "FilterGraph.h"
#include "FFMPEGCommon.h"

extern "C" {
#include <libavfilter/buffersink.h>
Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/FilterGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#pragma once

#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/StreamOptions.h"
#include "FFMPEGCommon.h"
#include "StreamOptions.h"

namespace facebook::torchcodec {

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/Frame.h"
#include "Frame.h"

namespace facebook::torchcodec {

Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#pragma once

#include <torch/types.h>
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/Metadata.h"
#include "src/torchcodec/_core/StreamOptions.h"
#include "FFMPEGCommon.h"
#include "Metadata.h"
#include "StreamOptions.h"

namespace facebook::torchcodec {

Expand Down
6 changes: 3 additions & 3 deletions src/torchcodec/_core/NVDECCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <torch/types.h>
#include <mutex>

#include "src/torchcodec/_core/CUDACommon.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/NVDECCache.h"
#include "CUDACommon.h"
#include "FFMPEGCommon.h"
#include "NVDECCache.h"

#include <cuda_runtime.h> // For cudaGetDevice

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/NVDECCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include <cuda.h>
#include <torch/types.h>
#include "src/torchcodec/_core/nvcuvid_include/cuviddec.h"
#include "src/torchcodec/_core/nvcuvid_include/nvcuvid.h"
#include "nvcuvid_include/cuviddec.h"
#include "nvcuvid_include/nvcuvid.h"

namespace facebook::torchcodec {

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/SingleStreamDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/SingleStreamDecoder.h"
#include "SingleStreamDecoder.h"
#include <cstdint>
#include <cstdio>
#include <iostream>
Expand Down
12 changes: 6 additions & 6 deletions src/torchcodec/_core/SingleStreamDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
#include <ostream>
#include <string_view>

#include "src/torchcodec/_core/AVIOContextHolder.h"
#include "src/torchcodec/_core/DeviceInterface.h"
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "src/torchcodec/_core/Frame.h"
#include "src/torchcodec/_core/StreamOptions.h"
#include "src/torchcodec/_core/Transform.h"
#include "AVIOContextHolder.h"
#include "DeviceInterface.h"
#include "FFMPEGCommon.h"
#include "Frame.h"
#include "StreamOptions.h"
#include "Transform.h"

namespace facebook::torchcodec {

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/Transform.h"
#include "Transform.h"
#include <torch/types.h>
#include "src/torchcodec/_core/FFMPEGCommon.h"
#include "FFMPEGCommon.h"

namespace facebook::torchcodec {

Expand Down
4 changes: 2 additions & 2 deletions src/torchcodec/_core/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <optional>
#include <string>
#include "src/torchcodec/_core/Frame.h"
#include "src/torchcodec/_core/Metadata.h"
#include "Frame.h"
#include "Metadata.h"

namespace facebook::torchcodec {

Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/ValidationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "src/torchcodec/_core/ValidationUtils.h"
#include "ValidationUtils.h"
#include <limits>
#include "c10/util/Exception.h"

Expand Down
2 changes: 2 additions & 0 deletions src/torchcodec/_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
_test_frame_pts_equality,
add_audio_stream,
add_video_stream,
core_library_path,
create_from_bytes,
create_from_file,
create_from_file_like,
Expand All @@ -41,4 +42,5 @@
get_next_frame,
scan_all_streams_to_update_metadata,
seek_to_pts,
variant,
)
Loading
Loading