PKGBUILDs/vlc/nightly/0002-Fix-compatibility-with...

300 lines
13 KiB
Diff

From 1424be0fc4a3239273d77005f4e126f52208a322 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 11 Mar 2018 20:23:42 +0100
Subject: [PATCH 2/3] Fix compatibility with OpenCV 3.4.1
---
modules/video_filter/Makefile.am | 2 +-
modules/video_filter/opencv_example.cpp | 4 +-
.../{opencv_wrapper.c => opencv_wrapper.cpp} | 113 +++++++++---------
po/POTFILES.in | 2 +-
4 files changed, 62 insertions(+), 59 deletions(-)
rename modules/video_filter/{opencv_wrapper.c => opencv_wrapper.cpp} (82%)
diff --git a/modules/video_filter/Makefile.am b/modules/video_filter/Makefile.am
index af190d16e3..d1703a7ed3 100644
--- a/modules/video_filter/Makefile.am
+++ b/modules/video_filter/Makefile.am
@@ -147,7 +147,7 @@ endif
libdeinterlace_plugin_la_LIBADD = libdeinterlace_common.la
video_filter_LTLIBRARIES += libdeinterlace_plugin.la
-libopencv_wrapper_plugin_la_SOURCES = video_filter/opencv_wrapper.c
+libopencv_wrapper_plugin_la_SOURCES = video_filter/opencv_wrapper.cpp
libopencv_wrapper_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(OPENCV_CFLAGS)
libopencv_wrapper_plugin_la_LIBADD = $(OPENCV_LIBS)
libopencv_wrapper_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(video_filterdir)'
diff --git a/modules/video_filter/opencv_example.cpp b/modules/video_filter/opencv_example.cpp
index a7a0bd7821..119c40d3fc 100644
--- a/modules/video_filter/opencv_example.cpp
+++ b/modules/video_filter/opencv_example.cpp
@@ -129,7 +129,7 @@ static int OpenFilter( vlc_object_t *p_this )
static void CloseFilter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t*)p_this;
- filter_sys_t *p_sys = p_filter->p_sys;
+ filter_sys_t *p_sys = reinterpret_cast<filter_sys_t *>(p_filter->p_sys);
if( p_sys->p_cascade )
cvReleaseHaarClassifierCascade( &p_sys->p_cascade );
@@ -151,7 +151,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
IplImage** p_img = NULL;
CvPoint pt1, pt2;
int scale = 1;
- filter_sys_t *p_sys = p_filter->p_sys;
+ filter_sys_t *p_sys = reinterpret_cast<filter_sys_t *>(p_filter->p_sys);
if ((!p_pic) )
{
diff --git a/modules/video_filter/opencv_wrapper.c b/modules/video_filter/opencv_wrapper.cpp
similarity index 82%
rename from modules/video_filter/opencv_wrapper.c
rename to modules/video_filter/opencv_wrapper.cpp
index ed48fe1f67..dade9b2f6c 100644
--- a/modules/video_filter/opencv_wrapper.c
+++ b/modules/video_filter/opencv_wrapper.cpp
@@ -154,7 +154,7 @@ static int Create( vlc_object_t *p_this )
char *psz_chroma, *psz_output;
/* Allocate structure */
- p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
+ p_filter->p_sys = reinterpret_cast<filter_sys_t*>( malloc( sizeof( filter_sys_t ) ) );
if( p_filter->p_sys == NULL )
return VLC_ENOMEM;
@@ -167,39 +167,40 @@ static int Create( vlc_object_t *p_this )
* We don't need to set up video formats for this filter as it not
* actually using a picture_t.
*/
- p_filter->p_sys->p_opencv = vlc_object_create( p_filter, sizeof(filter_t) );
- if( !p_filter->p_sys->p_opencv ) {
+ auto *p_filter_sys = reinterpret_cast<filter_sys_t*>(p_filter->p_sys);
+ p_filter_sys->p_opencv = reinterpret_cast<filter_t*>( vlc_object_create( p_filter, sizeof(filter_t) ) );
+ if( !p_filter_sys->p_opencv ) {
free( p_filter->p_sys );
return VLC_ENOMEM;
}
- p_filter->p_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
- if( p_filter->p_sys->psz_inner_name )
- p_filter->p_sys->p_opencv->p_module =
- module_need( p_filter->p_sys->p_opencv,
+ p_filter_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" );
+ if( p_filter_sys->psz_inner_name )
+ p_filter_sys->p_opencv->p_module =
+ module_need( p_filter_sys->p_opencv,
"opencv internal filter",
- p_filter->p_sys->psz_inner_name,
+ p_filter_sys->psz_inner_name,
true );
- if( !p_filter->p_sys->p_opencv->p_module )
+ if( !p_filter_sys->p_opencv->p_module )
{
- msg_Err( p_filter, "can't open internal opencv filter: %s", p_filter->p_sys->psz_inner_name );
- free( p_filter->p_sys->psz_inner_name );
- p_filter->p_sys->psz_inner_name = NULL;
- vlc_object_release( p_filter->p_sys->p_opencv );
- free( p_filter->p_sys );
+ msg_Err( p_filter, "can't open internal opencv filter: %s", p_filter_sys->psz_inner_name );
+ free( p_filter_sys->psz_inner_name );
+ p_filter_sys->psz_inner_name = NULL;
+ vlc_object_release( p_filter_sys->p_opencv );
+ free( p_filter_sys );
return VLC_ENOMOD;
}
/* Init structure */
- p_filter->p_sys->p_image = image_HandlerCreate( p_filter );
+ p_filter_sys->p_image = image_HandlerCreate( p_filter );
for( int i = 0; i < VOUT_MAX_PLANES; i++ )
- p_filter->p_sys->p_cv_image[i] = NULL;
- p_filter->p_sys->p_proc_image = NULL;
- p_filter->p_sys->p_to_be_freed = NULL;
- p_filter->p_sys->i_cv_image_size = 0;
+ p_filter_sys->p_cv_image[i] = NULL;
+ p_filter_sys->p_proc_image = NULL;
+ p_filter_sys->p_to_be_freed = NULL;
+ p_filter_sys->i_cv_image_size = 0;
/* Retrieve and apply config */
psz_chroma = var_InheritString( p_filter, "opencv-chroma" );
@@ -207,16 +208,16 @@ static int Create( vlc_object_t *p_this )
{
msg_Err( p_filter, "configuration variable %s empty, using 'grey'",
"opencv-chroma" );
- p_filter->p_sys->i_internal_chroma = GREY;
+ p_filter_sys->i_internal_chroma = GREY;
} else if( !strcmp( psz_chroma, "input" ) )
- p_filter->p_sys->i_internal_chroma = CINPUT;
+ p_filter_sys->i_internal_chroma = CINPUT;
else if( !strcmp( psz_chroma, "I420" ) )
- p_filter->p_sys->i_internal_chroma = GREY;
+ p_filter_sys->i_internal_chroma = GREY;
else if( !strcmp( psz_chroma, "RGB32" ) )
- p_filter->p_sys->i_internal_chroma = RGB;
+ p_filter_sys->i_internal_chroma = RGB;
else {
msg_Err( p_filter, "no valid opencv-chroma provided, using 'grey'" );
- p_filter->p_sys->i_internal_chroma = GREY;
+ p_filter_sys->i_internal_chroma = GREY;
}
free( psz_chroma );
@@ -226,28 +227,28 @@ static int Create( vlc_object_t *p_this )
{
msg_Err( p_filter, "configuration variable %s empty, using 'input'",
"opencv-output" );
- p_filter->p_sys->i_wrapper_output = VINPUT;
+ p_filter_sys->i_wrapper_output = VINPUT;
} else if( !strcmp( psz_output, "none" ) )
- p_filter->p_sys->i_wrapper_output = NONE;
+ p_filter_sys->i_wrapper_output = NONE;
else if( !strcmp( psz_output, "input" ) )
- p_filter->p_sys->i_wrapper_output = VINPUT;
+ p_filter_sys->i_wrapper_output = VINPUT;
else if( !strcmp( psz_output, "processed" ) )
- p_filter->p_sys->i_wrapper_output = PROCESSED;
+ p_filter_sys->i_wrapper_output = PROCESSED;
else {
msg_Err( p_filter, "no valid opencv-output provided, using 'input'" );
- p_filter->p_sys->i_wrapper_output = VINPUT;
+ p_filter_sys->i_wrapper_output = VINPUT;
}
free( psz_output );
- p_filter->p_sys->f_scale =
+ p_filter_sys->f_scale =
var_InheritFloat( p_filter, "opencv-scale" );
msg_Info(p_filter, "Configuration: opencv-scale: %f, opencv-chroma: %d, "
"opencv-output: %d, opencv-filter %s",
- p_filter->p_sys->f_scale,
- p_filter->p_sys->i_internal_chroma,
- p_filter->p_sys->i_wrapper_output,
- p_filter->p_sys->psz_inner_name);
+ p_filter_sys->f_scale,
+ p_filter_sys->i_internal_chroma,
+ p_filter_sys->i_wrapper_output,
+ p_filter_sys->psz_inner_name);
#ifndef NDEBUG
msg_Dbg( p_filter, "opencv_wrapper successfully started" );
@@ -269,11 +270,12 @@ static void Destroy( vlc_object_t *p_this )
ReleaseImages( p_filter );
// Release the internal OpenCV filter.
- module_unneed( p_filter->p_sys->p_opencv, p_filter->p_sys->p_opencv->p_module );
- vlc_object_release( p_filter->p_sys->p_opencv );
- p_filter->p_sys->p_opencv = NULL;
+ auto *p_filter_sys = reinterpret_cast<filter_sys_t*>(p_filter->p_sys);
+ module_unneed( p_filter_sys->p_opencv, p_filter_sys->p_opencv->p_module );
+ vlc_object_release( p_filter_sys->p_opencv );
+ p_filter_sys->p_opencv = NULL;
- free( p_filter->p_sys );
+ free( p_filter_sys );
}
/*****************************************************************************
@@ -281,7 +283,7 @@ static void Destroy( vlc_object_t *p_this )
*****************************************************************************/
static void ReleaseImages( filter_t* p_filter )
{
- filter_sys_t* p_sys = p_filter->p_sys;
+ filter_sys_t* p_sys = reinterpret_cast<filter_sys_t*>(p_filter->p_sys);
for( int i = 0; i < VOUT_MAX_PLANES; i++ )
{
@@ -315,9 +317,9 @@ static void VlcPictureToIplImage( filter_t* p_filter, picture_t* p_in )
{
int planes = p_in->i_planes; //num input video planes
// input video size
- CvSize sz = cvSize(abs(p_in->format.i_width), abs(p_in->format.i_height));
+ CvSize sz = cvSize(abs(static_cast<int>(p_in->format.i_width)), abs(static_cast<int>(p_in->format.i_height)));
video_format_t fmt_out;
- filter_sys_t* p_sys = p_filter->p_sys;
+ filter_sys_t* p_sys = reinterpret_cast<filter_sys_t*>(p_filter->p_sys);
memset( &fmt_out, 0, sizeof(video_format_t) );
@@ -413,20 +415,21 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
video_format_t fmt_out;
// Make a copy if we want to show the original input
- if (p_filter->p_sys->i_wrapper_output == VINPUT)
+ auto *p_filter_sys = reinterpret_cast<filter_sys_t*>(p_filter->p_sys);
+ if (p_filter_sys->i_wrapper_output == VINPUT)
picture_Copy( p_outpic, p_pic );
VlcPictureToIplImage( p_filter, p_pic );
// Pass the image (as a pointer to the first IplImage*) to the
// internal OpenCV filter for processing.
- p_filter->p_sys->p_opencv->pf_video_filter( p_filter->p_sys->p_opencv, (picture_t*)&(p_filter->p_sys->p_cv_image[0]) );
+ p_filter_sys->p_opencv->pf_video_filter( p_filter_sys->p_opencv, (picture_t*)&(p_filter_sys->p_cv_image[0]) );
- if(p_filter->p_sys->i_wrapper_output == PROCESSED) {
+ if(p_filter_sys->i_wrapper_output == PROCESSED) {
// Processed video
- if( (p_filter->p_sys->p_proc_image) &&
- (p_filter->p_sys->p_proc_image->i_planes > 0) &&
- (p_filter->p_sys->i_internal_chroma != CINPUT) ) {
- //p_filter->p_sys->p_proc_image->format.i_chroma = VLC_CODEC_RGB24;
+ if( (p_filter_sys->p_proc_image) &&
+ (p_filter_sys->p_proc_image->i_planes > 0) &&
+ (p_filter_sys->i_internal_chroma != CINPUT) ) {
+ //p_filter_sys->p_proc_image->format.i_chroma = VLC_CODEC_RGB24;
memset( &fmt_out, 0, sizeof(video_format_t) );
fmt_out = p_pic->format;
@@ -438,16 +441,16 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
* main video output error: pictures leaked, trying to workaround
*/
picture_t* p_outpic_tmp = image_Convert(
- p_filter->p_sys->p_image,
- p_filter->p_sys->p_proc_image,
- &(p_filter->p_sys->p_proc_image->format),
+ p_filter_sys->p_image,
+ p_filter_sys->p_proc_image,
+ &(p_filter_sys->p_proc_image->format),
&fmt_out );
picture_CopyPixels( p_outpic, p_outpic_tmp );
CopyInfoAndRelease( p_outpic, p_outpic_tmp );
- } else if( p_filter->p_sys->i_internal_chroma == CINPUT ) {
- picture_CopyPixels( p_outpic, p_filter->p_sys->p_proc_image );
- picture_CopyProperties( p_outpic, p_filter->p_sys->p_proc_image );
+ } else if( p_filter_sys->i_internal_chroma == CINPUT ) {
+ picture_CopyPixels( p_outpic, p_filter_sys->p_proc_image );
+ picture_CopyProperties( p_outpic, p_filter_sys->p_proc_image );
}
}
@@ -458,7 +461,7 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
msg_Dbg( p_filter, "Filter() done" );
#endif
- if( p_filter->p_sys->i_wrapper_output != NONE ) {
+ if( p_filter_sys->i_wrapper_output != NONE ) {
return p_outpic;
} else { // NONE
picture_Release( p_outpic );
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 665e02002a..82130b14cc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1142,7 +1142,7 @@ modules/video_filter/motionblur.c
modules/video_filter/motiondetect.c
modules/video_filter/oldmovie.c
modules/video_filter/opencv_example.cpp
-modules/video_filter/opencv_wrapper.c
+modules/video_filter/opencv_wrapper.cpp
modules/video_filter/posterize.c
modules/video_filter/postproc.c
modules/video_filter/psychedelic.c
--
2.17.0