torchcodec 0.7.0__cp312-cp312-win_amd64.whl → 0.8.1__cp312-cp312-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.

Files changed (66) hide show
  1. torchcodec/_core/AVIOTensorContext.cpp +23 -16
  2. torchcodec/_core/AVIOTensorContext.h +2 -1
  3. torchcodec/_core/BetaCudaDeviceInterface.cpp +718 -0
  4. torchcodec/_core/BetaCudaDeviceInterface.h +193 -0
  5. torchcodec/_core/CMakeLists.txt +18 -3
  6. torchcodec/_core/CUDACommon.cpp +330 -0
  7. torchcodec/_core/CUDACommon.h +51 -0
  8. torchcodec/_core/Cache.h +6 -20
  9. torchcodec/_core/CpuDeviceInterface.cpp +195 -108
  10. torchcodec/_core/CpuDeviceInterface.h +84 -19
  11. torchcodec/_core/CudaDeviceInterface.cpp +227 -376
  12. torchcodec/_core/CudaDeviceInterface.h +38 -6
  13. torchcodec/_core/DeviceInterface.cpp +57 -19
  14. torchcodec/_core/DeviceInterface.h +97 -16
  15. torchcodec/_core/Encoder.cpp +346 -9
  16. torchcodec/_core/Encoder.h +62 -1
  17. torchcodec/_core/FFMPEGCommon.cpp +190 -3
  18. torchcodec/_core/FFMPEGCommon.h +27 -1
  19. torchcodec/_core/FilterGraph.cpp +30 -22
  20. torchcodec/_core/FilterGraph.h +15 -1
  21. torchcodec/_core/Frame.cpp +22 -7
  22. torchcodec/_core/Frame.h +15 -61
  23. torchcodec/_core/Metadata.h +2 -2
  24. torchcodec/_core/NVCUVIDRuntimeLoader.cpp +320 -0
  25. torchcodec/_core/NVCUVIDRuntimeLoader.h +14 -0
  26. torchcodec/_core/NVDECCache.cpp +60 -0
  27. torchcodec/_core/NVDECCache.h +102 -0
  28. torchcodec/_core/SingleStreamDecoder.cpp +196 -201
  29. torchcodec/_core/SingleStreamDecoder.h +42 -15
  30. torchcodec/_core/StreamOptions.h +16 -6
  31. torchcodec/_core/Transform.cpp +87 -0
  32. torchcodec/_core/Transform.h +84 -0
  33. torchcodec/_core/__init__.py +4 -0
  34. torchcodec/_core/custom_ops.cpp +257 -32
  35. torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +61 -1
  36. torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
  37. torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
  38. torchcodec/_core/ops.py +147 -44
  39. torchcodec/_core/pybind_ops.cpp +22 -59
  40. torchcodec/_samplers/video_clip_sampler.py +7 -19
  41. torchcodec/decoders/__init__.py +1 -0
  42. torchcodec/decoders/_decoder_utils.py +61 -1
  43. torchcodec/decoders/_video_decoder.py +46 -20
  44. torchcodec/libtorchcodec_core4.dll +0 -0
  45. torchcodec/libtorchcodec_core5.dll +0 -0
  46. torchcodec/libtorchcodec_core6.dll +0 -0
  47. torchcodec/libtorchcodec_core7.dll +0 -0
  48. torchcodec/libtorchcodec_core8.dll +0 -0
  49. torchcodec/libtorchcodec_custom_ops4.dll +0 -0
  50. torchcodec/libtorchcodec_custom_ops5.dll +0 -0
  51. torchcodec/libtorchcodec_custom_ops6.dll +0 -0
  52. torchcodec/libtorchcodec_custom_ops7.dll +0 -0
  53. torchcodec/libtorchcodec_custom_ops8.dll +0 -0
  54. torchcodec/libtorchcodec_pybind_ops4.pyd +0 -0
  55. torchcodec/libtorchcodec_pybind_ops5.pyd +0 -0
  56. torchcodec/libtorchcodec_pybind_ops6.pyd +0 -0
  57. torchcodec/libtorchcodec_pybind_ops7.pyd +0 -0
  58. torchcodec/libtorchcodec_pybind_ops8.pyd +0 -0
  59. torchcodec/samplers/_time_based.py +8 -0
  60. torchcodec/version.py +1 -1
  61. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/METADATA +29 -16
  62. torchcodec-0.8.1.dist-info/RECORD +82 -0
  63. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/WHEEL +1 -1
  64. torchcodec-0.7.0.dist-info/RECORD +0 -67
  65. {torchcodec-0.7.0.dist-info → torchcodec-0.8.1.dist-info}/licenses/LICENSE +0 -0
  66. {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->current <= tensorContext->data.numel(),
22
- "Tried to read outside of the buffer: current=",
23
- tensorContext->current,
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->current);
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
- ", current=",
38
- tensorContext->current);
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->current,
46
+ tensorContext->data.data_ptr<uint8_t>() + tensorContext->current_pos,
47
47
  numBytesRead);
48
- tensorContext->current += numBytesRead;
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->current + bufSize > tensorContext->data.numel()) {
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->current + bufSize <= tensorContext->data.numel(),
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->current, buf, bufSize);
77
- tensorContext->current += bufSize;
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->current = offset;
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_{torch::empty({INITIAL_TENSOR_SIZE}, {torch::kUInt8}), 0} {
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_.current);
127
+ /*dim=*/0, /*start=*/0, /*length=*/tensorContext_.max_pos);
121
128
  }
122
129
 
123
130
  } // namespace facebook::torchcodec
@@ -15,7 +15,8 @@ namespace detail {
15
15
 
16
16
  struct TensorContext {
17
17
  torch::Tensor data;
18
- int64_t current;
18
+ int64_t current_pos;
19
+ int64_t max_pos;
19
20
  };
20
21
 
21
22
  } // namespace detail