* [FFmpeg-devel] [PATCH v4 0/1] avfilter/vf_colorspace: use colorspace negotiation API
@ 2024-04-04 17:05 Nicolas Gaullier
2024-04-04 17:05 ` [FFmpeg-devel] [PATCH v4 1/1] " Nicolas Gaullier
2024-04-17 20:21 ` [FFmpeg-devel] [PATCH v4 0/1] " Niklas Haas
0 siblings, 2 replies; 4+ messages in thread
From: Nicolas Gaullier @ 2024-04-04 17:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nicolas Gaullier
v4:
- remove dynamic color_range pass-through (which requires changing outlink dynamically and is forbidden)
- nits&coding style
- commit msg: simplified example (+ removed example for dynamic color_range pass-through)
Nicolas Gaullier (1):
avfilter/vf_colorspace: use colorspace negotiation API
libavfilter/vf_colorspace.c | 62 +++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 26 deletions(-)
--
2.30.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH v4 1/1] avfilter/vf_colorspace: use colorspace negotiation API
2024-04-04 17:05 [FFmpeg-devel] [PATCH v4 0/1] avfilter/vf_colorspace: use colorspace negotiation API Nicolas Gaullier
@ 2024-04-04 17:05 ` Nicolas Gaullier
2024-04-05 10:38 ` Niklas Haas
2024-04-17 20:21 ` [FFmpeg-devel] [PATCH v4 0/1] " Niklas Haas
1 sibling, 1 reply; 4+ messages in thread
From: Nicolas Gaullier @ 2024-04-04 17:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nicolas Gaullier
Fixes a regression due to the fact that the colorspace filter does
not use the new API introduced by 8c7934f73ab6c568acaa.
The scale filter uses it since 45e09a30419cc2a7251e, and the setparams
filter since 3bf80df3ccd32aed23f0.
Example:
ffprobe -f lavfi yuvtestsrc,setparams=color_primaries=bt470bg:color_trc=
bt470bg:colorspace=bt470bg,colorspace=bt709:range=tv,scale,showinfo
Before:
color_range:unknown color_space:bt470bg ...
After:
color_range:tv color_space:bt709 ...
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
---
libavfilter/vf_colorspace.c | 62 +++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index d181e81ace..7bacd7892a 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -433,8 +433,7 @@ static int create_filtergraph(AVFilterContext *ctx,
if (out->color_trc != s->out_trc) s->out_txchr = NULL;
if (in->colorspace != s->in_csp ||
in->color_range != s->in_rng) s->in_lumacoef = NULL;
- if (out->colorspace != s->out_csp ||
- out->color_range != s->out_rng) s->out_lumacoef = NULL;
+ if (out->color_range != s->out_rng) s->rgb2yuv = NULL;
if (!s->out_primaries || !s->in_primaries) {
s->in_prm = in->color_primaries;
@@ -563,26 +562,8 @@ static int create_filtergraph(AVFilterContext *ctx,
redo_yuv2rgb = 1;
}
- if (!s->out_lumacoef) {
- s->out_csp = out->colorspace;
+ if (!s->rgb2yuv) {
s->out_rng = out->color_range;
- s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
- if (!s->out_lumacoef) {
- if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
- if (s->user_all == CS_UNSPECIFIED) {
- av_log(ctx, AV_LOG_ERROR,
- "Please specify output colorspace\n");
- } else {
- av_log(ctx, AV_LOG_ERROR,
- "Unsupported output color property %d\n", s->user_all);
- }
- } else {
- av_log(ctx, AV_LOG_ERROR,
- "Unsupported output colorspace %d (%s)\n", s->out_csp,
- av_color_space_name(s->out_csp));
- }
- return AVERROR(EINVAL);
- }
redo_rgb2yuv = 1;
}
@@ -687,6 +668,26 @@ static av_cold int init(AVFilterContext *ctx)
{
ColorSpaceContext *s = ctx->priv;
+ s->out_csp = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
+ default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
+ s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
+ if (!s->out_lumacoef) {
+ if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
+ if (s->user_all == CS_UNSPECIFIED) {
+ av_log(ctx, AV_LOG_ERROR,
+ "Please specify output colorspace\n");
+ } else {
+ av_log(ctx, AV_LOG_ERROR,
+ "Unsupported output color property %d\n", s->user_all);
+ }
+ } else {
+ av_log(ctx, AV_LOG_ERROR,
+ "Unsupported output colorspace %d (%s)\n", s->out_csp,
+ av_color_space_name(s->out_csp));
+ }
+ return AVERROR(EINVAL);
+ }
+
ff_colorspacedsp_init(&s->dsp);
return 0;
@@ -735,6 +736,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
return res;
}
+ out->colorspace = s->out_csp;
+ out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
+ in->color_range : s->user_rng;
out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm;
if (s->user_trc == AVCOL_TRC_UNSPECIFIED) {
@@ -746,10 +750,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
} else {
out->color_trc = s->user_trc;
}
- out->colorspace = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
- default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
- out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
- in->color_range : s->user_rng;
if (rgb_sz != s->rgb_sz) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format);
int uvw = in->width >> desc->log2_chroma_w;
@@ -841,8 +841,18 @@ static int query_formats(AVFilterContext *ctx)
};
int res;
ColorSpaceContext *s = ctx->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
AVFilterFormats *formats = ff_make_format_list(pix_fmts);
+ res = ff_formats_ref(ff_make_formats_list_singleton(s->out_csp), &outlink->incfg.color_spaces);
+ if (res < 0)
+ return res;
+ if (s->user_rng != AVCOL_RANGE_UNSPECIFIED) {
+ res = ff_formats_ref(ff_make_formats_list_singleton(s->user_rng), &outlink->incfg.color_ranges);
+ if (res < 0)
+ return res;
+ }
+
if (!formats)
return AVERROR(ENOMEM);
if (s->user_format == AV_PIX_FMT_NONE)
@@ -855,7 +865,7 @@ static int query_formats(AVFilterContext *ctx)
if (res < 0)
return res;
- return ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats);
+ return ff_formats_ref(formats, &outlink->incfg.formats);
}
static int config_props(AVFilterLink *outlink)
--
2.30.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 1/1] avfilter/vf_colorspace: use colorspace negotiation API
2024-04-04 17:05 ` [FFmpeg-devel] [PATCH v4 1/1] " Nicolas Gaullier
@ 2024-04-05 10:38 ` Niklas Haas
0 siblings, 0 replies; 4+ messages in thread
From: Niklas Haas @ 2024-04-05 10:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nicolas Gaullier
On Thu, 04 Apr 2024 19:05:14 +0200 Nicolas Gaullier <nicolas.gaullier@cji.paris> wrote:
> Fixes a regression due to the fact that the colorspace filter does
> not use the new API introduced by 8c7934f73ab6c568acaa.
> The scale filter uses it since 45e09a30419cc2a7251e, and the setparams
> filter since 3bf80df3ccd32aed23f0.
>
> Example:
> ffprobe -f lavfi yuvtestsrc,setparams=color_primaries=bt470bg:color_trc=
> bt470bg:colorspace=bt470bg,colorspace=bt709:range=tv,scale,showinfo
>
> Before:
> color_range:unknown color_space:bt470bg ...
> After:
> color_range:tv color_space:bt709 ...
>
> Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
> ---
> libavfilter/vf_colorspace.c | 62 +++++++++++++++++++++----------------
> 1 file changed, 36 insertions(+), 26 deletions(-)
>
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index d181e81ace..7bacd7892a 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -433,8 +433,7 @@ static int create_filtergraph(AVFilterContext *ctx,
> if (out->color_trc != s->out_trc) s->out_txchr = NULL;
> if (in->colorspace != s->in_csp ||
> in->color_range != s->in_rng) s->in_lumacoef = NULL;
> - if (out->colorspace != s->out_csp ||
> - out->color_range != s->out_rng) s->out_lumacoef = NULL;
> + if (out->color_range != s->out_rng) s->rgb2yuv = NULL;
>
> if (!s->out_primaries || !s->in_primaries) {
> s->in_prm = in->color_primaries;
> @@ -563,26 +562,8 @@ static int create_filtergraph(AVFilterContext *ctx,
> redo_yuv2rgb = 1;
> }
>
> - if (!s->out_lumacoef) {
> - s->out_csp = out->colorspace;
> + if (!s->rgb2yuv) {
> s->out_rng = out->color_range;
> - s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
> - if (!s->out_lumacoef) {
> - if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
> - if (s->user_all == CS_UNSPECIFIED) {
> - av_log(ctx, AV_LOG_ERROR,
> - "Please specify output colorspace\n");
> - } else {
> - av_log(ctx, AV_LOG_ERROR,
> - "Unsupported output color property %d\n", s->user_all);
> - }
> - } else {
> - av_log(ctx, AV_LOG_ERROR,
> - "Unsupported output colorspace %d (%s)\n", s->out_csp,
> - av_color_space_name(s->out_csp));
> - }
> - return AVERROR(EINVAL);
> - }
> redo_rgb2yuv = 1;
> }
>
> @@ -687,6 +668,26 @@ static av_cold int init(AVFilterContext *ctx)
> {
> ColorSpaceContext *s = ctx->priv;
>
> + s->out_csp = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
> + default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
> + s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
> + if (!s->out_lumacoef) {
> + if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
> + if (s->user_all == CS_UNSPECIFIED) {
> + av_log(ctx, AV_LOG_ERROR,
> + "Please specify output colorspace\n");
> + } else {
> + av_log(ctx, AV_LOG_ERROR,
> + "Unsupported output color property %d\n", s->user_all);
> + }
> + } else {
> + av_log(ctx, AV_LOG_ERROR,
> + "Unsupported output colorspace %d (%s)\n", s->out_csp,
> + av_color_space_name(s->out_csp));
> + }
> + return AVERROR(EINVAL);
> + }
> +
> ff_colorspacedsp_init(&s->dsp);
>
> return 0;
> @@ -735,6 +736,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
> return res;
> }
>
> + out->colorspace = s->out_csp;
> + out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
> + in->color_range : s->user_rng;
> out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
> default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm;
> if (s->user_trc == AVCOL_TRC_UNSPECIFIED) {
> @@ -746,10 +750,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
> } else {
> out->color_trc = s->user_trc;
> }
> - out->colorspace = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
> - default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
> - out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
> - in->color_range : s->user_rng;
> if (rgb_sz != s->rgb_sz) {
> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format);
> int uvw = in->width >> desc->log2_chroma_w;
> @@ -841,8 +841,18 @@ static int query_formats(AVFilterContext *ctx)
> };
> int res;
> ColorSpaceContext *s = ctx->priv;
> + AVFilterLink *outlink = ctx->outputs[0];
> AVFilterFormats *formats = ff_make_format_list(pix_fmts);
>
> + res = ff_formats_ref(ff_make_formats_list_singleton(s->out_csp), &outlink->incfg.color_spaces);
> + if (res < 0)
> + return res;
> + if (s->user_rng != AVCOL_RANGE_UNSPECIFIED) {
> + res = ff_formats_ref(ff_make_formats_list_singleton(s->user_rng), &outlink->incfg.color_ranges);
> + if (res < 0)
> + return res;
> + }
> +
> if (!formats)
> return AVERROR(ENOMEM);
> if (s->user_format == AV_PIX_FMT_NONE)
> @@ -855,7 +865,7 @@ static int query_formats(AVFilterContext *ctx)
> if (res < 0)
> return res;
>
> - return ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats);
> + return ff_formats_ref(formats, &outlink->incfg.formats);
> }
>
> static int config_props(AVFilterLink *outlink)
> --
> 2.30.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Seems okay to me now.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 0/1] avfilter/vf_colorspace: use colorspace negotiation API
2024-04-04 17:05 [FFmpeg-devel] [PATCH v4 0/1] avfilter/vf_colorspace: use colorspace negotiation API Nicolas Gaullier
2024-04-04 17:05 ` [FFmpeg-devel] [PATCH v4 1/1] " Nicolas Gaullier
@ 2024-04-17 20:21 ` Niklas Haas
1 sibling, 0 replies; 4+ messages in thread
From: Niklas Haas @ 2024-04-17 20:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Nicolas Gaullier
On Thu, 04 Apr 2024 19:05:13 +0200 Nicolas Gaullier <nicolas.gaullier@cji.paris> wrote:
> v4:
> - remove dynamic color_range pass-through (which requires changing outlink dynamically and is forbidden)
> - nits&coding style
> - commit msg: simplified example (+ removed example for dynamic color_range pass-through)
>
> Nicolas Gaullier (1):
> avfilter/vf_colorspace: use colorspace negotiation API
>
> libavfilter/vf_colorspace.c | 62 +++++++++++++++++++++----------------
> 1 file changed, 36 insertions(+), 26 deletions(-)
>
> --
> 2.30.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Pushed as 376b3d53c54791c1be58709df4303ba2b90851bc
Sorry for the delay; it is really not clear to me who has push rights
and who does not, and whose job it is to merge patches.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-17 20:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 17:05 [FFmpeg-devel] [PATCH v4 0/1] avfilter/vf_colorspace: use colorspace negotiation API Nicolas Gaullier
2024-04-04 17:05 ` [FFmpeg-devel] [PATCH v4 1/1] " Nicolas Gaullier
2024-04-05 10:38 ` Niklas Haas
2024-04-17 20:21 ` [FFmpeg-devel] [PATCH v4 0/1] " Niklas Haas
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git