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 ...
Unified · Split
| @@ -433,8 +433,7 @@ static int create_filtergraph(AVFilterContext *ctx, · 432 unmodified lines | |||
| 433 | if (out->color_trc != s->out_trc) s->out_txchr = NULL; | 433 | if (out->color_trc != s->out_trc) s->out_txchr = NULL; |
| 434 | if (in->colorspace != s->in_csp || | 434 | if (in->colorspace != s->in_csp || |
| 435 | in->color_range != s->in_rng) s->in_lumacoef = NULL; | 435 | in->color_range != s->in_rng) s->in_lumacoef = NULL; |
| 436 | if (out->colorspace != s->out_csp || | 436 | if (out->color_range != s->out_rng) s->rgb2yuv = NULL; |
| 437 | out->color_range != s->out_rng) s->out_lumacoef = NULL; | ||
| 438 | 437 | ||
| 439 | if (!s->out_primaries || !s->in_primaries) { | 438 | if (!s->out_primaries || !s->in_primaries) { |
| 440 | s->in_prm = in->color_primaries; | 439 | s->in_prm = in->color_primaries; |
| @@ -563,26 +562,8 @@ static int create_filtergraph(AVFilterContext *ctx, · 122 unmodified lines | |||
| 563 | redo_yuv2rgb = 1; | 562 | redo_yuv2rgb = 1; |
| 564 | } | 563 | } |
| 565 | 564 | ||
| 566 | if (!s->out_lumacoef) { | 565 | if (!s->rgb2yuv) { |
| 567 | s->out_csp = out->colorspace; | ||
| 568 | s->out_rng = out->color_range; | 566 | s->out_rng = out->color_range; |
| 569 | s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp); | ||
| 570 | if (!s->out_lumacoef) { | ||
| 571 | if (s->out_csp == AVCOL_SPC_UNSPECIFIED) { | ||
| 572 | if (s->user_all == CS_UNSPECIFIED) { | ||
| 573 | av_log(ctx, AV_LOG_ERROR, | ||
| 574 | "Please specify output colorspace\n"); | ||
| 575 | } else { | ||
| 576 | av_log(ctx, AV_LOG_ERROR, | ||
| 577 | "Unsupported output color property %d\n", s->user_all); | ||
| 578 | } | ||
| 579 | } else { | ||
| 580 | av_log(ctx, AV_LOG_ERROR, | ||
| 581 | "Unsupported output colorspace %d (%s)\n", s->out_csp, | ||
| 582 | av_color_space_name(s->out_csp)); | ||
| 583 | } | ||
| 584 | return AVERROR(EINVAL); | ||
| 585 | } | ||
| 586 | redo_rgb2yuv = 1; | 567 | redo_rgb2yuv = 1; |
| 587 | } | 568 | } |
| 588 | 569 | ||
| @@ -687,6 +668,26 @@ static av_cold int init(AVFilterContext *ctx) · 98 unmodified lines | |||
| 687 | { | 668 | { |
| 688 | ColorSpaceContext *s = ctx->priv; | 669 | ColorSpaceContext *s = ctx->priv; |
| 689 | 670 | ||
| 671 | s->out_csp = s->user_csp == AVCOL_SPC_UNSPECIFIED ? | ||
| 672 | default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp; | ||
| 673 | s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp); | ||
| 674 | if (!s->out_lumacoef) { | ||
| 675 | if (s->out_csp == AVCOL_SPC_UNSPECIFIED) { | ||
| 676 | if (s->user_all == CS_UNSPECIFIED) { | ||
| 677 | av_log(ctx, AV_LOG_ERROR, | ||
| 678 | "Please specify output colorspace\n"); | ||
| 679 | } else { | ||
| 680 | av_log(ctx, AV_LOG_ERROR, | ||
| 681 | "Unsupported output color property %d\n", s->user_all); | ||
| 682 | } | ||
| 683 | } else { | ||
| 684 | av_log(ctx, AV_LOG_ERROR, | ||
| 685 | "Unsupported output colorspace %d (%s)\n", s->out_csp, | ||
| 686 | av_color_space_name(s->out_csp)); | ||
| 687 | } | ||
| 688 | return AVERROR(EINVAL); | ||
| 689 | } | ||
| 690 | |||
| 690 | ff_colorspacedsp_init(&s->dsp); | 691 | ff_colorspacedsp_init(&s->dsp); |
| 691 | 692 | ||
| 692 | return 0; | 693 | return 0; |
| @@ -735,6 +736,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 42 unmodified lines | |||
| 735 | return res; | 736 | return res; |
| 736 | } | 737 | } |
| 737 | 738 | ||
| 739 | out->colorspace = s->out_csp; | ||
| 740 | out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ? | ||
| 741 | in->color_range : s->user_rng; | ||
| 738 | out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ? | 742 | out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ? |
| 739 | default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm; | 743 | default_prm[FFMIN(s->user_all, CS_NB)] : s->user_prm; |
| 740 | if (s->user_trc == AVCOL_TRC_UNSPECIFIED) { | 744 | if (s->user_trc == AVCOL_TRC_UNSPECIFIED) { |
| @@ -746,10 +750,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 5 unmodified lines | |||
| 746 | } else { | 750 | } else { |
| 747 | out->color_trc = s->user_trc; | 751 | out->color_trc = s->user_trc; |
| 748 | } | 752 | } |
| 749 | out->colorspace = s->user_csp == AVCOL_SPC_UNSPECIFIED ? | ||
| 750 | default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp; | ||
| 751 | out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ? | ||
| 752 | in->color_range : s->user_rng; | ||
| 753 | if (rgb_sz != s->rgb_sz) { | 753 | if (rgb_sz != s->rgb_sz) { |
| 754 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format); | 754 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format); |
| 755 | int uvw = in->width >> desc->log2_chroma_w; | 755 | int uvw = in->width >> desc->log2_chroma_w; |
| @@ -841,8 +841,18 @@ static int query_formats(AVFilterContext *ctx) · 85 unmodified lines | |||
| 841 | }; | 841 | }; |
| 842 | int res; | 842 | int res; |
| 843 | ColorSpaceContext *s = ctx->priv; | 843 | ColorSpaceContext *s = ctx->priv; |
| 844 | AVFilterLink *outlink = ctx->outputs[0]; | ||
| 844 | AVFilterFormats *formats = ff_make_format_list(pix_fmts); | 845 | AVFilterFormats *formats = ff_make_format_list(pix_fmts); |
| 845 | 846 | ||
| 847 | res = ff_formats_ref(ff_make_formats_list_singleton(s->out_csp), &outlink->incfg.color_spaces); | ||
| 848 | if (res < 0) | ||
| 849 | return res; | ||
| 850 | if (s->user_rng != AVCOL_RANGE_UNSPECIFIED) { | ||
| 851 | res = ff_formats_ref(ff_make_formats_list_singleton(s->user_rng), &outlink->incfg.color_ranges); | ||
| 852 | if (res < 0) | ||
| 853 | return res; | ||
| 854 | } | ||
| 855 | |||
| 846 | if (!formats) | 856 | if (!formats) |
| 847 | return AVERROR(ENOMEM); | 857 | return AVERROR(ENOMEM); |
| 848 | if (s->user_format == AV_PIX_FMT_NONE) | 858 | if (s->user_format == AV_PIX_FMT_NONE) |
| @@ -855,7 +865,7 @@ static int query_formats(AVFilterContext *ctx) · 6 unmodified lines | |||
| 855 | if (res < 0) | 865 | if (res < 0) |
| 856 | return res; | 866 | return res; |
| 857 | 867 | ||
| 858 | return ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats); | 868 | return ff_formats_ref(formats, &outlink->incfg.formats); |
| 859 | } | 869 | } |
| 860 | 870 | ||
| 861 | static int config_props(AVFilterLink *outlink) | 871 | static int config_props(AVFilterLink *outlink) |