FFmpeg
Data Structures | Macros | Functions | Variables
d3d12va_encode.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/hwcontext_d3d12va_internal.h"
#include "libavutil/hwcontext_d3d12va.h"
#include "avcodec.h"
#include "d3d12va_encode.h"
#include "encode.h"

Go to the source code of this file.

Data Structures

struct  CommandAllocator
 

Macros

#define TRANSITION_BARRIER(res, before, after)
 
#define TRY_RC_MODE(mode, fail)
 

Functions

static int d3d12va_fence_completion (AVD3D12VASyncContext *psync_ctx)
 
static int d3d12va_sync_with_gpu (AVCodecContext *avctx)
 
static int d3d12va_get_valid_command_allocator (AVCodecContext *avctx, ID3D12CommandAllocator **ppAllocator)
 
static int d3d12va_discard_command_allocator (AVCodecContext *avctx, ID3D12CommandAllocator *pAllocator, uint64_t fence_value)
 
static int d3d12va_encode_wait (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int d3d12va_encode_create_metadata_buffers (AVCodecContext *avctx, D3D12VAEncodePicture *pic)
 
static int d3d12va_encode_issue (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int d3d12va_encode_discard (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int d3d12va_encode_free_rc_params (AVCodecContext *avctx)
 
static int d3d12va_encode_init (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static int d3d12va_encode_free (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static int d3d12va_encode_get_buffer_size (AVCodecContext *avctx, D3D12VAEncodePicture *pic, size_t *size)
 
static int d3d12va_encode_get_coded_data (AVCodecContext *avctx, D3D12VAEncodePicture *pic, AVPacket *pkt)
 
static int d3d12va_encode_output (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, AVPacket *pkt)
 
static int d3d12va_encode_set_profile (AVCodecContext *avctx)
 
static int check_rate_control_support (AVCodecContext *avctx, const D3D12VAEncodeRCMode *rc_mode)
 
static int d3d12va_encode_init_rate_control (AVCodecContext *avctx)
 
static int d3d12va_encode_init_gop_structure (AVCodecContext *avctx)
 
static int d3d12va_create_encoder (AVCodecContext *avctx)
 
static int d3d12va_create_encoder_heap (AVCodecContext *avctx)
 
static void d3d12va_encode_free_buffer (void *opaque, uint8_t *data)
 
static AVBufferRefd3d12va_encode_alloc_output_buffer (void *opaque, size_t size)
 
static int d3d12va_encode_prepare_output_buffers (AVCodecContext *avctx)
 
static int d3d12va_encode_create_command_objects (AVCodecContext *avctx)
 
static int d3d12va_encode_create_recon_frames (AVCodecContext *avctx)
 
int ff_d3d12va_encode_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
int ff_d3d12va_encode_init (AVCodecContext *avctx)
 
int ff_d3d12va_encode_close (AVCodecContext *avctx)
 

Variables

const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs []
 
static const D3D12VAEncodeRCMode d3d12va_encode_rc_modes []
 
static const FFHWEncodePictureOperation d3d12va_type
 

Macro Definition Documentation

◆ TRANSITION_BARRIER

#define TRANSITION_BARRIER (   res,
  before,
  after 
)
Value:
(D3D12_RESOURCE_BARRIER) { \
.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, \
.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, \
.Transition = { \
.pResource = res, \
.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, \
.StateBefore = before, \
.StateAfter = after, \
}, \
}

◆ TRY_RC_MODE

#define TRY_RC_MODE (   mode,
  fail 
)
Value:
do { \
if (!(rc_mode->d3d12_mode && check_rate_control_support(avctx, rc_mode))) { \
if (fail) { \
av_log(avctx, AV_LOG_ERROR, "Driver does not support %s " \
"RC mode.\n", rc_mode->name); \
return AVERROR(EINVAL); \
} \
av_log(avctx, AV_LOG_DEBUG, "Driver does not support %s " \
"RC mode.\n", rc_mode->name); \
rc_mode = NULL; \
} else { \
goto rc_mode_found; \
} \
} while (0)

Function Documentation

◆ d3d12va_fence_completion()

static int d3d12va_fence_completion ( AVD3D12VASyncContext psync_ctx)
static

Definition at line 41 of file d3d12va_encode.c.

Referenced by d3d12va_sync_with_gpu().

◆ d3d12va_sync_with_gpu()

static int d3d12va_sync_with_gpu ( AVCodecContext avctx)
static

Definition at line 54 of file d3d12va_encode.c.

Referenced by d3d12va_encode_create_command_objects().

◆ d3d12va_get_valid_command_allocator()

static int d3d12va_get_valid_command_allocator ( AVCodecContext avctx,
ID3D12CommandAllocator **  ppAllocator 
)
static

Definition at line 70 of file d3d12va_encode.c.

Referenced by d3d12va_encode_create_command_objects(), and d3d12va_encode_issue().

◆ d3d12va_discard_command_allocator()

static int d3d12va_discard_command_allocator ( AVCodecContext avctx,
ID3D12CommandAllocator *  pAllocator,
uint64_t  fence_value 
)
static

Definition at line 95 of file d3d12va_encode.c.

Referenced by d3d12va_encode_create_command_objects(), and d3d12va_encode_issue().

◆ d3d12va_encode_wait()

static int d3d12va_encode_wait ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 109 of file d3d12va_encode.c.

Referenced by d3d12va_encode_discard(), and d3d12va_encode_output().

◆ d3d12va_encode_create_metadata_buffers()

static int d3d12va_encode_create_metadata_buffers ( AVCodecContext avctx,
D3D12VAEncodePicture pic 
)
static

Definition at line 142 of file d3d12va_encode.c.

Referenced by d3d12va_encode_issue().

◆ d3d12va_encode_issue()

static int d3d12va_encode_issue ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 188 of file d3d12va_encode.c.

◆ d3d12va_encode_discard()

static int d3d12va_encode_discard ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 511 of file d3d12va_encode.c.

Referenced by d3d12va_encode_free().

◆ d3d12va_encode_free_rc_params()

static int d3d12va_encode_free_rc_params ( AVCodecContext avctx)
static

Definition at line 533 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_close().

◆ d3d12va_encode_init()

static int d3d12va_encode_init ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 558 of file d3d12va_encode.c.

◆ d3d12va_encode_free()

static int d3d12va_encode_free ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 575 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_close().

◆ d3d12va_encode_get_buffer_size()

static int d3d12va_encode_get_buffer_size ( AVCodecContext avctx,
D3D12VAEncodePicture pic,
size_t *  size 
)
static

Definition at line 589 of file d3d12va_encode.c.

Referenced by d3d12va_encode_get_coded_data().

◆ d3d12va_encode_get_coded_data()

static int d3d12va_encode_get_coded_data ( AVCodecContext avctx,
D3D12VAEncodePicture pic,
AVPacket pkt 
)
static

Definition at line 624 of file d3d12va_encode.c.

Referenced by d3d12va_encode_output().

◆ d3d12va_encode_output()

static int d3d12va_encode_output ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic,
AVPacket pkt 
)
static

Definition at line 666 of file d3d12va_encode.c.

◆ d3d12va_encode_set_profile()

static int d3d12va_encode_set_profile ( AVCodecContext avctx)
static

Definition at line 691 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ check_rate_control_support()

static int check_rate_control_support ( AVCodecContext avctx,
const D3D12VAEncodeRCMode rc_mode 
)
static

Definition at line 754 of file d3d12va_encode.c.

◆ d3d12va_encode_init_rate_control()

static int d3d12va_encode_init_rate_control ( AVCodecContext avctx)
static

Definition at line 779 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_encode_init_gop_structure()

static int d3d12va_encode_init_gop_structure ( AVCodecContext avctx)
static

Definition at line 1050 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_create_encoder()

static int d3d12va_create_encoder ( AVCodecContext avctx)
static

Definition at line 1121 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_create_encoder_heap()

static int d3d12va_create_encoder_heap ( AVCodecContext avctx)
static

Definition at line 1148 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_encode_free_buffer()

static void d3d12va_encode_free_buffer ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 1173 of file d3d12va_encode.c.

Referenced by d3d12va_encode_alloc_output_buffer().

◆ d3d12va_encode_alloc_output_buffer()

static AVBufferRef* d3d12va_encode_alloc_output_buffer ( void *  opaque,
size_t  size 
)
static

Definition at line 1181 of file d3d12va_encode.c.

Referenced by d3d12va_encode_prepare_output_buffers().

◆ d3d12va_encode_prepare_output_buffers()

static int d3d12va_encode_prepare_output_buffers ( AVCodecContext avctx)
static

Definition at line 1229 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_encode_create_command_objects()

static int d3d12va_encode_create_command_objects ( AVCodecContext avctx)
static

Definition at line 1263 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ d3d12va_encode_create_recon_frames()

static int d3d12va_encode_create_recon_frames ( AVCodecContext avctx)
static

Definition at line 1339 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

◆ ff_d3d12va_encode_receive_packet()

int ff_d3d12va_encode_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)

Definition at line 1387 of file d3d12va_encode.c.

◆ ff_d3d12va_encode_init()

int ff_d3d12va_encode_init ( AVCodecContext avctx)

Definition at line 1392 of file d3d12va_encode.c.

Referenced by d3d12va_encode_hevc_init().

◆ ff_d3d12va_encode_close()

int ff_d3d12va_encode_close ( AVCodecContext avctx)

Definition at line 1511 of file d3d12va_encode.c.

Referenced by d3d12va_encode_hevc_close().

Variable Documentation

◆ ff_d3d12va_encode_hw_configs

const AVCodecHWConfigInternal* const ff_d3d12va_encode_hw_configs[]
Initial value:
= {
HW_CONFIG_ENCODER_FRAMES(D3D12, D3D12VA),
}

Definition at line 36 of file d3d12va_encode.c.

◆ d3d12va_encode_rc_modes

const D3D12VAEncodeRCMode d3d12va_encode_rc_modes[]
static
Initial value:
= {
{ 0 },
{ RC_MODE_CQP, "CQP", 0, 0, 1, 0, D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP },
{ RC_MODE_CBR, "CBR", 1, 0, 0, 1, D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CBR },
{ RC_MODE_VBR, "VBR", 1, 1, 0, 1, D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_VBR },
{ RC_MODE_QVBR, "QVBR", 1, 1, 1, 1, D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_QVBR },
}

Definition at line 744 of file d3d12va_encode.c.

◆ d3d12va_type

const FFHWEncodePictureOperation d3d12va_type
static
Initial value:

Definition at line 1375 of file d3d12va_encode.c.

Referenced by ff_d3d12va_encode_init().

RC_MODE_CBR
@ RC_MODE_CBR
Definition: d3d12va_encode.h:95
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
RC_MODE_CQP
@ RC_MODE_CQP
Definition: d3d12va_encode.h:94
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
d3d12va_encode_output
static int d3d12va_encode_output(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, AVPacket *pkt)
Definition: d3d12va_encode.c:666
d3d12va_encode_free
static int d3d12va_encode_free(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: d3d12va_encode.c:575
fail
#define fail()
Definition: checkasm.h:188
d3d12va_encode_rc_modes
static const D3D12VAEncodeRCMode d3d12va_encode_rc_modes[]
Definition: d3d12va_encode.c:744
check_rate_control_support
static int check_rate_control_support(AVCodecContext *avctx, const D3D12VAEncodeRCMode *rc_mode)
Definition: d3d12va_encode.c:754
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
d3d12va_encode_issue
static int d3d12va_encode_issue(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
Definition: d3d12va_encode.c:188
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
NULL
#define NULL
Definition: coverity.c:32
RC_MODE_VBR
@ RC_MODE_VBR
Definition: d3d12va_encode.h:96
RC_MODE_QVBR
@ RC_MODE_QVBR
Definition: d3d12va_encode.h:97
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
D3D12VAEncodePicture
Definition: d3d12va_encode.h:42
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:98
d3d12va_encode_init
static int d3d12va_encode_init(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: d3d12va_encode.c:558
mode
mode
Definition: ebur128.h:83
rc_mode
mfxU16 rc_mode
Definition: qsvenc.c:143