1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * The Video Decode and Presentation API for UNIX (VDPAU) is used for 3cabdff1aSopenharmony_ci * hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1. 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * Copyright (C) 2008 NVIDIA 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * This file is part of FFmpeg. 8cabdff1aSopenharmony_ci * 9cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 10cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 11cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 12cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 13cabdff1aSopenharmony_ci * 14cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 15cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 16cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17cabdff1aSopenharmony_ci * Lesser General Public License for more details. 18cabdff1aSopenharmony_ci * 19cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 20cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 21cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22cabdff1aSopenharmony_ci */ 23cabdff1aSopenharmony_ci 24cabdff1aSopenharmony_ci#ifndef AVCODEC_VDPAU_H 25cabdff1aSopenharmony_ci#define AVCODEC_VDPAU_H 26cabdff1aSopenharmony_ci 27cabdff1aSopenharmony_ci/** 28cabdff1aSopenharmony_ci * @file 29cabdff1aSopenharmony_ci * @ingroup lavc_codec_hwaccel_vdpau 30cabdff1aSopenharmony_ci * Public libavcodec VDPAU header. 31cabdff1aSopenharmony_ci */ 32cabdff1aSopenharmony_ci 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ci/** 35cabdff1aSopenharmony_ci * @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer 36cabdff1aSopenharmony_ci * @ingroup lavc_codec_hwaccel 37cabdff1aSopenharmony_ci * 38cabdff1aSopenharmony_ci * VDPAU hardware acceleration has two modules 39cabdff1aSopenharmony_ci * - VDPAU decoding 40cabdff1aSopenharmony_ci * - VDPAU presentation 41cabdff1aSopenharmony_ci * 42cabdff1aSopenharmony_ci * The VDPAU decoding module parses all headers using FFmpeg 43cabdff1aSopenharmony_ci * parsing mechanisms and uses VDPAU for the actual decoding. 44cabdff1aSopenharmony_ci * 45cabdff1aSopenharmony_ci * As per the current implementation, the actual decoding 46cabdff1aSopenharmony_ci * and rendering (API calls) are done as part of the VDPAU 47cabdff1aSopenharmony_ci * presentation (vo_vdpau.c) module. 48cabdff1aSopenharmony_ci * 49cabdff1aSopenharmony_ci * @{ 50cabdff1aSopenharmony_ci */ 51cabdff1aSopenharmony_ci 52cabdff1aSopenharmony_ci#include <vdpau/vdpau.h> 53cabdff1aSopenharmony_ci 54cabdff1aSopenharmony_ci#include "libavutil/avconfig.h" 55cabdff1aSopenharmony_ci#include "libavutil/attributes.h" 56cabdff1aSopenharmony_ci 57cabdff1aSopenharmony_ci#include "avcodec.h" 58cabdff1aSopenharmony_ci 59cabdff1aSopenharmony_cistruct AVCodecContext; 60cabdff1aSopenharmony_cistruct AVFrame; 61cabdff1aSopenharmony_ci 62cabdff1aSopenharmony_citypedef int (*AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *, 63cabdff1aSopenharmony_ci const VdpPictureInfo *, uint32_t, 64cabdff1aSopenharmony_ci const VdpBitstreamBuffer *); 65cabdff1aSopenharmony_ci 66cabdff1aSopenharmony_ci/** 67cabdff1aSopenharmony_ci * This structure is used to share data between the libavcodec library and 68cabdff1aSopenharmony_ci * the client video application. 69cabdff1aSopenharmony_ci * The user shall allocate the structure via the av_alloc_vdpau_hwaccel 70cabdff1aSopenharmony_ci * function and make it available as 71cabdff1aSopenharmony_ci * AVCodecContext.hwaccel_context. Members can be set by the user once 72cabdff1aSopenharmony_ci * during initialization or through each AVCodecContext.get_buffer() 73cabdff1aSopenharmony_ci * function call. In any case, they must be valid prior to calling 74cabdff1aSopenharmony_ci * decoding functions. 75cabdff1aSopenharmony_ci * 76cabdff1aSopenharmony_ci * The size of this structure is not a part of the public ABI and must not 77cabdff1aSopenharmony_ci * be used outside of libavcodec. Use av_vdpau_alloc_context() to allocate an 78cabdff1aSopenharmony_ci * AVVDPAUContext. 79cabdff1aSopenharmony_ci */ 80cabdff1aSopenharmony_citypedef struct AVVDPAUContext { 81cabdff1aSopenharmony_ci /** 82cabdff1aSopenharmony_ci * VDPAU decoder handle 83cabdff1aSopenharmony_ci * 84cabdff1aSopenharmony_ci * Set by user. 85cabdff1aSopenharmony_ci */ 86cabdff1aSopenharmony_ci VdpDecoder decoder; 87cabdff1aSopenharmony_ci 88cabdff1aSopenharmony_ci /** 89cabdff1aSopenharmony_ci * VDPAU decoder render callback 90cabdff1aSopenharmony_ci * 91cabdff1aSopenharmony_ci * Set by the user. 92cabdff1aSopenharmony_ci */ 93cabdff1aSopenharmony_ci VdpDecoderRender *render; 94cabdff1aSopenharmony_ci 95cabdff1aSopenharmony_ci AVVDPAU_Render2 render2; 96cabdff1aSopenharmony_ci} AVVDPAUContext; 97cabdff1aSopenharmony_ci 98cabdff1aSopenharmony_ci/** 99cabdff1aSopenharmony_ci * @brief allocation function for AVVDPAUContext 100cabdff1aSopenharmony_ci * 101cabdff1aSopenharmony_ci * Allows extending the struct without breaking API/ABI 102cabdff1aSopenharmony_ci */ 103cabdff1aSopenharmony_ciAVVDPAUContext *av_alloc_vdpaucontext(void); 104cabdff1aSopenharmony_ci 105cabdff1aSopenharmony_ciAVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *); 106cabdff1aSopenharmony_civoid av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2); 107cabdff1aSopenharmony_ci 108cabdff1aSopenharmony_ci/** 109cabdff1aSopenharmony_ci * Associate a VDPAU device with a codec context for hardware acceleration. 110cabdff1aSopenharmony_ci * This function is meant to be called from the get_format() codec callback, 111cabdff1aSopenharmony_ci * or earlier. It can also be called after avcodec_flush_buffers() to change 112cabdff1aSopenharmony_ci * the underlying VDPAU device mid-stream (e.g. to recover from non-transparent 113cabdff1aSopenharmony_ci * display preemption). 114cabdff1aSopenharmony_ci * 115cabdff1aSopenharmony_ci * @note get_format() must return AV_PIX_FMT_VDPAU if this function completes 116cabdff1aSopenharmony_ci * successfully. 117cabdff1aSopenharmony_ci * 118cabdff1aSopenharmony_ci * @param avctx decoding context whose get_format() callback is invoked 119cabdff1aSopenharmony_ci * @param device VDPAU device handle to use for hardware acceleration 120cabdff1aSopenharmony_ci * @param get_proc_address VDPAU device driver 121cabdff1aSopenharmony_ci * @param flags zero of more OR'd AV_HWACCEL_FLAG_* flags 122cabdff1aSopenharmony_ci * 123cabdff1aSopenharmony_ci * @return 0 on success, an AVERROR code on failure. 124cabdff1aSopenharmony_ci */ 125cabdff1aSopenharmony_ciint av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, 126cabdff1aSopenharmony_ci VdpGetProcAddress *get_proc_address, unsigned flags); 127cabdff1aSopenharmony_ci 128cabdff1aSopenharmony_ci/** 129cabdff1aSopenharmony_ci * Gets the parameters to create an adequate VDPAU video surface for the codec 130cabdff1aSopenharmony_ci * context using VDPAU hardware decoding acceleration. 131cabdff1aSopenharmony_ci * 132cabdff1aSopenharmony_ci * @note Behavior is undefined if the context was not successfully bound to a 133cabdff1aSopenharmony_ci * VDPAU device using av_vdpau_bind_context(). 134cabdff1aSopenharmony_ci * 135cabdff1aSopenharmony_ci * @param avctx the codec context being used for decoding the stream 136cabdff1aSopenharmony_ci * @param type storage space for the VDPAU video surface chroma type 137cabdff1aSopenharmony_ci * (or NULL to ignore) 138cabdff1aSopenharmony_ci * @param width storage space for the VDPAU video surface pixel width 139cabdff1aSopenharmony_ci * (or NULL to ignore) 140cabdff1aSopenharmony_ci * @param height storage space for the VDPAU video surface pixel height 141cabdff1aSopenharmony_ci * (or NULL to ignore) 142cabdff1aSopenharmony_ci * 143cabdff1aSopenharmony_ci * @return 0 on success, a negative AVERROR code on failure. 144cabdff1aSopenharmony_ci */ 145cabdff1aSopenharmony_ciint av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, 146cabdff1aSopenharmony_ci uint32_t *width, uint32_t *height); 147cabdff1aSopenharmony_ci 148cabdff1aSopenharmony_ci/** 149cabdff1aSopenharmony_ci * Allocate an AVVDPAUContext. 150cabdff1aSopenharmony_ci * 151cabdff1aSopenharmony_ci * @return Newly-allocated AVVDPAUContext or NULL on failure. 152cabdff1aSopenharmony_ci */ 153cabdff1aSopenharmony_ciAVVDPAUContext *av_vdpau_alloc_context(void); 154cabdff1aSopenharmony_ci 155cabdff1aSopenharmony_ci/* @}*/ 156cabdff1aSopenharmony_ci 157cabdff1aSopenharmony_ci#endif /* AVCODEC_VDPAU_H */ 158