Skip to content

Commit 3f0417c

Browse files
committed
Fix?
1 parent 254529f commit 3f0417c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/torchcodec/_core/AVIOBytesContext.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ int64_t AVIOBytesContext::seek(void* opaque, int64_t offset, int whence) {
6868
}
6969

7070
AVIOToTensorContext::AVIOToTensorContext()
71-
: dataContext_{torch::empty({INITIAL_TENSOR_SIZE}, {torch::kUInt8}), 0} {
71+
: dataContext_{
72+
torch::empty(
73+
{AVIOToTensorContext::INITIAL_TENSOR_SIZE},
74+
{torch::kUInt8}),
75+
0} {
7276
createAVIOContext(nullptr, &write, &seek, &dataContext_);
7377
}
7478

@@ -78,9 +82,10 @@ int AVIOToTensorContext::write(void* opaque, const uint8_t* buf, int buf_size) {
7882

7983
if (dataContext->current + buf_size > dataContext->outputTensor.numel()) {
8084
TORCH_CHECK(
81-
dataContext->outputTensor.numel() * 2 <= MAX_TENSOR_SIZE,
85+
dataContext->outputTensor.numel() * 2 <=
86+
AVIOToTensorContext::MAX_TENSOR_SIZE,
8287
"We tried to allocate an output encoded tensor larger than ",
83-
MAX_TENSOR_SIZE,
88+
AVIOToTensorContext::MAX_TENSOR_SIZE,
8489
" bytes. If you think this should be supported, please report.");
8590

8691
// We double the size of the outpout tensor. Calling cat() may not be the

src/torchcodec/_core/AVIOBytesContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class AVIOToTensorContext : public AVIOContextHolder {
4242
int64_t current;
4343
};
4444

45-
static const int INITIAL_TENSOR_SIZE = 10'000'000; // 10MB
46-
static const int MAX_TENSOR_SIZE = 320'000'000; // 320 MB
45+
static constexpr int INITIAL_TENSOR_SIZE = 10'000'000; // 10MB
46+
static constexpr int MAX_TENSOR_SIZE = 320'000'000; // 320 MB
4747
static int write(void* opaque, const uint8_t* buf, int buf_size);
4848
// We need to expose seek() for some formats like mp3.
4949
static int64_t seek(void* opaque, int64_t offset, int whence);

0 commit comments

Comments
 (0)