summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_vdpaupp.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-05-04 10:50:32 +0200
committerwm4 <wm4@nowhere>2014-05-04 10:51:14 +0200
commita7fe47e49521009e2790e28c286ef199dae0b4f5 (patch)
tree559383a9d598067b6edf0dccae85bfcfd2c09c84 /video/filter/vf_vdpaupp.c
parent94441ed13963356fa25f7e52a12e36387220ebba (diff)
downloadmpv-a7fe47e49521009e2790e28c286ef199dae0b4f5.tar.bz2
mpv-a7fe47e49521009e2790e28c286ef199dae0b4f5.tar.xz
vdpau: deduplicate video surface upload code
This was a minor code duplication between vf_vdpaupp.c and vo_vdpau.c. (In theory, we could always require using vf_vdpaupp with vo_vdpau, but I think it's better if vo_vdpau can work standalone.)
Diffstat (limited to 'video/filter/vf_vdpaupp.c')
-rw-r--r--video/filter/vf_vdpaupp.c41
1 files changed, 5 insertions, 36 deletions
diff --git a/video/filter/vf_vdpaupp.c b/video/filter/vf_vdpaupp.c
index cf8a177088..1177dc74cf 100644
--- a/video/filter/vf_vdpaupp.c
+++ b/video/filter/vf_vdpaupp.c
@@ -53,35 +53,6 @@ struct vf_priv_s {
struct mp_vdpau_mixer_opts opts;
};
-static struct mp_image *upload(struct vf_instance *vf, struct mp_image *mpi)
-{
- struct vf_priv_s *p = vf->priv;
- struct vdp_functions *vdp = &p->ctx->vdp;
- VdpStatus vdp_st;
-
- VdpChromaType chroma_type = (VdpChromaType)-1;
- VdpYCbCrFormat pixel_format = (VdpYCbCrFormat)-1;
- mp_vdpau_get_format(mpi->imgfmt, &chroma_type, &pixel_format);
-
- struct mp_image *hwmpi =
- mp_vdpau_get_video_surface(p->ctx, chroma_type, mpi->w, mpi->h);
- if (!hwmpi)
- return mpi;
-
- VdpVideoSurface surface = (intptr_t)hwmpi->planes[3];
- const void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
- if (mpi->imgfmt == IMGFMT_NV12)
- destdata[1] = destdata[2];
- vdp_st = vdp->video_surface_put_bits_y_cb_cr(surface,
- pixel_format, destdata, mpi->stride);
- CHECK_VDP_WARNING(vf, "Error when calling vdp_video_surface_put_bits_y_cb_cr");
-
- mp_image_copy_attributes(hwmpi, mpi);
-
- talloc_free(mpi);
- return hwmpi;
-}
-
static void forget_frames(struct vf_instance *vf)
{
struct vf_priv_s *p = vf->priv;
@@ -153,15 +124,13 @@ static int filter_ext(struct vf_instance *vf, struct mp_image *mpi)
int maxbuffer = p->opts.deint ? MP_ARRAY_SIZE(p->buffered) : 2;
bool eof = !mpi;
- if (mpi && mpi->imgfmt != IMGFMT_VDPAU) {
- mpi = upload(vf, mpi);
- if (mpi->imgfmt != IMGFMT_VDPAU) {
- talloc_free(mpi);
+ if (mpi) {
+ struct mp_image *new = mp_vdpau_upload_video_surface(p->ctx, mpi);
+ talloc_free(mpi);
+ if (!new)
return -1;
- }
- }
+ mpi = new;
- if (mpi) {
if (mpi->planes[2]) {
MP_ERR(vf, "Can't apply vdpaupp filter multiple times.\n");
vf_add_output_frame(vf, mpi);