summaryrefslogtreecommitdiff
path: root/libavcodec/vdpau.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-06 12:32:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-06 12:38:26 +0200
commit10b6d7462cbf0d13913c9d07e85c79210427d71e (patch)
treeff6dffb91bb5c46b7aefcc5296523dacf67c1abb /libavcodec/vdpau.c
parentb64b719ad5c212e197009fa3f1e7aa96255cbd28 (diff)
parentce083282f0a8b7d63c4047c30b7bac498f9806dd (diff)
Merge commit 'ce083282f0a8b7d63c4047c30b7bac498f9806dd'
* commit 'ce083282f0a8b7d63c4047c30b7bac498f9806dd': vdpau: common support for managing the VdpDecoder in avcodec Conflicts: libavcodec/vdpau.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vdpau.c')
-rw-r--r--libavcodec/vdpau.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 9ac423a0eb..4fe486bce6 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -22,7 +22,9 @@
*/
#include <limits.h>
+#include "libavutil/avassert.h"
#include "avcodec.h"
+#include "internal.h"
#include "h264.h"
#include "vc1.h"
@@ -69,6 +71,68 @@ AVVDPAUContext *av_alloc_vdpaucontext(void)
MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
+int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
+ int level)
+{
+ VDPAUHWContext *hwctx = avctx->hwaccel_context;
+ VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
+ VdpDecoderCreate *create;
+ void *func;
+ VdpStatus status;
+ /* See vdpau/vdpau.h for alignment constraints. */
+ uint32_t width = (avctx->coded_width + 1) & ~1;
+ uint32_t height = (avctx->coded_height + 3) & ~3;
+
+ if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
+ vdctx->decoder = hwctx->context.decoder;
+ vdctx->render = hwctx->context.render;
+ vdctx->device = VDP_INVALID_HANDLE;
+ return 0; /* Decoder created by user */
+ }
+
+ vdctx->device = hwctx->device;
+ vdctx->get_proc_address = hwctx->get_proc_address;
+
+ status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
+ &func);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ else
+ create = func;
+
+ status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
+ &func);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ else
+ vdctx->render = func;
+
+ status = create(vdctx->device, profile, width, height, avctx->refs,
+ &vdctx->decoder);
+ return vdpau_error(status);
+}
+
+int ff_vdpau_common_uninit(AVCodecContext *avctx)
+{
+ VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
+ VdpDecoderDestroy *destroy;
+ void *func;
+ VdpStatus status;
+
+ if (vdctx->device == VDP_INVALID_HANDLE)
+ return 0; /* Decoder created and destroyed by user */
+
+ status = vdctx->get_proc_address(vdctx->device,
+ VDP_FUNC_ID_DECODER_DESTROY, &func);
+ if (status != VDP_STATUS_OK)
+ return vdpau_error(status);
+ else
+ destroy = func;
+
+ status = destroy(vdctx->decoder);
+ return vdpau_error(status);
+}
+
int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
av_unused const uint8_t *buffer,
av_unused uint32_t size)