[FFmpeg-cvslog] avcodec/pngdec: avoid erroring with sBIT on indexed-color images
Leo Izen
git at videolan.org
Fri Jul 19 04:39:53 EEST 2024
ffmpeg | branch: release/7.0 | Leo Izen <leo.izen at gmail.com> | Fri Jul 12 15:03:16 2024 -0400| [b5d42852d05509d8970452fdd573e0bf9ad3cb4a] | committer: Leo Izen
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 84b454935fae2633a8a5dd075e22393f3e8f932f.
Signed-off-by: Leo Izen <leo.izen at gmail.com>
Reported-by: Ramiro Polla <ramiro.polla at gmail.com>
Reviewed-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5d42852d05509d8970452fdd573e0bf9ad3cb4a
---
libavcodec/pngdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 6444425102..8a881963b5 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1082,7 +1082,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;
More information about the ffmpeg-cvslog
mailing list