From: Rémi Denis-Courmont <[email protected]>
---
libavcodec/vdpau_h264.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 32e9c28..a76d378 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -24,6 +24,7 @@
#include <vdpau/vdpau.h>
#include "avcodec.h"
+#include "internal.h"
#include "h264.h"
#include "mpegutils.h"
#include "vdpau.h"
@@ -189,13 +190,13 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
static int vdpau_h264_end_frame(AVCodecContext *avctx)
{
- AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ struct vdpau_context *vdctx = avctx->internal->hwaccel_priv_data;
H264Context *h = avctx->priv_data;
H264Picture *pic = h->cur_pic_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_h264_draw_horiz_band(h, 0, h->avctx->height);
@@ -204,6 +205,32 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
return 0;
}
+static int vdpau_h264_init(AVCodecContext *avctx)
+{
+ VdpDecoderProfile profile;
+ uint32_t level = avctx->level;
+
+ switch (avctx->profile & ~FF_PROFILE_H264_INTRA) {
+ case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+ case FF_PROFILE_H264_BASELINE:
+ profile = VDP_DECODER_PROFILE_H264_BASELINE;
+ break;
+ case FF_PROFILE_H264_MAIN:
+ profile = VDP_DECODER_PROFILE_H264_MAIN;
+ break;
+ case FF_PROFILE_H264_HIGH:
+ profile = VDP_DECODER_PROFILE_H264_HIGH;
+ break;
+ default:
+ return AVERROR(ENOTSUP);
+ }
+
+ if ((avctx->profile & FF_PROFILE_H264_INTRA) && avctx->level == 11)
+ level = VDP_DECODER_LEVEL_H264_1b;
+
+ return ff_vdpau_common_init(avctx, profile, level, 16);
+}
+
AVHWAccel ff_h264_vdpau_hwaccel = {
.name = "h264_vdpau",
.type = AVMEDIA_TYPE_VIDEO,
@@ -213,4 +240,7 @@ AVHWAccel ff_h264_vdpau_hwaccel = {
.end_frame = vdpau_h264_end_frame,
.decode_slice = vdpau_h264_decode_slice,
.frame_priv_data_size = sizeof(struct vdpau_picture_context),
+ .init = vdpau_h264_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