compare_pixdesc: fixed ordering unequal depth pixfmts

The comparator shouldn't sort v210 better than Y416 with respect to
xv30.

This was because v210 and Y416 have unequal bit depth (10 and 16), both
equal or better than src 10 bits. But closer variant, in this case v210
was immediately returned and thus subsampling wasn't even compared.
This commit is contained in:
Martin Pulec
2023-02-02 11:13:38 +01:00
parent 53ff8e4bbf
commit 97cd85bc93

View File

@@ -3665,21 +3665,24 @@ int compare_pixdesc(const struct pixfmt_desc *desc_a, const struct pixfmt_desc *
return desc_a->rgb == src_desc->rgb ? -1 : 1;
}
if (desc_a->depth != desc_b->depth) {
// either a or b is lower than orig - sort higher bit depth first
if (desc_a->depth < src_desc->depth || desc_b->depth < src_desc->depth) {
return desc_b->depth - desc_a->depth;
}
// both are equal or higher - sort lower bit depth first
return desc_a->depth - desc_b->depth;
if (desc_a->depth != desc_b->depth &&
(desc_a->depth < src_desc->depth || desc_b->depth < src_desc->depth)) { // either a or b is lower than orig - sort higher bit depth first
return desc_b->depth - desc_a->depth;
}
if (desc_a->subsampling != desc_b->subsampling &&
(desc_a->subsampling < src_desc->subsampling || desc_b->subsampling < src_desc->subsampling)) {
return desc_b->subsampling - desc_a->subsampling; // return better subs
}
// if both A and B are either undistinguishable or better than src, return closer ("worse") pixfmt
if (desc_a->depth != desc_b->depth) {
return desc_a->depth - desc_b->depth;
}
if (desc_a->subsampling != desc_b->subsampling) {
if (desc_a->subsampling < src_desc->subsampling || desc_b->subsampling < src_desc->subsampling) {
return desc_b->subsampling - desc_a->subsampling; // return better subs
}
return desc_a->subsampling - desc_b->subsampling;
}
return desc_a->id < desc_b->id ? -1 : 1;
}