mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
dc6c36ce46
commit
39f9601c10
|
@ -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);
|
||||
|
|
|
@ -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…
Reference in New Issue