protect jpegint.h references

This commit is contained in:
David Rose 2010-07-14 13:59:34 +00:00
parent 3bba5366a6
commit 16a4cc0d84
6 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -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]

View File

@ -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'),

View File

@ -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

View File

@ -20,7 +20,7 @@
#include <linux/videodev.h>
#include <linux/videodev2.h>
#ifdef HAVE_JPEG
#ifdef SUPPORT_WEBCAM_VIDEO_JPEG
extern "C" {
#include <jpeglib.h>
#include <jpegint.h>
@ -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<uint32_t>::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);

View File

@ -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