1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * This file is part of FFmpeg. 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 5cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 6cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 7cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 8cabdff1aSopenharmony_ci * 9cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 10cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 11cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12cabdff1aSopenharmony_ci * Lesser General Public License for more details. 13cabdff1aSopenharmony_ci * 14cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 15cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 16cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17cabdff1aSopenharmony_ci */ 18cabdff1aSopenharmony_ci 19cabdff1aSopenharmony_ci#ifndef AVCODEC_HWCONFIG_H 20cabdff1aSopenharmony_ci#define AVCODEC_HWCONFIG_H 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#include "avcodec.h" 23cabdff1aSopenharmony_ci#include "hwaccels.h" 24cabdff1aSopenharmony_ci 25cabdff1aSopenharmony_ci 26cabdff1aSopenharmony_ci#define HWACCEL_CAP_ASYNC_SAFE (1 << 0) 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_citypedef struct AVCodecHWConfigInternal { 30cabdff1aSopenharmony_ci /** 31cabdff1aSopenharmony_ci * This is the structure which will be returned to the user by 32cabdff1aSopenharmony_ci * avcodec_get_hw_config(). 33cabdff1aSopenharmony_ci */ 34cabdff1aSopenharmony_ci AVCodecHWConfig public; 35cabdff1aSopenharmony_ci /** 36cabdff1aSopenharmony_ci * If this configuration uses a hwaccel, a pointer to it. 37cabdff1aSopenharmony_ci * If not, NULL. 38cabdff1aSopenharmony_ci */ 39cabdff1aSopenharmony_ci const AVHWAccel *hwaccel; 40cabdff1aSopenharmony_ci} AVCodecHWConfigInternal; 41cabdff1aSopenharmony_ci 42cabdff1aSopenharmony_ci 43cabdff1aSopenharmony_ci// These macros are used to simplify AVCodecHWConfigInternal definitions. 44cabdff1aSopenharmony_ci 45cabdff1aSopenharmony_ci#define HW_CONFIG_HWACCEL(device, frames, ad_hoc, format, device_type_, name) \ 46cabdff1aSopenharmony_ci &(const AVCodecHWConfigInternal) { \ 47cabdff1aSopenharmony_ci .public = { \ 48cabdff1aSopenharmony_ci .pix_fmt = AV_PIX_FMT_ ## format, \ 49cabdff1aSopenharmony_ci .methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 0) | \ 50cabdff1aSopenharmony_ci (frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 0) | \ 51cabdff1aSopenharmony_ci (ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC : 0), \ 52cabdff1aSopenharmony_ci .device_type = AV_HWDEVICE_TYPE_ ## device_type_, \ 53cabdff1aSopenharmony_ci }, \ 54cabdff1aSopenharmony_ci .hwaccel = &name, \ 55cabdff1aSopenharmony_ci } 56cabdff1aSopenharmony_ci 57cabdff1aSopenharmony_ci#define HW_CONFIG_INTERNAL(format) \ 58cabdff1aSopenharmony_ci &(const AVCodecHWConfigInternal) { \ 59cabdff1aSopenharmony_ci .public = { \ 60cabdff1aSopenharmony_ci .pix_fmt = AV_PIX_FMT_ ## format, \ 61cabdff1aSopenharmony_ci .methods = AV_CODEC_HW_CONFIG_METHOD_INTERNAL, \ 62cabdff1aSopenharmony_ci .device_type = AV_HWDEVICE_TYPE_NONE, \ 63cabdff1aSopenharmony_ci }, \ 64cabdff1aSopenharmony_ci .hwaccel = NULL, \ 65cabdff1aSopenharmony_ci } 66cabdff1aSopenharmony_ci 67cabdff1aSopenharmony_ci#define HWACCEL_DXVA2(codec) \ 68cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 1, DXVA2_VLD, DXVA2, ff_ ## codec ## _dxva2_hwaccel) 69cabdff1aSopenharmony_ci#define HWACCEL_D3D11VA2(codec) \ 70cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 0, D3D11, D3D11VA, ff_ ## codec ## _d3d11va2_hwaccel) 71cabdff1aSopenharmony_ci#define HWACCEL_NVDEC(codec) \ 72cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 0, CUDA, CUDA, ff_ ## codec ## _nvdec_hwaccel) 73cabdff1aSopenharmony_ci#define HWACCEL_VAAPI(codec) \ 74cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 1, VAAPI, VAAPI, ff_ ## codec ## _vaapi_hwaccel) 75cabdff1aSopenharmony_ci#define HWACCEL_VDPAU(codec) \ 76cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 1, VDPAU, VDPAU, ff_ ## codec ## _vdpau_hwaccel) 77cabdff1aSopenharmony_ci#define HWACCEL_VIDEOTOOLBOX(codec) \ 78cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(1, 1, 1, VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel) 79cabdff1aSopenharmony_ci#define HWACCEL_D3D11VA(codec) \ 80cabdff1aSopenharmony_ci HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD, NONE, ff_ ## codec ## _d3d11va_hwaccel) 81cabdff1aSopenharmony_ci 82cabdff1aSopenharmony_ci#define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \ 83cabdff1aSopenharmony_ci &(const AVCodecHWConfigInternal) { \ 84cabdff1aSopenharmony_ci .public = { \ 85cabdff1aSopenharmony_ci .pix_fmt = AV_PIX_FMT_ ## format, \ 86cabdff1aSopenharmony_ci .methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 0) | \ 87cabdff1aSopenharmony_ci (frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 0) | \ 88cabdff1aSopenharmony_ci (ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC : 0), \ 89cabdff1aSopenharmony_ci .device_type = AV_HWDEVICE_TYPE_ ## device_type_, \ 90cabdff1aSopenharmony_ci }, \ 91cabdff1aSopenharmony_ci .hwaccel = NULL, \ 92cabdff1aSopenharmony_ci } 93cabdff1aSopenharmony_ci 94cabdff1aSopenharmony_ci#define HW_CONFIG_ENCODER_DEVICE(format, device_type_) \ 95cabdff1aSopenharmony_ci HW_CONFIG_ENCODER(1, 0, 0, format, device_type_) 96cabdff1aSopenharmony_ci 97cabdff1aSopenharmony_ci#define HW_CONFIG_ENCODER_FRAMES(format, device_type_) \ 98cabdff1aSopenharmony_ci HW_CONFIG_ENCODER(0, 1, 0, format, device_type_) 99cabdff1aSopenharmony_ci 100cabdff1aSopenharmony_ci#endif /* AVCODEC_HWCONFIG_H */ 101