#include "flv.h"
#include "h263.h"
#include "h263_parser.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mpeg_er.h"
#include "mpeg4video.h"
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
.flush = ff_mpeg_flush,
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+ HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+ HWACCEL_VDPAU(mpeg4),
+#endif
+ NULL
+ },
};
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "h264_ps.h"
+#include "hwaccel.h"
#include "mathops.h"
#include "me_cmp.h"
#include "mpegutils.h"
.capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_FRAME_THREADS,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H264_CUVID_HWACCEL
+ HWACCEL_CUVID(h264),
+#endif
+#if CONFIG_H264_DXVA2_HWACCEL
+ HWACCEL_DXVA2(h264),
+#endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+ HWACCEL_D3D11VA(h264),
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA2(h264),
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+ HWACCEL_VAAPI(h264),
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+ HWACCEL_VDPAU(h264),
+#endif
+#if CONFIG_H264_VDA_HWACCEL
+ HW_CONFIG_HWACCEL(0, 0, 1, VDA, NONE, ff_h264_vda_hwaccel),
+#endif
+#if CONFIG_H264_VDA_OLD_HWACCEL
+ HW_CONFIG_HWACCEL(0, 0, 1, VDA_VLD, NONE, ff_h264_vda_old_hwaccel),
+#endif
+ NULL
+ },
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING,
.flush = flush_dpb,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
#include "hevc.h"
#include "hevc_data.h"
#include "hevcdec.h"
+#include "hwaccel.h"
#include "profiles.h"
const uint8_t ff_hevc_qpel_extra_before[4] = { 0, 3, 3, 3 };
AV_CODEC_CAP_FRAME_THREADS,
.profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
.caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_INIT_THREADSAFE,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_HEVC_CUVID_HWACCEL
+ HWACCEL_CUVID(hevc),
+#endif
+#if CONFIG_HEVC_DXVA2_HWACCEL
+ HWACCEL_DXVA2(hevc),
+#endif
+#if CONFIG_HEVC_D3D11VA_HWACCEL
+ HWACCEL_D3D11VA(hevc),
+#endif
+#if CONFIG_HEVC_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA2(hevc),
+#endif
+#if CONFIG_HEVC_VAAPI_HWACCEL
+ HWACCEL_VAAPI(hevc),
+#endif
+#if CONFIG_HEVC_VDPAU_HWACCEL
+ HWACCEL_VDPAU(hevc),
+#endif
+ NULL
+ },
};
#define AVCODEC_HWACCEL_H
#include "avcodec.h"
+#include "hwaccels.h"
#define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
} AVCodecHWConfigInternal;
+// These macros are used to simplify AVCodecHWConfigInternal definitions.
+
+#define HW_CONFIG_HWACCEL(device, frames, ad_hoc, format, device_type_, name) \
+ &(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 = &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_CUVID(codec) \
+ HW_CONFIG_HWACCEL(1, 1, 0, CUDA, CUDA, ff_ ## codec ## _cuvid_hwaccel)
+#define HWACCEL_DXVA2(codec) \
+ HW_CONFIG_HWACCEL(1, 1, 1, DXVA2_VLD, DXVA2, ff_ ## codec ## _dxva2_hwaccel)
+#define HWACCEL_D3D11VA2(codec) \
+ HW_CONFIG_HWACCEL(1, 1, 0, D3D11, D3D11VA, ff_ ## codec ## _d3d11va2_hwaccel)
+#define HWACCEL_VAAPI(codec) \
+ HW_CONFIG_HWACCEL(1, 1, 1, VAAPI, VAAPI, ff_ ## codec ## _vaapi_hwaccel)
+#define HWACCEL_VDPAU(codec) \
+ HW_CONFIG_HWACCEL(1, 1, 1, VDPAU, VDPAU, ff_ ## codec ## _vdpau_hwaccel)
+#define HWACCEL_D3D11VA(codec) \
+ HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD, NONE, ff_ ## codec ## _d3d11va_hwaccel)
+
#endif /* AVCODEC_HWACCEL_H */
--- /dev/null
+/*
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HWACCELS_H
+#define AVCODEC_HWACCELS_H
+
+#include "avcodec.h"
+
+extern AVHWAccel ff_h263_vaapi_hwaccel;
+extern AVHWAccel ff_h264_cuvid_hwaccel;
+extern AVHWAccel ff_h264_d3d11va_hwaccel;
+extern AVHWAccel ff_h264_d3d11va2_hwaccel;
+extern AVHWAccel ff_h264_dxva2_hwaccel;
+extern AVHWAccel ff_h264_vaapi_hwaccel;
+extern AVHWAccel ff_h264_vda_hwaccel;
+extern AVHWAccel ff_h264_vda_old_hwaccel;
+extern AVHWAccel ff_h264_vdpau_hwaccel;
+extern AVHWAccel ff_hevc_cuvid_hwaccel;
+extern AVHWAccel ff_hevc_d3d11va_hwaccel;
+extern AVHWAccel ff_hevc_d3d11va2_hwaccel;
+extern AVHWAccel ff_hevc_dxva2_hwaccel;
+extern AVHWAccel ff_hevc_vaapi_hwaccel;
+extern AVHWAccel ff_hevc_vdpau_hwaccel;
+extern AVHWAccel ff_mpeg1_vdpau_hwaccel;
+extern AVHWAccel ff_mpeg2_d3d11va_hwaccel;
+extern AVHWAccel ff_mpeg2_d3d11va2_hwaccel;
+extern AVHWAccel ff_mpeg2_dxva2_hwaccel;
+extern AVHWAccel ff_mpeg2_vaapi_hwaccel;
+extern AVHWAccel ff_mpeg2_vdpau_hwaccel;
+extern AVHWAccel ff_mpeg4_vaapi_hwaccel;
+extern AVHWAccel ff_mpeg4_vdpau_hwaccel;
+extern AVHWAccel ff_vc1_d3d11va_hwaccel;
+extern AVHWAccel ff_vc1_d3d11va2_hwaccel;
+extern AVHWAccel ff_vc1_dxva2_hwaccel;
+extern AVHWAccel ff_vc1_vaapi_hwaccel;
+extern AVHWAccel ff_vc1_vdpau_hwaccel;
+extern AVHWAccel ff_vp8_vaapi_hwaccel;
+extern AVHWAccel ff_wmv3_d3d11va_hwaccel;
+extern AVHWAccel ff_wmv3_d3d11va2_hwaccel;
+extern AVHWAccel ff_wmv3_dxva2_hwaccel;
+extern AVHWAccel ff_wmv3_vaapi_hwaccel;
+extern AVHWAccel ff_wmv3_vdpau_hwaccel;
+
+#endif /* AVCODEC_HWACCELS_H */
#include <stdatomic.h>
#include "avcodec.h"
+#include "hwaccel.h"
#include "internal.h"
#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
.pix_fmt = AV_PIX_FMT_MMAL,
};
+static const AVCodecHWConfigInternal *mmal_hw_configs = {
+ HW_CONFIG_INTERNAL(MMAL),
+ NULL
+};
+
static const AVOption options[]={
{"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
{"extra_decoder_buffers", "extra MMAL internal buffered frames", offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, \
AV_PIX_FMT_YUV420P, \
AV_PIX_FMT_NONE}, \
+ .hw_configs = mmal_hw_configs, \
.wrapper_name = "mmal", \
};
#include "avcodec.h"
#include "bytestream.h"
#include "error_resilience.h"
+#include "hwaccel.h"
#include "idctdsp.h"
#include "internal.h"
#include "mpeg_er.h"
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_SLICE_THREADS,
.flush = flush,
- .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
+ .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_MPEG1_VDPAU_HWACCEL
+ HWACCEL_VDPAU(mpeg1),
+#endif
+ NULL
+ },
};
AVCodec ff_mpeg2video_decoder = {
AV_CODEC_CAP_SLICE_THREADS,
.flush = flush,
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_MPEG2_DXVA2_HWACCEL
+ HWACCEL_DXVA2(mpeg2),
+#endif
+#if CONFIG_MPEG2_D3D11VA_HWACCEL
+ HWACCEL_D3D11VA(mpeg2),
+#endif
+#if CONFIG_MPEG2_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA2(mpeg2),
+#endif
+#if CONFIG_MPEG2_VAAPI_HWACCEL
+ HWACCEL_VAAPI(mpeg2),
+#endif
+#if CONFIG_MPEG2_VDPAU_HWACCEL
+ HWACCEL_VDPAU(mpeg2),
+#endif
+ NULL
+ },
};
*/
#include "error_resilience.h"
+#include "hwaccel.h"
#include "idctdsp.h"
#include "internal.h"
#include "mpegutils.h"
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_FRAME_THREADS,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_MPEG4_VAAPI_HWACCEL
+ HWACCEL_VAAPI(mpeg4),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+ HWACCEL_VDPAU(mpeg4),
+#endif
+ NULL
+ },
.flush = ff_mpeg_flush,
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles),
#include "qsv_internal.h"
#include "qsvdec.h"
+const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
+ &(const AVCodecHWConfigInternal) {
+ .public = {
+ .pix_fmt = AV_PIX_FMT_QSV,
+ .methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
+ AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
+ .device_type = AV_HWDEVICE_TYPE_QSV,
+ },
+ .hwaccel = NULL,
+ },
+ NULL
+};
+
static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session,
AVBufferRef *hw_frames_ref, AVBufferRef *hw_device_ref)
{
#include "libavutil/pixfmt.h"
#include "avcodec.h"
+#include "hwaccel.h"
#include "qsv_internal.h"
typedef struct QSVContext {
int nb_ext_buffers;
} QSVContext;
+extern const AVCodecHWConfigInternal *ff_qsv_hw_configs[];
+
int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
AVFrame *frame, int *got_frame, AVPacket *pkt);
AV_PIX_FMT_P010,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.bsfs = "hevc_mp4toannexb",
.wrapper_name = "qsv",
};
AV_PIX_FMT_P010,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.bsfs = "h264_mp4toannexb",
.wrapper_name = "qsv",
};
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.wrapper_name = "qsv",
};
#endif
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.wrapper_name = "qsv",
};
#endif
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.wrapper_name = "qsv",
};
#endif
#include "avcodec.h"
#include "blockdsp.h"
#include "get_bits.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mpeg_er.h"
#include "mpegvideo.h"
.flush = ff_mpeg_flush,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.pix_fmts = vc1_hwaccel_pixfmt_list_420,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_VC1_DXVA2_HWACCEL
+ HWACCEL_DXVA2(vc1),
+#endif
+#if CONFIG_VC1_D3D11VA_HWACCEL
+ HWACCEL_D3D11VA(vc1),
+#endif
+#if CONFIG_VC1_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA2(vc1),
+#endif
+#if CONFIG_VC1_VAAPI_HWACCEL
+ HWACCEL_VAAPI(vc1),
+#endif
+#if CONFIG_VC1_VDPAU_HWACCEL
+ HWACCEL_VDPAU(vc1),
+#endif
+ NULL
+ },
.profiles = NULL_IF_CONFIG_SMALL(ff_vc1_profiles)
};
.flush = ff_mpeg_flush,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.pix_fmts = vc1_hwaccel_pixfmt_list_420,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_WMV3_DXVA2_HWACCEL
+ HWACCEL_DXVA2(wmv3),
+#endif
+#if CONFIG_WMV3_D3D11VA_HWACCEL
+ HWACCEL_D3D11VA(wmv3),
+#endif
+#if CONFIG_WMV3_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA2(wmv3),
+#endif
+#if CONFIG_WMV3_VAAPI_HWACCEL
+ HWACCEL_VAAPI(wmv3),
+#endif
+#if CONFIG_WMV3_VDPAU_HWACCEL
+ HWACCEL_VDPAU(wmv3),
+#endif
+ NULL
+ },
.profiles = NULL_IF_CONFIG_SMALL(ff_vc1_profiles)
};
#endif
#include "libavutil/imgutils.h"
#include "avcodec.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mathops.h"
#include "rectangle.h"
.decode = ff_vp8_decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS,
+ .hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_VP8_VAAPI_HWACCEL
+ HWACCEL_VAAPI(vp8),
+#endif
+ NULL
+ },
.flush = vp8_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),