Commit 54bb22fb authored by Ghislain MARY's avatar Ghislain MARY

Attempt to support turbo-jpeg with or without const buffer parameters.

parent 21a3e023
......@@ -39,10 +39,31 @@ find_library(TURBOJPEG_LIBRARIES
PATH_SUFFIXES bin lib
)
if(TURBOJPEG_INCLUDE_DIRS AND TURBOJPEG_LIBRARIES)
include(CheckCSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${TURBOJPEG_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${TURBOJPEG_LIBRARIES})
check_c_source_compiles("
#include <turbojpeg.h>
int main(int argc, char *argv[]) {
tjhandle handle = 0;
const unsigned char *srcPlanes = 0;
const int *strides = 0;
unsigned char *jpegBuf = 0;
unsigned long jpegSize = 0;
int width = 0, height = 0, subsamp = 0, jpegQual = 0, flags = 0;
return tjCompressFromYUVPlanes(handle, &srcPlanes, width, strides, height, subsamp, &jpegBuf, &jpegSize, jpegQual, flags);
}" TURBOJPEG_USE_CONST_BUFFERS)
cmake_pop_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TurboJpeg
DEFAULT_MSG
TURBOJPEG_INCLUDE_DIRS TURBOJPEG_LIBRARIES
)
mark_as_advanced(TURBOJPEG_INCLUDE_DIRS TURBOJPEG_LIBRARIES)
mark_as_advanced(TURBOJPEG_INCLUDE_DIRS TURBOJPEG_LIBRARIES TURBOJPEG_USE_CONST_BUFFERS)
......@@ -401,6 +401,9 @@ if(ENABLE_VIDEO)
list(APPEND VOIP_SOURCE_FILES_C
videofilters/turbojpegwriter.c
)
if(TURBOJPEG_USE_CONST_BUFFERS)
set_source_files_properties(videofilters/turbojpegwriter.c PROPERTIES COMPILE_DEFINITIONS "TURBOJPEG_USE_CONST_BUFFERS")
endif()
endif()
if(OPENGL_FOUND OR QTANGLE_FOUND)
list(APPEND VOIP_SOURCE_FILES_C
......
......@@ -30,7 +30,7 @@ typedef struct {
FILE *file;
char *filename;
char *tmpFilename;
tjhandle *turboJpeg;
tjhandle turboJpeg;
MSFilter *f;
}JpegWriter;
......@@ -125,7 +125,11 @@ static void jpg_process(MSFilter *f) {
error = tjCompressFromYUVPlanes(
s->turboJpeg,
#ifdef TURBOJPEG_USE_CONST_BUFFERS
(const unsigned char **)yuvbuf.planes,
#else
(unsigned char **)yuvbuf.planes,
#endif
yuvbuf.w,
yuvbuf.strides,
yuvbuf.h,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment