mirror of https://github.com/mpv-player/mpv
vf_scale: libswscale is being stupid
This time (there are a lot of times), libswscale randomly ignores brightness/saturation/contrast settings. Looking at MPlayer code, it appears the return value of sws_setColorspaceDetails() signals if changing these settings is supported at all. (Nevermind that supporting this feature has almost 0 value, and obviously eats maintenance time.)
This commit is contained in:
parent
1bbf1eb3ce
commit
08199a64d2
|
@ -238,9 +238,11 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
|
||||||
|
|
||||||
// This can fail even with normal operation, e.g. if a conversion path
|
// This can fail even with normal operation, e.g. if a conversion path
|
||||||
// simply does not support these settings.
|
// simply does not support these settings.
|
||||||
sws_setColorspaceDetails(ctx->sws, sws_getCoefficients(s_csp), s_range,
|
int r =
|
||||||
sws_getCoefficients(d_csp), d_range,
|
sws_setColorspaceDetails(ctx->sws, sws_getCoefficients(s_csp), s_range,
|
||||||
ctx->brightness, ctx->contrast, ctx->saturation);
|
sws_getCoefficients(d_csp), d_range,
|
||||||
|
ctx->brightness, ctx->contrast, ctx->saturation);
|
||||||
|
ctx->supports_csp = r >= 0;
|
||||||
|
|
||||||
if (sws_init_context(ctx->sws, ctx->src_filter, ctx->dst_filter) < 0)
|
if (sws_init_context(ctx->sws, ctx->src_filter, ctx->dst_filter) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -294,6 +296,8 @@ int mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src,
|
||||||
|
|
||||||
int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq)
|
int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq)
|
||||||
{
|
{
|
||||||
|
if (!sws->supports_csp)
|
||||||
|
return 0;
|
||||||
if (!strcmp(eq->item, "brightness"))
|
if (!strcmp(eq->item, "brightness"))
|
||||||
eq->value = ((sws->brightness * 100) + (1 << 15)) >> 16;
|
eq->value = ((sws->brightness * 100) + (1 << 15)) >> 16;
|
||||||
else if (!strcmp(eq->item, "contrast"))
|
else if (!strcmp(eq->item, "contrast"))
|
||||||
|
@ -307,6 +311,8 @@ int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq)
|
||||||
|
|
||||||
int mp_sws_set_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq)
|
int mp_sws_set_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq)
|
||||||
{
|
{
|
||||||
|
if (!sws->supports_csp)
|
||||||
|
return 0;
|
||||||
if (!strcmp(eq->item, "brightness"))
|
if (!strcmp(eq->item, "brightness"))
|
||||||
sws->brightness = ((eq->value << 16) + 50) / 100;
|
sws->brightness = ((eq->value << 16) + 50) / 100;
|
||||||
else if (!strcmp(eq->item, "contrast"))
|
else if (!strcmp(eq->item, "contrast"))
|
||||||
|
|
|
@ -44,6 +44,7 @@ struct mp_sws_context {
|
||||||
|
|
||||||
// Cached context (if any)
|
// Cached context (if any)
|
||||||
struct SwsContext *sws;
|
struct SwsContext *sws;
|
||||||
|
bool supports_csp;
|
||||||
|
|
||||||
// Contains parameters for which sws is valid
|
// Contains parameters for which sws is valid
|
||||||
struct mp_sws_context *cached;
|
struct mp_sws_context *cached;
|
||||||
|
|
Loading…
Reference in New Issue