mirror of https://github.com/mpv-player/mpv
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:
parent
6797f54378
commit
c0c57be07b
|
@ -392,6 +392,7 @@ static bool probe_formats(struct mp_filter *f, int hw_imgfmt, bool use_conversio
|
||||||
ctx->conversion_config);
|
ctx->conversion_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hw_transfer_index = 0;
|
||||||
for (int n = 0; cstr->valid_sw_formats &&
|
for (int n = 0; cstr->valid_sw_formats &&
|
||||||
cstr->valid_sw_formats[n] != AV_PIX_FMT_NONE; n++)
|
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 &&
|
AV_HWFRAME_TRANSFER_DIRECTION_TO, &fmts, 0) >= 0 &&
|
||||||
fmts[0] != AV_PIX_FMT_NONE)
|
fmts[0] != AV_PIX_FMT_NONE)
|
||||||
{
|
{
|
||||||
int index = p->num_fmts;
|
// Don't add the format to p->fmts if we know it cannot be used.
|
||||||
MP_TARRAY_APPEND(p, p->fmts, p->num_fmts, imgfmt);
|
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_index, index);
|
||||||
MP_TARRAY_GROW(p, p->fmt_upload_num, index);
|
MP_TARRAY_GROW(p, p->fmt_upload_num, index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue