Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/torchcodec/_core/WavDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ WavDecoder::ChunkInfo WavDecoder::findChunk(
void WavDecoder::convertSamplesToFloat(
const std::vector<uint8_t>& bufferData,
int64_t samplesInBuffer,
float* outputPtr) const {
float* __restrict__ outputPtr) const {
int64_t totalSamples = samplesInBuffer * header_.numChannels;

// Normalize PCM samples to [-1.0, 1.0] range. The convention across
Expand Down Expand Up @@ -364,7 +364,8 @@ AudioFramesOutput WavDecoder::getSamplesInRange(
double startSeconds,
std::optional<double> stopSecondsOptional) {
// Calculate the range of samples to decode.
// Negative startSeconds is resolved to 0 in the Python layer.
// Note: negative startSeconds should already be resolved in the Python layer
STD_TORCH_CHECK(startSeconds >= 0, "startSeconds must be non-negative");
STD_TORCH_CHECK(
startSeconds <= INT64_MAX / header_.sampleRate,
"startSample calculation would overflow: startSeconds * sampleRate");
Expand Down
2 changes: 1 addition & 1 deletion src/torchcodec/_core/WavDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FORCE_PUBLIC_VISIBILITY WavDecoder {
void convertSamplesToFloat(
const std::vector<uint8_t>& bufferData,
int64_t samplesInBuffer,
float* outputPtr) const;
float* __restrict__ outputPtr) const;

std::unique_ptr<AVIOContextHolder> avio_;
WavHeader header_;
Expand Down
Loading