diff options
author | heimdallr <heimdallr@ngs.ru> | 2018-03-31 19:37:23 +0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-07-08 19:45:46 +0200 |
commit | e0888e57588fd90ea648b0dac12ed6df6ec79cfe (patch) | |
tree | 2617791030f2bae791ef4bb6c4c2d7c9d8dbdd70 | |
parent | 7050970d066b853f82b0891fd7b57c19b4fd9095 (diff) | |
download | ffmpeg-e0888e57588fd90ea648b0dac12ed6df6ec79cfe.tar.gz |
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 354b26a3945eadd4ed8fcd801dfefad2566241de)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/imgconvert.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 1547f18966..7b0005b308 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -69,10 +69,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; } |