2009-01-05 01:55:27 +02:00
|
|
|
/*
|
|
|
|
* Video Decode and Presentation API for UNIX (VDPAU) is used for
|
2010-03-15 01:52:45 +02:00
|
|
|
* HW decode acceleration for MPEG-1/2, MPEG-4 ASP, H.264 and VC-1.
|
2009-01-05 01:55:27 +02:00
|
|
|
*
|
2009-01-19 17:46:40 +02:00
|
|
|
* Copyright (c) 2008 NVIDIA
|
2009-01-05 01:55:27 +02: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
|
|
|
|
*/
|
|
|
|
|
2022-02-23 14:56:49 +02:00
|
|
|
#include "config_components.h"
|
|
|
|
|
2024-03-25 02:30:37 +02:00
|
|
|
#include "libavutil/mem.h"
|
2009-01-05 01:55:27 +02:00
|
|
|
#include "avcodec.h"
|
2017-10-19 16:38:20 +02:00
|
|
|
#include "decode.h"
|
2023-08-01 19:44:22 +02:00
|
|
|
#include "hwaccel_internal.h"
|
2014-10-04 16:55:04 +03:00
|
|
|
#include "internal.h"
|
2022-02-01 09:42:25 +02:00
|
|
|
#include "mpegvideodec.h"
|
2009-02-14 15:37:18 +02:00
|
|
|
#include "vdpau.h"
|
2009-01-05 01:55:27 +02:00
|
|
|
#include "vdpau_internal.h"
|
|
|
|
|
|
|
|
/**
|
2011-06-23 23:41:54 +03:00
|
|
|
* @addtogroup VDPAU_Decoding
|
2009-01-05 01:55:27 +02:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2014-10-04 16:55:02 +03:00
|
|
|
static int vdpau_error(VdpStatus status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case VDP_STATUS_OK:
|
|
|
|
return 0;
|
|
|
|
case VDP_STATUS_NO_IMPLEMENTATION:
|
|
|
|
return AVERROR(ENOSYS);
|
|
|
|
case VDP_STATUS_DISPLAY_PREEMPTED:
|
|
|
|
return AVERROR(EIO);
|
|
|
|
case VDP_STATUS_INVALID_HANDLE:
|
|
|
|
return AVERROR(EBADF);
|
|
|
|
case VDP_STATUS_INVALID_POINTER:
|
|
|
|
return AVERROR(EFAULT);
|
|
|
|
case VDP_STATUS_RESOURCES:
|
|
|
|
return AVERROR(ENOBUFS);
|
|
|
|
case VDP_STATUS_HANDLE_DEVICE_MISMATCH:
|
|
|
|
return AVERROR(EXDEV);
|
|
|
|
case VDP_STATUS_ERROR:
|
|
|
|
return AVERROR(EIO);
|
|
|
|
default:
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-05 18:26:40 +02:00
|
|
|
#if FF_API_VDPAU_ALLOC_GET_SET
|
2013-08-11 12:21:50 +03:00
|
|
|
AVVDPAUContext *av_alloc_vdpaucontext(void)
|
|
|
|
{
|
2024-03-05 18:26:40 +02:00
|
|
|
FF_DISABLE_DEPRECATION_WARNINGS
|
2013-11-14 15:08:36 +03:00
|
|
|
return av_vdpau_alloc_context();
|
2024-03-05 18:26:40 +02:00
|
|
|
FF_ENABLE_DEPRECATION_WARNINGS
|
2013-08-11 12:21:50 +03:00
|
|
|
}
|
|
|
|
|
2021-08-02 05:29:06 +02:00
|
|
|
#define MAKE_ACCESSORS(str, name, type, field) \
|
|
|
|
type av_##name##_get_##field(const str *s) { return s->field; } \
|
|
|
|
void av_##name##_set_##field(str *s, type v) { s->field = v; }
|
2013-08-07 22:22:48 +03:00
|
|
|
MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
|
2024-03-05 18:26:40 +02:00
|
|
|
#endif
|
2013-08-07 22:22:48 +03:00
|
|
|
|
2014-12-19 19:15:09 +02:00
|
|
|
int av_vdpau_get_surface_parameters(AVCodecContext *avctx,
|
|
|
|
VdpChromaType *type,
|
|
|
|
uint32_t *width, uint32_t *height)
|
|
|
|
{
|
|
|
|
VdpChromaType t;
|
|
|
|
uint32_t w = avctx->coded_width;
|
|
|
|
uint32_t h = avctx->coded_height;
|
|
|
|
|
|
|
|
/* See <vdpau/vdpau.h> for per-type alignment constraints. */
|
|
|
|
switch (avctx->sw_pix_fmt) {
|
|
|
|
case AV_PIX_FMT_YUV420P:
|
|
|
|
case AV_PIX_FMT_YUVJ420P:
|
2020-06-27 15:34:22 +02:00
|
|
|
case AV_PIX_FMT_YUV420P10:
|
|
|
|
case AV_PIX_FMT_YUV420P12:
|
2014-12-19 19:15:09 +02:00
|
|
|
t = VDP_CHROMA_TYPE_420;
|
|
|
|
w = (w + 1) & ~1;
|
|
|
|
h = (h + 3) & ~3;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_YUV422P:
|
|
|
|
case AV_PIX_FMT_YUVJ422P:
|
|
|
|
t = VDP_CHROMA_TYPE_422;
|
|
|
|
w = (w + 1) & ~1;
|
|
|
|
h = (h + 1) & ~1;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_YUV444P:
|
|
|
|
case AV_PIX_FMT_YUVJ444P:
|
2020-06-27 15:34:22 +02:00
|
|
|
case AV_PIX_FMT_YUV444P10:
|
|
|
|
case AV_PIX_FMT_YUV444P12:
|
2014-12-19 19:15:09 +02:00
|
|
|
t = VDP_CHROMA_TYPE_444;
|
|
|
|
h = (h + 1) & ~1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return AVERROR(ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type)
|
|
|
|
*type = t;
|
|
|
|
if (width)
|
|
|
|
*width = w;
|
|
|
|
if (height)
|
|
|
|
*height = h;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-19 16:38:20 +02:00
|
|
|
int ff_vdpau_common_frame_params(AVCodecContext *avctx,
|
|
|
|
AVBufferRef *hw_frames_ctx)
|
|
|
|
{
|
|
|
|
AVHWFramesContext *hw_frames = (AVHWFramesContext*)hw_frames_ctx->data;
|
|
|
|
VdpChromaType type;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
|
|
|
|
if (av_vdpau_get_surface_parameters(avctx, &type, &width, &height))
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
|
|
|
|
hw_frames->format = AV_PIX_FMT_VDPAU;
|
|
|
|
hw_frames->sw_format = avctx->sw_pix_fmt;
|
|
|
|
hw_frames->width = width;
|
|
|
|
hw_frames->height = height;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:04 +03:00
|
|
|
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
|
|
|
|
int level)
|
|
|
|
{
|
|
|
|
VDPAUHWContext *hwctx = avctx->hwaccel_context;
|
|
|
|
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
|
2014-10-04 16:55:08 +03:00
|
|
|
VdpVideoSurfaceQueryCapabilities *surface_query_caps;
|
|
|
|
VdpDecoderQueryCapabilities *decoder_query_caps;
|
2014-10-04 16:55:04 +03:00
|
|
|
VdpDecoderCreate *create;
|
2017-07-01 11:40:10 +02:00
|
|
|
VdpGetInformationString *info;
|
|
|
|
const char *info_string;
|
2014-10-04 16:55:04 +03:00
|
|
|
void *func;
|
|
|
|
VdpStatus status;
|
2014-10-04 16:55:08 +03:00
|
|
|
VdpBool supported;
|
|
|
|
uint32_t max_level, max_mb, max_width, max_height;
|
2014-12-19 19:15:09 +02:00
|
|
|
VdpChromaType type;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2017-10-19 16:38:20 +02:00
|
|
|
int ret;
|
2014-10-04 16:55:04 +03:00
|
|
|
|
2014-10-04 16:55:06 +03:00
|
|
|
vdctx->width = UINT32_MAX;
|
|
|
|
vdctx->height = UINT32_MAX;
|
|
|
|
|
2017-03-05 01:57:33 +02:00
|
|
|
if (av_vdpau_get_surface_parameters(avctx, &type, &width, &height))
|
|
|
|
return AVERROR(ENOSYS);
|
2014-10-06 15:10:37 +03:00
|
|
|
|
2017-03-05 01:57:33 +02:00
|
|
|
if (hwctx) {
|
|
|
|
hwctx->reset = 0;
|
|
|
|
|
|
|
|
if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
|
|
|
|
vdctx->decoder = hwctx->context.decoder;
|
|
|
|
vdctx->render = hwctx->context.render;
|
|
|
|
vdctx->device = VDP_INVALID_HANDLE;
|
|
|
|
return 0; /* Decoder created by user */
|
|
|
|
}
|
|
|
|
|
|
|
|
vdctx->device = hwctx->device;
|
|
|
|
vdctx->get_proc_address = hwctx->get_proc_address;
|
|
|
|
|
|
|
|
if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL)
|
|
|
|
level = 0;
|
|
|
|
|
|
|
|
if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) &&
|
|
|
|
type != VDP_CHROMA_TYPE_420)
|
|
|
|
return AVERROR(ENOSYS);
|
|
|
|
} else {
|
2017-10-19 16:38:20 +02:00
|
|
|
AVHWFramesContext *frames_ctx;
|
2017-03-05 01:57:33 +02:00
|
|
|
AVVDPAUDeviceContext *dev_ctx;
|
|
|
|
|
2017-10-19 16:38:20 +02:00
|
|
|
ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VDPAU);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2017-03-05 01:57:33 +02:00
|
|
|
|
2017-10-19 16:38:20 +02:00
|
|
|
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
|
2017-03-05 01:57:33 +02:00
|
|
|
dev_ctx = frames_ctx->device_ctx->hwctx;
|
|
|
|
|
|
|
|
vdctx->device = dev_ctx->device;
|
|
|
|
vdctx->get_proc_address = dev_ctx->get_proc_address;
|
|
|
|
|
|
|
|
if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_IGNORE_LEVEL)
|
|
|
|
level = 0;
|
2014-10-04 16:55:04 +03:00
|
|
|
}
|
|
|
|
|
2017-03-05 01:57:33 +02:00
|
|
|
if (level < 0)
|
2014-10-04 16:55:08 +03:00
|
|
|
return AVERROR(ENOTSUP);
|
|
|
|
|
2017-07-01 11:40:10 +02:00
|
|
|
status = vdctx->get_proc_address(vdctx->device,
|
|
|
|
VDP_FUNC_ID_GET_INFORMATION_STRING,
|
|
|
|
&func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
info = func;
|
|
|
|
|
|
|
|
status = info(&info_string);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
if (avctx->codec_id == AV_CODEC_ID_HEVC && strncmp(info_string, "NVIDIA ", 7) == 0 &&
|
|
|
|
!(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) {
|
2018-11-01 01:58:09 +02:00
|
|
|
int driver_version = 0;
|
2018-10-29 10:09:54 +02:00
|
|
|
sscanf(info_string, "NVIDIA VDPAU Driver Shared Library %d", &driver_version);
|
|
|
|
if (driver_version < 410) {
|
|
|
|
av_log(avctx, AV_LOG_VERBOSE, "HEVC with NVIDIA VDPAU drivers is buggy, skipping.\n");
|
|
|
|
return AVERROR(ENOTSUP);
|
|
|
|
}
|
2017-07-01 11:40:10 +02:00
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:08 +03:00
|
|
|
status = vdctx->get_proc_address(vdctx->device,
|
|
|
|
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
|
|
|
|
&func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
surface_query_caps = func;
|
|
|
|
|
2014-12-19 19:15:09 +02:00
|
|
|
status = surface_query_caps(vdctx->device, type, &supported,
|
2014-10-04 16:55:08 +03:00
|
|
|
&max_width, &max_height);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
if (supported != VDP_TRUE ||
|
|
|
|
max_width < width || max_height < height)
|
|
|
|
return AVERROR(ENOTSUP);
|
|
|
|
|
|
|
|
status = vdctx->get_proc_address(vdctx->device,
|
|
|
|
VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
|
|
|
|
&func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
decoder_query_caps = func;
|
|
|
|
|
|
|
|
status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
|
|
|
|
&max_mb, &max_width, &max_height);
|
2014-12-13 18:42:21 +02:00
|
|
|
#ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE
|
2015-09-26 15:17:23 +02:00
|
|
|
if ((status != VDP_STATUS_OK || supported != VDP_TRUE) && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) {
|
2014-12-13 18:42:21 +02:00
|
|
|
profile = VDP_DECODER_PROFILE_H264_MAIN;
|
|
|
|
status = decoder_query_caps(vdctx->device, profile, &supported,
|
|
|
|
&max_level, &max_mb,
|
|
|
|
&max_width, &max_height);
|
|
|
|
}
|
|
|
|
#endif
|
2014-10-04 16:55:08 +03:00
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
|
|
|
|
if (supported != VDP_TRUE || max_level < level ||
|
|
|
|
max_width < width || max_height < height)
|
|
|
|
return AVERROR(ENOTSUP);
|
|
|
|
|
2014-10-04 16:55:04 +03:00
|
|
|
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
|
|
|
|
&func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
create = func;
|
|
|
|
|
|
|
|
status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
|
|
|
|
&func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
vdctx->render = func;
|
|
|
|
|
|
|
|
status = create(vdctx->device, profile, width, height, avctx->refs,
|
|
|
|
&vdctx->decoder);
|
2014-10-04 16:55:06 +03:00
|
|
|
if (status == VDP_STATUS_OK) {
|
|
|
|
vdctx->width = avctx->coded_width;
|
|
|
|
vdctx->height = avctx->coded_height;
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:04 +03:00
|
|
|
return vdpau_error(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ff_vdpau_common_uninit(AVCodecContext *avctx)
|
|
|
|
{
|
|
|
|
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
|
|
|
|
VdpDecoderDestroy *destroy;
|
|
|
|
void *func;
|
|
|
|
VdpStatus status;
|
|
|
|
|
|
|
|
if (vdctx->device == VDP_INVALID_HANDLE)
|
|
|
|
return 0; /* Decoder created and destroyed by user */
|
2014-10-04 16:55:06 +03:00
|
|
|
if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
|
|
|
|
return 0;
|
2014-10-04 16:55:04 +03:00
|
|
|
|
|
|
|
status = vdctx->get_proc_address(vdctx->device,
|
|
|
|
VDP_FUNC_ID_DECODER_DESTROY, &func);
|
|
|
|
if (status != VDP_STATUS_OK)
|
|
|
|
return vdpau_error(status);
|
|
|
|
else
|
|
|
|
destroy = func;
|
|
|
|
|
|
|
|
status = destroy(vdctx->decoder);
|
|
|
|
return vdpau_error(status);
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:06 +03:00
|
|
|
static int ff_vdpau_common_reinit(AVCodecContext *avctx)
|
|
|
|
{
|
2014-10-04 16:55:07 +03:00
|
|
|
VDPAUHWContext *hwctx = avctx->hwaccel_context;
|
2014-10-04 16:55:06 +03:00
|
|
|
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
|
|
|
|
|
|
|
|
if (vdctx->device == VDP_INVALID_HANDLE)
|
|
|
|
return 0; /* Decoder created by user */
|
|
|
|
if (avctx->coded_width == vdctx->width &&
|
2017-03-05 01:57:33 +02:00
|
|
|
avctx->coded_height == vdctx->height && (!hwctx || !hwctx->reset))
|
2014-10-04 16:55:06 +03:00
|
|
|
return 0;
|
|
|
|
|
2023-08-01 19:44:22 +02:00
|
|
|
FF_HW_SIMPLE_CALL(avctx, uninit);
|
|
|
|
return FF_HW_SIMPLE_CALL(avctx, init);
|
2014-10-04 16:55:06 +03:00
|
|
|
}
|
|
|
|
|
2014-03-20 10:53:16 +03:00
|
|
|
int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
|
2013-01-12 18:53:43 +03:00
|
|
|
av_unused const uint8_t *buffer,
|
|
|
|
av_unused uint32_t size)
|
|
|
|
{
|
2013-07-25 22:30:20 +03:00
|
|
|
pic_ctx->bitstream_buffers_allocated = 0;
|
|
|
|
pic_ctx->bitstream_buffers_used = 0;
|
|
|
|
pic_ctx->bitstream_buffers = NULL;
|
2013-01-12 18:53:43 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-04 16:55:03 +03:00
|
|
|
int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
|
|
|
|
struct vdpau_picture_context *pic_ctx)
|
2013-01-12 18:53:43 +03:00
|
|
|
{
|
2014-10-04 16:55:05 +03:00
|
|
|
VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
|
2013-01-12 18:53:43 +03:00
|
|
|
AVVDPAUContext *hwctx = avctx->hwaccel_context;
|
2014-10-04 16:55:03 +03:00
|
|
|
VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
|
|
|
|
VdpStatus status;
|
2014-10-04 16:55:06 +03:00
|
|
|
int val;
|
|
|
|
|
|
|
|
val = ff_vdpau_common_reinit(avctx);
|
|
|
|
if (val < 0)
|
|
|
|
return val;
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2017-03-05 01:57:33 +02:00
|
|
|
if (hwctx && !hwctx->render && hwctx->render2) {
|
2014-10-06 13:04:25 +03:00
|
|
|
status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info,
|
|
|
|
pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
|
2013-08-07 22:22:48 +03:00
|
|
|
} else
|
2015-10-30 16:26:25 +02:00
|
|
|
status = vdctx->render(vdctx->decoder, surf, &pic_ctx->info,
|
2014-10-04 16:55:03 +03:00
|
|
|
pic_ctx->bitstream_buffers_used,
|
|
|
|
pic_ctx->bitstream_buffers);
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2013-07-25 22:30:20 +03:00
|
|
|
av_freep(&pic_ctx->bitstream_buffers);
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2014-10-04 16:55:03 +03:00
|
|
|
return vdpau_error(status);
|
|
|
|
}
|
|
|
|
|
2015-11-04 05:29:22 +02:00
|
|
|
#if CONFIG_MPEG1_VDPAU_HWACCEL || \
|
2013-03-27 00:47:29 +03:00
|
|
|
CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
|
|
|
|
CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
|
2013-02-03 13:10:05 +03:00
|
|
|
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
|
2013-01-12 18:53:43 +03:00
|
|
|
{
|
2013-02-03 13:10:05 +03:00
|
|
|
MpegEncContext *s = avctx->priv_data;
|
2023-10-08 12:25:07 +02:00
|
|
|
MPVPicture *pic = s->cur_pic.ptr;
|
2013-07-25 22:30:20 +03:00
|
|
|
struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
|
2014-10-04 16:55:03 +03:00
|
|
|
int val;
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2014-10-04 16:55:03 +03:00
|
|
|
val = ff_vdpau_common_end_frame(avctx, pic->f, pic_ctx);
|
|
|
|
if (val < 0)
|
|
|
|
return val;
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2013-02-03 13:10:05 +03:00
|
|
|
ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
|
2013-01-12 18:53:43 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-27 00:47:29 +03:00
|
|
|
#endif
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2014-03-20 10:53:16 +03:00
|
|
|
int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx,
|
|
|
|
const uint8_t *buf, uint32_t size)
|
2013-01-12 18:53:43 +03:00
|
|
|
{
|
2013-07-25 22:30:20 +03:00
|
|
|
VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
|
2013-01-12 18:53:43 +03:00
|
|
|
|
2013-07-25 22:30:20 +03:00
|
|
|
buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
|
|
|
|
(pic_ctx->bitstream_buffers_used + 1) * sizeof(*buffers));
|
2013-01-12 18:53:43 +03:00
|
|
|
if (!buffers)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
2013-07-25 22:30:20 +03:00
|
|
|
pic_ctx->bitstream_buffers = buffers;
|
|
|
|
buffers += pic_ctx->bitstream_buffers_used++;
|
2013-01-12 18:53:43 +03:00
|
|
|
|
|
|
|
buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
|
|
|
|
buffers->bitstream = buf;
|
|
|
|
buffers->bitstream_bytes = size;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-08-17 16:31:14 +03:00
|
|
|
|
2024-03-05 18:26:40 +02:00
|
|
|
#if FF_API_VDPAU_ALLOC_GET_SET
|
2013-11-03 00:01:14 +03:00
|
|
|
AVVDPAUContext *av_vdpau_alloc_context(void)
|
|
|
|
{
|
2017-10-09 01:40:26 +02:00
|
|
|
return av_mallocz(sizeof(VDPAUHWContext));
|
2013-11-03 00:01:14 +03:00
|
|
|
}
|
2024-03-05 18:26:40 +02:00
|
|
|
#endif
|
2013-11-03 00:01:14 +03:00
|
|
|
|
2014-10-04 16:55:07 +03:00
|
|
|
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,
|
|
|
|
VdpGetProcAddress *get_proc, unsigned flags)
|
|
|
|
{
|
|
|
|
VDPAUHWContext *hwctx;
|
|
|
|
|
2014-12-19 19:15:10 +02:00
|
|
|
if (flags & ~(AV_HWACCEL_FLAG_IGNORE_LEVEL|AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH))
|
2014-10-14 12:59:53 +03:00
|
|
|
return AVERROR(EINVAL);
|
|
|
|
|
2014-10-04 16:55:07 +03:00
|
|
|
if (av_reallocp(&avctx->hwaccel_context, sizeof(*hwctx)))
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
hwctx = avctx->hwaccel_context;
|
|
|
|
|
|
|
|
memset(hwctx, 0, sizeof(*hwctx));
|
|
|
|
hwctx->context.decoder = VDP_INVALID_HANDLE;
|
|
|
|
hwctx->device = device;
|
|
|
|
hwctx->get_proc_address = get_proc;
|
2014-10-14 12:59:54 +03:00
|
|
|
hwctx->flags = flags;
|
2014-10-04 16:55:07 +03:00
|
|
|
hwctx->reset = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-05 01:55:27 +02:00
|
|
|
/* @}*/
|