From: Rémi Denis-Courmont <[email protected]>

---
 libavcodec/vdpau.c        |  4 ++--
 libavcodec/vdpau_mpeg12.c | 30 ++++++++++++++++++++++++++++++
 libavcodec/vdpau_mpeg4.c  | 30 ++++++++++++++++++++++++++++++
 libavcodec/vdpau_vc1.c    | 27 +++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index c285897..581f2d9 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -116,13 +116,13 @@ int ff_vdpau_common_start_frame(struct 
vdpau_picture_context *pic_ctx,
     CONFIG_VC1_VDPAU_HWACCEL   || CONFIG_WMV3_VDPAU_HWACCEL
 int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
 {
-    AVVDPAUContext *hwctx = avctx->hwaccel_context;
+    struct vdpau_context *vdctx = avctx->internal->hwaccel_priv_data;
     MpegEncContext *s = avctx->priv_data;
     Picture *pic = s->current_picture_ptr;
     struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
     VdpVideoSurface surf = ff_vdpau_get_surface_id(pic->f);
 
-    hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
+    vdctx->render(vdctx->decoder, surf, (void *)&pic_ctx->info,
                   pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
 
     ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index 2b53e66..9e1c9da 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -95,6 +95,12 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
 }
 
 #if CONFIG_MPEG1_VDPAU_HWACCEL
+static int vdpau_mpeg1_init(AVCodecContext *avctx)
+{
+    return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG1,
+                                VDP_DECODER_LEVEL_MPEG1_NA, 2);
+}
+
 AVHWAccel ff_mpeg1_vdpau_hwaccel = {
     .name           = "mpeg1_vdpau",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -104,10 +110,31 @@ AVHWAccel ff_mpeg1_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_mpeg_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_mpeg1_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
 #endif
 
 #if CONFIG_MPEG2_VDPAU_HWACCEL
+static int vdpau_mpeg2_init(AVCodecContext *avctx)
+{
+    VdpDecoderProfile profile;
+
+    switch (avctx->profile) {
+    case FF_PROFILE_MPEG2_MAIN:
+        profile = VDP_DECODER_PROFILE_MPEG2_MAIN;
+        break;
+    case FF_PROFILE_MPEG2_SIMPLE:
+        profile = VDP_DECODER_PROFILE_MPEG2_SIMPLE;
+        break;
+    default:
+        return AVERROR(EINVAL);
+    }
+
+    return ff_vdpau_common_init(avctx, profile, avctx->level, 2);
+}
+
 AVHWAccel ff_mpeg2_vdpau_hwaccel = {
     .name           = "mpeg2_vdpau",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -117,5 +144,8 @@ AVHWAccel ff_mpeg2_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_mpeg_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_mpeg2_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
 #endif
diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c
index 64e781d..4f80d69 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -89,6 +89,12 @@ static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext 
*avctx,
 }
 
 #if CONFIG_H263_VDPAU_HWACCEL
+static int vdpau_h263_init(AVCodecContext *avctx)
+{
+    return ff_vdpau_common_init(avctx, VDP_DECODER_PROFILE_MPEG4_PART2_ASP,
+                                avctx->level, 2);
+}
+
 AVHWAccel ff_h263_vdpau_hwaccel = {
     .name           = "h263_vdpau",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -98,10 +104,31 @@ AVHWAccel ff_h263_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_mpeg4_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_h263_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
 #endif
 
 #if CONFIG_MPEG4_VDPAU_HWACCEL
+static int vdpau_mpeg4_init(AVCodecContext *avctx)
+{
+    VdpDecoderProfile profile;
+
+    switch (avctx->profile) {
+    case FF_PROFILE_MPEG4_SIMPLE:
+        profile = VDP_DECODER_PROFILE_MPEG4_PART2_SP;
+        break;
+    case FF_PROFILE_MPEG4_ADVANCED_SIMPLE:
+        profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
+        break;
+    default:
+        return AVERROR(ENOTSUP);
+    }
+
+    return ff_vdpau_common_init(avctx, profile, avctx->level, 2);
+}
+
 AVHWAccel ff_mpeg4_vdpau_hwaccel = {
     .name           = "mpeg4_vdpau",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -111,5 +138,8 @@ AVHWAccel ff_mpeg4_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_mpeg4_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_mpeg4_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
 #endif
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index f7a7ecc..e4db9d5 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -109,6 +109,27 @@ static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
     return 0;
 }
 
+static int vdpau_vc1_init(AVCodecContext *avctx)
+{
+    VdpDecoderProfile profile;
+
+    switch (avctx->profile) {
+    case FF_PROFILE_VC1_SIMPLE:
+        profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
+        break;
+    case FF_PROFILE_VC1_MAIN:
+        profile = VDP_DECODER_PROFILE_VC1_MAIN;
+        break;
+    case FF_PROFILE_VC1_ADVANCED:
+        profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
+        break;
+    default:
+        return AVERROR(ENOTSUP);
+    }
+
+    return ff_vdpau_common_init(avctx, profile, avctx->level, 2);
+}
+
 #if CONFIG_WMV3_VDPAU_HWACCEL
 AVHWAccel ff_wmv3_vdpau_hwaccel = {
     .name           = "wm3_vdpau",
@@ -119,6 +140,9 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_vc1_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
 #endif
 
@@ -131,4 +155,7 @@ AVHWAccel ff_vc1_vdpau_hwaccel = {
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
     .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_vc1_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(struct vdpau_context),
 };
-- 
1.8.1.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to