From d65df35c8f381c29d2eceaeb4598f46e7502af51 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 27 Aug 2024 09:38:03 +0200 Subject: [PATCH] vo_postprocess_cf_wrapper: get_property callback Allow setting the get_property callback that can be specified for vo_postproess filters. This is optional for the wrapper - if set to nullptr, false will be always returned as until now. --- src/capture_filter/change_pixfmt.c | 2 +- src/capture_filter/color.c | 2 +- src/capture_filter/flip.c | 2 +- src/capture_filter/gamma.cpp | 2 +- src/capture_filter/grayscale.c | 2 +- src/capture_filter/matrix.c | 2 +- src/capture_filter/mirror.c | 2 +- src/capture_filter/override_prop.c | 2 +- src/capture_filter/resize.c | 2 +- src/vo_postprocess/capture_filter_wrapper.h | 14 ++++++++------ 10 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/capture_filter/change_pixfmt.c b/src/capture_filter/change_pixfmt.c index f17762a22e..aed1bfc50a 100644 --- a/src/capture_filter/change_pixfmt.c +++ b/src/capture_filter/change_pixfmt.c @@ -134,7 +134,7 @@ static const struct capture_filter_info capture_filter_change_pixfmt = { }; // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(change_pixfmt, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(change_pixfmt, init, filter, done, vo_pp_set_out_buffer, NULL) REGISTER_MODULE(change_pixfmt, &capture_filter_change_pixfmt, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); diff --git a/src/capture_filter/color.c b/src/capture_filter/color.c index 956b250e20..c4926bcd21 100644 --- a/src/capture_filter/color.c +++ b/src/capture_filter/color.c @@ -123,6 +123,6 @@ static const struct capture_filter_info capture_filter_color = { REGISTER_MODULE(color, &capture_filter_color, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(color, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(color, init, filter, done, vo_pp_set_out_buffer, NULL) /* vim: set expandtab sw=8: */ diff --git a/src/capture_filter/flip.c b/src/capture_filter/flip.c index 83b933ac12..b8e62c7b46 100644 --- a/src/capture_filter/flip.c +++ b/src/capture_filter/flip.c @@ -112,5 +112,5 @@ static const struct capture_filter_info capture_filter_flip = { REGISTER_MODULE(flip, &capture_filter_flip, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(flip, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(flip, init, filter, done, vo_pp_set_out_buffer, NULL) diff --git a/src/capture_filter/gamma.cpp b/src/capture_filter/gamma.cpp index f2f97ac6d2..5ee7ea2fb1 100644 --- a/src/capture_filter/gamma.cpp +++ b/src/capture_filter/gamma.cpp @@ -240,6 +240,6 @@ static const struct capture_filter_info capture_filter_gamma = { REGISTER_MODULE(gamma, &capture_filter_gamma, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(gamma, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(gamma, init, filter, done, vo_pp_set_out_buffer, nullptr) /* vim: set expandtab sw=8: */ diff --git a/src/capture_filter/grayscale.c b/src/capture_filter/grayscale.c index 05c84c107e..8fd22dfb1c 100644 --- a/src/capture_filter/grayscale.c +++ b/src/capture_filter/grayscale.c @@ -119,5 +119,5 @@ static const struct capture_filter_info capture_filter_grayscale = { REGISTER_MODULE(grayscale, &capture_filter_grayscale, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(grayscale, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(grayscale, init, filter, done, vo_pp_set_out_buffer, NULL) diff --git a/src/capture_filter/matrix.c b/src/capture_filter/matrix.c index 7ecdb72144..329f7de3d1 100644 --- a/src/capture_filter/matrix.c +++ b/src/capture_filter/matrix.c @@ -313,6 +313,6 @@ static const struct capture_filter_info capture_filter_matrix = { REGISTER_MODULE(matrix, &capture_filter_matrix, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(matrix, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(matrix, init, filter, done, vo_pp_set_out_buffer, NULL) /* vim: set expandtab sw=8: */ diff --git a/src/capture_filter/mirror.c b/src/capture_filter/mirror.c index ab0b8a688e..192fa92c24 100644 --- a/src/capture_filter/mirror.c +++ b/src/capture_filter/mirror.c @@ -137,5 +137,5 @@ static const struct capture_filter_info capture_filter_mirror = { REGISTER_MODULE(mirror, &capture_filter_mirror, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(mirror, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(mirror, init, filter, done, vo_pp_set_out_buffer, NULL) diff --git a/src/capture_filter/override_prop.c b/src/capture_filter/override_prop.c index 0666fc2581..8b6613426b 100644 --- a/src/capture_filter/override_prop.c +++ b/src/capture_filter/override_prop.c @@ -175,4 +175,4 @@ static const struct capture_filter_info capture_filter_override_prop = { REGISTER_MODULE(override_prop, &capture_filter_override_prop, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(override_prop, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(override_prop, init, filter, done, vo_pp_set_out_buffer, NULL) diff --git a/src/capture_filter/resize.c b/src/capture_filter/resize.c index 29c682b1b1..cf4dbce662 100644 --- a/src/capture_filter/resize.c +++ b/src/capture_filter/resize.c @@ -283,6 +283,6 @@ static const struct capture_filter_info capture_filter_resize = { REGISTER_MODULE(resize, &capture_filter_resize, LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION); // coverity[leaked_storage:SUPPRESS] -ADD_VO_PP_CAPTURE_FILTER_WRAPPER(resize, init, filter, done, vo_pp_set_out_buffer) +ADD_VO_PP_CAPTURE_FILTER_WRAPPER(resize, init, filter, done, vo_pp_set_out_buffer, NULL) /* vim: set expandtab sw=4: */ diff --git a/src/vo_postprocess/capture_filter_wrapper.h b/src/vo_postprocess/capture_filter_wrapper.h index 3758348811..d27039f42c 100644 --- a/src/vo_postprocess/capture_filter_wrapper.h +++ b/src/vo_postprocess/capture_filter_wrapper.h @@ -51,12 +51,13 @@ struct vo_pp_capture_filter_wrapper { void *state; ///< capture filter state + vo_postprocess_get_property_t get_property; struct video_frame *f; }; #define CF_WRAPPER_MERGE(a,b) a##b -#define ADD_VO_PP_CAPTURE_FILTER_WRAPPER(name, init, filter, done, set_out_buf) \ +#define ADD_VO_PP_CAPTURE_FILTER_WRAPPER(name, init, filter, done, set_out_buf, get_prop_callb) \ static void *CF_WRAPPER_MERGE(vo_pp_init_, name)(const char *cfg) {\ void *state;\ if (init(NULL, cfg, &state) != 0) {\ @@ -65,6 +66,7 @@ static void *CF_WRAPPER_MERGE(vo_pp_init_, name)(const char *cfg) {\ struct vo_pp_capture_filter_wrapper *s = (struct vo_pp_capture_filter_wrapper *) \ calloc(1, sizeof(struct vo_pp_capture_filter_wrapper));\ s->state = state;\ + s->get_property = get_prop_callb;\ return s;\ }\ \ @@ -75,11 +77,11 @@ static bool CF_WRAPPER_MERGE(vo_pp_reconfigure_, name)(void *state, struct video }\ \ static bool CF_WRAPPER_MERGE(vo_pp_get_property_, name)(void *state, int property, void *val, size_t *len) {\ - UNUSED(state);\ - UNUSED(property);\ - UNUSED(val);\ - UNUSED(len);\ - return false;\ + struct vo_pp_capture_filter_wrapper *s = (struct vo_pp_capture_filter_wrapper *) state;\ + if (s->get_property == 0) {\ + return false;\ + }\ + return s->get_property(s->state, property, val, len);\ }\ static struct video_frame *CF_WRAPPER_MERGE(vo_pp_getf_, name)(void *state) {\ struct vo_pp_capture_filter_wrapper *s = (struct vo_pp_capture_filter_wrapper *) state;\