torchcodec 0.6.0__cp310-cp310-macosx_11_0_arm64.whl → 0.8.0__cp310-cp310-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of torchcodec might be problematic. Click here for more details.
- torchcodec/.dylibs/libc++.1.0.dylib +0 -0
- torchcodec/.dylibs/libpython3.10.dylib +0 -0
- torchcodec/_core/AVIOContextHolder.cpp +10 -5
- torchcodec/_core/AVIOContextHolder.h +1 -0
- torchcodec/_core/AVIOFileLikeContext.cpp +23 -5
- torchcodec/_core/AVIOFileLikeContext.h +2 -1
- torchcodec/_core/AVIOTensorContext.cpp +4 -2
- torchcodec/_core/BetaCudaDeviceInterface.cpp +636 -0
- torchcodec/_core/BetaCudaDeviceInterface.h +191 -0
- torchcodec/_core/CMakeLists.txt +92 -20
- torchcodec/_core/CUDACommon.cpp +315 -0
- torchcodec/_core/CUDACommon.h +46 -0
- torchcodec/_core/Cache.h +138 -0
- torchcodec/_core/CpuDeviceInterface.cpp +201 -214
- torchcodec/_core/CpuDeviceInterface.h +88 -36
- torchcodec/_core/CudaDeviceInterface.cpp +239 -164
- torchcodec/_core/CudaDeviceInterface.h +33 -4
- torchcodec/_core/DeviceInterface.cpp +57 -19
- torchcodec/_core/DeviceInterface.h +97 -16
- torchcodec/_core/Encoder.cpp +315 -14
- torchcodec/_core/Encoder.h +57 -5
- torchcodec/_core/FFMPEGCommon.cpp +198 -3
- torchcodec/_core/FFMPEGCommon.h +33 -0
- torchcodec/_core/FilterGraph.cpp +149 -0
- torchcodec/_core/FilterGraph.h +59 -0
- torchcodec/_core/Frame.cpp +17 -7
- torchcodec/_core/Frame.h +15 -61
- torchcodec/_core/Metadata.h +2 -2
- torchcodec/_core/NVDECCache.cpp +70 -0
- torchcodec/_core/NVDECCache.h +104 -0
- torchcodec/_core/SingleStreamDecoder.cpp +233 -229
- torchcodec/_core/SingleStreamDecoder.h +39 -14
- torchcodec/_core/StreamOptions.h +16 -6
- torchcodec/_core/Transform.cpp +60 -0
- torchcodec/_core/Transform.h +59 -0
- torchcodec/_core/ValidationUtils.cpp +35 -0
- torchcodec/_core/ValidationUtils.h +21 -0
- torchcodec/_core/__init__.py +2 -0
- torchcodec/_core/custom_ops.cpp +199 -51
- torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +142 -8
- torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
- torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
- torchcodec/_core/ops.py +120 -21
- torchcodec/_core/pybind_ops.cpp +22 -21
- torchcodec/_internally_replaced_utils.py +9 -6
- torchcodec/_samplers/video_clip_sampler.py +7 -19
- torchcodec/decoders/__init__.py +1 -0
- torchcodec/decoders/_audio_decoder.py +3 -1
- torchcodec/decoders/_decoder_utils.py +62 -2
- torchcodec/decoders/_video_decoder.py +128 -33
- torchcodec/encoders/_audio_encoder.py +41 -1
- torchcodec/libtorchcodec_core4.dylib +0 -0
- torchcodec/libtorchcodec_core5.dylib +0 -0
- torchcodec/libtorchcodec_core6.dylib +0 -0
- torchcodec/libtorchcodec_core7.dylib +0 -0
- torchcodec/libtorchcodec_core8.dylib +0 -0
- torchcodec/libtorchcodec_custom_ops4.dylib +0 -0
- torchcodec/libtorchcodec_custom_ops5.dylib +0 -0
- torchcodec/libtorchcodec_custom_ops6.dylib +0 -0
- torchcodec/libtorchcodec_custom_ops7.dylib +0 -0
- torchcodec/libtorchcodec_custom_ops8.dylib +0 -0
- torchcodec/libtorchcodec_pybind_ops4.so +0 -0
- torchcodec/libtorchcodec_pybind_ops5.so +0 -0
- torchcodec/libtorchcodec_pybind_ops6.so +0 -0
- torchcodec/libtorchcodec_pybind_ops7.so +0 -0
- torchcodec/libtorchcodec_pybind_ops8.so +0 -0
- torchcodec/samplers/_index_based.py +2 -0
- torchcodec/samplers/_time_based.py +10 -0
- torchcodec/version.py +1 -1
- {torchcodec-0.6.0.dist-info → torchcodec-0.8.0.dist-info}/METADATA +31 -47
- torchcodec-0.8.0.dist-info/RECORD +82 -0
- {torchcodec-0.6.0.dist-info → torchcodec-0.8.0.dist-info}/WHEEL +1 -1
- torchcodec-0.6.0.dist-info/RECORD +0 -64
- {torchcodec-0.6.0.dist-info → torchcodec-0.8.0.dist-info}/licenses/LICENSE +0 -0
- {torchcodec-0.6.0.dist-info → torchcodec-0.8.0.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -14,6 +14,7 @@ void AVIOContextHolder::createAVIOContext(
|
|
|
14
14
|
AVIOWriteFunction write,
|
|
15
15
|
AVIOSeekFunction seek,
|
|
16
16
|
void* heldData,
|
|
17
|
+
bool isForWriting,
|
|
17
18
|
int bufferSize) {
|
|
18
19
|
TORCH_CHECK(
|
|
19
20
|
bufferSize > 0,
|
|
@@ -23,14 +24,18 @@ void AVIOContextHolder::createAVIOContext(
|
|
|
23
24
|
buffer != nullptr,
|
|
24
25
|
"Failed to allocate buffer of size " + std::to_string(bufferSize));
|
|
25
26
|
|
|
26
|
-
TORCH_CHECK(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
TORCH_CHECK(seek != nullptr, "seek method must be defined");
|
|
28
|
+
|
|
29
|
+
if (isForWriting) {
|
|
30
|
+
TORCH_CHECK(write != nullptr, "write method must be defined for writing");
|
|
31
|
+
} else {
|
|
32
|
+
TORCH_CHECK(read != nullptr, "read method must be defined for reading");
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
avioContext_.reset(avioAllocContext(
|
|
31
36
|
buffer,
|
|
32
37
|
bufferSize,
|
|
33
|
-
/*write_flag=*/
|
|
38
|
+
/*write_flag=*/isForWriting,
|
|
34
39
|
heldData,
|
|
35
40
|
read,
|
|
36
41
|
write,
|
|
@@ -9,21 +9,31 @@
|
|
|
9
9
|
|
|
10
10
|
namespace facebook::torchcodec {
|
|
11
11
|
|
|
12
|
-
AVIOFileLikeContext::AVIOFileLikeContext(
|
|
12
|
+
AVIOFileLikeContext::AVIOFileLikeContext(
|
|
13
|
+
const py::object& fileLike,
|
|
14
|
+
bool isForWriting)
|
|
13
15
|
: fileLike_{UniquePyObject(new py::object(fileLike))} {
|
|
14
16
|
{
|
|
15
17
|
// TODO: Is it necessary to acquire the GIL here? Is it maybe even
|
|
16
18
|
// harmful? At the moment, this is only called from within a pybind
|
|
17
19
|
// function, and pybind guarantees we have the GIL.
|
|
18
20
|
py::gil_scoped_acquire gil;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
if (isForWriting) {
|
|
23
|
+
TORCH_CHECK(
|
|
24
|
+
py::hasattr(fileLike, "write"),
|
|
25
|
+
"File like object must implement a write method for writing.");
|
|
26
|
+
} else {
|
|
27
|
+
TORCH_CHECK(
|
|
28
|
+
py::hasattr(fileLike, "read"),
|
|
29
|
+
"File like object must implement a read method for reading.");
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
TORCH_CHECK(
|
|
23
33
|
py::hasattr(fileLike, "seek"),
|
|
24
34
|
"File like object must implement a seek method.");
|
|
25
35
|
}
|
|
26
|
-
createAVIOContext(&read,
|
|
36
|
+
createAVIOContext(&read, &write, &seek, &fileLike_, isForWriting);
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
int AVIOFileLikeContext::read(void* opaque, uint8_t* buf, int buf_size) {
|
|
@@ -77,4 +87,12 @@ int64_t AVIOFileLikeContext::seek(void* opaque, int64_t offset, int whence) {
|
|
|
77
87
|
return py::cast<int64_t>((*fileLike)->attr("seek")(offset, whence));
|
|
78
88
|
}
|
|
79
89
|
|
|
90
|
+
int AVIOFileLikeContext::write(void* opaque, const uint8_t* buf, int buf_size) {
|
|
91
|
+
auto fileLike = static_cast<UniquePyObject*>(opaque);
|
|
92
|
+
py::gil_scoped_acquire gil;
|
|
93
|
+
py::bytes bytes_obj(reinterpret_cast<const char*>(buf), buf_size);
|
|
94
|
+
|
|
95
|
+
return py::cast<int>((*fileLike)->attr("write")(bytes_obj));
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
} // namespace facebook::torchcodec
|
|
@@ -19,11 +19,12 @@ namespace facebook::torchcodec {
|
|
|
19
19
|
// and seek calls back up to the methods on the Python object.
|
|
20
20
|
class AVIOFileLikeContext : public AVIOContextHolder {
|
|
21
21
|
public:
|
|
22
|
-
explicit AVIOFileLikeContext(py::object fileLike);
|
|
22
|
+
explicit AVIOFileLikeContext(const py::object& fileLike, bool isForWriting);
|
|
23
23
|
|
|
24
24
|
private:
|
|
25
25
|
static int read(void* opaque, uint8_t* buf, int buf_size);
|
|
26
26
|
static int64_t seek(void* opaque, int64_t offset, int whence);
|
|
27
|
+
static int write(void* opaque, const uint8_t* buf, int buf_size);
|
|
27
28
|
|
|
28
29
|
// Note that we dynamically allocate the Python object because we need to
|
|
29
30
|
// strictly control when its destructor is called. We must hold the GIL
|
|
@@ -105,12 +105,14 @@ AVIOFromTensorContext::AVIOFromTensorContext(torch::Tensor data)
|
|
|
105
105
|
TORCH_CHECK(data.numel() > 0, "data must not be empty");
|
|
106
106
|
TORCH_CHECK(data.is_contiguous(), "data must be contiguous");
|
|
107
107
|
TORCH_CHECK(data.scalar_type() == torch::kUInt8, "data must be kUInt8");
|
|
108
|
-
createAVIOContext(
|
|
108
|
+
createAVIOContext(
|
|
109
|
+
&read, nullptr, &seek, &tensorContext_, /*isForWriting=*/false);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
AVIOToTensorContext::AVIOToTensorContext()
|
|
112
113
|
: tensorContext_{torch::empty({INITIAL_TENSOR_SIZE}, {torch::kUInt8}), 0} {
|
|
113
|
-
createAVIOContext(
|
|
114
|
+
createAVIOContext(
|
|
115
|
+
nullptr, &write, &seek, &tensorContext_, /*isForWriting=*/true);
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
torch::Tensor AVIOToTensorContext::getOutputTensor() {
|