summaryrefslogtreecommitdiff
path: root/libavcodec/vdpau_h264.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2013-08-07 21:22:48 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2013-08-11 20:16:57 +0200
commitd404fe35b2fb918e38e58c2256a77b8113229951 (patch)
treec3e2acd88f9bf557a6936b1addbd6552de181af2 /libavcodec/vdpau_h264.c
parentaf05edc658f3af284a1af39c00a36aeff0adaa0d (diff)
downloadffmpeg-d404fe35b2fb918e38e58c2256a77b8113229951.tar.gz
Make new VDPAU easier to use by adding context to callback.
Using VDPAU correctly means checking for preemption and possibly regenerating the context all the time. With the current API there is no context or other user-defined pointer and thus this in not possible during decoding unless using some hack like global variables. The need to reinitialize both surfaces and even function pointers makes handling preemption even more difficult. This patch introduces a new render2 function that gets both the AVCodecContext and AVFrame in addition, in both the user can store additional opaque data. This allows even advanced approaches like keeping a "generation counter" for the surfaces so they can be regenerated on the fly and efficiently. In addition, the function has a return value that will be passed through all the way instead of being silently ignored as for the current render function. Unfortunately the HWAccel API has no way of providing API/ABI compatibility, so a currently disallowed state (render pointer being NULL) is used to extend it. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/vdpau_h264.c')
-rw-r--r--libavcodec/vdpau_h264.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 06a9582913..3f6415d4f8 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -188,19 +188,24 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
static int vdpau_h264_end_frame(AVCodecContext *avctx)
{
+ int res = 0;
AVVDPAUContext *hwctx = avctx->hwaccel_context;
H264Context *h = avctx->priv_data;
Picture *pic = h->cur_pic_ptr;
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+ if (!hwctx->render) {
+ res = hwctx->render2(avctx, &pic->f, (void *)&pic_ctx->info,
+ pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
+ } else
hwctx->render(hwctx->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);
av_freep(&pic_ctx->bitstream_buffers);
- return 0;
+ return res;
}
AVHWAccel ff_h264_vdpau_hwaccel = {