1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

vd_lavc: reduce hardware decoder mid-stream reinitializations

Instead of doing it on every seek (libavcodec calls get_format on every
seek), reinitialize the decoder only if the video resolution changes.

Note that this may be relatively naive, since we e.g. (or: in
particular) don't check for profile changes. But it's not worse than the
state before the get_format change, and at least it paints over the
current vaapi breakage (issue #646).
This commit is contained in:
wm4 2014-03-16 14:54:21 +01:00
parent 61f3b188a5
commit 269c1e1f41

View File

@ -465,10 +465,15 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
if (ctx->hwdec->image_format) {
for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) {
if (ctx->hwdec->image_format == pixfmt2imgfmt(fmt[i])) {
// There could be more reasons for a change, e.g. profile change.
bool change =
ctx->hwdec_w != avctx->width ||
ctx->hwdec_h != avctx->height ||
ctx->hwdec_fmt != ctx->hwdec->image_format;
ctx->hwdec_w = avctx->width;
ctx->hwdec_h = avctx->height;
ctx->hwdec_fmt = ctx->hwdec->image_format;
if (ctx->hwdec->init_decoder) {
if (ctx->hwdec->init_decoder && change) {
if (ctx->hwdec->init_decoder(ctx, ctx->hwdec_fmt,
ctx->hwdec_w, ctx->hwdec_h) < 0)
{