avcodec/pngdec: avoid erroring with sBIT on indexed-color images

Indexed color images use three colors for sBIT, but the function
ff_png_get_nb_channels returns 1 in this case. We should avoid erroring
out on valid files in this scenario.

Regression since 84b454935f.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Leo Izen 2024-07-12 15:03:16 -04:00
parent 483fd732ab
commit 4225f51c62
No known key found for this signature in database
GPG Key ID: 764E48EA48221833
1 changed files with 1 additions and 1 deletions

View File

@ -1084,7 +1084,7 @@ static int decode_sbit_chunk(AVCodecContext *avctx, PNGDecContext *s,
return AVERROR_INVALIDDATA;
}
channels = ff_png_get_nb_channels(s->color_type);
channels = s->color_type & PNG_COLOR_MASK_PALETTE ? 3 : ff_png_get_nb_channels(s->color_type);
if (bytestream2_get_bytes_left(gb) != channels)
return AVERROR_INVALIDDATA;