diff options
author | RĂ©mi Denis-Courmont <remi@remlab.net> | 2013-01-12 17:53:43 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2013-01-13 14:41:27 +0100 |
commit | 44e065d56c87d6a9d0effccec5f31517f72924ec (patch) | |
tree | 1a3b2b88390b09144c718450adc107936cc914bd /libavcodec/vdpau.c | |
parent | 22c436c85e0dd81702b4e9289b90755b7310982f (diff) | |
download | ffmpeg-44e065d56c87d6a9d0effccec5f31517f72924ec.tar.gz |
vdpau: Add context and common helpers for hwaccel support
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavcodec/vdpau.c')
-rw-r--r-- | libavcodec/vdpau.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 6daf494b60..851c7cb9f3 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; |