Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-12-26 Thread Paul B Mahol
On 12/13/22, Soft Works  wrote:
> Another Ping

Please confirm that this still applies without issues,
otherwise provide new patches for this feature so i can apply it.

>
> Thanks,
> softworkz
>
>> -Original Message-
>> From: Paul B Mahol 
>> Sent: Thursday, November 3, 2022 10:58 AM
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>
>> Cc: softworkz 
>> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add
>> avfilter_print_config_formats()
>>
>> On 10/11/22, softworkz  wrote:
>> > From: softworkz 
>> >
>> > Prints the following to AVBPrint:
>> >
>> > For pass-through filter links:
>> >
>> > "All (passthrough)"
>> >
>> > For filters using query_formats:
>> >
>> > "Dynamic"
>> >
>> > For filters using query_formats where a call to query_formats
>> > succeeds (example):
>> >
>> > "Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"
>> >
>> > For all other filters (example):
>> >
>> > "[s16p, s32p, fltp, dblp]"
>> >
>> > Except in case when the number of formats equals the number of
>> > available formats:
>> >
>> > "All"
>> >
>> > Signed-off-by: softworkz 
>> > ---
>> >  doc/APIchanges  |   3 ++
>> >  libavfilter/avfilter.c  | 102
>> +++-
>> >  libavfilter/avfilter.h  |  12 +
>> >  libavfilter/avfiltergraph.c |  14 +++--
>> >  libavfilter/internal.h  |   9 
>> >  libavfilter/version.h   |   4 +-
>> >  6 files changed, 136 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/doc/APIchanges b/doc/APIchanges
>> > index cbb579612e..6e2a528b04 100644
>> > --- a/doc/APIchanges
>> > +++ b/doc/APIchanges
>> > @@ -14,6 +14,9 @@ libavutil: 2021-04-27
>> >
>> >  API changes, most recent first:
>> >
>> > +2022-10-11 - xx - lavf 59.50.100 - avfilter.h
>> > +  Add add avfilter_print_config_formats().
>> > +
>> >  2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
>> >Add AV_CPU_FLAG_RVB_BASIC.
>> >
>> > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
>> > index cc5505e65b..8cc665e19c 100644
>> > --- a/libavfilter/avfilter.c
>> > +++ b/libavfilter/avfilter.c
>> > @@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
>> >  av_freep(link);
>> >  }
>> >
>> > +static unsigned get_nb_pix_fmts()
>> > +{
>> > +unsigned i = 0;
>> > +while (av_pix_fmt_desc_get(i++)) {}
>> > +return i - 1;
>> > +}
>> > +
>> > +static unsigned get_nb_sample_fmts()
>> > +{
>> > +unsigned i = 0;
>> > +while (av_get_sample_fmt_name(i++)) {}
>> > +return i - 1;
>> > +}
>> > +
>> > +int avfilter_print_config_formats(AVBPrint *bp, const struct
>> AVFilter
>> > *filter, int for_output, unsigned pad_index)
>> > +{
>> > +AVFilterGraph *graph;
>> > +AVFilterContext *filter_context;
>> > +AVFilterFormatsConfig *config;
>> > +enum AVMediaType media_type;
>> > +int ret = 0;
>> > +
>> > +if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
>> > +av_bprintf(bp, "All (passthrough)");
>> > +return 0;
>> > +}
>> > +
>> > +graph = avfilter_graph_alloc();
>> > +if (!graph) {
>> > +av_log(NULL, AV_LOG_ERROR, "Failed to create
>> filtergraph\n");
>> > +ret = AVERROR(ENOMEM);
>> > +goto cleanup;
>> > +}
>> > +
>> > +filter_context = avfilter_graph_alloc_filter(graph, filter,
>> "filter");
>> > +if (!filter_context) {
>> > +av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
>> > +ret = AVERROR(ENOMEM);
>> > +goto cleanup;
>> > +}
>> > +
>> > +avfilter_init_str(filter_context, NULL);
>> > +
>> > +if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
>> > +av_bprintf(bp, "Dynamic");
>> > +
>> > +if (!for_output && pad_index >= filter_context->nb_inputs
>> > +   

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-12-12 Thread Soft Works
Another Ping

Thanks,
softworkz

> -Original Message-
> From: Paul B Mahol 
> Sent: Thursday, November 3, 2022 10:58 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: softworkz 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add
> avfilter_print_config_formats()
> 
> On 10/11/22, softworkz  wrote:
> > From: softworkz 
> >
> > Prints the following to AVBPrint:
> >
> > For pass-through filter links:
> >
> > "All (passthrough)"
> >
> > For filters using query_formats:
> >
> > "Dynamic"
> >
> > For filters using query_formats where a call to query_formats
> > succeeds (example):
> >
> > "Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"
> >
> > For all other filters (example):
> >
> > "[s16p, s32p, fltp, dblp]"
> >
> > Except in case when the number of formats equals the number of
> > available formats:
> >
> > "All"
> >
> > Signed-off-by: softworkz 
> > ---
> >  doc/APIchanges  |   3 ++
> >  libavfilter/avfilter.c  | 102
> +++-
> >  libavfilter/avfilter.h  |  12 +
> >  libavfilter/avfiltergraph.c |  14 +++--
> >  libavfilter/internal.h  |   9 
> >  libavfilter/version.h   |   4 +-
> >  6 files changed, 136 insertions(+), 8 deletions(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index cbb579612e..6e2a528b04 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -14,6 +14,9 @@ libavutil: 2021-04-27
> >
> >  API changes, most recent first:
> >
> > +2022-10-11 - xx - lavf 59.50.100 - avfilter.h
> > +  Add add avfilter_print_config_formats().
> > +
> >  2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
> >Add AV_CPU_FLAG_RVB_BASIC.
> >
> > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> > index cc5505e65b..8cc665e19c 100644
> > --- a/libavfilter/avfilter.c
> > +++ b/libavfilter/avfilter.c
> > @@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
> >  av_freep(link);
> >  }
> >
> > +static unsigned get_nb_pix_fmts()
> > +{
> > +unsigned i = 0;
> > +while (av_pix_fmt_desc_get(i++)) {}
> > +return i - 1;
> > +}
> > +
> > +static unsigned get_nb_sample_fmts()
> > +{
> > +unsigned i = 0;
> > +while (av_get_sample_fmt_name(i++)) {}
> > +return i - 1;
> > +}
> > +
> > +int avfilter_print_config_formats(AVBPrint *bp, const struct
> AVFilter
> > *filter, int for_output, unsigned pad_index)
> > +{
> > +AVFilterGraph *graph;
> > +AVFilterContext *filter_context;
> > +AVFilterFormatsConfig *config;
> > +enum AVMediaType media_type;
> > +int ret = 0;
> > +
> > +if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
> > +av_bprintf(bp, "All (passthrough)");
> > +return 0;
> > +}
> > +
> > +graph = avfilter_graph_alloc();
> > +if (!graph) {
> > +av_log(NULL, AV_LOG_ERROR, "Failed to create
> filtergraph\n");
> > +ret = AVERROR(ENOMEM);
> > +goto cleanup;
> > +}
> > +
> > +filter_context = avfilter_graph_alloc_filter(graph, filter,
> "filter");
> > +if (!filter_context) {
> > +av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
> > +ret = AVERROR(ENOMEM);
> > +goto cleanup;
> > +}
> > +
> > +avfilter_init_str(filter_context, NULL);
> > +
> > +if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
> > +av_bprintf(bp, "Dynamic");
> > +
> > +if (!for_output && pad_index >= filter_context->nb_inputs
> > +|| for_output && pad_index >= filter_context->nb_outputs)
> > +goto cleanup;
> > +
> > +avfilter_graph_config(graph, graph);
> > +
> > +for (unsigned i = 0; i < filter_context->nb_inputs; i++)
> > +filter_context->inputs[i] = (AVFilterLink
> > *)av_mallocz(sizeof(AVFilterLink));
> > +
> > +for (unsigned i = 0; i < filter_context->nb_outputs; i++)
> > +filter_context->outputs[i] = (AVFilterLink
> > *)av_mallocz(sizeof(AVFilterLink));
> > +
> > +ff_filter_query_formats(filter_context);
> > +
>

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-11-03 Thread Soft Works



> -Original Message-
> From: Paul B Mahol 
> Sent: Thursday, November 3, 2022 10:58 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: softworkz 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add
> avfilter_print_config_formats()
> 
> On 10/11/22, softworkz  wrote:
> > From: softworkz 
> >
> > Prints the following to AVBPrint:
> >
> > For pass-through filter links:
> >
> > "All (passthrough)"
> >
> > For filters using query_formats:
> >
> > "Dynamic"
> >
> > For filters using query_formats where a call to query_formats
> > succeeds (example):
> >
> > "Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"
> >
> > For all other filters (example):
> >
> > "[s16p, s32p, fltp, dblp]"
> >
> > Except in case when the number of formats equals the number of
> > available formats:
> >
> > "All"
> >
> > Signed-off-by: softworkz 
> > ---
> >  doc/APIchanges  |   3 ++
> >  libavfilter/avfilter.c  | 102
> +++-
> >  libavfilter/avfilter.h  |  12 +
> >  libavfilter/avfiltergraph.c |  14 +++--
> >  libavfilter/internal.h  |   9 
> >  libavfilter/version.h   |   4 +-
> >  6 files changed, 136 insertions(+), 8 deletions(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index cbb579612e..6e2a528b04 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -14,6 +14,9 @@ libavutil: 2021-04-27
> >
> >  API changes, most recent first:
> >
> > +2022-10-11 - xx - lavf 59.50.100 - avfilter.h
> > +  Add add avfilter_print_config_formats().
> > +
> >  2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
> >Add AV_CPU_FLAG_RVB_BASIC.
> >
> > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> > index cc5505e65b..8cc665e19c 100644
> > --- a/libavfilter/avfilter.c
> > +++ b/libavfilter/avfilter.c
> > @@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
> >  av_freep(link);
> >  }
> >
> > +static unsigned get_nb_pix_fmts()
> > +{
> > +unsigned i = 0;
> > +while (av_pix_fmt_desc_get(i++)) {}
> > +return i - 1;
> > +}
> > +
> > +static unsigned get_nb_sample_fmts()
> > +{
> > +unsigned i = 0;
> > +while (av_get_sample_fmt_name(i++)) {}
> > +return i - 1;
> > +}
> > +
> > +int avfilter_print_config_formats(AVBPrint *bp, const struct
> AVFilter
> > *filter, int for_output, unsigned pad_index)
> > +{
> > +AVFilterGraph *graph;
> > +AVFilterContext *filter_context;
> > +AVFilterFormatsConfig *config;
> > +enum AVMediaType media_type;
> > +int ret = 0;
> > +
> > +if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
> > +av_bprintf(bp, "All (passthrough)");
> > +return 0;
> > +}
> > +
> > +graph = avfilter_graph_alloc();
> > +if (!graph) {
> > +av_log(NULL, AV_LOG_ERROR, "Failed to create
> filtergraph\n");
> > +ret = AVERROR(ENOMEM);
> > +goto cleanup;
> > +}
> > +
> > +filter_context = avfilter_graph_alloc_filter(graph, filter,
> "filter");
> > +if (!filter_context) {
> > +av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
> > +ret = AVERROR(ENOMEM);
> > +goto cleanup;
> > +}
> > +
> > +avfilter_init_str(filter_context, NULL);
> > +
> > +if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
> > +av_bprintf(bp, "Dynamic");
> > +
> > +if (!for_output && pad_index >= filter_context->nb_inputs
> > +|| for_output && pad_index >= filter_context->nb_outputs)
> > +goto cleanup;
> > +
> > +avfilter_graph_config(graph, graph);
> > +
> > +for (unsigned i = 0; i < filter_context->nb_inputs; i++)
> > +filter_context->inputs[i] = (AVFilterLink
> > *)av_mallocz(sizeof(AVFilterLink));
> > +
> > +for (unsigned i = 0; i < filter_context->nb_outputs; i++)
> > +filter_context->outputs[i] = (AVFilterLink
> > *)av_mallocz(sizeof(AVFilterLink));
> > +
> > +ff_filter_query_formats(filter_context);
> > +
> > +config = for_outpu

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/avfilter: add avfilter_print_config_formats()

2022-11-03 Thread Paul B Mahol
On 10/11/22, softworkz  wrote:
> From: softworkz 
>
> Prints the following to AVBPrint:
>
> For pass-through filter links:
>
> "All (passthrough)"
>
> For filters using query_formats:
>
> "Dynamic"
>
> For filters using query_formats where a call to query_formats
> succeeds (example):
>
> "Dynamic, Defaults: [yuv420p, yuvj420p, yuva420p, nv12, nv21]"
>
> For all other filters (example):
>
> "[s16p, s32p, fltp, dblp]"
>
> Except in case when the number of formats equals the number of
> available formats:
>
> "All"
>
> Signed-off-by: softworkz 
> ---
>  doc/APIchanges  |   3 ++
>  libavfilter/avfilter.c  | 102 +++-
>  libavfilter/avfilter.h  |  12 +
>  libavfilter/avfiltergraph.c |  14 +++--
>  libavfilter/internal.h  |   9 
>  libavfilter/version.h   |   4 +-
>  6 files changed, 136 insertions(+), 8 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index cbb579612e..6e2a528b04 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,9 @@ libavutil: 2021-04-27
>
>  API changes, most recent first:
>
> +2022-10-11 - xx - lavf 59.50.100 - avfilter.h
> +  Add add avfilter_print_config_formats().
> +
>  2022-10-05 - 37d5ddc317 - lavu 57.39.100 - cpu.h
>Add AV_CPU_FLAG_RVB_BASIC.
>
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index cc5505e65b..8cc665e19c 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -196,6 +196,104 @@ void avfilter_link_free(AVFilterLink **link)
>  av_freep(link);
>  }
>
> +static unsigned get_nb_pix_fmts()
> +{
> +unsigned i = 0;
> +while (av_pix_fmt_desc_get(i++)) {}
> +return i - 1;
> +}
> +
> +static unsigned get_nb_sample_fmts()
> +{
> +unsigned i = 0;
> +while (av_get_sample_fmt_name(i++)) {}
> +return i - 1;
> +}
> +
> +int avfilter_print_config_formats(AVBPrint *bp, const struct AVFilter
> *filter, int for_output, unsigned pad_index)
> +{
> +AVFilterGraph *graph;
> +AVFilterContext *filter_context;
> +AVFilterFormatsConfig *config;
> +enum AVMediaType media_type;
> +int ret = 0;
> +
> +if (filter->formats_state == FF_FILTER_FORMATS_PASSTHROUGH) {
> +av_bprintf(bp, "All (passthrough)");
> +return 0;
> +}
> +
> +graph = avfilter_graph_alloc();
> +if (!graph) {
> +av_log(NULL, AV_LOG_ERROR, "Failed to create filtergraph\n");
> +ret = AVERROR(ENOMEM);
> +goto cleanup;
> +}
> +
> +filter_context = avfilter_graph_alloc_filter(graph, filter, "filter");
> +if (!filter_context) {
> +av_log(NULL, AV_LOG_ERROR, "Failed to create filter\n");
> +ret = AVERROR(ENOMEM);
> +goto cleanup;
> +}
> +
> +avfilter_init_str(filter_context, NULL);
> +
> +if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
> +av_bprintf(bp, "Dynamic");
> +
> +if (!for_output && pad_index >= filter_context->nb_inputs
> +|| for_output && pad_index >= filter_context->nb_outputs)
> +goto cleanup;
> +
> +avfilter_graph_config(graph, graph);
> +
> +for (unsigned i = 0; i < filter_context->nb_inputs; i++)
> +filter_context->inputs[i] = (AVFilterLink
> *)av_mallocz(sizeof(AVFilterLink));
> +
> +for (unsigned i = 0; i < filter_context->nb_outputs; i++)
> +filter_context->outputs[i] = (AVFilterLink
> *)av_mallocz(sizeof(AVFilterLink));
> +
> +ff_filter_query_formats(filter_context);
> +
> +config = for_output ? _context->outputs[pad_index]->incfg :
> _context->inputs[pad_index]->outcfg;
> +
> +if (!config || !config->formats)
> +goto cleanup;
> +
> +media_type= for_output ? filter->outputs[pad_index].type :
> filter->inputs[pad_index].type;
> +
> +if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) {
> +if (config->formats && config->formats->nb_formats)
> +av_bprintf(bp, ", Default: ");
> +}
> +
> +if (config->formats == NULL)
> +av_bprintf(bp, "unknown");
> +else if (media_type == AVMEDIA_TYPE_VIDEO &&
> config->formats->nb_formats == get_nb_pix_fmts() ||
> + media_type == AVMEDIA_TYPE_AUDIO &&
> config->formats->nb_formats == get_nb_sample_fmts())
> +av_bprintf(bp, "All");
> +else {
> +for (unsigned i = 0; i < config->formats->nb_formats; i++) {
> +if (i == 0)
> +av_bprintf(bp, "[");
> +
> +if (media_type == AVMEDIA_TYPE_VIDEO)
> +av_bprintf(bp, "%s",
> av_get_pix_fmt_name(config->formats->formats[i]));
> +else if (media_type == AVMEDIA_TYPE_AUDIO)
> +av_bprintf(bp, "%s",
> av_get_sample_fmt_name(config->formats->formats[i]));
> +
> +if (i < config->formats->nb_formats - 1)
> +av_bprintf(bp, ", ");
> +else
> +av_bprintf(bp, "]");}
> +}
> +
> +cleanup:
> +avfilter_graph_free();
> +return