Browse Source

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>
tags/n0.9
Matthew Einhorn Stefano Sabatini 13 years ago
parent
commit
39f9601c10
2 changed files with 3 additions and 1 deletions
  1. +2
    -0
      libavcodec/avcodec.h
  2. +1
    -1
      libavcodec/imgconvert.c

+ 2
- 0
libavcodec/avcodec.h View File

@@ -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);


+ 1
- 1
libavcodec/imgconvert.c View File

@@ -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) {


Loading…
Cancel
Save