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
3 changes: 1 addition & 2 deletions .circleci/unittest/linux/scripts/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ dependencies:
- pytest-cov
- pip
- libpng
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- jpeg
- ca-certificates
- pip:
- future
Expand Down
3 changes: 1 addition & 2 deletions .circleci/unittest/windows/scripts/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ dependencies:
- pytest-cov
- pip
- libpng
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- jpeg
- ca-certificates
- pip:
- future
Expand Down
9 changes: 3 additions & 6 deletions packaging/torchvision/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ requirements:
build:
- {{ compiler('c') }} # [win]
- libpng
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- jpeg
# NOTE: The only ffmpeg version that we build is actually 4.2
- ffmpeg >=4.2 # [not win]

Expand All @@ -25,8 +24,7 @@ requirements:
- python
- libpng
- ffmpeg >=4.2 # [not win]
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- jpeg
- pillow >=5.3.0
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
Expand All @@ -52,8 +50,7 @@ test:
requires:
- pytest
- scipy
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- jpeg
- ca-certificates


Expand Down
10 changes: 9 additions & 1 deletion torchvision/csrc/io/image/cpu/encode_jpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
}

#else
// For libjpeg version <= 9b, the out_size parameter in jpeg_mem_dest() is
// defined as unsigned long, where as in later version, it is defined as size_t.
#if !defined(JPEG_LIB_VERSION_MAJOR) || JPEG_LIB_VERSION_MAJOR < 9 || \
(JPEG_LIB_VERSION_MAJOR == 9 && JPEG_LIB_VERSION_MINOR <= 2)
using JpegSizeType = unsigned long;
#else
using JpegSizeType = size_t;
#endif

using namespace detail;

Expand All @@ -22,7 +30,7 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
struct torch_jpeg_error_mgr jerr;

// Define buffer to write JPEG information to and its size
unsigned long jpegSize = 0;
JpegSizeType jpegSize = 0;
uint8_t* jpegBuf = NULL;

cinfo.err = jpeg_std_error(&jerr.pub);
Expand Down