mirror of
https://github.com/mpv-player/mpv
synced 2025-01-04 14:12:10 +00:00
vaapi: remove vaDeriveImage() code path
In theory, this code path avoids a copy. In practice, it never seems to get enabled at all. But it does have potential for weird bugs or performance issues (like being mapped from non-cacheable memory), so kill it.
This commit is contained in:
parent
d98cd6609d
commit
d660e67be9
@ -186,7 +186,6 @@ struct va_surface {
|
||||
int rt_format;
|
||||
|
||||
VAImage image; // used for software decoding case
|
||||
bool is_derived; // is image derived by vaDeriveImage()?
|
||||
};
|
||||
|
||||
VASurfaceID va_surface_id(struct mp_image *mpi)
|
||||
@ -258,7 +257,6 @@ static void va_surface_image_destroy(struct va_surface *surface)
|
||||
return;
|
||||
vaDestroyImage(surface->display, surface->image.image_id);
|
||||
surface->image.image_id = VA_INVALID_ID;
|
||||
surface->is_derived = false;
|
||||
}
|
||||
|
||||
static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
||||
@ -266,7 +264,6 @@ static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
||||
struct va_surface *p = va_surface_in_mp_image(img);
|
||||
if (!format || !p)
|
||||
return -1;
|
||||
VADisplay *display = p->display;
|
||||
|
||||
if (p->image.image_id != VA_INVALID_ID &&
|
||||
p->image.format.fourcc == format->fourcc)
|
||||
@ -277,26 +274,10 @@ static int va_surface_image_alloc(struct mp_image *img, VAImageFormat *format)
|
||||
|
||||
va_surface_image_destroy(p);
|
||||
|
||||
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 == img->w && p->image.height == img->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) {
|
||||
VAStatus status = vaCreateImage(p->display, format, img->w, img->h, &p->image);
|
||||
if (!CHECK_VA_STATUS(p->ctx, "vaCreateImage()")) {
|
||||
p->image.image_id = VA_INVALID_ID;
|
||||
status = vaCreateImage(p->display, format, img->w, img->h, &p->image);
|
||||
if (!CHECK_VA_STATUS(p->ctx, "vaCreateImage()")) {
|
||||
p->image.image_id = VA_INVALID_ID;
|
||||
r = -1;
|
||||
}
|
||||
r = -1;
|
||||
}
|
||||
|
||||
va_unlock(p->ctx);
|
||||
@ -377,16 +358,14 @@ int va_surface_upload(struct mp_image *va_dst, struct mp_image *sw_src)
|
||||
mp_image_copy(&img, sw_src);
|
||||
va_image_unmap(p->ctx, &p->image);
|
||||
|
||||
if (!p->is_derived) {
|
||||
va_lock(p->ctx);
|
||||
VAStatus status = vaPutImage2(p->display, p->id,
|
||||
p->image.image_id,
|
||||
0, 0, sw_src->w, sw_src->h,
|
||||
0, 0, sw_src->w, sw_src->h);
|
||||
va_unlock(p->ctx);
|
||||
if (!CHECK_VA_STATUS(p->ctx, "vaPutImage()"))
|
||||
return -1;
|
||||
}
|
||||
va_lock(p->ctx);
|
||||
VAStatus status = vaPutImage2(p->display, p->id,
|
||||
p->image.image_id,
|
||||
0, 0, sw_src->w, sw_src->h,
|
||||
0, 0, sw_src->w, sw_src->h);
|
||||
va_unlock(p->ctx);
|
||||
if (!CHECK_VA_STATUS(p->ctx, "vaPutImage()"))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -405,14 +384,12 @@ static struct mp_image *try_download(struct mp_image *src,
|
||||
!va_fourcc_to_imgfmt(image->format.fourcc))
|
||||
return NULL;
|
||||
|
||||
if (!p->is_derived) {
|
||||
va_lock(p->ctx);
|
||||
status = vaGetImage(p->display, p->id, 0, 0,
|
||||
src->w, src->h, image->image_id);
|
||||
va_unlock(p->ctx);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
return NULL;
|
||||
}
|
||||
va_lock(p->ctx);
|
||||
status = vaGetImage(p->display, p->id, 0, 0,
|
||||
src->w, src->h, image->image_id);
|
||||
va_unlock(p->ctx);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
struct mp_image *dst = NULL;
|
||||
struct mp_image tmp;
|
||||
|
Loading…
Reference in New Issue
Block a user