FFmpeg
Data Structures | Macros | Functions | Variables
d3d12va_encode_hevc.c File Reference
#include "libavutil/opt.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/hwcontext_d3d12va_internal.h"
#include "avcodec.h"
#include "cbs.h"
#include "cbs_h265.h"
#include "h2645data.h"
#include "h265_profile_level.h"
#include "codec_internal.h"
#include "d3d12va_encode.h"

Go to the source code of this file.

Data Structures

struct  D3D12VAEncodeHEVCPicture
 
struct  D3D12VAEncodeHEVCContext
 
struct  D3D12VAEncodeHEVCLevel
 

Macros

#define D3D_PROFILE_DESC(name)   { sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC), { .pHEVCProfile = (D3D12_VIDEO_ENCODER_PROFILE_HEVC *)&profile_ ## name } }
 
#define OFFSET(x)   offsetof(D3D12VAEncodeHEVCContext, x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 
#define PROFILE(name, value)
 
#define LEVEL(name, value)
 

Functions

static uint8_t d3d12va_encode_hevc_map_cusize (D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE cusize)
 
static uint8_t d3d12va_encode_hevc_map_tusize (D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE tusize)
 
static int d3d12va_encode_hevc_write_access_unit (AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
 
static int d3d12va_encode_hevc_add_nal (AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
 
static int d3d12va_encode_hevc_write_sequence_header (AVCodecContext *avctx, char *data, size_t *data_len)
 
static int d3d12va_encode_hevc_init_sequence_params (AVCodecContext *avctx)
 
static int d3d12va_encode_hevc_get_encoder_caps (AVCodecContext *avctx)
 
static int d3d12va_encode_hevc_configure (AVCodecContext *avctx)
 
static int d3d12va_encode_hevc_set_level (AVCodecContext *avctx)
 
static void d3d12va_encode_hevc_free_picture_params (D3D12VAEncodePicture *pic)
 
static int d3d12va_encode_hevc_init_picture_params (AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
 
static int d3d12va_encode_hevc_init (AVCodecContext *avctx)
 
static int d3d12va_encode_hevc_close (AVCodecContext *avctx)
 

Variables

static const D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_config_support_sets []
 
static const D3D12VAEncodeHEVCLevel hevc_levels []
 
static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN
 
static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main10 = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10
 
static const D3D12VAEncodeProfile d3d12va_encode_hevc_profiles []
 
static const D3D12VAEncodeType d3d12va_encode_type_hevc
 
static const AVOption d3d12va_encode_hevc_options []
 
static const FFCodecDefault d3d12va_encode_hevc_defaults []
 
static const AVClass d3d12va_encode_hevc_class
 
const FFCodec ff_hevc_d3d12va_encoder
 

Macro Definition Documentation

◆ D3D_PROFILE_DESC

#define D3D_PROFILE_DESC (   name)    { sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC), { .pHEVCProfile = (D3D12_VIDEO_ENCODER_PROFILE_HEVC *)&profile_ ## name } }

Definition at line 132 of file d3d12va_encode_hevc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(D3D12VAEncodeHEVCContext, x)

Definition at line 915 of file d3d12va_encode_hevc.c.

◆ FLAGS

Definition at line 916 of file d3d12va_encode_hevc.c.

◆ PROFILE

#define PROFILE (   name,
  value 
)
Value:
{ .i64 = value }, 0, 0, FLAGS, "profile"

◆ LEVEL

#define LEVEL (   name,
  value 
)
Value:
{ .i64 = value }, 0, 0, FLAGS, "level"

Function Documentation

◆ d3d12va_encode_hevc_map_cusize()

static uint8_t d3d12va_encode_hevc_map_cusize ( D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE  cusize)
static

◆ d3d12va_encode_hevc_map_tusize()

static uint8_t d3d12va_encode_hevc_map_tusize ( D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE  tusize)
static

Definition at line 152 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_init_sequence_params().

◆ d3d12va_encode_hevc_write_access_unit()

static int d3d12va_encode_hevc_write_access_unit ( AVCodecContext avctx,
char *  data,
size_t *  data_len,
CodedBitstreamFragment au 
)
static

Definition at line 164 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_write_sequence_header().

◆ d3d12va_encode_hevc_add_nal()

static int d3d12va_encode_hevc_add_nal ( AVCodecContext avctx,
CodedBitstreamFragment au,
void *  nal_unit 
)
static

Definition at line 190 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_write_sequence_header().

◆ d3d12va_encode_hevc_write_sequence_header()

static int d3d12va_encode_hevc_write_sequence_header ( AVCodecContext avctx,
char *  data,
size_t *  data_len 
)
static

Definition at line 208 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_init_sequence_params()

static int d3d12va_encode_hevc_init_sequence_params ( AVCodecContext avctx)
static

Definition at line 234 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_get_encoder_caps()

static int d3d12va_encode_hevc_get_encoder_caps ( AVCodecContext avctx)
static

Definition at line 571 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_configure()

static int d3d12va_encode_hevc_configure ( AVCodecContext avctx)
static

Definition at line 647 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_set_level()

static int d3d12va_encode_hevc_set_level ( AVCodecContext avctx)
static

Definition at line 709 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_free_picture_params()

static void d3d12va_encode_hevc_free_picture_params ( D3D12VAEncodePicture pic)
static

Definition at line 739 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_init_picture_params()

static int d3d12va_encode_hevc_init_picture_params ( AVCodecContext avctx,
FFHWBaseEncodePicture base_pic 
)
static

Definition at line 750 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_init()

static int d3d12va_encode_hevc_init ( AVCodecContext avctx)
static

Definition at line 877 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_close()

static int d3d12va_encode_hevc_close ( AVCodecContext avctx)
static

Definition at line 901 of file d3d12va_encode_hevc.c.

Variable Documentation

◆ hevc_config_support_sets

const D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_config_support_sets[]
static

Definition at line 64 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_get_encoder_caps().

◆ hevc_levels

const D3D12VAEncodeHEVCLevel hevc_levels[]
static
Initial value:
= {
{ 30, D3D12_VIDEO_ENCODER_LEVELS_HEVC_1 },
{ 60, D3D12_VIDEO_ENCODER_LEVELS_HEVC_2 },
{ 63, D3D12_VIDEO_ENCODER_LEVELS_HEVC_21 },
{ 90, D3D12_VIDEO_ENCODER_LEVELS_HEVC_3 },
{ 93, D3D12_VIDEO_ENCODER_LEVELS_HEVC_31 },
{ 120, D3D12_VIDEO_ENCODER_LEVELS_HEVC_4 },
{ 123, D3D12_VIDEO_ENCODER_LEVELS_HEVC_41 },
{ 150, D3D12_VIDEO_ENCODER_LEVELS_HEVC_5 },
{ 153, D3D12_VIDEO_ENCODER_LEVELS_HEVC_51 },
{ 156, D3D12_VIDEO_ENCODER_LEVELS_HEVC_52 },
{ 180, D3D12_VIDEO_ENCODER_LEVELS_HEVC_6 },
{ 183, D3D12_VIDEO_ENCODER_LEVELS_HEVC_61 },
{ 186, D3D12_VIDEO_ENCODER_LEVELS_HEVC_62 },
}

Definition at line 113 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_set_level().

◆ profile_main

const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN
static

Definition at line 129 of file d3d12va_encode_hevc.c.

◆ profile_main10

const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main10 = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10
static

Definition at line 130 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_profiles

const D3D12VAEncodeProfile d3d12va_encode_hevc_profiles[]
static
Initial value:

Definition at line 134 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_type_hevc

const D3D12VAEncodeType d3d12va_encode_type_hevc
static
Initial value:
= {
.d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
.default_quality = 25,
.picture_priv_data_size = sizeof(D3D12VAEncodeHEVCPicture),
.init_sequence_params = &d3d12va_encode_hevc_init_sequence_params,
.init_picture_params = &d3d12va_encode_hevc_init_picture_params,
.free_picture_params = &d3d12va_encode_hevc_free_picture_params,
.write_sequence_header = &d3d12va_encode_hevc_write_sequence_header,
}

Definition at line 849 of file d3d12va_encode_hevc.c.

Referenced by d3d12va_encode_hevc_init().

◆ d3d12va_encode_hevc_options

const AVOption d3d12va_encode_hevc_options[]
static

Definition at line 917 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_defaults

const FFCodecDefault d3d12va_encode_hevc_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ "bf", "2" },
{ "g", "120" },
{ "i_qfactor", "1" },
{ "i_qoffset", "0" },
{ "b_qfactor", "1" },
{ "b_qoffset", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ NULL },
}

Definition at line 966 of file d3d12va_encode_hevc.c.

◆ d3d12va_encode_hevc_class

const AVClass d3d12va_encode_hevc_class
static
Initial value:
= {
.class_name = "hevc_d3d12va",
.item_name = av_default_item_name,
}

Definition at line 979 of file d3d12va_encode_hevc.c.

◆ ff_hevc_d3d12va_encoder

const FFCodec ff_hevc_d3d12va_encoder
Initial value:

Definition at line 986 of file d3d12va_encode_hevc.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
d3d12va_encode_hevc_write_sequence_header
static int d3d12va_encode_hevc_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: d3d12va_encode_hevc.c:208
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
d3d12va_encode_hevc_init_sequence_params
static int d3d12va_encode_hevc_init_sequence_params(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:234
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN
Definition: defs.h:159
d3d12va_encode_hevc_class
static const AVClass d3d12va_encode_hevc_class
Definition: d3d12va_encode_hevc.c:979
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:35
D3D12VAEncodeHEVCContext
Definition: d3d12va_encode_hevc.c:41
ff_d3d12va_encode_hw_configs
const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs[]
Definition: d3d12va_encode.c:36
d3d12va_encode_hevc_free_picture_params
static void d3d12va_encode_hevc_free_picture_params(D3D12VAEncodePicture *pic)
Definition: d3d12va_encode_hevc.c:739
d3d12va_encode_hevc_close
static int d3d12va_encode_hevc_close(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:901
d3d12va_encode_hevc_get_encoder_caps
static int d3d12va_encode_hevc_get_encoder_caps(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:571
main
int main
Definition: dovi_rpuenc.c:37
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
D3D12VAEncodeHEVCPicture
Definition: d3d12va_encode_hevc.c:36
FLAGS
#define FLAGS
Definition: d3d12va_encode_hevc.c:916
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
d3d12va_encode_hevc_set_level
static int d3d12va_encode_hevc_set_level(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:709
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PIX_FMT_D3D12
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
Definition: pixfmt.h:440
AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_10
Definition: defs.h:160
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
d3d12va_encode_hevc_init
static int d3d12va_encode_hevc_init(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:877
d3d12va_encode_hevc_options
static const AVOption d3d12va_encode_hevc_options[]
Definition: d3d12va_encode_hevc.c:917
d3d12va_encode_hevc_defaults
static const FFCodecDefault d3d12va_encode_hevc_defaults[]
Definition: d3d12va_encode_hevc.c:966
d3d12va_encode_hevc_init_picture_params
static int d3d12va_encode_hevc_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
Definition: d3d12va_encode_hevc.c:750
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:228
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
D3D_PROFILE_DESC
#define D3D_PROFILE_DESC(name)
Definition: d3d12va_encode_hevc.c:132
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_d3d12va_encode_receive_packet
int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: d3d12va_encode.c:1387
d3d12va_encode_hevc_configure
static int d3d12va_encode_hevc_configure(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:647
d3d12va_encode_hevc_profiles
static const D3D12VAEncodeProfile d3d12va_encode_hevc_profiles[]
Definition: d3d12va_encode_hevc.c:134
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299