2009-01-05 00:55:27 +01:00
|
|
|
/*
|
|
|
|
* Video Decode and Presentation API for UNIX (VDPAU) is used for
|
2010-03-15 00:52:45 +01:00
|
|
|
* HW decode acceleration for MPEG-1/2, MPEG-4 ASP, H.264 and VC-1.
|
2009-01-05 00:55:27 +01:00
|
|
|
*
|
2009-01-19 16:46:40 +01:00
|
|
|
* Copyright (c) 2008 NVIDIA
|
2009-01-05 00:55:27 +01:00
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include "avcodec.h"
|
|
|
|
#include "h264.h"
|
2009-01-20 10:28:36 +01:00
|
|
|
#include "vc1.h"
|
2009-01-05 00:55:27 +01:00
|
|
|
|
|
|
|
#undef NDEBUG
|
|
|
|
#include <assert.h>
|
|
|
|
|
2009-02-14 14:37:18 +01:00
|
|
|
#include "vdpau.h"
|
2009-01-05 00:55:27 +01:00
|
|
|
#include "vdpau_internal.h"
|
|
|
|
|
|
|
|
/**
|
2011-06-23 22:41:54 +02:00
|
|
|
* @addtogroup VDPAU_Decoding
|
2009-01-05 00:55:27 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
int ff_vdpau_common_start_frame(Picture *pic,
|
2013-01-12 16:53:43 +01:00
|
|
|
av_unused const uint8_t *buffer,
|
|
|
|
av_unused uint32_t size)
|
|
|
|
{
|
2013-07-25 21:30:20 +02:00
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
2013-01-12 16:53:43 +01:00
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
pic_ctx->bitstream_buffers_allocated = 0;
|
|
|
|
pic_ctx->bitstream_buffers_used = 0;
|
|
|
|
pic_ctx->bitstream_buffers = NULL;
|
2013-01-12 16:53:43 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-26 22:47:29 +01:00
|
|
|
#if CONFIG_H263_VDPAU_HWACCEL || CONFIG_MPEG1_VDPAU_HWACCEL || \
|
|
|
|
CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
|
|
|
|
CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
|
2013-02-03 11:10:05 +01:00
|
|
|
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
|
2013-01-12 16:53:43 +01:00
|
|
|
{
|
|
|
|
AVVDPAUContext *hwctx = avctx->hwaccel_context;
|
2013-02-03 11:10:05 +01:00
|
|
|
MpegEncContext *s = avctx->priv_data;
|
2013-07-25 21:30:20 +02:00
|
|
|
Picture *pic = s->current_picture_ptr;
|
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
|
|
|
VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
|
2013-01-12 16:53:43 +01:00
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
|
|
|
|
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
|
2013-01-12 16:53:43 +01:00
|
|
|
|
2013-02-03 11:10:05 +01:00
|
|
|
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
2013-07-25 21:30:20 +02:00
|
|
|
av_freep(&pic_ctx->bitstream_buffers);
|
2013-01-12 16:53:43 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-26 22:47:29 +01:00
|
|
|
#endif
|
2013-01-12 16:53:43 +01:00
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t size)
|
2013-01-12 16:53:43 +01:00
|
|
|
{
|
2013-07-25 21:30:20 +02:00
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
|
|
|
VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
|
2013-01-12 16:53:43 +01:00
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
|
|
|
|
(pic_ctx->bitstream_buffers_used + 1) * sizeof(*buffers));
|
2013-01-12 16:53:43 +01:00
|
|
|
if (!buffers)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
2013-07-25 21:30:20 +02:00
|
|
|
pic_ctx->bitstream_buffers = buffers;
|
|
|
|
buffers += pic_ctx->bitstream_buffers_used++;
|
2013-01-12 16:53:43 +01:00
|
|
|
|
|
|
|
buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
|
|
|
|
buffers->bitstream = buf;
|
|
|
|
buffers->bitstream_bytes = size;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-01-05 00:55:27 +01:00
|
|
|
/* @}*/
|