Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3rdparty: added libjpeg-turbo (with deprecation of libjpeg) #11497

Merged
merged 3 commits into from
May 14, 2018

Conversation

alalek
Copy link
Member

@alalek alalek commented May 10, 2018

Repo: https://github.com/libjpeg-turbo/libjpeg-turbo.git
Tag: 1.5.3

SIMD optimizations are disabled (removed) due build issues.

Enable BUILD_JPEG_TURBO_DISABLE=ON to use libjpeg.

docker_image:Custom=powerpc64le
allow_multiple_commits=1

@kinchungwong
Copy link
Contributor

Just a curious question. All of the SIMD code in libjpeg-turbo are actually in the *.asm files in each folder. To build these assembly files, either NASM or YASM will be needed.

If libjpeg-turbo is to be compiled on each user's computer, then either NASM or YASM will need to be accessible to CMake during configuration.

Another approach is to invoke NASM or YASM using custom build actions defined for *.asm file type. In this approach, the Visual Studio solution projects need to contain a snippet that knows how to invoke NASM or YASM when the project is built.

There is also the question of whether NASM or YASM should be installed into user's computer as part of the CMake preparation. However this might not be popular with some (experienced) people. But not doing this means some (novice) users will be annoyed when their first encounter with OpenCV CMake fails, and they have to manually install NASM or YASM.

This is just a curious question; I'm sure you have decided how to solve it. I just want to know more about it.

@alalek
Copy link
Member Author

alalek commented May 11, 2018

users will be annoyed when their first encounter with OpenCV CMake fails, and they have to manually install NASM or YASM

We would like to avoid such cases.

Currently we put libjpeg-turbo without any SIMD .asm code which should work on almost all platforms without extra requirements.
In the future libjpeg-turbo SIMD will be enabled on supported (capable) configurations only (with proper detection of assembler support on build platform).

ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
endif()
if(NOT DEFINED JPEG_LIB_VERSION AND EXISTS "${JPEG_INCLUDE_DIR}/jconfig.h") # libjpeg-turbo stores version in a separate file
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is jconfig.h checked for existence but jpeglib.h is parsed?

Maybe it is better to make it in a loop, something like:

foreach(jpeg_dir "${JPEG_INCLUDE_DIR};${${JPEG_LIBRARY}_BINARY_DIR}")
foreach(jpeg_hdr "jpeglib.h;jconfig.h;jconfig-64.h;...")
  ocv_parse_header("${jpeg_dir}/${jpeg_hdr}" JPEG_VERSION_LINES JPEG_LIB_VERSION)
  if (JPEG_LIB_VERSION)
    break()
  endif()
endforeach()
endforeach()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added macro to avoid copy-paste mistakes

Repo: https://github.com/libjpeg-turbo/libjpeg-turbo.git
Tag: 1.5.3

excluded libjpeg-turbo files:
- bmp.c
- bmp.h
- cderror.h
- cdjpeg.c
- cdjpeg.h
- cjpeg.c
- djpeg.c
- example.c
- jcstest.c
- jdatadst-tj.c
- jdatasrc-tj.c
- jpegtran.c
- rdbmp.c
- rdcolmap.c
- rdgif.c
- rdjpgcom.c
- rdppm.c
- rdrle.c
- rdswitch.c
- rdtarga.c
- tjbench.c
- tjunittest.c
- tjutil.c
- tjutil.h
- transupp.c
- transupp.h
- turbojpeg-jni.c
- turbojpeg.c
- turbojpeg.h
- wrbmp.c
- wrgif.c
- wrjpgcom.c
- wrppm.c
- wrrle.c
- wrtarga.c
Copy link
Contributor

@vpisarev vpisarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! 👍

@opencv-pushbot opencv-pushbot merged commit f825270 into opencv:3.4 May 14, 2018
@alalek alalek mentioned this pull request May 14, 2018
skvark pushed a commit to opencv/opencv-python that referenced this pull request Aug 18, 2019
* Including a custom libjpeg is no longer needed

Since opencv/opencv#11497, OpenCV bundles its own

* (dummy commit to trigger rebuild)
skvark pushed a commit to opencv/opencv-python that referenced this pull request Sep 5, 2019
* Including a custom libjpeg is no longer needed

Since opencv/opencv#11497, OpenCV bundles its own

* (dummy commit to trigger rebuild)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants