mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-11 17:30:00 +01:00
avfilter/vf_fade: set correct alpha mode requirement
Fading to black in non-alpha mode works for either straight or premultiplied alpha, but fading to a color does not.
This commit is contained in:
@@ -151,19 +151,36 @@ static int query_formats(const AVFilterContext *ctx,
|
|||||||
AV_PIX_FMT_GBRAP,
|
AV_PIX_FMT_GBRAP,
|
||||||
AV_PIX_FMT_NONE
|
AV_PIX_FMT_NONE
|
||||||
};
|
};
|
||||||
|
const static int straight_alpha[] = {
|
||||||
|
AVALPHA_MODE_UNSPECIFIED,
|
||||||
|
AVALPHA_MODE_STRAIGHT,
|
||||||
|
-1,
|
||||||
|
};
|
||||||
const enum AVPixelFormat *pixel_fmts;
|
const enum AVPixelFormat *pixel_fmts;
|
||||||
|
int need_straight = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (s->alpha) {
|
if (s->alpha) {
|
||||||
if (s->black_fade)
|
if (s->black_fade)
|
||||||
pixel_fmts = pix_fmts_alpha;
|
pixel_fmts = pix_fmts_alpha;
|
||||||
else
|
else
|
||||||
pixel_fmts = pix_fmts_rgba;
|
pixel_fmts = pix_fmts_rgba;
|
||||||
|
need_straight = 1;
|
||||||
} else {
|
} else {
|
||||||
if (s->black_fade)
|
if (s->black_fade)
|
||||||
pixel_fmts = pix_fmts;
|
pixel_fmts = pix_fmts;
|
||||||
else
|
else {
|
||||||
pixel_fmts = pix_fmts_rgb;
|
pixel_fmts = pix_fmts_rgb;
|
||||||
|
need_straight = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_straight) {
|
||||||
|
ret = ff_set_common_alpha_modes_from_list2(ctx, cfg_in, cfg_out, straight_alpha);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pixel_fmts);
|
return ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pixel_fmts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user