2016-11-24 14:14:22 +00:00
|
|
|
/*
|
2017-03-21 11:34:50 +00:00
|
|
|
* This file is part of FFmpeg.
|
2016-11-24 14:14:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-04-13 15:33:14 +00:00
|
|
|
#ifndef AVCODEC_HWCONFIG_H
|
|
|
|
#define AVCODEC_HWCONFIG_H
|
2016-11-24 14:14:22 +00:00
|
|
|
|
2017-10-25 23:18:39 +00:00
|
|
|
#include "avcodec.h"
|
2017-10-25 23:18:40 +00:00
|
|
|
#include "hwaccels.h"
|
2017-10-25 23:18:39 +00:00
|
|
|
|
|
|
|
typedef struct AVCodecHWConfigInternal {
|
|
|
|
/**
|
|
|
|
* This is the structure which will be returned to the user by
|
|
|
|
* avcodec_get_hw_config().
|
|
|
|
*/
|
|
|
|
AVCodecHWConfig public;
|
|
|
|
/**
|
|
|
|
* If this configuration uses a hwaccel, a pointer to it.
|
|
|
|
* If not, NULL.
|
|
|
|
*/
|
2023-08-01 17:44:22 +00:00
|
|
|
const struct FFHWAccel *hwaccel;
|
2017-10-25 23:18:39 +00:00
|
|
|
} AVCodecHWConfigInternal;
|
|
|
|
|
2023-04-28 09:48:04 +00:00
|
|
|
void ff_hwaccel_uninit(AVCodecContext *avctx);
|
2017-10-25 23:18:39 +00:00
|
|
|
|
2017-10-25 23:18:40 +00:00
|
|
|
// These macros are used to simplify AVCodecHWConfigInternal definitions.
|
|
|
|
|
2017-12-08 15:59:39 +00:00
|
|
|
#define HW_CONFIG_HWACCEL(device, frames, ad_hoc, format, device_type_, name) \
|
2017-10-25 23:18:40 +00:00
|
|
|
&(const AVCodecHWConfigInternal) { \
|
|
|
|
.public = { \
|
|
|
|
.pix_fmt = AV_PIX_FMT_ ## format, \
|
2017-12-08 15:59:39 +00:00
|
|
|
.methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 0) | \
|
|
|
|
(frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 0) | \
|
|
|
|
(ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC : 0), \
|
|
|
|
.device_type = AV_HWDEVICE_TYPE_ ## device_type_, \
|
2017-10-25 23:18:40 +00:00
|
|
|
}, \
|
|
|
|
.hwaccel = &name, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HW_CONFIG_INTERNAL(format) \
|
|
|
|
&(const AVCodecHWConfigInternal) { \
|
|
|
|
.public = { \
|
|
|
|
.pix_fmt = AV_PIX_FMT_ ## format, \
|
|
|
|
.methods = AV_CODEC_HW_CONFIG_METHOD_INTERNAL, \
|
|
|
|
.device_type = AV_HWDEVICE_TYPE_NONE, \
|
|
|
|
}, \
|
|
|
|
.hwaccel = NULL, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HWACCEL_DXVA2(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 1, DXVA2_VLD, DXVA2, ff_ ## codec ## _dxva2_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_D3D11VA2(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 0, D3D11, D3D11VA, ff_ ## codec ## _d3d11va2_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_NVDEC(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 0, CUDA, CUDA, ff_ ## codec ## _nvdec_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_VAAPI(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 1, VAAPI, VAAPI, ff_ ## codec ## _vaapi_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_VDPAU(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 1, VDPAU, VDPAU, ff_ ## codec ## _vdpau_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_VIDEOTOOLBOX(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(1, 1, 1, VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel)
|
2022-12-18 07:31:03 +00:00
|
|
|
#define HWACCEL_VULKAN(codec) \
|
|
|
|
HW_CONFIG_HWACCEL(1, 1, 1, VULKAN, VULKAN, ff_ ## codec ## _vulkan_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
#define HWACCEL_D3D11VA(codec) \
|
2017-12-08 15:59:39 +00:00
|
|
|
HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD, NONE, ff_ ## codec ## _d3d11va_hwaccel)
|
2023-12-05 06:46:44 +00:00
|
|
|
#define HWACCEL_D3D12VA(codec) \
|
|
|
|
HW_CONFIG_HWACCEL(1, 1, 0, D3D12, D3D12VA, ff_ ## codec ## _d3d12va_hwaccel)
|
2017-10-25 23:18:40 +00:00
|
|
|
|
2020-04-13 15:33:15 +00:00
|
|
|
#define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \
|
|
|
|
&(const AVCodecHWConfigInternal) { \
|
|
|
|
.public = { \
|
|
|
|
.pix_fmt = AV_PIX_FMT_ ## format, \
|
|
|
|
.methods = (device ? AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX : 0) | \
|
|
|
|
(frames ? AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX : 0) | \
|
|
|
|
(ad_hoc ? AV_CODEC_HW_CONFIG_METHOD_AD_HOC : 0), \
|
|
|
|
.device_type = AV_HWDEVICE_TYPE_ ## device_type_, \
|
|
|
|
}, \
|
|
|
|
.hwaccel = NULL, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HW_CONFIG_ENCODER_DEVICE(format, device_type_) \
|
|
|
|
HW_CONFIG_ENCODER(1, 0, 0, format, device_type_)
|
|
|
|
|
|
|
|
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_) \
|
|
|
|
HW_CONFIG_ENCODER(0, 1, 0, format, device_type_)
|
|
|
|
|
2020-04-13 15:33:14 +00:00
|
|
|
#endif /* AVCODEC_HWCONFIG_H */
|