mirror of
https://github.com/mpv-player/mpv
synced 2025-01-25 00:53:22 +00:00
vf_vavpp: allocate output surfaces with the same size as input
This can happen if the hw decoder allocates padded surfaces (e.g. mod16), but the VPP output surface was allocated with the exact size. Apparently VPP requires matching input and output sizes, or it will add artifacts. In this case, it added mirrored pixels to the bottom few pixels. Note that the previous commit should have fixed this. But it didn't work, while this commit does. Fixes #2320.
This commit is contained in:
parent
e0c005cb75
commit
2ed9370bd6
@ -160,9 +160,12 @@ static struct mp_image *render(struct vf_instance *vf, struct mp_image *in,
|
||||
if (!p->pipe.filters || in_id == VA_INVALID_ID)
|
||||
return NULL;
|
||||
|
||||
struct mp_image *img = mp_image_pool_get(p->pool, IMGFMT_VAAPI, in->w, in->h);
|
||||
int r_w, r_h;
|
||||
va_surface_get_uncropped_size(in, &r_w, &r_h);
|
||||
struct mp_image *img = mp_image_pool_get(p->pool, IMGFMT_VAAPI, r_w, r_h);
|
||||
if (!img)
|
||||
return NULL;
|
||||
mp_image_set_size(img, in->w, in->h);
|
||||
|
||||
bool need_end_picture = false;
|
||||
bool success = false;
|
||||
|
@ -210,6 +210,15 @@ int va_surface_rt_format(struct mp_image *mpi)
|
||||
return surface ? surface->rt_format : 0;
|
||||
}
|
||||
|
||||
// Return the real size of the underlying surface. (HW decoding might allocate
|
||||
// padded surfaces for example.)
|
||||
void va_surface_get_uncropped_size(struct mp_image *mpi, int *out_w, int *out_h)
|
||||
{
|
||||
struct va_surface *s = va_surface_in_mp_image(mpi);
|
||||
*out_w = s ? s->w : 0;
|
||||
*out_h = s ? s->h : 0;
|
||||
}
|
||||
|
||||
static void release_va_surface(void *arg)
|
||||
{
|
||||
struct va_surface *surface = arg;
|
||||
|
@ -69,6 +69,8 @@ VAImageFormat * va_image_format_from_imgfmt(struct mp_vaapi_ctx *ctx, i
|
||||
bool va_image_map(struct mp_vaapi_ctx *ctx, VAImage *image, struct mp_image *mpi);
|
||||
bool va_image_unmap(struct mp_vaapi_ctx *ctx, VAImage *image);
|
||||
|
||||
void va_surface_get_uncropped_size(struct mp_image *mpi, int *out_w, int *out_h);
|
||||
|
||||
void va_pool_set_allocator(struct mp_image_pool *pool, struct mp_vaapi_ctx *ctx,
|
||||
int rt_format);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user