From 31c3c13014e49eb1d00f9f355e7ab0449e7ce2ed Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 14 Jul 2017 18:49:05 -0400 Subject: [PATCH] ... --- Makefile.in | 6 +-- coders/dng.c | 109 +++++++++++++++++++++++++++++++++++++++++++-- config/config.h.in | 2 +- configure | 77 ++++++++++++++++---------------- configure.ac | 20 ++++----- 5 files changed, 159 insertions(+), 55 deletions(-) diff --git a/Makefile.in b/Makefile.in index e0e467410..cd52c02b3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -949,7 +949,7 @@ coders_djvu_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $@ @DJVU_DELEGATE_TRUE@@WITH_MODULES_TRUE@am_coders_djvu_la_rpath = \ @DJVU_DELEGATE_TRUE@@WITH_MODULES_TRUE@ -rpath $(codersdir) -coders_dng_la_DEPENDENCIES = $(MAGICKCORE_LIBS) $(am__DEPENDENCIES_1) +coders_dng_la_DEPENDENCIES = $(MAGICKCORE_LIBS) am_coders_dng_la_OBJECTS = coders/coders_dng_la-dng.lo coders_dng_la_OBJECTS = $(am_coders_dng_la_OBJECTS) coders_dng_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -2758,8 +2758,8 @@ QUANTUM_DEPTH = @QUANTUM_DEPTH@ RANLIB = @RANLIB@ RAQM_CFLAGS = @RAQM_CFLAGS@ RAQM_LIBS = @RAQM_LIBS@ -RAW_CFLAGS = @RAW_CFLAGS@ -RAW_LIBS = @RAW_LIBS@ +RAW_R_CFLAGS = @RAW_R_CFLAGS@ +RAW_R_LIBS = @RAW_R_LIBS@ RMDelegate = @RMDelegate@ RPM = @RPM@ RSVGDecodeDelegate = @RSVGDecodeDelegate@ diff --git a/coders/dng.c b/coders/dng.c index ae56776ec..71fbabf7e 100644 --- a/coders/dng.c +++ b/coders/dng.c @@ -53,9 +53,12 @@ #include "MagickCore/log.h" #include "MagickCore/magick.h" #include "MagickCore/memory_.h" +#include "MagickCore/monitor.h" +#include "MagickCore/monitor-private.h" #include "MagickCore/opencl.h" -#include "MagickCore/resource_.h" +#include "MagickCore/pixel-accessor.h" #include "MagickCore/quantum-private.h" +#include "MagickCore/resource_.h" #include "MagickCore/static.h" #include "MagickCore/string_.h" #include "MagickCore/module.h" @@ -183,9 +186,108 @@ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception) return((Image *) NULL); } (void) CloseBlob(image); - (void) DestroyImageList(image); #if defined(MAGICKCORE_RAW_DELEGATE) + { + int + status; + + libraw_data_t + *raw_info; + + libraw_processed_image_t + *raw_image; + + register ssize_t + y; + + unsigned short + *p; + + status=0; + raw_info=libraw_init(0); + if (raw_info == (libraw_data_t *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + libraw_strerror(status),"`%s'",image->filename); + return(DestroyImageList(image)); + } + status=libraw_open_file(raw_info,image->filename); + if (status != LIBRAW_SUCCESS) + { + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + libraw_strerror(status),"`%s'",image->filename); + return(DestroyImageList(image)); + } + status=libraw_unpack(raw_info); + if (status != LIBRAW_SUCCESS) + { + libraw_close(raw_info); + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + libraw_strerror(status),"`%s'",image->filename); + return(DestroyImageList(image)); + } + raw_info->params.output_bps=16; + status=libraw_dcraw_process(raw_info); + if (status != LIBRAW_SUCCESS) + { + libraw_close(raw_info); + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + libraw_strerror(status),"`%s'",image->filename); + return(DestroyImageList(image)); + } + raw_image=libraw_dcraw_make_mem_image(raw_info,&status); + if (status != LIBRAW_SUCCESS) + { + libraw_close(raw_info); + (void) ThrowMagickException(exception,GetMagickModule(),CoderError, + libraw_strerror(status),"`%s'",image->filename); + return(DestroyImageList(image)); + } + image->columns=raw_image->width; + image->rows=raw_image->height; + image->depth=16; + status=SetImageExtent(image,image->columns,image->rows,exception); + if (status == MagickFalse) + { + libraw_dcraw_clear_mem(raw_image); + libraw_close(raw_info); + return(DestroyImageList(image)); + } + p=(unsigned short *) raw_image->data; + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *q; + + register ssize_t + x; + + q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + break; + for (x=0; x < (ssize_t) image->columns; x++) + { + SetPixelRed(image,ScaleShortToQuantum(*p++),q); + SetPixelGreen(image,ScaleShortToQuantum(*p++),q); + SetPixelBlue(image,ScaleShortToQuantum(*p++),q); + q+=GetPixelChannels(image); + } + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + libraw_dcraw_clear_mem(raw_image); + libraw_close(raw_info); + return(image); + } #endif + (void) DestroyImageList(image); /* Convert DNG to PPM with delegate. */ @@ -384,7 +486,8 @@ ModuleExport size_t RegisterDNGImage(void) entry->flags^=CoderBlobSupportFlag; entry->format_type=ExplicitFormatType; (void) RegisterMagickInfo(entry); - entry=AcquireMagickInfo("DNG","NRW","Nikon Digital SLR Camera Raw Image File"); + entry=AcquireMagickInfo("DNG","NRW", + "Nikon Digital SLR Camera Raw Image File"); entry->decoder=(DecodeImageHandler *) ReadDNGImage; entry->flags|=CoderDecoderSeekableStreamFlag; entry->flags^=CoderBlobSupportFlag; diff --git a/config/config.h.in b/config/config.h.in index 17437bf79..15cbf9db2 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -842,7 +842,7 @@ #undef RAQM_DELEGATE /* Define if you have LIBRAW library */ -#undef RAW_DELEGATE +#undef RAW_R_DELEGATE /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE diff --git a/configure b/configure index 3eb28724e..71c27742a 100755 --- a/configure +++ b/configure @@ -773,10 +773,10 @@ CAIRO_SVG_LIBS CAIRO_SVG_CFLAGS RSVG_LIBS RSVG_CFLAGS -RAW_DELEGATE_FALSE -RAW_DELEGATE_TRUE -RAW_LIBS -RAW_CFLAGS +RAW_R_DELEGATE_FALSE +RAW_R_DELEGATE_TRUE +RAW_R_LIBS +RAW_R_CFLAGS PNG_DELEGATE_FALSE PNG_DELEGATE_TRUE PNG_LIBS @@ -1278,8 +1278,8 @@ PANGO_CFLAGS PANGO_LIBS PNG_CFLAGS PNG_LIBS -RAW_CFLAGS -RAW_LIBS +RAW_R_CFLAGS +RAW_R_LIBS RSVG_CFLAGS RSVG_LIBS CAIRO_SVG_CFLAGS @@ -2100,8 +2100,9 @@ Some influential environment variables: PANGO_LIBS linker flags for PANGO, overriding pkg-config PNG_CFLAGS C compiler flags for PNG, overriding pkg-config PNG_LIBS linker flags for PNG, overriding pkg-config - RAW_CFLAGS C compiler flags for RAW, overriding pkg-config - RAW_LIBS linker flags for RAW, overriding pkg-config + RAW_R_CFLAGS + C compiler flags for RAW_R, overriding pkg-config + RAW_R_LIBS linker flags for RAW_R, overriding pkg-config RSVG_CFLAGS C compiler flags for RSVG, overriding pkg-config RSVG_LIBS linker flags for RSVG, overriding pkg-config CAIRO_SVG_CFLAGS @@ -4529,7 +4530,7 @@ MAGICK_PATCHLEVEL_VERSION=1 MAGICK_VERSION=7.0.6-1 -MAGICK_GIT_REVISION=20424:dc427a01e:20170714 +MAGICK_GIT_REVISION=20425:6805f410d:20170714 # Substitute library versioning @@ -33727,27 +33728,27 @@ if test "$with_raw" != 'yes'; then fi have_raw='no' -RAW_CFLAGS="" -RAW_LIBS="" -RAW_PKG="" +RAW_R_CFLAGS="" +RAW_R_LIBS="" +RAW_R_PKG="" if test "x$with_raw" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: -------------------------------------------------------------" >&5 $as_echo "-------------------------------------------------------------" >&6; } pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAW" >&5 -$as_echo_n "checking for RAW... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAW_R" >&5 +$as_echo_n "checking for RAW_R... " >&6; } -if test -n "$RAW_CFLAGS"; then - pkg_cv_RAW_CFLAGS="$RAW_CFLAGS" +if test -n "$RAW_R_CFLAGS"; then + pkg_cv_RAW_R_CFLAGS="$RAW_R_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libraw >= 0.14.8\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libraw >= 0.14.8") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libraw_r >= 0.14.8\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libraw_r >= 0.14.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_RAW_CFLAGS=`$PKG_CONFIG --cflags "libraw >= 0.14.8" 2>/dev/null` + pkg_cv_RAW_R_CFLAGS=`$PKG_CONFIG --cflags "libraw_r >= 0.14.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -33755,16 +33756,16 @@ fi else pkg_failed=untried fi -if test -n "$RAW_LIBS"; then - pkg_cv_RAW_LIBS="$RAW_LIBS" +if test -n "$RAW_R_LIBS"; then + pkg_cv_RAW_R_LIBS="$RAW_R_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libraw >= 0.14.8\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libraw >= 0.14.8") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libraw_r >= 0.14.8\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libraw_r >= 0.14.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_RAW_LIBS=`$PKG_CONFIG --libs "libraw >= 0.14.8" 2>/dev/null` + pkg_cv_RAW_R_LIBS=`$PKG_CONFIG --libs "libraw_r >= 0.14.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -33785,12 +33786,12 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - RAW_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libraw >= 0.14.8" 2>&1` + RAW_R_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libraw_r >= 0.14.8" 2>&1` else - RAW_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libraw >= 0.14.8" 2>&1` + RAW_R_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libraw_r >= 0.14.8" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$RAW_PKG_ERRORS" >&5 + echo "$RAW_R_PKG_ERRORS" >&5 have_raw=no elif test $pkg_failed = untried; then @@ -33798,8 +33799,8 @@ elif test $pkg_failed = untried; then $as_echo "no" >&6; } have_raw=no else - RAW_CFLAGS=$pkg_cv_RAW_CFLAGS - RAW_LIBS=$pkg_cv_RAW_LIBS + RAW_R_CFLAGS=$pkg_cv_RAW_R_CFLAGS + RAW_R_LIBS=$pkg_cv_RAW_R_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_raw=yes @@ -33810,17 +33811,17 @@ fi if test "$have_raw" = 'yes'; then -$as_echo "#define RAW_DELEGATE 1" >>confdefs.h +$as_echo "#define RAW_R_DELEGATE 1" >>confdefs.h - CFLAGS="$RAW_CFLAGS $CFLAGS" + CFLAGS="$RAW_R_CFLAGS $CFLAGS" fi if test "$have_raw" = 'yes'; then - RAW_DELEGATE_TRUE= - RAW_DELEGATE_FALSE='#' + RAW_R_DELEGATE_TRUE= + RAW_R_DELEGATE_FALSE='#' else - RAW_DELEGATE_TRUE='#' - RAW_DELEGATE_FALSE= + RAW_R_DELEGATE_TRUE='#' + RAW_R_DELEGATE_FALSE= fi @@ -37764,7 +37765,7 @@ fi if test "$build_modules" != 'no'; then MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $RAQM_LIBS $LQR_LIBS $FFTW_LIBS $FLIF_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" else - MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $RAQM_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FLIF_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $LIBOPENJP2_LIBS $PANGO_LIBS $RAW_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $RAQM_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FLIF_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $LIBOPENJP2_LIBS $PANGO_LIBS $RAW_R_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" fi @@ -38135,8 +38136,8 @@ if test -z "${PNG_DELEGATE_TRUE}" && test -z "${PNG_DELEGATE_FALSE}"; then as_fn_error $? "conditional \"PNG_DELEGATE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${RAW_DELEGATE_TRUE}" && test -z "${RAW_DELEGATE_FALSE}"; then - as_fn_error $? "conditional \"RAW_DELEGATE\" was never defined. +if test -z "${RAW_R_DELEGATE_TRUE}" && test -z "${RAW_R_DELEGATE_FALSE}"; then + as_fn_error $? "conditional \"RAW_R_DELEGATE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${RSVG_DELEGATE_TRUE}" && test -z "${RSVG_DELEGATE_FALSE}"; then diff --git a/configure.ac b/configure.ac index 40c6719af..e7420f7f8 100644 --- a/configure.ac +++ b/configure.ac @@ -2609,23 +2609,23 @@ if test "$with_raw" != 'yes'; then fi have_raw='no' -RAW_CFLAGS="" -RAW_LIBS="" -RAW_PKG="" +RAW_R_CFLAGS="" +RAW_R_LIBS="" +RAW_R_PKG="" if test "x$with_raw" = "xyes"; then AC_MSG_RESULT([-------------------------------------------------------------]) - PKG_CHECK_MODULES(RAW,[libraw >= 0.14.8], have_raw=yes, have_raw=no) + PKG_CHECK_MODULES(RAW_R,[libraw_r >= 0.14.8], have_raw=yes, have_raw=no) AC_MSG_RESULT([]) fi if test "$have_raw" = 'yes'; then - AC_DEFINE(RAW_DELEGATE,1,Define if you have LIBRAW library) - CFLAGS="$RAW_CFLAGS $CFLAGS" + AC_DEFINE(RAW_R_DELEGATE,1,Define if you have LIBRAW library) + CFLAGS="$RAW_R_CFLAGS $CFLAGS" fi -AM_CONDITIONAL(RAW_DELEGATE, test "$have_raw" = 'yes') -AC_SUBST(RAW_CFLAGS) -AC_SUBST(RAW_LIBS) +AM_CONDITIONAL(RAW_R_DELEGATE, test "$have_raw" = 'yes') +AC_SUBST(RAW_R_CFLAGS) +AC_SUBST(RAW_R_LIBS) dnl =========================================================================== @@ -3802,7 +3802,7 @@ fi if test "$build_modules" != 'no'; then MAGICK_DEP_LIBS="$USER_LIBS $LCMS_LIBS $FREETYPE_LIBS $RAQM_LIBS $LQR_LIBS $FFTW_LIBS $FLIF_LIBS $FONTCONFIG_LIBS $XEXT_LIBS $IPC_LIBS $X11_LIBS $XT_LIBS $LZMA_LIBS $BZLIB_LIBS $ZLIB_LIBS $LTDL_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" else - MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $RAQM_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FLIF_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $LIBOPENJP2_LIBS $PANGO_LIBS $RAW_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" + MAGICK_DEP_LIBS="$USER_LIBS $JBIG_LIBS $LCMS_LIBS $TIFF_LIBS $FREETYPE_LIBS $RAQM_LIBS $JPEG_LIBS $GS_LIBS $LQR_LIBS $PNG_LIBS $AUTOTRACE_LIBS $DJVU_LIBS $FFTW_LIBS $FLIF_LIBS $FPX_LIBS $FONTCONFIG_LIBS $WEBP_LIBS $WMF_LIBS $DPS_LIBS $XEXT_LIBS $XT_LIBS $IPC_LIBS $X11_LIBS $LZMA_LIBS $BZLIB_LIBS $OPENEXR_LIBS $LIBOPENJP2_LIBS $PANGO_LIBS $RAW_R_LIBS $RSVG_LIBS $XML_LIBS $GVC_LIBS $ZLIB_LIBS $GDI32_LIBS $MATH_LIBS $GOMP_LIBS $CL_LIBS $UMEM_LIBS $JEMALLOC_LIBS $THREAD_LIBS" fi AC_SUBST(MAGICK_DEP_LIBS) -- 2.40.0