mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec_find_best_pix_fmt_of_2: favor formats with fewer components if it does not incur a loss.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
649d8bd8a5
commit
0880f26bbe
@ -551,6 +551,8 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt
|
||||
{
|
||||
enum AVPixelFormat dst_pix_fmt;
|
||||
int loss1, loss2, loss_order1, loss_order2, i, loss_mask;
|
||||
const AVPixFmtDescriptor *desc1 = av_pix_fmt_desc_get(dst_pix_fmt1);
|
||||
const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2);
|
||||
static const int loss_mask_order[] = {
|
||||
~0, /* no loss first */
|
||||
~FF_LOSS_ALPHA,
|
||||
@ -577,7 +579,11 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt
|
||||
loss_order2 = loss2 & loss_mask_order[i];
|
||||
|
||||
if (loss_order1 == 0 && loss_order2 == 0 && dst_pix_fmt2 != AV_PIX_FMT_NONE && dst_pix_fmt1 != AV_PIX_FMT_NONE){ /* use format with smallest depth */
|
||||
dst_pix_fmt = avg_bits_per_pixel(dst_pix_fmt2) < avg_bits_per_pixel(dst_pix_fmt1) ? dst_pix_fmt2 : dst_pix_fmt1;
|
||||
if(avg_bits_per_pixel(dst_pix_fmt2) != avg_bits_per_pixel(dst_pix_fmt1)) {
|
||||
dst_pix_fmt = avg_bits_per_pixel(dst_pix_fmt2) < avg_bits_per_pixel(dst_pix_fmt1) ? dst_pix_fmt2 : dst_pix_fmt1;
|
||||
} else {
|
||||
dst_pix_fmt = desc2->nb_components < desc1->nb_components ? dst_pix_fmt2 : dst_pix_fmt1;
|
||||
}
|
||||
} else if (loss_order1 == 0 || loss_order2 == 0) { /* use format with no loss */
|
||||
dst_pix_fmt = loss_order2 ? dst_pix_fmt1 : dst_pix_fmt2;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user