summaryrefslogtreecommitdiff
path: root/libavcodec/vdpau.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-14 13:29:00 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-14 13:29:00 +0100
commit8ee7b3881bfe96981de28d6eedaf1dcb59fe3215 (patch)
tree33a4bbe392eba0869b79b69c97ca8226fa2b6b00 /libavcodec/vdpau.c
parenta601eb9543ecab09aa69a6673e553318daf7ea57 (diff)
parent44e065d56c87d6a9d0effccec5f31517f72924ec (diff)
Merge commit '44e065d56c87d6a9d0effccec5f31517f72924ec'
* commit '44e065d56c87d6a9d0effccec5f31517f72924ec': vdpau: Add context and common helpers for hwaccel support Conflicts: Changelog doc/APIchanges libavcodec/vdpau.h libavcodec/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vdpau.c')
-rw-r--r--libavcodec/vdpau.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 6ac195ec00..20ce97b5fe 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -38,6 +38,55 @@
* @{
*/
+int ff_vdpau_common_start_frame(AVCodecContext *avctx,
+ av_unused const uint8_t *buffer,
+ av_unused uint32_t size)
+{
+ AVVDPAUContext *hwctx = avctx->hwaccel_context;
+
+ hwctx->bitstream_buffers_used = 0;
+ return 0;
+}
+
+int ff_vdpau_common_end_frame(AVCodecContext *avctx)
+{
+ MpegEncContext * const s = avctx->priv_data;
+ AVVDPAUContext *hwctx = avctx->hwaccel_context;
+
+ if (hwctx->bitstream_buffers_used) {
+ VdpVideoSurface surf = ff_vdpau_get_surface_id(s->current_picture_ptr);
+
+ hwctx->render(hwctx->decoder, surf, (void *)&hwctx->info,
+ hwctx->bitstream_buffers_used, hwctx->bitstream_buffers);
+
+ ff_draw_horiz_band(s, 0, s->avctx->height);
+ hwctx->bitstream_buffers_used = 0;
+ }
+ return 0;
+}
+
+int ff_vdpau_add_buffer(AVCodecContext *avctx,
+ const uint8_t *buf, uint32_t size)
+{
+ AVVDPAUContext *hwctx = avctx->hwaccel_context;
+ VdpBitstreamBuffer *buffers = hwctx->bitstream_buffers;
+
+ buffers = av_fast_realloc(buffers, &hwctx->bitstream_buffers_allocated,
+ (hwctx->bitstream_buffers_used + 1) * sizeof(*buffers));
+ if (!buffers)
+ return AVERROR(ENOMEM);
+
+ hwctx->bitstream_buffers = buffers;
+ buffers += hwctx->bitstream_buffers_used++;
+
+ buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
+ buffers->bitstream = buf;
+ buffers->bitstream_bytes = size;
+ return 0;
+}
+
+/* Obsolete non-hwaccel VDPAU support below... */
+
void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
{
H264Context *h = s->avctx->priv_data;