aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Einhorn <moiein2000@gmail.com>2011-08-17 01:58:33 -0400
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-08-18 01:02:34 +0200
commit39f9601c10f51fea519f16bccb4509f8ed3c51a7 (patch)
tree04ea94c758f7e75073a1f0ac3c10498dcb5bba10
parentdc6c36ce46d4c4d7cb63503afc2ee44f00bf3725 (diff)
downloadffmpeg-39f9601c10f51fea519f16bccb4509f8ed3c51a7.tar.gz
lavc: fix avcodec_find_best_pix_fmt() when there's more than 64 pixel formats
This fixed the problem where if there's more than 64 pixel formats defined avcodec_find_best_pix_fmt() returns the wrong pixel format. Signed-off-by: Matthew Einhorn <moiein2000@gmail.com> Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>
-rw-r--r--libavcodec/avcodec.h2
-rw-r--r--libavcodec/imgconvert.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7c82d737bd..b0f3fcb8d2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3499,6 +3499,8 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
* The pixel formats from which it chooses one, are determined by the
* pix_fmt_mask parameter.
*
+ * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
+ *
* @code
* src_pix_fmt = PIX_FMT_YUV420P;
* pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 9efed50955..071d3122c9 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -439,7 +439,7 @@ static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
/* find exact color match with smallest size */
dst_pix_fmt = PIX_FMT_NONE;
min_dist = 0x7fffffff;
- for(i = 0;i < PIX_FMT_NB; i++) {
+ for (i = 0; i < FFMIN(PIX_FMT_NB, 64); i++) {
if (pix_fmt_mask & (1ULL << i)) {
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
if (loss == 0) {