mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
e632e37ab8
commit
a9b1e72ef2
|
@ -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
|
// There could be more reasons for a change, and it's possible
|
||||||
// that we miss some. (Might also depend on the hwaccel type.)
|
// that we miss some. (Might also depend on the hwaccel type.)
|
||||||
bool change =
|
bool change =
|
||||||
ctx->hwdec_w != avctx->width ||
|
ctx->hwdec_w != avctx->coded_width ||
|
||||||
ctx->hwdec_h != avctx->height ||
|
ctx->hwdec_h != avctx->coded_height ||
|
||||||
ctx->hwdec_fmt != ctx->hwdec->image_format ||
|
ctx->hwdec_fmt != ctx->hwdec->image_format ||
|
||||||
ctx->hwdec_profile != avctx->profile;
|
ctx->hwdec_profile != avctx->profile;
|
||||||
ctx->hwdec_w = avctx->width;
|
ctx->hwdec_w = avctx->coded_width;
|
||||||
ctx->hwdec_h = avctx->height;
|
ctx->hwdec_h = avctx->coded_height;
|
||||||
ctx->hwdec_fmt = ctx->hwdec->image_format;
|
ctx->hwdec_fmt = ctx->hwdec->image_format;
|
||||||
ctx->hwdec_profile = avctx->profile;
|
ctx->hwdec_profile = avctx->profile;
|
||||||
if (ctx->hwdec->init_decoder && change) {
|
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)
|
if (!IMGFMT_IS_HWACCEL(imgfmt) || !ctx->hwdec)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Using frame->width/height is bad. For non-mod 16 video (which would
|
// We expect it to use the exact size used to create the hw decoder in
|
||||||
// require alignment of frame sizes) we want the decoded size, not the
|
// get_format_hwdec(). For cropped video, this is expected to be the
|
||||||
// aligned size. At least vdpau needs this: the video mixer is created
|
// uncropped size (usually coded_width/coded_height).
|
||||||
// with decoded size, and the video surfaces must have matching size.
|
int w = pic->width;
|
||||||
int w = ctx->avctx->width;
|
int h = pic->height;
|
||||||
int h = ctx->avctx->height;
|
|
||||||
|
|
||||||
if (ctx->hwdec->init_decoder) {
|
if (ctx->hwdec->init_decoder) {
|
||||||
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
|
if (imgfmt != ctx->hwdec_fmt && w != ctx->hwdec_w && h != ctx->hwdec_h)
|
||||||
|
|
Loading…
Reference in New Issue