diff options
author | wm4 <wm4@nowhere> | 2015-05-28 21:55:16 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-05-28 21:55:16 +0200 |
commit | a9b1e72ef2f6da931bdbd2e8e50424183869698c (patch) | |
tree | 507cf71ec6aa715f21c87f91b0de3a488228a343 /video/decode | |
parent | e632e37ab8e9865ab12423868dc5f2c26e425be3 (diff) | |
download | mpv-a9b1e72ef2f6da931bdbd2e8e50424183869698c.tar.bz2 mpv-a9b1e72ef2f6da931bdbd2e8e50424183869698c.tar.xz |
vd_lavc: allocate hw surfaces using the coded size
...instead of relying on the hw decoding API to align it for us. The old
method could in theory have gone wrong if the video is cropped by an
amount large enough to step over several blocks.
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/vd_lavc.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index c0209cab21..7c95f00e2c 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -514,12 +514,12 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, // There could be more reasons for a change, and it's possible // that we miss some. (Might also depend on the hwaccel type.) bool change = - ctx->hwdec_w != avctx->width || - ctx->hwdec_h != avctx->height || + ctx->hwdec_w != avctx->coded_width || + ctx->hwdec_h != avctx->coded_height || ctx->hwdec_fmt != ctx->hwdec->image_format || ctx->hwdec_profile != avctx->profile; - ctx->hwdec_w = avctx->width; - ctx->hwdec_h = avctx->height; + ctx->hwdec_w = avctx->coded_width; + ctx->hwdec_h = avctx->coded_height; ctx->hwdec_fmt = ctx->hwdec->image_format; ctx->hwdec_profile = avctx->profile; if (ctx->hwdec->init_decoder && change) { @@ -568,12 +568,11 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags) if (!IMGFMT_IS_HWACCEL(imgfmt) || !ctx->hwdec) return -1; - // Using frame->width/height is bad. For non-mod 16 video (which would - // require alignment of frame sizes) we want the decoded size, not the - // aligned size. At least vdpau needs this: the video mixer is created - // with decoded size, and the video surfaces must have matching size. - int w = ctx->avctx->width; - int h = ctx->avctx->height; + // We expect it to use the exact size used to create the hw decoder in + // get_format_hwdec(). For cropped video, this is expected to be the + // uncropped size (usually coded_width/coded_height). + int w = pic->width; + int h = pic->height; if (ctx->hwdec->init_decoder) { if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h) |