CC: libav-stable@libav.org
(cherry picked from commit 39bb27bf79bc4c2d8beaed637a14176264cb1916)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 7a7229b52d1900279041991fadbd29b27e8dfe95)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
(cherry picked from commit 8812b5f164109553f009ce385e17a1af16b6ea53)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
... | ... |
@@ -851,7 +851,8 @@ static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask, |
851 | 851 |
/* find exact color match with smallest size */ |
852 | 852 |
dst_pix_fmt = PIX_FMT_NONE; |
853 | 853 |
min_dist = 0x7fffffff; |
854 |
- for(i = 0;i < PIX_FMT_NB; i++) { |
|
854 |
+ /* test only the first 64 pixel formats to avoid undefined behaviour */ |
|
855 |
+ for (i = 0; i < 64; i++) { |
|
855 | 856 |
if (pix_fmt_mask & (1ULL << i)) { |
856 | 857 |
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask; |
857 | 858 |
if (loss == 0) { |