mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-01-06 06:05:32 +01:00
avcodec/imgconvert: Fix loss mask bug in avcodec_find_best_pix_fmt_of_list()
example:
AVPixelFormat pixFmts[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA };
int loss = 0;
AVPixelFormat best = avcodec_find_best_pix_fmt_of_list(pixFmts, AV_PIX_FMT_BGRA, 1, &loss);
best is AV_PIX_FMT_RGB24. But AV_PIX_FMT_RGBA is better.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 354b26a394)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
367d459f78
commit
eb86546109
@@ -81,10 +81,14 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p
|
||||
int i;
|
||||
|
||||
enum AVPixelFormat best = AV_PIX_FMT_NONE;
|
||||
int loss;
|
||||
|
||||
for(i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++)
|
||||
best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, loss_ptr);
|
||||
for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {
|
||||
loss = *loss_ptr;
|
||||
best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, &loss);
|
||||
}
|
||||
|
||||
*loss_ptr = loss;
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user