1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 17:12:36 +00:00

vd_lavc: add gross workaround for nvdec/libavcodec broken API issue

libavcodec's nvdec wrapper can return invalid frames, that do not have
any data fields set. This is not allowed by the API, but why would they
follow their own API?

Add a workaround to specifically detect this situation. In practice,
this should fall back to software decoding if it happens too often in a
row. (But single errors are still tolerated, because I don't know why.)

Untested due to lack of hardware from the regrettable graphics company.

Better do this here than deal with the moronic project we unfortunately
depend on.

See: #7185
This commit is contained in:
wm4 2019-12-18 01:56:29 +01:00
parent 06c9c38199
commit bd96b97170

View File

@ -1055,15 +1055,21 @@ static int decode_frame(struct mp_filter *vd)
// data.
assert(ctx->pic->buf[0]);
ctx->hwdec_fail_count = 0;
struct mp_image *mpi = mp_image_from_av_frame(ctx->pic);
if (!mpi) {
av_frame_unref(ctx->pic);
return ret;
}
if (mpi->imgfmt == IMGFMT_CUDA)
assert(mpi->planes[0]);
if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) {
MP_ERR(vd, "CUDA frame without data. This is a FFmpeg bug.\n");
talloc_free(mpi);
handle_err(vd);
return AVERROR_BUG;
}
ctx->hwdec_fail_count = 0;
mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);