Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
swscale/utils: override forced-zero formats back to full range
Fixes vf_scale outputting RGB AVFrames with limited range flagged
in case either input or output specifically sets the range.

This is the reverse of the logic utilized for RGB and PAL8 content
in sws_setColorspaceDetails.
  • Loading branch information
jeeb committed Oct 11, 2020
1 parent 3fe24fe commit 7ea4bcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libswscale/utils.c
Expand Up @@ -1013,8 +1013,8 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,

*inv_table = c->srcColorspaceTable;
*table = c->dstColorspaceTable;
*srcRange = c->srcRange;
*dstRange = c->dstRange;
*srcRange = range_override_needed(c->srcFormat) ? 1 : c->srcRange;
*dstRange = range_override_needed(c->dstFormat) ? 1 : c->dstRange;
*brightness = c->brightness;
*contrast = c->contrast;
*saturation = c->saturation;
Expand Down

1 comment on commit 7ea4bcf

@jeeb
Copy link
Contributor Author

@jeeb jeeb commented on 7ea4bcf Aug 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the commit message, this logic just mirrors what sws_setColorspaceDetails already did. It would forcibly set dstRange and srcRange to zero for !isYUV(format) && !isGray(format). So the input range information was lost /way/ before this point.

This just fixes swscale always reporting the range as being limited for RGB. I did attempt to change swscale to report the actual range given to it, but the RGB behavior would break at the very least in alpha handling if I did so. Thus I gave up.

Please sign in to comment.