mirror of
https://github.com/mpv-player/mpv
synced 2025-04-17 20:58:20 +00:00
video: remove special path for hwdec screenshots
This was phased out, and was used only by vdpau by now. Drop the mechanism and the vdpau special code, which means screenshots won't include the vf_vdpaupp processing anymore. (I don't care enough about vdpau, it's on its way out.)
This commit is contained in:
parent
9e140775bc
commit
ddfccd67d5
@ -404,12 +404,6 @@ static struct mp_image *screenshot_get(struct MPContext *mpctx, int mode)
|
||||
|
||||
if (image && (image->fmt.flags & MP_IMGFLAG_HWACCEL)) {
|
||||
struct mp_image *nimage = mp_image_hw_download(image, NULL);
|
||||
if (!nimage && mpctx->vo_chain && mpctx->vo_chain->hwdec_devs) {
|
||||
struct mp_hwdec_ctx *ctx =
|
||||
hwdec_devices_get_first(mpctx->vo_chain->hwdec_devs);
|
||||
if (ctx && ctx->download_image)
|
||||
nimage = ctx->download_image(ctx, image, NULL);
|
||||
}
|
||||
talloc_free(image);
|
||||
image = nimage;
|
||||
}
|
||||
|
@ -56,16 +56,6 @@ struct mp_hwdec_ctx {
|
||||
// Hint to generic code: it's using a wrapper API
|
||||
bool emulated;
|
||||
|
||||
// Optional. Legacy. (New code should use AVHWFramesContext and
|
||||
// mp_image_hw_download().)
|
||||
// Allocates a software image from the pool, downloads the hw image from
|
||||
// mpi, and returns it.
|
||||
// pool can be NULL (then just use straight allocation).
|
||||
// Return NULL on error or if mpi has the wrong format.
|
||||
struct mp_image *(*download_image)(struct mp_hwdec_ctx *ctx,
|
||||
struct mp_image *mpi,
|
||||
struct mp_image_pool *swpool);
|
||||
|
||||
// Optional. Crap for vdpau. Makes sure preemption recovery is run if needed.
|
||||
void (*restore_device)(struct mp_hwdec_ctx *ctx);
|
||||
|
||||
|
@ -254,8 +254,7 @@ void mp_image_pool_set_lru(struct mp_image_pool *pool)
|
||||
|
||||
// Copies the contents of the HW surface img to system memory and retuns it.
|
||||
// If swpool is not NULL, it's used to allocate the target image.
|
||||
// img must be a hw surface with a AVHWFramesContext attached. If not, you
|
||||
// must use the legacy mp_hwdec_ctx.download_image.
|
||||
// img must be a hw surface with a AVHWFramesContext attached.
|
||||
// The returned image is cropped as needed.
|
||||
// Returns NULL on failure.
|
||||
struct mp_image *mp_image_hw_download(struct mp_image *src,
|
||||
|
@ -31,89 +31,6 @@
|
||||
#include "mp_image_pool.h"
|
||||
#include "vdpau_mixer.h"
|
||||
|
||||
static struct mp_image *download_image_yuv(struct mp_hwdec_ctx *hwctx,
|
||||
struct mp_image *mpi,
|
||||
struct mp_image_pool *swpool)
|
||||
{
|
||||
if (mpi->imgfmt != IMGFMT_VDPAU || mp_vdpau_mixed_frame_get(mpi))
|
||||
return NULL;
|
||||
|
||||
return mp_image_hw_download(mpi, swpool);
|
||||
}
|
||||
|
||||
static struct mp_image *download_image(struct mp_hwdec_ctx *hwctx,
|
||||
struct mp_image *mpi,
|
||||
struct mp_image_pool *swpool)
|
||||
{
|
||||
if (mpi->imgfmt != IMGFMT_VDPAU && mpi->imgfmt != IMGFMT_VDPAU_OUTPUT)
|
||||
return NULL;
|
||||
|
||||
struct mp_vdpau_ctx *ctx = hwctx->ctx;
|
||||
struct vdp_functions *vdp = &ctx->vdp;
|
||||
VdpStatus vdp_st;
|
||||
|
||||
struct mp_image *res = NULL;
|
||||
int w, h;
|
||||
mp_image_params_get_dsize(&mpi->params, &w, &h);
|
||||
|
||||
res = download_image_yuv(hwctx, mpi, swpool);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
// Abuse this lock for our own purposes. It could use its own lock instead.
|
||||
pthread_mutex_lock(&ctx->pool_lock);
|
||||
|
||||
if (ctx->getimg_surface == VDP_INVALID_HANDLE ||
|
||||
ctx->getimg_w < w || ctx->getimg_h < h)
|
||||
{
|
||||
if (ctx->getimg_surface != VDP_INVALID_HANDLE) {
|
||||
vdp_st = vdp->output_surface_destroy(ctx->getimg_surface);
|
||||
CHECK_VDP_WARNING(ctx, "Error when calling vdp_output_surface_destroy");
|
||||
}
|
||||
ctx->getimg_surface = VDP_INVALID_HANDLE;
|
||||
vdp_st = vdp->output_surface_create(ctx->vdp_device,
|
||||
VDP_RGBA_FORMAT_B8G8R8A8, w, h,
|
||||
&ctx->getimg_surface);
|
||||
CHECK_VDP_WARNING(ctx, "Error when calling vdp_output_surface_create");
|
||||
if (vdp_st != VDP_STATUS_OK)
|
||||
goto error;
|
||||
ctx->getimg_w = w;
|
||||
ctx->getimg_h = h;
|
||||
}
|
||||
|
||||
if (!ctx->getimg_mixer)
|
||||
ctx->getimg_mixer = mp_vdpau_mixer_create(ctx, ctx->log);
|
||||
|
||||
VdpRect in = { .x1 = mpi->w, .y1 = mpi->h };
|
||||
VdpRect out = { .x1 = w, .y1 = h };
|
||||
if (mp_vdpau_mixer_render(ctx->getimg_mixer, NULL, ctx->getimg_surface, &out,
|
||||
mpi, &in) < 0)
|
||||
goto error;
|
||||
|
||||
res = mp_image_pool_get(swpool, IMGFMT_BGR0, ctx->getimg_w, ctx->getimg_h);
|
||||
if (!res)
|
||||
goto error;
|
||||
|
||||
void *dst_planes[] = { res->planes[0] };
|
||||
uint32_t dst_pitches[] = { res->stride[0] };
|
||||
vdp_st = vdp->output_surface_get_bits_native(ctx->getimg_surface, NULL,
|
||||
dst_planes, dst_pitches);
|
||||
CHECK_VDP_WARNING(ctx, "Error when calling vdp_output_surface_get_bits_native");
|
||||
if (vdp_st != VDP_STATUS_OK)
|
||||
goto error;
|
||||
|
||||
mp_image_set_size(res, w, h);
|
||||
mp_image_copy_attributes(res, mpi);
|
||||
|
||||
pthread_mutex_unlock(&ctx->pool_lock);
|
||||
return res;
|
||||
error:
|
||||
talloc_free(res);
|
||||
MP_WARN(ctx, "Error copying image from GPU.\n");
|
||||
pthread_mutex_unlock(&ctx->pool_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void mark_vdpau_objects_uninitialized(struct mp_vdpau_ctx *ctx)
|
||||
{
|
||||
for (int i = 0; i < MAX_VIDEO_SURFACES; i++) {
|
||||
@ -451,7 +368,6 @@ struct mp_vdpau_ctx *mp_vdpau_create_device_x11(struct mp_log *log, Display *x11
|
||||
.hwctx = {
|
||||
.type = HWDEC_VDPAU,
|
||||
.ctx = ctx,
|
||||
.download_image = download_image,
|
||||
.restore_device = recheck_preemption,
|
||||
},
|
||||
.getimg_surface = VDP_INVALID_HANDLE,
|
||||
|
Loading…
Reference in New Issue
Block a user