[FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2022-12-27 Thread Jeffrey CHAPUIS
Hello, first attempt to contribute. Related to https://trac.ffmpeg.org/ticket/9851. Tested with ffmpeg and mpv, amazing results. Signed-off-by: Ashyni --- doc/filters.texi | 13 + libavfilter/vf_cropdetect.c| 42 +-- tests/ref/fate/fil

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2022-12-27 Thread Jeffrey CHAPUIS
Resend whithout line wrap. Signed-off-by: Ashyni --- doc/filters.texi | 13 + libavfilter/vf_cropdetect.c| 42 +-- tests/ref/fate/filter-metadata-cropdetect | 60 +++--- tests/ref/fate/filter-metadata-cropdetect1 | 14 ++

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2022-12-27 Thread Jeffrey CHAPUIS
You could just call ff_filter_process_command() instead of hardcoding supported commands here. It will ignore any option without the AV_OPT_FLAG_RUNTIME_PARAM flag. This is going to generate memleaks, and needlessly reallocate unrelated buffers. You should instead av_realloc all four s->bb

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2022-12-28 Thread Jeffrey CHAPUIS
Updated working patch with ff_filter_process_command and no memory leaks. Signed-off-by: Ashyni --- doc/filters.texi | 13 + libavfilter/vf_cropdetect.c| 15 -- tests/ref/fate/filter-metadata-cropdetect | 60 +++--- tests/ref/fa

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2022-12-28 Thread Jeffrey CHAPUIS
You need a custom function that will keep old values around and realloc the buffers for bboxes using the new reset_count value passed as a runtime command, but one that will not call config_input() like you did the first time as that one does a lot more than what you need. It should also cal

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-10 Thread Jeffrey CHAPUIS
Hello, I decided to continue on a simpler path without 'reset/reset_count', it was only to experiment anyway, 'limit' is the main goal. 'limit' is added to the metadata to control that the result is associated to a change at runtime, it's after scaling with bitdetph but that's not really a probl

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-11 Thread Jeffrey Chapuis
Here is part of the updated patch, 'limit' exposed in metadata/log is now coherent with init(). Like 'limit/limit_user' is of type float, i've used what's done in av_dict_set_int() to print it as float. Compare 's->limit_user' and 's->limit' to check for a change instead of 'strcmp'. Is there an

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-11 Thread Jeffrey Chapuis
>Here is part of the updated patch, 'limit' exposed in metadata/log is now >coherent with init(). >Like 'limit/limit_user' is of type float, i've used what's done in >av_dict_set_int() to print it as float. >Compare 's->limit_user' and 's->limit' to check for a change instead of >'strcmp'. >Is t

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-12 Thread Jeffrey Chapuis
Le 10/01/2023 à 16:45, Paul B Mahol a écrit : > On 1/10/23, Jeffrey CHAPUIS wrote: >> Hello, >> I decided to continue on a simpler path without 'reset/reset_count', it was >> only to experiment anyway, 'limit' is the main goal. >> 'limit

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
>Le 10/01/2023 à 16:45, Paul B Mahol a écrit : >> On 1/10/23, Jeffrey CHAPUIS wrote: >>> Hello, >>> I decided to continue on a simpler path without 'reset/reset_count', it was >>> only to experiment anyway, 'limit' is the main goal. >>

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
On 17/01/2023 12:52, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >>> Le 10/01/2023 à 16:45, Paul B Mahol a écrit : >>>> On 1/10/23, Jeffrey CHAPUIS wrote: >>>>> Hello, >>>>> I decided to continue on a simpler path without 

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
On 17/01/2023 13:34, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >> On 17/01/2023 12:52, Paul B Mahol wrote: >>> On 1/17/23, Jeffrey Chapuis wrote: >>>>> Le 10/01/2023 à 16:45, Paul B Mahol a écrit : >>>>>> On 1/10/23, Jeffrey

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
On 17/01/2023 14:45, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >> On 17/01/2023 13:34, Paul B Mahol wrote: >>> On 1/17/23, Jeffrey Chapuis wrote: >>>> On 17/01/2023 12:52, Paul B Mahol wrote: >>>>> On 1/17/23, Jeffrey Chapuis wrote:

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
On 17/01/2023 15:29, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >> On 17/01/2023 14:45, Paul B Mahol wrote: >>> On 1/17/23, Jeffrey Chapuis wrote: >>>> On 17/01/2023 13:34, Paul B Mahol wrote: >>>>> On 1/17/23, Jeffrey Chapuis wrote: &

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
I'm getting there, don't give up on me. Now 'limit_upscaled' become the variable used in filter_frame() and 'limit' is never change, unless by user We only have to update 'limit_upscaled' if 'limit' really changes.From 866ddedf0225582d1c82514463d0730d687d514c Mon Sep 17 00:00:00 2001 From: Ashyni

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-17 Thread Jeffrey Chapuis
On 17/01/2023 19:11, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >> I'm getting there, don't give up on me. >> >> Now 'limit_upscaled' become the variable used in filter_frame() and >> 'limit' is never change, unless by

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-19 Thread Jeffrey Chapuis
On 17/01/2023 19:11, Paul B Mahol wrote: > On 1/17/23, Jeffrey Chapuis wrote: >> I'm getting there, don't give up on me. >> >> Now 'limit_upscaled' become the variable used in filter_frame() and >> 'limit' is never change, unless by

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: add ability to change limit/reset at runtime

2023-01-19 Thread Jeffrey Chapuis
>On 17/01/2023 19:11, Paul B Mahol wrote: >> On 1/17/23, Jeffrey Chapuis wrote: >>> I'm getting there, don't give up on me. >>> >>> Now 'limit_upscaled' become the variable used in filter_frame() and >>> 'limit' is never c

[FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: fix type for old_limit

2023-01-27 Thread Jeffrey Chapuis
old_limit is of type float like limit, sorry about that. Signed-off-by: Ashyni --- libavfilter/vf_cropdetect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 724047f864..56457ee90b 100644 --- a/libavfilter/vf_cr

Re: [FFmpeg-devel] [PATCH] avfilter/vf_cropdetect: fix type for old_limit

2023-01-27 Thread Jeffrey Chapuis
patch attached.From 555e1a9f45c99a3e3d15225c17bd98d52855a03d Mon Sep 17 00:00:00 2001 From: Ashyni Date: Fri, 27 Jan 2023 14:20:50 +0100 Subject: [PATCH] avfilter/vf_cropdetect: fix type for old_limit Signed-off-by: Ashyni --- libavfilter/vf_cropdetect.c | 2 +- 1 file changed, 1 insertion(+),