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,494 @@
|
|
|
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 "WavDecoder.h"
|
|
8
|
+
|
|
9
|
+
#include <cstddef>
|
|
10
|
+
#include <cstring>
|
|
11
|
+
#include <vector>
|
|
12
|
+
#include "ValidationUtils.h"
|
|
13
|
+
|
|
14
|
+
namespace facebook::torchcodec {
|
|
15
|
+
namespace {
|
|
16
|
+
|
|
17
|
+
constexpr int64_t RIFF_HEADER_SIZE = 12; // "RIFF" + fileSize + "WAVE"
|
|
18
|
+
constexpr int64_t CHUNK_HEADER_SIZE = 8; // chunkID + chunkSize
|
|
19
|
+
// Standard WAV fmt chunk is at least 16 bytes:
|
|
20
|
+
// audioFormat(2) + numChannels(2) + sampleRate(4) + byteRate(4) + blockAlign(2)
|
|
21
|
+
// + bitsPerSample(2)
|
|
22
|
+
constexpr int64_t MIN_FMT_CHUNK_SIZE = 16;
|
|
23
|
+
// WAVE_FORMAT_EXTENSIBLE adds to the standard WAV fmt chunk: cbSize(2) +
|
|
24
|
+
// wValidBitsPerSample(2) + dwChannelMask(4) + SubFormat GUID(16) = 24 more
|
|
25
|
+
// bytes, total 40
|
|
26
|
+
constexpr int64_t MIN_WAVEX_FMT_CHUNK_SIZE = 40;
|
|
27
|
+
// Arbitrary max for fmt chunk allocation - set to 5x extended format size
|
|
28
|
+
constexpr int64_t MAX_FMT_CHUNK_SIZE = 200;
|
|
29
|
+
// Soundfile's default buffer size. See
|
|
30
|
+
// https://github.com/libsndfile/libsndfile/blob/master/src/common.h#L77
|
|
31
|
+
constexpr size_t TMP_BUFFER_SIZE = 8192;
|
|
32
|
+
|
|
33
|
+
// See standard format codes and Wav file format used in WavHeader:
|
|
34
|
+
// https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
|
|
35
|
+
constexpr uint16_t WAV_FORMAT_PCM = 1;
|
|
36
|
+
constexpr uint16_t WAV_FORMAT_IEEE_FLOAT = 3;
|
|
37
|
+
constexpr uint16_t WAV_FORMAT_EXTENSIBLE = 0xFFFE;
|
|
38
|
+
|
|
39
|
+
template <typename OutType, typename InType>
|
|
40
|
+
OutType read_value(const InType& data, int64_t offset) {
|
|
41
|
+
static_assert(std::is_trivially_copyable_v<OutType>);
|
|
42
|
+
static_assert(
|
|
43
|
+
sizeof(typename InType::value_type) == 1,
|
|
44
|
+
"InType value_type must be a 1-byte type for safe byte access");
|
|
45
|
+
OutType value;
|
|
46
|
+
std::memcpy(
|
|
47
|
+
&value, data.data() + static_cast<size_t>(offset), sizeof(OutType));
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
template <typename OutType, typename InType>
|
|
52
|
+
OutType safe_read_value(const InType& data, int64_t offset) {
|
|
53
|
+
STD_TORCH_CHECK(offset >= 0);
|
|
54
|
+
STD_TORCH_CHECK(
|
|
55
|
+
data.size() >= sizeof(OutType) &&
|
|
56
|
+
static_cast<size_t>(offset) <= data.size() - sizeof(OutType),
|
|
57
|
+
"Reading ",
|
|
58
|
+
sizeof(OutType),
|
|
59
|
+
" bytes at offset ",
|
|
60
|
+
offset,
|
|
61
|
+
": exceeds buffer length ",
|
|
62
|
+
data.size());
|
|
63
|
+
return read_value<OutType>(data, offset);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
bool matches_four_cc(
|
|
67
|
+
const uint8_t* data,
|
|
68
|
+
int64_t data_size,
|
|
69
|
+
int64_t offset,
|
|
70
|
+
std::string_view expected) {
|
|
71
|
+
STD_TORCH_CHECK(
|
|
72
|
+
data_size >= 4 && offset <= data_size - 4,
|
|
73
|
+
"Data array too small for FourCC comparison at offset ",
|
|
74
|
+
offset);
|
|
75
|
+
STD_TORCH_CHECK(offset >= 0);
|
|
76
|
+
return std::memcmp(data + static_cast<size_t>(offset), expected.data(), 4) ==
|
|
77
|
+
0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void safe_read(IOInterface& avio, uint8_t* buf, int64_t bytes_to_read) {
|
|
81
|
+
STD_TORCH_CHECK(bytes_to_read >= 0);
|
|
82
|
+
int64_t total_read = 0;
|
|
83
|
+
while (total_read < bytes_to_read) {
|
|
84
|
+
int bytes_read = avio.read(
|
|
85
|
+
buf + total_read,
|
|
86
|
+
static_cast<int>(std::min(
|
|
87
|
+
bytes_to_read - total_read, static_cast<int64_t>(INT_MAX))));
|
|
88
|
+
STD_TORCH_CHECK(
|
|
89
|
+
bytes_read > 0,
|
|
90
|
+
"WAV: unexpected end of data (expected ",
|
|
91
|
+
bytes_to_read,
|
|
92
|
+
" bytes, got ",
|
|
93
|
+
total_read,
|
|
94
|
+
")");
|
|
95
|
+
total_read += bytes_read;
|
|
96
|
+
}
|
|
97
|
+
STD_TORCH_CHECK(
|
|
98
|
+
total_read == bytes_to_read,
|
|
99
|
+
"Read more bytes than requested: got ",
|
|
100
|
+
total_read,
|
|
101
|
+
", expected ",
|
|
102
|
+
bytes_to_read);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
template <typename Container>
|
|
106
|
+
void safe_read(IOInterface& avio, Container& buffer, int64_t bytes_to_read) {
|
|
107
|
+
static_assert(
|
|
108
|
+
sizeof(typename Container::value_type) == 1,
|
|
109
|
+
"Container value_type must be a 1-byte type");
|
|
110
|
+
STD_TORCH_CHECK(
|
|
111
|
+
static_cast<size_t>(bytes_to_read) <= buffer.size(),
|
|
112
|
+
"Read size exceeds buffer length");
|
|
113
|
+
safe_read(avio, reinterpret_cast<uint8_t*>(buffer.data()), bytes_to_read);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void safe_seek(IOInterface& avio, int64_t pos) {
|
|
117
|
+
int64_t result = avio.seek(pos, SEEK_SET);
|
|
118
|
+
STD_TORCH_CHECK(result >= 0, "Failed to seek to ", pos, " in WAV file");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
} // namespace
|
|
122
|
+
|
|
123
|
+
WavDecoder::WavDecoder(std::unique_ptr<IOInterface> io) : io_(std::move(io)) {
|
|
124
|
+
STD_TORCH_CHECK(
|
|
125
|
+
std::endian::native == std::endian::little,
|
|
126
|
+
"WAV decoder requires little-endian architecture");
|
|
127
|
+
STD_TORCH_CHECK(io_ != nullptr, "AVIO context cannot be null");
|
|
128
|
+
source_size_ = static_cast<uint64_t>(io_->get_size());
|
|
129
|
+
parse_header();
|
|
130
|
+
validate_header();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void WavDecoder::parse_header() {
|
|
134
|
+
safe_seek(*io_, 0);
|
|
135
|
+
|
|
136
|
+
std::array<uint8_t, RIFF_HEADER_SIZE> riff_header;
|
|
137
|
+
safe_read(*io_, riff_header, RIFF_HEADER_SIZE);
|
|
138
|
+
|
|
139
|
+
STD_TORCH_CHECK(
|
|
140
|
+
matches_four_cc(riff_header.data(), RIFF_HEADER_SIZE, 0, "RIFF"),
|
|
141
|
+
"Missing RIFF header");
|
|
142
|
+
STD_TORCH_CHECK(
|
|
143
|
+
matches_four_cc(riff_header.data(), RIFF_HEADER_SIZE, 8, "WAVE"),
|
|
144
|
+
"Missing WAVE format identifier");
|
|
145
|
+
|
|
146
|
+
ChunkInfo fmt_chunk =
|
|
147
|
+
find_chunk("fmt ", static_cast<uint64_t>(RIFF_HEADER_SIZE));
|
|
148
|
+
STD_TORCH_CHECK(
|
|
149
|
+
fmt_chunk.size >= MIN_FMT_CHUNK_SIZE,
|
|
150
|
+
"Invalid fmt chunk: size must be at least ",
|
|
151
|
+
MIN_FMT_CHUNK_SIZE,
|
|
152
|
+
" bytes");
|
|
153
|
+
|
|
154
|
+
// Use ChunkInfo to seek to and read the fmt chunk data
|
|
155
|
+
safe_seek(*io_, static_cast<int64_t>(fmt_chunk.offset));
|
|
156
|
+
STD_TORCH_CHECK(
|
|
157
|
+
fmt_chunk.size <= MAX_FMT_CHUNK_SIZE,
|
|
158
|
+
"fmt chunk too large for allocation: ",
|
|
159
|
+
fmt_chunk.size,
|
|
160
|
+
" bytes, maximum allowed is ",
|
|
161
|
+
MAX_FMT_CHUNK_SIZE,
|
|
162
|
+
" bytes");
|
|
163
|
+
std::vector<uint8_t> fmt_data(static_cast<size_t>(fmt_chunk.size));
|
|
164
|
+
safe_read(*io_, fmt_data, fmt_chunk.size);
|
|
165
|
+
|
|
166
|
+
header_.audio_format = safe_read_value<uint16_t>(fmt_data, 0);
|
|
167
|
+
header_.num_channels = safe_read_value<uint16_t>(fmt_data, 2);
|
|
168
|
+
header_.sample_rate = safe_read_value<uint32_t>(fmt_data, 4);
|
|
169
|
+
header_.num_bytes_per_sample = safe_read_value<uint16_t>(fmt_data, 12);
|
|
170
|
+
header_.bits_per_sample = safe_read_value<uint16_t>(fmt_data, 14);
|
|
171
|
+
|
|
172
|
+
if (header_.audio_format == WAV_FORMAT_EXTENSIBLE) {
|
|
173
|
+
STD_TORCH_CHECK(
|
|
174
|
+
fmt_chunk.size >= MIN_WAVEX_FMT_CHUNK_SIZE,
|
|
175
|
+
"WAVE_FORMAT_EXTENSIBLE fmt chunk too small");
|
|
176
|
+
// The actual format is in the first 2 bytes of the SubFormat GUID.
|
|
177
|
+
header_.audio_format = safe_read_value<uint16_t>(fmt_data, 24);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
ChunkInfo data_chunk =
|
|
181
|
+
find_chunk("data", static_cast<uint64_t>(RIFF_HEADER_SIZE));
|
|
182
|
+
header_.data_offset = data_chunk.offset;
|
|
183
|
+
header_.data_size = data_chunk.size;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void WavDecoder::validate_header() {
|
|
187
|
+
STD_TORCH_CHECK(
|
|
188
|
+
header_.audio_format == WAV_FORMAT_PCM ||
|
|
189
|
+
header_.audio_format == WAV_FORMAT_IEEE_FLOAT,
|
|
190
|
+
"Unsupported WAV format: ",
|
|
191
|
+
header_.audio_format,
|
|
192
|
+
". Only PCM and IEEE float formats are supported.");
|
|
193
|
+
|
|
194
|
+
if (header_.audio_format == WAV_FORMAT_PCM) {
|
|
195
|
+
STD_TORCH_CHECK(
|
|
196
|
+
header_.bits_per_sample == 8 || header_.bits_per_sample == 16 ||
|
|
197
|
+
header_.bits_per_sample == 24 || header_.bits_per_sample == 32,
|
|
198
|
+
"Unsupported PCM bit depth: ",
|
|
199
|
+
header_.bits_per_sample,
|
|
200
|
+
". Currently supported bit depths are: 8, 16, 24, 32");
|
|
201
|
+
} else {
|
|
202
|
+
STD_TORCH_CHECK(
|
|
203
|
+
header_.bits_per_sample == 32 || header_.bits_per_sample == 64,
|
|
204
|
+
"Unsupported IEEE float bit depth: ",
|
|
205
|
+
header_.bits_per_sample,
|
|
206
|
+
". Currently supported bit depths are: 32, 64");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
STD_TORCH_CHECK(header_.num_channels > 0, "Invalid WAV: zero channels");
|
|
210
|
+
STD_TORCH_CHECK(header_.sample_rate > 0, "Invalid WAV: zero sample rate");
|
|
211
|
+
STD_TORCH_CHECK(
|
|
212
|
+
header_.num_bytes_per_sample > 0, "Invalid WAV: zero block alignment");
|
|
213
|
+
// The WAV spec requires numBytesPerSample == numChannels * bitsPerSample / 8.
|
|
214
|
+
// https://en.wikipedia.org/wiki/WAV#WAV_file_header
|
|
215
|
+
// Our output tensor has (dataSize / numBytesPerSample) * numChannels
|
|
216
|
+
// elements. By validating numBytesPerSample is consistent with numChannels,
|
|
217
|
+
// total tensor size is bounded by the file:
|
|
218
|
+
// dataSize / (numChannels * bitsPerSample/8) * numChannels
|
|
219
|
+
// = dataSize / (bitsPerSample/8)
|
|
220
|
+
// Without this check, a corrupt numChannels could multiply tensor size
|
|
221
|
+
// independently of dataSize.
|
|
222
|
+
STD_TORCH_CHECK(
|
|
223
|
+
header_.num_bytes_per_sample ==
|
|
224
|
+
header_.num_channels * (header_.bits_per_sample / 8),
|
|
225
|
+
"Invalid WAV: block alignment (",
|
|
226
|
+
header_.num_bytes_per_sample,
|
|
227
|
+
") does not match numChannels * bitsPerSample/8 (",
|
|
228
|
+
header_.num_channels * (header_.bits_per_sample / 8),
|
|
229
|
+
")");
|
|
230
|
+
|
|
231
|
+
if (header_.audio_format == WAV_FORMAT_PCM && header_.bits_per_sample == 32) {
|
|
232
|
+
sample_format_ = "s32";
|
|
233
|
+
codec_name_ = "pcm_s32le";
|
|
234
|
+
} else if (
|
|
235
|
+
header_.audio_format == WAV_FORMAT_PCM && header_.bits_per_sample == 24) {
|
|
236
|
+
// FFmpeg decodes s24 into s32 samples (no native 24-bit type).
|
|
237
|
+
sample_format_ = "s32";
|
|
238
|
+
codec_name_ = "pcm_s24le";
|
|
239
|
+
} else if (
|
|
240
|
+
header_.audio_format == WAV_FORMAT_PCM && header_.bits_per_sample == 16) {
|
|
241
|
+
sample_format_ = "s16";
|
|
242
|
+
codec_name_ = "pcm_s16le";
|
|
243
|
+
} else if (
|
|
244
|
+
header_.audio_format == WAV_FORMAT_PCM && header_.bits_per_sample == 8) {
|
|
245
|
+
sample_format_ = "u8";
|
|
246
|
+
codec_name_ = "pcm_u8";
|
|
247
|
+
} else if (
|
|
248
|
+
header_.audio_format == WAV_FORMAT_IEEE_FLOAT &&
|
|
249
|
+
header_.bits_per_sample == 32) {
|
|
250
|
+
sample_format_ = "flt";
|
|
251
|
+
codec_name_ = "pcm_f32le";
|
|
252
|
+
} else if (
|
|
253
|
+
header_.audio_format == WAV_FORMAT_IEEE_FLOAT &&
|
|
254
|
+
header_.bits_per_sample == 64) {
|
|
255
|
+
sample_format_ = "dbl";
|
|
256
|
+
codec_name_ = "pcm_f64le";
|
|
257
|
+
} else {
|
|
258
|
+
STD_TORCH_CHECK(
|
|
259
|
+
false,
|
|
260
|
+
"Unsupported format after validation. "
|
|
261
|
+
"This is a bug in TorchCodec, please report it.");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Given a chunkId, read through each chunk until we find a match, then return
|
|
266
|
+
// its offset and size.
|
|
267
|
+
WavDecoder::ChunkInfo WavDecoder::find_chunk(
|
|
268
|
+
std::string_view chunk_id,
|
|
269
|
+
uint64_t start_pos) {
|
|
270
|
+
STD_TORCH_CHECK(
|
|
271
|
+
source_size_ >= static_cast<uint64_t>(CHUNK_HEADER_SIZE),
|
|
272
|
+
"File too small to contain chunk:",
|
|
273
|
+
chunk_id);
|
|
274
|
+
while (start_pos <= source_size_ - CHUNK_HEADER_SIZE) {
|
|
275
|
+
safe_seek(*io_, static_cast<int64_t>(start_pos));
|
|
276
|
+
|
|
277
|
+
std::array<uint8_t, CHUNK_HEADER_SIZE> chunk_header;
|
|
278
|
+
safe_read(*io_, chunk_header, CHUNK_HEADER_SIZE);
|
|
279
|
+
// Read chunk size which immediately follows the chunk ID
|
|
280
|
+
uint32_t chunk_size = safe_read_value<uint32_t>(chunk_header, 4);
|
|
281
|
+
|
|
282
|
+
if (matches_four_cc(chunk_header.data(), CHUNK_HEADER_SIZE, 0, chunk_id)) {
|
|
283
|
+
return {start_pos + CHUNK_HEADER_SIZE, chunk_size};
|
|
284
|
+
}
|
|
285
|
+
// Skip this chunk and continue searching (odd chunks are padded)
|
|
286
|
+
uint64_t num_bytes_to_skip = CHUNK_HEADER_SIZE +
|
|
287
|
+
static_cast<uint64_t>(chunk_size) + (chunk_size % 2);
|
|
288
|
+
STD_TORCH_CHECK(
|
|
289
|
+
start_pos <= UINT64_MAX - num_bytes_to_skip,
|
|
290
|
+
"File position arithmetic would overflow");
|
|
291
|
+
start_pos += num_bytes_to_skip;
|
|
292
|
+
}
|
|
293
|
+
// If this code is reached, the required chunk was not found, so we error
|
|
294
|
+
STD_TORCH_CHECK(false, "Chunk not found: ", chunk_id);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Callers must ensure outputPtr has space for at least
|
|
298
|
+
// samplesInBuffer * numChannels floats.
|
|
299
|
+
void WavDecoder::convert_samples_to_float(
|
|
300
|
+
const std::vector<uint8_t>& buffer_data,
|
|
301
|
+
int64_t samples_in_buffer,
|
|
302
|
+
float* output_ptr) const {
|
|
303
|
+
int64_t total_samples = samples_in_buffer * header_.num_channels;
|
|
304
|
+
|
|
305
|
+
// Normalize PCM samples to [-1.0, 1.0] range. The convention across
|
|
306
|
+
// implementations is to divide by 2^(N - 1) where N is the bitdepth.
|
|
307
|
+
// We use readValue because the buffer size is already validated earlier.
|
|
308
|
+
// Float32 is handled directly in getSamplesInRange (no conversion
|
|
309
|
+
// needed), so it doesn't appear here.
|
|
310
|
+
if (header_.bits_per_sample == 64) {
|
|
311
|
+
for (int64_t i = 0; i < total_samples; ++i) {
|
|
312
|
+
double sample = read_value<double>(
|
|
313
|
+
buffer_data, i * static_cast<int64_t>(sizeof(double)));
|
|
314
|
+
output_ptr[i] = static_cast<float>(sample);
|
|
315
|
+
}
|
|
316
|
+
} else if (header_.bits_per_sample == 32) {
|
|
317
|
+
constexpr float scale = 1.0f / static_cast<float>(1U << 31);
|
|
318
|
+
for (int64_t i = 0; i < total_samples; ++i) {
|
|
319
|
+
int32_t sample = read_value<int32_t>(
|
|
320
|
+
buffer_data, i * static_cast<int64_t>(sizeof(int32_t)));
|
|
321
|
+
output_ptr[i] = static_cast<float>(sample) * scale;
|
|
322
|
+
}
|
|
323
|
+
} else if (header_.bits_per_sample == 24) {
|
|
324
|
+
// 24-bit samples are 3 bytes each. We shift into the *upper* 24
|
|
325
|
+
// bits of an int32 so that sign extension happens naturally, then
|
|
326
|
+
// reuse the same 1/(2^31) scale as 32-bit.
|
|
327
|
+
constexpr float scale = 1.0f / static_cast<float>(1U << 31);
|
|
328
|
+
for (int64_t i = 0; i < total_samples; ++i) {
|
|
329
|
+
int64_t offset = i * 3;
|
|
330
|
+
auto b0 = static_cast<uint32_t>(buffer_data[offset]);
|
|
331
|
+
auto b1 = static_cast<uint32_t>(buffer_data[offset + 1]);
|
|
332
|
+
auto b2 = static_cast<uint32_t>(buffer_data[offset + 2]);
|
|
333
|
+
auto sample = static_cast<int32_t>((b0 << 8) | (b1 << 16) | (b2 << 24));
|
|
334
|
+
output_ptr[i] = static_cast<float>(sample) * scale;
|
|
335
|
+
}
|
|
336
|
+
} else if (header_.bits_per_sample == 16) {
|
|
337
|
+
constexpr float scale = 1.0f / static_cast<float>(1U << 15);
|
|
338
|
+
for (int64_t i = 0; i < total_samples; ++i) {
|
|
339
|
+
int16_t sample = read_value<int16_t>(
|
|
340
|
+
buffer_data, i * static_cast<int64_t>(sizeof(int16_t)));
|
|
341
|
+
output_ptr[i] = static_cast<float>(sample) * scale;
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
STD_TORCH_CHECK(
|
|
345
|
+
header_.bits_per_sample == 8,
|
|
346
|
+
"Unsupported bit depth in convertSamplesToFloat: ",
|
|
347
|
+
header_.bits_per_sample,
|
|
348
|
+
". This is a bug in TorchCodec, please report it.");
|
|
349
|
+
// 8-bit WAV is *unsigned*, so we first have to center the data (- 128)
|
|
350
|
+
// before scaling it.
|
|
351
|
+
constexpr float scale = 1.0f / static_cast<float>(1U << 7);
|
|
352
|
+
for (int64_t i = 0; i < total_samples; ++i) {
|
|
353
|
+
uint8_t sample = read_value<uint8_t>(buffer_data, i);
|
|
354
|
+
output_ptr[i] = (static_cast<float>(sample) - 128.0f) * scale;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
AudioFramesOutput WavDecoder::get_samples_in_range(
|
|
360
|
+
double start_seconds,
|
|
361
|
+
std::optional<double> stop_seconds_optional) {
|
|
362
|
+
// Calculate the range of samples to decode.
|
|
363
|
+
// Negative startSeconds is resolved to 0 in the Python layer.
|
|
364
|
+
STD_TORCH_CHECK(
|
|
365
|
+
start_seconds <= INT64_MAX / header_.sample_rate,
|
|
366
|
+
"startSample calculation would overflow: startSeconds * sampleRate");
|
|
367
|
+
// Sample boundary alignment: round to nearest sample to avoid partial samples
|
|
368
|
+
// See corresponding logic in AudioDecoder:
|
|
369
|
+
// https://github.com/meta-pytorch/torchcodec/blob/910005cf5328d9d44ff8123ad540a51db9ce15b5/src/torchcodec/decoders/_audio_decoder.py#L142
|
|
370
|
+
const int64_t start_sample =
|
|
371
|
+
static_cast<int64_t>(std::round(start_seconds * header_.sample_rate));
|
|
372
|
+
|
|
373
|
+
// Cap dataSize to file size to reduce risk of large tensor allocation on
|
|
374
|
+
// corrupt files with incorrect dataSize.
|
|
375
|
+
int64_t end_sample = static_cast<int64_t>(
|
|
376
|
+
std::min(static_cast<uint64_t>(header_.data_size), source_size_) /
|
|
377
|
+
header_.num_bytes_per_sample);
|
|
378
|
+
if (stop_seconds_optional.has_value()) {
|
|
379
|
+
STD_TORCH_CHECK(
|
|
380
|
+
start_seconds <= stop_seconds_optional.value(),
|
|
381
|
+
"Start seconds (",
|
|
382
|
+
start_seconds,
|
|
383
|
+
") must be less than or equal to stop seconds (",
|
|
384
|
+
stop_seconds_optional.value(),
|
|
385
|
+
").");
|
|
386
|
+
if (start_seconds == stop_seconds_optional.value()) {
|
|
387
|
+
return AudioFramesOutput{
|
|
388
|
+
torch::stable::empty({header_.num_channels, 0}, kStableFloat32),
|
|
389
|
+
start_seconds};
|
|
390
|
+
}
|
|
391
|
+
STD_TORCH_CHECK(
|
|
392
|
+
stop_seconds_optional.value() <= INT64_MAX / header_.sample_rate,
|
|
393
|
+
"End sample calculation would overflow: stopSeconds * sampleRate");
|
|
394
|
+
int64_t requested_end_sample = static_cast<int64_t>(
|
|
395
|
+
std::round(stop_seconds_optional.value() * header_.sample_rate));
|
|
396
|
+
end_sample = std::min(requested_end_sample, end_sample);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const int64_t num_samples = end_sample - start_sample;
|
|
400
|
+
STD_TORCH_CHECK(
|
|
401
|
+
num_samples > 0,
|
|
402
|
+
"No samples to decode. ",
|
|
403
|
+
"This is probably because start_seconds is too high(",
|
|
404
|
+
start_seconds,
|
|
405
|
+
"), ",
|
|
406
|
+
"or because stop_seconds is too low.");
|
|
407
|
+
|
|
408
|
+
STD_TORCH_CHECK(
|
|
409
|
+
start_sample <= INT64_MAX / header_.num_bytes_per_sample,
|
|
410
|
+
"byteOffset calculation would overflow: startSample * numBytesPerSample ");
|
|
411
|
+
int64_t byte_offset = start_sample * header_.num_bytes_per_sample;
|
|
412
|
+
|
|
413
|
+
STD_TORCH_CHECK(
|
|
414
|
+
header_.data_offset <= static_cast<uint64_t>(INT64_MAX - byte_offset),
|
|
415
|
+
"dataPosition calculation would overflow: dataOffset + byteOffset ");
|
|
416
|
+
byte_offset += static_cast<int64_t>(header_.data_offset);
|
|
417
|
+
|
|
418
|
+
safe_seek(*io_, byte_offset);
|
|
419
|
+
|
|
420
|
+
auto samples =
|
|
421
|
+
torch::stable::empty({num_samples, header_.num_channels}, kStableFloat32);
|
|
422
|
+
|
|
423
|
+
if (header_.audio_format == WAV_FORMAT_IEEE_FLOAT &&
|
|
424
|
+
header_.bits_per_sample == 32) {
|
|
425
|
+
// Float32 samples can be read directly into the output tensor.
|
|
426
|
+
int64_t total_bytes = num_samples * header_.num_bytes_per_sample;
|
|
427
|
+
safe_read(
|
|
428
|
+
*io_,
|
|
429
|
+
reinterpret_cast<uint8_t*>(samples.mutable_data_ptr<float>()),
|
|
430
|
+
total_bytes);
|
|
431
|
+
} else {
|
|
432
|
+
// We need to align buffer size to actual boundaries of samples to
|
|
433
|
+
// avoid reading partial samples. See
|
|
434
|
+
// https://github.com/FFmpeg/FFmpeg/blob/0f600cbc16b7903703b47d23981b636c94a41c71/libavformat/wavdec.c#L786-L791
|
|
435
|
+
size_t aligned_buffer_size = TMP_BUFFER_SIZE;
|
|
436
|
+
aligned_buffer_size = (aligned_buffer_size / header_.num_bytes_per_sample) *
|
|
437
|
+
header_.num_bytes_per_sample;
|
|
438
|
+
STD_TORCH_CHECK(
|
|
439
|
+
aligned_buffer_size > 0,
|
|
440
|
+
"WAV bytes per sample (",
|
|
441
|
+
header_.num_bytes_per_sample,
|
|
442
|
+
") exceeds buffer size (",
|
|
443
|
+
TMP_BUFFER_SIZE,
|
|
444
|
+
")");
|
|
445
|
+
|
|
446
|
+
std::vector<uint8_t> buffer(aligned_buffer_size);
|
|
447
|
+
int64_t samples_processed = 0;
|
|
448
|
+
const int64_t samples_per_buffer =
|
|
449
|
+
static_cast<int64_t>(aligned_buffer_size) /
|
|
450
|
+
header_.num_bytes_per_sample;
|
|
451
|
+
|
|
452
|
+
while (samples_processed < num_samples) {
|
|
453
|
+
const int64_t samples_this_iteration =
|
|
454
|
+
std::min(num_samples - samples_processed, samples_per_buffer);
|
|
455
|
+
safe_read(
|
|
456
|
+
*io_, buffer, samples_this_iteration * header_.num_bytes_per_sample);
|
|
457
|
+
|
|
458
|
+
float* output_ptr = samples.mutable_data_ptr<float>() +
|
|
459
|
+
(samples_processed * header_.num_channels);
|
|
460
|
+
convert_samples_to_float(buffer, samples_this_iteration, output_ptr);
|
|
461
|
+
samples_processed += samples_this_iteration;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Convert to [channels, samples]
|
|
466
|
+
samples = torch::stable::transpose(samples, 0, 1);
|
|
467
|
+
|
|
468
|
+
// We return the actual sample start time
|
|
469
|
+
// (rounded to nearest sample boundary to startSeconds).
|
|
470
|
+
const double actual_start_seconds =
|
|
471
|
+
static_cast<double>(start_sample) / header_.sample_rate;
|
|
472
|
+
return AudioFramesOutput{samples, actual_start_seconds};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
StreamMetadata WavDecoder::get_stream_metadata() const {
|
|
476
|
+
StreamMetadata metadata;
|
|
477
|
+
metadata.stream_index = 0; // WAV files have single audio stream
|
|
478
|
+
metadata.sample_rate = static_cast<int64_t>(header_.sample_rate);
|
|
479
|
+
metadata.num_channels = static_cast<int64_t>(header_.num_channels);
|
|
480
|
+
metadata.sample_format = sample_format_;
|
|
481
|
+
metadata.codec_name = codec_name_;
|
|
482
|
+
|
|
483
|
+
// Calculate duration from data size
|
|
484
|
+
double bit_rate = static_cast<double>(header_.sample_rate) *
|
|
485
|
+
static_cast<double>(header_.num_channels) *
|
|
486
|
+
static_cast<double>(header_.bits_per_sample);
|
|
487
|
+
metadata.bit_rate = bit_rate;
|
|
488
|
+
metadata.duration_seconds_from_header =
|
|
489
|
+
static_cast<double>(header_.data_size) * 8 / bit_rate;
|
|
490
|
+
metadata.begin_stream_pts_seconds_from_content = 0.0;
|
|
491
|
+
|
|
492
|
+
return metadata;
|
|
493
|
+
}
|
|
494
|
+
} // namespace facebook::torchcodec
|
|
@@ -0,0 +1,73 @@
|
|
|
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 <memory>
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <string_view>
|
|
13
|
+
#include <vector>
|
|
14
|
+
#include "Frame.h"
|
|
15
|
+
#include "IOInterface.h"
|
|
16
|
+
#include "Metadata.h"
|
|
17
|
+
#include "StableABICompat.h"
|
|
18
|
+
|
|
19
|
+
namespace facebook::torchcodec {
|
|
20
|
+
|
|
21
|
+
class FORCE_PUBLIC_VISIBILITY WavDecoder {
|
|
22
|
+
public:
|
|
23
|
+
explicit WavDecoder(std::unique_ptr<IOInterface> io);
|
|
24
|
+
// Delete copy constructor and copy assignment operator since
|
|
25
|
+
// unique_ptr is not copyable.
|
|
26
|
+
WavDecoder(const WavDecoder&) = delete;
|
|
27
|
+
WavDecoder& operator=(const WavDecoder&) = delete;
|
|
28
|
+
WavDecoder(WavDecoder&&) noexcept = default;
|
|
29
|
+
WavDecoder& operator=(WavDecoder&&) noexcept = default;
|
|
30
|
+
~WavDecoder() = default;
|
|
31
|
+
|
|
32
|
+
AudioFramesOutput get_samples_in_range(
|
|
33
|
+
double start_seconds,
|
|
34
|
+
std::optional<double> stop_seconds_optional = std::nullopt);
|
|
35
|
+
|
|
36
|
+
StreamMetadata get_stream_metadata() const;
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
struct WavHeader {
|
|
40
|
+
// For WAVE_FORMAT_EXTENSIBLE files, this is the format from SubFormat.
|
|
41
|
+
uint16_t audio_format = 0;
|
|
42
|
+
uint16_t num_channels = 0;
|
|
43
|
+
uint32_t sample_rate = 0;
|
|
44
|
+
uint16_t num_bytes_per_sample =
|
|
45
|
+
0; // Bytes per sample across all channels (renamed from blockAlign)
|
|
46
|
+
uint16_t bits_per_sample = 0;
|
|
47
|
+
uint64_t data_offset = 0;
|
|
48
|
+
uint32_t data_size = 0; // Size of audio data in bytes
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
struct ChunkInfo {
|
|
52
|
+
uint64_t offset;
|
|
53
|
+
uint32_t size;
|
|
54
|
+
|
|
55
|
+
ChunkInfo(uint64_t offset, uint32_t size) : offset(offset), size(size) {}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
ChunkInfo find_chunk(std::string_view chunk_id, uint64_t start_pos);
|
|
59
|
+
void parse_header();
|
|
60
|
+
void validate_header();
|
|
61
|
+
void convert_samples_to_float(
|
|
62
|
+
const std::vector<uint8_t>& buffer_data,
|
|
63
|
+
int64_t samples_in_buffer,
|
|
64
|
+
float* output_ptr) const;
|
|
65
|
+
|
|
66
|
+
std::unique_ptr<IOInterface> io_;
|
|
67
|
+
WavHeader header_;
|
|
68
|
+
uint64_t source_size_ = 0;
|
|
69
|
+
std::string sample_format_;
|
|
70
|
+
std::string codec_name_;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace facebook::torchcodec
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
|
|
8
|
+
from ._metadata import (
|
|
9
|
+
AudioStreamMetadata,
|
|
10
|
+
ContainerMetadata,
|
|
11
|
+
get_container_metadata,
|
|
12
|
+
get_container_metadata_from_header,
|
|
13
|
+
VideoStreamMetadata,
|
|
14
|
+
)
|
|
15
|
+
from .ops import (
|
|
16
|
+
_get_backend_details,
|
|
17
|
+
_get_key_frame_indices,
|
|
18
|
+
_get_nvdec_cache_size,
|
|
19
|
+
_test_frame_pts_equality,
|
|
20
|
+
core_library_path,
|
|
21
|
+
create_streaming_encoder,
|
|
22
|
+
create_wav_decoder_from_file,
|
|
23
|
+
ffmpeg_major_version,
|
|
24
|
+
get_ffmpeg_library_versions,
|
|
25
|
+
get_frame_at_index,
|
|
26
|
+
get_frame_at_pts,
|
|
27
|
+
get_frames_at_indices,
|
|
28
|
+
get_frames_by_pts,
|
|
29
|
+
get_frames_by_pts_in_range,
|
|
30
|
+
get_frames_by_pts_in_range_audio,
|
|
31
|
+
get_frames_in_range,
|
|
32
|
+
get_json_metadata,
|
|
33
|
+
get_next_frame,
|
|
34
|
+
get_nvdec_cache_capacity,
|
|
35
|
+
get_wav_metadata_from_decoder,
|
|
36
|
+
get_wav_samples_in_range,
|
|
37
|
+
set_nvdec_cache_capacity,
|
|
38
|
+
streaming_encoder_add_audio_stream,
|
|
39
|
+
streaming_encoder_add_frames,
|
|
40
|
+
streaming_encoder_add_samples,
|
|
41
|
+
streaming_encoder_add_video_stream,
|
|
42
|
+
streaming_encoder_close,
|
|
43
|
+
streaming_encoder_open_file,
|
|
44
|
+
streaming_encoder_open_file_like,
|
|
45
|
+
)
|