torchcodec 1.0.0__py3-none-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.
- torchcodec/__init__.py +50 -0
- torchcodec/_core/AVIOContextHolder.cpp +85 -0
- torchcodec/_core/AVIOContextHolder.h +44 -0
- torchcodec/_core/AudioCommon.cpp +101 -0
- torchcodec/_core/AudioCommon.h +48 -0
- torchcodec/_core/AudioConverter.cpp +130 -0
- torchcodec/_core/AudioConverter.h +59 -0
- torchcodec/_core/BetaCudaDeviceInterface.cpp +1635 -0
- torchcodec/_core/BetaCudaDeviceInterface.h +364 -0
- torchcodec/_core/CMakeLists.txt +661 -0
- torchcodec/_core/CUDACommon.cpp +129 -0
- torchcodec/_core/CUDACommon.h +115 -0
- torchcodec/_core/Cache.h +126 -0
- torchcodec/_core/CodecParameters.cpp +98 -0
- torchcodec/_core/CodecParameters.h +59 -0
- torchcodec/_core/ColorConverter.cpp +92 -0
- torchcodec/_core/ColorConverter.h +40 -0
- torchcodec/_core/CpuDeviceInterface.cpp +654 -0
- torchcodec/_core/CpuDeviceInterface.h +153 -0
- torchcodec/_core/CudaDeviceInterface.cpp +519 -0
- torchcodec/_core/CudaDeviceInterface.h +92 -0
- torchcodec/_core/DecodeAvif.cpp +284 -0
- torchcodec/_core/DecodeAvif.h +28 -0
- torchcodec/_core/DecodeGif.cpp +488 -0
- torchcodec/_core/DecodeGif.h +32 -0
- torchcodec/_core/DecodeHeic.cpp +306 -0
- torchcodec/_core/DecodeHeic.h +18 -0
- torchcodec/_core/DecodeJpeg.cpp +489 -0
- torchcodec/_core/DecodeJpeg.h +17 -0
- torchcodec/_core/DecodeJpegCuda.cpp +638 -0
- torchcodec/_core/DecodeJpegCuda.h +92 -0
- torchcodec/_core/DecodePng.cpp +569 -0
- torchcodec/_core/DecodePng.h +31 -0
- torchcodec/_core/DecodeWebp.cpp +238 -0
- torchcodec/_core/DecodeWebp.h +17 -0
- torchcodec/_core/Demuxer.cpp +415 -0
- torchcodec/_core/Demuxer.h +158 -0
- torchcodec/_core/DeviceInterface.cpp +152 -0
- torchcodec/_core/DeviceInterface.h +255 -0
- torchcodec/_core/EncodeJpeg.cpp +223 -0
- torchcodec/_core/EncodeJpeg.h +19 -0
- torchcodec/_core/EncodeJpegCuda.cpp +272 -0
- torchcodec/_core/EncodeJpegCuda.h +56 -0
- torchcodec/_core/EncodePng.cpp +207 -0
- torchcodec/_core/EncodePng.h +19 -0
- torchcodec/_core/Encoder.cpp +1023 -0
- torchcodec/_core/Encoder.h +144 -0
- torchcodec/_core/Exif.h +241 -0
- torchcodec/_core/FFMPEGCommon.cpp +1159 -0
- torchcodec/_core/FFMPEGCommon.h +506 -0
- torchcodec/_core/FileIO.cpp +78 -0
- torchcodec/_core/FileIO.h +34 -0
- torchcodec/_core/FileLikeIO.cpp +76 -0
- torchcodec/_core/FileLikeIO.h +68 -0
- torchcodec/_core/FilterGraph.cpp +211 -0
- torchcodec/_core/FilterGraph.h +59 -0
- torchcodec/_core/Frame.cpp +75 -0
- torchcodec/_core/Frame.h +76 -0
- torchcodec/_core/IOInterface.h +44 -0
- torchcodec/_core/ImageCommon.h +113 -0
- torchcodec/_core/Logging.cpp +42 -0
- torchcodec/_core/Logging.h +38 -0
- torchcodec/_core/Metadata.cpp +312 -0
- torchcodec/_core/Metadata.h +115 -0
- torchcodec/_core/NVCUVIDRuntimeLoader.cpp +324 -0
- torchcodec/_core/NVCUVIDRuntimeLoader.h +14 -0
- torchcodec/_core/NVDECCache.cpp +111 -0
- torchcodec/_core/NVDECCache.h +136 -0
- torchcodec/_core/NVDECCacheConfig.cpp +61 -0
- torchcodec/_core/NVDECCacheConfig.h +30 -0
- torchcodec/_core/PacketDecoder.cpp +358 -0
- torchcodec/_core/PacketDecoder.h +140 -0
- torchcodec/_core/SingleStreamDecoder.cpp +1856 -0
- torchcodec/_core/SingleStreamDecoder.h +424 -0
- torchcodec/_core/StableABICompat.h +213 -0
- torchcodec/_core/StreamOptions.h +93 -0
- torchcodec/_core/SwScale.cpp +124 -0
- torchcodec/_core/SwScale.h +67 -0
- torchcodec/_core/TensorIO.cpp +136 -0
- torchcodec/_core/TensorIO.h +53 -0
- torchcodec/_core/Transform.cpp +207 -0
- torchcodec/_core/Transform.h +125 -0
- torchcodec/_core/ValidationUtils.cpp +65 -0
- torchcodec/_core/ValidationUtils.h +29 -0
- torchcodec/_core/WavDecoder.cpp +494 -0
- torchcodec/_core/WavDecoder.h +73 -0
- torchcodec/_core/__init__.py +45 -0
- torchcodec/_core/_decoder_utils.py +258 -0
- torchcodec/_core/_ffmpeg_op_names.py +95 -0
- torchcodec/_core/_ffmpeg_ops.py +699 -0
- torchcodec/_core/_file_like.py +221 -0
- torchcodec/_core/_metadata.py +402 -0
- torchcodec/_core/color_conversion.cpp +316 -0
- torchcodec/_core/color_conversion.cu +391 -0
- torchcodec/_core/color_conversion.h +150 -0
- torchcodec/_core/custom_ops.cpp +2438 -0
- torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +192 -0
- torchcodec/_core/fetch_avif_from_s3.cmake +81 -0
- torchcodec/_core/giflib/README +28 -0
- torchcodec/_core/giflib/dgif_lib.c +1313 -0
- torchcodec/_core/giflib/gif_hash.c +129 -0
- torchcodec/_core/giflib/gif_hash.h +43 -0
- torchcodec/_core/giflib/gif_lib.h +292 -0
- torchcodec/_core/giflib/gif_lib_private.h +73 -0
- torchcodec/_core/giflib/gifalloc.c +426 -0
- torchcodec/_core/giflib/openbsd-reallocarray.c +74 -0
- torchcodec/_core/heic_custom_ops.cpp +20 -0
- torchcodec/_core/image_custom_ops.cpp +137 -0
- torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
- torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
- torchcodec/_core/ops.py +103 -0
- torchcodec/_core/sources.bzl +113 -0
- torchcodec/_frame.py +146 -0
- torchcodec/_internally_replaced_utils.py +129 -0
- torchcodec/_logging.py +59 -0
- torchcodec/decoders/__init__.py +50 -0
- torchcodec/decoders/_audio_decoder.py +183 -0
- torchcodec/decoders/_blocks/__init__.py +48 -0
- torchcodec/decoders/_blocks/_audio_converter.py +155 -0
- torchcodec/decoders/_blocks/_codec_parameters.py +229 -0
- torchcodec/decoders/_blocks/_color_converter.py +107 -0
- torchcodec/decoders/_blocks/_demuxer.py +678 -0
- torchcodec/decoders/_blocks/_frame.py +577 -0
- torchcodec/decoders/_blocks/_helpers.py +53 -0
- torchcodec/decoders/_blocks/_packet_decoder.py +357 -0
- torchcodec/decoders/_decoder_utils.py +128 -0
- torchcodec/decoders/_image_decoders.py +1575 -0
- torchcodec/decoders/_video_decoder.py +592 -0
- torchcodec/decoders/_wav_decoder.py +131 -0
- torchcodec/encoders/__init__.py +4 -0
- torchcodec/encoders/_audio_encoder.py +167 -0
- torchcodec/encoders/_image_encoders.py +181 -0
- torchcodec/encoders/_multi_stream_encoder.py +272 -0
- torchcodec/encoders/_video_encoder.py +227 -0
- torchcodec/jpeg8.dll +0 -0
- torchcodec/libavif.dll +0 -0
- torchcodec/libpng16.dll +0 -0
- torchcodec/libsharpyuv.dll +0 -0
- 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_core9.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_custom_ops9.dll +0 -0
- torchcodec/libtorchcodec_heic.dll +0 -0
- torchcodec/libtorchcodec_image.dll +0 -0
- torchcodec/libwebp.dll +0 -0
- torchcodec/libwebpdecoder.dll +0 -0
- torchcodec/libwebpdemux.dll +0 -0
- torchcodec/libwebpmux.dll +0 -0
- torchcodec/libzstd.dll +0 -0
- torchcodec/py.typed +0 -0
- torchcodec/samplers/__init__.py +2 -0
- torchcodec/samplers/_common.py +83 -0
- torchcodec/samplers/_index_based.py +287 -0
- torchcodec/samplers/_time_based.py +360 -0
- torchcodec/share/cmake/TorchCodec/TorchCodecConfig.cmake +76 -0
- torchcodec/share/cmake/TorchCodec/ffmpeg_versions.cmake +128 -0
- torchcodec/transforms/__init__.py +12 -0
- torchcodec/transforms/_decoder_transforms.py +375 -0
- torchcodec/version.py +1 -0
- torchcodec/zlib.dll +0 -0
- torchcodec-1.0.0.dist-info/METADATA +275 -0
- torchcodec-1.0.0.dist-info/RECORD +179 -0
- torchcodec-1.0.0.dist-info/WHEEL +5 -0
- torchcodec-1.0.0.dist-info/licenses/LICENSE +28 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/COPYING.dav1d +23 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libavif +387 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libjpeg-turbo +135 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libpng +134 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libwebp +30 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libyuv +29 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.zlib +22 -0
|
@@ -0,0 +1,125 @@
|
|
|
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 <optional>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include "Frame.h"
|
|
12
|
+
#include "Metadata.h"
|
|
13
|
+
|
|
14
|
+
namespace facebook::torchcodec {
|
|
15
|
+
|
|
16
|
+
class Transform {
|
|
17
|
+
public:
|
|
18
|
+
virtual std::string get_filter_graph_cpu() const = 0;
|
|
19
|
+
virtual ~Transform() = default;
|
|
20
|
+
|
|
21
|
+
// If the transformation does not change the output frame dimensions, then
|
|
22
|
+
// there is no need to override this member function. The default
|
|
23
|
+
// implementation returns an empty optional, indicating that the output frame
|
|
24
|
+
// has the same dimensions as the input frame.
|
|
25
|
+
//
|
|
26
|
+
// If the transformation does change the output frame dimensions, then it
|
|
27
|
+
// must override this member function and return the output frame dimensions.
|
|
28
|
+
virtual std::optional<FrameDims> get_output_frame_dims() const {
|
|
29
|
+
return std::nullopt;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The ResizeTransform is special because it is the only transform
|
|
33
|
+
// that swscale can handle.
|
|
34
|
+
virtual bool is_resize() const {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The validity of some transforms depends on the characteristics of the
|
|
39
|
+
// AVStream they're being applied to. For example, some transforms will
|
|
40
|
+
// specify coordinates inside a frame, we need to validate that those are
|
|
41
|
+
// within the frame's bounds.
|
|
42
|
+
//
|
|
43
|
+
// Note that the validation function does not return anything. We expect
|
|
44
|
+
// invalid configurations to throw an exception.
|
|
45
|
+
virtual void validate([[maybe_unused]] const FrameDims& input_dims) const {}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
class ResizeTransform : public Transform {
|
|
49
|
+
public:
|
|
50
|
+
enum class InterpolationMode { BILINEAR };
|
|
51
|
+
|
|
52
|
+
explicit ResizeTransform(const FrameDims& dims)
|
|
53
|
+
: output_dims_(dims), interpolation_mode_(InterpolationMode::BILINEAR) {}
|
|
54
|
+
|
|
55
|
+
ResizeTransform(const FrameDims& dims, InterpolationMode interpolation_mode)
|
|
56
|
+
: output_dims_(dims), interpolation_mode_(interpolation_mode) {}
|
|
57
|
+
|
|
58
|
+
std::string get_filter_graph_cpu() const override;
|
|
59
|
+
std::optional<FrameDims> get_output_frame_dims() const override;
|
|
60
|
+
bool is_resize() const override;
|
|
61
|
+
|
|
62
|
+
int get_sws_flags() const;
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
FrameDims output_dims_;
|
|
66
|
+
InterpolationMode interpolation_mode_;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
class CropTransform : public Transform {
|
|
70
|
+
public:
|
|
71
|
+
CropTransform(const FrameDims& dims, int x, int y);
|
|
72
|
+
|
|
73
|
+
// Becomes a center crop if x and y are not specified.
|
|
74
|
+
explicit CropTransform(const FrameDims& dims);
|
|
75
|
+
|
|
76
|
+
std::string get_filter_graph_cpu() const override;
|
|
77
|
+
std::optional<FrameDims> get_output_frame_dims() const override;
|
|
78
|
+
void validate(const FrameDims& input_dims) const override;
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
FrameDims output_dims_;
|
|
82
|
+
std::optional<int> x_;
|
|
83
|
+
std::optional<int> y_;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Rotation values for RotationTransform.
|
|
87
|
+
// These correspond to video metadata rotation angles.
|
|
88
|
+
enum class Rotation {
|
|
89
|
+
NONE, // 0°
|
|
90
|
+
CCW90, // 90° counter-clockwise
|
|
91
|
+
CW90, // 90° clockwise (or -90°)
|
|
92
|
+
ROTATE180 // 180° (or -180°)
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Converts rotation degrees from video metadata to Rotation enum.
|
|
96
|
+
// Input is expected in the range [-180, 180].
|
|
97
|
+
// Rounds to nearest multiple of 90 degrees before converting.
|
|
98
|
+
// Returns Rotation::NONE for nullopt.
|
|
99
|
+
Rotation rotation_from_degrees(std::optional<double> degrees);
|
|
100
|
+
|
|
101
|
+
// Rotates an HWC tensor, returning a contiguous result (`hwc` unchanged for
|
|
102
|
+
// Rotation::NONE). For the paths that can't express rotation as a filter graph
|
|
103
|
+
// and have to apply it to the already-converted RGB frame.
|
|
104
|
+
FORCE_PUBLIC_VISIBILITY torch::stable::Tensor rotate_hwc_tensor(
|
|
105
|
+
const torch::stable::Tensor& hwc,
|
|
106
|
+
Rotation rotation);
|
|
107
|
+
|
|
108
|
+
// Applies rotation in multiples of 90 degrees using FFmpeg's transpose/flip
|
|
109
|
+
// filters. Note: this does not support arbitrary angle rotation
|
|
110
|
+
// like TorchVision's RandomRotation transform.
|
|
111
|
+
// Handles rotation in the filter graph so that user transforms
|
|
112
|
+
// operate in post-rotation coordinate space.
|
|
113
|
+
class RotationTransform : public Transform {
|
|
114
|
+
public:
|
|
115
|
+
RotationTransform(Rotation rotation, const FrameDims& input_dims);
|
|
116
|
+
|
|
117
|
+
std::string get_filter_graph_cpu() const override;
|
|
118
|
+
std::optional<FrameDims> get_output_frame_dims() const override;
|
|
119
|
+
|
|
120
|
+
private:
|
|
121
|
+
Rotation rotation_;
|
|
122
|
+
FrameDims output_dims_;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
} // namespace facebook::torchcodec
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
#include "ValidationUtils.h"
|
|
8
|
+
#include <limits>
|
|
9
|
+
#include "StableABICompat.h"
|
|
10
|
+
|
|
11
|
+
namespace facebook::torchcodec {
|
|
12
|
+
|
|
13
|
+
int validate_int64_to_int(int64_t value, const std::string& parameter_name) {
|
|
14
|
+
STD_TORCH_CHECK(
|
|
15
|
+
value >= std::numeric_limits<int>::min() &&
|
|
16
|
+
value <= std::numeric_limits<int>::max(),
|
|
17
|
+
parameter_name,
|
|
18
|
+
"=",
|
|
19
|
+
value,
|
|
20
|
+
" is out of range for int type.");
|
|
21
|
+
|
|
22
|
+
return static_cast<int>(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
uint32_t validate_int64_to_uint32(
|
|
26
|
+
int64_t value,
|
|
27
|
+
const std::string& parameter_name) {
|
|
28
|
+
STD_TORCH_CHECK(
|
|
29
|
+
value >= 0 && value <= std::numeric_limits<uint32_t>::max(),
|
|
30
|
+
parameter_name,
|
|
31
|
+
"=",
|
|
32
|
+
value,
|
|
33
|
+
" is out of range for uint32 type.");
|
|
34
|
+
|
|
35
|
+
return static_cast<uint32_t>(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
std::optional<int> validate_optional_int64_to_int(
|
|
39
|
+
const std::optional<int64_t>& value,
|
|
40
|
+
const std::string& parameter_name) {
|
|
41
|
+
if (value.has_value()) {
|
|
42
|
+
return validate_int64_to_int(value.value(), parameter_name);
|
|
43
|
+
} else {
|
|
44
|
+
return std::nullopt;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
std::streampos validate_uint64_to_streampos(
|
|
49
|
+
uint64_t value,
|
|
50
|
+
const std::string& parameter_name) {
|
|
51
|
+
// We validate against streamoff limits because streampos
|
|
52
|
+
// (std::fpos<state_type>) stores the actual position as streamoff internally.
|
|
53
|
+
// https://en.cppreference.com/w/cpp/io/fpos.html
|
|
54
|
+
STD_TORCH_CHECK(
|
|
55
|
+
value <=
|
|
56
|
+
static_cast<uint64_t>(std::numeric_limits<std::streamoff>::max()),
|
|
57
|
+
parameter_name,
|
|
58
|
+
"=",
|
|
59
|
+
value,
|
|
60
|
+
" is out of range for streampos type.");
|
|
61
|
+
|
|
62
|
+
return static_cast<std::streampos>(value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} // namespace facebook::torchcodec
|
|
@@ -0,0 +1,29 @@
|
|
|
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 <cstdint>
|
|
10
|
+
#include <optional>
|
|
11
|
+
#include <string>
|
|
12
|
+
|
|
13
|
+
namespace facebook::torchcodec {
|
|
14
|
+
|
|
15
|
+
int validate_int64_to_int(int64_t value, const std::string& parameter_name);
|
|
16
|
+
|
|
17
|
+
uint32_t validate_int64_to_uint32(
|
|
18
|
+
int64_t value,
|
|
19
|
+
const std::string& parameter_name);
|
|
20
|
+
|
|
21
|
+
std::optional<int> validate_optional_int64_to_int(
|
|
22
|
+
const std::optional<int64_t>& value,
|
|
23
|
+
const std::string& parameter_name);
|
|
24
|
+
|
|
25
|
+
std::streampos validate_uint64_to_streampos(
|
|
26
|
+
uint64_t value,
|
|
27
|
+
const std::string& parameter_name);
|
|
28
|
+
|
|
29
|
+
} // namespace facebook::torchcodec
|