From 16a4cc0d84f0ed42b197b16dbef318c36ed39167 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 14 Jul 2010 13:59:34 +0000 Subject: [PATCH] protect jpegint.h references --- dtool/Config.pp | 4 ++++ dtool/LocalSetup.pp | 1 + makepanda/makepanda.py | 1 + panda/src/vision/Sources.pp | 2 +- panda/src/vision/webcamVideoCursorV4L.cxx | 12 ++++++------ panda/src/vision/webcamVideoCursorV4L.h | 5 ++++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dtool/Config.pp b/dtool/Config.pp index 6f6e61ba97..4cc10a8488 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -474,6 +474,10 @@ #define JPEG_LIBS jpeg #defer HAVE_JPEG $[libtest $[JPEG_LPATH],$[JPEG_LIBS]] +// Some versions of libjpeg did not provide jpegint.h. Redefine this +// to empty if you lack this header file. +#define PHAVE_JPEGINT_H 1 + // Is libpng installed, and where? #define PNG_IPATH #define PNG_LPATH diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index ed3669680b..ea337886f4 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -280,6 +280,7 @@ $[cdefine REPORT_OPENSSL_ERRORS] /* Define if we have libjpeg installed. */ $[cdefine HAVE_JPEG] +$[cdefine PHAVE_JPEGINT_H] /* Define if we have libpng installed. */ $[cdefine HAVE_PNG] diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 6e8b4388d0..811e0c62c3 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1357,6 +1357,7 @@ DTOOL_CONFIG=[ ("HAVE_ZLIB", 'UNDEF', 'UNDEF'), ("HAVE_PNG", 'UNDEF', 'UNDEF'), ("HAVE_JPEG", 'UNDEF', 'UNDEF'), + ("PHAVE_JPEGINT_H", '1', '1'), ("HAVE_TIFF", 'UNDEF', 'UNDEF'), ("HAVE_SGI_RGB", '1', '1'), ("HAVE_TGA", '1', '1'), diff --git a/panda/src/vision/Sources.pp b/panda/src/vision/Sources.pp index a5a4642300..45f683eea6 100644 --- a/panda/src/vision/Sources.pp +++ b/panda/src/vision/Sources.pp @@ -1,7 +1,7 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m prc:c -#define USE_PACKAGES opencv artoolkit +#define USE_PACKAGES opencv artoolkit jpeg #define BUILDING_DLL BUILDING_VISION diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index f31a5a9be5..5aee147197 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -20,7 +20,7 @@ #include #include -#ifdef HAVE_JPEG +#ifdef SUPPORT_WEBCAM_VIDEO_JPEG extern "C" { #include #include @@ -59,7 +59,7 @@ INLINE static void yuyv_to_rgbargba(unsigned char *dest, const unsigned char *sr dest[7] = (unsigned char) -1; } -#if defined(HAVE_JPEG) && !defined(CPPPARSER) +#if defined(SUPPORT_WEBCAM_VIDEO_JPEG) && !defined(CPPPARSER) struct my_error_mgr { struct jpeg_error_mgr pub; @@ -151,7 +151,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; pvector::iterator it; for (it = src->_pformats.begin(); it != src->_pformats.end(); ++it) { -#ifdef HAVE_JPEG +#ifdef SUPPORT_WEBCAM_VIDEO_JPEG if (*it == V4L2_PIX_FMT_MJPEG) { _format->fmt.pix.pixelformat = *it; break; @@ -238,7 +238,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { vision_cat.error() << "Failed to stream from buffer!\n"; } -#ifdef HAVE_JPEG +#ifdef SUPPORT_WEBCAM_VIDEO_JPEG // Initialize the JPEG library, if necessary if (_format->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { _cinfo = (struct jpeg_decompress_struct *) malloc(sizeof(struct jpeg_decompress_struct)); @@ -265,7 +265,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { //////////////////////////////////////////////////////////////////// WebcamVideoCursorV4L:: ~WebcamVideoCursorV4L() { -#ifdef HAVE_JPEG +#ifdef SUPPORT_WEBCAM_VIDEO_JPEG if (_cinfo != NULL) { jpeg_destroy_decompress(_cinfo); free(_cinfo); @@ -316,7 +316,7 @@ fetch_into_buffer(double time, unsigned char *block, bool bgra) { unsigned char *buf = (unsigned char *) _buffers[vbuf.index]; if (_format->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { -#ifdef HAVE_JPEG +#ifdef SUPPORT_WEBCAM_VIDEO_JPEG nassertv(!bgra); struct my_error_mgr jerr; _cinfo->err = jpeg_std_error(&jerr.pub); diff --git a/panda/src/vision/webcamVideoCursorV4L.h b/panda/src/vision/webcamVideoCursorV4L.h index 34f43cb50a..7107e7fe65 100644 --- a/panda/src/vision/webcamVideoCursorV4L.h +++ b/panda/src/vision/webcamVideoCursorV4L.h @@ -22,7 +22,10 @@ #include "webcamVideo.h" struct v4l2_format; -#ifdef HAVE_JPEG + +// We can only decode a motion-jpeg stream if we have jpegint.h. +#if defined(HAVE_JPEG) && defined(PHAVE_JPEGINT_H) +#define SUPPORT_WEBCAM_VIDEO_JPEG 1 struct jpeg_decompress_struct; #endif