Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

filter: ensure type safety for the VideoFilter init function

add a function pointer to the FilterInfo struct and use it instead of
using dlsym and a symbol string. Fix many "X is defined but not used"
warnings after the FFmpeg sync (caused by declaring functions static
after `gcc -Werror=missing-prototypes` failed to compile).

git-svn-id: http://svn.mythtv.org/svn/trunk@25811 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
commit 29f275681c05e2f98d0f010c37a990dd1720eaef 1 parent a449cbc
@jannau jannau authored
View
2  mythtv/filters/adjust/filter_adjust.c
@@ -312,7 +312,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "newAdjustFilter",
+ filter_init: &newAdjustFilter,
name: "adjust",
descript: "adjust range and gamma of video",
formats: FmtList,
View
8 mythtv/filters/bobdeint/filter_bobdeint.c
@@ -103,8 +103,10 @@ void bobDtor(VideoFilter *f)
free(filter->tmp_ptr);
}
-VideoFilter *new_filter(VideoFrameType inpixfmt, VideoFrameType outpixfmt,
- int *width, int *height, char *options, int threads)
+static VideoFilter *new_filter(VideoFrameType inpixfmt,
+ VideoFrameType outpixfmt,
+ int *width, int *height, char *options,
+ int threads)
{
BDFilter *filter;
(void)width;
@@ -141,7 +143,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "bobdeint",
descript: "bob deinterlace filter; splits fields to top and bottom of buffer",
formats: FmtList,
View
2  mythtv/filters/convert/filter_convert.c
@@ -159,7 +159,7 @@ static FmtConv FmtList[] =
FilterInfo filter_table[] =
{
{
- symbol: "newConvertFilter",
+ filter_init: &newConvertFilter,
name: "convert",
descript: "converts between various video types",
formats: FmtList,
View
2  mythtv/filters/crop/filter_crop.c
@@ -303,7 +303,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "crop",
descript: "crops picture by macroblock intervals",
formats: FmtList,
View
2  mythtv/filters/denoise3d/filter_denoise3d.c
@@ -473,7 +473,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "NewDenoise3DFilter",
+ filter_init: &NewDenoise3DFilter,
name: "denoise3d",
descript: "removes noise with a spatial and temporal low-pass filter",
formats: FmtList,
View
10 mythtv/filters/fieldorder/filter_fieldorder.c
@@ -193,10 +193,10 @@ static void CleanupFieldorderDeintFilter(VideoFilter * filter)
}
}
-static VideoFilter * FieldorderDeintFilter(VideoFrameType inpixfmt,
- VideoFrameType outpixfmt,
- int *width, int *height,
- char *options)
+static VideoFilter *FieldorderDeintFilter(VideoFrameType inpixfmt,
+ VideoFrameType outpixfmt,
+ int *width, int *height,
+ char *options, int threads)
{
ThisFilter *filter;
(void) height;
@@ -229,7 +229,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "FieldorderDeintFilter",
+ filter_init: &FieldorderDeintFilter,
name: "fieldorderdoubleprocessdeint",
descript: "avoids synchronisation problems when matching an "
"interlaced video mode to an interlaced source",
View
24 mythtv/filters/force/filter_force.c
@@ -6,7 +6,7 @@
#include "filter.h"
#include "frame.h"
-VideoFilter *
+static VideoFilter *
new_force_template (VideoFrameType inpixfmt, VideoFrameType outpixfmt,
VideoFrameType mypixfmt)
{
@@ -26,9 +26,9 @@ new_force_template (VideoFrameType inpixfmt, VideoFrameType outpixfmt,
return filter;
}
-VideoFilter *
+static VideoFilter *
new_force_yv12 (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
- int *height, char *options)
+ int *height, char *options, int threads)
{
(void) width;
(void) height;
@@ -37,9 +37,9 @@ new_force_yv12 (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
return new_force_template (inpixfmt, outpixfmt, FMT_YV12);
}
-VideoFilter *
+static VideoFilter *
new_force_yuv422p (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
- int *height, char *options)
+ int *height, char *options, int threads)
{
(void) width;
(void) height;
@@ -48,9 +48,9 @@ new_force_yuv422p (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width
return new_force_template (inpixfmt, outpixfmt, FMT_YUV422P);
}
-VideoFilter *
+static VideoFilter *
new_force_rgb24 (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
- int *height, char *options)
+ int *height, char *options, int threads)
{
(void) width;
(void) height;
@@ -59,7 +59,7 @@ new_force_rgb24 (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
return new_force_template (inpixfmt, outpixfmt, FMT_RGB24);
}
-VideoFilter *
+static VideoFilter *
new_force_argb32 (VideoFrameType inpixfmt, VideoFrameType outpixfmt, int *width,
int *height, char *options, int threads)
{
@@ -98,28 +98,28 @@ static FmtConv Fmt_List_ARGB32[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_force_yv12",
+ filter_init: &new_force_yv12,
name: "forceyv12",
descript: "forces use of YV12 video format",
formats: Fmt_List_YV12,
libname: NULL
},
{
- symbol: "new_force_yuv422p",
+ filter_init: &new_force_yuv422p,
name: "forceyuv422p",
descript: "forces use of YUV422P video format",
formats: Fmt_List_YUV422P,
libname: NULL
},
{
- symbol: "new_force_rgb24",
+ filter_init: &new_force_rgb24,
name: "forcergb24",
descript: "forces use of RGB24 video format",
formats: Fmt_List_RGB24,
libname: NULL
},
{
- symbol: "new_force_argb32",
+ filter_init: &new_force_argb32,
name: "forceargb32",
descript: "forces use of ARGB32 video format",
formats: Fmt_List_ARGB32,
View
4 mythtv/filters/greedyhdeint/filter_greedyhdeint.c
@@ -275,14 +275,14 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "GreedyHDeintFilter",
+ filter_init: &GreedyHDeintFilter,
name: "greedyhdeint",
descript: "combines data from several fields to deinterlace with less motion blur",
formats: FmtList,
libname: NULL
},
{
- symbol: "GreedyHDeintFilter",
+ filter_init: &GreedyHDeintFilter,
name: "greedyhdoubleprocessdeint",
descript: "combines data from several fields to deinterlace with less motion blur",
formats: FmtList,
View
8 mythtv/filters/invert/filter_invert.c
@@ -38,8 +38,10 @@ int invert(VideoFilter *vf, VideoFrame *frame, int field)
return 0;
}
-VideoFilter *new_filter(VideoFrameType inpixfmt, VideoFrameType outpixfmt,
- int *width, int *height, char *options, int threads)
+static VideoFilter *new_filter(VideoFrameType inpixfmt,
+ VideoFrameType outpixfmt,
+ int *width, int *height, char *options,
+ int threads)
{
ThisFilter *filter;
@@ -77,7 +79,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "invert",
descript: "inverts the colors of the input video",
formats: FmtList,
View
9 mythtv/filters/ivtc/filter_ivtc.c
@@ -190,9 +190,10 @@ static void SetupFilter(ThisFilter *vf, int width, int height, int *pitches)
vf->context->stride[3] = 0;
}
-static VideoFilter *
-NewIvtcFilter (VideoFrameType inpixfmt, VideoFrameType outpixfmt,
- int *width, int *height, char *options, int threads)
+static VideoFilter *NewIvtcFilter(VideoFrameType inpixfmt,
+ VideoFrameType outpixfmt,
+ int *width, int *height, char *options,
+ int threads)
{
(void) threads;
@@ -251,7 +252,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "NewIvtcFilter",
+ filter_init: &NewIvtcFilter,
name: "ivtc",
descript: "inverse telecine filter",
formats: FmtList,
View
4 mythtv/filters/kerneldeint/filter_kerneldeint.c
@@ -663,7 +663,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "NewKernelDeintFilter",
+ filter_init: &NewKernelDeintFilter,
name: "kerneldeint",
descript: "combines data from several fields to deinterlace "
"with less motion blur",
@@ -671,7 +671,7 @@ ConstFilterInfo filter_table[] =
libname: NULL
},
{
- symbol: "NewKernelDeintFilter",
+ filter_init: &NewKernelDeintFilter,
name: "kerneldoubleprocessdeint",
descript: "combines data from several fields to deinterlace "
"with less motion blur",
View
2  mythtv/filters/linearblend/filter_linearblend.c
@@ -370,7 +370,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "linearblend",
descript: "fast blending deinterlace filter",
formats: FmtList,
View
8 mythtv/filters/onefield/filter_onefield.c
@@ -58,8 +58,10 @@ int oneFieldFilter(VideoFilter *f, VideoFrame *frame, int field)
return 0;
}
-VideoFilter *new_filter(VideoFrameType inpixfmt, VideoFrameType outpixfmt,
- int *width, int *height, char *options, int threads)
+static VideoFilter *new_filter(VideoFrameType inpixfmt,
+ VideoFrameType outpixfmt,
+ int *width, int *height, char *options,
+ int threads)
{
OFFilter *filter;
(void)width;
@@ -95,7 +97,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "onefield",
descript: "one-field-only deinterlace filter; parameter \"bottom\" for bottom field, otherwise top",
formats: FmtList,
View
2  mythtv/filters/postprocess/filter_postprocess.c
@@ -136,7 +136,7 @@ FmtConv FmtList[] =
FilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "postprocess",
descript: "FFMPEG's postprocessing filters",
formats: FmtList,
View
2  mythtv/filters/quickdnr/filter_quickdnr.c
@@ -590,7 +590,7 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "new_filter",
+ filter_init: &new_filter,
name: "quickdnr",
descript: "removes noise with a fast single/double thresholded average filter",
formats: FmtList,
View
4 mythtv/filters/yadif/filter_yadif.c
@@ -723,14 +723,14 @@ static FmtConv FmtList[] =
ConstFilterInfo filter_table[] =
{
{
- symbol: "YadifDeintFilter",
+ filter_init: &YadifDeintFilter,
name: "yadifdeint",
descript: "combines data from several fields to deinterlace with less motion blur",
formats: FmtList,
libname: NULL
},
{
- symbol: "YadifDeintFilter",
+ filter_init: &YadifDeintFilter,
name: "yadifdoubleprocessdeint",
descript: "combines data from several fields to deinterlace with less motion blur",
formats: FmtList,
View
12 mythtv/libs/libmythtv/filter.h
@@ -19,9 +19,13 @@ typedef struct FmtConv_
#define FMT_NULL {FMT_NONE,FMT_NONE}
+typedef struct VideoFilter_ VideoFilter;
+
+typedef VideoFilter*(*init_filter)(int, int, int *, int *, char *, int);
+
typedef struct FilterInfo_
{
- char *symbol;
+ init_filter filter_init;
char *name;
char *descript;
FmtConv *formats;
@@ -30,14 +34,14 @@ typedef struct FilterInfo_
typedef struct ConstFilterInfo_
{
- const char *symbol;
+ const init_filter filter_init;
const char *name;
const char *descript;
const FmtConv *formats;
const char *libname;
} ConstFilterInfo;
-typedef struct VideoFilter_
+struct VideoFilter_
{
int (*filter)(struct VideoFilter_ *, VideoFrame *, int);
void (*cleanup)(struct VideoFilter_ *);
@@ -47,7 +51,7 @@ typedef struct VideoFilter_
VideoFrameType outpixfmt;
char *opts;
FilterInfo *info;
-} VideoFilter;
+};
#define FILT_NULL {NULL,NULL,NULL,NULL,NULL}
View
31 mythtv/libs/libmythtv/filtermanager.cpp
@@ -103,7 +103,6 @@ FilterManager::~FilterManager()
FilterInfo *tmp = itf->second;
itf->second = NULL;
- free(tmp->symbol);
free(tmp->name);
free(tmp->descript);
free(tmp->libname);
@@ -156,13 +155,13 @@ bool FilterManager::LoadFilterLib(const QString &path)
return false;
}
- for (; filtInfo->symbol; filtInfo++)
+ for (; filtInfo->filter_init; filtInfo++)
{
- if (!filtInfo->symbol || !filtInfo->name || !filtInfo->formats)
+ if (!filtInfo->filter_init || !filtInfo->name || !filtInfo->formats)
break;
FilterInfo *newFilter = new FilterInfo;
- newFilter->symbol = strdup(filtInfo->symbol);
+ newFilter->filter_init = NULL;
newFilter->name = strdup(filtInfo->name);
newFilter->descript = strdup(filtInfo->descript);
@@ -495,7 +494,6 @@ VideoFilter * FilterManager::LoadFilter(const FilterInfo *FiltInfo,
{
void *handle;
VideoFilter *Filter;
- VideoFilter *(*InitFilter)(int, int, int *, int *, char *, int);
if (FiltInfo == NULL)
{
@@ -511,13 +509,6 @@ VideoFilter * FilterManager::LoadFilter(const FilterInfo *FiltInfo,
return NULL;
}
- if (FiltInfo->symbol == NULL)
- {
- VERBOSE(VB_IMPORTANT, "FilterManager: LoadFilter called with invalid "
- "FilterInfo (symbol is NULL)");
- return NULL;
- }
-
handle = dlopen(FiltInfo->libname, RTLD_NOW);
if (!handle)
@@ -529,24 +520,22 @@ VideoFilter * FilterManager::LoadFilter(const FilterInfo *FiltInfo,
return NULL;
}
- InitFilter =
- (VideoFilter * (*)(int, int, int *, int *, char *, int))dlsym(handle,
- FiltInfo->
- symbol);
+ const ConstFilterInfo *filtInfo
+ = (const ConstFilterInfo*)dlsym(handle, "filter_table");
- if (!InitFilter)
+ if (!filtInfo || !filtInfo->filter_init)
{
- VERBOSE(VB_IMPORTANT, QString("FilterManager: unable to load symbol "
+ VERBOSE(VB_IMPORTANT, QString("FilterManager: unable to load filter "
"'%1' from shared library '%2', dlopen reports error '%3'")
- .arg(FiltInfo->symbol)
+ .arg(FiltInfo->name)
.arg(FiltInfo->libname)
.arg(dlerror()));
dlclose(handle);
return NULL;
}
- Filter = (*InitFilter)(inpixfmt, outpixfmt, &width, &height,
- const_cast<char*>(opts), max_threads);
+ Filter = filtInfo->filter_init(inpixfmt, outpixfmt, &width, &height,
+ const_cast<char*>(opts), max_threads);
if (Filter == NULL)
{
Please sign in to comment.
Something went wrong with that request. Please try again.