mirror of https://git.ffmpeg.org/ffmpeg.git
pixdesc: Improve scoring for opaque/unknown pixel formats
Hardware pixel formats do not tell you anything about their actual contents, but should still score higher than formats with completely unknown properties, which in turn should score higher than invalid formats. Do not return an AVERROR code as a score. Fixes a hang in libavfilter where format negotiation gets stuck in a loop because AV_PIX_FMT_NONE scores more highly than all other possibilities.
This commit is contained in:
parent
5b8a708492
commit
8a442d7a8a
|
@ -2511,8 +2511,16 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
|
||||||
int ret, loss, i, nb_components;
|
int ret, loss, i, nb_components;
|
||||||
int score = INT_MAX - 1;
|
int score = INT_MAX - 1;
|
||||||
|
|
||||||
if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE)
|
if (!src_desc || !dst_desc)
|
||||||
return ~0;
|
return -4;
|
||||||
|
|
||||||
|
if ((src_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) ||
|
||||||
|
(dst_desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
||||||
|
if (dst_pix_fmt == src_pix_fmt)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
/* compute loss */
|
/* compute loss */
|
||||||
*lossp = loss = 0;
|
*lossp = loss = 0;
|
||||||
|
@ -2521,9 +2529,9 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
|
||||||
return INT_MAX;
|
return INT_MAX;
|
||||||
|
|
||||||
if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
|
if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0)
|
||||||
return ret;
|
return -3;
|
||||||
if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
|
if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0)
|
||||||
return ret;
|
return -3;
|
||||||
|
|
||||||
src_color = get_color_type(src_desc);
|
src_color = get_color_type(src_desc);
|
||||||
dst_color = get_color_type(dst_desc);
|
dst_color = get_color_type(dst_desc);
|
||||||
|
|
Loading…
Reference in New Issue