Skip to content

Commit 41c70dd

Browse files
author
pytorchbot
committed
2025-03-05 nightly release (da9164e)
1 parent d5e4b79 commit 41c70dd

File tree

6 files changed

+95
-107
lines changed

6 files changed

+95
-107
lines changed

.github/workflows/linux_cuda_wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
# For the actual release we should add that label and change this to
6767
# include more python versions.
6868
python-version: ['3.9']
69-
cuda-version: ['11.8', '12.6']
69+
cuda-version: ['11.8', '12.6', '12.8']
7070
# TODO: put back ffmpeg 5 https://github.com/pytorch/torchcodec/issues/325
7171
ffmpeg-version-for-tests: ['4.4.2', '6', '7']
7272

src/torchcodec/decoders/_core/FFMPEGCommon.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,26 @@ int64_t getDuration(const AVFrame* frame) {
6262

6363
AVIOBytesContext::AVIOBytesContext(
6464
const void* data,
65-
size_t data_size,
66-
size_t tempBufferSize) {
67-
auto buffer = static_cast<uint8_t*>(av_malloc(tempBufferSize));
68-
if (!buffer) {
69-
throw std::runtime_error(
70-
"Failed to allocate buffer of size " + std::to_string(tempBufferSize));
71-
}
72-
bufferData_.data = static_cast<const uint8_t*>(data);
73-
bufferData_.size = data_size;
74-
bufferData_.current = 0;
65+
size_t dataSize,
66+
size_t bufferSize)
67+
: bufferData_{static_cast<const uint8_t*>(data), dataSize, 0} {
68+
auto buffer = static_cast<uint8_t*>(av_malloc(bufferSize));
69+
TORCH_CHECK(
70+
buffer != nullptr,
71+
"Failed to allocate buffer of size " + std::to_string(bufferSize));
7572

7673
avioContext_.reset(avio_alloc_context(
7774
buffer,
78-
tempBufferSize,
75+
bufferSize,
7976
0,
8077
&bufferData_,
8178
&AVIOBytesContext::read,
8279
nullptr,
8380
&AVIOBytesContext::seek));
81+
8482
if (!avioContext_) {
8583
av_freep(&buffer);
86-
throw std::runtime_error("Failed to allocate AVIOContext");
84+
TORCH_CHECK(false, "Failed to allocate AVIOContext");
8785
}
8886
}
8987

@@ -99,14 +97,14 @@ AVIOContext* AVIOBytesContext::getAVIO() {
9997

10098
// The signature of this function is defined by FFMPEG.
10199
int AVIOBytesContext::read(void* opaque, uint8_t* buf, int buf_size) {
102-
struct AVIOBufferData* bufferData =
103-
static_cast<struct AVIOBufferData*>(opaque);
100+
auto bufferData = static_cast<AVIOBufferData*>(opaque);
104101
TORCH_CHECK(
105102
bufferData->current <= bufferData->size,
106103
"Tried to read outside of the buffer: current=",
107104
bufferData->current,
108105
", size=",
109106
bufferData->size);
107+
110108
buf_size =
111109
FFMIN(buf_size, static_cast<int>(bufferData->size - bufferData->current));
112110
TORCH_CHECK(
@@ -117,6 +115,7 @@ int AVIOBytesContext::read(void* opaque, uint8_t* buf, int buf_size) {
117115
bufferData->size,
118116
", current=",
119117
bufferData->current);
118+
120119
if (!buf_size) {
121120
return AVERROR_EOF;
122121
}
@@ -127,7 +126,7 @@ int AVIOBytesContext::read(void* opaque, uint8_t* buf, int buf_size) {
127126

128127
// The signature of this function is defined by FFMPEG.
129128
int64_t AVIOBytesContext::seek(void* opaque, int64_t offset, int whence) {
130-
AVIOBufferData* bufferData = (AVIOBufferData*)opaque;
129+
auto bufferData = static_cast<AVIOBufferData*>(opaque);
131130
int64_t ret = -1;
132131

133132
switch (whence) {
@@ -141,6 +140,7 @@ int64_t AVIOBytesContext::seek(void* opaque, int64_t offset, int whence) {
141140
default:
142141
break;
143142
}
143+
144144
return ret;
145145
}
146146

src/torchcodec/decoders/_core/FFMPEGCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct AVIOBufferData {
155155
// memory buffer that is passed in.
156156
class AVIOBytesContext {
157157
public:
158-
AVIOBytesContext(const void* data, size_t data_size, size_t tempBufferSize);
158+
AVIOBytesContext(const void* data, size_t dataSize, size_t bufferSize);
159159
~AVIOBytesContext();
160160

161161
// Returns the AVIOContext that can be passed to FFMPEG.

0 commit comments

Comments
 (0)