0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 11:32:22 +02:00

f_hwtransfer: filter out unsupported hwuploads from p->fmts

With the previous change, it is possible that the mp_hwdec_ctx contains
a list of known supported hwuploads. Take this into account when adding
to the p->fmts list. We want to be sure to select only something that is
actually possible to use. If the hwdec does not implement
supported_hwupload_formats, then all are assumed to work.
This commit is contained in:
Dudemanguy 2024-09-09 16:24:20 -05:00
parent 6797f54378
commit c0c57be07b

View File

@ -392,6 +392,7 @@ static bool probe_formats(struct mp_filter *f, int hw_imgfmt, bool use_conversio
ctx->conversion_config);
}
int hw_transfer_index = 0;
for (int n = 0; cstr->valid_sw_formats &&
cstr->valid_sw_formats[n] != AV_PIX_FMT_NONE; n++)
{
@ -489,8 +490,19 @@ static bool probe_formats(struct mp_filter *f, int hw_imgfmt, bool use_conversio
AV_HWFRAME_TRANSFER_DIRECTION_TO, &fmts, 0) >= 0 &&
fmts[0] != AV_PIX_FMT_NONE)
{
int index = p->num_fmts;
MP_TARRAY_APPEND(p, p->fmts, p->num_fmts, imgfmt);
// Don't add the format to p->fmts if we know it cannot be used.
if (ctx->supported_hwupload_formats) {
for (int i = 0; ctx->supported_hwupload_formats[i]; i++) {
if (ctx->supported_hwupload_formats[i] == imgfmt)
MP_TARRAY_APPEND(p, p->fmts, p->num_fmts, imgfmt);
}
} else {
MP_TARRAY_APPEND(p, p->fmts, p->num_fmts, imgfmt);
}
int index = hw_transfer_index;
hw_transfer_index++;
MP_TARRAY_GROW(p, p->fmt_upload_index, index);
MP_TARRAY_GROW(p, p->fmt_upload_num, index);