[libkdcraw/f17] make libjpeg support work on Fedora 17

Kevin Kofler kkofler at fedoraproject.org
Sat Mar 9 23:03:19 UTC 2013


commit f9576701ab72debbaffa170c5204cacfbba057f2
Author: Kevin Kofler <Kevin at tigcc.ticalc.org>
Date:   Sun Mar 10 00:02:54 2013 +0100

    make libjpeg support work on Fedora 17
    
    * Sat Mar 09 2013 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.10.1-1.1
    - make libjpeg support work on Fedora 17

 libkdcraw-4.10.0-libjpeg-turbo.patch |  127 +++++++++++++++++++++-------------
 libkdcraw.spec                       |   10 ++-
 2 files changed, 85 insertions(+), 52 deletions(-)
---
diff --git a/libkdcraw-4.10.0-libjpeg-turbo.patch b/libkdcraw-4.10.0-libjpeg-turbo.patch
index 96ed83b..9f3a2e9 100644
--- a/libkdcraw-4.10.0-libjpeg-turbo.patch
+++ b/libkdcraw-4.10.0-libjpeg-turbo.patch
@@ -1,28 +1,7 @@
-From 68ddf3f752956247f58e11be76f7518f7566e343 Mon Sep 17 00:00:00 2001
-Message-Id: <68ddf3f752956247f58e11be76f7518f7566e343.1360173442.git.kevin.kofler at chello.at>
-From: Kevin Kofler <kevin.kofler at chello.at>
-Date: Wed, 6 Feb 2013 17:11:58 +0100
-Subject: [PATCH] fix libjpeg detection for libjpeg-turbo
-
-This fixes the libjpeg detection to check for the availability of
-jpeg_mem_src rather than for JPEG_LIB_VERSION, allowing to build the
-JPEG functionality with libjpeg-turbo >= 1.2.90.
-
-RawSpeed/DngDecoderSlices.cpp tries to define its own jpeg_mem_src
-function if JPEG_LIB_VERSION < 80, so patch it to use the detected
-USE_JPEG8 instead to avoid the redefinition and the resulting compiler
-error.
----
- libraw/CMakeLists.txt                       | 29 +++++++++++++++--------------
- libraw/RawSpeed/DngDecoderSlices.cpp        |  2 +-
- libraw/RawSpeed/rawspeed.jpeg-version.patch | 13 +++++++++++++
- 3 Dateien geändert, 29 Zeilen hinzugefügt(+), 15 Zeilen entfernt(-)
-
-diff --git a/libraw/CMakeLists.txt b/libraw/CMakeLists.txt
-index 581e7b1..e83b134 100644
---- a/libraw/CMakeLists.txt
-+++ b/libraw/CMakeLists.txt
-@@ -88,28 +88,29 @@ ENDIF (ENABLE_LCMS2)
+diff -Nur libkdcraw-4.10.0/libraw/CMakeLists.txt libkdcraw-4.10.0-libjpeg-turbo/libraw/CMakeLists.txt
+--- libkdcraw-4.10.0/libraw/CMakeLists.txt	2013-01-23 23:00:43.000000000 +0100
++++ libkdcraw-4.10.0-libjpeg-turbo/libraw/CMakeLists.txt	2013-03-09 23:58:25.000000000 +0100
+@@ -88,29 +88,26 @@
  
  FIND_PACKAGE(JPEG)
  IF(JPEG_FOUND)
@@ -32,15 +11,16 @@ index 581e7b1..e83b134 100644
 -    SET(_jpeglib_version_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/cmake_jpeglib_version_check.cpp)
 -    FILE(WRITE "${_jpeglib_version_source_file}" "${_jpeglib_version_source}")
 -    SET(_jpeglib_version_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${JPEG_INCLUDE_DIR}")
--
++    INCLUDE(CheckSymbolExists)
+ 
 -    TRY_COMPILE(_jpeglib_version_compile_result ${CMAKE_BINARY_DIR} ${_jpeglib_version_source_file}
 -                CMAKE_FLAGS "${_jpeglib_version_include_dirs}"
 -                COMPILE_OUTPUT_VARIABLE _jpeglib_version_compile_output_var
 -               )
 -    IF(_jpeglib_version_compile_result)
 -        MESSAGE(STATUS "Identified libjpeg version less than 80 (too low)")
-+    INCLUDE(CheckSymbolExists)
-+
+-        SET(JPEG_FOUND FALSE)
+-    ENDIF()
 +    # check for the jpeg_mem_src function
 +    SET(OLD_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
 +    LIST(APPEND CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIR}")
@@ -49,28 +29,25 @@ index 581e7b1..e83b134 100644
 +    CHECK_SYMBOL_EXISTS(jpeg_mem_src "stddef.h;stdio.h;jpeglib.h" HAVE_JPEG_MEM_SRC)
 +    SET(CMAKE_REQUIRED_INCLUDES "${OLD_CMAKE_REQUIRED_INCLUDES}")
 +    SET(CMAKE_REQUIRED_LIBRARIES "${OLD_CMAKE_REQUIRED_LIBRARIES}")
-+
-+    IF(NOT HAVE_JPEG_MEM_SRC)
-+        MESSAGE(STATUS "libjpeg too old (need IJG libjpeg >= 8 or libjpeg-turbo >= 1.2.90)")
-         SET(JPEG_FOUND FALSE)
-     ENDIF()
  ENDIF(JPEG_FOUND)
  
 -MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "JPEG image format support" "http://www.ijg.org" FALSE "80" "needed for the LibRaw DNG lossy codec")
-+MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "JPEG image format support" "http://www.ijg.org" FALSE "8" "needed for the LibRaw DNG lossy codec")
++MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "JPEG image format support" "http://www.ijg.org" FALSE "" "needed for the LibRaw DNG lossy codec")
  
  # Flag to use libjpeg with LibRaw DNG lossy codec
  IF(JPEG_FOUND)
      ADD_DEFINITIONS(-DUSE_JPEG)
-+    # always claim JPEG8, all that's needed is jpeg_mem_src we just checked for
-     ADD_DEFINITIONS(-DUSE_JPEG8)
+-    ADD_DEFINITIONS(-DUSE_JPEG8)
++    IF(HAVE_JPEG_MEM_SRC)
++        ADD_DEFINITIONS(-DUSE_JPEG8)
++    ENDIF(HAVE_JPEG_MEM_SRC)
      INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
  ENDIF()
-diff --git a/libraw/RawSpeed/DngDecoderSlices.cpp b/libraw/RawSpeed/DngDecoderSlices.cpp
-index 28a137e..617b4b3 100644
---- a/libraw/RawSpeed/DngDecoderSlices.cpp
-+++ b/libraw/RawSpeed/DngDecoderSlices.cpp
-@@ -88,7 +88,7 @@ void DngDecoderSlices::startDecoding() {
+ 
+diff -Nur libkdcraw-4.10.0/libraw/RawSpeed/DngDecoderSlices.cpp libkdcraw-4.10.0-libjpeg-turbo/libraw/RawSpeed/DngDecoderSlices.cpp
+--- libkdcraw-4.10.0/libraw/RawSpeed/DngDecoderSlices.cpp	2013-01-23 23:00:43.000000000 +0100
++++ libkdcraw-4.10.0-libjpeg-turbo/libraw/RawSpeed/DngDecoderSlices.cpp	2013-03-09 23:48:29.000000000 +0100
+@@ -88,7 +88,7 @@
  
  }
  
@@ -79,11 +56,9 @@ index 28a137e..617b4b3 100644
  /* Read JPEG image from a memory segment */
  
  static void init_source (j_decompress_ptr cinfo) {}
-diff --git a/libraw/RawSpeed/rawspeed.jpeg-version.patch b/libraw/RawSpeed/rawspeed.jpeg-version.patch
-new file mode 100644
-index 0000000..3a012d1
---- /dev/null
-+++ b/libraw/RawSpeed/rawspeed.jpeg-version.patch
+diff -Nur libkdcraw-4.10.0/libraw/RawSpeed/rawspeed.jpeg-version.patch libkdcraw-4.10.0-libjpeg-turbo/libraw/RawSpeed/rawspeed.jpeg-version.patch
+--- libkdcraw-4.10.0/libraw/RawSpeed/rawspeed.jpeg-version.patch	1970-01-01 01:00:00.000000000 +0100
++++ libkdcraw-4.10.0-libjpeg-turbo/libraw/RawSpeed/rawspeed.jpeg-version.patch	2013-03-09 23:48:29.000000000 +0100
 @@ -0,0 +1,13 @@
 +diff --git a/RawSpeed/DngDecoderSlices.cpp b/RawSpeed/DngDecoderSlices.cpp
 +index 28a137e..617b4b3 100644
@@ -98,6 +73,60 @@ index 0000000..3a012d1
 + /* Read JPEG image from a memory segment */
 + 
 + static void init_source (j_decompress_ptr cinfo) {}
--- 
-1.7.11.7
-
+diff -Nur libkdcraw-4.10.0/libraw/src/libraw_datastream.cpp libkdcraw-4.10.0-libjpeg-turbo/libraw/src/libraw_datastream.cpp
+--- libkdcraw-4.10.0/libraw/src/libraw_datastream.cpp	2013-01-23 23:00:44.000000000 +0100
++++ libkdcraw-4.10.0-libjpeg-turbo/libraw/src/libraw_datastream.cpp	2013-03-09 23:55:06.000000000 +0100
+@@ -443,9 +443,52 @@
+ #endif
+ }
+ 
++#ifndef USE_JPEG8
++/* Read JPEG image from a memory segment
++   (from libraw/RawSpeed/DngDecoderSlices.cpp, LGPLv2+) */
++
++static void init_source (j_decompress_ptr cinfo) {}
++static boolean fill_input_buffer (j_decompress_ptr cinfo)
++{
++  struct jpeg_source_mgr* src = (struct jpeg_source_mgr*) cinfo->src;
++  return !!src->bytes_in_buffer;
++}
++static void skip_input_data (j_decompress_ptr cinfo, long num_bytes)
++{
++  struct jpeg_source_mgr* src = (struct jpeg_source_mgr*) cinfo->src;
++
++  if (num_bytes > (int)src->bytes_in_buffer)
++    throw std::runtime_error("JPEG Decoder - read out of buffer");
++  if (num_bytes > 0) {
++    src->next_input_byte += (size_t) num_bytes;
++    src->bytes_in_buffer -= (size_t) num_bytes;
++  }
++}
++static void term_source (j_decompress_ptr cinfo) {}
++static void jpeg_mem_src (j_decompress_ptr cinfo, unsigned char* buffer, long nbytes)
++{
++  struct jpeg_source_mgr* src;
++
++  if (cinfo->src == NULL) {   /* first time for this JPEG object? */
++    cinfo->src = (struct jpeg_source_mgr *)
++      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
++      sizeof(struct jpeg_source_mgr));
++  }
++
++  src = (struct jpeg_source_mgr*) cinfo->src;
++  src->init_source = init_source;
++  src->fill_input_buffer = fill_input_buffer;
++  src->skip_input_data = skip_input_data;
++  src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
++  src->term_source = term_source;
++  src->bytes_in_buffer = nbytes;
++  src->next_input_byte = (JOCTET*)buffer;
++}
++#endif
++
+ int LibRaw_buffer_datastream::jpeg_src(void *jpegdata)
+ {
+-#if defined(NO_JPEG) || !defined (USE_JPEG8)
++#if defined(NO_JPEG)
+   return -1;
+ #else
+   j_decompress_ptr cinfo = (j_decompress_ptr) jpegdata;
diff --git a/libkdcraw.spec b/libkdcraw.spec
index 6a0cfca..78d8fc5 100644
--- a/libkdcraw.spec
+++ b/libkdcraw.spec
@@ -1,7 +1,7 @@
 Name:    libkdcraw
 Summary: A C++ interface around LibRaw library
 Version: 4.10.1
-Release: 1%{?dist}
+Release: 1%{?dist}.1
 
 # libkdcraw is GPLv2+,
 # LibRaw(bundled) is LGPLv2
@@ -16,14 +16,15 @@ URL:     https://projects.kde.org/projects/kde/kdegraphics/libs/libkdcraw
 %endif
 Source0: http://download.kde.org/%{stable}/%{version}/src/%{name}-%{version}.tar.xz
 # fix libjpeg detection for libjpeg-turbo, hopefully upstreamable
+# (the hack to add jpeg_mem_src from RawSpeed to LibRaw might not be though)
 Patch50: libkdcraw-4.10.0-libjpeg-turbo.patch
 
 BuildRequires: kdelibs4-devel
-# libjpeg 80+ or libjpeg-turbo-1.2.90+  needed for the LibRaw DNG lossy codec
 %if 0%{?fedora} > 17
+# libjpeg-turbo-1.2.90+ provides jpeg_mem_src
 %define libjpeg_ver 1.2.90
 %endif
-%{?libjpeg_ver:BuildRequires: libjpeg-turbo-devel >= %{libjpeg_ver}}
+BuildRequires: libjpeg-turbo-devel%{?libjpeg_ver: >= %{libjpeg_ver}}
 BuildRequires: pkgconfig(lcms2)
 BuildRequires: pkgconfig(jasper)
 BuildRequires: pkgconfig(libxml-2.0)
@@ -114,6 +115,9 @@ fi
 
 
 %changelog
+* Sat Mar 09 2013 Kevin Kofler <Kevin at tigcc.ticalc.org> - 4.10.1-1.1
+- make libjpeg support work on Fedora 17
+
 * Sat Mar 02 2013 Rex Dieter <rdieter at fedoraproject.org> - 4.10.1-1
 - 4.10.1
 


More information about the scm-commits mailing list