mirror of
https://github.com/mpv-player/mpv
synced 2025-02-02 05:01:56 +00:00
Revert "vaapi: remove vaDeriveImage() code path"
This reverts commit d660e67be9
.
Fixes #2123.
This commit is contained in:
parent
d1c37c0e29
commit
e3e20f1431
@ -189,6 +189,7 @@ struct va_surface {
|
|||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
VAImage image; // used for software decoding case
|
VAImage image; // used for software decoding case
|
||||||
|
bool is_derived; // is image derived by vaDeriveImage()?
|
||||||
};
|
};
|
||||||
|
|
||||||
VASurfaceID va_surface_id(struct mp_image *mpi)
|
VASurfaceID va_surface_id(struct mp_image *mpi)
|
||||||
@ -262,6 +263,7 @@ static void va_surface_image_destroy(struct va_surface *surface)
|
|||||||
return;
|
return;
|
||||||
vaDestroyImage(surface->display, surface->image.image_id);
|
vaDestroyImage(surface->display, surface->image.image_id);
|
||||||
surface->image.image_id = VA_INVALID_ID;
|
surface->image.image_id = VA_INVALID_ID;
|
||||||
|
surface->is_derived = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
||||||
@ -269,6 +271,7 @@ static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
|||||||
struct va_surface *p = va_surface_in_mp_image(img);
|
struct va_surface *p = va_surface_in_mp_image(img);
|
||||||
if (!format || !p)
|
if (!format || !p)
|
||||||
return -1;
|
return -1;
|
||||||
|
VADisplay *display = p->display;
|
||||||
|
|
||||||
if (p->image.image_id != VA_INVALID_ID &&
|
if (p->image.image_id != VA_INVALID_ID &&
|
||||||
p->image.format.fourcc == format->fourcc)
|
p->image.format.fourcc == format->fourcc)
|
||||||
@ -279,11 +282,27 @@ static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
|||||||
|
|
||||||
va_surface_image_destroy(p);
|
va_surface_image_destroy(p);
|
||||||
|
|
||||||
VAStatus status = vaCreateImage(p->display, format, p->w, p->h, &p->image);
|
VAStatus status = vaDeriveImage(display, p->id, &p->image);
|
||||||
|
if (status == VA_STATUS_SUCCESS) {
|
||||||
|
/* vaDeriveImage() is supported, check format */
|
||||||
|
if (p->image.format.fourcc == format->fourcc &&
|
||||||
|
p->image.width == p->w && p->image.height == p->h)
|
||||||
|
{
|
||||||
|
p->is_derived = true;
|
||||||
|
MP_VERBOSE(p->ctx, "Using vaDeriveImage()\n");
|
||||||
|
} else {
|
||||||
|
vaDestroyImage(p->display, p->image.image_id);
|
||||||
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
|
p->image.image_id = VA_INVALID_ID;
|
||||||
|
status = vaCreateImage(p->display, format, p->w, p->h, &p->image);
|
||||||
if (!CHECK_VA_STATUS(p->ctx, "vaCreateImage()")) {
|
if (!CHECK_VA_STATUS(p->ctx, "vaCreateImage()")) {
|
||||||
p->image.image_id = VA_INVALID_ID;
|
p->image.image_id = VA_INVALID_ID;
|
||||||
r = -1;
|
r = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
va_unlock(p->ctx);
|
va_unlock(p->ctx);
|
||||||
return r;
|
return r;
|
||||||
@ -365,6 +384,7 @@ int va_surface_upload(struct mp_image *va_dst, struct mp_image *sw_src)
|
|||||||
mp_image_copy(&img, sw_src);
|
mp_image_copy(&img, sw_src);
|
||||||
va_image_unmap(p->ctx, &p->image);
|
va_image_unmap(p->ctx, &p->image);
|
||||||
|
|
||||||
|
if (!p->is_derived) {
|
||||||
va_lock(p->ctx);
|
va_lock(p->ctx);
|
||||||
VAStatus status = vaPutImage(p->display, p->id,
|
VAStatus status = vaPutImage(p->display, p->id,
|
||||||
p->image.image_id,
|
p->image.image_id,
|
||||||
@ -373,6 +393,7 @@ int va_surface_upload(struct mp_image *va_dst, struct mp_image *sw_src)
|
|||||||
va_unlock(p->ctx);
|
va_unlock(p->ctx);
|
||||||
if (!CHECK_VA_STATUS(p->ctx, "vaPutImage()"))
|
if (!CHECK_VA_STATUS(p->ctx, "vaPutImage()"))
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -391,12 +412,14 @@ static struct mp_image *try_download(struct mp_image *src,
|
|||||||
!va_fourcc_to_imgfmt(image->format.fourcc))
|
!va_fourcc_to_imgfmt(image->format.fourcc))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (!p->is_derived) {
|
||||||
va_lock(p->ctx);
|
va_lock(p->ctx);
|
||||||
status = vaGetImage(p->display, p->id, 0, 0,
|
status = vaGetImage(p->display, p->id, 0, 0,
|
||||||
p->w, p->h, image->image_id);
|
p->w, p->h, image->image_id);
|
||||||
va_unlock(p->ctx);
|
va_unlock(p->ctx);
|
||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct mp_image *dst = NULL;
|
struct mp_image *dst = NULL;
|
||||||
struct mp_image tmp;
|
struct mp_image tmp;
|
||||||
|
Loading…
Reference in New Issue
Block a user