[FFmpeg-devel] [PATCH] Try to make new VDPAU usable by adding context to callback.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Wed Aug 7 21:28:15 CEST 2013
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
unless using some hack like global variables.
This introduces a new decode function that gets
both the AVCodecContext and AVFrame in addition,
in both the user can store additional opaque data.
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.
An alternative would be to add the new function pointer
to the AVCodecContext.
Strictly speaking this probably doesn't have to be under
!INCOMPATIBLE condition.
---
libavcodec/vdpau.c | 6 ++++++
libavcodec/vdpau.h | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index cf564a5..218d218 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -61,6 +61,12 @@ int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+#if !AV_HAVE_INCOMPATIBLE_LIBAV_ABI
+ if (!hwctx->render) {
+ hwctx->render2(avctx, &pic->f, surf, (void *)&pic_ctx->info,
+ pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
+ } else
+#endif
hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index 08116bf..b77d988 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -128,6 +128,12 @@ typedef struct AVVDPAUContext {
attribute_deprecated
VdpBitstreamBuffer *bitstream_buffers;
#endif
+#if !AV_HAVE_INCOMPATIBLE_LIBAV_ABI
+ int (*render2)(struct AVCodecContext *, struct AVFrame *, VdpVideoSurface,
+ const VdpPictureInfo *,
+ uint32_t,
+ const VdpBitstreamBuffer *);
+#endif
} AVVDPAUContext;
#if FF_API_CAP_VDPAU
--
1.8.3.2
More information about the ffmpeg-devel
mailing list