diff options
author | wm4 <wm4@nowhere> | 2014-03-16 14:54:21 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-16 14:54:21 +0100 |
commit | 269c1e1f41f6daf4ff17ffd47f5dfe78884b8ec7 (patch) | |
tree | 34b017d3e02ebc04c53919c4e452586b608f6848 /video/decode/vd_lavc.c | |
parent | 61f3b188a57aac400829efac1ec6aa8978d28687 (diff) | |
download | mpv-269c1e1f41f6daf4ff17ffd47f5dfe78884b8ec7.tar.bz2 mpv-269c1e1f41f6daf4ff17ffd47f5dfe78884b8ec7.tar.xz |
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).
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r-- | video/decode/vd_lavc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index b49f3c6c44..4914d04f20 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -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) { |