[FFmpeg-devel] [PATCH 3/3] swscale/swscale_unscaled: fix packed16togbra16() for formats with bpc between 9-14 bits

James Almer jamrial at gmail.com
Mon May 19 00:14:21 EEST 2025


On 5/18/2025 5:52 PM, Ramiro Polla wrote:
> Currently, packed16togbra16() always sets the alpha value to 0xFFFF,
> without taking the bit depth into consideration.
> 
> This commit restricts the alpha value to the bit depth.

packed16togbra16() seems to only be called for BGR48 and BGRA64, both of 
which are 16bits, so this change is superfluous.

> ---
>   libswscale/swscale_unscaled.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
> index 8d71a88c23..488db43e0b 100644
> --- a/libswscale/swscale_unscaled.c
> +++ b/libswscale/swscale_unscaled.c
> @@ -699,7 +699,7 @@ static void packed16togbra16(const uint8_t *src, int srcStride,
>                       dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
>                       dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
>                       dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
> -                    dst[3][x] = 0xFFFF;
> +                    dst[3][x] = av_bswap16(0xFFFF >> shift);
>                   }
>               } else if (src_alpha) {
>                   for (x = 0; x < width; x++) {
> @@ -729,7 +729,7 @@ static void packed16togbra16(const uint8_t *src, int srcStride,
>                       dst[0][x] = av_bswap16(*src_line++ >> shift);
>                       dst[1][x] = av_bswap16(*src_line++ >> shift);
>                       dst[2][x] = av_bswap16(*src_line++ >> shift);
> -                    dst[3][x] = 0xFFFF;
> +                    dst[3][x] = av_bswap16(0xFFFF >> shift);
>                   }
>               } else if (src_alpha) {
>                   for (x = 0; x < width; x++) {
> @@ -759,7 +759,7 @@ static void packed16togbra16(const uint8_t *src, int srcStride,
>                       dst[0][x] = av_bswap16(*src_line++) >> shift;
>                       dst[1][x] = av_bswap16(*src_line++) >> shift;
>                       dst[2][x] = av_bswap16(*src_line++) >> shift;
> -                    dst[3][x] = 0xFFFF;
> +                    dst[3][x] = 0xFFFF >> shift;
>                   }
>               } else if (src_alpha) {
>                   for (x = 0; x < width; x++) {
> @@ -789,7 +789,7 @@ static void packed16togbra16(const uint8_t *src, int srcStride,
>                       dst[0][x] = *src_line++ >> shift;
>                       dst[1][x] = *src_line++ >> shift;
>                       dst[2][x] = *src_line++ >> shift;
> -                    dst[3][x] = 0xFFFF;
> +                    dst[3][x] = 0xFFFF >> shift;
>                   }
>               } else if (src_alpha) {
>                   for (x = 0; x < width; x++) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250518/f022ce6c/attachment.sig>


More information about the ffmpeg-devel mailing list