torchcodec 0.7.0__cp313-cp313-win_amd64.whl → 0.8.1__cp313-cp313-win_amd64.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/_core/AVIOTensorContext.cpp +23 -16
- torchcodec/_core/AVIOTensorContext.h +2 -1
- torchcodec/_core/BetaCudaDeviceInterface.cpp +718 -0
- torchcodec/_core/BetaCudaDeviceInterface.h +193 -0
- torchcodec/_core/CMakeLists.txt +18 -3
- torchcodec/_core/CUDACommon.cpp +330 -0
- torchcodec/_core/CUDACommon.h +51 -0
- torchcodec/_core/Cache.h +6 -20
- torchcodec/_core/CpuDeviceInterface.cpp +195 -108
- torchcodec/_core/CpuDeviceInterface.h +84 -19
- torchcodec/_core/CudaDeviceInterface.cpp +227 -376
- torchcodec/_core/CudaDeviceInterface.h +38 -6
- torchcodec/_core/DeviceInterface.cpp +57 -19
- torchcodec/_core/DeviceInterface.h +97 -16
- torchcodec/_core/Encoder.cpp +346 -9
- torchcodec/_core/Encoder.h +62 -1
- torchcodec/_core/FFMPEGCommon.cpp +190 -3
- torchcodec/_core/FFMPEGCommon.h +27 -1
- torchcodec/_core/FilterGraph.cpp +30 -22
- torchcodec/_core/FilterGraph.h +15 -1
- torchcodec/_core/Frame.cpp +22 -7
- torchcodec/_core/Frame.h +15 -61
- torchcodec/_core/Metadata.h +2 -2
- torchcodec/_core/NVCUVIDRuntimeLoader.cpp +320 -0
- torchcodec/_core/NVCUVIDRuntimeLoader.h +14 -0
- torchcodec/_core/NVDECCache.cpp +60 -0
- torchcodec/_core/NVDECCache.h +102 -0
- torchcodec/_core/SingleStreamDecoder.cpp +196 -201
- torchcodec/_core/SingleStreamDecoder.h +42 -15
- torchcodec/_core/StreamOptions.h +16 -6
- torchcodec/_core/Transform.cpp +87 -0
- torchcodec/_core/Transform.h +84 -0
- torchcodec/_core/__init__.py +4 -0
- torchcodec/_core/custom_ops.cpp +257 -32
- torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +61 -1
- torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
- torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
- torchcodec/_core/ops.py +147 -44
- torchcodec/_core/pybind_ops.cpp +22 -59
- torchcodec/_samplers/video_clip_sampler.py +7 -19
- torchcodec/decoders/__init__.py +1 -0
- torchcodec/decoders/_decoder_utils.py +61 -1
- torchcodec/decoders/_video_decoder.py +46 -20
- torchcodec/libtorchcodec_core4.dll +0 -0
- torchcodec/libtorchcodec_core5.dll +0 -0
- torchcodec/libtorchcodec_core6.dll +0 -0
- torchcodec/libtorchcodec_core7.dll +0 -0
- torchcodec/libtorchcodec_core8.dll +0 -0
- torchcodec/libtorchcodec_custom_ops4.dll +0 -0
- torchcodec/libtorchcodec_custom_ops5.dll +0 -0
- torchcodec/libtorchcodec_custom_ops6.dll +0 -0
- torchcodec/libtorchcodec_custom_ops7.dll +0 -0
- torchcodec/libtorchcodec_custom_ops8.dll +0 -0
- torchcodec/libtorchcodec_pybind_ops4.pyd +0 -0
- torchcodec/libtorchcodec_pybind_ops5.pyd +0 -0
- torchcodec/libtorchcodec_pybind_ops6.pyd +0 -0
- torchcodec/libtorchcodec_pybind_ops7.pyd +0 -0
- torchcodec/libtorchcodec_pybind_ops8.pyd +0 -0
- torchcodec/samplers/_time_based.py +8 -0
- torchcodec/version.py +1 -1
- {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/METADATA +29 -16
- torchcodec-0.8.1.dist-info/RECORD +82 -0
- {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/WHEEL +1 -1
- torchcodec-0.7.0.dist-info/RECORD +0 -67
- {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/licenses/LICENSE +0 -0
- {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/top_level.txt +0 -0
|
@@ -18,15 +18,15 @@ constexpr int64_t MAX_TENSOR_SIZE = 320'000'000; // 320 MB
|
|
|
18
18
|
int read(void* opaque, uint8_t* buf, int buf_size) {
|
|
19
19
|
auto tensorContext = static_cast<detail::TensorContext*>(opaque);
|
|
20
20
|
TORCH_CHECK(
|
|
21
|
-
tensorContext->
|
|
22
|
-
"Tried to read outside of the buffer:
|
|
23
|
-
tensorContext->
|
|
21
|
+
tensorContext->current_pos <= tensorContext->data.numel(),
|
|
22
|
+
"Tried to read outside of the buffer: current_pos=",
|
|
23
|
+
tensorContext->current_pos,
|
|
24
24
|
", size=",
|
|
25
25
|
tensorContext->data.numel());
|
|
26
26
|
|
|
27
27
|
int64_t numBytesRead = std::min(
|
|
28
28
|
static_cast<int64_t>(buf_size),
|
|
29
|
-
tensorContext->data.numel() - tensorContext->
|
|
29
|
+
tensorContext->data.numel() - tensorContext->current_pos);
|
|
30
30
|
|
|
31
31
|
TORCH_CHECK(
|
|
32
32
|
numBytesRead >= 0,
|
|
@@ -34,8 +34,8 @@ int read(void* opaque, uint8_t* buf, int buf_size) {
|
|
|
34
34
|
numBytesRead,
|
|
35
35
|
", size=",
|
|
36
36
|
tensorContext->data.numel(),
|
|
37
|
-
",
|
|
38
|
-
tensorContext->
|
|
37
|
+
", current_pos=",
|
|
38
|
+
tensorContext->current_pos);
|
|
39
39
|
|
|
40
40
|
if (numBytesRead == 0) {
|
|
41
41
|
return AVERROR_EOF;
|
|
@@ -43,9 +43,9 @@ int read(void* opaque, uint8_t* buf, int buf_size) {
|
|
|
43
43
|
|
|
44
44
|
std::memcpy(
|
|
45
45
|
buf,
|
|
46
|
-
tensorContext->data.data_ptr<uint8_t>() + tensorContext->
|
|
46
|
+
tensorContext->data.data_ptr<uint8_t>() + tensorContext->current_pos,
|
|
47
47
|
numBytesRead);
|
|
48
|
-
tensorContext->
|
|
48
|
+
tensorContext->current_pos += numBytesRead;
|
|
49
49
|
return numBytesRead;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ int write(void* opaque, const uint8_t* buf, int buf_size) {
|
|
|
54
54
|
auto tensorContext = static_cast<detail::TensorContext*>(opaque);
|
|
55
55
|
|
|
56
56
|
int64_t bufSize = static_cast<int64_t>(buf_size);
|
|
57
|
-
if (tensorContext->
|
|
57
|
+
if (tensorContext->current_pos + bufSize > tensorContext->data.numel()) {
|
|
58
58
|
TORCH_CHECK(
|
|
59
59
|
tensorContext->data.numel() * 2 <= MAX_TENSOR_SIZE,
|
|
60
60
|
"We tried to allocate an output encoded tensor larger than ",
|
|
@@ -68,13 +68,17 @@ int write(void* opaque, const uint8_t* buf, int buf_size) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
TORCH_CHECK(
|
|
71
|
-
tensorContext->
|
|
71
|
+
tensorContext->current_pos + bufSize <= tensorContext->data.numel(),
|
|
72
72
|
"Re-allocation of the output tensor didn't work. ",
|
|
73
73
|
"This should not happen, please report on TorchCodec bug tracker");
|
|
74
74
|
|
|
75
75
|
uint8_t* outputTensorData = tensorContext->data.data_ptr<uint8_t>();
|
|
76
|
-
std::memcpy(outputTensorData + tensorContext->
|
|
77
|
-
tensorContext->
|
|
76
|
+
std::memcpy(outputTensorData + tensorContext->current_pos, buf, bufSize);
|
|
77
|
+
tensorContext->current_pos += bufSize;
|
|
78
|
+
// Track the maximum position written so getOutputTensor's narrow() does not
|
|
79
|
+
// truncate the file if final seek was backwards
|
|
80
|
+
tensorContext->max_pos =
|
|
81
|
+
std::max(tensorContext->current_pos, tensorContext->max_pos);
|
|
78
82
|
return buf_size;
|
|
79
83
|
}
|
|
80
84
|
|
|
@@ -88,7 +92,7 @@ int64_t seek(void* opaque, int64_t offset, int whence) {
|
|
|
88
92
|
ret = tensorContext->data.numel();
|
|
89
93
|
break;
|
|
90
94
|
case SEEK_SET:
|
|
91
|
-
tensorContext->
|
|
95
|
+
tensorContext->current_pos = offset;
|
|
92
96
|
ret = offset;
|
|
93
97
|
break;
|
|
94
98
|
default:
|
|
@@ -101,7 +105,7 @@ int64_t seek(void* opaque, int64_t offset, int whence) {
|
|
|
101
105
|
} // namespace
|
|
102
106
|
|
|
103
107
|
AVIOFromTensorContext::AVIOFromTensorContext(torch::Tensor data)
|
|
104
|
-
: tensorContext_{data, 0} {
|
|
108
|
+
: tensorContext_{data, 0, 0} {
|
|
105
109
|
TORCH_CHECK(data.numel() > 0, "data must not be empty");
|
|
106
110
|
TORCH_CHECK(data.is_contiguous(), "data must be contiguous");
|
|
107
111
|
TORCH_CHECK(data.scalar_type() == torch::kUInt8, "data must be kUInt8");
|
|
@@ -110,14 +114,17 @@ AVIOFromTensorContext::AVIOFromTensorContext(torch::Tensor data)
|
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
AVIOToTensorContext::AVIOToTensorContext()
|
|
113
|
-
: tensorContext_{
|
|
117
|
+
: tensorContext_{
|
|
118
|
+
torch::empty({INITIAL_TENSOR_SIZE}, {torch::kUInt8}),
|
|
119
|
+
0,
|
|
120
|
+
0} {
|
|
114
121
|
createAVIOContext(
|
|
115
122
|
nullptr, &write, &seek, &tensorContext_, /*isForWriting=*/true);
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
torch::Tensor AVIOToTensorContext::getOutputTensor() {
|
|
119
126
|
return tensorContext_.data.narrow(
|
|
120
|
-
/*dim=*/0, /*start=*/0, /*length=*/tensorContext_.
|
|
127
|
+
/*dim=*/0, /*start=*/0, /*length=*/tensorContext_.max_pos);
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
} // namespace facebook::torchcodec
|