23#include "config_components.h"
36 DXVA_PicParams_HEVC
pp;
46 memset(slice, 0,
sizeof(*slice));
47 slice->BSNALunitDataLocation = position;
48 slice->SliceBytesInBuffer =
size;
49 slice->wBadSliceChopping = 0;
82 const HEVCFrame *current_picture =
h->cur_frame;
100#define START_CODE 65536
101#define START_CODE_SIZE 3
106 const HEVCFrame *current_picture =
h->cur_frame;
110 uint8_t *mapped_data, *mapped_ptr;
111 DXVA_Slice_HEVC_Short *slice;
112 D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args;
113 UINT bitstream_size =
ctx->bitstream_size;
115 if (FAILED(ID3D12Resource_Map(
buffer, 0,
NULL, (
void **)&mapped_data))) {
120 mapped_ptr = mapped_data;
125 position = slice->BSNALunitDataLocation;
126 size = slice->SliceBytesInBuffer;
135 slice->BSNALunitDataLocation = mapped_ptr - mapped_data;
143 bitstream_size -=
size;
148 input_args->CompressedBitstream = (D3D12_VIDEO_DECODE_COMPRESSED_BITSTREAM){
151 .Size = mapped_ptr - mapped_data,
154 args = &input_args->FrameArguments[input_args->NumFrameArguments++];
155 args->Type = D3D12_VIDEO_DECODE_ARGUMENT_TYPE_SLICE_CONTROL;
156 args->Size =
sizeof(DXVA_Slice_HEVC_Short) * ctx_pic->
slice_count;
167 int scale = ctx_pic->
pp.dwCodingParamToolFlags & 1;
179 DXVA_PicParams_HEVC pp;
183 ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN10;
188 ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN;
191 av_log(avctx,
AV_LOG_ERROR,
"D3D12 doesn't support PROFILE_HEVC_MAIN_STILL_PICTURE!\n");
197 ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN;
206#if CONFIG_HEVC_D3D12VA_HWACCEL
208 .p.name =
"hevc_d3d12va",
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer)
av_cold int ff_d3d12va_decode_init(AVCodecContext *avctx)
init D3D12VADecodeContext
int ff_d3d12va_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
d3d12va common frame params
av_cold int ff_d3d12va_decode_uninit(AVCodecContext *avctx)
uninit D3D12VADecodeContext
int ff_d3d12va_common_end_frame(AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*update_input_arguments)(AVCodecContext *, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *, ID3D12Resource *))
d3d12va common end frame
#define D3D12VA_DECODE_CONTEXT(avctx)
static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer)
static int d3d12va_hevc_start_frame(AVCodecContext *avctx, av_unused const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
static int d3d12va_hevc_end_frame(AVCodecContext *avctx)
static av_cold int d3d12va_hevc_decode_init(AVCodecContext *avctx)
static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size)
#define AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_STILL_PICTURE
void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_HEVC *pp)
void ff_dxva2_hevc_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_HEVC *qm)
#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
Hardware acceleration should still be attempted for decoding when the codec profile does not match th...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const struct FFHWAccel ff_hevc_d3d12va_hwaccel
static void scale(int *out, const int *in, const int w, const int h, const int shift)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
main external API structure.
int hwaccel_flags
Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated decoding (if active).
This structure is used to provide the necessary configurations and data to the FFmpeg Direct3D 12 HWA...
DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]
const uint8_t * bitstream
void * hwaccel_picture_private
RefStruct reference.
static AVFormatContext * ctx