diff --git a/src/capture_filter.cpp b/src/capture_filter.cpp index ae508dfb0..5f3288995 100644 --- a/src/capture_filter.cpp +++ b/src/capture_filter.cpp @@ -74,7 +74,7 @@ static int create_filter(struct capture_filter *s, char *cfg) const auto & capture_filters = get_libraries_for_class(LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); for (auto && item : capture_filters) { auto capture_filter_info = static_cast(item.second); - if(strcasecmp(capture_filter_info->name, filter_name) == 0) { + if(strcasecmp(item.first.c_str(), filter_name) == 0) { struct capture_filter_instance *instance = (struct capture_filter_instance *) malloc(sizeof(struct capture_filter_instance)); instance->functions = capture_filter_info; @@ -119,8 +119,7 @@ int capture_filter_init(struct module *parent, const char *cfg, struct capture_f const auto & capture_filters = get_libraries_for_class(LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); printf("Available capture filters:\n"); for (auto && item : capture_filters) { - auto cfi = static_cast(item.second); - printf("\t%s\n", cfi->name); + printf("\t%s\n", item.first.c_str()); } module_done(&s->mod); free(s); diff --git a/src/capture_filter.h b/src/capture_filter.h index 6cb2e7dd9..cd1ed3fc0 100644 --- a/src/capture_filter.h +++ b/src/capture_filter.h @@ -49,7 +49,7 @@ #ifndef CAPTURE_FILTER_H_ #define CAPTURE_FILTER_H_ -#define CAPTURE_FILTER_ABI_VERSION 1 +#define CAPTURE_FILTER_ABI_VERSION 2 #ifdef __cplusplus extern "C" { @@ -58,7 +58,6 @@ extern "C" { struct module; struct capture_filter_info { - const char *name; /// @brief Initializes capture filter /// @param parent parent module /// @param cfg configuration string from cmdline diff --git a/src/capture_filter/blank.cpp b/src/capture_filter/blank.cpp index 2271f922f..1bfeba2fc 100644 --- a/src/capture_filter/blank.cpp +++ b/src/capture_filter/blank.cpp @@ -290,7 +290,6 @@ static struct video_frame *filter(void *state, struct video_frame *in) } static const struct capture_filter_info capture_filter_blank = { - .name = "blank", .init = init, .done = done, .filter = filter, diff --git a/src/capture_filter/every.c b/src/capture_filter/every.c index a2fa5638e..f9c32f23d 100644 --- a/src/capture_filter/every.c +++ b/src/capture_filter/every.c @@ -141,7 +141,6 @@ static struct video_frame *filter(void *state, struct video_frame *in) } static const struct capture_filter_info capture_filter_every = { - .name = "every", .init = init, .done = done, .filter = filter, diff --git a/src/capture_filter/logo.cpp b/src/capture_filter/logo.cpp index afc1d1c21..62bae642e 100644 --- a/src/capture_filter/logo.cpp +++ b/src/capture_filter/logo.cpp @@ -254,7 +254,6 @@ static struct video_frame *filter(void *state, struct video_frame *in) } static const struct capture_filter_info capture_filter_logo = { - "logo", init, done, filter, diff --git a/src/capture_filter/none.c b/src/capture_filter/none.c index 37f1b1e75..51b926b37 100644 --- a/src/capture_filter/none.c +++ b/src/capture_filter/none.c @@ -77,7 +77,6 @@ static struct video_frame *filter(void *state, struct video_frame *in) } static const struct capture_filter_info capture_filter_none = { - .name = "none", .init = init, .done = done, .filter = filter, diff --git a/src/capture_filter/resize.cpp b/src/capture_filter/resize.cpp index 5f198f76f..2aa1bcc2f 100644 --- a/src/capture_filter/resize.cpp +++ b/src/capture_filter/resize.cpp @@ -180,7 +180,6 @@ static struct video_frame *filter(void *state, struct video_frame *in) } static struct capture_filter_info capture_filter_resize = { - "resize", init, done, filter, diff --git a/src/capture_filter/scale.c b/src/capture_filter/scale.c index d61dd4fb6..c023a994e 100644 --- a/src/capture_filter/scale.c +++ b/src/capture_filter/scale.c @@ -120,7 +120,6 @@ static struct video_frame *filter(void *state, struct video_frame *in_frame) } static const struct capture_filter_info capture_filter_scale = { - .name = "scale", .init = init, .done = done, .filter = filter, diff --git a/src/vo_postprocess.c b/src/vo_postprocess.c index d46474e44..829e29e5b 100644 --- a/src/vo_postprocess.c +++ b/src/vo_postprocess.c @@ -59,7 +59,7 @@ extern char **uv_argv; struct vo_postprocess_state { - struct vo_postprocess_info *funcs; + const struct vo_postprocess_info *funcs; void *state; }; @@ -69,7 +69,7 @@ void show_vo_postprocess_help() list_modules(LIBRARY_CLASS_VIDEO_POSTPROCESS, VO_PP_ABI_VERSION); } -struct vo_postprocess_state *vo_postprocess_init(char *config_string) +struct vo_postprocess_state *vo_postprocess_init(const char *config_string) { struct vo_postprocess_state *s; char *vo_postprocess_options = NULL; diff --git a/src/vo_postprocess.h b/src/vo_postprocess.h index d28bd4412..7fd93aa50 100644 --- a/src/vo_postprocess.h +++ b/src/vo_postprocess.h @@ -58,11 +58,11 @@ extern "C" { #define VO_PP_PROPERTY_CODECS 0 /* codec_t[] all uncompressed */ #define VO_PP_DOES_CHANGE_TILING_MODE 1 /* bool false */ -#define VO_PP_ABI_VERSION 4 +#define VO_PP_ABI_VERSION 5 struct vo_postprocess_state; -typedef void *(*vo_postprocess_init_t)(char *cfg); +typedef void *(*vo_postprocess_init_t)(const char *cfg); /** * Reconfigures postprocessor for frame @@ -135,7 +135,7 @@ struct vo_postprocess_info { /** * Semantic and parameters of following functions is same as their typedef counterparts */ -struct vo_postprocess_state *vo_postprocess_init(char *config_string); +struct vo_postprocess_state *vo_postprocess_init(const char *config_string); int vo_postprocess_reconfigure(struct vo_postprocess_state *, struct video_desc); struct video_frame * vo_postprocess_getf(struct vo_postprocess_state *); diff --git a/src/vo_postprocess/3d-interlaced.c b/src/vo_postprocess/3d-interlaced.c index 929706cda..12ec9ba6c 100644 --- a/src/vo_postprocess/3d-interlaced.c +++ b/src/vo_postprocess/3d-interlaced.c @@ -75,7 +75,7 @@ static bool interlaced_3d_get_property(void *state, int property, void *val, siz } -static void * interlaced_3d_init(char *config) { +static void * interlaced_3d_init(const char *config) { struct state_interlaced_3d *s; if(config && strcmp(config, "help") == 0) { diff --git a/src/vo_postprocess/deinterlace.cpp b/src/vo_postprocess/deinterlace.cpp index cedd2d821..13e631ae3 100644 --- a/src/vo_postprocess/deinterlace.cpp +++ b/src/vo_postprocess/deinterlace.cpp @@ -59,7 +59,7 @@ static void usage() printf("\t-p deinterlace\n"); } -static void * deinterlace_init(char *config) { +static void * deinterlace_init(const char *config) { if(config && strcmp(config, "help") == 0) { usage(); return NULL; diff --git a/src/vo_postprocess/double-framerate.c b/src/vo_postprocess/double-framerate.c index 213ea9604..efb6b4802 100644 --- a/src/vo_postprocess/double-framerate.c +++ b/src/vo_postprocess/double-framerate.c @@ -71,7 +71,7 @@ static void usage() printf("-p double_framerate\n"); } -static void * df_init(char *config) { +static void * df_init(const char *config) { struct state_df *s; if(config && strcmp(config, "help") == 0) { diff --git a/src/vo_postprocess/interlace.c b/src/vo_postprocess/interlace.c index a81a74e7f..56616dca3 100644 --- a/src/vo_postprocess/interlace.c +++ b/src/vo_postprocess/interlace.c @@ -76,7 +76,7 @@ static void usage() printf("-p interlace\n"); } -static void * interlace_init(char *config) { +static void * interlace_init(const char *config) { struct state_interlace *s; if(config && strcmp(config, "help") == 0) { diff --git a/src/vo_postprocess/scale.c b/src/vo_postprocess/scale.c index 0191ca7c4..b7f1eed3f 100644 --- a/src/vo_postprocess/scale.c +++ b/src/vo_postprocess/scale.c @@ -100,7 +100,7 @@ static void usage() printf("\t-p scale:width:height\n"); } -static void * scale_init(char *config) { +static void * scale_init(const char *config) { struct state_scale *s; char *save_ptr = NULL; char *ptr; @@ -114,18 +114,21 @@ static void * scale_init(char *config) { return NULL; } + const char *tmp = strdup(config); + s = (struct state_scale *) malloc(sizeof(struct state_scale)); + assert(s != NULL); - - ptr = strtok_r(config, ":", &save_ptr); + ptr = strtok_r(tmp, ":", &save_ptr); assert(ptr != NULL); s->scaled_width = atoi(ptr); assert(ptr != NULL); ptr = strtok_r(NULL, ":", &save_ptr); s->scaled_height = atoi(ptr); - assert(s != NULL); + free(tmp); + s->in = NULL; init_gl_context(&s->context, GL_CONTEXT_LEGACY); diff --git a/src/vo_postprocess/split.c b/src/vo_postprocess/split.c index f92a51a81..df2854160 100644 --- a/src/vo_postprocess/split.c +++ b/src/vo_postprocess/split.c @@ -95,7 +95,7 @@ static void usage() printf("\tsplit to XxY tiles\n"); } -static void * split_init(char *config) { +static void * split_init(const char *config) { struct state_split *s; char *save_ptr = NULL; char *item; @@ -106,17 +106,21 @@ static void * split_init(char *config) { } s = (struct state_split *) malloc(sizeof(struct state_split)); + + char *tmp = strdup(config); - item = strtok_r(config, ":", &save_ptr); + item = strtok_r(tmp, ":", &save_ptr); s->grid_width = atoi(item); - item = strtok_r(config, ":", &save_ptr); + item = strtok_r(NULL, ":", &save_ptr); if(!item) { usage(); free(s); + free(tmp); return NULL; } s->grid_height = atoi(item); + free(tmp); s->in = vf_alloc(1); diff --git a/src/vo_postprocess/text.cpp b/src/vo_postprocess/text.cpp index 91a27857a..0115b4d02 100644 --- a/src/vo_postprocess/text.cpp +++ b/src/vo_postprocess/text.cpp @@ -93,7 +93,7 @@ static void init_text() { } -static void * text_init(char *config) { +static void * text_init(const char *config) { pthread_once(&vo_postprocess_text_initialized, init_text); struct state_text *s; @@ -113,9 +113,7 @@ static void * text_init(char *config) { static int cf_text_init(struct module * /* parent */, const char *cfg, void **state) { - char *tmp = strdup(cfg); - *state = text_init(tmp); - free(tmp); + *state = text_init(cfg); return 0; } @@ -314,7 +312,6 @@ static const struct vo_postprocess_info vo_pp_text_info = { }; static const struct capture_filter_info capture_filter_text_info = { - "text", cf_text_init, text_done, cf_text_filter