Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/torchcodec/_core/AVIOFileLikeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

namespace facebook::torchcodec {

AVIOFileLikeContext::AVIOFileLikeContext(py::object fileLike, bool isForWriting)
AVIOFileLikeContext::AVIOFileLikeContext(
const py::object& fileLike,
bool isForWriting)
: fileLike_{UniquePyObject(new py::object(fileLike))} {
{
// TODO: Is it necessary to acquire the GIL here? Is it maybe even
Expand Down Expand Up @@ -90,7 +92,7 @@ int AVIOFileLikeContext::write(void* opaque, const uint8_t* buf, int buf_size) {
py::gil_scoped_acquire gil;
py::bytes bytes_obj(reinterpret_cast<const char*>(buf), buf_size);

return py::cast<int64_t>((*fileLike)->attr("write")(bytes_obj));
return py::cast<int>((*fileLike)->attr("write")(bytes_obj));
}

} // namespace facebook::torchcodec
2 changes: 1 addition & 1 deletion src/torchcodec/_core/AVIOFileLikeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace facebook::torchcodec {
// and seek calls back up to the methods on the Python object.
class AVIOFileLikeContext : public AVIOContextHolder {
public:
explicit AVIOFileLikeContext(py::object fileLike, bool isForWriting);
explicit AVIOFileLikeContext(const py::object& fileLike, bool isForWriting);

private:
static int read(void* opaque, uint8_t* buf, int buf_size);
Expand Down
Loading