Skip to content

Commit

Permalink
patch it
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Berchtold committed Feb 8, 2021
1 parent f4aabe6 commit 2d9db83
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions recipes/opencv/4.x/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ sources:
url: https://github.com/opencv/opencv/archive/4.5.1.tar.gz
- sha256: 12c3b1ddd0b8c1a7da5b743590a288df0934e5cef243e036ca290c2e45e425f5
url: https://github.com/opencv/opencv_contrib/archive/4.5.1.tar.gz
patches:
"4.1.2":
- patch_file: "patches/0001-jasper.patch"
base_path: "source_subfolder"
15 changes: 4 additions & 11 deletions recipes/opencv/4.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class OpenCVConan(ConanFile):
"with_webp": True,
"with_gtk": True,
"with_quirc": True}
exports_sources = "CMakeLists.txt"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"
_cmake = None

Expand Down Expand Up @@ -82,11 +82,7 @@ def requirements(self):
elif self.options.with_jpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/2.0.5")
if self.options.with_jpeg2000 == "jasper":
if tools.Version(self.version) >= "4.5.0":
self.requires("jasper/2.0.21")
else:
#https://github.com/opencv/opencv/issues/17984
self.requires("jasper/2.0.16")
self.requires("jasper/2.0.21")
elif self.options.with_jpeg2000 == "openjpeg":
self.requires("openjpeg/2.3.1")
if self.options.with_png:
Expand Down Expand Up @@ -119,6 +115,8 @@ def source(self):
os.rename("opencv_contrib-{}".format(self.version), self._contrib_folder)

def _patch_opencv(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
for directory in ['libjasper', 'libjpeg-turbo', 'libjpeg', 'libpng', 'libtiff', 'libwebp', 'openexr', 'protobuf', 'zlib', 'quirc']:
tools.rmdir(os.path.join(self._source_subfolder, '3rdparty', directory))
if self.options.with_openexr:
Expand Down Expand Up @@ -267,11 +265,6 @@ def _configure_cmake(self):

def build(self):
self._patch_opencv()

if self.options.with_jpeg2000 == "jasper":
if tools.Version(self.version) < "4.5.0" and self.deps_cpp_info["jasper"].version > "2.0.16":
raise ConanInvalidConfiguration("OpenCV < 4.5.0 needs an older jasper version, see https://github.com/opencv/opencv/issues/17984")

cmake = self._configure_cmake()
cmake.build()

Expand Down
20 changes: 20 additions & 0 deletions recipes/opencv/4.x/patches/0001-jasper.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp
+++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp
@@ -378,7 +378,7 @@ bool Jpeg2KDecoder::readComponent8u( uchar *data, void *_buffer,

for( y = 0; y < yend - ystart; )
{
- jas_seqent_t* pix_row = &jas_matrix_get( buffer, y / ystep, 0 );
+ jas_seqent_t* pix_row = jas_matrix_getref( buffer, y / ystep, 0 );
uchar* dst = data + (y - yoffset) * step - xoffset;

if( xstep == 1 )
@@ -444,7 +444,7 @@ bool Jpeg2KDecoder::readComponent16u( unsigned short *data, void *_buffer,

for( y = 0; y < yend - ystart; )
{
- jas_seqent_t* pix_row = &jas_matrix_get( buffer, y / ystep, 0 );
+ jas_seqent_t* pix_row = jas_matrix_getref( buffer, y / ystep, 0 );
ushort* dst = data + (y - yoffset) * step - xoffset;

if( xstep == 1 )

0 comments on commit 2d9db83

Please sign in to comment.