torchcodec 0.7.0__cp312-cp312-win_amd64.whl → 0.8.0__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 (61) hide show
  1. torchcodec/_core/BetaCudaDeviceInterface.cpp +636 -0
  2. torchcodec/_core/BetaCudaDeviceInterface.h +191 -0
  3. torchcodec/_core/CMakeLists.txt +36 -3
  4. torchcodec/_core/CUDACommon.cpp +315 -0
  5. torchcodec/_core/CUDACommon.h +46 -0
  6. torchcodec/_core/CpuDeviceInterface.cpp +189 -108
  7. torchcodec/_core/CpuDeviceInterface.h +81 -19
  8. torchcodec/_core/CudaDeviceInterface.cpp +211 -368
  9. torchcodec/_core/CudaDeviceInterface.h +33 -6
  10. torchcodec/_core/DeviceInterface.cpp +57 -19
  11. torchcodec/_core/DeviceInterface.h +97 -16
  12. torchcodec/_core/Encoder.cpp +302 -9
  13. torchcodec/_core/Encoder.h +51 -1
  14. torchcodec/_core/FFMPEGCommon.cpp +189 -2
  15. torchcodec/_core/FFMPEGCommon.h +18 -0
  16. torchcodec/_core/FilterGraph.cpp +28 -21
  17. torchcodec/_core/FilterGraph.h +15 -1
  18. torchcodec/_core/Frame.cpp +17 -7
  19. torchcodec/_core/Frame.h +15 -61
  20. torchcodec/_core/Metadata.h +2 -2
  21. torchcodec/_core/NVDECCache.cpp +70 -0
  22. torchcodec/_core/NVDECCache.h +104 -0
  23. torchcodec/_core/SingleStreamDecoder.cpp +202 -198
  24. torchcodec/_core/SingleStreamDecoder.h +39 -14
  25. torchcodec/_core/StreamOptions.h +16 -6
  26. torchcodec/_core/Transform.cpp +60 -0
  27. torchcodec/_core/Transform.h +59 -0
  28. torchcodec/_core/__init__.py +1 -0
  29. torchcodec/_core/custom_ops.cpp +180 -32
  30. torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +61 -1
  31. torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
  32. torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
  33. torchcodec/_core/ops.py +86 -43
  34. torchcodec/_core/pybind_ops.cpp +22 -59
  35. torchcodec/_samplers/video_clip_sampler.py +7 -19
  36. torchcodec/decoders/__init__.py +1 -0
  37. torchcodec/decoders/_decoder_utils.py +61 -1
  38. torchcodec/decoders/_video_decoder.py +56 -20
  39. torchcodec/libtorchcodec_core4.dll +0 -0
  40. torchcodec/libtorchcodec_core5.dll +0 -0
  41. torchcodec/libtorchcodec_core6.dll +0 -0
  42. torchcodec/libtorchcodec_core7.dll +0 -0
  43. torchcodec/libtorchcodec_core8.dll +0 -0
  44. torchcodec/libtorchcodec_custom_ops4.dll +0 -0
  45. torchcodec/libtorchcodec_custom_ops5.dll +0 -0
  46. torchcodec/libtorchcodec_custom_ops6.dll +0 -0
  47. torchcodec/libtorchcodec_custom_ops7.dll +0 -0
  48. torchcodec/libtorchcodec_custom_ops8.dll +0 -0
  49. torchcodec/libtorchcodec_pybind_ops4.pyd +0 -0
  50. torchcodec/libtorchcodec_pybind_ops5.pyd +0 -0
  51. torchcodec/libtorchcodec_pybind_ops6.pyd +0 -0
  52. torchcodec/libtorchcodec_pybind_ops7.pyd +0 -0
  53. torchcodec/libtorchcodec_pybind_ops8.pyd +0 -0
  54. torchcodec/samplers/_time_based.py +8 -0
  55. torchcodec/version.py +1 -1
  56. {torchcodec-0.7.0.dist-info → torchcodec-0.8.0.dist-info}/METADATA +24 -13
  57. torchcodec-0.8.0.dist-info/RECORD +80 -0
  58. {torchcodec-0.7.0.dist-info → torchcodec-0.8.0.dist-info}/WHEEL +1 -1
  59. torchcodec-0.7.0.dist-info/RECORD +0 -67
  60. {torchcodec-0.7.0.dist-info → torchcodec-0.8.0.dist-info}/licenses/LICENSE +0 -0
  61. {torchcodec-0.7.0.dist-info → torchcodec-0.8.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,104 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ // All rights reserved.
3
+ //
4
+ // This source code is licensed under the BSD-style license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+
7
+ #pragma once
8
+
9
+ #include <map>
10
+ #include <memory>
11
+ #include <mutex>
12
+
13
+ #include <cuda.h>
14
+ #include "src/torchcodec/_core/nvcuvid_include/cuviddec.h"
15
+ #include "src/torchcodec/_core/nvcuvid_include/nvcuvid.h"
16
+
17
+ namespace facebook::torchcodec {
18
+
19
+ // This file implements a cache for NVDEC decoders.
20
+ // TODONVDEC P3: Consider merging this with Cache.h. The main difference is that
21
+ // this NVDEC Cache involves a cache key (the decoder parameters).
22
+
23
+ struct CUvideoDecoderDeleter {
24
+ void operator()(CUvideodecoder* decoderPtr) const {
25
+ if (decoderPtr && *decoderPtr) {
26
+ cuvidDestroyDecoder(*decoderPtr);
27
+ delete decoderPtr;
28
+ }
29
+ }
30
+ };
31
+
32
+ using UniqueCUvideodecoder =
33
+ std::unique_ptr<CUvideodecoder, CUvideoDecoderDeleter>;
34
+
35
+ // A per-device cache for NVDEC decoders. There is one instance of this class
36
+ // per GPU device, and it is accessed through the static getCache() method.
37
+ class NVDECCache {
38
+ public:
39
+ static NVDECCache& getCache(int deviceIndex);
40
+
41
+ // Get decoder from cache - returns nullptr if none available
42
+ UniqueCUvideodecoder getDecoder(CUVIDEOFORMAT* videoFormat);
43
+
44
+ // Return decoder to cache - returns true if added to cache
45
+ bool returnDecoder(CUVIDEOFORMAT* videoFormat, UniqueCUvideodecoder decoder);
46
+
47
+ private:
48
+ // Cache key struct: a decoder can be reused and taken from the cache only if
49
+ // all these parameters match.
50
+ struct CacheKey {
51
+ cudaVideoCodec codecType;
52
+ uint32_t width;
53
+ uint32_t height;
54
+ cudaVideoChromaFormat chromaFormat;
55
+ uint32_t bitDepthLumaMinus8;
56
+ uint8_t numDecodeSurfaces;
57
+
58
+ CacheKey() = delete;
59
+
60
+ explicit CacheKey(CUVIDEOFORMAT* videoFormat)
61
+ : codecType(videoFormat->codec),
62
+ width(videoFormat->coded_width),
63
+ height(videoFormat->coded_height),
64
+ chromaFormat(videoFormat->chroma_format),
65
+ bitDepthLumaMinus8(videoFormat->bit_depth_luma_minus8),
66
+ numDecodeSurfaces(videoFormat->min_num_decode_surfaces) {}
67
+
68
+ CacheKey(const CacheKey&) = default;
69
+ CacheKey& operator=(const CacheKey&) = default;
70
+
71
+ // TODONVDEC P2: we only implement operator< which is enough for std::map,
72
+ // but:
73
+ // - we should consider using std::unordered_map
74
+ // - we should consider a more sophisticated and potentially less strict
75
+ // cache key comparison logic
76
+ bool operator<(const CacheKey& other) const {
77
+ return std::tie(
78
+ codecType,
79
+ width,
80
+ height,
81
+ chromaFormat,
82
+ bitDepthLumaMinus8,
83
+ numDecodeSurfaces) <
84
+ std::tie(
85
+ other.codecType,
86
+ other.width,
87
+ other.height,
88
+ other.chromaFormat,
89
+ other.bitDepthLumaMinus8,
90
+ other.numDecodeSurfaces);
91
+ }
92
+ };
93
+
94
+ NVDECCache() = default;
95
+ ~NVDECCache() = default;
96
+
97
+ std::map<CacheKey, UniqueCUvideodecoder> cache_;
98
+ std::mutex cacheLock_;
99
+
100
+ // Max number of cached decoders, per device
101
+ static constexpr int MAX_CACHE_SIZE = 20;
102
+ };
103
+
104
+ } // namespace facebook::torchcodec