summaryrefslogtreecommitdiffstats
path: root/video/decode/vdpau.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-10 22:36:23 +0100
committerwm4 <wm4@nowhere>2014-03-10 22:56:26 +0100
commitccce58d6d63538911fa7bdd216a32e8444ea36b8 (patch)
tree2a59a762d1242ea796655c42531de0d64765d55c /video/decode/vdpau.c
parentfbddbce01dec878c072cd9dd00da9ff035f3350f (diff)
downloadmpv-ccce58d6d63538911fa7bdd216a32e8444ea36b8.tar.bz2
mpv-ccce58d6d63538911fa7bdd216a32e8444ea36b8.tar.xz
video: initialize hw decoder in get_format
Apparently the "right" place to initialize the hardware decoder is in the libavcodec get_format callback. This doesn't change vda.c and vdpau_old.c, because I don't have OSX, and vdpau_old.c is probably going to be removed soon (if Libav ever manages to release Libav 10). So for now the init_decoder callback added with this commit is optional. This also means vdpau.c and vaapi.c don't have to manage and check the image parameters anymore. This change is probably needed for when libavcodec VDA supports gets a new iteration of its API.
Diffstat (limited to 'video/decode/vdpau.c')
-rw-r--r--video/decode/vdpau.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/video/decode/vdpau.c b/video/decode/vdpau.c
index 6c0c891ad4..995b5460e8 100644
--- a/video/decode/vdpau.c
+++ b/video/decode/vdpau.c
@@ -37,9 +37,6 @@ struct priv {
uint64_t preemption_counter;
AVVDPAUContext context;
-
- int vid_width;
- int vid_height;
};
struct profile_entry {
@@ -97,7 +94,7 @@ static int handle_preemption(struct lavc_ctx *ctx)
return 0;
}
-static bool create_vdp_decoder(struct lavc_ctx *ctx)
+static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h)
{
struct priv *p = ctx->hwdec_priv;
struct vdp_functions *vdp = p->mpvdp->vdp;
@@ -125,17 +122,16 @@ static bool create_vdp_decoder(struct lavc_ctx *ctx)
MP_ERR(p, "Codec or profile not supported by hardware.\n");
goto fail;
}
- if (p->vid_width > maxw || p->vid_height > maxh) {
+ if (w > maxw || h > maxh) {
MP_ERR(p, "Video resolution(%dx%d) is larger than the maximum size(%dx%d) supported.\n",
- p->vid_width, p->vid_height, maxw, maxh);
+ w, h, maxw, maxh);
goto fail;
}
int maxrefs = hwdec_get_max_refs(ctx);
vdp_st = vdp->decoder_create(p->vdp_device, pe->hw_profile,
- p->vid_width, p->vid_height, maxrefs,
- &p->context.decoder);
+ w, h, maxrefs, &p->context.decoder);
CHECK_VDP_WARNING(p, "Failed creating VDPAU decoder");
if (vdp_st != VDP_STATUS_OK)
goto fail;
@@ -151,20 +147,8 @@ static struct mp_image *allocate_image(struct lavc_ctx *ctx, int fmt,
{
struct priv *p = ctx->hwdec_priv;
- if (fmt != IMGFMT_VDPAU)
- return NULL;
-
handle_preemption(ctx);
- if (w != p->vid_width || h != p->vid_height ||
- p->context.decoder == VDP_INVALID_HANDLE)
- {
- p->vid_width = w;
- p->vid_height = h;
- if (!create_vdp_decoder(ctx))
- return NULL;
- }
-
VdpChromaType chroma;
mp_vdpau_get_format(IMGFMT_VDPAU, &chroma, NULL);
@@ -226,5 +210,6 @@ const struct vd_lavc_hwdec mp_vd_lavc_vdpau = {
.probe = probe,
.init = init,
.uninit = uninit,
+ .init_decoder = init_decoder,
.allocate_image = allocate_image,
};