Unverified Commit 16caba5e authored by zzk1st's avatar zzk1st Committed by GitHub
Browse files

Unpinned the libjpeg version and fixed jpeg_mem_dest's size type Wind… (#4288)



* Unpinned the libjpeg version and fixed jpeg_mem_dest's size type Windows BC issue

* Temporarily get back pinned jpeg lib in order to run tests on CircleCI

* Revert "Temporarily get back pinned jpeg lib in order to run tests on CircleCI"

This reverts commit ab18a354150f750256b61911e54aa48621ef24cd.

* Used using instead of typedef and Fixed comment typo
Co-authored-by: default avatarZhongkai Zhu <zhongkai@fb.com>
Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent 84888b93
...@@ -7,8 +7,7 @@ dependencies: ...@@ -7,8 +7,7 @@ dependencies:
- pytest-mock - pytest-mock
- pip - pip
- libpng - libpng
# NOTE: Pinned to fix issues with size_t on Windows - jpeg
- jpeg <=9b
- ca-certificates - ca-certificates
- pip: - pip:
- future - future
......
...@@ -7,8 +7,7 @@ dependencies: ...@@ -7,8 +7,7 @@ dependencies:
- pytest-mock - pytest-mock
- pip - pip
- libpng - libpng
# NOTE: Pinned to fix issues with size_t on Windows - jpeg
- jpeg <=9b
- ca-certificates - ca-certificates
- pip: - pip:
- future - future
......
...@@ -9,8 +9,7 @@ requirements: ...@@ -9,8 +9,7 @@ requirements:
build: build:
- {{ compiler('c') }} # [win] - {{ compiler('c') }} # [win]
- libpng - libpng
# NOTE: Pinned to fix issues with size_t on Windows - jpeg
- jpeg <=9b
# NOTE: The only ffmpeg version that we build is actually 4.2 # NOTE: The only ffmpeg version that we build is actually 4.2
- ffmpeg >=4.2 # [not win] - ffmpeg >=4.2 # [not win]
...@@ -25,8 +24,7 @@ requirements: ...@@ -25,8 +24,7 @@ requirements:
- python - python
- libpng - libpng
- ffmpeg >=4.2 # [not win] - ffmpeg >=4.2 # [not win]
# NOTE: Pinned to fix issues with size_t on Windows - jpeg
- jpeg <=9b
- pillow >=5.3.0 - pillow >=5.3.0
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }} {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }} {{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
...@@ -52,8 +50,7 @@ test: ...@@ -52,8 +50,7 @@ test:
requires: requires:
- pytest - pytest
- scipy - scipy
# NOTE: Pinned to fix issues with size_t on Windows - jpeg
- jpeg <=9b
- ca-certificates - ca-certificates
......
...@@ -13,6 +13,18 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) { ...@@ -13,6 +13,18 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
} }
#else #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.
// For windows backward compatibility, we define JpegSizeType as different types
// according to the libjpeg version used, in order to prevent compilcation
// errors.
#if defined(_WIN32) || !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; using namespace detail;
...@@ -22,7 +34,7 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) { ...@@ -22,7 +34,7 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
struct torch_jpeg_error_mgr jerr {}; struct torch_jpeg_error_mgr jerr {};
// Define buffer to write JPEG information to and its size // Define buffer to write JPEG information to and its size
unsigned long jpegSize = 0; JpegSizeType jpegSize = 0;
uint8_t* jpegBuf = nullptr; uint8_t* jpegBuf = nullptr;
cinfo.err = jpeg_std_error(&jerr.pub); cinfo.err = jpeg_std_error(&jerr.pub);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment