summaryrefslogtreecommitdiffstats
path: root/video/vdpau_mixer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-28 21:54:02 +0200
committerwm4 <wm4@nowhere>2015-05-28 21:54:02 +0200
commite632e37ab8e9865ab12423868dc5f2c26e425be3 (patch)
treec2df9e38eca487dffcdc2ed59312e31432d08028 /video/vdpau_mixer.c
parent939132cbd9d13e4f271b4ec3652598d793523374 (diff)
downloadmpv-e632e37ab8e9865ab12423868dc5f2c26e425be3.tar.bz2
mpv-e632e37ab8e9865ab12423868dc5f2c26e425be3.tar.xz
vdpau: retrieve mixer parameters directly from the hw surface
Always configure the vdpau mixer based on the current surface sent to it. Before this, we just hardcoded the chroma type, and the surface size was essentially a guess. Calling VdpVideoSurfaceGetParameters() on every surface is a bit suspicious, but it appears it's a cheap function (just requiring some locks and a table lookup). This way we avoid creating another complicated mechanism to carry around the actual surface parameters with a mp_image/AVFrame.
Diffstat (limited to 'video/vdpau_mixer.c')
-rw-r--r--video/vdpau_mixer.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/video/vdpau_mixer.c b/video/vdpau_mixer.c
index 1c6211352e..d568285f92 100644
--- a/video/vdpau_mixer.c
+++ b/video/vdpau_mixer.c
@@ -67,7 +67,6 @@ struct mp_vdpau_mixer *mp_vdpau_mixer_create(struct mp_vdpau_ctx *vdp_ctx,
.ctx = vdp_ctx,
.log = log,
.video_mixer = VDP_INVALID_HANDLE,
- .chroma_type = VDP_CHROMA_TYPE_420,
.video_eq = {
.capabilities = MP_CSP_EQ_CAPS_COLORMATRIX,
},
@@ -114,7 +113,8 @@ static int set_video_attribute(struct mp_vdpau_mixer *mixer,
#define SET_VIDEO_ATTR(attr_name, attr_type, value) set_video_attribute(mixer, \
VDP_VIDEO_MIXER_ATTRIBUTE_ ## attr_name, &(attr_type){value},\
# attr_name)
-static int create_vdp_mixer(struct mp_vdpau_mixer *mixer)
+static int create_vdp_mixer(struct mp_vdpau_mixer *mixer,
+ VdpChromaType chroma_type, uint32_t w, uint32_t h)
{
struct vdp_functions *vdp = &mixer->ctx->vdp;
VdpDevice vdp_device = mixer->ctx->vdp_device;
@@ -135,9 +135,9 @@ static int create_vdp_mixer(struct mp_vdpau_mixer *mixer)
VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE,
};
const void *const parameter_values[VDP_NUM_MIXER_PARAMETER] = {
- &(uint32_t){mixer->image_params.w},
- &(uint32_t){mixer->image_params.h},
- &(VdpChromaType){mixer->chroma_type},
+ &(uint32_t){w},
+ &(uint32_t){h},
+ &(VdpChromaType){chroma_type},
};
if (opts->deint >= 3)
features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL;
@@ -176,6 +176,9 @@ static int create_vdp_mixer(struct mp_vdpau_mixer *mixer)
CHECK_VDP_ERROR(mixer, "Error when calling vdp_video_mixer_create");
mixer->initialized = true;
+ mixer->current_chroma_type = chroma_type;
+ mixer->current_w = w;
+ mixer->current_h = h;
for (i = 0; i < feature_count; i++)
feature_enables[i] = VDP_TRUE;
@@ -257,8 +260,17 @@ int mp_vdpau_mixer_render(struct mp_vdpau_mixer *mixer,
if (mixer->video_mixer == VDP_INVALID_HANDLE)
mixer->initialized = false;
+ VdpChromaType s_chroma_type;
+ uint32_t s_w, s_h;
+
+ vdp_st = vdp->video_surface_get_parameters(frame->current, &s_chroma_type,
+ &s_w, &s_h);
+ CHECK_VDP_ERROR(mixer, "Error when calling vdp_video_surface_get_parameters");
+
if (!mixer->initialized || !opts_equal(opts, &mixer->opts) ||
- !mp_image_params_equal(&video->params, &mixer->image_params))
+ !mp_image_params_equal(&video->params, &mixer->image_params) ||
+ mixer->current_w != s_w || mixer->current_h != s_h ||
+ mixer->current_chroma_type != s_chroma_type)
{
mixer->opts = *opts;
mixer->image_params = video->params;
@@ -268,7 +280,7 @@ int mp_vdpau_mixer_render(struct mp_vdpau_mixer *mixer,
}
mixer->video_mixer = VDP_INVALID_HANDLE;
mixer->initialized = false;
- if (create_vdp_mixer(mixer) < 0)
+ if (create_vdp_mixer(mixer, s_chroma_type, s_w, s_h) < 0)
return -1;
}